datafev.data_handling package

Submodules

datafev.data_handling.charger module

class src.datafev.data_handling.charger.ChargingUnit(cu_id, p_max_ch, p_max_ds, efficiency)[source]

Bases: object

Simulation model of EV chargers.

connect(ts, ev)[source]

This method connects an EV to the charger. It is called in execution of arrival routines.

Parameters:
  • ts (datetime.datetime) – Connection time.

  • ev (ElectricVehicle) – Connected EV object.

Return type:

None.

disconnect(ts)[source]

This method disconnects the connected EV from the charger. It is called in execution of departure routines.

Parameters:

ts (datetime.datetime) – Disconnection time.

Return type:

None.

occupation_record(start, end, step)[source]

This method is run after simulation to analyze the occupation profile of the charger.

Parameters:
  • start (datetime) – Start of the period of investigation.

  • end (datetime) – End of the period of investigation.

  • step (timedelta) – Time resolution of the period of investiation.

Returns:

record – Time indexed occupation record. Each index indicates a time step in the investigated period. Each value indicates the number of connected EVs (0 or 1) during a particular time step (i.e. index value).

Return type:

pandas.Series

set_active_schedule(ts)[source]

A single charger may be assigned with multiple schedules. For instance, it may have a schedule for the connected vehicle and another schedule for an EV that has reservation in the future. This method marks the one that has been set at ‘ts’ as the ‘active schedule’ so that it is considered to be ‘the schedule’ for the current charging event.

Parameters:

ts (datetime.datetime) – Time at which the schedule that should be activated was set.

Return type:

None.

set_schedule(ts, schedule_pow, schedule_soc)[source]

This method assigns a charging schedule to the charger.

Parameters:
  • ts (datetime.datetime) – Current time.

  • schedule_pow (pandas.Series) – Time indexed power schedule. Each index indicates a time step in the scheduling horizon. Each value indicates how much power the charger should supply (kW) during a particular time step (i.e. index value).

  • schedule_soc (pandas.Series) – Time indexed SOC schedule. Each index indicates a time step in the scheduling horizon. Each value indicates the SOC (0<soc<1) that the connected EV battery should achieve by a partiuclar time step (i.e. index).

Return type:

None.

supply(ts, tdelta, p)[source]

This method triggers ‘charge’ method of the connected EV. The connected EV charges with ‘p’ power during current time step. The charger consumes (for p>0) or inject (for p<0) from/to grid.

Parameters:
  • ts (datetime.datetime) – Current time.

  • tdelta (datetime.timedelta) – Length of time step.

  • p (float) – Charge power (kW). p>0 indicates EV charging and power consumption from the grid. p<0 indicates EV discharging and power injection to the grid.

Return type:

None.

uncontrolled_supply(ts, step)[source]

This method is run to execute the uncontrolled charging behavior.

Parameters:
  • ts (datetime.datetime) – Current time.

  • step (datetime.timedelta) – Length of time step.

Return type:

None.

datafev.data_handling.cluster module

class src.datafev.data_handling.cluster.ChargerCluster(cluster_id, topology_data)[source]

Bases: object

A charger cluster consists of X number of charging units. It is considered to be the lower aggregation level in the datafev framework. A single entity (e.g., a charging station operator, micro-grid controller, aggregator) is responsible for management of a cluster.

add_cu(charging_unit)[source]

This method is run at initialization of the cluster object. It adds charging units to the cluster.

Parameters:

charging_unit (ChargingUnit) – A charging unit object.

Return type:

None.

analyze_consumption_profile(start, end, step)[source]

This method is run after simulation to analyze the power consumption profile of the chargers in the cluster.

Parameters:
  • start (datetime) – Start of the period of investigation.

  • end (datetime) – End of the period of investigation.

  • step (timedelta) – Time resolution of the period of investiation.

Returns:

df – Table contining the power consumption profiles of chargers. Each index indicates a time step in the investigated period. Columns indicate the charger identifiers. The value of a single cell in this table indicates the power (kW) that the a particular charger imports (p>0) or exports (p<0) from or to the grid in a particular time step.

Return type:

pandas.DataFrame

analyze_occupation_profile(start, end, step)[source]

This method is run after simulation to analyze the occupation profile of the cluster.

Parameters:
  • start (datetime) – Start of the period of investigation.

  • end (datetime) – End of the period of investigation.

  • step (timedelta) – Time resolution of the period of investiation.

