YAC 3.21.0
Yet Another Coupler
Loading...
Searching...
No Matches
ml_coupler.MLCoupler Class Reference

Encapsulates YAC setup and exchange for the ml_predictor component. More...

Collaboration diagram for ml_coupler.MLCoupler:
Collaboration graph

Public Member Functions

 __init__ (self, str component_name="ml_predictor")
 Initialize the YAC coupler for the ml_predictor component.
 
 setup (self, str grid_name, np.ndarray x_vertices, np.ndarray y_vertices)
 Define the 2D regular grid and fields for the ml_predictor component.
 
bool has_data (self)
 
bool heat_flux_is_coupled (self)
 Whether heat_flux is actually coupled back to the simulation component.
 
str datetime (self)
 Return the current datetime of the next exchange (temperature is used as a reference).
 
np.ndarray|None recv_temperature (self)
 Receive the temperature field from the Fortran component.
 
 send_heat_flux (self, np.ndarray heat_flux)
 Send the predicted heat flux back to the Fortran component.
 
 finalize (self)
 Finalize the YAC coupler and clean up resources.
 

Data Fields

 component_name
 
 yac
 
 comp
 
 temp_field
 
 heat_flux_field
 
 heat_flux_is_coupled
 

Detailed Description

Encapsulates YAC setup and exchange for the ml_predictor component.

Definition at line 11 of file ml_coupler.py.

Constructor & Destructor Documentation

◆ __init__()

ml_coupler.MLCoupler.__init__ ( self,
str component_name = "ml_predictor" )

Initialize the YAC coupler for the ml_predictor component.

Parameters
[in]component_nameName of the component for registration in YAC

Definition at line 16 of file ml_coupler.py.

Member Function Documentation

◆ datetime()

str ml_coupler.MLCoupler.datetime ( self)

Return the current datetime of the next exchange (temperature is used as a reference).

Returns
The current datetime of the next exchange as an ISO 8601 string (e.g., "2024-01-01T00:00:00Z")

Definition at line 79 of file ml_coupler.py.

◆ finalize()

ml_coupler.MLCoupler.finalize ( self)

Finalize the YAC coupler and clean up resources.

Definition at line 120 of file ml_coupler.py.

Here is the call graph for this function:

◆ has_data()

bool ml_coupler.MLCoupler.has_data ( self)

Definition at line 63 of file ml_coupler.py.

◆ heat_flux_is_coupled()

bool ml_coupler.MLCoupler.heat_flux_is_coupled ( self)

Whether heat_flux is actually coupled back to the simulation component.

A one-way (training) configuration only couples temperature, in which case heat_flux's role is ExchangeType.NONE instead of ExchangeType.SOURCE.

Returns
True if heat_flux should be sent via send_heat_flux

Definition at line 67 of file ml_coupler.py.

◆ recv_temperature()

np.ndarray | None ml_coupler.MLCoupler.recv_temperature ( self)

Receive the temperature field from the Fortran component.

Returns
The temperature values, or None if no data was received.

Definition at line 89 of file ml_coupler.py.

◆ send_heat_flux()

ml_coupler.MLCoupler.send_heat_flux ( self,
np.ndarray heat_flux )

Send the predicted heat flux back to the Fortran component.

Only call this if heat_flux_is_coupled is True; otherwise there is no coupling configured for heat_flux to send data on (e.g. during a one-way training run).

Parameters
[in]heat_fluxThe predicted heat flux values to send back.

Definition at line 103 of file ml_coupler.py.

◆ setup()

ml_coupler.MLCoupler.setup ( self,
str grid_name,
np.ndarray x_vertices,
np.ndarray y_vertices )

Define the 2D regular grid and fields for the ml_predictor component.

Parameters
[in]grid_nameName of the grid for registration in YAC
[in]x_verticesX coordinates of the grid vertices
[in]y_verticesY coordinates of the grid vertices

Definition at line 30 of file ml_coupler.py.

Field Documentation

◆ comp

ml_coupler.MLCoupler.comp

Definition at line 24 of file ml_coupler.py.

◆ component_name

ml_coupler.MLCoupler.component_name

Definition at line 22 of file ml_coupler.py.

◆ heat_flux_field

ml_coupler.MLCoupler.heat_flux_field

Definition at line 26 of file ml_coupler.py.

◆ heat_flux_is_coupled

ml_coupler.MLCoupler.heat_flux_is_coupled

Definition at line 113 of file ml_coupler.py.

◆ temp_field

ml_coupler.MLCoupler.temp_field

Definition at line 25 of file ml_coupler.py.

◆ yac

ml_coupler.MLCoupler.yac

Definition at line 23 of file ml_coupler.py.


The documentation for this class was generated from the following file: