Example of steady temperature with 1t solver, all models and all parameters
In [1]:
Copied!
import numpy as np
import matplotlib.pyplot as plt
from thermohl.solver.entities import VariableType
from thermohl.solver.entities import ModelType
from thermohl.solver.entities import HeatEquationType
from thermohl.solver.entities import PowerType
from thermohl import solver
import numpy as np
import matplotlib.pyplot as plt
from thermohl.solver.entities import VariableType
from thermohl.solver.entities import ModelType
from thermohl.solver.entities import HeatEquationType
from thermohl.solver.entities import PowerType
from thermohl import solver
In [2]:
Copied!
# time array in hours
hour = np.linspace(0, 24, 241)[:-1]
minute = np.linspace(0, 24 * 60, 241)[:-1].astype(int)
# time array in hours
hour = np.linspace(0, 24, 241)[:-1]
minute = np.linspace(0, 24 * 60, 241)[:-1].astype(int)
We can modify the values of the parameters' dictionnary if we don't want to use the default values. Missing or None values in the input dictionary are replaced with a default value, available using solver.default_values()
In [3]:
Copied!
# input dict, with varying transit, ambient temperature and wind speed
parameters = {
# position
"latitude": 45.2,
"longitude": 0.0,
"altitude": 543.0,
"cable_azimuth": 21.0,
"datetime_utc": np.array([np.datetime64(f"2026-06-20T{minute // 60:02d}:{minute % 60:02d}:00") for minute in minute]),
# weather
"ambient_temperature": 10.0 + 7.5 * (1 + np.sin(np.pi * (hour - 7.0) / 12.0)),
"wind_speed": np.piecewise(hour, [hour <= 6.0, hour > 6.0, hour > 12.0, hour >= 18.0], [1.0, 2.0, 1.0, 3.0]),
"wind_azimuth": 69,
"albedo": 0.21,
"turbidity": 0.5,
# transit
"transit": np.piecewise(hour, [hour < 12.0, hour >= 12.0], [300.0, 600.0]),
# conductor
"core_diameter": 0.0,
"outer_diameter": 3.0e-02,
"core_area": 0.0,
"outer_area": 5.69e-04,
"roughness_ratio": 6.30e-02,
"solar_absorptivity": 0.9,
"emissivity": 0.8,
"linear_resistance_dc_20c": 5.84e-05,
"magnetic_coeff": 1.02,
"magnetic_coeff_per_a": 0.01,
"temperature_coeff_linear": 4.0e-03,
"temperature_coeff_quadratic": 8.0e-07,
"linear_resistance_temp_high": 6.7744e-05,
"linear_resistance_temp_low": 5.84e-05,
"temp_high": 60.0,
"temp_low": 20.0,
}
# input dict, with varying transit, ambient temperature and wind speed
parameters = {
# position
"latitude": 45.2,
"longitude": 0.0,
"altitude": 543.0,
"cable_azimuth": 21.0,
"datetime_utc": np.array([np.datetime64(f"2026-06-20T{minute // 60:02d}:{minute % 60:02d}:00") for minute in minute]),
# weather
"ambient_temperature": 10.0 + 7.5 * (1 + np.sin(np.pi * (hour - 7.0) / 12.0)),
"wind_speed": np.piecewise(hour, [hour <= 6.0, hour > 6.0, hour > 12.0, hour >= 18.0], [1.0, 2.0, 1.0, 3.0]),
"wind_azimuth": 69,
"albedo": 0.21,
"turbidity": 0.5,
# transit
"transit": np.piecewise(hour, [hour < 12.0, hour >= 12.0], [300.0, 600.0]),
# conductor
"core_diameter": 0.0,
"outer_diameter": 3.0e-02,
"core_area": 0.0,
"outer_area": 5.69e-04,
"roughness_ratio": 6.30e-02,
"solar_absorptivity": 0.9,
"emissivity": 0.8,
"linear_resistance_dc_20c": 5.84e-05,
"magnetic_coeff": 1.02,
"magnetic_coeff_per_a": 0.01,
"temperature_coeff_linear": 4.0e-03,
"temperature_coeff_quadratic": 8.0e-07,
"linear_resistance_temp_high": 6.7744e-05,
"linear_resistance_temp_low": 5.84e-05,
"temp_high": 60.0,
"temp_low": 20.0,
}
In [4]:
Copied!
# compute steady_temperature using 1t heat equation and Rte model
solver_rte = solver.rte(parameters, heat_equation=HeatEquationType.ONE_TEMPERATURE)
steady_temperature = solver_rte.steady_temperature()
# compute steady_temperature using 1t heat equation and Rte model
solver_rte = solver.rte(parameters, heat_equation=HeatEquationType.ONE_TEMPERATURE)
steady_temperature = solver_rte.steady_temperature()
In [5]:
Copied!
# Compute steady temperature and power terms using all 4 models,
# using 1t heat equation
models = [
ModelType.CIGRE,
ModelType.IEEE,
ModelType.OLLA,
ModelType.RTE,
]
solvers = [
solver._factory(
parameters, heat_equation=HeatEquationType.ONE_TEMPERATURE, model=model
)
for model in models
]
results = [s.steady_temperature(return_power=True) for s in solvers]
# Compute steady temperature and power terms using all 4 models,
# using 1t heat equation
models = [
ModelType.CIGRE,
ModelType.IEEE,
ModelType.OLLA,
ModelType.RTE,
]
solvers = [
solver._factory(
parameters, heat_equation=HeatEquationType.ONE_TEMPERATURE, model=model
)
for model in models
]
results = [s.steady_temperature(return_power=True) for s in solvers]
In [6]:
Copied!
# plot all
fig, ax = plt.subplots(nrows=2, ncols=4, figsize=(20, 10))
for i, key in enumerate([VariableType.TRANSIT.value, "ambient_temperature", "wind_speed"]):
ax[0, i].plot(hour, parameters[key])
ax[0, i].set_title(f"Input {key}")
ax[0, 3].set_title("Conductor temperature")
for i, r in enumerate(results):
ci = f"C{1 + i}"
ax[0, 3].plot(hour, r[VariableType.TEMPERATURE.value], c=ci, label=models[i])
for j, p in enumerate(
[
PowerType.JOULE,
PowerType.SOLAR,
PowerType.CONVECTION,
PowerType.RADIATION,
]
):
ax[1, j].plot(hour, r[p.value], c=ci, label=models[i])
ax[1, j].set_title(f"{p.value} (W/m)")
for i in range(ax.shape[0]):
for j in range(ax.shape[1]):
ax[i, j].set_xlabel("Time (hour)")
ax[i, j].grid(True)
ax[-1, -1].legend()
%matplotlib inline
# plot all
fig, ax = plt.subplots(nrows=2, ncols=4, figsize=(20, 10))
for i, key in enumerate([VariableType.TRANSIT.value, "ambient_temperature", "wind_speed"]):
ax[0, i].plot(hour, parameters[key])
ax[0, i].set_title(f"Input {key}")
ax[0, 3].set_title("Conductor temperature")
for i, r in enumerate(results):
ci = f"C{1 + i}"
ax[0, 3].plot(hour, r[VariableType.TEMPERATURE.value], c=ci, label=models[i])
for j, p in enumerate(
[
PowerType.JOULE,
PowerType.SOLAR,
PowerType.CONVECTION,
PowerType.RADIATION,
]
):
ax[1, j].plot(hour, r[p.value], c=ci, label=models[i])
ax[1, j].set_title(f"{p.value} (W/m)")
for i in range(ax.shape[0]):
for j in range(ax.shape[1]):
ax[i, j].set_xlabel("Time (hour)")
ax[i, j].grid(True)
ax[-1, -1].legend()
%matplotlib inline