model.general ============= .. py:module:: model.general Attributes ---------- .. autoapisummary:: model.general.postgresql_exclude model.general.postgresql_array_check Classes ------- .. autoapisummary:: model.general.ScenarioType model.general.Scenario model.general.EnergySource model.general.VehicleType model.general.BatteryType model.general.Vehicle model.general.VehicleClass model.general.AssocVehicleTypeVehicleClass model.general.EventType model.general.Event model.general.ConsumptionLut model.general.Temperatures model.general.ChargingPointType Functions --------- .. autoapisummary:: model.general.check_vehicle_type_before_commit model.general.check_event_before_commit Module Contents --------------- .. py:class:: ScenarioType(*args, **kwds) Bases: :py:obj:`enum.Enum` Classifies a scenario by its provenance: original input, derived mutation, or simulation result. .. py:attribute:: SOURCE .. py:attribute:: MUTATION .. py:attribute:: SIMULATION .. py:class:: Scenario Bases: :py:obj:`eflips.model.Base` .. py:attribute:: __tablename__ :value: 'Scenario' .. py:attribute:: id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the scenario. Auto-incremented. .. py:attribute:: parent_id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the parent scenario. Foreign key to :attr:`Scenario.id`. .. py:attribute:: parent :type: sqlalchemy.orm.Mapped[Scenario] The parent scenario. .. py:attribute:: children :type: sqlalchemy.orm.Mapped[List[Scenario]] A list of child scenarios. .. py:attribute:: scenario_type :type: sqlalchemy.orm.Mapped[ScenarioType] The type of Scenario. Used by django-simba. .. py:attribute:: name :type: sqlalchemy.orm.Mapped[str] A name for the scenario. .. py:attribute:: name_short :type: sqlalchemy.orm.Mapped[str] An optional short name for the scenario. .. py:attribute:: description :type: sqlalchemy.orm.Mapped[str] An optional description for the scenario. Can be used to store additional information about the scenario. .. py:attribute:: created :type: sqlalchemy.orm.Mapped[datetime.datetime] The time the scenario was created. Automatically set to the current time at creation. .. py:attribute:: finished :type: sqlalchemy.orm.Mapped[datetime.datetime] The time the simulation was finished. Automatically set to the current time at simulation end. Null if not yet finished. .. py:attribute:: default_simba_options :type: str :value: '{"eta": false, "days": null, "mode": ["sim", "report"], "seed": 1, "config": null, "margin": 1,... .. py:attribute:: simba_options :type: sqlalchemy.orm.Mapped[Dict[str, Any]] The options for the simBA simulation. Stored as a JSON object. .. py:attribute:: eflips_depot_options :type: sqlalchemy.orm.Mapped[Dict[str, Any]] The options for the eflips-depot simulation. Stored as a JSON object. .. py:attribute:: task_id :type: sqlalchemy.orm.Mapped[uuid.UUID] The task id of the simulation. Automatically set to a UUID when a scenario is submitted for simulation. .. py:attribute:: manager_id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the manager. Only used in the `django.simba` project. .. py:attribute:: tco_parameters :type: sqlalchemy.orm.Mapped[Dict[str, Any]] The TCO (Total Cost of Ownership) parameters for the scenario analysis. Stored as a JSON object containing the following parameters: Financial Parameters: - project_duration: Analysis period in years - interest_rate: Interest rate (value between 0 and 1) - inflation_rate: General inflation rate (value between 0 and 1) Cost Parameters: - staff_cost: Cost per staff member per hour - energy_cost: Cost per kWh of energy - maint_cost: Maintenance cost per vehicle per kilometer - maint_infr_cost: Maintenance cost per charging point and year - taxes: Tax cost per vehicle and year - insurance: Insurance cost per vehicle Price Escalation Factors (PEF): - pef_general: General price escalation factor (value between 0 and 1) - pef_wages: Wage price escalation factor (value between 0 and 1) - pef_energy: Energy price escalation factor (value between 0 and 1) - pef_insurance: Insurance price escalation factor (value between 0 and 1) Note: Cost parameters can be set to null if not applicable to the analysis. Price escalation factors represent annual cost increase rates, not relative to inflation. .. py:attribute:: vehicle_types :type: sqlalchemy.orm.Mapped[List[VehicleType]] A list of vehicle types. .. py:attribute:: battery_types :type: sqlalchemy.orm.Mapped[List[BatteryType]] A list of battery types. .. py:attribute:: vehicles :type: sqlalchemy.orm.Mapped[List[Vehicle]] A list of vehicles. .. py:attribute:: vehicle_classes :type: sqlalchemy.orm.Mapped[List[VehicleClass]] .. py:attribute:: lines :type: sqlalchemy.orm.Mapped[List[eflips.model.Line]] A list of lines. .. py:attribute:: routes :type: sqlalchemy.orm.Mapped[List[eflips.model.Route]] A list of routes. .. py:attribute:: stations :type: sqlalchemy.orm.Mapped[List[eflips.model.Station]] .. py:attribute:: assoc_route_stations :type: sqlalchemy.orm.Mapped[List[eflips.model.AssocRouteStation]] A list of stations. .. py:attribute:: stop_times :type: sqlalchemy.orm.Mapped[List[eflips.model.StopTime]] A list of stop times. .. py:attribute:: trips :type: sqlalchemy.orm.Mapped[List[eflips.model.Trip]] A list of trips. .. py:attribute:: rotations :type: sqlalchemy.orm.Mapped[List[eflips.model.Rotation]] A list of events. .. py:attribute:: events :type: sqlalchemy.orm.Mapped[List[Event]] .. py:attribute:: consumption_luts :type: sqlalchemy.orm.Mapped[List[ConsumptionLut]] .. py:attribute:: temperatures :type: sqlalchemy.orm.Mapped[List[Temperatures]] .. py:attribute:: depots :type: sqlalchemy.orm.Mapped[List[eflips.model.Depot]] A list of depots. .. py:attribute:: plans :type: sqlalchemy.orm.Mapped[List[eflips.model.Plan]] A list of plans. .. py:attribute:: areas :type: sqlalchemy.orm.Mapped[List[eflips.model.Area]] A list of areas. .. py:attribute:: processes :type: sqlalchemy.orm.Mapped[List[eflips.model.Process]] A list of processes. .. py:attribute:: assoc_plan_processes :type: sqlalchemy.orm.Mapped[List[eflips.model.AssocPlanProcess]] .. py:attribute:: charging_point_types :type: sqlalchemy.orm.Mapped[List[ChargingPointType]] A list of charging point types. .. py:method:: _copy_object(obj, session, scenario) :staticmethod: Creates a copy of an SQLAlchemy object and attaches it to a new scenario. The original object is left completely unchanged in the session. :param obj: An SQLAlchemy object. Must have an 'id' and a 'scenario_id' attribute. :param session: An SQLAlchemy session. :param scenario: The new scenario to attach the copy to. :return: The newly created copy, pending in the session. .. py:method:: clone(session) Creates a copy of the scenario, including all owned objects. :param session: The database session. :return: The copy of the scenario. .. py:method:: select_rotations(session, start_time, time_window) Keeps only the rotations that are within the time window. Deletes all other rotations from the database. This method is useful if (for example) your import gave you a six-month schedule, but you only want to simulate a week of it. :param session: An SQLAlchemy session to a database with eflips-model tables. :param start_time: The start time of the time window. Rotations that start before this time are not selected. This time must have a timezone. :param time_window: The time window. Rotations that end after this time are not selected. :return: None .. py:method:: __repr__() .. py:class:: EnergySource(*args, **kwds) Bases: :py:obj:`enum.Enum` The kind of energy a vehicle uses for propulsion. .. py:attribute:: BATTERY_ELECTRIC .. py:attribute:: DIESEL .. py:attribute:: HYDROGEN .. py:class:: VehicleType Bases: :py:obj:`eflips.model.Base` This class represents a vehicle type, containing the technical parameters shared by all vehicles of this type. It is used by vehicles (which are of a specific type) and by the rotations (which are for specific vehicle types). .. py:attribute:: __tablename__ :value: 'VehicleType' .. py:attribute:: _table_args_list :value: [] .. py:attribute:: id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the vehicle type. Auto-incremented. .. py:attribute:: scenario_id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the scenario. Foreign key to :attr:`Scenario.id`. .. py:attribute:: scenario :type: sqlalchemy.orm.Mapped[Scenario] The scenario. .. py:attribute:: battery_type_id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the battery type. Foreign key to :attr:`BatteryType.id`. .. py:attribute:: battery_type :type: sqlalchemy.orm.Mapped[BatteryType] The battery type. .. py:attribute:: name :type: sqlalchemy.orm.Mapped[str] A name for the vehicle type. .. py:attribute:: name_short :type: sqlalchemy.orm.Mapped[str] An optional short name for the vehicle type. .. py:attribute:: energy_source :type: sqlalchemy.orm.Mapped[EnergySource] The energy/propulsion source of the vehicle type. .. py:attribute:: battery_capacity :type: sqlalchemy.orm.Mapped[float] The battery capacity in kWh. This refers to the usable capacity, not the total capacity. .. py:attribute:: battery_capacity_constraint .. py:attribute:: battery_capacity_reserve :type: sqlalchemy.orm.Mapped[float] The battery capacity reserve below 0 kWh 'capacity' in kWh. Using this value in generating evaluation, things such as "always 10% reserve" can be modeled. .. py:attribute:: battery_capacity_reserve_constraint .. py:attribute:: charging_curve :type: sqlalchemy.orm.Mapped[List[List[float]]] The charging curve of the vehicle type. This is a 2D array of floats with two rows. The first row contains the state of charge, ranging from 0 (or some negative value if there is a nonzero reserve) to 1. The second row contains the charging power in kW. The charging curve is used to calculate the charging power of a vehicle using linear interpolation. The charging curve must be monotonically increasing in the first row. .. py:attribute:: v2g_curve :type: sqlalchemy.orm.Mapped[List[List[float]]] The vehicle-to-grid curve of the vehicle type. This is a 2D array of floats with two rows. The first row contains the state of charge, ranging from 0 to 1. The second row contains the discharging power in kW. The v2g curve is used to calculate the discharging power of a vehicle using linear interpolation. The v2g curve must be monotonically increasing in the first row. It may bo None if the vehicle type does not support vehicle-to-grid. .. py:attribute:: charging_efficiency :type: sqlalchemy.orm.Mapped[float] Ratio of battery output (while driving/V2G) to grid input. Also applies to V2G. .. py:attribute:: charging_efficiency_constraint_lower .. py:attribute:: charging_efficiency_constraint_upper .. py:attribute:: opportunity_charging_capable :type: sqlalchemy.orm.Mapped[bool] Whether the bus is capable of automatic highpower charging. All buses are assumed to be capable of (depot) conductive charging. .. py:attribute:: minimum_charging_power :type: sqlalchemy.orm.Mapped[float] If the charging power falls below this value, charging is canceled .. py:attribute:: minimum_charging_power_constraint .. py:attribute:: length :type: sqlalchemy.orm.Mapped[float] The length of the vehicle in meters. .. py:attribute:: width :type: sqlalchemy.orm.Mapped[float] The width of the vehicle in meters. .. py:attribute:: height :type: sqlalchemy.orm.Mapped[float] The height of the vehicle in meters. .. py:attribute:: empty_mass :type: sqlalchemy.orm.Mapped[float] The empty mass of the vehicle in kg. .. py:attribute:: empty_mass_constraint .. py:attribute:: allowed_mass :type: sqlalchemy.orm.Mapped[float] The allowed payload mass of the vehicle in kg. The total mass of the vehicle is empty_mass + allowed_mass. .. py:attribute:: allowed_mass_constraint .. py:attribute:: tco_parameters :type: sqlalchemy.orm.Mapped[Dict[str, Any]] The TCO (Total Cost of Ownership) parameters of the vehicle type. This parameter stores a JSON object containing the following fields: - "useful_life": The expected operational lifetime of the vehicle in years - "procurement_cost": The initial purchase cost per vehicle - "cost_escalation": Annual cost escalation factor as a decimal between 0 and 1 (e.g., 0.02 represents 2% annual cost increase) - "average_electricity_consumption": energy consumption in kWh/km VehicleType has energy_source BATTERY_ELECTRIC. If energy_source is DIESEL, average_diesel_consumption in l/km is to be filled in. .. py:attribute:: lca_parameters :type: sqlalchemy.orm.Mapped[Dict[str, Any]] LCA (Life Cycle Assessment) parameters for this vehicle type. Stored as a JSON object. Use ``eflips.lca.VehicleTypeLcaParams.from_dict()`` to deserialise and ``.to_dict()`` to serialise. Contains chassis, motor, use-phase, and maintenance emission factors. See the eflips-lca design document for the full schema. .. py:attribute:: consumption :type: sqlalchemy.orm.Mapped[float] The vehicle's energy consumption in kWh/km. This is used to calculate the energy consumption of a trip. Can be None if we are using more detailed consumption models. Either this or consumption_lut must be specified. Both cannot exist at the same time. .. py:attribute:: vehicles :type: sqlalchemy.orm.Mapped[List[Vehicle]] A list of vehicles. .. py:attribute:: vehicle_classes :type: sqlalchemy.orm.Mapped[List[VehicleClass]] A list of vehicle classes. .. py:attribute:: rotations :type: sqlalchemy.orm.Mapped[List[eflips.model.Rotation]] A list of rotations. .. py:attribute:: events :type: sqlalchemy.orm.Mapped[List[Event]] A list of events. .. py:attribute:: areas :type: sqlalchemy.orm.Mapped[List[eflips.model.Area]] A list of areas. .. py:attribute:: assoc_vehicle_type_vehicle_classes :type: sqlalchemy.orm.Mapped[AssocVehicleTypeVehicleClass] .. py:attribute:: __table_args__ :value: () .. py:method:: __repr__() .. py:function:: check_vehicle_type_before_commit(_, __, target) A VehicleType may hav consumption xor consumption_lut, but not both. :param target: A VehicleType object :return: Nothing. Raises an exception if something is wrong. .. py:class:: BatteryType Bases: :py:obj:`eflips.model.Base` .. py:attribute:: __tablename__ :value: 'BatteryType' .. py:attribute:: id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the battery type. Auto-incremented. .. py:attribute:: scenario_id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the scenario. Foreign key to :attr:`Scenario.id`. .. py:attribute:: scenario :type: sqlalchemy.orm.Mapped[Scenario] The scenario. .. py:attribute:: vehicle_types :type: sqlalchemy.orm.Mapped[List[VehicleType]] .. py:attribute:: specific_mass :type: sqlalchemy.orm.Mapped[float] The specific mass of the battery in kg/kWh. Relative to gross (not net) capacity. .. py:attribute:: chemistry :type: sqlalchemy.orm.Mapped[str] The chemistry of the battery as a plain string, e.g. ``'LFP'`` or ``'NMC622'``. .. py:attribute:: tco_parameters :type: sqlalchemy.orm.Mapped[Dict[str, Any]] The Total Cost of Ownership (TCO) parameters for the battery type. Stored as a JSON object containing the following fields: - useful_life (int): The expected operational lifespan of the battery in years. Represents how long the battery is expected to maintain acceptable performance before requiring replacement. - procurement_cost (float or null): The initial acquisition cost per kWh of battery capacity. - cost_escalation (float): The annual rate of cost change as a decimal between 0 and 1. Negative values indicate cost reductions over time, while positive values indicate cost increases. For example, -0.03 represents a 3% annual cost reduction. .. py:attribute:: lca_parameters :type: sqlalchemy.orm.Mapped[Dict[str, Any]] LCA parameters for this battery type. Stored as a JSON object. Use ``eflips.lca.BatteryTypeLcaParams.from_dict()`` to deserialise. Contains emission factors per kg and battery lifetime. .. py:method:: __repr__() .. py:class:: Vehicle Bases: :py:obj:`eflips.model.Base` A vehicle is a concrete vehicle of a certain type. .. py:attribute:: __tablename__ :value: 'Vehicle' .. py:attribute:: id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the battery type. Auto-incremented. .. py:attribute:: scenario_id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the scenario. Foreign key to :attr:`Scenario.id`. .. py:attribute:: scenario :type: sqlalchemy.orm.Mapped[Scenario] The scenario. .. py:attribute:: vehicle_type_id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the vehicle type. Foreign key to :attr:`VehicleType.id`. .. py:attribute:: vehicle_type :type: sqlalchemy.orm.Mapped[VehicleType] The vehicle type. .. py:attribute:: name :type: sqlalchemy.orm.Mapped[str] A name for the vehicle. .. py:attribute:: name_short :type: sqlalchemy.orm.Mapped[str] An optional short name for the vehicle. .. py:attribute:: rotations :type: sqlalchemy.orm.Mapped[List[eflips.model.Rotation]] A list of rotations this vehicle is used for. .. py:attribute:: events :type: sqlalchemy.orm.Mapped[List[Event]] .. py:method:: __repr__() .. py:class:: VehicleClass Bases: :py:obj:`eflips.model.Base` VehicleClasses allow a many-to-many relationship between vehicles and classes, which may be used for specifying things such as "any 12m bus" or "any 18m bus". The VehicleClass table is not used directly, but through the association table AssocVehicleTypeVehicleClass. **Support is currently incomplete. THis only exists as a stub (and is used by eflip-LCA), but is not implemented in django.simba or eflips-depot** .. py:attribute:: __tablename__ :value: 'VehicleClass' .. py:attribute:: id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the battery type. Auto-incremented. .. py:attribute:: scenario_id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the scenario. Foreign key to :attr:`Scenario.id`. .. py:attribute:: scenario :type: sqlalchemy.orm.Mapped[Scenario] The scenario. .. py:attribute:: name :type: sqlalchemy.orm.Mapped[str] A name for the vehicle class. .. py:attribute:: name_short :type: sqlalchemy.orm.Mapped[str] An optional short name for the vehicle class. .. py:attribute:: vehicle_types :type: sqlalchemy.orm.Mapped[List[VehicleType]] .. py:attribute:: consumption_lut :type: sqlalchemy.orm.Mapped[ConsumptionLut] A consumption look up table. Either this or consumption must be specified. Both cannot exist at the same time. .. py:attribute:: assoc_vehicle_type_vehicle_classes :type: sqlalchemy.orm.Mapped[AssocVehicleTypeVehicleClass] .. py:method:: __repr__() .. py:class:: AssocVehicleTypeVehicleClass Bases: :py:obj:`eflips.model.Base` The association table for the many-to-many relationship between vehicles and classes. .. py:attribute:: __tablename__ :value: 'AssocVehicleTypeVehicleClass' .. py:attribute:: id :type: sqlalchemy.orm.Mapped[int] Not the primary key and not used in SQLAlchemy, but required by Django. .. py:attribute:: vehicle_type_id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the vehicle type. Foreign key to :attr:`VehicleType.id`. .. py:attribute:: vehicle_type :type: sqlalchemy.orm.Mapped[VehicleType] .. py:attribute:: vehicle_class_id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the vehicle class. Foreign key to :attr:`VehicleClass.id`. .. py:attribute:: vehicle_class :type: sqlalchemy.orm.Mapped[VehicleClass] .. py:method:: __repr__() .. py:class:: EventType(*args, **kwds) Bases: :py:obj:`enum.Enum` The EventType can be used to filter for certain types of events. It is also used to determine the valid combinations of nullable fields in the Event table. .. py:attribute:: DRIVING Driving on a trip. .. py:attribute:: CHARGING_OPPORTUNITY Charging at a terminal station. .. py:attribute:: CHARGING_DEPOT Charging at a depot. .. py:attribute:: SERVICE Service at a depot. Probably, the description field should be used to specify the type of service. .. py:attribute:: STANDBY Standing in the depot while waiting for something. Not yet ready for departure. .. py:attribute:: STANDBY_DEPARTURE Ready for departure from a depot. .. py:attribute:: PRECONDITIONING HVAC is turned on using grid power. .. py:class:: Event Bases: :py:obj:`eflips.model.Base` An Event represents a signle event in the simulation. This does not necessary mean a point in time, but a process during which something happens. For example, there are charging and driving events. Events are used to track the state of the simulation. They are also the basis for the evaluation of the simulation. Note that there are only certain valid combinations of the nullable fields. An event can take place either at a - station (station_id is not null and subloc_no is not null). Possible events: CHARGING_OPPORTUNITY - depot (station_id is not null and subloc_no is null). Possible events: CHARGING_DEPOT, SERVICE, STANDBY_DEPARTURE PRECONDITIONING - trip (trip_id is not null and subloc_no is null). Possible events: DRIVING .. py:attribute:: __tablename__ :value: 'Event' .. py:attribute:: id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the event. Auto-incremented. .. py:attribute:: scenario_id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the scenario. Foreign key to :attr:`Scenario.id`. .. py:attribute:: scenario :type: sqlalchemy.orm.Mapped[Scenario] The scenario. .. py:attribute:: vehicle_type_id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the vehicle type. Foreign key to :attr:`VehicleType.id`. .. py:attribute:: vehicle_type :type: sqlalchemy.orm.Mapped[VehicleType] .. py:attribute:: vehicle_id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the vehicle. Foreign key to :attr:`Vehicle.id`. .. py:attribute:: vehicle :type: sqlalchemy.orm.Mapped[Vehicle] The vehicle. .. py:attribute:: station_id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the station. Foreign key to :attr:`Station.id`. .. py:attribute:: station :type: sqlalchemy.orm.Mapped[eflips.model.Station] .. py:attribute:: area_id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the area in the depot. Foreign key to :attr:`Area.id`. .. py:attribute:: area :type: sqlalchemy.orm.Mapped[eflips.model.Area] .. py:attribute:: subloc_no :type: sqlalchemy.orm.Mapped[int] The number of the sub-location in the depot or multi-chargpoint terminal. The mapping of sub-locations to physical locations is defined by the depot layout and/or the multi-chargpoint terminal layout. .. py:attribute:: trip_id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the trip. Foreign key to :attr:`Trip.id`. .. py:attribute:: trip :type: sqlalchemy.orm.Mapped[eflips.model.Trip] .. py:attribute:: time_start :type: sqlalchemy.orm.Mapped[datetime.datetime] The time the event starts. .. py:attribute:: time_end :type: sqlalchemy.orm.Mapped[datetime.datetime] The time the event ends. .. py:attribute:: soc_start :type: sqlalchemy.orm.Mapped[float] The state of charge at the start of the event. This should refer to the net battery capacity. .. py:attribute:: soc_end :type: sqlalchemy.orm.Mapped[float] The state of charge at the end of the event. This should refer to the net battery capacity. .. py:attribute:: event_type :type: sqlalchemy.orm.Mapped[EventType] The type of the event. .. py:attribute:: description :type: sqlalchemy.orm.Mapped[str] A description of the event. Used to display additional information to the user. .. py:attribute:: timeseries :type: sqlalchemy.orm.Mapped[Dict[str, List[Union[datetime.datetime, str, float]]]] Dict with mandatory keys „time“ (ISO 18601 with TZ), „soc“ (0-1) and optional keys „distance“ (m, along route for trip) + other freely defined keys. Array of same length for each key .. py:attribute:: __table_args__ .. py:method:: __repr__() .. py:data:: postgresql_exclude .. py:function:: check_event_before_commit(_, __, target) 1. If the event has a timeseries, check if the keys are correct. Also make sure the first timestamp is >= time_start and the last timestamp is <= time_end. 2. Check if the start or end time is not a full second, warn the user if it is not. :param target: an event object :return: Nothing. Raises an exception if something is wrong. .. py:class:: ConsumptionLut Bases: :py:obj:`eflips.model.Base` The Consumption table stores the energy consumption look-up-tables for each vehicle class. Uses a regression model generated from real world electric bus data to create a consumption table in django-simba format (temperature, speed, level of loading, incline, consumption) and exports it into the session database. .. py:attribute:: __tablename__ :value: 'ConsumptionLut' .. py:attribute:: __table_args__ .. py:attribute:: id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the consumption. Auto-incremented. .. py:attribute:: scenario_id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the scenario. Foreign key to :attr:`Scenario.id`. .. py:attribute:: scenario :type: sqlalchemy.orm.Mapped[Scenario] The scenario. .. py:attribute:: name A name for the consumption table. .. py:attribute:: vehicle_class_id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the vehicle type. Foreign key to :attr:`VehicleClass.id`. .. py:attribute:: vehicle_class :type: sqlalchemy.orm.Mapped[VehicleClass] The vehicle class. .. py:attribute:: columns A JSON-encoded list of column name strings. The order of these should match the order of the values for each row in the data_points .. py:attribute:: data_points :type: sqlalchemy.orm.Mapped[List[List[float]]] A list of data points. These are the coordinates of the data point. Its value is stored in the `value` column. The order of columns is the entry in the `columns` column. .. py:attribute:: values :type: sqlalchemy.orm.Mapped[List[float]] A list of consumption values in kWh/km. The corresponding temperatures, inclines etc. are stored in the `data_points` column. .. py:attribute:: INCLINE :value: 'incline' .. py:attribute:: T_AMB :value: 't_amb' .. py:attribute:: LEVEL_OF_LOADING :value: 'level_of_loading' .. py:attribute:: SPEED :value: 'mean_speed_kmh' .. py:attribute:: CONSUMPTION :value: 'consumption_kwh_per_km' .. py:method:: calc_consumption(trip_distance, temperature, mass, duration, incline = 0.0) :staticmethod: This function calculates the consumption of the trip according to the model of Ji, Bie, Zeng, Wang https://doi.org/10.1016/j.commtr.2022.100069, augmented with a linear physics-based slope term (the original Ji model has none). :param trip_distance: Travelled distance in km :param temperature: Average temperature during trip in degrees Celsius :param mass: Curb weight + passengers in kg :param duration: Trip time in minutes :param incline: Average road grade as a fraction (e.g. 0.05 = +5 % uphill, -0.03 = -3 % downhill). Defaults to 0 (level road). :return: Trip energy in kWh .. py:method:: table_generator(vehicle_type) :staticmethod: Takes VehicleType information to create a consumption table in django-simba format. :return: .. py:method:: df_to_consumption_obj(df, scenario_or_id, vehicle_class_or_id) :staticmethod: .. py:method:: from_vehicle_type(vehicle_type, vehicle_class) :classmethod: .. py:class:: Temperatures Bases: :py:obj:`eflips.model.Base` The Consumption table stores the energy consumption look-up-tables for each vehicle class. Uses a regression model generated from real world electric bus data to create a consumption table in django-simba format (temperature, speed, level of loading, incline, consumption) and exports it into the session database. .. py:attribute:: __tablename__ :value: 'Temperatures' .. py:attribute:: __table_args__ .. py:attribute:: id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the consumption. Auto-incremented. .. py:attribute:: scenario_id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the scenario. Foreign key to :attr:`Scenario.id`. .. py:attribute:: scenario :type: sqlalchemy.orm.Mapped[Scenario] The scenario. .. py:attribute:: name :type: sqlalchemy.orm.Mapped[str] A name for the temperature table. .. py:attribute:: use_only_time :type: sqlalchemy.orm.Mapped[bool] Whether the temperature data is for one repeating day. If False, the temperature data is for multiple days. If true, it is for one day and all other days should use the values from this day. .. py:attribute:: datetimes :type: sqlalchemy.orm.Mapped[List[datetime.datetime]] The datetimes of the temperature data. If is_one_repeating_day is True, this should be a single day. The length of this list should be the same as the length of the temperatures. .. py:attribute:: data :type: sqlalchemy.orm.Mapped[List[float]] The temperatures in degrees Celsius. The order of the temperatures should match the order of the datetimes. The length of this list should be the same as the length of the datetimes. .. py:data:: postgresql_array_check .. py:class:: ChargingPointType Bases: :py:obj:`eflips.model.Base` This class is designed for distinguishing between charging point at area or at station. .. py:attribute:: __tablename__ :value: 'ChargingPointType' .. py:attribute:: id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the charging point type. Auto-incremented. .. py:attribute:: scenario_id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the scenario. Foreign key to :attr:`Scenario.id`. .. py:attribute:: scenario :type: sqlalchemy.orm.Mapped[Scenario] The scenario. .. py:attribute:: name :type: sqlalchemy.orm.Mapped[str] The name of the charging point type. .. py:attribute:: name_short :type: sqlalchemy.orm.Mapped[str] The short name of the charging point type (if available). .. py:attribute:: tco_parameters :type: sqlalchemy.orm.Mapped[Dict[str, Any]] The TCO (Total Cost of Ownership) parameters of the charging point. Stored as a JSON object containing the following fields: - useful_life (int): Expected operational lifespan of the charging point in years. Default: 20 years - procurement_cost (float, optional): Initial purchase cost per charging point. - cost_escalation (float): Annual cost escalation rate as a decimal. Should be between 0.0 and 1.0 (e.g., 0.02 = 2% annual increase). Used to project future operational costs over the useful life period. .. py:attribute:: lca_parameters :type: sqlalchemy.orm.Mapped[Dict[str, Any]] LCA parameters for this charging point type. Stored as a JSON object. Use ``eflips.lca.ChargingPointTypeLcaParams.from_dict()`` to deserialise. Contains control/power/user unit emission factors, concrete parameters, and infrastructure lifetime. .. py:attribute:: stations :type: sqlalchemy.orm.Mapped[List[eflips.model.Station]] The stations that have this charging point type. .. py:attribute:: areas :type: sqlalchemy.orm.Mapped[List[eflips.model.Area]] The areas that have this charging point type. .. py:method:: __repr__()