Skip to content

Commit

Permalink
MAINT: Update interface of krylov methods from scipy to 1.26
Browse files Browse the repository at this point in the history
  • Loading branch information
jwboth committed Sep 9, 2024
1 parent 9b207f1 commit cbeba48
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/darsia/measure/wasserstein.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from enum import Enum
from pathlib import Path
from typing import Optional, Union
from warnings import warn

import numpy as np
import pyamg
Expand Down Expand Up @@ -407,12 +408,15 @@ def setup_amg_solver(self, matrix: sps.csc_matrix) -> None:

# Define solver options
linear_solver_options = self.options.get("linear_solver_options", {})
tol = linear_solver_options.get("tol", 1e-6)
atol = linear_solver_options.get("atol", 1e-6)
rtol = linear_solver_options.get("rtol", None)
if not rtol:
warn("rtol not used for AMG solver.")
maxiter = linear_solver_options.get("maxiter", 100)
self.amg_residual_history = []
"""list: history of residuals for the AMG solver"""
self.solver_options = {
"tol": tol,
"tol": atol,
"maxiter": maxiter,
"residuals": self.amg_residual_history,
}
Expand Down Expand Up @@ -442,10 +446,12 @@ def setup_cg_solver(self, matrix: sps.csc_matrix) -> None:

# Define solver options
linear_solver_options = self.options.get("linear_solver_options", {})
tol = linear_solver_options.get("tol", 1e-6)
rtol = linear_solver_options.get("rtol", 1e-6)
atol = linear_solver_options.get("atol", 0)
maxiter = linear_solver_options.get("maxiter", 100)
self.solver_options = {
"tol": tol,
"rtol": rtol,
"atol": atol,
"maxiter": maxiter,
"M": amg,
}
Expand Down Expand Up @@ -474,7 +480,8 @@ def setup_ksp_solver(

# Define solver options
linear_solver_options = self.options.get("linear_solver_options", {})
tol = linear_solver_options.get("tol", 1e-6)
rtol = linear_solver_options.get("rtol", 1e-6)
atol = linear_solver_options.get("atol", 0)
maxiter = linear_solver_options.get("maxiter", 100)
approach = linear_solver_options.get("approach", "direct")

Expand All @@ -490,7 +497,8 @@ def setup_ksp_solver(
self.solver_options = {
"ksp_type": approach,
# "ksp_monitor_true_residual": None,
"ksp_rtol": tol,
"ksp_rtol": rtol,
"ksp_atol": atol,
"ksp_max_it": maxiter,
"pc_type": prec,
}
Expand All @@ -509,7 +517,8 @@ def setup_ksp_solver(
# passed to the field_ises
self.solver_options = {
"ksp_type": approach,
"ksp_rtol": tol,
"ksp_rtol": rtol,
"ksp_atol": atol,
"ksp_max_it": maxiter,
# "ksp_monitor_true_residual": None, #this is for debugging
"pc_type": "fieldsplit",
Expand Down

0 comments on commit cbeba48

Please sign in to comment.