Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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: 3 additions & 0 deletions src/pulse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
utils,
viscoelasticity,
)
from .active_model import ActiveModel, Passive
from .active_stress import ActiveStress
from .boundary_conditions import BoundaryConditions, NeumannBC, RobinBC
from .cardiac_model import CardiacModel
Expand Down Expand Up @@ -70,6 +71,8 @@
"active_model",
"active_stress",
"ActiveStress",
"ActiveModel",
"Passive",
"geometry",
"Geometry",
"NeumannBC",
Expand Down
31 changes: 28 additions & 3 deletions src/pulse/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,10 +513,35 @@ def reset(self):
self.reset_states()
self._init_forms()

def solve(self) -> bool:
def solve(
self,
rtol: float = 1e-10,
atol: float = 1e-6,
beta: float = 1.0,
update_old_states: bool = True,
) -> bool:
"""Solve nonlinear problem with Newton solver

Parameters
----------
rtol : float, optional
Relative tolerance, by default 1e-10
atol : float, optional
Absolute tolerance, by default 1e-6
beta : float, optional
Damping parameter, by default 1.0
update_old_states : bool, optional
Whether to update old states before solving, by default True

Returns
-------
bool
True if converged, False otherwise
"""
logger.debug("Solving the system...")
self.update_old_states()
ret = self._solver.solve(rtol=1e-10, atol=1e-6)
if update_old_states:
self.update_old_states()
ret = self._solver.solve(rtol=rtol, atol=atol, beta=beta)
self.update_fields()

return ret
Expand Down