Returns:

record – Time indexed occupation record. Each index indicates a time step in the investigated period. Columns indicate the charger identifiers The value of a single cell in this table indicates whether a particular charger has (1) or has no (0) connected EV a particular time step.

Return type:

pandas.Series

enter_data_of_incoming_vehicle(ts, ev, cu)[source]

This method adds an entry in cc_dataset for the incoming EV. It is called in execution of arrival routines.

Parameters:
  • ts (datetime.datetime) – Current time.

  • ev (ElectricVehicle) – Electric vehicle object.

  • cu (ChargingUnit) – Charging unit object.

Return type:

None.

enter_data_of_outgoing_vehicle(ts, ev)[source]

This method enters the data about the charging event to the cc_dataset for an outgoing EV. It is usually called in execution of departure routines.

Parameters:
  • ts (datetime.datetime) – Current time.

  • ev (ElectricVehicle) – Electric vehicle object.

Return type:

None.

enter_power_limits(start, end, step, limits, tolerance=0)[source]

This method enters limits (lower and upper) for aggregate net power consumption of the cluster within a specific period. It is often run at the begining of simulation. However, it is possible to call this method multiple times during the simulation to update the peak power limits of the cluster.

Parameters:
  • start (datetime.datetime) – Start of the period for which the limits are set.

  • end (datetime.datetime) – End of the period for which the limits are set.

  • step (datetime.timedelta) – Time resolution of the target period.

  • limits (pandas.DataFrame) – Time indexed table indicating the lower and upper limits. index –> Identifier of time steps LB –> Lower bound of consumption limit at a particular time step UB –> Lower bound of consumption limit at a particular time step

  • tolerance (float, optional) – It is possible to specify a tolerance range (kW) for violation of the given limits. If specified, the net consumption of the cluster is allowed to be larger than the upper limit or smaller than the lower limit but such violation should not exceed ‘tolerance’. The default is 0.

Return type:

None.

export_results_to_excel(start, end, step, xlfile)[source]

This method is run after simulation to analyze the simulation results related to the cluster. It exports simulation results to an xlsx file.

Parameters:
  • start (datetime.datetime) – Start of the period of investigation.

  • end (datetime.datetime) – End of the period of investigation.

  • step (datetime.timedelta) – Time resolution of the period of investiation.

  • xlfile (str) – The name of the xlsx file to export results.

Return type:

None.

query_actual_occupation(ts)[source]

This function identifies currently occupied chargers. It is usually called in execution of arrival routines.

Parameters:

ts (datetime.datetime) – Current time.

Returns:

nb_of_connected_cu – Number of occupied chargers.

Return type:

int

query_actual_schedule(start, end, step)[source]

This method retrieves the aggregate schedule of the cluster for a specific query (future) period considering actual schedules of the charging units. It is usually run in execution of reservation protocol.

Parameters:
  • start (datetime.datetime) – Start of queried period (EV’s estimated arrival at this cluster).

  • end (datetime.datetime) – End of queried period (EV’s estimated arrival at this cluster).

  • step (datetime.timedelta) – Time resolution in the queried period.

Returns:

cc_sch – Time indexed power schedule of cluster. Each index indicates a time step in the queried period. Each value indicates how much power the cluster should consume (kW) during a particular time step (i.e. index value).

Return type:

pandas.Series

query_availability(start, end, step)[source]

This function creates a dataframe containing the data of the available chargers for a specific period. It is usually called in execution of reservation routines.

Parameters:
  • start (datetime.datetime) – Start of queried period (EV’s estimated arrival at this cluster).

  • end (datetime.datetime) – End of queried period (EV’s estimated arrival at this cluster).

  • step (datetime.timedelta) – Time resolution in the queried period.

Returns:

available_chargers – Table containing the data of available chargers. index–> string identifier max p_ch –> maximum charge power max p_ds –> maximum discharge power eff –> power conversion efficiency of the charger.

Return type:

pandas.DataFrame

reserve(ts, res_from, res_until, ev, cu, contract=None)[source]

This method reserves a charging unit for an EV for a specific period. It is usually called in execution of reservation protocol. However, it is called also in execution of arrival protocol in scenarios without advance reservations.

