Esempio n. 1
0
def run_simulation(fname="tdem_vmd.h5", sigma_halfspace=0.01, src_type="VMD"):
    from SimPEG.EM import TDEM, Analytics, mu_0
    import numpy as np
    from SimPEG import Mesh, Maps, Utils, EM, Survey
    from pymatsolver import Pardiso

    cs = 20.0
    ncx, ncy, ncz = 5, 3, 4
    npad = 10
    npadz = 10
    pad_rate = 1.3
    hx = [(cs, npad, -pad_rate), (cs, ncx), (cs, npad, pad_rate)]
    hy = [(cs, npad, -pad_rate), (cs, ncy), (cs, npad, pad_rate)]
    hz = Utils.meshTensor([(cs, npadz, -1.3), (cs / 2.0, ncz), (cs, 5, 2)])
    mesh = Mesh.TensorMesh([hx, hy, hz],
                           x0=["C", "C", -hz[:int(npadz + ncz / 2)].sum()])
    sigma = np.ones(mesh.nC) * sigma_halfspace
    sigma[mesh.gridCC[:, 2] > 0.0] = 1e-8

    xmin, xmax = -600.0, 600.0
    ymin, ymax = -600.0, 600.0
    zmin, zmax = -600, 100.0

    times = np.logspace(-5, -2, 21)
    rxList = EM.TDEM.Rx.Point_dbdt(np.r_[10.0, 0.0, 30.0],
                                   times,
                                   orientation="z")
    if src_type == "VMD":
        src = EM.TDEM.Src.CircularLoop(
            [rxList],
            loc=np.r_[0.0, 0.0, 30.0],
            orientation="Z",
            waveform=EM.TDEM.Src.StepOffWaveform(),
            radius=13.0,
        )
    elif src_type == "HMD":
        src = EM.TDEM.Src.MagDipole(
            [rxList],
            loc=np.r_[0.0, 0.0, 30.0],
            orientation="X",
            waveform=EM.TDEM.Src.StepOffWaveform(),
        )
    SrcList = [src]
    survey = EM.TDEM.Survey(SrcList)
    sig = 1e-2
    sigma = np.ones(mesh.nC) * sig
    sigma[mesh.gridCC[:, 2] > 0] = 1e-8
    prb = EM.TDEM.Problem3D_b(mesh,
                              sigmaMap=Maps.IdentityMap(mesh),
                              verbose=True)
    prb.pair(survey)
    prb.Solver = Pardiso
    prb.timeSteps = [
        (1e-06, 5),
        (5e-06, 5),
        (1e-05, 10),
        (5e-05, 10),
        (1e-4, 15),
        (5e-4, 16),
    ]

    f = prb.fields(sigma)

    xyzlim = np.array([[xmin, xmax], [ymin, ymax], [zmin, zmax]])
    actinds, meshCore = Utils.ExtractCoreMesh(xyzlim, mesh)
    Pex = mesh.getInterpolationMat(meshCore.gridCC, locType="Ex")
    Pey = mesh.getInterpolationMat(meshCore.gridCC, locType="Ey")
    Pez = mesh.getInterpolationMat(meshCore.gridCC, locType="Ez")
    Pfx = mesh.getInterpolationMat(meshCore.gridCC, locType="Fx")
    Pfy = mesh.getInterpolationMat(meshCore.gridCC, locType="Fy")
    Pfz = mesh.getInterpolationMat(meshCore.gridCC, locType="Fz")

    sigma_core = sigma[actinds]

    def getEBJcore(src0):
        B0 = np.r_[Pfx * f[src0, "b"], Pfy * f[src0, "b"], Pfz * f[src0, "b"]]
        E0 = np.r_[Pex * f[src0, "e"], Pey * f[src0, "e"], Pez * f[src0, "e"]]
        J0 = Utils.sdiag(np.r_[sigma_core, sigma_core, sigma_core]) * E0
        return E0, B0, J0

    E, B, J = getEBJcore(src)
    tdem_is = {
        "E": E,
        "B": B,
        "J": J,
        "sigma": sigma_core,
        "mesh": meshCore.serialize(),
        "time": prb.times,
    }
    dd.io.save(fname, tdem_is)
