-
-
Notifications
You must be signed in to change notification settings - Fork 577
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
[Bug]: No key set for variable in model although it is defined in model.rhs #4018
Comments
When discretising the model we remove any independent eqns to simplify the model automatically, see: PyBaMM/pybamm/discretisations/discretisation.py Line 1092 in b0bc5cf
but we don't check if those variables are required by the events. Fixed by #4019 |
working code: import pybamm x_n = pybamm.Variable("Negative electrode stochiometry") i = pybamm.FunctionParameter("Current function [A]", {"Time [s]": pybamm.t}) model = pybamm.BaseModel("reservoir model") model.variables["Voltage [V]"] = U_p - U_n - i * R model.rhs[x_n].visualise("x_n_rhs.png") #events model.events = [ def graphite_LGM50_ocp_Chen2020(sto): return u_eq def nmc_LGM50_ocp_Chen2020(sto): return u_eq param = pybamm.ParameterValues({ #debugging #time #solve it |
@raghuramshankar if you add the voltage to |
Works now, I accidentally deleted that line while editing. Thanks @rtimms |
* pybamm-team#4018 check indepedent vars in events * pybamm-team#4018 changelog
PyBaMM Version
24.1
Python Version
3.9
Describe the bug
Unclear why
Negative electrode sto
is not a key inmodel.rhs
although it has been added in previous stepsSteps to Reproduce
Produces the error:
But
model.rhs
produces:Relevant log output
No response
The text was updated successfully, but these errors were encountered: