pycanha.tmm — Thermal Mathematical Model#

The tmm subpackage provides the high-level classes for building and inspecting thermal models.

The CouplingMatrices class is re-exported from pycanha_core.tmm — see the pycanha_core.tmm — Core Thermal Model Classes page for its full documentation.

Model container#

class pycanha.tmm.ThermalMathematicalModel(name='', nodes=None, conductive=None, radiative=None, parameters=None, formulas=None, thermal_data=None)[source]#

Bases: ThermalMathematicalModel

Parameters:
read_tmd(self, filepath: str, verbose: bool = False) None[source]#

Read an ESATAN TMD file into this model.

Parameters:
Return type:

None

load_tmd(filepath, *, engine='cpp', verbose=False)[source]#
Parameters:
Return type:

Self

classmethod from_esatan_tmd(filepath, name='', *, engine='cpp', verbose=False)[source]#
Parameters:
Return type:

Self

add_conductive_coupling(self, node_1: int, node_2: int, value: float) None#
add_conductive_coupling(self, coupling: pycanha_core.pycanha_core.tmm.Coupling) None

Overloaded function.

  1. add_conductive_coupling(self, node_1: int, node_2: int, value: float) -> None

Add a conductive coupling [W/K] between two nodes.

  1. add_conductive_coupling(self, coupling: pycanha_core.pycanha_core.tmm.Coupling) -> None

Add a conductive coupling from a Coupling object.

add_node(self, node: pycanha_core.pycanha_core.tmm.Node) None#
add_node(self, node_num: int) None

Overloaded function.

  1. add_node(self, node: pycanha_core.pycanha_core.tmm.Node) -> None

Add a Node object to the model.

  1. add_node(self, node_num: int) -> None

Add a default node by user node number.

add_radiative_coupling(self, node_1: int, node_2: int, value: float) None#
add_radiative_coupling(self, coupling: pycanha_core.pycanha_core.tmm.Coupling) None

Overloaded function.

  1. add_radiative_coupling(self, node_1: int, node_2: int, value: float) -> None

Add a radiative coupling [m^2] between two nodes.

  1. add_radiative_coupling(self, coupling: pycanha_core.pycanha_core.tmm.Coupling) -> None

Add a radiative coupling from a Coupling object.

add_temperature_variable(self, name: str, x_data: numpy.ndarray[dtype=float64, shape=(*), order='C'], y_data: numpy.ndarray[dtype=float64, shape=(*), order='C'], interpolation: pycanha_core.pycanha_core.tmm.InterpolationMethod = InterpolationMethod.LINEAR, extrapolation: pycanha_core.pycanha_core.tmm.ExtrapolationMethod = ExtrapolationMethod.CONSTANT) None#

Add a temperature-driven variable (evaluated from a lookup table of temperature).

add_time_variable(self, name: str, x_data: numpy.ndarray[dtype=float64, shape=(*), order='C'], y_data: numpy.ndarray[dtype=float64, shape=(*), order='C'], interpolation: pycanha_core.pycanha_core.tmm.InterpolationMethod = InterpolationMethod.LINEAR, extrapolation: pycanha_core.pycanha_core.tmm.ExtrapolationMethod = ExtrapolationMethod.CONSTANT) None#

Add a time-driven variable (parameter updated from a lookup table of time).

property c_callbacks_active#

Enable/disable C function-pointer callbacks.

callback_solver_loop(self) None#

Execute all registered solver-loop callbacks.

callback_transient_after_timestep(self) None#

Execute all registered after-timestep callbacks.

callback_transient_time_change(self) None#

Execute all registered time-change callbacks.

property callbacks_active#

Master switch to enable/disable all callbacks.

property conductive_couplings#

Reference to the ConductiveCouplings.

property formulas#

Reference to the Formulas collection.

get_temperature_variable(self, name: str) pycanha_core.pycanha_core.tmm.TemperatureVariable#

Get a read-only reference to a temperature variable by name.

get_time_variable(self, name: str) pycanha_core.pycanha_core.tmm.TimeVariable#

Get a read-only reference to a time variable by name.

