Open KimKitsurag1 opened 10 months ago
That's very strange. The model runs just fine with the default parameters but not with the updated ones. We will look into it.
I've been having a look into this issue. I can recreate the error with the most recent PyBaMM release, and narrowed down the cause to the updated C1
, R0
, R1
and Open-circuit voltage
parameters - comment out any one of these in the updated parameters and the example runs fine (actually a different error pertaining to the maximum voltage crops up, but increasing that value solves the issue). If you only update one of the problematic parameters and leave the rest as defaults, the simulation still runs without error.
Having looked at the model.rhs at the point of discretisation, I think the issue is that in the default parameters, all 4 are functions containing the SoC variable, which is created in the get_fundamental_variables
method of the OCVElement
class. When all 4 parameters are overwritten as in the above example, the SoC variable no longer appears in the rhs equation values, even though it's present in the model.rhs keys prior to solving. SoC is then removed from the rhs entirely as an independent variable by remove_independent_variables_from_rhs()
. The final error comes because the default model events contain the min/maximum SoC which depend on the SoC variable. As the variable has been removed from the model RHS, the error is raised.
In the case where only one parameter is updated, the SoC variable is still present as part of the other three from initialisation.
@brosaplanella I'm not a battery modeller, so I'm not entirely sure which part is the bug here; is the model valid without an SoC variable? From having a brief look at the Thevenin reference paper it seems like OCV, and possibly the other parameters, should always depend on SoC? In which case the way the parameters are updated should be edited. Or is the model valid without an SoC variable, and the model events need to update to remove those that depend on missing variables?
PyBaMM Version
23.5
Python Version
3.11.5150
Describe the bug
Got an issue trying to run a solution for following model, simulation, and parameters.
Then got:
But SoC was presented in model.rhs as Variable(-0x22f01313d791d1c7, SoC, children=[], domains={}): Multiplication(0x511128df7b7d7ad5, *, children=['0.0002777777777777778', '-Current function [A] / Cell capacity [A.h]'], domains={}) What am I doing wrong?
Steps to Reproduce
Relevant log output
No response