Skip to content

Commit

Permalink
test to catch the bug
Browse files Browse the repository at this point in the history
  • Loading branch information
KulaginVladimir committed Jan 16, 2024
1 parent 94aa16e commit bef2e88
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions test/system/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -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)

0 comments on commit bef2e88

Please sign in to comment.