Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inverter class rewritten #164

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft

Conversation

NormannK
Copy link
Contributor

fully rewritten the inverter class
add tests

please check carefully
output from single_test_optimization.py is identical

@drbacke
Copy link
Contributor

drbacke commented Oct 12, 2024

We should BE very carefull Here and a Lot of more Tests are required. The Inverter behaviour is very sensitive to Changes and Bugs are hard to find

@NormannK
Copy link
Contributor Author

NormannK commented Oct 12, 2024

I increased the test coverage we do now test for:

  1. Excess Generation: The system handles more generation than consumption, feeding excess to the grid and charging the battery.
  2. Generation Equals Consumption: No feed-in or grid draw when generation matches consumption.
  3. Battery Discharge: The battery discharges to help meet consumption, and the grid supplies any remaining shortfall.
  4. Battery Empty: When the battery is empty, the grid covers the entire shortfall.
  5. Battery Full at Start: When the battery is full, excess generation is fed into the grid.
  6. Insufficient Generation, No Battery: When there’s insufficient generation and no battery discharge, the grid supplies the entire shortfall.
  7. Insufficient Generation with Battery Assistance: The battery partially discharges to cover a shortfall, with the grid supplying the rest.
  8. Zero Generation: When there’s zero generation, the system relies entirely on the battery and grid.
  9. Zero Consumption: Verifies that when there is no consumption, the energy is either fed to the grid or used to charge the battery.
  10. Zero Generation & Zero Consumption: Checks if the system correctly handles an idle state (no generation or consumption).
  11. Partial Battery Discharge: Extends the test where the battery only partially covers the shortfall, with the grid providing the remaining energy.
  12. Zero Generation, Full Battery, and High Consumption: Tests how well the inverter handles the case where only the battery and grid can fulfill consumption.

let me know if you have other scenarios we should test.

@NormannK
Copy link
Contributor Author

There are some things that should be done too but would extend the logic and im not sure how other parts of the optimization would react.
I would not allow it to handle wrong values.
e.g. you can hand over a negative generation value. This cant handle and something should produce an error or do something. e,g, adding:

        if generation < 0:
            generation = 0.0  # Treat invalid negative generation as zero

@NormannK
Copy link
Contributor Author

NormannK commented Oct 12, 2024

this should be the best test. i back ported the new test for the new class to the old class by only changing the import and the names of the function/variables called. minimal changes.
both files with _old should be deleted in a later PR if accepted.

@drbacke drbacke marked this pull request as draft October 22, 2024 08:48
@drbacke
Copy link
Contributor

drbacke commented Oct 22, 2024

Please re-run all tests, code changed quite a lot

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