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 want to calculate the sensitivities of some parameters with the DFN model. I used this notebook (2021-09-workshop/Session 3/sensitivities_and_data_fitting.ipynb) as a baseline and added a parameter set, geometry, different input parameter and also changed t_eval.
Now I get this error: ValueError: x and y must have same first dimension, but have shapes (500,) and (494, 1).
When I change t_eval to np.linspace(0, 3600, 1000), I get this error: x and y must have same first dimension, but have shapes (1000,) and (988, 1).
With the default steps of 100 I get the error: ValueError: x and y must have same first dimension, but have shapes (100,) and (99, 1)
Is there something I'm missing so that the outputs have matching dimensions?
This is my code:
import pybamm
import numpy as np
import matplotlib.pylab as plt
# load model
model = pybamm.lithium_ion.DFN()
# create geometry
geometry = pybamm.battery_geometry(form_factor="cylindrical")
# load parameter values and process model and geometry
param = pybamm.ParameterValues("Chen2020")
param.update({'Positive particle radius [m]': "[input]"})
param.process_geometry(geometry)
param.process_model(model)
# set mesh
var = pybamm.standard_spatial_vars
var_pts = {var.x_n: 30, var.x_s: 30, var.x_p: 30, var.r_n: 40, var.r_p: 40}
mesh = pybamm.Mesh(geometry, model.default_submesh_types, var_pts)
# discretise model
disc = pybamm.Discretisation(mesh, model.default_spatial_methods)
disc.process_model(model)
# create solver
t_eval = np.linspace(0, 3600, 500)
solver = pybamm.CasadiSolver(mode="safe", atol=1e-6, rtol=1e-4, max_step_decrease_count=20)
# evaluate the senstivities
solution = solver.solve(
model, t_eval,
inputs={'Positive particle radius [m]': 5.22e-06},
calculate_sensitivities=True
)
plt.plot(
t_eval,
solution["Terminal voltage [V]"]
.sensitivities['Positive particle radius [m]']
)
plt.xlabel(r'$t$')
plt.ylabel('sensitivities of Terminal voltage wrt Positive particle radius [m]')
plt.show()
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.
-
Hello all,
I want to calculate the sensitivities of some parameters with the DFN model. I used this notebook (2021-09-workshop/Session 3/sensitivities_and_data_fitting.ipynb) as a baseline and added a parameter set, geometry, different input parameter and also changed t_eval.
Now I get this error: ValueError: x and y must have same first dimension, but have shapes (500,) and (494, 1).
When I change t_eval to np.linspace(0, 3600, 1000), I get this error: x and y must have same first dimension, but have shapes (1000,) and (988, 1).
With the default steps of 100 I get the error: ValueError: x and y must have same first dimension, but have shapes (100,) and (99, 1)
Is there something I'm missing so that the outputs have matching dimensions?
This is my code:
Beta Was this translation helpful? Give feedback.
All reactions