def test_Simulation2DNodal(self): problemDC = dc.Simulation2DNodal(self.mesh, survey=self.surveyDC, sigmaMap=maps.IdentityMap(self.mesh)) problemDC.solver = Solver data0 = problemDC.dpred(self.sigma0) datainf = problemDC.dpred(self.sigmaInf) surveyIP = ip.Survey(self.source_lists_ip) problemIP = ip.Simulation2DNodal( self.mesh, survey=surveyIP, sigma=self.sigmaInf, etaMap=maps.IdentityMap(self.mesh), ) problemIP.solver = Solver data_full = data0 - datainf data = problemIP.dpred(self.eta) err = np.linalg.norm( (data - data_full) / data_full)**2 / data_full.size if err < 0.05: passed = True print(">> IP forward test for Simulation2DNodal is passed") print(err) else: passed = False print(">> IP forward test for Simulation2DNodal is failed") self.assertTrue(passed)
def setUp(self): cs = 12.5 hx = [(cs, 7, -1.3), (cs, 61), (cs, 7, 1.3)] hy = [(cs, 7, -1.3), (cs, 20)] mesh = discretize.TensorMesh([hx, hy], x0="CN") # x = np.linspace(-200, 200., 20) x = np.linspace(-200, 200.0, 2) M = utils.ndgrid(x - 12.5, np.r_[0.0]) N = utils.ndgrid(x + 12.5, np.r_[0.0]) A0loc = np.r_[-150, 0.0] A1loc = np.r_[-130, 0.0] B0loc = np.r_[-130, 0.0] B1loc = np.r_[-110, 0.0] rx = dc.Rx.Dipole(M, N) src0 = dc.Src.Dipole([rx], A0loc, B0loc) src1 = dc.Src.Dipole([rx], A1loc, B1loc) survey = ip.Survey([src0, src1]) sigma = np.ones(mesh.nC) * 1.0 problem = ip.Simulation2DCellCentered( mesh, survey=survey, sigma=sigma, etaMap=maps.IdentityMap(mesh), verbose=False, ) mSynth = np.ones(mesh.nC) * 0.1 dobs = problem.make_synthetic_data(mSynth, add_noise=True) # Now set up the problem to do some minimization dmis = data_misfit.L2DataMisfit(data=dobs, simulation=problem) reg = regularization.Tikhonov(mesh) opt = optimization.InexactGaussNewton(maxIterLS=20, maxIter=10, tolF=1e-6, tolX=1e-6, tolG=1e-6, maxIterCG=6) invProb = inverse_problem.BaseInvProblem(dmis, reg, opt, beta=1e4) inv = inversion.BaseInversion(invProb) self.inv = inv self.reg = reg self.p = problem self.mesh = mesh self.m0 = mSynth self.survey = survey self.dmis = dmis
def setUp(self): cs = 12.5 hx = [(cs, 7, -1.3), (cs, 61), (cs, 7, 1.3)] hy = [(cs, 7, -1.3), (cs, 20)] mesh = discretize.TensorMesh([hx, hy], x0="CN") x = np.linspace(-200, 200.0, 20) M = utils.ndgrid(x - 12.5, np.r_[0.0]) N = utils.ndgrid(x + 12.5, np.r_[0.0]) A0loc = np.r_[-150, 0.0] A1loc = np.r_[-130, 0.0] B0loc = np.r_[-130, 0.0] B1loc = np.r_[-110, 0.0] rx = dc.Rx.Dipole(M, N) src0 = dc.Src.Dipole([rx], A0loc, B0loc) src1 = dc.Src.Dipole([rx], A1loc, B1loc) survey_dc = dc.Survey([src0, src1]) rx_ip = dc.Rx.Dipole(M, N, data_type="apparent_chargeability") src0_ip = dc.Src.Dipole([rx_ip], A0loc, B0loc) src1_ip = dc.Src.Dipole([rx_ip], A1loc, B1loc) survey_ip = ip.Survey([src0_ip, src1_ip]) sigmaInf = np.ones(mesh.nC) * 1.0 blkind = utils.model_builder.getIndicesSphere(np.r_[0, -150], 40, mesh.gridCC) eta = np.zeros(mesh.nC) eta[blkind] = 0.05 sigma0 = sigmaInf * (1.0 - eta) self.survey_dc = survey_dc self.survey_ip = survey_ip self.mesh = mesh self.sigmaInf = sigmaInf self.sigma0 = sigma0 self.eta = eta
def test_Simulation2DCellCentered(self): problemDC = dc.Simulation2DCellCentered(self.mesh, survey=self.surveyDC, rhoMap=maps.IdentityMap( self.mesh)) problemDC.solver = Solver data0 = problemDC.dpred(1.0 / self.sigma0) finf = problemDC.fields(1.0 / self.sigmaInf) datainf = problemDC.dpred(1.0 / self.sigmaInf, f=finf) surveyIP = ip.Survey(self.source_lists_ip) problemIP = ip.Simulation2DCellCentered( self.mesh, survey=surveyIP, rho=1.0 / self.sigmaInf, etaMap=maps.IdentityMap(self.mesh), ) problemIP.solver = Solver data_full = data0 - datainf data = problemIP.dpred(self.eta) err = np.linalg.norm( (data - data_full) / data_full)**2 / data_full.size if err < 0.05: passed = True print(">> IP forward test for Simulation2DCellCentered is passed") else: import matplotlib.pyplot as plt passed = False print(">> IP forward test for Simulation2DCellCentered is failed") print(err) plt.plot(data_full) plt.plot(data, "k.") plt.show() self.assertTrue(passed)
def setUp(self): cs = 12.5 npad = 2 hx = [(cs, npad, -1.3), (cs, 21), (cs, npad, 1.3)] hy = [(cs, npad, -1.3), (cs, 21), (cs, npad, 1.3)] hz = [(cs, npad, -1.3), (cs, 20)] mesh = discretize.TensorMesh([hx, hy, hz], x0="CCN") x = mesh.vectorCCx[(mesh.vectorCCx > -80.0) & (mesh.vectorCCx < 80.0)] y = mesh.vectorCCy[(mesh.vectorCCy > -80.0) & (mesh.vectorCCy < 80.0)] Aloc = np.r_[-100.0, 0.0, 0.0] Bloc = np.r_[100.0, 0.0, 0.0] M = utils.ndgrid(x - 12.5, y, np.r_[0.0]) N = utils.ndgrid(x + 12.5, y, np.r_[0.0]) radius = 50.0 xc = np.r_[0.0, 0.0, -100] blkind = utils.model_builder.getIndicesSphere(xc, radius, mesh.gridCC) sigmaInf = np.ones(mesh.nC) * 1e-2 eta = np.zeros(mesh.nC) eta[blkind] = 0.1 sigma0 = sigmaInf * (1.0 - eta) rx = dc.receivers.Dipole(M, N) src = dc.sources.Dipole([rx], Aloc, Bloc) survey_dc = dc.survey.Survey([src]) rx_ip = dc.receivers.Dipole(M, N, data_type="apparent_chargeability") src_ip = dc.sources.Dipole([rx_ip], Aloc, Bloc) survey_ip = ip.Survey([src_ip]) self.survey_dc = survey_dc self.survey_ip = survey_ip self.mesh = mesh self.sigmaInf = sigmaInf self.sigma0 = sigma0 self.src = src self.eta = eta