has_temperature_variable(self, name: str) bool#

Check whether a temperature variable with the given name exists.

has_time_variable(self, name: str) bool#

Check whether a time variable with the given name exists.

property internal_callbacks_active#

Enable/disable internal (C++) callbacks.

property name#

Model name.

property network#

Reference to the ThermalNetwork.

property network_ptr#

Shared pointer to the ThermalNetwork.

property nodes#

Reference to the Nodes container.

property nodes_ptr#

Shared pointer to the Nodes container.

property parameters#

Reference to the Parameters store.

property python_apply_formulas#

Python callable invoked to apply formulas during callbacks.

property python_callbacks_active#

Enable/disable Python callbacks.

property python_extern_callback_solver_loop#

Python callable invoked each solver iteration.

property python_extern_callback_transient_after_timestep#

Python callable invoked after each transient timestep.

property python_extern_callback_transient_time_change#

Python callable invoked when simulation time changes.

property python_formulas_active#

Enable/disable Python formula evaluation during callbacks.

property radiative_couplings#

Reference to the RadiativeCouplings.

remove_temperature_variable(self, name: str) None#

Remove a temperature variable by name.

remove_time_variable(self, name: str) None#

Remove a time variable by name.

property thermal_data#

Reference to the ThermalData store.

property time#

Current simulation time [s].

Nodes#

class pycanha.tmm.Node(*args, **kwargs)[source]#

Bases: Node

property C#

Thermal capacity [J/K].

property T#

Node temperature [K].

property a#

Node area [m^2].

property aph#

Solar absorptivity [-].

property capacity#

Alias for C (thermal capacity) [J/K].

property eps#

IR emissivity [-].

property fx#

Node X coordinate [m].

property fy#

Node Y coordinate [m].

property fz#

Node Z coordinate [m].

int_node_num(self) int#

Return the internal (solver) node index, or -1 if standalone.

property literal_C#

Literal (formula) representation of thermal capacity.

property node_num#

User-assigned node number.

parent_pointer(self) pycanha_core.pycanha_core.tmm.Nodes#

Return the parent Nodes container, or None if standalone.

parent_pointer_address(self) int#

Memory address of the parent Nodes container.

property qa#

Albedo heat load [W].

property qe#

Earth IR heat load [W].

property qi#

Internal dissipation heat load [W].

property qr#

Other (residual) heat load [W].

property qs#

Solar heat load [W].

property type#

Node type (DIFFUSIVE or BOUNDARY).

class pycanha.tmm.Nodes[source]#

Bases: Nodes

add_node(self, node: pycanha_core.pycanha_core.tmm.Node) None#

Add a node to the container.

property estimated_number_of_nodes#

Hint for pre-allocating internal storage.

get_C(self, node_num: int) float#

Get thermal capacity [J/K] of a node.

get_C_value_pointer(self, node_num: int) int#

Memory address of the thermal capacity value for formula binding.

get_T(self, node_num: int) float#

Get temperature [K] of a node.

get_T_value_pointer(self, node_num: int) int#

Memory address of the temperature value for formula binding.

get_a(self, node_num: int) float#

Get area [m^2] of a node.

get_a_value_pointer(self, node_num: int) int#

Memory address of the area value for formula binding.

get_aph(self, node_num: int) float#

Get solar absorptivity [-] of a node.

get_aph_value_pointer(self, node_num: int) int#

Memory address of the solar absorptivity value for formula binding.

get_eps(self, node_num: int) float#

Get IR emissivity [-] of a node.

get_eps_value_pointer(self, node_num: int) int#

Memory address of the IR emissivity value for formula binding.

get_fx(self, node_num: int) float#

Get X coordinate [m] of a node.

get_fx_value_pointer(self, node_num: int) int#

Memory address of the X coordinate value for formula binding.

get_fy(self, node_num: int) float#

Get Y coordinate [m] of a node.

get_fy_value_pointer(self, node_num: int) int#

Memory address of the Y coordinate value for formula binding.

get_fz(self, node_num: int) float#

Get Z coordinate [m] of a node.

