Skip to content

Solver

entities

CableType

Bases: Enum

Defines the type of the cable.

HeatEquationType

Bases: Enum

Defines all the possible heat equation types and their string values. * WITH_ONE_TEMPERATURE: computes a single temperature for the cable * WITH_THREE_TEMPERATURES: computes three temperatures for the cable (core, surface and average) * WITH_THREE_TEMPERATURES_LEGACY: computes three temperatures for the cable (core, surface and average), with specifications

ModelType

Bases: Enum

All the models available in thermohl. * cigre : model published by CIGRE * ieee : model published by IEEE * olla : model developed by RTE's R&D team * rte : model developed by RTE

PowerType

Bases: Enum

All the powers involved in the cable heating and cooling. * Joule heating : the way the electricity heats the cable (+ magnetic effect for core-metal cables) * Solar heating : the way the sun heats the cable * Convective cooling : the way the air cools the cable * Radiative cooling : the way the cable is cooled down by the radiations it emits * Precipitation : the way the rain cools the cable

TargetType

Bases: Enum

Defines the locations in the cable of the reference temperature * SURFACE: the reference temperature is at the surface of the cable * AVERAGE: the reference temperature is at an average thickness of the cable * CORE: the reference temperature is at the core of the cable

TemperatureType

Bases: Enum

Defines all the possible temperature locations for the cable. * SURFACE: the temperature at the surface of the cable * AVERAGE: the average temperature of the cable * CORE: the temperature at the core of the cable

VariableType

Bases: Enum

Defines the different types of variables that can be used in a solver. * ERROR: used to retrieve the error of the solver * TIME: the moment associated with TRANSIT and TEMPERATURE predictions * TRANSIT: the electric transit used in the solver * TEMPERATURE: the temperature used in the solver

solver

Base class to build a solver for heat equation.

Solver

Solver(
    dic: Optional[dict[str, Any]] = None,
    joule: Type[PowerTerm] = PowerTerm,
    solar: Type[PowerTerm] = PowerTerm,
    convective: Type[PowerTerm] = PowerTerm,
    radiative: Type[PowerTerm] = PowerTerm,
    precipitation: Type[PowerTerm] = PowerTerm,
)

Bases: ABC

Object to solve a temperature problem.

The temperature of a conductor is driven by four power terms, two heating terms (joule and solar heating) and three cooling terms (convective, radiative and precipitation cooling). This class is used to solve a temperature problem with the heating and cooling terms passed to its init function.

Parameters:

Name Type Description Default

dic

dict[str, Any] | None

Input values used in power terms. If there is a missing value, a default is used.

None

joule

Type[PowerTerm]

Joule heating term class.

PowerTerm

solar

Type[PowerTerm]

Solar heating term class.

PowerTerm

convective

Type[PowerTerm]

Convective cooling term class.

PowerTerm

radiative

Type[PowerTerm]

Radiative cooling term class.

PowerTerm

precipitation

Type[PowerTerm]

Precipitation cooling term class.

PowerTerm

Returns:

Type Description
None

None

Source code in src/thermohl/solver/solver.py
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
def __init__(
    self,
    dic: Optional[dict[str, Any]] = None,
    joule: Type[PowerTerm] = PowerTerm,
    solar: Type[PowerTerm] = PowerTerm,
    convective: Type[PowerTerm] = PowerTerm,
    radiative: Type[PowerTerm] = PowerTerm,
    precipitation: Type[PowerTerm] = PowerTerm,
) -> None:
    """Create a Solver object.

    Args:
        dic (dict[str, Any] | None): Input values used in power terms. If there is a missing value, a default is used.
        joule (Type[PowerTerm]): Joule heating term class.
        solar (Type[PowerTerm]): Solar heating term class.
        convective (Type[PowerTerm]): Convective cooling term class.
        radiative (Type[PowerTerm]): Radiative cooling term class.
        precipitation (Type[PowerTerm]): Precipitation cooling term class.

    Returns:
        None

    """
    self.args = Parameters(dic)
    self.args.extend()
    self.joule_heating = joule(**self.args.__dict__)
    self.solar_heating = solar(**self.args.__dict__)
    self.convective_cooling = convective(**self.args.__dict__)
    self.radiative_cooling = radiative(**self.args.__dict__)
    self.precipitation_cooling = precipitation(**self.args.__dict__)
    self.args.compress()

