diff --git a/CHANGELOG.md b/CHANGELOG.md index b6bc1ba7f8..ca0fb48e76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,11 +2,12 @@ ## Features +- Experiments can be set to terminate when a voltage is reached (across all steps) ([#1832](https://github.com/pybamm-team/PyBaMM/pull/1832)) - Added cylindrical geometry and finite volume method ([#1824](https://github.com/pybamm-team/PyBaMM/pull/1824)) ## Bug fixes -- Experiments can be set to terminate when a voltage is reached (across all steps) ([#1832](https://github.com/pybamm-team/PyBaMM/pull/1832)) +- Simulations with drive cycles now support `initial_soc` ([#1842](https://github.com/pybamm-team/PyBaMM/pull/1842)) - Fixed bug in expression tree simplification ([#1831](https://github.com/pybamm-team/PyBaMM/pull/1831)) - Solid tortuosity is now correctly calculated with Bruggeman coefficient of the respective electrode ([#1773](https://github.com/pybamm-team/PyBaMM/pull/1773)) diff --git a/pybamm/simulation.py b/pybamm/simulation.py index a9a8a374cc..90fb70d38c 100644 --- a/pybamm/simulation.py +++ b/pybamm/simulation.py @@ -740,7 +740,9 @@ def solve( raise ValueError( "starting_solution can only be provided if simulating an Experiment" ) - if self.operating_mode == "without experiment": + if self.operating_mode == "without experiment" or isinstance( + self.model, pybamm.lithium_ion.ElectrodeSOH + ): if t_eval is None: raise pybamm.SolverError( "'t_eval' must be provided if not using an experiment or " diff --git a/tests/unit/test_simulation.py b/tests/unit/test_simulation.py index df10bd76f0..64213ad73d 100644 --- a/tests/unit/test_simulation.py +++ b/tests/unit/test_simulation.py @@ -226,6 +226,21 @@ def test_solve_with_initial_soc(self): sim.solve(initial_soc=0.8) self.assertEqual(sim._built_initial_soc, 0.8) + # test with drive cycle + drive_cycle = pd.read_csv( + os.path.join("pybamm", "input", "drive_cycles", "US06.csv"), + comment="#", + header=None + ).to_numpy() + timescale = param.evaluate(model.timescale) + current_interpolant = pybamm.Interpolant( + drive_cycle[:, 0], drive_cycle[:, 1], timescale * pybamm.t + ) + param["Current function [A]"] = current_interpolant + sim = pybamm.Simulation(model, parameter_values=param) + sim.solve(initial_soc=0.8) + self.assertEqual(sim._built_initial_soc, 0.8) + def test_solve_with_inputs(self): model = pybamm.lithium_ion.SPM() param = model.default_parameter_values