get_fz_value_pointer(self, node_num: int) int#

Memory address of the Z coordinate value for formula binding.

get_idx_from_node_num(self, node_num: int) int | None#

Get internal index from user node number, or None if not found.

get_literal_C(self, node_num: int) str#

Get literal (formula) representation of thermal capacity.

get_node_from_idx(self, idx: int) pycanha_core.pycanha_core.tmm.Node#

Get a Node object by internal index.

get_node_from_node_num(self, node_num: int) pycanha_core.pycanha_core.tmm.Node#

Get a Node object by user node number.

get_node_num_from_idx(self, idx: int) int | None#

Get user node number from internal index, or None if invalid.

get_qa(self, node_num: int) float#

Get albedo heat load [W] of a node.

get_qa_value_pointer(self, node_num: int) int#

Memory address of the albedo heat load value for formula binding.

get_qe(self, node_num: int) float#

Get Earth IR heat load [W] of a node.

get_qe_value_pointer(self, node_num: int) int#

Memory address of the Earth IR heat load value for formula binding.

get_qi(self, node_num: int) float#

Get internal dissipation heat load [W] of a node.

get_qi_value_pointer(self, node_num: int) int#

Memory address of the internal heat load value for formula binding.

get_qr(self, node_num: int) float#

Get other (residual) heat load [W] of a node.

get_qr_value_pointer(self, node_num: int) int#

Memory address of the residual heat load value for formula binding.

get_qs(self, node_num: int) float#

Get solar heat load [W] of a node.

get_qs_value_pointer(self, node_num: int) int#

Memory address of the solar heat load value for formula binding.

get_type(self, node_num: int) pycanha_core.pycanha_core.tmm.NodeType#

Get the type of a node (DIFFUSIVE or BOUNDARY).

is_mapped(self) bool#

Check whether the internal node-number map is up to date.

is_node(self, node_num: int) bool#

Check whether a node with the given number exists.

property num_bound_nodes#

Number of boundary nodes.

property num_diff_nodes#

Number of diffusive nodes.

property num_nodes#

Total number of nodes.

remove_node(self, node_num: int) None#

Remove a node by its user node number.

set_C(self, node_num: int, value: float) bool#

Set thermal capacity [J/K] of a node.

set_T(self, node_num: int, value: float) bool#

Set temperature [K] of a node.

set_a(self, node_num: int, value: float) bool#

Set area [m^2] of a node.

set_aph(self, node_num: int, value: float) bool#

Set solar absorptivity [-] of a node.

set_eps(self, node_num: int, value: float) bool#

Set IR emissivity [-] of a node.

set_fx(self, node_num: int, value: float) bool#

Set X coordinate [m] of a node.

set_fy(self, node_num: int, value: float) bool#

Set Y coordinate [m] of a node.

set_fz(self, node_num: int, value: float) bool#

Set Z coordinate [m] of a node.

set_literal_C(self, node_num: int, literal: str) bool#

Set literal (formula) representation of thermal capacity.

set_qa(self, node_num: int, value: float) bool#

Set albedo heat load [W] of a node.

set_qe(self, node_num: int, value: float) bool#

Set Earth IR heat load [W] of a node.

set_qi(self, node_num: int, value: float) bool#

Set internal dissipation heat load [W] of a node.

set_qr(self, node_num: int, value: float) bool#

Set other (residual) heat load [W] of a node.

set_qs(self, node_num: int, value: float) bool#

Set solar heat load [W] of a node.

set_type(self, node_num: int, node_type: pycanha_core.pycanha_core.tmm.NodeType) bool#

Set the type of a node (DIFFUSIVE or BOUNDARY).

pycanha.tmm.NodeType = <enum 'NodeType'>#

DIFFUSIVE or BOUNDARY.

Type:

Thermal node type

Couplings#

class pycanha.tmm.Coupling(*args, **kwargs)[source]#

Bases: Coupling

property node_1#

First node number.

property node_2#

Second node number.

property value#

Conductance value [W/K] or radiative exchange factor [m^2].

class pycanha.tmm.ConductiveCouplings(nodes)[source]#

