Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error message for divergence with no dt_min #888

Closed
RemDelaporteMathurin opened this issue Oct 7, 2024 · 0 comments · Fixed by #889
Closed

Better error message for divergence with no dt_min #888

RemDelaporteMathurin opened this issue Oct 7, 2024 · 0 comments · Fixed by #889
Labels
enhancement New feature or request

Comments

@RemDelaporteMathurin
Copy link
Collaborator

Running this on FESTIM 1.3.1 produces:

import festim as F
import numpy as np

my_model = F.Simulation(log_level=40)

tungsten = F.Material(id=1, D_0=4.10e-7, E_D=0.39)
my_model.materials = tungsten


my_model.mesh = F.MeshFromVertices(vertices=np.linspace(0, 1, 10))
my_model.T = 400


my_model.boundary_conditions = [
    F.DirichletBC(surfaces=[1, 2], value=1e20, field="solute")
]

my_model.dt = F.Stepsize(0.001, stepsize_change_ratio=1.1)


my_model.settings = F.Settings(
    absolute_tolerance=1e-10,
    relative_tolerance=1e-10,
    final_time=100,
)

my_model.initialise()
my_model.run()
Defining initial values
Defining variational problem
Defining source terms
Defining boundary conditions
Time stepping...
Traceback (most recent call last):time so far: 0.0 s
  File "/home/remidm/FESTIM/mwe.py", line 28, in <module>
    my_model.run()
  File "/home/remidm/FESTIM/festim/generic_simulation.py", line 422, in run
    self.run_transient()
  File "/home/remidm/FESTIM/festim/generic_simulation.py", line 445, in run_transient
    self.iterate()
  File "/home/remidm/FESTIM/festim/generic_simulation.py", line 473, in iterate
    self.h_transport_problem.update(self.t, self.dt)
  File "/home/remidm/FESTIM/festim/h_transport_problem.py", line 338, in update
    dt.adapt(t, nb_it, converged)
  File "/home/remidm/FESTIM/festim/stepsize.py", line 100, in adapt
    if float(self.value) < dt_min:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: '<' not supported between instances of 'float' and 'NoneType'

I've recently noticed that this is a situation users often encounter and we should provide a more explanatory error message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant