Module “propertymodel”¶
- class tc_python.propertymodel.PropertyModelCalculation(calculator)¶
Bases:
AbstractCalculation
Configuration for a Property Model calculation.
Note
Specify the settings, the calculation is performed with
calculate()
.- calculate(timeout_in_minutes: float = 0.0) PropertyModelResult ¶
Runs the Property Model calculation.
- Parameters:
timeout_in_minutes – Used to prevent the calculation from running longer than what is wanted, or from hanging. If the calculation runs longer than timeout_in_minutes, a CalculationEngineException will be thrown.
- Returns:
A
PropertyModelResult
which later can be used to get specific values from the simulation.
- get_argument_default(argument_id: str) object ¶
Returns the default value for the specified argument. The argument id can be obtained with
get_arguments()
.- Parameters:
argument_id – The argument id
- Returns:
The default value (the type depends on the argument)
- get_argument_description(argument_id: str) str ¶
Returns the detailed description of the argument. The id can be obtained with
get_arguments()
.- Parameters:
argument_id – The argument id
- Returns:
The detailed description
- get_arguments() Set[str] ¶
Returns a list of the arguments of the Property Model.
Note
The arguments are the ‘UI-panel components’ defined in the Property Model interface method
provide_ui_panel_components()
. They have the same id as specified in the Property Model. The naming is different because there is no UI present.- Returns:
The ids of the available arguments
- get_dynamic_arguments() Set[str] ¶
Returns a list of the dynamic arguments of the Property Model.
Note
Dynamic arguments are “extra” arguments created by pressing the “plus” button that can occur next to the UI-panel for some models, when running the Property Model from within Thermo-Calc. You can use them also from the API by
invoke_dynamic_argument()
.- Returns:
The ids of the available dynamic arguments
- get_model_description() str ¶
Returns the description text of the current model.
- Returns:
the description
- get_model_parameter_value(model_parameter_id: str) float ¶
Returns the current value of an optimizable model parameter. The id can be obtained with
get_model_parameters()
.- Parameters:
model_parameter_id – The model parameter id
- Returns:
The current value [unit according to the parameter meaning]
- get_model_parameters() Set[str] ¶
Returns a list of the optimizable model parameters.
Note
The model parameters are an optional set of variables that can be used within the Property Model. Typically they are used to provide the possibility to inject parameter values during an optimization into the model. This allows the dynamic development of Property Models that need to be fitted to experimental data. The model parameters are controlled with the Property Model interface methods provide_model_parameters and set_model_parameter.
- Returns:
The ids of the optimizable model parameters
- get_system_data() SystemData ¶
Returns the content of the database for the currently loaded system. This can be used to modify the parameters and functions and to change the current system by using
with_system_modifications()
.Note
Parameters can only be read from unencrypted (i.e. user) databases loaded as *.tdb-file.
- Returns:
The system data
- invoke_dynamic_argument(argument_id: str)¶
Increases the number of instances of this dynamic argument by one, the argument will have an id such as argument_1, argument_2, … if the dynamic argument is called argument.
Note
You can obtain all available dynamic arguments by using
get_dynamic_arguments()
.- Parameters:
argument_id – argument_id: The argument id
- Returns:
This
PropertyModelCalculation
object
- remove_all_conditions()¶
Removes all set classic POLY conditions.
Note
This does not affect the compositions set by
set_composition()
.- Returns:
This
PropertyModelCalculation
object
- remove_dependent_element()¶
Removes a manually set dependent element. This method does not affect the automatic choice of the dependent element if
set_composition()
is used.- Returns:
This
PropertyModelCalculation
object
- set_argument(argument: str, value: str)¶
Sets the specified model argument to the specified value. The id can be obtained with
get_arguments()
.- Parameters:
argument – The argument id
value – The value [unit according to the argument meaning]
- Returns:
This
PropertyModelCalculation
object
- set_composition(element_name: str, value: float)¶
Sets the composition of a element. The unit for the composition can be changed using
set_composition_unit()
.Default: Mole percent (
CompositionUnit.MOLE_PERCENT
)- Parameters:
element_name – The element
value – The composition value [composition unit defined for the calculation]
- Returns:
This
PropertyModelCalculation
object
- set_composition_unit(unit_enum: CompositionUnit = CompositionUnit.MOLE_PERCENT)¶
Sets the composition unit.
Default: Mole percent (
CompositionUnit.MOLE_PERCENT
).- Parameters:
unit_enum – The new composition unit
- Returns:
This
PropertyModelCalculation
object
- set_condition(classic_condition: str, value: float)¶
Adds a classic POLY condition. If that method is used, all conditions need to be specified in such a way. If this method is used, it is necessary to set the dependent element manually using
set_dependent_element()
.Default if not specified: pressure P = 1e5 Pa, system size N = 1, Temperature T = 1000 K
Warning
It is not possible to mix POLY-commands and compositions using
set_composition()
.Note
It should not be necessary for most users to use this method, try to use
set_composition()
instead.Warning
As this method runs raw POLY-commands directly in the engine, it may hang the program in case of spelling mistakes (e.g. forgotten parenthesis, …).
- Parameters:
classic_condition – The classic POLY condition (for example: X(CR))
value – The value of the condition
- Returns:
This
PropertyModelCalculation
object
- set_dependent_element(dependent_element_name: str)¶
Sets the dependent element manually.
Note
It should not be necessary for most users to use this method. Setting the dependent element manually is only necessary and allowed if
set_condition()
is used.- Parameters:
dependent_element_name – The name of the dependent element
- Returns:
This
PropertyModelCalculation
object
- set_model_parameter(model_parameter_id: str, value)¶
Resets an optimizable model parameter. The id can be obtained with
get_model_parameters()
.- Parameters:
model_parameter_id – The model parameter id
value – The new value of the parameter
- Returns:
This
PropertyModelCalculation
object
- set_temperature(temperature: float = 1000)¶
Sets the temperature.
Default: 1000 K
- Parameters:
temperature – The temperature [K]
- Returns:
This
PropertyModelCalculation
object
- with_system_modifications(system_modifications: SystemModifications)¶
Updates the system of this calculator with the supplied system modification (containing new phase parameters and system functions).
Note
This is only possible if the system has been read from unencrypted (i.e. user) databases loaded as a
*.tdb
-file.- Parameters:
system_modifications – The system modification to be performed
- Returns:
This
PropertyModelCalculation
object
- class tc_python.propertymodel.PropertyModelResult(result)¶
Bases:
AbstractResult
The result of a Property Model calculation.
- get_result_quantities() Set[str] ¶
Returns a list of the available result quantities defined in the Property Model.
- Returns:
The ids of the defined result quantities
- get_result_quantity_description(result_quantity_id) str ¶
Returns the detailed description of the result quantity. The id can be obtained by
get_result_quantities()
.- Parameters:
result_quantity_id – The result quantity id
- Returns:
The detailed description
- get_single_equilibrium_result(result_quantity_id: str = '') SingleEquilibriumResult ¶
Returns a result quantity value. The available result quantities can be obtained by
get_result_quantities()
.- Parameters:
result_quantity_id – The id of the result quantity.
- Returns:
The requested value [unit depending on the quantity], if the result is a SingleEquilibriumResult, is returned.
- get_value_of(result_quantity_id: str) Union[float, Dict[str, float]] ¶
Returns a result quantity value. The available result quantities can be obtained by
get_result_quantities()
.- Parameters:
result_quantity_id – The id of the result quantity
- Returns:
The requested value [unit depending on the quantity]. If the result is parameterized, parameter-value pairs are returned.
- save_to_disk(path: str)¶
Saves the result to disk. The result can later be loaded using
tc_python.server.SetUp.load_result_from_disk()
.Note
The result data is represented by a whole folder possibly containing multiple files.
- Parameters:
path – The path to the result folder, can be relative or absolute.
- Returns:
This
PropertyModelResult
object