Bases: ConductiveCouplings

Parameters:

nodes (Nodes)

add_coupling(self, node_num_1: int, node_num_2: int, value: float) None#
add_coupling(self, coupling: pycanha_core.pycanha_core.tmm.Coupling) None

Overloaded function.

  1. add_coupling(self, node_num_1: int, node_num_2: int, value: float) -> None

Add a conductive coupling [W/K] between two nodes.

  1. add_coupling(self, coupling: pycanha_core.pycanha_core.tmm.Coupling) -> None

Add a conductive coupling from a Coupling object.

get_coupling_value(self, node_num_1: int, node_num_2: int) float#

Get the conductive coupling value [W/K] between two nodes.

set_coupling_value(self, node_num_1: int, node_num_2: int, value: float) None#

Set the conductive coupling value [W/K] between two nodes.

class pycanha.tmm.RadiativeCouplings(nodes)[source]#

Bases: RadiativeCouplings

Parameters:

nodes (Nodes)

add_coupling(self, node_num_1: int, node_num_2: int, value: float) None#
add_coupling(self, coupling: pycanha_core.pycanha_core.tmm.Coupling) None

Overloaded function.

  1. add_coupling(self, node_num_1: int, node_num_2: int, value: float) -> None

Add a radiative coupling [m^2] between two nodes.

  1. add_coupling(self, coupling: pycanha_core.pycanha_core.tmm.Coupling) -> None

Add a radiative coupling from a Coupling object.

get_coupling_value(self, node_num_1: int, node_num_2: int) float#

Get the radiative coupling value [m^2] between two nodes.

set_coupling_value(self, node_num_1: int, node_num_2: int, value: float) None#

Set the radiative coupling value [m^2] between two nodes.

class pycanha.tmm.Couplings(nodes)[source]#

Bases: Couplings

Parameters:

nodes (Nodes)

add_coupling(self, node_num_1: int, node_num_2: int, value: float) None#
add_coupling(self, coupling: pycanha_core.pycanha_core.tmm.Coupling) None

Overloaded function.

  1. add_coupling(self, node_num_1: int, node_num_2: int, value: float) -> None

Add a coupling between two nodes.

  1. add_coupling(self, coupling: pycanha_core.pycanha_core.tmm.Coupling) -> None

Add a coupling from a Coupling object.

add_new_coupling(self, node_num_1: int, node_num_2: int, value: float) None#
add_new_coupling(self, coupling: pycanha_core.pycanha_core.tmm.Coupling) None

Overloaded function.

  1. add_new_coupling(self, node_num_1: int, node_num_2: int, value: float) -> None

Add a coupling only if it does not already exist.

  1. add_new_coupling(self, coupling: pycanha_core.pycanha_core.tmm.Coupling) -> None

Add a coupling from a Coupling object only if new.

add_ovw_coupling(self, node_num_1: int, node_num_2: int, value: float) None#
add_ovw_coupling(self, coupling: pycanha_core.pycanha_core.tmm.Coupling) None

Overloaded function.

  1. add_ovw_coupling(self, node_num_1: int, node_num_2: int, value: float) -> None

Add or overwrite a coupling between two nodes.

  1. add_ovw_coupling(self, coupling: pycanha_core.pycanha_core.tmm.Coupling) -> None

Add or overwrite a coupling from a Coupling object.

add_ovw_coupling_verbose(self, node_num_1: int, node_num_2: int, value: float) None#
add_ovw_coupling_verbose(self, coupling: pycanha_core.pycanha_core.tmm.Coupling) None

Overloaded function.

  1. add_ovw_coupling_verbose(self, node_num_1: int, node_num_2: int, value: float) -> None

Add or overwrite a coupling (verbose logging).

  1. add_ovw_coupling_verbose(self, coupling: pycanha_core.pycanha_core.tmm.Coupling) -> None

Add or overwrite a coupling from a Coupling object (verbose).

add_sum_coupling(self, node_num_1: int, node_num_2: int, value: float) None#
add_sum_coupling(self, coupling: pycanha_core.pycanha_core.tmm.Coupling) None

