Open MarkV-ADI opened 2 months ago
@MarkV-ADI In relation to the BPX issue, you can't write in new fields in this part of the BPX file or it will be rejected by the schema. The schema errors themselves are not helpful (https://github.com/FaradayInstitution/BPX/issues/52).
BPX permits you to add any additional fields for the BPX file under "Parameterisation" -> "User-defined"
. PyBaMM imports these directly into the pybamm.ParameterValues
object, by default.
Does this error persist if you apply your inputs to the parameter values (as you are doing), assemble a pybamm.Simulation
directly and let PyBaMM do the default things, rather than processing the model in place? This might help debug if there is still a PyBaMM issue here. I've put some approximate code below.
# Set-up the model
options = {"cell geometry": "arbitrary", "thermal": "lumped"}
model = pybamm.lithium_ion.DFN(options=options)
geometry = model.default_geometry
# param = model.default_parameter_values
param = pybamm.ParameterValues.create_from_bpx(r'lfp_18650_cell_BPX.json')
param.update(inputs)
var = pybamm.standard_spatial_vars
var_pts = {var.x_n: 20, var.x_s: 20, var.x_p: 20, var.r_n: 10, var.r_p: 10}
# Use a short time-vector for this example
t_eval = np.linspace(0, 360, 10)
# Include the variable of interest in output_variables
output_variables = [
"Voltage [V]",
"Current [A]",
"Time [min]",
"X-averaged cell temperature [C]" # want to retrieve this and print the output
]
# Create the IDAKLU Solver object
idaklu_solver = pybamm.IDAKLUSolver(rtol=1e-6, atol=1e-6, output_variables=output_variables)
sim = pybamm.Simulation(
model,
parameter_values=param,
geometry=geometry,
var_pts=var_pts,
solver=idaklu_solver,
output_variables=output_variables,
)
sol = sim.solve(
t_eval=t_eval,
calculate_sensitivities=True,
)
@MarkV-ADI @ejfdickinson's code should work if you don't use the output_variables
option in the IDAKLU solver. Using the output_variables option reveals a small bug I've noted in #4439.
@MarkV-ADI Did this resolve your question?
Hi all, I recently been playing around with the IDAKLU-JAX Solver and very impressed with it's speed! I am trying to target a BPX model cell. However when i do, i get this error: KeyError: 'Current function [A]'
Setup: WSL2 Ubuntu, Python 3.10.12, Pybamm[Jax]==24.5 and BPX==0.4.0
Code
Response
NOTE: The above code works if i use
param = model.default_parameter_values
instead ofparam = pybamm.ParameterValues.create_from_bpx(r'lfp_18650_cell_BPX.json')
The BPX file used is found from the about:energy repo for BPX: https://github.com/About-Energy-OpenSource/About-Energy-BPX-Parameterisation/blob/main/LFP/lfp_18650_cell_BPX.json
I thought that i could add in the current function parameter similar to how it was done in chen2020 but after modifying the bpx Parameterisation->cell to have a current function
Response to modified BPX Schema
so on and so on for each parameter...
Is there a way i can use idaklu solver with the bpx model? should my input dict change to not use current?, or is it that i'm meant to modify the bpx file somehow to target current or is there a general recommend way for me to solve with IDAKULU-JAX for this.
to note: i'm quite new to the domain of battery simulations so i don't believe this is a bug but just a gap in my knowledge on how to perform this type of simulation :)
Thanks all in advance :)