eelib.core.devices.ev.ev_simulator

Mosaik interface for the eELib car model. Simulator for communication between orchestrator (mosaik) and car entities.

Within this interface mosaik functionalities are used. Copyright (c) LGPL

Author: elenia@TUBS
Copyright 2024 elenia
This file is part of eELib, which is free software under the terms of the GNU GPL Version 3.

Module Contents

Classes

Sim

Simulator class for eELib car model.

Attributes

ADAPTION_TOLERANCE

META

ADAPTION_TOLERANCE = '1e-05'
META
class Sim

Bases: mosaik_api_v3.Simulator

Simulator class for eELib car model.

output_cache
data
entities
init(sid: str, scenario_config: dict, time_resolution: int = 1) dict

Initializes parameters for an object of the Car:Sim class.

Parameters:
  • sid (str) – Id of the created instance of the car simulator (e.g. CarSim-0).

  • scenario_config (dict) – scenario configuration data, like resolution or step size.

  • time_resolution (int) – fitting of the step size to the simulation scenario step size.

Returns:

description of the simulator

Return type:

dict

create(num: int, model_type: str, init_vals: dict) dict

Creates instances of the eELib car model.

Parameters:
  • num (int) – Number of car models to be created

  • model_type (str) – Description of the created instance (here “Car”)

  • init_vals (dict) – dict (length=num) with initial values for each car model

Raises:

ValueError – If entity ID is already existing

Returns:

created entities

Return type:

dict

get_entity_by_id(entity_id: str) eelib.core.devices.ev.ev_model.EV

Searches for a requested entity id and gives back the entity model.

Parameters:

entity_id (str) – id of the entity to be searched for

Returns:

entity model if found, None otherwise

Return type:

ev_model.EV

step(time: int, inputs: dict, max_advance: int) int

Performs simulation step calling the eELib-car model.

Parameters:
  • time (int) – Current simulation time according to step size. Given by MOSAIK.

  • inputs (dict) – Is a dictionary, that maps entity IDs to data dictionaries which map attribute names to lists of values. Given by MOSAIK.

  • max_advance (int, optional) – Is the simulation time until the simulator can safely advance it’s internal time without causing any causality errors.

Raises:
  • ValueError – Error if incoming input has wrong format or includes more than one set value

  • TypeError – value_dict has unknown format

Returns:

New timestamp (time increased by step size)

Return type:

int

get_data(outputs: dict) dict

Gets the data for the next concatenated model. Core function of mosaik.

Parameters:

outputs (dict) – Dictionary with data outputs from each car model

Raises:

ValueError – Error if attribute not in model metadata

Returns:

Dictionary with simulation outputs

Return type:

dict