Skip to content

Commit

Permalink
The solver method applied in solve_ivp should be set in parameters.py…
Browse files Browse the repository at this point in the history
…. Running marlpde as from the previous commit led to 'RuntimeError: Encountered Not-A-Number (NaN) in evolution' (this is with 'LSODA'). Stability was added by providing the equivalent of a Jacobian sparsity matrix for 'LSODA' which is done by setting 'lband' and 'uband'. This not only provided stability but also led to a substantial performance increase!
  • Loading branch information
HannoSpreeuw committed Aug 2, 2024
1 parent b6b3df0 commit cd364b7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion marlpde/Evolve_scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ def integrate_equations(**kwargs):

sol, info = eq.solve(state, t_range=End_time, dt=dt, \
solver=kwargs["solver"], scheme=kwargs["scheme"],\
method="LSODA", tracker=["progress", \
method=kwargs["method"], lband=kwargs["lband"], \
uband=kwargs["uband"], tracker=["progress", \
storage.tracker(kwargs["progress_tracker_interval"]),\
live_plots, data_tracker], \
backend=kwargs["backend"], ret_info=kwargs["retinfo"],\
Expand Down
8 changes: 8 additions & 0 deletions marlpde/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,14 @@ class Solver:
# chosen py-pde's native "explicit" solver above.
scheme: str = "euler"
adaptive: bool = True
# solve_ivp from scipy offers six methods. They can be set here.
method: str = "LSODA"
# Setting lband and uband for method="LSODA" leads to tremendous performance
# increase. See Scipy's solve_ivp documentation for background. Consider it
# equivalent to providing a sparsity matrix for the "Radau" and "BDF"
# implicit methods.
lband: int = 1
uband: int = 1
backend: str = "numba"
retinfo: bool = True

Expand Down

0 comments on commit cd364b7

Please sign in to comment.