Source code for suboptimumg.vehicle.accumulator.accumulator
from ..vehicle_models import VehicleModel
[docs]
class Accumulator:
def __init__(
self,
vehicle_model: VehicleModel,
) -> None:
self.vehicle_model = vehicle_model
self.params = vehicle_model.accum
[docs]
def apply_pack_weight(self, new_pack_weight: float) -> float:
"""
Resize the pack, updating vehicle mass and capacity to match.
Parameters
----------
new_pack_weight : float
Battery pack weight to install (kg).
Returns
-------
float
The resulting pack capacity (kWh).
"""
pack_weight_delta = new_pack_weight - self.params.pack_weight
new_mass = self.vehicle_model.mass + pack_weight_delta
new_capacity = self.params.capacity + pack_weight_delta * self.params.energy_density
self.vehicle_model.mass = new_mass
self.params.pack_weight = new_pack_weight
self.params.capacity = new_capacity
return new_capacity