Parameters:
  • ts (datetime.datetime) – Current time (i.e., when the reservation is placed).

  • res_from (datetime.datetime) – Start of the reservation period.

  • res_until (datetime.datetime) – End of the reservation period.

  • ev (ElectricVehicle) – Reserving electric vehicle.

  • cu (ChargingUNit) – Reserved charging unit.

  • contract (dictionary, optional) – datafev framework distinguishes two types of reservations. Simple reservations only indicate a reservation period. Smart reservations include schedules and optionally price details. The default is None.

Return type:

None.

uncontrolled_supply(ts, step)[source]

This method is run to execute the uncontrolled charging behavior.

Parameters:
  • ts (datetime.datetime) – Current time.

  • step (datetime.timedelta) – Length of time step.

Return type:

None.

unreserve(ts, reservation_id)[source]

This method cancels a particular reservation. It is usually called in execution of departure routines.

Parameters:
  • ts (datetime.datetime) – Current time.

  • reservation_id (str) – Identifier of the reservation to be cancelled.

Return type:

None.

datafev.data_handling.fleet module

class src.datafev.data_handling.fleet.EVFleet(fleet_id, behavior, sim_horizon)[source]

Bases: object

Class to define charging demand of an EV fleet.

enter_power_soc_table(table)[source]

In practice, power that can be handled (withdrawn/injected) by EV batteries change by SOC. This method is called to enter SOC dependency data of the EVs in the scenario. SOC dependency is defined in a table.

Parameters:

table (pandas.DataFrame) –

This table contains all EVs SOC dependency data. Each EV’s data has the following parameters:
  • index –> Identifier of the SOC range,

  • SOC_LB –> Lower bound of a particular SOC range,

  • SOC_UB –> Upper bound of a particular SOC range,

  • P_LB –> Lower bound of power capability in a particular SOC range,

  • P_UB –> Upper bound of power capability in a particular SOC range.

Return type:

None.

export_results_to_excel(start, end, step, xlfile)[source]

This method is run after simulation to analyze the simulation results related to the EV fleet. It exports simulation results to a xlsx file.

Parameters:
  • start (datetime.datetime) – Start of the period of investigation.

  • end (datetime.datetime) – End of the period of investigation.

  • step (datetime.timedelta) – Time resolution of the period of investigation.

  • xlfile (str) – The name of the xlsx file to export results.

Return type:

None.

incoming_vehicles_at(ts)[source]

The method to query vehicles that arrive in charger clusters at a particular time step in simulation.

Parameters:

ts (datetime.datetime) – The queried time step.

Returns:

The list of the objects that arrive in clusters at ts.

Return type:

list

outgoing_vehicles_at(ts)[source]

The method to query vehicles that leave charger clusters at a particular time step in simulation.

Parameters:

ts (datetime) – The queried time step

Returns:

The list of the objects that leave clusters at ts.

Return type:

list

reserving_vehicles_at(ts)[source]

The method to query vehicles that place reservation request at a particular time step in simulatio.

Parameters:

ts (datetime) – The queried time step

Returns:

The list of the objects that place reservation request at ts.

Return type:

list

datafev.data_handling.multi_cluster module

class src.datafev.data_handling.multi_cluster.MultiClusterSystem(system_id)[source]

Bases: object

A multi-cluster system consists of X number of charger clusters. It is considered to be the higher aggregation level in the datafev framework. It contains multiple controlling entities each being responsible for management of a cluster.

add_cc(cluster)[source]

This method is run at initialization of the multicluster system object. It adds clusters to the self.clusters dictionary.

Parameters:

cluster (ChargerCluster) – A charger clusterobject.

Return type:

None.

enter_power_limits(start, end, step, peaklimits)[source]

This method enters limits (lower and upper) for aggregate net power consumption of the multi-cluster system within a specific period. It is often run at the begining of simulation. However, it is possible to call this method multiple times during the simulation to update the peak power limits of the system.

Parameters:
  • start (datetime.datetime) – Start of the period for which the limits are set.

  • end (datetime.datetime) – End of the period for which the limits are set.

  • step (datetime.timedelta) – Time resolution of the target period.

  • limits (pandas.DataFrame) –

    Time indexed table indicating the lower and upper limits:
    • index –> Identifier of time steps,

    • LB –> Lower bound of consumption limit at a particular time step,

    • UB –> Upper bound of consumption limit at a particular time step.

Return type:

None.

enter_tou_price(series, resolution)[source]

This method enters electricity price data as time series in the desired resolution. It is usually called before running simulation.

Parameters:
  • series (pandas.Series) – Electricity price data.

  • resolution (int) – Desired resolution.

Return type:

None.

export_results_to_excel(start, end, step, xlfile)[source]

This method is run after simulation to analyze the simulation results related to the multi-cluster system. It exports simulation results to an xlsx file.

Parameters:
  • start (datetime.datetime) – Start of the period of investigation.

  • end (datetime.datetime) – End of the period of investigation.

  • step (datetime.timedelta) – Time resolution of the period of investiation.

  • xlfile (str) – The name of the xlsx file to export results.

Return type:

None.

query_actual_schedules(ts, t_delta, horizon)[source]

This method retrieves the aggregate schedule of the cluster for a specific query (future) period considering actual schedules of the charging units. It is usually run in execution of reservation protocol.

Parameters:
  • start (datetime.datetime) – Start of queried period (EV’s estimated arrival at this cluster).

  • end (datetime.datetime) – End of queried period (EV’s estimated arrival at this cluster).

  • step (datetime.timedelta) – Time resolution in the queried period.

Returns:

cc_sch – Time indexed power schedules of clusters. Each index indicates a time step in the queried period. Each column indicates a charger cluster. A cell value indicateshow much power the cluster should consume (kW) during a particular time step (i.e. index value).

Return type:

pandas.DataFrame

query_availability(start, end, step, deviations)[source]

This function creates a dataframe containing the data of the available chargers for a specific period. It is usually called in execution of reservation routines.

Parameters:
  • start (datetime.datetime) – Start of queried period.

  • end (datetime.datetime) – End of queried period.

  • step (datetime.timedelta) – Time resolution in the queried period.

  • deviations (dict) – Deviations in estimated arrival/departure times. These data are obtained from the traffic forecast if availble. It

Returns:

available_chargers

Table containing the data of available chargers in the system:

index –> string identifier of the charger cluster –> string identifier of the cluster max p_ch –> maximum charge power max p_ds –> maximum discharge power eff –> power conversion efficiency of the charger.

Return type:

pandas.DataFrame

uncontrolled_supply(ts, step)[source]

This method is run to execute the uncontrolled charging behavior.

Parameters:
  • ts (datetime.datetime) – Current time.

  • step (datetime.timedelta) – Length of time step.

Return type:

None.

visualize_cluster_loading(start, end, step)[source]

This method is run after simulation to plot the aggregate power consumption profiles of the clusters as well as the power consumption limits.

Parameters:
  • start (datetime.datetime) – Start of the period of investigation.

  • end (datetime.datetime) – End of the period of investigation.

  • step (datetime.timedelta) – Time resolution of the period of investiation.

  • xlfile (str) – The name of the xlsx file to export results.

Returns:

fig – The figure containing the cluster load profiles in subplots.

Return type:

matplotlib.pyplot

visualize_cluster_occupation(start, end, step)[source]

This method is run after simulation to plot the occupation profiles of the clusters in the multi-cluster system.

Parameters:
  • start (datetime.datetime) – Start of the period of investigation.

  • end (datetime.datetime) – End of the period of investigation.

  • step (datetime.timedelta) – Time resolution of the period of investiation.

  • xlfile (str) – The name of the xlsx file to export results.

Returns:

fig – The figure containing the cluster occupation profiles in subplots.

Return type:

matplotlib.pyplot

visualize_fulfillment_rates(fleet)[source]
This method is run after simulation to plot the fulfillment rates in three performance metrics:
  • Real/scheduled parking duration,

  • real/scheduled G2V supply.

  • and real/scheduled V2G supply.

Parameters:

fleet (datafev.Fleet.EVFleet) – EVFleet object containing the EV objects involved in simulation.

Returns:

fig – The figure containing the parallel coordinate figures for three fulfillment metrics in each y-axis.

Return type:

matplotlib.pyplot

datafev.data_handling.vehicle module

class src.datafev.data_handling.vehicle.ElectricVehicle(carID, bCapacity, p_max_ch=50, p_max_ds=50, minSoC=0.0, maxSoC=1.0, pow_soc_table=None)[source]

Bases: object

Simulation model of electric vehicles.

charge(ts, tdelta, p_in)[source]

The method to enter the charging data to EV.

Parameters:
  • ts (datetime) – Current time.

  • tdelta (timedelta) – Length of time step.

  • p_in (float) –

    Charge power to starting from ts for tdelta by p_in:

    p_in>0 charging, p_in<0 discharging.

Return type:

None.