-
-
Notifications
You must be signed in to change notification settings - Fork 589
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
Allow drive cycles in experiments #1193
Comments
Dear @tinosulzer, Thanks a lot in advance and best regards, |
This functionality is not implemented yet as described above. Can you show me the code you are using to load your drive cycle? |
Here it is. I tried to reuse part of tutorial4. import pybamm parameter_values["Current function [A]"] = current_interpolant Thanks a lot and best regards, |
Sorry, I misunderstood your initial post. |
Can you describe what you are trying to do? Would be good to know, in case it is easy to implement |
The final goal is to simulate an experiment composed by a multistep charge followed by a series of WLTP cycles. |
Dear @tinosulzer, |
Yes, please open a separate issue and I or someone else will look into it |
To add to this issue, it would be good to generalise it so you can pass drive cycles for current, voltage or power. Not sure if they all have the same level of complexity or not. |
Yes, good idea, that would be under the same level of complexity |
@Saransh-cpp could you try this? Basically it now just requires passing the drive cycle interpolant to Lines 437 to 439 in 40a114e
op_inputs as it will cause problems later on if it's not a scalar.
|
Could you please elaborate more on this? Should I remove "Current input [A]" completely from |
With the new setup type the Current input (and actually voltage input and power input) are only needed for the parameter values. So once you update the parameter values you can throw them away. Something like I = op_inputs.pop("Current input [A]")
new_parameter_values.update("Current function [A]": I) might just work out of the box. Since |
I will definitely look into this and if everything goes fine, I will make a PR. |
@tinosulzer could you please confirm the format in which the new drive cycle experiments can be simulated? The code below gives an error (which I think it should because my experiment doesn't contain "A", "C", "V" or "W") -
Code - import pybamm
import pandas as pd
import numpy as np
model = pybamm.lithium_ion.DFN()
params = model.default_parameter_values
drive_cycle = pd.read_csv("US06.csv", comment="#", header=None).to_numpy()
experiment = pybamm.Experiment(["Run US06 for 1 hour"], drive_cycles={"US06": drive_cycle}, period="20 seconds")
sim = pybamm.Simulation(model, experiment=experiment, solver=pybamm.CasadiSolver(mode="fast"))
sim.solve()
solution = sim.solution
pybamm.dynamic_plot(solution) I also ran basic simulations by changing "Current function [A]" using I = op_inputs.pop("Current input [A]")
new_parameter_values.update("Current function [A]": I) to |
Ah yeah. Looking at it again I think there should be a specifier in the experiment class for what kind of data the drive cycle is giving, e.g. "Run US06 (A) for 1 hour" and then in the electric = (ext_drive_cycle[:, 1], "Drive")
time = ext_drive_cycle[:, 0][-1] should be replaced with interp = ... # define the interpolant
typ = ... # find the type ("A", "V", or "W")
electric = (interp, typ) Maybe @alibh95 can help with that. Note that the simulation calls different functions depending on whether or not you supply an experiment (it doesn't call the code you changed if you don't supply an experiment) |
Oh yes, running experiments with the edited code does give an error -
I will try to work around this (exploring the code more for now) and see if I can find something. |
Popping out "Current input [A]" does work and removes it from both
on solving a simulated experiment. I have been trying to solve this but I haven't discovered a solution yet. Making the "input" values 0 does work but again 0 is a scalar so that is not something desirable. |
Closed via #1793 |
Add functionality to allow running a drive cycle as part of an experiment. For example:
Currently, the way experiments are implemented require current/voltage/power to be constant (they are set up as
InputParameter
objects). So this could be challenging to implement, and would depend on #895 being possible.The text was updated successfully, but these errors were encountered: