Skip to content

✨ Feature: Battery Lifetime Estimator#650

Merged
fderuiter merged 1 commit intomainfrom
feature/lifetime-estimator-5247989038705432542
Mar 13, 2026
Merged

✨ Feature: Battery Lifetime Estimator#650
fderuiter merged 1 commit intomainfrom
feature/lifetime-estimator-5247989038705432542

Conversation

@fderuiter
Copy link
Owner

This PR implements the "Lifetime Estimator" feature within the Battery Degradation module.

To prevent BatteryDegradationTab from becoming bloated, it was refactored to use the Strategy Pattern by defining a BatteryDegradationTool trait. The existing logic was moved to a CapacityFadeTool, and a new LifetimeEstimatorTool was added. This tool leverages the PowerLawModel from math_explorer to calculate the estimated battery life in years based on target capacity, DoD, and usage frequency.


PR created automatically by Jules for task 5247989038705432542 started by @fderuiter

- Refactored `BatteryDegradationTab` to use the `BatteryDegradationTool` trait (Strategy pattern) to manage sub-tools.
- Moved existing Capacity Fade logic into `CapacityFadeTool`.
- Implemented `LifetimeEstimatorTool` using `PowerLawModel::cycles_to_capacity` and typed values (`Capacity`, `DepthOfDischarge`) to calculate and display expected battery lifetime.
- Checked off "Lifetime Estimator" in `todo_gui.md`.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@fderuiter fderuiter marked this pull request as ready for review March 13, 2026 18:39
Copilot AI review requested due to automatic review settings March 13, 2026 18:39
@fderuiter fderuiter merged commit 2c6a95f into main Mar 13, 2026
1 check passed
@fderuiter fderuiter deleted the feature/lifetime-estimator-5247989038705432542 branch March 13, 2026 18:39
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Implements a new “Lifetime Estimator” feature in the Battery Degradation GUI module and refactors the tab to use a strategy-style sub-tool architecture to keep the main tab manageable.

Changes:

  • Introduces BatteryDegradationTool and refactors Battery Degradation into selectable sub-tools.
  • Extracts existing capacity-fade UI into CapacityFadeTool.
  • Adds LifetimeEstimatorTool that estimates lifetime (cycles/days/years) using PowerLawModel.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
todo_gui.md Marks “Lifetime Estimator” as completed in the roadmap.
math_explorer_gui/src/tabs/battery_degradation/mod.rs Adds the tool-trait + tool selector tab wrapper (BatteryDegradationTab).
math_explorer_gui/src/tabs/battery_degradation/capacity_fade.rs Refactors the existing UI into CapacityFadeTool implementing the new tool trait.
math_explorer_gui/src/tabs/battery_degradation/lifetime_estimator.rs Adds the new Lifetime Estimator tool UI and model-based calculation.
Comments suppressed due to low confidence (1)

math_explorer_gui/src/tabs/battery_degradation/capacity_fade.rs:30

  • self.dod is clamped to allow 0.0, but with the current PowerLawModel (negative exponent), DepthOfDischarge::new(0.0) makes n70 infinite (0.0.powf(negative) -> inf), which then propagates into plot/results. Consider enforcing a small positive minimum DoD here (e.g. 0.1) and aligning the UI slider range accordingly, or special-casing 0.0 as 'no cycling'.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


fn show(&mut self, ctx: &egui::Context) {
// Enforce valid ranges
self.target_capacity = self.target_capacity.clamp(0.1, 99.9);
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