Skip to content

Update dispatch for grid outages#632

Closed
brtietz wants to merge 56 commits into
developfrom
dispatch_for_grid_outage
Closed

Update dispatch for grid outages#632
brtietz wants to merge 56 commits into
developfrom
dispatch_for_grid_outage

Conversation

@brtietz

@brtietz brtietz commented Oct 28, 2021

Copy link
Copy Markdown
Collaborator

Brings the grid outage code into the mainline battery dispatch. Allows the resiliency runner and the outage dispatch to use the same code. Pairs with SAM pull request NatLabRockies/SAM#722, please pull dispatch_for_grid_outage branch to test.

Solves #631 and #590

  • Adds a second min SOC variable "batt_minimum_outage_SOC", so that the battery can have a different min SOC during nominal operation and an outage.
    • Also prevents the SOC from going to zero during the default outage behavior, allowing the battery to black start the PV inverter in the morning
  • Add new output variables:
    • batt_to_system_load - tracks the battery covering the inverter night time losses
    • outage_losses_unmet - tracks unmet losses separately from the unmet critical load
  • Updates the DC resiliency runner to better account for efficiency updates to meet the critical load
  • Modifies the dispatch planning code such that the dispatch algorithms re-plan after an outage
  • Modifies the losses code in pvsamv1 so that the resiliency code can dispatch against AC losses
  • Updates the test values to account for all of the above

Recommended tests:

  • Ensure that grid usage is zero during outage periods
  • Ensure that the resiliency runner predicts when the battery will hit the minimum state of charge
  • Ensure the outage code works with pvsamv1, battwatts, generic battery and fuel cell batttery

Brian Mirletz added 30 commits August 31, 2021 10:54
…t and construct one. set up outage framework including outage manager in dispatch functions for automated btm and manual
… way, fix an efficiency declaration issue in battwatts, and a constructor issue in the powerflow code
…ns to the resiliency runner. Update the tests in cmod_battery_test to reflect the decreased reslience due to these restrictions. Make the restrictions more explicit in the resiliency code to save on iterations
…veral bugfixes to both the outage dispatch and btm dispatch constraints, including appropriate test updates. custom dispatch is now further constrianed from discharging to the grid
…ariables to set up new tests, still need to update powerflow code
…osses when grid is down and battery is fully discharged
…eet critical load. Add efficiency into interative loop for charging such that there isn't critical load unmet during charging steps
…increase discharging or decrease charging to compensate
@brtietz

brtietz commented Oct 28, 2021

Copy link
Copy Markdown
Collaborator Author

It looks like I had to solve #614 to get one of the outage tests passing on Linux, so add that to the pile of issues this PR will fix.

Brian Mirletz added 3 commits November 1, 2021 10:25
@brtietz

brtietz commented Nov 1, 2021

Copy link
Copy Markdown
Collaborator Author

The file I've been using to test this is attached here:
test_grid_outage_2.zip

@sjanzou sjanzou left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I tested with your file posted and went through some other cases and found some interesting plots and the annoying desired duration in hours bug in the parametrics, kWh can be used with additional calculations
image

with some results that @n8blair might be interested in
image

@cpaulgilman may have an issue with the limits on the Battery page in the fuel cell and the dispatch page in the battery configuration (I do not see a way around that)
image

Hmmm.... Fuel cell is failing with an 8760 weather file and an 8760 load:
image

File for testing with failing fuel cell configuration
test_grid_outage_2_fuelcell.zip

bool chargeOnlySystemExceedLoad,
bool dischargeOnlyLoadExceedSystem
bool dischargeOnlyLoadExceedSystem,
double SOC_min_outage

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

at some point we should stick with one naming convention and c++ instead of java structure. Just a comment and nothing specific to this pull request

