diff --git a/pybamm/solvers/casadi_solver.py b/pybamm/solvers/casadi_solver.py index 2d657c0cc0..d05e6283f9 100644 --- a/pybamm/solvers/casadi_solver.py +++ b/pybamm/solvers/casadi_solver.py @@ -153,6 +153,7 @@ def _integrate(self, model, t_eval, inputs=None): # Initialize solution solution = pybamm.Solution(np.array([t]), y0[:, np.newaxis]) solution.solve_time = 0 + solution.integration_time = 0 else: solution = None diff --git a/tests/unit/test_expression_tree/test_unary_operators.py b/tests/unit/test_expression_tree/test_unary_operators.py index e952ac9273..165f8fd88c 100644 --- a/tests/unit/test_expression_tree/test_unary_operators.py +++ b/tests/unit/test_expression_tree/test_unary_operators.py @@ -47,8 +47,8 @@ def test_smooth_absolute_value(self): self.assertAlmostEqual(expr.evaluate(y=np.array([-1]))[0, 0], 1) self.assertEqual( str(expr), - "y[0:1] * exp(10.0 * y[0:1]) - exp(-10.0 * y[0:1]) " - "/ exp(10.0 * y[0:1]) + exp(-10.0 * y[0:1])", + "y[0:1] * (exp(10.0 * y[0:1]) - exp(-10.0 * y[0:1])) " + "/ (exp(10.0 * y[0:1]) + exp(-10.0 * y[0:1]))", ) def test_sign(self): diff --git a/tests/unit/test_solvers/test_solution.py b/tests/unit/test_solvers/test_solution.py index 99c5a67a7a..d2cc7fb967 100644 --- a/tests/unit/test_solvers/test_solution.py +++ b/tests/unit/test_solvers/test_solution.py @@ -31,6 +31,7 @@ def test_append(self): y1 = np.tile(t1, (20, 1)) sol1 = pybamm.Solution(t1, y1) sol1.solve_time = 1.5 + sol1.integration_time = 0.3 sol1.model = pybamm.BaseModel() sol1.inputs = {"a": 1} @@ -39,11 +40,13 @@ def test_append(self): y2 = np.tile(t2, (20, 1)) sol2 = pybamm.Solution(t2, y2) sol2.solve_time = 1 + sol2.integration_time = 0.5 sol2.inputs = {"a": 2} sol1.append(sol2, create_sub_solutions=True) # Test self.assertEqual(sol1.solve_time, 2.5) + self.assertEqual(sol1.integration_time, 0.8) np.testing.assert_array_equal(sol1.t, np.concatenate([t1, t2[1:]])) np.testing.assert_array_equal(sol1.y, np.concatenate([y1, y2[:, 1:]], axis=1)) np.testing.assert_array_equal(