You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to simulate 20~40 drive cycle repetitions for US06 and UDDS. Currently I have a drive cycle and would like to replicate this over multiple cycles. To solve this problem, I followed the previous tinosulzer's Q&A answer suggesting the following code:
The following example repeats the US06 drive cycle 3 times (for 1800s instead of 600s):
import pybamm
import pandas as pd
import os
os.chdir(pybamm.path[0] + "/..")
pybamm.set_logging_level("INFO")
load model and update parameters so the input current is the US06 drive cycle
model = pybamm.lithium_ion.SPMe({"thermal": "lumped"})
param = model.default_parameter_values
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to simulate 20~40 drive cycle repetitions for US06 and UDDS. Currently I have a drive cycle and would like to replicate this over multiple cycles. To solve this problem, I followed the previous tinosulzer's Q&A answer suggesting the following code:
The following example repeats the US06 drive cycle 3 times (for 1800s instead of 600s):
import pybamm
import pandas as pd
import os
os.chdir(pybamm.path[0] + "/..")
pybamm.set_logging_level("INFO")
load model and update parameters so the input current is the US06 drive cycle
model = pybamm.lithium_ion.SPMe({"thermal": "lumped"})
param = model.default_parameter_values
import drive cycle from file
drive_cycle = pd.read_csv(
"pybamm/input/drive_cycles/US06.csv", comment="#", header=None
).to_numpy()
create interpolant
timescale = param.evaluate(model.timescale)
in the following line we use % 600 to repeat the drive cycle every 600 seconds
current_interpolant = pybamm.Interpolant(drive_cycle, (timescale * pybamm.t) % 600)
set drive cycle
param["Current function [A]"] = current_interpolant
create and run simulation using the CasadiSolver in "fast" mode, remembering to
pass in the updated parameters
sim = pybamm.Simulation(
model, parameter_values=param, solver=pybamm.CasadiSolver(mode="fast")
)
we need to specify the solve time to be different from the default [0, 600]
this will raise a warning but this can be ignored
sim.solve([0, 1800])
use this instead to get rid of the warning
t_drive = drive_cycle[:, 0]
step_size = np.min(np.diff(t_drive))
t_eval = np.arange(0, 1800, step_size)
sim.solve(t_eval)
you can play with step_size to change the level of resolution of the drive cycle
sim.plot(
[
"Negative particle surface concentration [mol.m-3]",
"Electrolyte concentration [mol.m-3]",
"Positive particle surface concentration [mol.m-3]",
"Current [A]",
"Negative electrode potential [V]",
"Electrolyte potential [V]",
"Positive electrode potential [V]",
"Terminal voltage [V]",
"X-averaged cell temperature",
]
)
However, when I run the code, there is an error "timescale has been removed since models are now dimensional".
Beta Was this translation helpful? Give feedback.
All reactions