diff --git a/test/system/test_misc.py b/test/system/test_misc.py index 40d11a673..36e5d2049 100644 --- a/test/system/test_misc.py +++ b/test/system/test_misc.py @@ -124,17 +124,18 @@ def test_wrong_value_for_bc_field(field): def test_txt_export_desired_times(tmp_path): """ Tests that TXTExport can be exported at desired times + Also catches the bug #682 """ my_model = F.Simulation() my_model.mesh = F.MeshFromVertices(np.linspace(0, 1)) my_model.materials = F.Material(1, 1, 0) - my_model.settings = F.Settings(1e-10, 1e-10, final_time=1) + my_model.settings = F.Settings(1e-10, 1e-10, final_time=1e-7) my_model.T = F.Temperature(500) - my_model.dt = F.Stepsize(0.1) + my_model.dt = F.Stepsize(1e-9) my_export = F.TXTExport( - "solute", times=[0.2, 0.5], filename="{}/mobile_conc.txt".format(tmp_path) + "solute", times=[1e-8, 2e-8], filename="{}/mobile_conc.txt".format(tmp_path) ) my_model.exports = [my_export] @@ -252,3 +253,20 @@ def test_derived_quantities_exported_last_timestep_with_small_stepsize(tmp_path) my_model.run() assert os.path.exists(f"{tmp_path}/out.csv") + + +def test_small_timesteps_final_time_bug(): + """ + Test to catch the bug #682 + Runs a sim on small timescales and checks that the final time is reached + """ + my_model = F.Simulation(log_level=40) + my_model.mesh = F.MeshFromVertices(np.linspace(0, 1, 10)) + my_model.materials = F.Material(1, 1, 0.1) + my_model.T = F.Temperature(1000) + my_model.settings = F.Settings(1e-10, 1e-10, final_time=1e-7) + my_model.dt = F.Stepsize(1e-9) + my_model.initialise() + my_model.run() + + assert np.isclose(my_model.t, my_model.settings.final_time, atol=0.0)