evnrg.simulation package¶
Subpackages¶
Submodules¶
evnrg.simulation.bracket module¶
-
class
evnrg.simulation.bracket.
BracketNT
[source]¶ Bases:
tuple
Deprecated, but kept for reference
-
begin
¶ Alias for field number 0
-
dist
¶ Alias for field number 6
-
end
¶ Alias for field number 1
-
idist
¶ Alias for field number 7
-
index
¶ Alias for field number 2
-
length
¶ Alias for field number 3
-
mask
¶ Alias for field number 4
-
status
¶ Alias for field number 5
-
stopped
¶ Alias for field number 8
-
evnrg.simulation.eligibility module¶
-
class
evnrg.simulation.eligibility.
EligibilityRules
(mask, threshold_priority, away_threshold, home_threshold)[source]¶ Bases:
tuple
-
away_threshold
¶ Alias for field number 2
-
home_threshold
¶ Alias for field number 3
-
mask
¶ Alias for field number 0
-
threshold_priority
¶ Alias for field number 1
-
-
class
evnrg.simulation.eligibility.
ECode
[source]¶ Bases:
tuple
Small NamedTuple to indicate the stop’s eligibility.
-
begin_index
¶ Beginning index of the stop.
Type: int
-
end_index
¶ Ending inde xof the stop. This is also the index of the beginning of the next trip.
Type: int
-
code
¶ The status of the a stop. Will be one of Status.INELIGIBLE, Status.HOME_ELIGIBLE, or Status.AWAY_ELIGIBLE. If the stop is not actually a stop, Status.DRIVING is used.
Type: Status
-
begin_index
Alias for field number 0
-
code
Alias for field number 2
-
end_index
Alias for field number 1
-
evnrg.simulation.fleet module¶
-
class
evnrg.simulation.fleet.
Fleet
(df: pandas.core.frame.DataFrame, powertrains: list, probabilities: list, rules: evnrg.simulation.eligibility.EligibilityRules)[source]¶ Bases:
object
A collection of vehicles and data connecting them.
-
add_vehicle
(col_id, pt: evnrg.common.powertrain.Powertrain, rules: evnrg.simulation.eligibility.EligibilityRules)[source]¶
-
assign_powertrains
(powertrains: list, probabilities: list, rules: evnrg.simulation.eligibility.EligibilityRules)[source]¶
-
df
¶
-
fleet_ids
¶
-
get_powertrain_distribution
(powertrains: list, probabilities: list, rules: evnrg.simulation.eligibility.EligibilityRules)[source]¶
-
size
¶
-
vehicle_ids
¶
-
vehicles
¶
-
evnrg.simulation.loop module¶
evnrg.simulation.simulation module¶
-
class
evnrg.simulation.simulation.
SimulationResult
(deferred, fuel_use, occupancy, demand, battery, uid, errors)[source]¶ Bases:
tuple
-
battery
¶ Alias for field number 4
-
deferred
¶ Alias for field number 0
-
demand
¶ Alias for field number 3
-
errors
¶ Alias for field number 6
-
fuel_use
¶ Alias for field number 1
-
occupancy
¶ Alias for field number 2
-
uid
¶ Alias for field number 5
-
-
evnrg.simulation.simulation.
run_simulation
(sc: evnrg.common.scenario.Scenario, storage_info: evnrg.storage.datastorage.StorageInfo)[source]¶ Runs a simulation with a given scenario by downloading data, running the simulation, and uploading results.
Parameters: sc (Scenario) – The scenario structure to use. Returns: A SimulationResult with all the relevant energy data.
evnrg.simulation.vehicle module¶
-
class
evnrg.simulation.vehicle.
Vehicle
(fleet_index: int, ptrain: evnrg.common.powertrain.Powertrain, distance: numpy.array, rules: evnrg.simulation.eligibility.EligibilityRules, start_soc: float = 1.0, soc_buffer: float = 0)[source]¶ Bases:
object
The primary driving logic object.
The Vehicle object keeps track of all data and operations specific to an individual vehicle. Many of the operations are sped up through external JITed functions.
-
fleet_id
¶ The column index of the vehicle for use when referencing 2-D array or positions in a Fleet object.
Type: int
-
powertrain
¶ The ‘Powertrain used for this vehicle’s energy calculations.
Type: Powertrain
-
max-soc
The maximum state of charge (0.0 to 1.0) this vehicle’s battery may reach. This will be handy for modeling battery degradation. For now, it defaults to 1.
Type: float
-
evse_power
¶ The effective power level in kW that this vehicle is connected to. If the vehicle is not connected to EVSE, this value is 0.
Type: float
-
distance_a
¶ A 1-D array of type numpy.float32 that contains the interval distance data. Unless deferring and rewriting trips, this array should generally be treated as read-only.
Type: numpy.array
-
fuel_burned_a
¶ A 1-D array of type numpy.float32 that holds fuel consumption data.
Type: numpy.array
-
deferred_a
¶ A 1-D array of type numpy.float32 that holds deferred distance. When BEVs have to defer trips, the distances are copied to this array before the window in distance_a is set to zero. This offers useful data about trip completion by BEVs.
Type: numpy.array
-
battery_a
¶ A 1-D array of type ‘numpy.float32` that reflects the battery energy of the vehicle over time.
Type: numpy.array
-
idx
¶ The internal index for the Vehicle object.
Type: int
-
begin_energy
¶ The energy the vehicle starts with. This value is referenced in battery operations when idx is 0.
Type: float
-
status
¶ indicates the current status of the vehicle. The value is held by an int, but is generally set by referencing the Status object (which is an enum.IntEnum). Do not try to evaluate this value on its own. Instead use Status (e.g.
vehicle.status == Status.CONNECTED
Type: int
Parameters: - fleet_index (int) – The vehicle column index from a Fleet object.
- ptrain (Powertrain) – The Powertrain object that will be used with this vehicle.
- distance (numpy.array) – A 1-D numpy.array of type numpy.float32 that holds the interval distance data for this vehicle.
- rules (EligibilityRules) – The EligibilityRules that will be used to evaluate the initial charging eligibility if start_soc is less than 1.0.
- start_soc (float) – The initial state of charge of the vehicle. Defaults to 1.0 (100%).
-
advance_index
(rules: evnrg.simulation.eligibility.EligibilityRules, min_per_interval: float)[source]¶
-
attempt_defer_trips
(rules: evnrg.simulation.eligibility.EligibilityRules, min_per_interval: float)[source]¶
-
battery_a
-
battery_state
¶ Provides the “incoming” battery state (from the previous index).
Returns: A float representing the battery energy.
-
begin_energy
-
charge_battery
(energy: float)[source]¶ Charges the battery.
Essentially a wrapper for Vehicle.delta_battery(), esxcept that this function checks to ensure there is EVSE connected.
Parameters: energy (float) – The energy to add Returns: - A float representing net energy added.
- This adjusts for the fact the battery may be nearly full.
-
connect_evse
(power, dcfc, plugs=None)[source]¶ Attempts to connect EVSE to the vehicle.
Checks to see if the connection is compatible.
Parameters: - power (float) – The input power from the EVSE
- dcfc (bool) – Whether the input is DC.
- ( (plugs) – obj: iterable, optional): An iterable containing the DC connectors available at this EVSE. Defaults to None. This is only needed for DC connections. AC connections are assumed to be J1772.
Returns: False if connection fails, or a float representing the effective power level of the conenction (in kW).
-
deferred_a
-
delta_battery
(delta: float)[source]¶ Sets the current index’s battery state.
The battery will be normalized to zero or the battery max.
Parameters: delta (float) – The change in the battery. Returns: A float representing the current battery energy.
-
distance
¶
-
distance_a
-
elapsed_distance
¶ Returns the elapsed distance for this simulation
-
ev_range
¶ Returns the range (in km) the battery has remaining.
-
evse_connected
¶ Indicates if the attribute evse_power is greater than zero. A value of True indicates that an EVSE is connected to the vehicle.
-
evse_power
-
fleet_id
-
fuel_burned_a
-
idx
-
increment_index
(index: int)[source]¶ Advances the vehicle’s index, but only if ithe vehicle is behind.
Parameters: index (int) – The index to attempt to advance to. Returns: - An int indicating the number intervals behind or forward
- the vehicle’s internal index is.
-
index_sync
(index: int)[source]¶ Reports back how many intervals ahead or behind the vehicle is.
Parameters: index (int) – The index to check against Returns: - An int indicating the differnce between index and the
- vehicle’s index. A negative number indicates the vehicle is ahead. A positive number indicates it is behind. Zero indicates the indexes are in sync.
-
intervals
¶ The length of the distance array.
Returns: A length of type int. Raises: AssertionError if the length is zero.
-
is_driving
¶ Returns a bool indicating if the vehicle is driving.
-
is_new_stop
¶
-
is_stopped
¶ Returns the opposite of is_driving.
-
max_ev_range
¶ The electric range the vehicle would have on a fully-charged battery.
-
max_soc
¶
-
powertrain
-
progress
¶ Returns how far through its distance array the vehicle is. The value is expressed as a float percentage wher 1.0 is 100%.
-
set_battery
(val: float, previous: bool = True)[source]¶ Sets the battery energy.
Parameters: - val (float) – The value to set the battery to. Nomalizes to be between 0 and the battery’s max.
- ( (previous) – obj: bool, optional): Whether to set the previous index’s value. Defaults to True. If the current index is 0, then sets the beginning value for the vehicle.
-
soc
¶ Returns the battery state of charge as a percentage.
-
soc_buffer
¶
-
status
-
total_distance
¶ Returns the total distance for the simuilation. .. note:: This value will change if trips are deferred!
-
will_drive_next
¶ Indicates whether the next interval will start a trip.
-