Skip to content
Merged
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
2 changes: 1 addition & 1 deletion shared/lib_battery_powerflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ void BatteryPowerFlow::calculateACConnected()

// Error checking trying to charge from grid when not allowed
if (!m_BatteryPower->canGridCharge && P_battery_ac < -tolerance) {
if ((fabs(P_grid_ac - P_grid_to_load_ac) > tolerance) && (-P_grid_ac > P_grid_to_load_ac)) {
if ((fabs(P_grid_ac - P_grid_to_load_ac) > tolerance) && (-P_grid_ac > P_grid_to_load_ac + tolerance)) {
P_battery_ac = P_pv_ac - P_pv_to_grid_ac - P_pv_to_load_ac - P_system_loss_ac;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Fixes peak shaving stack overflow but not the grid target of zero with time series resilency calculations per case 3 in the attached sam project file in the comments

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Case three has different problems depending on which branch you're on. On connect_outage_vars... it gets into the stack overflow because the unmet critical load is drawn from the grid. On dispatch_for_grid_outage it fails because the resiliency runner isn't properly updating the battery power flow variables as it steps forward through the hypothetical outage.

I'm inclined to fix the problem on dispatch_for_grid_outage (since that branch has already fixed the first problem) but what do we do about #618 in that case?

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;
Expand Down