cs = 1.25 hx = [(cs, npad, -1.3), (cs, 100), (cs, npad, 1.3)] hy = [(cs, npad, -1.3), (cs, 50)] 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.0 xmax = 40.0 ymin = -40.0 ymax = 5.0 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'
def run_simulation(fname="tdem_gs_half.h5", sigma_block=0.01, sigma_halfspace=0.01): from SimPEG.electromagnetics import time_domain as tdem from SimPEG.electromagnetics.utils import waveform_utils from SimPEG.EM import Analytics, mu_0 import numpy as np from SimPEG import 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 = 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 times = np.logspace(-4, -2, 21) rx_ex = tdem.receivers.PointElectricField(xyz, times + t0, orientation="x") rx_ey = tdem.receivers.PointElectricField(xyz, times + t0, orientation="y") rx_by = tdem.receivers.PointElectricField(xyz, times + t0, orientation="y") rxList = [rx_ex, rx_ey, rx_by] src = tdem.sources.LineCurrent(rxList, loc=srcLoc, waveform=waveform) survey = tdem.survey.Survey([src]) sim = tdem.simulation.Simulation3DMagneticFluxDensity(mesh, survey=survey, sigma=sigma, verbose=True) sim.Solver = Pardiso sim.solverOpts = {"is_symmetric": False} sim.time_steps = [(1e-3, 10), (2e-5, 10), (1e-4, 10), (5e-4, 10), (1e-3, 10)] t0 = 0.01 + 1e-4 out = waveform_utils.VTEMFun(sim.times, 0.01, t0, 200) wavefun = interp1d(sim.times, out) waveform = tdem.sources.RawWaveform(offTime=t0, waveFct=wavefun) input_currents = wavefun(sim.times) f = sim.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": sim.times - t0, "input_currents": input_currents, } dd.io.save(fname, tdem_gs)
def run_simulation(fname="tdem_vmd.h5", sigma_halfspace=0.01, src_type="VMD"): from SimPEG.electromagnetics import time_domain from scipy.constants import mu_0 import numpy as np from SimPEG import maps 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 = 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 = time_domain.receivers.PointMagneticFluxTimeDerivative( np.r_[10.0, 0.0, 30.0], times, orientation="z") if src_type == "VMD": src = time_domain.sources.CircularLoop( [rxList], loc=np.r_[0.0, 0.0, 30.0], orientation="Z", waveform=time_domain.sources.StepOffWaveform(), radius=13.0, ) elif src_type == "HMD": src = time_domain.sources.MagDipole( [rxList], loc=np.r_[0.0, 0.0, 30.0], orientation="X", waveform=time_domain.sources.StepOffWaveform(), ) SrcList = [src] survey = time_domain.Survey(SrcList) sig = 1e-2 sigma = np.ones(mesh.nC) * sig sigma[mesh.gridCC[:, 2] > 0] = 1e-8 prb = time_domain.Simulation3DMagneticFluxDensity( mesh, sigmaMap=maps.IdentityMap(mesh), verbose=True, survey=survey, solver=Pardiso, ) prb.time_steps = [ (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)