Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
    def test_Simulation2DNodal(self):

        simDC = dc.Simulation2DNodal(
            self.mesh,
            sigmaMap=maps.IdentityMap(self.mesh),
            solver=Solver,
            survey=self.survey_dc,
        )
        data0 = simDC.dpred(self.sigma0)
        datainf = simDC.dpred(self.sigmaInf)
        data_full = (data0 - datainf) / datainf

        simIP = ip.Simulation2DNodal(
            self.mesh,
            sigma=self.sigmaInf,
            etaMap=maps.IdentityMap(self.mesh),
            solver=Solver,
            survey=self.survey_ip,
        )
        data = simIP.dpred(self.eta)

        simIP_store = ip.Simulation2DNodal(
            self.mesh,
            sigma=self.sigmaInf,
            etaMap=maps.IdentityMap(self.mesh),
            solver=Solver,
            survey=self.survey_ip,
            storeJ=True,
        )
        data2 = simIP_store.dpred(self.eta)

        np.testing.assert_allclose(data, data2)

        np.testing.assert_allclose(simIP._scale, simIP._sign / datainf)

        err = np.linalg.norm(
            (data - data_full) / data_full)**2 / data_full.size
        if err > 0.05:
            import matplotlib.pyplot as plt

            plt.plot(data_full)
            plt.plot(data, "k.")
            plt.show()

        self.assertLess(err, 0.05)
Exemplo n.º 3
0
    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.Simulation2DNodal(
            mesh,
            survey=survey,
            rho=1.0 / 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