change some parameters simultaneously #286
Unanswered
alirahdarian
asked this question in
Q&A
Replies: 1 comment
-
There are two issues. The first is that the maximum concentration cannot be an input and I wouldn't suggest varying this between cells anyway as it's a property of the material. Initial concentrations can vary. This example also fails in PyBaMM
The second issue is the way you are defining the model and not passing it to the solver. The way liionpack works is a bit different to PyBaMM in this regard and you need to actually pass a sim_func which builds the model for you. An example of this is found here https://liionpack.readthedocs.io/en/latest/examples/06%20Changing%20a%20model/ |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I use the following code to change 5 parameters (5 inputs) in the model but it returns an error while it works when I change only two parameters. I want to know how can I change these 5 parameters simultaneously.
import liionpack as lp
import pybamm
import numpy as np
I_mag = 5.0
OCV_init = 4.0 # used for intial guess
Ri_init = 5e-2 # used for intial guess
R_busbar = 1.5e-3
R_connection = 1e-2
Np = 2
Ns = 1
Nbatt = Np * Ns
netlist = lp.setup_circuit(
Np=Np, Ns=Ns, Rb=R_busbar, Rc=R_connection, Ri=Ri_init, V=OCV_init, I=I_mag
)
#print(netlist)
experiment = pybamm.Experiment(
[
"Charge at 2 A for 30 minutes",
"Rest for 15 minutes",
"Discharge at 2 A for 30 minutes",
"Rest for 15 minutes",
],
period="10 seconds",
)
parameter_values = pybamm.ParameterValues("Chen2020")
parameter_values.update({"Negative electrode diffusivity [m2.s-1]": "[input]"})
parameter_values.update({"Positive electrode diffusivity [m2.s-1]": "[input]"})
parameter_values.update({"Maximum concentration in negative electrode [mol.m-3]": "[input]"})
parameter_values.update({"Maximum concentration in positive electrode [mol.m-3]": "[input]"})
parameter_values.update({"SEI resistivity [Ohm.m]": "[input]"})
inputs = {"Negative electrode diffusivity [m2.s-1]": [3.3e-14,3.3e-14],
"Positive electrode diffusivity [m2.s-1]": [4e-15,4e-15],
"Maximum concentration in negative electrode [mol.m-3]": [33133.0,33133.0],
"Maximum concentration in positive electrode [mol.m-3]": [63104.0,63104.0],
"SEI resistivity [Ohm.m]": [200000.0,200000]
}
SPMe = pybamm.models.full_battery_models.lithium_ion.SPMe()
output = lp.solve(
netlist=netlist,
parameter_values=parameter_values,
experiment=experiment,
inputs=inputs,
initial_soc=0.5
)
print(parameter_values)
#lp.plot_output(output)
#lp.show_plots()
Save simulation output to CSV files
#lp.save_to_csv(output)
Beta Was this translation helpful? Give feedback.
All reactions