Skip to content

abstract_model

AbstractModel

AbstractModel(static_env: StaticEnvT)

Bases: ABC, Generic[ModelRunOptionsT, StateT, ScenarioModelT, StaticEnvT]

Abstract base class for thermal cable models.

Source code in cable_thermal_model/model/abstract_model.py
35
36
37
38
def __init__(self, static_env: StaticEnvT):
    """Initialise the model with a static environment."""
    self.static_env = static_env
    self._set_run_options(run_options=None)

run

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

Computes the temperature solutions for all cable objects in the model for the given scenario.

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
scenario DataFrame

Scenario dataframe for this run. The dataframe is validated internally before execution.

required
initial_state StateT | None

Heating information from a previous computation.

None
run_options ModelRunOptionsT | dict | None

Run options for this simulation run. 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
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
def run(
    self,
    scenario: pd.DataFrame,
    initial_state: StateT | None = None,
    run_options: ModelRunOptionsT | dict | None = None,
) -> ModelOutputSchema[StateT]:
    """Computes the temperature solutions for all cable objects in the model for the given scenario.

    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:
        scenario: Scenario dataframe for this run. The dataframe is validated internally before execution.
        initial_state: Heating information from a previous computation.
        run_options: Run options for this simulation run. 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.

    """
    validated_scenario = self._validate_scenario(scenario=scenario)
    self._set_run_options(run_options=run_options)

    self._validate_initial_state(initial_state=initial_state)

    # Compute the temperature solution.
    result = self._compute_temperature_solution(
        scenario=validated_scenario,
        initial_state=initial_state,
    )

    return result