Skip to content

Commit e9f68d7

Browse files
change step offset to 1e-9
1 parent 509bc4a commit e9f68d7

File tree

8 files changed

+14
-14
lines changed

8 files changed

+14
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
## Breaking changes
2020

21-
- When using `solver.step()`, the first time point in the step is shifted by `pybamm.settings.step_start_offset` (default 1 us) to avoid having duplicate times in the solution steps from the end of one step and the start of the next. ([#2773](https://github.com/pybamm-team/PyBaMM/pull/2773))
21+
- When using `solver.step()`, the first time point in the step is shifted by `pybamm.settings.step_start_offset` (default 1 ns) to avoid having duplicate times in the solution steps from the end of one step and the start of the next. ([#2773](https://github.com/pybamm-team/PyBaMM/pull/2773))
2222
- Renamed "Measured open circuit voltage [V]" to "Surface open-circuit voltage [V]". This variable was calculated from surface particle concentrations, and hence "hid" the overpotential from particle gradients. The new variable "Open-circuit voltage [V]" is calculated from bulk particle concentrations instead. ([#2740](https://github.com/pybamm-team/PyBaMM/pull/2740))
2323
- Renamed all references to "open circuit" to be "open-circuit" instead. ([#2740](https://github.com/pybamm-team/PyBaMM/pull/2740))
2424
- Renamed parameter "1 + dlnf/dlnc" to "Thermodynamic factor". ([#2727](https://github.com/pybamm-team/PyBaMM/pull/2727))

pybamm/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Settings(object):
1212
_abs_smoothing = "exact"
1313
max_words_in_line = 4
1414
max_y_value = 1e5
15-
step_start_offset = 1e-6
15+
step_start_offset = 1e-9
1616
tolerances = {
1717
"D_e__c_e": 10, # dimensional
1818
"kappa_e__c_e": 10, # dimensional

pybamm/solvers/base_solver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@ def step(
11001100
if t_start == 0:
11011101
t_start_shifted = t_start
11021102
else:
1103-
# offset t_start by t_start_offset (default 1 us)
1103+
# offset t_start by t_start_offset (default 1 ns)
11041104
# to avoid repeated times in the solution
11051105
# from having the same time at the end of the previous step and
11061106
# the start of the next step

tests/integration/test_experiments.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def test_discharge_rest_charge(self):
2323
sim.solve()
2424
np.testing.assert_array_almost_equal(
2525
sim._solution["Time [h]"].entries,
26-
np.array([0, 0.5, 1, 1 + 1e-6, 1.5, 2, 2 + 1e-6, 2.5, 3]),
26+
np.array([0, 0.5, 1, 1 + 1e-9, 1.5, 2, 2 + 1e-9, 2.5, 3]),
2727
)
2828
cap = model.default_parameter_values["Nominal cell capacity [A.h]"]
2929
np.testing.assert_array_almost_equal(

tests/unit/test_simulation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,19 +155,19 @@ def test_step(self):
155155
sim.step(dt) # automatically append the next step
156156
self.assertEqual(sim.solution.y.full()[0, :].size, 4)
157157
np.testing.assert_array_almost_equal(
158-
sim.solution.t, np.array([0, dt, dt + 1e-6, 2 * dt])
158+
sim.solution.t, np.array([0, dt, dt + 1e-9, 2 * dt])
159159
)
160160

161161
sim.step(dt, save=False) # now only store the two end step points
162162
self.assertEqual(sim.solution.y.full()[0, :].size, 2)
163163
np.testing.assert_array_almost_equal(
164-
sim.solution.t, np.array([2 * dt + 1e-6, 3 * dt])
164+
sim.solution.t, np.array([2 * dt + 1e-9, 3 * dt])
165165
)
166166
# Start from saved solution
167167
sim.step(dt, starting_solution=saved_sol)
168168
self.assertEqual(sim.solution.y.full()[0, :].size, 4)
169169
np.testing.assert_array_almost_equal(
170-
sim.solution.t, np.array([0, dt, dt + 1e-6, 2 * dt])
170+
sim.solution.t, np.array([0, dt, dt + 1e-9, 2 * dt])
171171
)
172172

173173
def test_solve_with_initial_soc(self):
@@ -233,7 +233,7 @@ def test_step_with_inputs(self):
233233
) # automatically append the next step
234234
self.assertEqual(sim.solution.y.full()[0, :].size, 4)
235235
np.testing.assert_array_almost_equal(
236-
sim.solution.t, np.array([0, dt, dt + 1e-6, 2 * dt])
236+
sim.solution.t, np.array([0, dt, dt + 1e-9, 2 * dt])
237237
)
238238
np.testing.assert_array_equal(
239239
sim.solution.all_inputs[1]["Current function [A]"], 2

tests/unit/test_solvers/test_casadi_solver.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ def test_model_step(self):
292292
# Step again (return 5 points)
293293
step_sol_2 = solver.step(step_sol, model, dt, npts=5)
294294
np.testing.assert_array_equal(
295-
step_sol_2.t, np.array([0, 1, 1 + 1e-6, 1.25, 1.5, 1.75, 2])
295+
step_sol_2.t, np.array([0, 1, 1 + 1e-9, 1.25, 1.5, 1.75, 2])
296296
)
297297
np.testing.assert_array_almost_equal(
298298
step_sol_2.y.full()[0], np.exp(0.1 * step_sol_2.t)
@@ -324,7 +324,7 @@ def test_model_step_with_input(self):
324324
step_sol_2 = solver.step(step_sol, model, dt, npts=5, inputs={"a": -1})
325325
np.testing.assert_array_almost_equal(
326326
step_sol_2.t,
327-
np.array([0, 0.025, 0.05, 0.075, 0.1, 0.1 + 1e-6, 0.125, 0.15, 0.175, 0.2]),
327+
np.array([0, 0.025, 0.05, 0.075, 0.1, 0.1 + 1e-9, 0.125, 0.15, 0.175, 0.2]),
328328
)
329329
np.testing.assert_array_equal(
330330
step_sol_2["a"].entries,

tests/unit/test_solvers/test_scikits_solvers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ def test_model_step_ode_python(self):
532532
# Step again (return 5 points)
533533
step_sol_2 = solver.step(step_sol, model, dt, npts=5)
534534
np.testing.assert_array_equal(
535-
step_sol_2.t, np.array([0, 1, 1 + 1e-6, 1.25, 1.5, 1.75, 2])
535+
step_sol_2.t, np.array([0, 1, 1 + 1e-9, 1.25, 1.5, 1.75, 2])
536536
)
537537
np.testing.assert_allclose(step_sol_2.y[0], np.exp(-0.1 * step_sol_2.t))
538538

@@ -566,7 +566,7 @@ def test_model_step_dae_python(self):
566566
# Step again (return 5 points)
567567
step_sol_2 = solver.step(step_sol, model, dt, npts=5)
568568
np.testing.assert_array_equal(
569-
step_sol_2.t, np.array([0, 1, 1 + 1e-6, 1.25, 1.5, 1.75, 2])
569+
step_sol_2.t, np.array([0, 1, 1 + 1e-9, 1.25, 1.5, 1.75, 2])
570570
)
571571
np.testing.assert_allclose(step_sol_2.y[0, :], np.exp(0.1 * step_sol_2.t))
572572
np.testing.assert_allclose(step_sol_2.y[-1, :], 2 * np.exp(0.1 * step_sol_2.t))
@@ -598,7 +598,7 @@ def test_model_solver_ode_events_casadi(self):
598598
solution = solver.solve(model, t_eval)
599599
np.testing.assert_allclose(solution.y[0], np.exp(0.1 * solution.t))
600600
np.testing.assert_array_less(solution.y[0:, -1], 1.5)
601-
np.testing.assert_array_less(solution.y[0:, -1], 1.25 + 1e-6)
601+
np.testing.assert_array_less(solution.y[0:, -1], 1.25 + 1e-9)
602602
np.testing.assert_equal(solution.t_event[0], solution.t[-1])
603603
np.testing.assert_array_equal(solution.y_event[:, 0], solution.y[:, -1])
604604

tests/unit/test_solvers/test_scipy_solver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def test_model_step_python(self):
180180
# Step again (return 5 points)
181181
step_sol_2 = solver.step(step_sol, model, dt, npts=5)
182182
np.testing.assert_array_equal(
183-
step_sol_2.t, np.array([0, 1, 1 + 1e-6, 1.25, 1.5, 1.75, 2])
183+
step_sol_2.t, np.array([0, 1, 1 + 1e-9, 1.25, 1.5, 1.75, 2])
184184
)
185185
np.testing.assert_array_almost_equal(
186186
step_sol_2.y[0], np.exp(0.1 * step_sol_2.t)

0 commit comments

Comments
 (0)