NumericHandler¶
- class simu.NumericHandler¶
This class implements the function object describing the top level model.
- __init__(
- model: ModelProxy,
- port_properties: bool = True,
The option
port_propertiesdetermines whether the properties of connected materials are also reported from a child model’s perspective by the name of their ports.
- property function: QFunction¶
Create a Function object based on currently available argument and result structures.
- property arguments: Mapping[str, Quantity]¶
The function arguments as numerical values. A DataFlowError is thrown, if not all numerical values are known. A deepcopy of the structure is provided, so the returned data can be altered without side effects.
- export_state() NestedMutMap[str]¶
Export the internal state of the model in a hierarchical structure, whereas all thermodynamic states are given in \(T, p, n\).
As by the philosophy of the chosen approach, only the thermodynamic models know how to obtain their internal state from any \(T, p, n\) specification.
The returned structure is meant to be easy to store for instance in yaml or json format, and easy to edit. One can use
parse_quantities_in_struct()to convert the values of the data structure intoQuantityobjects for programmatic processing.
- import_state( ) NestedMap[str]¶
Imports the state data in terms of \(T, p, n\) as exported by
export_state().- Parameters:
state – A nested mapping as returned by
export_state(), containing the two first-level keysthermo(for thermodynamic states) andnon-canonicalfor non-canonical states.allow_missing – If true, throw a
ValueErrorif there are model states in the model that are not defined in the givenstatestructure.allow_extra – If false, throw a
ValueErrorif there are states in the givenstatestructure that are not present in the model.
- Returns:
A nested mapping of same structure as
state, but containing states that are not present in the model (value =extra) and states that were not given as part ofstate(value =missing)
- retain_state( )¶
Given a numeric
statevector and the current set ofparametersas a nested mapping of quantities, store the values for temperature, pressure and molar quantities back into the internal representations of the initial thermodynamic states.
- extract_parameters( ) Quantity¶
collect the parameter symbols addressed by the
definitionargument, which defines the unit of measurement for each parameter - as the numerical parameter vector elements must be considered dimensionless.Note
Unfortunately, we cannot easily allow unit conversion (even compatible units) at this point, as the parameters are already independent variables used to build up the symbolic graph. Well, it can be done by first building the original function, and then call the function as f(c(x)), where c(x) is the unit conversion.
These parameter symbols and values are then removed from the original argument structure and instead added to the vector entry as dimensionless entities.
- Parameters:
key – The name to be used for the parameter set
definition – The parameters to be extracted