Skip to content

Adding charge and discharge efficiency to pysam battery model#699

Open
johnjasa wants to merge 6 commits intoNatLabRockies:developfrom
johnjasa:pass_eff_to_batt
Open

Adding charge and discharge efficiency to pysam battery model#699
johnjasa wants to merge 6 commits intoNatLabRockies:developfrom
johnjasa:pass_eff_to_batt

Conversation

@johnjasa
Copy link
Copy Markdown
Collaborator

@johnjasa johnjasa commented Apr 24, 2026

Add charge and discharge efficiencies to PySAM battery performance model

Charge and discharge efficiencies set in the dispatch configuration are now applied in the PySAMBatteryPerformanceModel.simulate() method. Previously, these efficiencies were used in the Pyomo dispatch SOC inventory constraint but were not reflected in the PySAM battery performance output, causing a mismatch between planned dispatch and actual performance.

The fix adds charge_efficiency, discharge_efficiency, and round_trip_efficiency parameters to PySAMBatteryPerformanceModelConfig. These are applied on top of PySAM's internal chemistry-based losses when computing the battery output power. When no efficiencies are specified, both default to 1.0, preserving backward compatibility.

Would it be more appropriate to use this efficiency value in pySAM instead?
https://nrel-pysam.readthedocs.io/en/main/modules/Battery.html#PySAM.Battery.Battery.BatterySystem.batt_dc_ac_efficiency

Section 1: Type of Contribution

  • Feature Enhancement
    • Framework
    • New Model
    • Updated Model
    • Tools/Utilities
    • Other (please describe):
  • Bug Fix
  • Documentation Update
  • CI Changes
  • Other (please describe):

Section 2: Draft PR Checklist

  • Open draft PR
  • Describe the feature that will be added
  • Fill out TODO list steps
  • Describe requested feedback from reviewers on draft PR
  • Complete Section 7: New Model Checklist (if applicable)

TODO:

  • Step 1
  • Step 2

Type of Reviewer Feedback Requested (on Draft PR)

Structural feedback:

Implementation feedback:

Other feedback:

Section 3: General PR Checklist

  • PR description thoroughly describes the new feature, bug fix, etc.
  • Added tests for new functionality or bug fixes
  • Tests pass (If not, and this is expected, please elaborate in the Section 6: Test Results)
  • Documentation
    • Docstrings are up-to-date
    • Related docs/ files are up-to-date, or added when necessary
    • Documentation has been rebuilt successfully
    • Examples have been updated (if applicable)
  • CHANGELOG.md
    • At least one complete sentence has been provided to describe the changes made in this PR
    • After the above, a hyperlink has been provided to the PR using the following format:
      "A complete thought. [PR XYZ]((https://github.com/NatLabRockies/H2Integrate/pull/XYZ)", where
      XYZ should be replaced with the actual number.

Section 4: Related Issues

Hopefully resolves #474

Section 5: Impacted Areas of the Software

Section 5.1: New Files

None.

Section 5.2: Modified Files

See files tab

Section 6: Additional Supporting Information

PySAM does not expose charge/discharge efficiency as a configurable parameter - efficiency is determined internally by the battery chemistry. The efficiencies added here are applied as an external scaling on top of PySAM's output, matching the convention used by the Pyomo dispatch SOC inventory constraint and the generic StoragePerformanceModel.

Section 7: Test Results, if applicable

All 5 tests in test_pysam_battery.py pass (26 subtests total), including the new test_pysam_battery_charge_discharge_efficiency test and all existing regression tests.

@johnjasa johnjasa marked this pull request as ready for review April 24, 2026 00:23
Copy link
Copy Markdown
Collaborator

@elenya-grant elenya-grant left a comment

Choose a reason for hiding this comment

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

I think that these should be applied internal to the PySAM battery model.

The PySAM battery input parameters, batt_losses_charging and batt_losses_discharging could be set based on the user-input charge and discharge efficiency.

If the charge and discharge efficiency are going to be added to the PySAM storage model - these attributes could now be added to the StoragePerformanceBaseConfig (same with the corresponding __attrs_post_init__ logic)

@johnjasa
Copy link
Copy Markdown
Collaborator Author

johnjasa commented Apr 24, 2026

Chatting about this now with Elenya, action items for me on the PR:

  • make the losses internal to the pysam model
  • don't use the batt_losses_charging
  • do add them to the base config

@johnjasa johnjasa requested a review from elenya-grant April 27, 2026 19:46
@johnjasa
Copy link
Copy Markdown
Collaborator Author

Elenya will see if she can get the correct way to use the pySAM internal args

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants