Sensitivity analysis #3701
Unanswered
ssingh-ipa
asked this question in
Q&A
Replies: 1 comment 6 replies
-
You won't be able to calculate the sensitivities with respect to any of the geometical parameters like "Negative electrode thickness [m]", as these are used in the discretisation of the equations and we cannot take the gradient in this case. |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
As per the following discussion,
#1477
the idea of calculating the sensitivity of the model outputs on the model parameters has already been implemented.
Are there any examples where the usage of this attribute is shown? If not, please help with the following issue:
options = {"cell geometry": "arbitrary", "thermal": "lumped"}
model = pybamm.lithium_ion.DFN(options)
param = pybamm.ParameterValues("Chen2020")
param.update(
{
"Cell cooling surface area [m2]": 0.0040192,
"Cell volume [m3]": 3.676e-04,
"Total heat transfer coefficient [W.m-2.K-1]": 10.0,
}
)
current_interpolant = pybamm.Interpolant(Time_sec, Current, pybamm.t)
param["Current function [A]"] = current_interpolant
solver = pybamm.CasadiSolver(atol=1e-6, rtol=1e-6, mode="safe")
sim = pybamm.Simulation(model, parameter_values=param, solver=solver)
sol = sim.solve()
plt.plot(Time_sec, Voltage_EK1, color='blue', label='Measured Voltage')
sim_voltage = np.array(sol["Terminal voltage [V]"].entries)
Sim_Time = np.array(sol["Time [s]"].entries)
plt.plot(Sim_Time, sim_voltage, color='red', label="Simulated voltage")
plt.xlabel('Time [s]')
plt.ylabel('Voltage [V]')
plt.legend()
plt.show()
solver2=pybamm.CasadiSolver()
print(solver2)
help(solver2.solve)
inputs = {
"Negative electrode thickness [m]": 6.73e-05,
"Positive electrode thickness [m]": 5.55e-05,
}
sens = solver2.solve(model, t_eval=Time_sec, inputs=inputs, calculate_sensitivities=True)
Results and error:
<pybamm.solvers.casadi_solver.CasadiSolver object at 0x000001DE9C960130>
Help on method solve in module pybamm.solvers.base_solver:
solve(model, t_eval=None, inputs=None, initial_conditions=None, nproc=None, calculate_sensitivities=False) method of pybamm.solvers.casadi_solver.CasadiSolver instance
Execute the solver setup and calculate the solution of the model at
specified times.
DiscretisationError: Spatial method has not been given for variable Negative particle concentration [mol.m-3] with domain ['negative particle']
DiscretisationError: Cannot automatically discretise model, model should be discretised before solving (Spatial method has not been given for variable Negative particle concentration [mol.m-3] with domain ['negative particle'])
The model had no discretization issues until now. The issue persists even after doing the following discretization:
disc = pybamm.Discretisation()
disc.process_model(model)
Please refer me to an example where the attribute calculate_sensitivites has been used.
Beta Was this translation helpful? Give feedback.
All reactions