Skip to content

abstract_model

AbstractModel

AbstractModel(
    static_env: StaticEnv,
    scenario: DataFrame[ScenarioSchemaT],
)

Bases: ABC, Generic[ModelRunOptionsT, StateT, ScenarioSchemaT]

Abstract base class for thermal cable models.

Source code in cable_thermal_model/model/abstract_model.py
48
49
50
51
52
53
def __init__(self, static_env: StaticEnv, scenario: DataFrame[ScenarioSchemaT]):
    """Initialise the model with a static environment and scenario DataFrame."""
    # Validate if the scenario dataframe provides the required data on cable loads and ambient temperature
    self.static_env = static_env
    self._set_scenario(scenario=scenario)
    self._set_run_options(run_options=None)

run

run(
    initial_state: StateT | None = None,
    run_options: ModelRunOptionsT | dict | None = None,
) -> ModelOutputSchema[StateT]

Computes the temperature solutions for all cable objects.

Notes

Be careful about changing default run option values. The following settings affect the temperature outcome and should only be changed if you understand the implications:

  • temperature_dependent_electric_resistance
  • ac_current
  • soil_drying
  • initial_state

Parameters:

Name Type Description Default
initial_state StateT | None

Heating information from a previous computation.

None
run_options ModelRunOptionsT | dict | None

Run options for the model. If None or a dictionary is provided, the options are validated and default values are applied.

None

Returns:

Name Type Description
ModelOutputSchema ModelOutputSchema[StateT]

Temperature solutions for all cables.

Raises:

Type Description
ValueError

If the provided initial state does not match the model environment.

Source code in cable_thermal_model/model/abstract_model.py
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
def run(
    self,
    initial_state: StateT | None = None,
    run_options: ModelRunOptionsT | dict | None = None,
) -> ModelOutputSchema[StateT]:
    """Computes the temperature solutions for all cable objects.

    Notes:
        Be careful about changing default run option values. The following settings affect the
        temperature outcome and should only be changed if you understand the implications:

        - temperature_dependent_electric_resistance
        - ac_current
        - soil_drying
        - initial_state

    Args:
        initial_state: Heating information from a previous computation.
        run_options: Run options for the model. If `None` or a dictionary is provided, the
            options are validated and default values are applied.

    Returns:
        ModelOutputSchema: Temperature solutions for all cables.

    Raises:
        ValueError: If the provided initial state does not match the model environment.

    """
    self._set_run_options(run_options=run_options)

    self._validate_initial_state(initial_state=initial_state)

    # compute temperature solution
    result = self._compute_temperature_solution(
        initial_state=initial_state,
    )

    return result