Skip to content

Fix sam 976 daily losses batteries#780

Merged
brtietz merged 11 commits into
patchfrom
fix_sam_976_daily_losses_batteries
Mar 30, 2022
Merged

Fix sam 976 daily losses batteries#780
brtietz merged 11 commits into
patchfrom
fix_sam_976_daily_losses_batteries

Conversation

@brtietz

@brtietz brtietz commented Mar 10, 2022

Copy link
Copy Markdown
Collaborator

Rewrite some of the losses code so that daily AC losses are better accounted for, and don't cause infinite recursion for an AC-connected battery. Clean up the downstream implications so the grid and loss variables all add up. This entailed splitting losses into two categories: those that affect the output of the PV inverter, and those that affect all AC output. The latter category (system availability and daily losses) are a little fuzzy about energy tracking, but this maintains the behavior in the previous release. We are discussing ways to handle this in the next release.

This SAM file has pre-configured DC and AC systems with outages and losses:
DC_AC_Connected.zip

@brtietz brtietz added this to the 2021.12.02 Patch 2 milestone Mar 10, 2022
@brtietz brtietz requested a review from cpaulgilman March 10, 2022 20:55
@brtietz

brtietz commented Mar 10, 2022

Copy link
Copy Markdown
Collaborator Author

Fixes NatLabRockies/SAM#976

@brtietz

brtietz commented Mar 10, 2022

Copy link
Copy Markdown
Collaborator Author

I was a little sloppy in my branching, and accidentally pushed a fix for NatLabRockies/SAM#977 to this pull request as well. Mind reviewing both at once? A SAM file for the 2nd issue is here:
fuel_cell_issue_977.zip

If not, I can use git cherry-pick to fix things.

@cpaulgilman

Copy link
Copy Markdown
Collaborator

I was a little sloppy in my branching, and accidentally pushed a fix for NREL/SAM#977 to this pull request as well. Mind reviewing both at once? A SAM file for the 2nd issue is here: fuel_cell_issue_977.zip

If not, I can use git cherry-pick to fix things.

@brtietz I'll review both, no need to cherry pick. Thanks.

@cpaulgilman cpaulgilman 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.

This addresses SAM #976: The simulation now runs to completion when AC lifetime daily losses and/or DC lifetime daily losses are specified.

A couple of additional items:

  1. For a case with only 100% AC lifetime daily losses for days 1-5, SAM reports the "AC lifetime daily loss (kW)" as follows, where orange is "System power generated (kW)":

image

However, for a case with only 100% DC lifetime daily losses for Days 1-5, there is no equivalent "DC lifetime daily loss (kW)." (Note that the January 1 output is from the AC-connected battery because it starts at 50% SOC):

image

I think we should either report both a DC and AC lifetime daily loss value, or report a single lifetime daily loss value that includes both and is in AC kW.

  1. For the MiniGrid DC case in the file you provided, the time series "Electricity to load..." outputs are not clear to me. Are the daily lifetime losses included in the load?

image

@cpaulgilman

Copy link
Copy Markdown
Collaborator

I confirmed that this fixes NatLabRockies/SAM#977: Electricity to battery from fuel cell is now consistent with results from SAM 2020.12.02 before r1.

@brtietz

brtietz commented Mar 17, 2022

Copy link
Copy Markdown
Collaborator Author

Great testing! For the first chart, I went with adding a DC lifetime losses output, which I'll push shortly. The second chart has exposed some additional issues on how the powerflow code handles AC losses, in the 100% AC loss case, a DC connected battery should be unable to meet the load. It looks like I'm going to have to overhaul the AC losses code in the powerflow code (which to be fair, is pretty new), let me confirm a few things to make sure I get this right in the fix.

For a DC connected battery, the AC losses on the losses page should apply to all power - for example, the 1% wiring loss increases power drawn from the grid during grid charging:

image

For an AC connected battery, that sort of loss shows up in the AC/DC conversion efficiency instead, so the wiring loss only applies to the PV inverter:

image

Does that match your understanding of the assumptions for the losses page? The battery code currently treats all of the AC losses (wiring, transformer, availability, and lifetime) the same way, so if I need to break any of those out so they can be treated differently, let me know. Happy to discuss during the SAM meeting or a side meeting.

@cpaulgilman

Copy link
Copy Markdown
Collaborator

The unclear role of inputs on the Losses page for PV-Battery systems is because those inputs were originally designed for PV only systems. I think you are correct that the AC loss inputs currently only apply to the output of the PV inverter, and I think it makes sense to preserve that behavior for now.

There is a larger question of how to better manage all of the loss inputs, some of which seem to overlap: For PV-battery systems, the Shading and Layout, Losses, Battery Cell and System, Grid Limits, and Lifetime and Degradation pages all contain various kinds of loss inputs. "Grid Curtailment", "Availability" and "Lifetime Daily Losses" all include AC losses that are applied in different ways and in different parts of the code in addition to the transformer, transmission, and AC losses. I think this is worth discussion at some point and perhaps cleaning up for a future release.

@brtietz

brtietz commented Mar 23, 2022

Copy link
Copy Markdown
Collaborator Author

I did a deeper dive into pvsamv1, and I think two categories are appropriate for the current code: one that covers the losses in the pv inverter before an AC connected battery runs (wiring, transformer), and one that covers losses that are applied after the battery runs in both configurations (availability, lifetime). This sheet describes the current behavior:
ac_losses_matrix.xlsx

There's some ongoing discussion about whether transformer losses should be treated differently - the transformer loss probably should affect the output of the battery in some (front of meter) cases. If we want to go that route, I'll create a separate issue and fix it in a second pull request, since it would be a change in the behavior of that loss.

@brtietz brtietz marked this pull request as draft March 25, 2022 17:40
@brtietz brtietz marked this pull request as ready for review March 29, 2022 22:39
@brtietz brtietz requested a review from cpaulgilman March 29, 2022 22:39
@cpaulgilman

Copy link
Copy Markdown
Collaborator

@brtietz Thanks for diving into this and documenting your process. In the ac_losses_matrix.xlsx, I'm not sure what question "yes" and "no" answer. For each power flow shown in the matrix, is the question "Does AC loss apply?"

@brtietz

brtietz commented Mar 30, 2022

Copy link
Copy Markdown
Collaborator Author

@cpaulgilman Ah, no. It's "Given a 100% loss, is the action in column A allowed?" Also I made some changes since the version posted above, the latest version is here:
ac_losses_matrix.xlsx

@cpaulgilman

cpaulgilman commented Mar 30, 2022

Copy link
Copy Markdown
Collaborator

I think the behavior looks correct now.

It's a bit confusing that hourly kWh and lifetime kW "electricity to/from grid" are different in these results for the MiniGrid AC case of the DC_AC_Connected.sam test file -- lifetime hourly is zero for all time steps, as I think it should be due to the grid outage for all time steps (this is true in this branch and SAM 2021.12.02 r1):

ac-daily-losses-with-outage-ac-connected

@brtietz

brtietz commented Mar 30, 2022

Copy link
Copy Markdown
Collaborator Author

"Electricity to/from grid (year 1 hourly)" is computed in utility rate 5. I tried to handle the grid outage variables in cmod_grid, but it looks like utility rate 5 might need to reference the grid outage variable as well in order to correct that output.

Any objections to fixing that in a second issue? I feel like this pull request already has enough stuffed into it.

@cpaulgilman

Copy link
Copy Markdown
Collaborator

No objections from me. I was hesitant to bring it up here for that reason.

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.

2 participants