Skip to content

Commit

Permalink
Pass data through all compute modules to losses and powerflow code
Browse files Browse the repository at this point in the history
  • Loading branch information
brtietz committed Nov 8, 2024
1 parent 282d2a6 commit ebc31f7
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
1 change: 0 additions & 1 deletion shared/lib_battery_dispatch_automatic_fom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ void dispatch_automatic_front_of_meter_t::update_dispatch(size_t year, size_t ho
}

// Also charge from grid if it is valuable to do so, still leaving EnergyToStoreClipped capacity in battery
// TODO: Grid charging needs to check cleared capacity!
if (m_batteryPower->canGridCharge &&
((revenueToGridCharge >= revenueToPVChargeMax &&
revenueToGridCharge > 0 &&
Expand Down
12 changes: 10 additions & 2 deletions ssc/cmod_battery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1174,8 +1174,13 @@ battstor::battstor(var_table& vt, bool setup_model, size_t nrec, double dt_hr, c
batt_vars->batt_Qfull_flow, batt_vars->batt_initial_SOC, batt_vars->batt_maximum_SOC, batt_vars->batt_minimum_SOC, dt_hr);
}

// TODO: fix this!
std::vector<double> adj_losses(8760, 0.0);
std::vector<double> adj_losses;
adjustment_factors haf(&vt, "batt_adjust");
haf.setup(nrec);
for (size_t i = 0; i < nrec; i++) {
adj_losses.push_back(1.0 - haf(i)); // Convert to convention within powerflow and capacity code
}

if (batt_vars->batt_loss_choice == losses_params::MONTHLY) {
if (*std::min_element(batt_vars->batt_losses_charging.begin(), batt_vars->batt_losses_charging.end()) < 0
|| *std::min_element(batt_vars->batt_losses_discharging.begin(), batt_vars->batt_losses_discharging.end()) < 0
Expand Down Expand Up @@ -1846,6 +1851,9 @@ void battstor::advance(var_table*, double P_gen, double V_gen, double P_load, do
powerflow->acXfmrNoLoadLoss = xfmr_nll;
powerflow->powerSystemClipped = P_gen_clipped;

size_t lifetime_index = util::lifetimeIndex(year, hour, step, _dt_hour);
powerflow->adjustLosses = battery_model->getAvailabilityLoss(lifetime_index);

charge_control->run(year, hour, step, year_index);
outputs_fixed();
outputs_topology_dependent();
Expand Down
1 change: 1 addition & 0 deletions ssc/cmod_battwatts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ battwatts_create(size_t n_recs, size_t n_years, int chem, int meter_pos, double
cm_battwatts::cm_battwatts()
{
add_var_info(vtab_battwatts);
add_var_info(vtab_batt_adjustment_factors);
add_var_info(vtab_battery_outputs);
add_var_info(vtab_technology_outputs);
add_var_info(vtab_resilience_outputs);
Expand Down
1 change: 1 addition & 0 deletions ssc/cmod_pvsamv1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,7 @@ cm_pvsamv1::cm_pvsamv1()
add_var_info(vtab_dc_adjustment_factors);
add_var_info(vtab_technology_outputs);
add_var_info(vtab_battery_inputs);
add_var_info(vtab_batt_adjustment_factors);
add_var_info(vtab_forecast_price_signal);
add_var_info(vtab_battery_outputs);
add_var_info(vtab_resilience_outputs);
Expand Down
10 changes: 5 additions & 5 deletions ssc/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,11 +564,11 @@ var_info vtab_sf_adjustment_factors[] = {
var_info_invalid };

var_info vtab_batt_adjustment_factors[] = {
{ SSC_INPUT,SSC_NUMBER , "batt_adjust_constant" , "DC Constant loss adjustment", "%", "", "Adjustment Factors", "?=0" , "MAX=100" , ""},
{ SSC_INPUT, SSC_NUMBER, "batt_adjust_en_timeindex" , "Enable lifetime adjustment factors", "0/1", "", "Adjustment Factors", "?=0", "BOOLEAN", "" },
{ SSC_INPUT, SSC_NUMBER, "batt_adjust_en_periods" , "Enable period-based adjustment factors", "0/1", "", "Adjustment Factors", "?=0", "BOOLEAN", "" },
{ SSC_INPUT,SSC_ARRAY , "batt_adjust_timeindex" , "DC Lifetime Adjustment Factors" , "%" , "" , "Adjustment Factors" , "batt_adjust_en_timeindex=1" , "" , ""},
{ SSC_INPUT,SSC_MATRIX , "batt_adjust_periods" , "DC Period-based Adjustment Factors" , "%" , "n x 3 matrix [ start, end, loss ]" , "Adjustment Factors" , "batt_adjust_en_periods=1" , "COLS=3" , ""},
{ SSC_INPUT,SSC_NUMBER , "batt_adjust_constant" , "Battery Constant loss adjustment", "%", "", "Adjustment Factors", "?=0" , "MAX=100" , ""},
{ SSC_INPUT, SSC_NUMBER, "batt_adjust_en_timeindex" , "Enable battery lifetime adjustment factors", "0/1", "", "Adjustment Factors", "?=0", "BOOLEAN", "" },
{ SSC_INPUT, SSC_NUMBER, "batt_adjust_en_periods" , "Enable battery period-based adjustment factors", "0/1", "", "Adjustment Factors", "?=0", "BOOLEAN", "" },
{ SSC_INPUT,SSC_ARRAY , "batt_adjust_timeindex" , "Battery Lifetime Adjustment Factors" , "%" , "" , "Adjustment Factors" , "batt_adjust_en_timeindex=1" , "" , ""},
{ SSC_INPUT,SSC_MATRIX , "batt_adjust_periods" , "Battery Period-based Adjustment Factors" , "%" , "n x 3 matrix [ start, end, loss ]" , "Adjustment Factors" , "batt_adjust_en_periods=1" , "COLS=3" , ""},
var_info_invalid };

var_info vtab_financial_capacity_payments[] = {
Expand Down

0 comments on commit ebc31f7

Please sign in to comment.