diff --git a/festim/generic_simulation.py b/festim/generic_simulation.py index 402d09dbf..1f7dfbe57 100644 --- a/festim/generic_simulation.py +++ b/festim/generic_simulation.py @@ -1,6 +1,7 @@ import festim from festim.h_transport_problem import HTransportProblem from fenics import * +import numpy as np class Simulation: @@ -331,7 +332,9 @@ def iterate(self): # avoid t > final_time next_time = self.t + float(self.dt.value) - if next_time > self.settings.final_time and self.t != self.settings.final_time: + if next_time > self.settings.final_time and not np.isclose( + self.t, self.settings.final_time + ): self.dt.value.assign(self.settings.final_time - self.t) def display_time(self): @@ -342,7 +345,7 @@ def display_time(self): msg = "{:.1f} % ".format(simulation_percentage) msg += "{:.1e} s".format(simulation_time) msg += " Ellapsed time so far: {:.1f} s".format(elapsed_time) - if self.t != self.settings.final_time and self.log_level == 40: + if not np.isclose(self.t, self.settings.final_time) and self.log_level == 40: print(msg, end="\r") else: print(msg) diff --git a/test/unit/test_boundary_conditions.py b/test/unit/test_boundary_conditions.py index 975dbb009..fed7a3447 100644 --- a/test/unit/test_boundary_conditions.py +++ b/test/unit/test_boundary_conditions.py @@ -1,5 +1,3 @@ -from attr import has -from sympy.matrices import expressions import festim import fenics import pytest