Overloaded function.

  1. add_sum_coupling(self, node_num_1: int, node_num_2: int, value: float) -> None

Add a coupling, summing with any existing value.

  1. add_sum_coupling(self, coupling: pycanha_core.pycanha_core.tmm.Coupling) -> None

Add a coupling from a Coupling object, summing with existing.

add_sum_coupling_verbose(self, node_num_1: int, node_num_2: int, value: float) None#
add_sum_coupling_verbose(self, coupling: pycanha_core.pycanha_core.tmm.Coupling) None

Overloaded function.

  1. add_sum_coupling_verbose(self, node_num_1: int, node_num_2: int, value: float) -> None

Add a coupling, summing with existing (verbose logging).

  1. add_sum_coupling_verbose(self, coupling: pycanha_core.pycanha_core.tmm.Coupling) -> None

Add a coupling from a Coupling object, summing (verbose).

coupling_exists(self, node_num_1: int, node_num_2: int) bool#

Check whether a coupling exists between two nodes.

get_coupling_from_coupling_idx(self, idx: int) pycanha_core.pycanha_core.tmm.Coupling#

Get a Coupling object from a flat coupling index.

get_coupling_matrices(self) pycanha_core.pycanha_core.tmm.CouplingMatrices#

Return a reference to the underlying CouplingMatrices.

get_coupling_value(self, node_num_1: int, node_num_2: int) float#

Get the conductance value between two nodes.

get_coupling_value_address(self, node_num_1: int, node_num_2: int) int#

Memory address (as int) of the coupling value.

get_coupling_value_pointer(self, node_num_1: int, node_num_2: int) int#

Memory address of the coupling value for formula binding.

set_coupling_value(self, node_num_1: int, node_num_2: int, value: float) None#

Set the conductance value between two nodes.

Thermal network#

class pycanha.tmm.ThermalNetwork(nodes=None, conductive=None, radiative=None)[source]#

Bases: ThermalNetwork

Parameters:
add_node(self, node: pycanha_core.pycanha_core.tmm.Node) None#

Add a node to the network.

property conductive_couplings#

Reference to the ConductiveCouplings container.

flow_conductive(self, node_num_1: int, node_num_2: int) float#
flow_conductive(self, node_nums_1: collections.abc.Sequence[int], node_nums_2: collections.abc.Sequence[int]) float

Overloaded function.

  1. flow_conductive(self, node_num_1: int, node_num_2: int) -> float

Compute conductive heat flow [W] between two nodes.

  1. flow_conductive(self, node_nums_1: collections.abc.Sequence[int], node_nums_2: collections.abc.Sequence[int]) -> float

Compute total conductive heat flow [W] between two groups of nodes.

flow_radiative(self, node_num_1: int, node_num_2: int) float#
flow_radiative(self, node_nums_1: collections.abc.Sequence[int], node_nums_2: collections.abc.Sequence[int]) float

Overloaded function.

  1. flow_radiative(self, node_num_1: int, node_num_2: int) -> float

Compute radiative heat flow [W] between two nodes.

  1. flow_radiative(self, node_nums_1: collections.abc.Sequence[int], node_nums_2: collections.abc.Sequence[int]) -> float

Compute total radiative heat flow [W] between two groups of nodes.

property nodes#

Reference to the Nodes container.

property nodes_ptr#

Shared pointer to the Nodes container.

property radiative_couplings#

Reference to the RadiativeCouplings container.

remove_node(self, node_num: int) None#

Remove a node from the network by user node number.

Thermal data#

class pycanha.tmm.ThermalData(network=None)[source]#

Bases: ThermalData

Parameters:

network (pcc.tmm.ThermalNetwork | None)

associate(self, network: pycanha_core.pycanha_core.tmm.ThermalNetwork) None#

Associate this ThermalData with a ThermalNetwork.

property models#

Reference to the transient output model store.

property network#

Reference to the associated ThermalNetwork.

property network_ptr#

Shared pointer to the associated ThermalNetwork.

property size#

Total number of stored data objects.

property tables#

Reference to the lookup-table store.