powerTempLoss_kW = tempLoss * m_numInverters * util::watt_to_kilowatt;
powerLossTotal_kW = powerDC_kW - powerAC_kW;
if (powerDC_kW < 0.0)
powerLossTotal_kW = fabs(powerDC_kW) - fabs(powerAC_kW); // DC connected grid charging

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Are the charging and discharging losses all accounted for in the difference here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is the fix for #631

The more detailed loss accounting is in lib_battery_power_dispatch.cpp, scattered throughout the calculation functions. There's also code in cmod_battery that does updates for the actual AC losses in pvsamv1. Many of the changes in those three files are related to loss computation.

Comment thread ssc/cmod_battwatts.cpp

// Power converters and topology
batt_vars->batt_topology = ChargeController::AC_CONNECTED;
batt_vars->batt_ac_dc_efficiency = 96;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is this really stating that changing and discharging efficiency is the same?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Sort of - this variable might be better named batt_ac_to_dc_efficiency. Since battwatts doesn't allow customization of these in the GUI, they are hardcoded to the detailed battery defaults.

Note that these lines have been moved to fix a big in the batt_power_charge/discharge kw (lines 209 and 210 in this PR), they haven't been changed.

@brtietz

brtietz commented Nov 2, 2021

Copy link
Copy Markdown
Collaborator Author

The issue with fuel cell and generic system was that battstor was overwriting the values of crit_load before cmod_battery had a chance to read them. I've fixed that issue, but a few others have cropped up in the ssc tests. I'll fix those tomorrow, and it'll hopefully be ready for another round of review in the afternoon.

@dguittet

dguittet commented Nov 4, 2021

Copy link
Copy Markdown
Collaborator

The file I've been using to test this is attached here: test_grid_outage_2.zip

Thanks for adding. When I opened this, there were no critical loads specified or outage time periods (the 8760 was all 0), is that expected?

@dguittet

dguittet commented Nov 4, 2021

Copy link
Copy Markdown
Collaborator

I built on dispatch_for_grid_outage for both sam & ssc, but when I save the file and re-open it, the critical loads & grid outage timeseries inputs are back to the defaults. So something in the saving and reopening process isn't working for me. Is it just me?

I'm adding some high-level feedback in the comments before digging into the code:

  1. image
    It'll be nice to have these e-16 numbers rounded to 0. Probably by the ssc losses and/or powerflow code

  2. image
    I think the inverter is supposed to be off at the start of the year when there's no power production, but at the start of the second year, this behavior seems to revert to inverter nighttime losses again.

  3. image
    This label should be "power" not "energy"

Brian Mirletz added 3 commits November 4, 2021 09:53
…ge value that said energy to power to match units. Set p_battery_ac to zero when it's less than tolerance in the powerflow code
@brtietz

brtietz commented Nov 4, 2021

Copy link
Copy Markdown
Collaborator Author

@dguittet Great catch on all of the above. Those should be fixed in the latest commit.

@dguittet dguittet left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Really well done on this large piece of work! And thanks for splitting up the grid outage work into separate PRs.

Comment thread shared/lib_resilience.cpp
if (pv_kwac > crit_load_kwac){
double remaining_kwdc = -(pv_kwac - crit_load_kwac) * m_batteryPower->singlePointEfficiencyACToDC;
remaining_kwdc = fmax(remaining_kwdc, max_charge_kwdc);
dispatch_kw(remaining_kwdc);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

looks like dispatch_kw is no longer used. would it be ok to delete?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, good catch!

else if (h > 16) {
load_prediction.push_back(700);
}
else if (h > 18) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this h>18 condition never comes on because anything > 18 is > 16 so will be set to 700

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Right, thanks. Removing this doesn't change the test result, and these tests still show what I want them to show (ability to resume normal dispatch after an outage), so I've just removed this else if block.

@brtietz

brtietz commented Nov 8, 2021

Copy link
Copy Markdown
Collaborator Author

Merged in 9cf27a1

@brtietz brtietz closed this Nov 8, 2021
@brtietz brtietz deleted the dispatch_for_grid_outage 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

3 participants