metrics
This module consists of code that computes virtual battery metrics associated with energy flexible operation.
Functions to estimate flexibility metrics from power consumption trajectories.
- electric_emission_cost.metrics.energy_capacity(baseline_kW, flexible_kW, timestep=0.25, ec_type='discharging', relative=True)[source]
Calculate the energy capacity of a virtual battery system. This approach implicitly assumes the system has completed a round-trip.
- Parameters:
baseline_kW (array-like) – The baseline power consumption of the facility in kW.
flexible_kW (array-like) – The flexible power consumption of the facility in kW.
timestep (float) – The time step of the data in hours. Default is 0.25 hours (15 minutes).
ec_type (str) – The type of energy capacity to calculate. Options are ‘average’, ‘charging’, ‘discharging’
relative (bool) – If True, return the fractional energy capacity. If False, return the absolute energy capacity.
- Raises:
ValueError – If ec_type is not one of the expected values (‘average’, ‘charging’, ‘discharging’).
- Returns:
The energy capacity of the virtual battery system in either relative or absolute terms.
- Return type:
- electric_emission_cost.metrics.net_present_value(capital_cost=0, electricity_savings=0, maintenance_diff=0, ancillary_service_benefit=0, service_curtailment=0, service_price=1.0, timestep=0.25, simulation_years=1, upgrade_lifetime=30, interest_rate=0.03)[source]
Calculate the net present value of flexibility of a virtual battery system.
- Parameters:
capital_cost (float) – The capital cost of the virtual battery system in $.
electricity_savings (float) – The electricity savings from the flexible operation in $.
maintenance_diff (float) – The difference in maintenance costs between the baseline and flexible operation in $.
ancillary_service_benefit (float) – The benefit from providing ancillary services in $.
service_curtailment (float) – The amount of service curtailment. If the virtual battery system produces a product, this may be in units of volume or mass (e.g., m^3 or kg).
service_price (float) – The marginal price of curtailed service $/amount. Amount here may refer to units of volume or mass (e.g., $/m^3 or $/kg).
timestep (float) – The time step of the data in hours. Default is 0.25 hours (15 minutes).
simulation_years (int) – The number of years in which the electricity savings or ancillary service benefits are calculated for. Default is 1 year.
upgrade_lifetime (int) – The number of years of operation left for the upgrade. Default is 30 years.
interest_rate (float) – The interest rate used to discount future cash flows. Default is 0.03.
- Raises:
Warning – If the capital cost is less than 0
ValueError – If the upgrade lifetime is less than or equal to 0
ValueError – If the interest rate is less than 0.
ValueError – if the timestep is less than or equal to 0.
- Returns:
The net present value benefit of the virtual battery system in $.
- Return type:
- electric_emission_cost.metrics.power_capacity(baseline_kW, flexible_kW, timestep=0.25, pc_type='average', relative=True)[source]
Calculate the power capacity of a virtual battery system. This approach implicitly assumes the system has completed a round-trip.
- Parameters:
baseline_kW (array-like) – The baseline power consumption of the facility in kW.
flexible_kW (array-like) – The flexible power consumption of the facility in kW.
timestep (float) – The time step of the data in hours. Default is 0.25 hours (15 minutes).
pc_type (str) – The type of power capacity to calculate. Options are ‘average’, ‘charging’, ‘discharging’, ‘maximum’
relative (bool) – If True, return the fractional power capacity. If False, return the absolute power capacity.
- Raises:
ValueError – If pc_type is not one of the expected values (‘average’, ‘charging’, ‘discharging’, ‘maximum’).
- Returns:
The power capacity of the virtual battery system in either relative or absolute terms.
- Return type:
- electric_emission_cost.metrics.roundtrip_efficiency(baseline_kW, flexible_kW)[source]
Calculate the round-trip efficiency of a flexibly operating power trajectory relative to a baseline.
- Parameters:
baseline_kW (list or np.ndarray) – power consumption data of the baseline system in units of kW
flexible_kW (list or np.ndarray) – power consumption data of the flexibly operating or cost-optimized system in units of kW.
- Raises:
TypeError – When baseline_kW and flexible_kW are not an acceptable type (e.g., list vs. np.ndarray).
ValueError – When baseline_kW and flexible_kW are not of the same length
Warnings – When baseline_kW and flexible_kW contain negative values, which may indicate an error in the data.
ValueError – When baseline_kW and flexible_kW contain missing values.
Warnings – When rte is calculated to be greater than 1. This may indicate an error in the assumptions behind the data.
- Returns:
The round-trip efficiency [0,1] of the flexible power trajectory relative to the baseline.
- Return type: