Skip to content

Commit bf59b7d

Browse files
committed
#1477 fix integration idaklu test
1 parent 313c9c3 commit bf59b7d

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

tests/integration/test_solvers/test_idaklu.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,20 @@ def test_on_spme(self):
2020
np.testing.assert_array_less(1, solution.t.size)
2121

2222
def test_on_spme_sensitivities(self):
23-
param_name = "Negative electrode conductivity [S.m-1]"
24-
neg_electrode_cond = 100.0
23+
param_name = 'Typical current [A]'
24+
param_value = 0.15652
2525
model = pybamm.lithium_ion.SPMe()
2626
geometry = model.default_geometry
2727
param = model.default_parameter_values
2828
param.update({param_name: "[input]"})
29-
inputs = {param_name: neg_electrode_cond}
29+
inputs = {param_name: param_value}
3030
param.process_model(model)
3131
param.process_geometry(geometry)
3232
mesh = pybamm.Mesh(geometry, model.default_submesh_types, model.default_var_pts)
3333
disc = pybamm.Discretisation(mesh, model.default_spatial_methods)
3434
disc.process_model(model)
3535
t_eval = np.linspace(0, 3600, 100)
36-
solver = pybamm.IDAKLUSolver()
36+
solver = pybamm.IDAKLUSolver(rtol=1e-10, atol=1e-10)
3737
solution = solver.solve(
3838
model, t_eval,
3939
inputs=inputs,
@@ -48,16 +48,18 @@ def test_on_spme_sensitivities(self):
4848
h = 1e-6
4949
sol_plus = solver.solve(
5050
model, t_eval,
51-
inputs={param_name: neg_electrode_cond + 0.5 * h}
51+
inputs={param_name: param_value + 0.5 * h}
5252
)
5353
sol_neg = solver.solve(
5454
model, t_eval,
55-
inputs={param_name: neg_electrode_cond - 0.5 * h}
55+
inputs={param_name: param_value - 0.5 * h}
5656
)
5757
dyda_fd = (sol_plus.y - sol_neg.y) / h
58+
dyda_fd = dyda_fd.transpose().reshape(-1, 1)
5859

59-
np.testing.assert_array_almost_equal(
60-
dyda_ida, dyda_fd
60+
np.testing.assert_allclose(
61+
dyda_ida, dyda_fd,
62+
rtol=1e-2, atol=1e-3,
6163
)
6264

6365
def test_set_tol_by_variable(self):
@@ -109,7 +111,6 @@ def test_changing_grid(self):
109111
if __name__ == "__main__":
110112
print("Add -v for more debug output")
111113

112-
pybamm.set_logging_level('INFO')
113114
if "-v" in sys.argv:
114115
debug = True
115116
pybamm.settings.debug_mode = True

0 commit comments

Comments
 (0)