-
Hi all, I have a question concerning a used-defined function, e.g., for OCP, to which I would like to pass additional arguments besides the pybamm symbol sto. So my question is: how can I realize this. For example, if my OCP-function is of the form: My approach was to pass the function as a parameter: But I do not know to define sto in the right way, i.e., how to handle/get access to the symbol and implement this in my function. It would be very nice if someone can provide a hint how to manage this issue. With best regards |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
What are the parameters it depends on? If they can be defined ahead of time (e.g. you know their values and want to run simulations with different values) you could wrap the function like param1, param2, param3 = ...
def pos_ocp(sto):
return my_ocp(sto, param1, param2, param3)
param = pybamm.ParameterValues(chemistry=chemistry)
param['Positive electrode OCP [V]']=pos_ocp(sto,param1,param2,param3) You could make |
Beta Was this translation helpful? Give feedback.
-
This example might help import pybamm
from pybamm import exp, constants
# pick parameters
param = pybamm.ParameterValues("Ecker2015")
# define custom diffusivity function with some input parameters we can specify when solving
a = pybamm.InputParameter("a")
b = pybamm.InputParameter("b")
c = pybamm.InputParameter("c")
def D_n(sto, T):
D_ref = a * exp(-b * sto) + c
E_D_s = 3.03e4
arrhenius = exp(-E_D_s / (constants.R * T)) * exp(E_D_s / (constants.R * 296))
return D_ref * arrhenius
# update parameters
param["Negative electrode diffusivity [m2.s-1]"] = D_n
# set up simulation
model = pybamm.lithium_ion.SPMe()
sim = pybamm.Simulation(model, parameter_values=param)
# solve, specifying inputs (you could wrap this call to solve in an optimizer)
sim.solve([0, 3600], inputs={"a":4.4e-13, "b":10.3, "c":8.2e-15})
# plot
sim.plot() |
Beta Was this translation helpful? Give feedback.
This example might help