-
Notifications
You must be signed in to change notification settings - Fork 16
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
Validate the sto limits subbed into the OCPs give the correct voltage limits #32
Validate the sto limits subbed into the OCPs give the correct voltage limits #32
Conversation
Checked the A:E parametrisation again,
NMC fails with
|
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## develop #32 +/- ##
==========================================
Coverage ? 97.77%
==========================================
Files ? 9
Lines ? 314
Branches ? 0
==========================================
Hits ? 307
Misses ? 7
Partials ? 0 ☔ View full report in Codecov by Sentry. |
… sto limits if basic checks are not successful)
I think that rather than checking higher/lower, we should check the voltage difference between computed and expected, and compare it to a given tolerance. For example, for the LFP cell, the SOC = 0% voltage evaluates as I'll look into why we are missing by so much on the upper cut-off! |
Separate comment: I don't think we should force This is because SOC is defined here by equilibration at manufacturer's cut-off voltages at a reference temperature. It is perfectly possible for the cell to have a state outside these limits - for example, if it is brought to equilibrium at 4.2 V at a higher/lower temperature, and then the temperature is changed and it is allowed to equilibrate at the reference temperature, it might have a voltage > 4.2 V and therefore SOC > 1. The actual unphysical states are those for which |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree we should add use some tolerance for these checks (ideally the user can control this tolerance when they create the BPX object) and maybe raise a warning instead of an error.
Also agree on allowing initial SOC to be outside of [0,1].
Otherwise looks good to go, thanks!
Agreed on using some user-defined tolerance, a warning instead of an error, and the initial SoC to be outside [0,1]. What do you think would be the best way of defining the tolerance? Or how a user would pass the tolerance to the BPX object? EDIT: From @rtimms email:
|
|
Codecov ReportAll modified lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #32 +/- ##
==========================================
Coverage ? 96.81%
==========================================
Files ? 11
Lines ? 440
Branches ? 0
==========================================
Hits ? 426
Misses ? 14
Partials ? 0 ☔ View full report in Codecov by Sentry. |
I updated this PR @rtimms, @ejfdickinson. Allowed the initial SOC to be outside of [0,1], added user-defined tolerance, changed errors to warnings, and added tests. By default, the tolerance is 1 mV. This can give a warning, for example: import bpx
p=bpx.parse_bpx_file("nmc_pouch_cell_BPX.json")
/home/ik3g18/workspace/BPX/bpx/validators.py:32: UserWarning: The maximum voltage computed from the STO limits (4.201761488607647 V) is higher than the upper voltage cut-off (4.2 V) with the absolute tolerance v_tol = 0.001 V
warn( The tolerance can be defined as: q=bpx.parse_bpx_file("nmc_pouch_cell_BPX.json", v_tol=0.005) or BPX.settings.v_tol = 0.005 Let me know if I need to change anything (including variable names, warning messages, etc.) |
@@ -1,20 +1,25 @@ | |||
from bpx import BPX | |||
|
|||
|
|||
def parse_bpx_file(filename: str) -> BPX: | |||
def parse_bpx_file(filename: str, v_tol: float = 0.001) -> BPX: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should also add v_tol
to parse_bpx_obj
and parse_bpx_str
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit tricky because if I overwrite parse_obj
in ExtraBaseModel
class, I'll break other methods that call parse_obj
.
What would be the most natural and 'future-proof' way of introducing parameter v_tol
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could use have some global settings, e.g. have a file
class Settings(object):
tolerances = {
"Voltage [V]": 1e-3,
}
settings = Settings()
then expose settings
as part of bpx
so we can do bpx.settings.tolerances["Voltage [V]"] = v_tol
to update the tolerance before reading a BPX? Maybe there is a cleaner solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, thanks!
I changed this setting to bpx.settings.tolerances["Voltage [V]"]
but left it inside ExtraBaseModel
in schema.py
for now.
It's just one parameter at the moment.
Now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
Added validator to check that the STO limits give the correct voltage limits according to issue #8 and added corresponding tests.
This will only work if the OCPs are defined as functions. It does not validate the voltage limits if the OCPs are tables.
Note that this check will likely fail the NMC parametrisation provided by A:E because of not very accurate upper/lower cut-off voltages in their example. So we either need to change the validation formula in
schema.py
or ask A:E to adjust their min/max sto or min/max voltages for NMC and update the repo.I also added the target SOC check in the
get_electrode_concentrations()
function with tests.This PR is not related to the BPX roadmap directly, I just wanted to start with something easier to understand how the schema works and can be validated.