Source code for suboptimumg.vehicle.accumulator.accumulator
from ...constants import *
from ..vehicle_models import VehicleModel
[docs]
class Accumulator:
def __init__(
self,
vehicle_model: VehicleModel,
):
self.vehicle_model = vehicle_model
self.params = vehicle_model.accum
# Capture the nominal mass at construction time for pack weight to mass/capacity conversions
self.nominal_mass = vehicle_model.mass
self.nominal_pack_weight = self.params.pack_weight
self.nominal_capacity = self.params.capacity
self.energy_density = self.params.energy_density
[docs]
def apply_pack_weight(self, new_pack_weight: float) -> float:
"""
Derive vehicle mass and capacity from a new pack weight.
Parameters
----------
Returns the new capacity (kWh).
"""
delta = new_pack_weight - self.nominal_pack_weight
new_mass = self.nominal_mass + delta
new_capacity = self.nominal_capacity + delta * self.energy_density
self.vehicle_model.mass = new_mass
self.params.pack_weight = new_pack_weight
self.params.capacity = new_capacity
return new_capacity