Example of transient temperature with 3t solver and OLLA model
In [1]:
Copied!
import matplotlib
matplotlib.use("nbagg")
import matplotlib.pyplot as plt
import numpy as np
from thermohl import solver
from thermohl.solver.entities import HeatEquationType
from thermohl.solver.entities import VariableType
from thermohl.solver.entities import TemperatureType
import matplotlib
matplotlib.use("nbagg")
import matplotlib.pyplot as plt
import numpy as np
from thermohl import solver
from thermohl.solver.entities import HeatEquationType
from thermohl.solver.entities import VariableType
from thermohl.solver.entities import TemperatureType
Plot conductor temperatures (surface, average and core) when a step of transit occurs. Simulation made with the 3t solver and RTE power terms.
In [2]:
Copied!
# Define input dict (for the sake of simplicity, only a few inputs are
# used, the rest is filled with default values).
parameters = {
"latitude": 46.1,
"altitude": 123.0,
"azimuth": 31.0,
"datetime_utc": np.datetime64("2026-06-20T00:00:00"),
"transit": 700.0,
}
time = np.linspace(0, 3600, 901)
# Define input dict (for the sake of simplicity, only a few inputs are
# used, the rest is filled with default values).
parameters = {
"latitude": 46.1,
"altitude": 123.0,
"azimuth": 31.0,
"datetime_utc": np.datetime64("2026-06-20T00:00:00"),
"transit": 700.0,
}
time = np.linspace(0, 3600, 901)
In [3]:
Copied!
# Create solver with rte power terms and 3t heat equation
solver_rte = solver.rte(parameters, heat_equation=HeatEquationType.THREE_TEMPERATURES)
# Change solver args to get initial state,
# compute initial values of surface and core temperature using steady temperature
solver_rte.args[VariableType.TRANSIT.value] = 400.0
solver_rte.update() # Don't forget to call this method after changing solver args
steady_temperature = solver_rte.steady_temperature()
surface_steady_temperature = steady_temperature[TemperatureType.SURFACE.value]
core_steady_temperature = steady_temperature[TemperatureType.CORE.value]
# Restore initial transit in parameters
solver_rte.args[VariableType.TRANSIT.value] = parameters[VariableType.TRANSIT.value]
solver_rte.update()
# Compute temperature
transient_temperature = solver_rte.transient_temperature(
time,
surface_temperature_0=surface_steady_temperature,
core_temperature_0=core_steady_temperature,
return_power=True,
)
# plot
fig, ax = plt.subplots(nrows=1, ncols=1)
tm = time / 60
ax.fill_between(
tm, transient_temperature[TemperatureType.SURFACE.value], transient_temperature[TemperatureType.SURFACE.value], fc="gray", alpha=0.33, ec=None
)
ax.plot(tm, transient_temperature[TemperatureType.SURFACE.value], c="C0", label="Surface Conductor temperature (C)")
ax.plot(tm, transient_temperature[TemperatureType.AVERAGE.value], c="C1", label="average Conductor temperature (C)")
ax.plot(tm, transient_temperature[TemperatureType.CORE.value], c="C3", label="Core Conductor temperature (C)")
ax.set_xlabel("Time (hour)")
ax.set_ylabel("Temperature (C)")
ax.grid(True)
ax.legend()
%matplotlib inline
plt.show()
# Create solver with rte power terms and 3t heat equation
solver_rte = solver.rte(parameters, heat_equation=HeatEquationType.THREE_TEMPERATURES)
# Change solver args to get initial state,
# compute initial values of surface and core temperature using steady temperature
solver_rte.args[VariableType.TRANSIT.value] = 400.0
solver_rte.update() # Don't forget to call this method after changing solver args
steady_temperature = solver_rte.steady_temperature()
surface_steady_temperature = steady_temperature[TemperatureType.SURFACE.value]
core_steady_temperature = steady_temperature[TemperatureType.CORE.value]
# Restore initial transit in parameters
solver_rte.args[VariableType.TRANSIT.value] = parameters[VariableType.TRANSIT.value]
solver_rte.update()
# Compute temperature
transient_temperature = solver_rte.transient_temperature(
time,
surface_temperature_0=surface_steady_temperature,
core_temperature_0=core_steady_temperature,
return_power=True,
)
# plot
fig, ax = plt.subplots(nrows=1, ncols=1)
tm = time / 60
ax.fill_between(
tm, transient_temperature[TemperatureType.SURFACE.value], transient_temperature[TemperatureType.SURFACE.value], fc="gray", alpha=0.33, ec=None
)
ax.plot(tm, transient_temperature[TemperatureType.SURFACE.value], c="C0", label="Surface Conductor temperature (C)")
ax.plot(tm, transient_temperature[TemperatureType.AVERAGE.value], c="C1", label="average Conductor temperature (C)")
ax.plot(tm, transient_temperature[TemperatureType.CORE.value], c="C3", label="Core Conductor temperature (C)")
ax.set_xlabel("Time (hour)")
ax.set_ylabel("Temperature (C)")
ax.grid(True)
ax.legend()
%matplotlib inline
plt.show()