commonpower.models.components.EVData

class EVData(name: str, config: dict = {})[source]

Bases: Component

Electric Vehicle with schedule data. An EV has a charge requirement which needs to be fulfilled by a certain deadline. To enable continous control, we assume that it is connected at the start of each “control cycle” and specify its departure and return time for each cycle. Once an EV is unplugged, we assume a decreasing state of charge such that soc=soc_init on return. This means the EV is modeled to behave identically in every cycle (once unplugged).

>>> from commonpower.models.components import EVData
>>> EVData.info()

---- INFO: EVData ----

+---------------------+----------+-------------------------------------------------+------------------+------------+------------------------------+---------------+
|       Element       |   Type   |                   Description                   |      Domain      |   Bounds   |       Required config        | Data provider |
+---------------------+----------+-------------------------------------------------+------------------+------------+------------------------------+---------------+
|          p          |  INPUT   |                   active power                  |      Reals       |    None    |           (lb, ub)           |               |
|         soc         |  STATE   |                 state of charge                 | NonNegativeReals |    None    |           (lb, ub)           |               |
|         rho         | CONSTANT |                 cost of wear pu                 | NonNegativeReals |    None    | constant or ParamInitializer |               |
|         etac        | CONSTANT |                charge efficiency                | NonNegativeReals | (0.0, 1.0) | constant or ParamInitializer |               |
|         etad        | CONSTANT |               discharge efficiency              | NonNegativeReals | (0.0, 1.0) | constant or ParamInitializer |               |
|         etas        | CONSTANT |            self-discharge coefficient           | NonNegativeReals | (0.0, 1.0) | constant or ParamInitializer |               |
|    is_plugged_in    |   DATA   |                presence indicator               |      Binary      |   (0, 1)   |                              |      Yes      |
| departure_indicator |   DATA   |               departure indicator               |      Binary      |   (0, 1)   |                              |      Yes      |
|   return_indicator  |   DATA   |                 return indicator                |      Binary      |   (0, 1)   |                              |      Yes      |
|     req_soc_rel     | CONSTANT | required final relative soc, i.e., soc/max(soc) | NonNegativeReals | (0.0, 1.0) | constant or ParamInitializer |               |
|       soc_init      | CONSTANT |          state of charge initial value          | NonNegativeReals |    None    |       ParamInitializer       |               |
|         cost        |   COST   |                  dispatch cost                  |      Reals       |    None    |                              |               |
+---------------------+----------+-------------------------------------------------+------------------+------------+------------------------------+---------------+

CONFIG TEMPLATE

{
    "p": "(lb, ub) (Reals)",
    "soc": "(lb, ub) (NonNegativeReals)",
    "rho": "constant or ParamInitializer (NonNegativeReals)",
    "etac": "constant or ParamInitializer (NonNegativeReals)",
    "etad": "constant or ParamInitializer (NonNegativeReals)",
    "etas": "constant or ParamInitializer (NonNegativeReals)",
    "req_soc_rel": "constant or ParamInitializer (NonNegativeReals)",
    "soc_init": "ParamInitializer (NonNegativeReals)"
}

---- INFO END ----

Generic power system device. We use this to model generators, loads, storage systems, etc.

Parameters:
  • name (str) – Name of the Component object.

  • config (dict, optional) – Configuration for defined model elements. Defaults to {}.

Methods

add_data_provider

Adds a data provider to the entity.

add_node

Components cannot have subordinate nodes.

add_to_model

This method adds the calling entity to the given (global) pyomo model. To this end, we - declare and add a new pyomo block named by self.id (the entity's global id). - call _get_model_elements() to retrieve the entity's model elements (variables and parameters). - call _augment_model_elements() to add additional model elements (constraints etc.). - check the configuration dict for completeness based on the defined model elements. - add all model elements to the previously declared pyomo block.

clear_data_providers

compute_cost

Computes the cost based on the specified cost_fcn and stores the result in the node's cost parameter.

cost_fcn

Cost of wear.

detach_controller

Remove the current controller from the entity

empty_copy

Creates a fresh copy of the node.

fix_inputs

Set the variables corresponding to inputs to fixed

get_children

get_input_ids

Get identifiers of input elements of a given model instance or self :param model_instance: model to get the input element identifiers for

get_inputs

Extracts model elements of type INPUT from a given model instance or self :param model_instance: model to get the input elements for :type model_instance: ConcreteModel, Optional

get_pyomo_element

Gets a pyomo element referenced by name from the given model.

get_pyomo_element_id

Constructs the global element name from the local name.

get_self_as_pyomo_block

Retrieves the pyomo block of the calling entity from a global model (based on the entity's global id).

get_value

Gets the value of the specified model element.

has_pyomo_element

This is essentially an indicator wrapper around get_pyomo_element() which returns False if no corresponding model element could be found (instead of raising an error).

info

Prints some information about this entity.

input_space

Determines the input space of an entity from the bounds of all model elements with type INPUT within the tree :param normalize: Whether or not to normalize the input space to [-1,1] :type normalize: bool

n_inputs

Total number of model elements with type INPUT within the entire tree of this entity

observation_space

Determines the observation space of an entity based on the observation mask by retrieving the bounds of the model elements listed in the mask

observe

Get observations for one node within the system based on the model items within the observation mask.

register_controller

Register a controller with this node :param controller: controller to be registered :type controller: BaseController

reset

Stores the current global model instance and initializes parameters according to their configuration.

set_id

Generates and sets the node id.

set_value

Sets the value of the specified model element to the specified value.

unmodeled_update

System updates that are not modeled.

update

This reads data providers and executes the dynamics of self and all subordinate nodes.

update_data

Reads data providers for self and all subnodes.

validate_controller

Used to check whether all nodes which require a controller have one assigned.

validate_data_providers

Validates if data providers have compatible configurations.

Attributes

CLASS_INDEX

MAX_P

_get_additional_constraints() List[ModelElement][source]

We add a number of constraints to represent the EVs behavior. For details refer to the source code.

_get_dynamic_fcn() List[ModelElement][source]

While plugged in, the dynamics follow those of a generic ESS.

\[soc_{t+1} = etas * soc_{t} + etas * p_{ec} * p_t + \frac{1}{etad} * (1 - p_{ec}) * p_t\]
classmethod _get_model_elements() List[ModelElement][source]

Returns primary model elements.

Returns:

List[ModelElement] – Model elements.

cost_fcn(scenario: CostScenario, model: ConcreteModel, t: int = 0) Expression[source]

Cost of wear.

\[cost = |p| * rho\]