Skip to content

Commit

Permalink
Add fallback code if batt_adjust is not defined
Browse files Browse the repository at this point in the history
  • Loading branch information
brtietz committed Nov 8, 2024
1 parent ebc31f7 commit bd44be4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 2 additions & 0 deletions shared/lib_resilience.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ bool dispatch_resilience::run_outage_step_ac(double crit_load_kwac, double pv_kw
}
m_batteryPower->powerCritLoad = crit_load_kwac;
m_batteryPower->isOutageStep = true;
m_batteryPower->adjustLosses = _Battery->getAvailabilityLoss(current_outage_index);

dispatch_ac_outage_step(current_outage_index);

Expand All @@ -95,6 +96,7 @@ bool dispatch_resilience::run_outage_step_dc(double crit_load_kwac, double pv_kw
m_batteryPower->powerSystemClipped = pv_clipped;
m_batteryPower->sharedInverter->Tdry_C = tdry;
m_batteryPower->isOutageStep = true;
m_batteryPower->adjustLosses = _Battery->getAvailabilityLoss(current_outage_index);

dispatch_dc_outage_step(current_outage_index);

Expand Down
13 changes: 8 additions & 5 deletions ssc/cmod_battery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1174,11 +1174,14 @@ 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);
}

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
std::vector<double> adj_losses(1, 0.0);
if (vt.is_assigned("batt_adjust")) {
adj_losses.clear();
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) {
Expand Down

0 comments on commit bd44be4

Please sign in to comment.