Add battery energy integration#8
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds integration-based workflows to the RateMapBattery model so missions/endurance can be computed with time-history integration (including delivered energy, consumed charge, and stop reasons), and updates docs/examples/tests to reflect the new API.
Changes:
- Introduces
BatteryIntegrationResultas a public type for integration outputs (final state + histories + energy/charge + feasibility + stop reason). - Extends
RateMapBatterywith point-state internal-loss support plus multiple integration modes (time-based, target-DOD, and segmented power profiles) and energy knockdown helpers. - Updates documentation and examples to demonstrate integration-based advancement and new point-state helpers; expands tests to cover integration stop conditions.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
tests/test_battery.py |
Adds coverage for BatteryIntegrationResult, state_at_power_loss, and the new integration/knockdown helper methods. |
pythrust/battery/state.py |
Adds BatteryIntegrationResult with post-init normalization/validation of time-history data. |
pythrust/battery/rate_map.py |
Implements state_at_power_loss and a suite of SciPy-based integrators + DOD/power helper utilities. |
pythrust/battery/__init__.py |
Exposes BatteryIntegrationResult in the public battery API. |
examples/rate_map_battery_point_states.py |
Demonstrates the new internal-loss point-state helper. |
examples/rate_map_battery_mission.py |
Switches mission advancement from fixed-step step_current to integrate_current and uses delivered energy from the result. |
docs/examples.md |
Updates example descriptions to mention integration and the new power-loss point state. |
docs/battery_model.md |
Expands model docs with integration modes, helper tables, and usage examples. |
docs/api_reference.md |
Adds API reference tables for point-state and integration helper methods. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request enhances the documentation and API for the
RateMapBatterymodel, adds a newBatteryIntegrationResulttype, and updates the examples to demonstrate new integration features. The changes clarify available battery simulation modes, add support for integration-based workflows, and improve API consistency and usability.API and Type Additions:
BatteryIntegrationResultto the public API, representing the result of battery integration with final state, time histories, delivered energy, and stop reason. Includes validation logic to ensure data consistency. (pythrust/battery/state.py,pythrust/battery/__init__.py) [1] [2]Documentation Improvements:
docs/battery_model.mdanddocs/api_reference.mdto describe new point-state and integration helper methods, integration modes, and result reporting. Added method tables and example code for integration workflows. [1] [2] [3] [4]Example Updates:
examples/rate_map_battery_mission.pyto useintegrate_currentand accumulate delivered energy using the new result type. [1] [2]examples/rate_map_battery_point_states.pyto demonstrate the newstate_at_power_lossmethod. [1] [2]Minor Cleanups:
These changes make the battery model more robust, easier to use in time-stepped and mission simulations, and better documented for users.
Closes #7