Building a Thermal Model#
A thermal mathematical model (TMM) in pycanha consists of two main parts: nodes and couplings. Optionally, you can define parameters and formulas to link model quantities to parameters.
Creating a model#
Every analysis starts by instantiating a
ThermalMathematicalModel:
from pycanha.tmm import ThermalMathematicalModel
tmm = ThermalMathematicalModel("MyModel")
Adding nodes#
Nodes represent lumped thermal masses with a temperature. Each node has a unique integer
identifier (node_num) and several attributes like thermal capacity and heat loads.
Nodes are either diffusive (temperature computed by the solver) or boundary.
from pycanha.tmm import Node, NodeType
# Diffusive node (temperature computed by solver)
node1 = Node(1)
node1.C = 1000.0 # capacity [J/K]
node1.qi = 50.0 # internal dissipation [W]
# Boundary node (temperature fixed)
node2 = Node(2)
node2.type = NodeType.BOUNDARY
node2.T = 300.0 # fixed temperature [K]
tmm.add_node(node1)
tmm.add_node(node2)
Note
Internally, nodes are auto-sorted so that all diffusive nodes come before
all boundary nodes. Use get_idx_from_node_num()
to map between user node numbers and internal indices. This internal order is
not guaranteed to remain as described here, so don’t rely on it in your code.
Node attributes#
Each node exposes the following scalar attributes:
Attribute |
Description |
Default |
|---|---|---|
|
Temperature [K] |
0.0 |
|
Thermal capacity [J/K] |
0.0 |
|
Internal dissipation [W] |
0.0 |
|
Solar absorbed heat [W] |
0.0 |
|
Albedo absorbed heat [W] |
0.0 |
|
Earth IR absorbed heat [W] |
0.0 |
|
Other heat loads [W] |
0.0 |
|
Emissivity |
0.0 |
|
Absorptivity |
0.0 |
|
User-defined auxiliary floats (e.g. position) |
0.0 |
Adding couplings#
Couplings define the heat exchange between nodes.
# Conductive coupling: GL(1,2) = 0.5 W/K
tmm.conductive_couplings.add_coupling(1, 2, 0.5)
# Radiative coupling: GR(1,2) = 1e-7 m^2
tmm.radiative_couplings.add_coupling(1, 2, 1.0e-7)
Conductive couplings produce a heat flow proportional to the temperature difference: \(Q = GL \cdot (T_1 - T_2)\).
Radiative couplings produce a heat flow proportional to the difference of fourth powers: \(Q = \sigma \cdot GR \cdot (T_1^4 - T_2^4)\).
Accessing the thermal network#
The model exposes its internal containers through properties:
tmm.nodes # Nodes container
tmm.conductive_couplings # ConductiveCouplings container
tmm.radiative_couplings # RadiativeCouplings container
tmm.network # ThermalNetwork (nodes + couplings)
tmm.parameters # Parameters storage
tmm.formulas # Formulas collection
tmm.thermal_data # ThermalData result tables