Tools for interacting with ML models in Python#

The repeat_onnx module is designed to prepare additional descriptions of machine learning models, which are placed in the neutral ONNX format along with the model. This description is used by the following REPEAT VISION platform blocks when loading ML models:

  1. Approximation model (TL) in the library Thermohydraulics;

  2. Approximation model (P) in the Pneumatics library.

An additional description allows the REPEAT VISION platform blocks to uniquely map the input parameters of a machine learning model to the pressures and temperatures of the block nodes. The description also allows one to compare the calculation results on the model’s output parameters with nodal flow rates and energy or enthalpy flows.

An additional description of the ML model must be located in the metadata_props structure under the "repeat_contract" key.

See also

For more information on the requirements for additional descriptions of ML models, see the help for the relevant block:

  1. Approximation model (TL)

  2. Approximation model (P)

The following is an example of an additional description of a machine learning model for use with the Thermohydraulics library blocks of the REPEAT VISION platform.

The example below writes an additional description for a pre-prepared ML model containing 2 nodes and saved in the neutral ONNX format at path.

import onnx
import repeat_onnx  as rx


model_description = rx.ModelTH(
  [
   rx.NodeTH(
     "Input unit", "pressure_1", "temperature_1", 
     "flowrate_1", "enthalpy_flux_1"
     ),
   rx.NodeTH(
     "Output unit", "pressure_2", "temperature_2", 
     "flowrate_2", "enthalpy_flux_2"
     ),
   ]
  )
properties = onnx.StringStringEntryProto()
properties.key = "repeat_contract"
properties.value = model_description.to_onnx()
model = onnx.load(path)
model.metadata_props.append(properties)
onnx.save(model, path)

See also

Please review the documentation on creating ML models using the Python programming language for subsequent integration with the REPEAT VISION platform:

  1. Approximation model of gas flow through a nozzle;

  2. A simple machine learning model of thermal conductivity;

  3. Approximating the solution of an oscillation differential equation using PINN;

Tools for approximation models of thermal hydraulics

The help presents tools for preparing additional descriptions of ML thermal hydraulics models for the ‘Approximation Model (TL)’ block.

Tools for ML models of thermohydraulics
Tools for approximation models of pneumatics

The help provides tools for preparing additional descriptions of ML models of pneumatics for the ‘Approximation Model (P)’ block.

Tools for ML models of pneumatics