def run_simulation(fname="tdem_gs_half.h5",
                   sigma_block=0.01,
                   sigma_halfspace=0.01):
    from SimPEG.EM import TDEM, Analytics, mu_0
    import numpy as np
    from SimPEG import Mesh, Maps, Utils, EM, Survey
    from pymatsolver import Pardiso

    cs = 20
    ncx, ncy, ncz = 20, 20, 20
    npad = 10
    hx = [(cs, npad, -1.5), (cs, ncx), (cs, npad, 1.5)]
    hy = [(cs, npad, -1.5), (cs, ncy), (cs, npad, 1.5)]
    hz = [(cs, npad, -1.5), (cs, ncz), (cs, npad, 1.5)]
    mesh = Mesh.TensorMesh([hx, hy, hz], "CCC")
    sigma = np.ones(mesh.nC) * sigma_halfspace
    blk_ind = Utils.ModelBuilder.getIndicesBlock(np.r_[-40, -40, -160],
                                                 np.r_[40, 40,
                                                       -80], mesh.gridCC)
    sigma[mesh.gridCC[:, 2] > 0.0] = 1e-8
    sigma[blk_ind] = sigma_block

    xmin, xmax = -200.0, 200.0
    ymin, ymax = -200.0, 200.0
    x = mesh.vectorCCx[np.logical_and(mesh.vectorCCx > xmin,
                                      mesh.vectorCCx < xmax)]
    y = mesh.vectorCCy[np.logical_and(mesh.vectorCCy > ymin,
                                      mesh.vectorCCy < ymax)]
    xyz = Utils.ndgrid(x, y, np.r_[-1.0])

    px = np.r_[-200.0, 200.0]
    py = np.r_[0.0, 0.0]
    pz = np.r_[0.0, 0.0]
    srcLoc = np.c_[px, py, pz]

    from scipy.interpolate import interp1d

    prb = TDEM.Problem3D_b(mesh, sigma=sigma, verbose=True)
    prb.Solver = Pardiso
    prb.solverOpts = {"is_symmetric": False}
    prb.timeSteps = [(1e-3, 10), (2e-5, 10), (1e-4, 10), (5e-4, 10),
                     (1e-3, 10)]
    t0 = 0.01 + 1e-4
    out = EM.Utils.VTEMFun(prb.times, 0.01, t0, 200)
    wavefun = interp1d(prb.times, out)
    waveform = EM.TDEM.Src.RawWaveform(offTime=t0, waveFct=wavefun)
    input_currents = wavefun(prb.times)

    times = np.logspace(-4, -2, 21)
    rx_ex = TDEM.Rx.Point_e(xyz, times + t0, orientation="x")
    rx_ey = TDEM.Rx.Point_e(xyz, times + t0, orientation="y")
    rx_by = TDEM.Rx.Point_e(xyz, times + t0, orientation="y")

    rxList = [rx_ex, rx_ey, rx_by]
    src = TDEM.Src.LineCurrent(rxList, loc=srcLoc, waveform=waveform)
    survey = TDEM.Survey([src])
    survey.pair(prb)

    f = prb.fields(sigma)

    xyzlim = np.array([[xmin, xmax], [ymin, ymax], [-400, 0.0]])
    actinds, meshCore = Utils.ExtractCoreMesh(xyzlim, mesh)
    Pex = mesh.getInterpolationMat(meshCore.gridCC, locType="Ex")
    Pey = mesh.getInterpolationMat(meshCore.gridCC, locType="Ey")
    Pez = mesh.getInterpolationMat(meshCore.gridCC, locType="Ez")
    Pfx = mesh.getInterpolationMat(meshCore.gridCC, locType="Fx")
    Pfy = mesh.getInterpolationMat(meshCore.gridCC, locType="Fy")
    Pfz = mesh.getInterpolationMat(meshCore.gridCC, locType="Fz")

    sigma_core = sigma[actinds]

    def getEBJcore(src0):
        B0 = np.r_[Pfx * f[src0, "b"], Pfy * f[src0, "b"], Pfz * f[src0, "b"]]
        E0 = np.r_[Pex * f[src0, "e"], Pey * f[src0, "e"], Pez * f[src0, "e"]]
        J0 = Utils.sdiag(np.r_[sigma_core, sigma_core, sigma_core]) * E0
        return E0, B0, J0

    E, B, J = getEBJcore(src)
    tdem_gs = {
        "E": E,
        "B": B,
        "J": J,
        "sigma": sigma_core,
        "mesh": meshCore.serialize(),
        "time": prb.times - t0,
        "input_currents": input_currents,
    }
    dd.io.save(fname, tdem_gs)
Esempio n. 3
0
cs = 1.25
hx = [(cs, npad, -1.3), (cs, 100), (cs, npad, 1.3)]
hy = [(cs, npad, -1.3), (cs, 50)]
mesh = Mesh.TensorMesh([hx, hy], "CN")
circmap = ParametricCircleLayerMap(mesh)
circmap.slope = 1e5
mapping = circmap
dx = 5
xr = np.arange(-40, 41, dx)
dxr = np.diff(xr)
xmin = -40.
xmax = 40.
ymin = -40.
ymax = 5.
xylim = np.c_[[xmin, ymin], [xmax, ymax]]
indCC, meshcore = Utils.ExtractCoreMesh(xylim, mesh)
indx = (mesh.gridFx[:, 0] >= xmin) & (mesh.gridFx[:, 0] <= xmax) \
    & (mesh.gridFx[:, 1] >= ymin) & (mesh.gridFx[:, 1] <= ymax)
indy = (mesh.gridFy[:, 0] >= xmin) & (mesh.gridFy[:, 0] <= xmax) \
    & (mesh.gridFy[:, 1] >= ymin) & (mesh.gridFy[:, 1] <= ymax)
indF = np.concatenate((indx, indy))


def DC2Dsurvey(flag="PolePole"):
    """
    Function that define a surface DC survey
    :param str flag: Survey Type 'PoleDipole', 'DipoleDipole', 'DipolePole', 'PolePole'
    """
    if flag == "PoleDipole":
        ntx, nmax = xr.size-2, 8
    elif flag == "DipolePole":