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

Wrong value for error_on_nonconvergence in NewtonSolver #874

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions festim/concentration/traps/extrinsic_trap.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __init__(
relative_tolerance=1e-10,
maximum_iterations=30,
linear_solver=None,
preconditioner=None,
preconditioner="default",
**kwargs,
):
"""Inits ExtrinsicTrap
Expand Down Expand Up @@ -73,7 +73,6 @@ def newton_solver(self, value):
def define_newton_solver(self):
"""Creates the Newton solver and sets its parameters"""
self.newton_solver = NewtonSolver(MPI.comm_world)
self.newton_solver.parameters["error_on_nonconvergence"] = False
self.newton_solver.parameters["absolute_tolerance"] = self.absolute_tolerance
self.newton_solver.parameters["relative_tolerance"] = self.relative_tolerance
self.newton_solver.parameters["maximum_iterations"] = self.maximum_iterations
Expand Down
1 change: 0 additions & 1 deletion festim/temperature/temperature_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ def define_variational_problem(self, materials, mesh, dt=None):
def define_newton_solver(self):
"""Creates the Newton solver and sets its parameters"""
self.newton_solver = f.NewtonSolver(f.MPI.comm_world)
self.newton_solver.parameters["error_on_nonconvergence"] = False
RemDelaporteMathurin marked this conversation as resolved.
Show resolved Hide resolved
self.newton_solver.parameters["absolute_tolerance"] = self.absolute_tolerance
self.newton_solver.parameters["relative_tolerance"] = self.relative_tolerance
self.newton_solver.parameters["maximum_iterations"] = self.maximum_iterations
Expand Down
22 changes: 22 additions & 0 deletions test/unit/test_temperature.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,3 +262,25 @@ def test_temperature_from_xdmf(tmpdir):
temperature = festim.TemperatureFromXDMF(T_file, "T")

assert temperature.is_steady_state()


def test_heat_transfer_default_solver():
"""
Tests that the default parameters for the Newton solver
of HeatTransferProblem are correct
"""

heat_solver = festim.HeatTransferProblem()
heat_solver.define_newton_solver()

default_settings = {
"absolute_tolerance": 1e-3,
"relative_tolerance": 1e-10,
"maximum_iterations": 30,
"linear_solver": None,
"preconditioner": "default",
"error_on_nonconvergence": True,
}

for key in default_settings.keys():
assert default_settings[key] == heat_solver.newton_solver.parameters[key]
23 changes: 21 additions & 2 deletions test/unit/test_traps/test_extrinsic_trap.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,31 @@ def test_create_form_density(self):
print(self.my_trap.form_density)
assert self.my_trap.form_density.equals(expected_form)

def test_default_solver_parameters(self):
"""
A test to check that the default parameters for the Newton solver
of ExtrinsicTrap are correct
"""
self.my_trap.define_newton_solver()

default_settings = {
"absolute_tolerance": 1e0,
"relative_tolerance": 1e-10,
"maximum_iterations": 30,
"linear_solver": None,
"preconditioner": "default",
"error_on_nonconvergence": True,
}

for key in default_settings.keys():
assert default_settings[key] == self.my_trap.newton_solver.parameters[key]

def test_solver_parameters(self):
"""
A test to ensure the extrinsic trap solver parameters can be accessed
"""
self.my_trap.absolute_tolerance = 1
self.my_trap.relative_tolerance = 1
self.my_trap.absolute_tolerance = 1.0
self.my_trap.relative_tolerance = 1.0
self.my_trap.maximum_iterations = 1
self.my_trap.linear_solver = "mumps"
self.my_trap.preconditioner = "icc"
Expand Down
Loading