Skip to content

Commit

Permalink
Merge pull request #542 from RemDelaporteMathurin/patch-tiny-stepsize
Browse files Browse the repository at this point in the history
Patch tiny stepsize
  • Loading branch information
RemDelaporteMathurin committed Jun 29, 2023
2 parents aa7d822 + e90b6ab commit 9af03ea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 5 additions & 2 deletions festim/generic_simulation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import festim
from festim.h_transport_problem import HTransportProblem
from fenics import *
import numpy as np


class Simulation:
Expand Down Expand Up @@ -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):
Expand All @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions test/unit/test_boundary_conditions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from attr import has
from sympy.matrices import expressions
import festim
import fenics
import pytest
Expand Down

0 comments on commit 9af03ea

Please sign in to comment.