pycanha_core.parameters — Parameters and Formulas#
The parameters submodule provides the core parameter storage and formula
binding types used by the thermal model.
Parameters#
- class Parameters(*args, **kwargs)#
Bases:
objectNamed parameter store for parametric studies.
Stores values of type bool, int, float, str, or numpy array, keyed by string name. Used with Formulas to propagate parameter changes to the thermal network.
- __init__#
Create an empty Parameters store.
- add_parameter#
Add a new named parameter with the given value.
- contains#
Check whether a parameter with the given name exists.
- property data#
Dictionary of all parameter name-value pairs.
- get_idx#
Get the internal index of a parameter by name.
- get_memory_address#
Memory address (as int) of a parameter value for formula binding.
- get_parameter#
Get the current value of a parameter.
- get_size_of_parameter#
Get the byte size of a parameter’s stored value.
- remove_parameter#
Remove a parameter by name.
- set_parameter#
Update the value of an existing parameter.
- size#
Return the number of stored parameters.
Entities#
Formulas#
- class Formula#
Bases:
objectAbstract base class for formulas that bind parameter values to thermal entities.
- __init__(*args, **kwargs)#
- apply_compiled_formula#
Evaluate and write using pre-compiled pointers (faster).
- apply_formula#
Evaluate and write the formula result to the entity.
- calculate_derivatives#
Calculate derivative values with respect to parameter dependencies.
- clone#
Create an independent copy of this formula.
- compile_formula#
Compile the formula (resolve pointers for fast evaluation).
- property entity#
Reference to the target ThermalEntity.
- get_derivative_values#
Get derivative values for sensitivity analysis, or None.
- get_value#
Get the current computed value of the formula.
- property parameter_dependencies#
List of parameter names this formula depends on.
- class ParameterFormula(*args, **kwargs)#
Bases:
FormulaFormula that copies a named parameter value to an entity.
When applied, sets entity value = parameter value.
- __init__#
Overloaded function.
__init__(self, entity: pycanha_core.pycanha_core.parameters.ThermalEntity, parameters: pycanha_core.pycanha_core.parameters.Parameters, parameter: str) -> None
Create a formula linking entity to a named parameter.
__init__(self, entity: pycanha_core.pycanha_core.parameters.ThermalEntity, parameters: pycanha_core.pycanha_core.parameters.Parameters, parameter: str) -> None
Create a formula linking entity (shared_ptr) to a named parameter.
- apply_compiled_formula#
Evaluate and write using pre-compiled pointers (faster).
- apply_formula#
Evaluate and write the parameter value to the entity.
- compile_formula#
Compile the formula (resolve pointers for fast evaluation).
- get_derivative_values#
Get derivative values for sensitivity analysis, or None.
- get_value#
Get the current parameter value.
- class ValueFormula(*args, **kwargs)#
Bases:
FormulaFormula that assigns a fixed constant value to an entity.
- __init__#
Overloaded function.
__init__(self, entity: pycanha_core.pycanha_core.parameters.ThermalEntity) -> None
Create a value formula for the given entity.
__init__(self, entity: pycanha_core.pycanha_core.parameters.ThermalEntity) -> None
Create a value formula for the given entity (shared_ptr).
- apply_compiled_formula#
Write using pre-compiled pointers (faster).
- apply_formula#
Write the constant value to the entity.
- compile_formula#
Compile the formula (resolve pointers for fast evaluation).
- get_derivative_values#
Get derivative values for sensitivity analysis, or None.
- get_value#
Get the stored constant value.
- set_value#
Set the constant value to assign.
- class ExpressionFormula(*args, **kwargs)#
Bases:
FormulaFormula that evaluates a scalar expression of named parameters.
- __init__#
Overloaded function.
__init__(self, entity: pycanha_core.pycanha_core.parameters.ThermalEntity, parameters: pycanha_core.pycanha_core.parameters.Parameters, expression: str) -> None
Create an expression formula for the given entity.
__init__(self, entity: pycanha_core.pycanha_core.parameters.ThermalEntity, parameters: pycanha_core.pycanha_core.parameters.Parameters, expression: str) -> None
Create an expression formula for the given entity (shared_ptr).
- apply_compiled_formula#
Evaluate the compiled expression and write the result to the entity.
- apply_formula#
Evaluate the expression and write the result to the entity.
- compile_formula#
Compile the expression for fast repeated evaluation.
- property expression#
Original expression string.
- get_derivative_values#
Get derivative values for sensitivity analysis, or None.
- get_value#
Get the current expression value.
- class Formulas(*args, **kwargs)#
Bases:
objectCollection of formulas linking parameters to thermal entities. Call apply_formulas() to propagate parameter changes to the network.
- __init__#
Overloaded function.
__init__(self) -> None
Create an empty Formulas collection.
__init__(self, network: pycanha_core.pycanha_core.tmm.ThermalNetwork, parameters: pycanha_core.pycanha_core.parameters.Parameters) -> None
Create a Formulas collection with associated network and parameters.
- add_formula#
Overloaded function.
add_formula(self, formula: pycanha_core.pycanha_core.parameters.Formula) -> None
Add a formula (by copy) to the collection.
add_formula(self, formula: pycanha_core.pycanha_core.parameters.Formula) -> None
Add a formula (by shared pointer) to the collection.
- apply_formulas#
Apply all formulas, propagating parameter values to the network.
- associate#
Associate this collection with a network and parameters store.
- calculate_derivatives#
Calculate derivatives for all stored formulas.
- create_parameter_formula#
Create and add a ParameterFormula for the entity and parameter name.
- property formulas#
List of all stored Formula objects.
- property parameter_dependencies#
Dict mapping parameter names to lists of dependent formulas.