Models¶
models
¶
Core data models for the tramway power-supply simulation.
This module defines immutable configuration and result containers used across the simulation and optimization pipeline. The classes are intentionally kept lightweight: they validate physical parameters, expose convenient unit conversions, and centralize the data exchanged between modules.
ElectricalNetwork
dataclass
¶
Electrical parameters of the DC tramway supply network.
The network is modeled as two DC substations feeding the train through the overhead contact line and the rails. The parameters defined here are used to compute the Thevenin equivalent resistance seen by the train.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
substation_voltage_v
|
float
|
No-load voltage of each substation, in volts. |
790.0
|
substation_resistance_ohm
|
float
|
Internal resistance of each substation, in ohms. |
0.033
|
overhead_line_resistance_ohm_per_m
|
float
|
Linear resistance of the overhead contact line, in ohms per meter. |
9.5e-05
|
rail_resistance_ohm_per_m
|
float
|
Linear resistance of the rails, in ohms per meter. |
1e-05
|
Notes
The default resistance values correspond to the corrected values used in the project statement to avoid physically impossible operating points.
Source code in src\tramway_optimization\models.py
TrainConfig
dataclass
¶
Mechanical and onboard electrical parameters of the train.
This configuration groups the parameters required to estimate the train traction power from its position profile. The resistive force is described by a Davis-like polynomial model depending on speed and train mass.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mass_kg
|
float
|
Train mass, in kilograms. |
70000.0
|
motor_efficiency
|
float
|
Constant efficiency of the motor and power conversion chain. |
0.8
|
onboard_auxiliary_power_w
|
float
|
Constant onboard auxiliary power demand, in watts. |
35000.0
|
slope_rad
|
float
|
Track slope angle, in radians. A positive value represents an uphill slope. |
0.0
|
gravity_m_per_s2
|
float
|
Gravitational acceleration, in meters per second squared. |
9.81
|
a0_n
|
float
|
Constant rolling-resistance coefficient, in newtons. |
780.0
|
a1_n_per_ton
|
float
|
Mass-dependent rolling-resistance coefficient. |
6.4
|
b0_n_per_kmh
|
float
|
Linear speed-dependent resistance coefficient. |
0.0
|
b1_n_per_ton_per_kmh
|
float
|
Mass-dependent linear speed-resistance coefficient. |
0.14
|
c0_n_per_kmh2
|
float
|
Quadratic speed-dependent aerodynamic resistance coefficient. |
0.3634
|
c1_n_per_ton_per_kmh2
|
float
|
Mass-dependent quadratic speed-resistance coefficient. |
0.0
|
Notes
The model is intentionally simple because the project focuses on power supply simulation and multi-objective battery sizing, not detailed train dynamics.
Source code in src\tramway_optimization\models.py
BatteryConfig
dataclass
¶
Battery sizing and control parameters.
The battery is described by its energy capacity, efficiency, initial state of charge, and the power threshold used by the rule-based controller.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
capacity_j
|
float
|
Maximum usable battery energy, in joules. |
required |
power_threshold_w
|
float
|
Line power threshold, in watts. When the train demand exceeds this value, the controller attempts to supply the excess using the battery. |
required |
efficiency
|
float
|
Battery charge/discharge efficiency. |
0.9
|
initial_state_of_charge
|
float
|
Initial battery state of charge, between 0 and 1. |
1.0
|
Notes
Internally, energy is stored in joules to remain consistent with SI units.
The from_kwh constructor and capacity_kwh property are provided for
user-facing battery sizing.
Source code in src\tramway_optimization\models.py
capacity_kwh
property
¶
Battery capacity expressed in kilowatt-hours.
power_threshold_kw
property
¶
Line power threshold expressed in kilowatts.
from_kwh(capacity_kwh, power_threshold_kw, efficiency=0.9, initial_state_of_charge=1.0)
classmethod
¶
Create a battery configuration from engineering units.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
capacity_kwh
|
float
|
Battery capacity, in kilowatt-hours. |
required |
power_threshold_kw
|
float
|
Line power threshold, in kilowatts. |
required |
efficiency
|
float
|
Battery charge/discharge efficiency. |
0.9
|
initial_state_of_charge
|
float
|
Initial battery state of charge, between 0 and 1. |
1.0
|
Returns:
| Name | Type | Description |
|---|---|---|
BatteryConfig |
'BatteryConfig'
|
Battery configuration converted to SI units. |
Source code in src\tramway_optimization\models.py
SimulationResult
dataclass
¶
Time-domain outputs of a tramway power-supply simulation.
This container stores the main time series produced by a simulation. Battery-related fields are optional so that the same result type can be used for simulations with and without onboard storage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time_s
|
ndarray
|
Simulation time samples, in seconds. |
required |
position_m
|
ndarray
|
Train position at each time sample, in meters. |
required |
train_power_w
|
ndarray
|
Electrical power requested by the train, in watts. Positive values correspond to traction demand, while negative values correspond to regenerative braking. |
required |
line_power_w
|
ndarray
|
Power supplied by the DC line, in watts. |
required |
train_voltage_v
|
ndarray
|
Voltage at the train terminals, in volts. |
required |
voltage_drop_v
|
ndarray
|
Difference between substation voltage and train voltage, in volts. |
required |
battery_power_w
|
ndarray | None
|
Battery power, in watts. Positive values indicate discharge into the train, while negative values indicate charging. |
None
|
battery_energy_j
|
ndarray | None
|
Battery stored energy over time, in joules. |
None
|
rheostat_power_w
|
ndarray | None
|
Power dissipated in the rheostat during braking, in watts. |
None
|
Source code in src\tramway_optimization\models.py
max_voltage_drop_v
property
¶
Maximum voltage drop observed during the simulation, in volts.
OptimizationResult
dataclass
¶
Result of a bi-objective battery optimization run.
The optimization problem minimizes battery capacity and maximum voltage drop. This container stores all evaluated designs and the indices of the non-dominated solutions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
capacities_kwh
|
ndarray
|
Battery capacities evaluated during optimization, in kilowatt-hours. |
required |
power_thresholds_kw
|
ndarray
|
Associated power thresholds, in kilowatts. |
required |
max_voltage_drops_v
|
ndarray
|
Maximum voltage drop obtained for each evaluated design, in volts. |
required |
pareto_indices
|
ndarray
|
Indices of non-dominated solutions in the evaluated design arrays. |
required |