Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion shared/lib_battery_powerflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,8 @@ void BatteryPowerFlow::calculateACConnected()
if ((fabs(P_grid_ac - P_grid_to_load_ac) > tolerance) && (-P_grid_ac > P_grid_to_load_ac)) {
P_battery_ac = P_pv_ac - P_pv_to_grid_ac - P_pv_to_load_ac - P_system_loss_ac;
P_battery_ac = P_battery_ac > 0 ? P_battery_ac : 0; // Don't swap from charging to discharging
m_BatteryPower->powerBatteryDC = -P_battery_ac * m_BatteryPower->singlePointEfficiencyACToDC;
// m_BatteryPower->powerBatteryDC = -P_battery_ac * m_BatteryPower->singlePointEfficiencyACToDC;
m_BatteryPower->powerBatteryDC = P_battery_ac * m_BatteryPower->singlePointEfficiencyACToDC;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code will only run when the battery is charging (see line 489), therefore the sign on line 493 is correct. We don't want this code swapping from charging to discharging, which is what line 494 now does.

If there's a less confusing way to do the sign swap between 491 and 493, I'm open to that, but at the end of this section powerBatteryDC needs to be a negative number. The StackOverflow issue needs to be solved between lines 304 and 385. (I'll try to narrow that down today)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My hunch on the lines was incorrect - proposed fix here: https://github.com/NREL/ssc/pull/620/files

Happy to accept a PR with just the "batt_annual_charge_energy" change.

return calculateACConnected();
}
}
Expand Down
1 change: 1 addition & 0 deletions ssc/common_financial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3314,6 +3314,7 @@ var_info vtab_lcos_inputs[] = {

{ SSC_INPUT, SSC_ARRAY, "batt_annual_charge_from_system", "Battery annual energy charged from system", "kWh", "", "Battery", "", "", "" },
{ SSC_INPUT, SSC_ARRAY, "batt_annual_discharge_energy", "Battery annual energy discharged", "kWh", "", "Battery", "", "", "" },
{ SSC_INPUT, SSC_ARRAY, "batt_annual_charge_energy", "Battery annual energy charged", "kWh", "", "Battery", "", "", "" },
{ SSC_INPUT, SSC_NUMBER, "batt_salvage_percentage", "Net pre-tax cash battery salvage value", "%", "", "Financial Parameters", "?=0", "MIN=0,MAX=100", "" },

{ SSC_INPUT, SSC_NUMBER, "battery_total_cost_lcos", "Battery total investment cost", "$", "", "Battery", "", "", "" },
Expand Down