Skip to content

Commit

Permalink
Merge pull request #1031 from NREL/real_time_info_for_price_signals
Browse files Browse the repository at this point in the history
Give price signals dispatch info about real time system power and load for dispatch for apples to apples comparison of forecast error
  • Loading branch information
brtietz authored May 26, 2023
2 parents 06c4c33 + 3dca820 commit aebe554
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 30 deletions.
21 changes: 20 additions & 1 deletion shared/lib_battery_dispatch_automatic_btm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ dispatch_automatic_behind_the_meter_t::dispatch_automatic_behind_the_meter_t(
bool chargeOnlySystemExceedLoad,
bool dischargeOnlyLoadExceedSystem,
bool behindTheMeterDischargeToGrid,
double SOC_min_outage
double SOC_min_outage,
int load_forecast_mode
) : dispatch_automatic_t(Battery, dt_hour, SOC_min, SOC_max, current_choice, Ic_max, Id_max, Pc_max_kwdc, Pd_max_kwdc, Pc_max_kwac, Pd_max_kwac,
t_min, dispatch_mode, weather_forecast_mode, pv_dispatch, nyears, look_ahead_hours, dispatch_update_frequency_hours, can_charge, can_clip_charge, can_grid_charge, can_fuelcell_charge,
battReplacementCostPerkWh, battCycleCostChoice, battCycleCost, battOMCost, interconnection_limit, chargeOnlySystemExceedLoad, dischargeOnlyLoadExceedSystem,
Expand All @@ -81,6 +82,8 @@ dispatch_automatic_behind_the_meter_t::dispatch_automatic_behind_the_meter_t(
_P_target_use.reserve(_num_steps);
_P_battery_use.reserve(_num_steps);

_load_forecast_mode = load_forecast_mode;

grid.reserve(_num_steps);
sorted_grid.reserve(_num_steps);

Expand Down Expand Up @@ -264,6 +267,20 @@ void dispatch_automatic_behind_the_meter_t::initialize(size_t hour_of_year, size
m_batteryPower->powerBatteryTarget = 0;
_day_index = 0;

// Give all algorithms real data for the current step (overwrite forecast if needed)
if (_load_forecast_mode != LOAD_LOOK_AHEAD) {
_P_load_ac[lifetimeIndex] = m_batteryPower->powerLoad;
}
// Lookahead forecasts may better account for losses than the code below, so don't run this if lookahead
if (_weather_forecast_mode != WF_LOOK_AHEAD) {
if (m_batteryPower->connectionMode == AC_CONNECTED) {
_P_pv_ac[lifetimeIndex] = m_batteryPower->powerSystem;
}
else {
_P_pv_ac[lifetimeIndex] = m_batteryPower->powerSystem * m_batteryPower->sharedInverter->efficiencyAC;
}
}

// clean up vectors
size_t lifetimeMax = _P_pv_ac.size();
for (size_t ii = 0; ii != _num_steps && lifetimeIndex < lifetimeMax; ii++)
Expand All @@ -274,6 +291,7 @@ void dispatch_automatic_behind_the_meter_t::initialize(size_t hour_of_year, size
_P_battery_use.push_back(0.);
lifetimeIndex++;
}

}
bool dispatch_automatic_behind_the_meter_t::check_new_month(size_t hour_of_year, size_t step)
{
Expand Down Expand Up @@ -320,6 +338,7 @@ void dispatch_automatic_behind_the_meter_t::sort_grid(size_t idx, FILE *p, const

// compute grid net from pv and load (no battery)
size_t count = 0;

for (size_t hour = 0; hour != 24 && idx < _P_load_ac.size(); hour++)
{
for (size_t step = 0; step != _steps_per_hour; step++)
Expand Down
6 changes: 5 additions & 1 deletion shared/lib_battery_dispatch_automatic_btm.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ class dispatch_automatic_behind_the_meter_t : public dispatch_automatic_t
bool chargeOnlySystemExceedLoad,
bool dischargeOnlyLoadExceedSystem,
bool behindTheMeterDischargeToGrid,
double SOC_min_outage
double SOC_min_outage,
int load_forecast_mode
);

~dispatch_automatic_behind_the_meter_t() override {};
Expand Down Expand Up @@ -166,6 +167,9 @@ class dispatch_automatic_behind_the_meter_t : public dispatch_automatic_t
/*! Full time-series of loads [kW] */
double_vec _P_load_ac;

/*! Forecast mode for loads (look ahead, look behind, custom) */
int _load_forecast_mode;

/*! Full time-series of target power [kW] */
double_vec _P_target_input;

Expand Down
2 changes: 1 addition & 1 deletion ssc/cmod_battery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1334,7 +1334,7 @@ battstor::battstor(var_table& vt, bool setup_model, size_t nrec, double dt_hr, c
batt_vars->batt_dispatch_auto_can_charge, batt_vars->batt_dispatch_auto_can_clipcharge, batt_vars->batt_dispatch_auto_can_gridcharge, batt_vars->batt_dispatch_auto_can_fuelcellcharge,
util_rate_data, batt_vars->batt_cost_per_kwh, batt_vars->batt_cycle_cost_choice, batt_vars->batt_cycle_cost, batt_vars->om_batt_variable_cost_per_kwh, batt_vars->grid_interconnection_limit_kW,
batt_vars->batt_dispatch_charge_only_system_exceeds_load, batt_vars->batt_dispatch_discharge_only_load_exceeds_system,
batt_vars->batt_dispatch_auto_btm_can_discharge_to_grid, batt_vars->batt_minimum_outage_SOC
batt_vars->batt_dispatch_auto_btm_can_discharge_to_grid, batt_vars->batt_minimum_outage_SOC, batt_vars->batt_dispatch_load_forecast
);
if (batt_vars->batt_dispatch == dispatch_t::CUSTOM_DISPATCH)
{
Expand Down
Loading

0 comments on commit aebe554

Please sign in to comment.