Skip to content

Conversation

@brtietz
Copy link
Collaborator

@brtietz brtietz commented Sep 28, 2021

A floating point error (~1e-15) was causing a stack overflow in the powerflow code. Add a tolerance to fix the issue.

floating_point_stack_overflow

Alternative fix would be to set gen to zero if it's smaller than some tolerance. I think "tolerance" in the powerflow code is too high for this approach, I'd want 1e-7 or smaller for this approach.

Test with
Test_Case.zip

@brtietz brtietz merged commit 9a9fa13 into connect_outage_vars_to_powerflow Sep 28, 2021
@sjanzou
Copy link
Collaborator

sjanzou commented Sep 28, 2021

Still failing for case 3 of attached file, hangs at 66.6%
image

Case 3 of attached file - grid target 0 and time series critical load hangs as above image with these changes...
Test_Case.zip

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?

@brtietz brtietz added this to the SAM Fall 2021 Release milestone Dec 3, 2021
@brtietz brtietz deleted the add_tolerance_to_powerflow_error_check branch December 7, 2021 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants