Skip to content

Commit

Permalink
use default solver rather than pardiso
Browse files Browse the repository at this point in the history
  • Loading branch information
lheagy committed Jan 12, 2025
1 parent 916a009 commit 67222da
Show file tree
Hide file tree
Showing 17 changed files with 64 additions and 50 deletions.
16 changes: 9 additions & 7 deletions geoscilabs/dcip/DCIP_overburden_PseudoSection.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@
from simpeg.utils import extract_core_mesh
from simpeg.electromagnetics.static import resistivity as DC
from simpeg.electromagnetics.static import induced_polarization as IP
from pymatsolver import Pardiso
from simpeg.utils.solver_utils import get_default_solver

from ..base import widgetify

Solver = get_default_solver()

# Mesh, sigmaMap can be globals global
npad = 12
growrate = 2.0
Expand Down Expand Up @@ -179,13 +181,13 @@ def model_fields(A, B, mtrue, mhalf, mair, mover, whichprimary="overburden"):
survey = DC.Survey([src])
# Create three simulations so the fields object is accurate
sim_primary = DC.Simulation2DCellCentered(
mesh, survey=survey, sigmaMap=mapping, solver=Pardiso
mesh, survey=survey, sigmaMap=mapping, solver=Solver
)
sim_total = DC.Simulation2DCellCentered(
mesh, survey=survey, sigmaMap=mapping, solver=Pardiso
mesh, survey=survey, sigmaMap=mapping, solver=Solver
)
sim_air = DC.Simulation2DCellCentered(
mesh, survey=survey, sigmaMap=mapping, solver=Pardiso
mesh, survey=survey, sigmaMap=mapping, solver=Solver
)

if whichprimary == "air":
Expand Down Expand Up @@ -302,7 +304,7 @@ def getSensitivity(survey, A, B, M, N, model):

survey = DC.Survey([src])
problem = DC.Simulation2DCellCentered(
mesh, sigmaMap=mapping, solver=Pardiso, survey=survey
mesh, sigmaMap=mapping, solver=Solver, survey=survey
)

J = problem.getJ(model)[0]
Expand Down Expand Up @@ -458,7 +460,7 @@ def DC2Dsimulation(mtrue, flag="PoleDipole", nmax=8):

survey = DC.Survey(txList)
simulation = DC.Simulation2DCellCentered(
mesh, sigmaMap=mapping, survey=survey, solver=Pardiso
mesh, sigmaMap=mapping, survey=survey, solver=Solver
)

return simulation, xzlocs
Expand Down Expand Up @@ -548,7 +550,7 @@ def IP2Dsimulation(miptrue, sigmadc, flag="PoleDipole", nmax=8):
sigma=sigmadc,
etaMap=maps.IdentityMap(mesh),
survey=survey,
solver=Pardiso,
solver=Solver,
)

return simulation, xzlocs
Expand Down
6 changes: 4 additions & 2 deletions geoscilabs/dcip/DCLayers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
from discretize import TensorMesh

from simpeg import maps, utils
from pymatsolver import Pardiso
from simpeg.utils.solver_utils import get_default_solver

from ..base import widgetify

Solver = get_default_solver()

rcParams["font.size"] = 16

# Mesh parameters
Expand Down Expand Up @@ -172,7 +174,7 @@ def solve_2D_potentials(rho1, rho2, h, A, B):
* utils.sdiag(1.0 / (mesh.dim * mesh.aveF2CC.T * (1.0 / sigma)))
* mesh.cell_gradient
)
Ainv = Pardiso(A)
Ainv = Solver(A)

V = Ainv * q
return V
Expand Down
10 changes: 6 additions & 4 deletions geoscilabs/dcip/DCWidgetPlate2_5D.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@
from matplotlib.path import Path
import matplotlib.patches as patches

from pymatsolver import Pardiso
from simpeg.utils.solver_utils import get_default_solver

from discretize import TensorMesh
from simpeg import maps, SolverLU, utils
from simpeg.utils import extract_core_mesh
from simpeg.electromagnetics.static import resistivity as DC
from ..base import widgetify

Solver = get_default_solver()

# Mesh, mapping can be globals global
npad = 15
growrate = 2.0
Expand Down Expand Up @@ -88,10 +90,10 @@ def plate_fields(A, B, dx, dz, xc, zc, rotAng, sigplate, sighalf):
src = DC.sources.Dipole([], np.r_[A, 0.0], np.r_[B, 0.0])
survey = DC.survey.Survey([src])
problem = DC.Simulation2DCellCentered(
mesh, survey=survey, sigmaMap=mapping, solver=Pardiso
mesh, survey=survey, sigmaMap=mapping, solver=Solver
)
problem_prim = DC.Simulation2DCellCentered(
mesh, survey=survey, sigmaMap=mapping, solver=Pardiso
mesh, survey=survey, sigmaMap=mapping, solver=Solver
)

total_field = problem.fields(mtrue)
Expand Down Expand Up @@ -292,7 +294,7 @@ def getSensitivity(survey, A, B, M, N, model):

survey = DC.Survey([src])
sim = DC.Simulation3DCellCentered(
mesh, sigmaMap=mapping, solver=Pardiso, survey=survey
mesh, sigmaMap=mapping, solver=Solver, survey=survey
)
J = sim.getJ(model)[0]

Expand Down
10 changes: 6 additions & 4 deletions geoscilabs/dcip/DCWidgetPlate_2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from matplotlib.ticker import LogFormatter
from matplotlib.path import Path
import matplotlib.patches as patches
from pymatsolver import Pardiso
from simpeg.utils.solver_utils import get_default_solver

from discretize import TensorMesh
from simpeg import maps, SolverLU, utils
Expand All @@ -20,6 +20,8 @@

from ..base import widgetify

Solver = get_default_solver()

# Mesh, mapping can be globals global
npad = 15
growrate = 2.0
Expand Down Expand Up @@ -91,10 +93,10 @@ def plate_fields(A, B, dx, dz, xc, zc, rotAng, sigplate, sighalf):
survey = DC.survey.Survey([src])

problem = DC.Simulation3DCellCentered(
mesh, survey=survey, sigmaMap=mapping, solver=Pardiso
mesh, survey=survey, sigmaMap=mapping, solver=Solver
)
problem_prim = DC.Simulation3DCellCentered(
mesh, survey=survey, sigmaMap=mapping, solver=Pardiso
mesh, survey=survey, sigmaMap=mapping, solver=Solver
)

primary_field = problem_prim.fields(mhalf)
Expand Down Expand Up @@ -293,7 +295,7 @@ def getSensitivity(survey, A, B, M, N, model):

survey = DC.Survey([src])
sim = DC.Simulation3DCellCentered(
mesh, sigmaMap=mapping, solver=Pardiso, survey=survey
mesh, sigmaMap=mapping, solver=Solver, survey=survey
)
J = sim.getJ(model)[0]

Expand Down
10 changes: 6 additions & 4 deletions geoscilabs/dcip/DCWidgetResLayer2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
import matplotlib.patches as patches
from scipy.constants import epsilon_0
import copy
from pymatsolver import Pardiso
from simpeg.utils.solver_utils import get_default_solver

from ipywidgets import interact, IntSlider, FloatSlider, FloatText, ToggleButtons

from ..base import widgetify

Solver = get_default_solver()

# Mesh, sigmaMap can be globals global
npad = 15
growrate = 2.0
Expand Down Expand Up @@ -94,10 +96,10 @@ def model_fields(A, B, zcLayer, dzLayer, xc, zc, r, sigLayer, sigTarget, sigHalf
survey = DC.Survey([src])

problem = DC.Simulation3DCellCentered(
mesh, sigmaMap=sigmaMap, solver=Pardiso, survey=survey
mesh, sigmaMap=sigmaMap, solver=Solver, survey=survey
)
problem_prim = DC.Simulation3DCellCentered(
mesh, sigmaMap=sigmaMap, solver=Pardiso, survey=survey
mesh, sigmaMap=sigmaMap, solver=Solver, survey=survey
)

primary_field = problem_prim.fields(mhalf)
Expand Down Expand Up @@ -335,7 +337,7 @@ def getSensitivity(survey, A, B, M, N, model):

survey = DC.survey.Survey([src])
problem = DC.Simulation3DCellCentered(
mesh, survey=survey, sigmaMap=sigmaMap, solver=Pardiso
mesh, survey=survey, sigmaMap=sigmaMap, solver=Solver
)
J = problem.getJ(model)

Expand Down
10 changes: 6 additions & 4 deletions geoscilabs/dcip/DCWidgetResLayer2_5D.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@
from simpeg import maps, SolverLU, utils
from simpeg.utils import extract_core_mesh
from simpeg.electromagnetics.static import resistivity as DC
from pymatsolver import Pardiso
from simpeg.utils.solver_utils import get_default_solver

from discretize import TensorMesh

from ipywidgets import interact, IntSlider, FloatSlider, FloatText, ToggleButtons

from ..base import widgetify

Solver = get_default_solver()

# Mesh, sigmaMap can be globals global
npad = 15
growrate = 2.0
Expand Down Expand Up @@ -99,11 +101,11 @@ def model_fields(A, B, zcLayer, dzLayer, xc, zc, r, sigLayer, sigTarget, sigHalf
src = DC.sources.Dipole([], np.r_[A, 0.0], np.r_[B, 0.0])
survey = DC.Survey([src])
sim = DC.Simulation2DCellCentered(
mesh, survey=survey, sigmaMap=mapping, solver=Pardiso
mesh, survey=survey, sigmaMap=mapping, solver=Solver
)
total_field = sim.fields(mtrue)
sim_prim = DC.Simulation2DCellCentered(
mesh, survey=survey, sigmaMap=mapping, solver=Pardiso
mesh, survey=survey, sigmaMap=mapping, solver=Solver
)
primary_field = sim_prim.fields(mhalf)

Expand Down Expand Up @@ -347,7 +349,7 @@ def getSensitivity(survey, A, B, M, N, model):

Src = DC.Survey([src])
sim = DC.Simulation2DCellCentered(
mesh, survey=Src, sigmaMap=mapping, solver=Pardiso
mesh, survey=Src, sigmaMap=mapping, solver=Solver
)
J = sim.getJ(model)

Expand Down
12 changes: 7 additions & 5 deletions geoscilabs/dcip/DCWidget_Overburden_2_5D.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@
from simpeg.utils import extract_core_mesh
from simpeg.electromagnetics.static import resistivity as DC

from pymatsolver import Pardiso
from simpeg.utils.solver_utils import get_default_solver

from ..base import widgetify

Solver = get_default_solver()

# Mesh, sigmaMap can be globals global
npad = 12
growrate = 2.0
Expand Down Expand Up @@ -165,13 +167,13 @@ def model_fields(A, B, mtrue, mhalf, mair, mover, whichprimary="air"):
src = DC.sources.Dipole([], np.r_[A, surfaceA], np.r_[B, surfaceB])
survey = DC.survey.Survey([src])
problem = DC.Simulation2DCellCentered(
mesh, survey=survey, sigmaMap=mapping, solver=Pardiso
mesh, survey=survey, sigmaMap=mapping, solver=Solver
)
problem_prim = DC.Simulation2DCellCentered(
mesh, survey=survey, sigmaMap=mapping, solver=Pardiso
mesh, survey=survey, sigmaMap=mapping, solver=Solver
)
problem_air = DC.Simulation2DCellCentered(
mesh, survey=survey, sigmaMap=mapping, solver=Pardiso
mesh, survey=survey, sigmaMap=mapping, solver=Solver
)

if whichprimary == "air":
Expand Down Expand Up @@ -307,7 +309,7 @@ def getSensitivity(survey, A, B, M, N, model):

Src = DC.Survey([src])
sim = DC.Simulation2DCellCentered(
mesh, survey=Src, sigmaMap=mapping, solver=Pardiso
mesh, survey=Src, sigmaMap=mapping, solver=Solver
)
J = sim.getJ(model)[0]

Expand Down
5 changes: 3 additions & 2 deletions geoscilabs/dcip/DC_Pseudosections.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import matplotlib.patches as patches

from discretize import TensorMesh
from pymatsolver import Pardiso
from simpeg.utils.solver_utils import get_default_solver

from simpeg import maps, SolverLU, utils
from simpeg.electromagnetics.static import resistivity as DC
Expand All @@ -27,6 +27,7 @@

from ..base import widgetify

Solver = get_default_solver()

class ParametricCircleLayerMap(IdentityMap):

Expand Down Expand Up @@ -167,7 +168,7 @@ def DC2Dsurvey(flag="PolePole"):

survey = DC.Survey(txList)
simulation = DC.Simulation2DCellCentered(
mesh, survey=survey, sigmaMap=mapping, solver=Pardiso
mesh, survey=survey, sigmaMap=mapping, solver=Solver
)

sigblk, sighalf, siglayer = 2e-2, 2e-3, 1e-3
Expand Down
10 changes: 6 additions & 4 deletions geoscilabs/dcip/DC_cylinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from matplotlib.path import Path
import matplotlib.patches as patches

from pymatsolver import Pardiso
from simpeg.utils.solver_utils import get_default_solver
from discretize import TensorMesh

from simpeg import maps, utils
Expand All @@ -18,6 +18,8 @@

from ..base import widgetify

Solver = get_default_solver()

# Mesh, sigmaMap can be globals global
npad = 15
growrate = 2.0
Expand Down Expand Up @@ -88,10 +90,10 @@ def cylinder_fields(A, B, r, sigcyl, sighalf, xc=0.0, zc=-20.0):

# make two simulations for the seperate field objects
sim_primary = DC.Simulation2DCellCentered(
mesh, survey=survey, sigmaMap=sigmaMap, solver=Pardiso
mesh, survey=survey, sigmaMap=sigmaMap, solver=Solver
)
sim_total = DC.Simulation2DCellCentered(
mesh, survey=survey, sigmaMap=sigmaMap, solver=Pardiso
mesh, survey=survey, sigmaMap=sigmaMap, solver=Solver
)

primary_field = sim_primary.fields(mhalf)
Expand Down Expand Up @@ -194,7 +196,7 @@ def getSensitivity(survey, A, B, M, N, model):

Src = DC.Survey([src])
sim = DC.Simulation2DCellCentered(
mesh, survey=Src, sigmaMap=sigmaMap, solver=Pardiso
mesh, survey=Src, sigmaMap=sigmaMap, solver=Solver
)
J = sim.getJ(model)[0]

Expand Down
6 changes: 3 additions & 3 deletions geoscilabs/em/HarmonicVMDCylWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
from discretize import CylindricalMesh, TensorMesh
from simpeg import maps, utils
from simpeg.electromagnetics import frequency_domain as fdem
from pymatsolver import Pardiso
from simpeg.utils.solver_utils import get_default_solver

# from pymatsolver import PardisoSolver
import matplotlib.pyplot as plt
import numpy as np
from PIL import Image
Expand All @@ -16,6 +15,7 @@
from .DipoleWidgetFD import DisPosNegvalues
from .BiotSavart import BiotSavartFun

Solver = get_default_solver()

class HarmonicVMDCylWidget(object):
"""FDEMCylWidgete"""
Expand Down Expand Up @@ -193,7 +193,7 @@ def simulate(self, srcLoc, rxLoc, freqs):

survey = fdem.survey.Survey(self.srcList)
sim = fdem.Simulation3DMagneticFluxDensity(
self.mesh, survey=survey, sigmaMap=self.mapping, mu=self.mu, solver=Pardiso
self.mesh, survey=survey, sigmaMap=self.mapping, mu=self.mu, solver=Solver
)

self.f = sim.fields(self.m)
Expand Down
3 changes: 0 additions & 3 deletions geoscilabs/em/Loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
import matplotlib.pyplot as plt
import matplotlib.patches as patches

from pymatsolver import Pardiso


def rectangular_plane_layout(mesh, corner, closed=False, I=1.0):
"""
corner: sorted list of four corners (x,y,z)
Expand Down
Loading

0 comments on commit 67222da

Please sign in to comment.