reshape

reshape(
    input_array: numberArrayLike,
    nb_row: int,
    nb_columns: int,
) -> numberArray

Reshape the input array to the specified dimensions (nr, nc) if possible.

Parameters:

Name Type Description Default

input_array

numberArrayLike

Input array to be reshaped.

required

nb_row

int

Desired number of rows for the reshaped array.

required

nb_columns

int

Desired number of columns for the reshaped array.

required

Returns:

Name Type Description
numberArray numberArray

Reshaped array of size (nb_row, nb_columns). If reshaping is not possible, returns an array filled with the input_value repeated to fill the dimension (nb_row, nb_columns).

Raises:

Type Description
AttributeError

If the input_array has an invalid shape that cannot be reshaped.

Source code in src/thermohl/solver/solver.py
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
def reshape(input_array: numberArrayLike, nb_row: int, nb_columns: int) -> numberArray:
    """
    Reshape the input array to the specified dimensions (nr, nc) if possible.

    Args:
        input_array (numberArrayLike): Input array to be reshaped.
        nb_row (int): Desired number of rows for the reshaped array.
        nb_columns (int): Desired number of columns for the reshaped array.

    Returns:
        numberArray: Reshaped array of size (nb_row, nb_columns). If reshaping is not possible,
            returns an array filled with the input_value repeated to fill the dimension (nb_row, nb_columns).

    Raises:
        AttributeError: If the input_array has an invalid shape that cannot be reshaped.
    """
    reshaped_array = ndarray
    try:
        input_shape = input_array.shape
        if len(input_shape) == 1:
            if nb_row == input_shape[0]:
                reshaped_array = np.column_stack(nb_columns * (input_array,))
            elif nb_columns == input_shape[0]:
                reshaped_array = np.vstack(nb_row * (input_array,))
        elif len(input_shape) == 0:
            raise AttributeError()
        else:
            reshaped_array = np.reshape(input_array, (nb_row, nb_columns))
    except AttributeError:
        reshaped_array = input_array * np.ones(
            (nb_row, nb_columns), dtype=type(input_array)
        )
    return reshaped_array

parameters

Parameters

Parameters(input_dict: Optional[dict[str, Any]] = None)

Object to store Solver args in a dict-like manner.

Source code in src/thermohl/solver/parameters.py
24
25
26
27
28
29
30
31
32
33
def __init__(self, input_dict: Optional[dict[str, Any]] = None):
    # add default values
    self._set_default_values()
    # use values from input dict
    if input_dict is None:
        return
    arg_keys = self.keys()
    for input_key, input_value in input_dict.items():
        if input_key in arg_keys and input_value is not None:
            self[input_key] = input_value

compress

compress() -> None

Compress the elements in the Args dictionary by replacing lists containing a unique value with this value.

Source code in src/thermohl/solver/parameters.py
115
116
117
118
119
120
121
122
123
def compress(self) -> None:
    """
    Compress the elements in the Args dictionary by replacing lists containing a unique value
    with this value.
    """
    for key in self.keys():
        u = np.unique(self[key])
        if len(u) == 1:
            self[key] = u[0]

extend

extend() -> None

Extend all compressed elements in the Args dictionary to the right length, ie the number of computations. If the element is a list, it already has the right length. If the element is a scalar, it is replaced with a list of the right length filled with the scalar value.

Source code in src/thermohl/solver/parameters.py
104
105
106
107
108
109
110
111
112
113
def extend(self) -> None:
    """
    Extend all compressed elements in the Args dictionary to the right length, ie the number of computations.
    If the element is a list, it already has the right length.
    If the element is a scalar, it is replaced with a list of the right length filled with the scalar value.
    """
    number_of_computations = self.get_number_of_computations()
    for key in self.keys():
        if not isinstance(self[key], Iterable):
            self[key] = np.array(number_of_computations * [self[key]])

keys

keys() -> KeysView[str]

Get list of members as dict keys.

Source code in src/thermohl/solver/parameters.py
88
89
90
def keys(self) -> KeysView[str]:
    """Get list of members as dict keys."""
    return self.__dict__.keys()