示例#1
0
    def test_Problem2D_CC(self):

        problemDC = DC.Problem2D_CC(self.mesh,
                                    rhoMap=Maps.IdentityMap(self.mesh))
        problemDC.Solver = Solver
        problemDC.pair(self.surveyDC)
        data0 = self.surveyDC.dpred(1. / self.sigma0)
        finf = problemDC.fields(1. / self.sigmaInf)
        datainf = self.surveyDC.dpred(1. / self.sigmaInf, f=finf)
        problemIP = IP.Problem2D_CC(self.mesh,
                                    rho=1. / self.sigmaInf,
                                    etaMap=Maps.IdentityMap(self.mesh))
        problemIP.Solver = Solver
        surveyIP = IP.Survey(self.srcLists_ip)
        problemIP.pair(surveyIP)
        data_full = data0 - datainf
        data = surveyIP.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 Problem2D_CC is passed")
        else:
            import matplotlib.pyplot as plt
            passed = False
            print(">> IP forward test for Problem2D_CC is failed")
            print(err)
            plt.plot(data_full)
            plt.plot(data, 'k.')
            plt.show()

        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 = Mesh.TensorMesh([hx, hy], x0="CN")

        # x = np.linspace(-200, 200., 20)
        x = np.linspace(-200, 200., 2)
        M = Utils.ndgrid(x - 12.5, np.r_[0.])
        N = Utils.ndgrid(x + 12.5, np.r_[0.])

        A0loc = np.r_[-150, 0.]
        A1loc = np.r_[-130, 0.]
        B0loc = np.r_[-130, 0.]
        B1loc = np.r_[-110, 0.]

        rx = DC.Rx.Dipole_ky(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.
        problem = IP.Problem2D_CC(mesh,
                                  sigma=sigma,
                                  etaMap=Maps.IdentityMap(mesh),
                                  verbose=False)
        problem.pair(survey)

        mSynth = np.ones(mesh.nC) * 0.1
        survey.makeSyntheticData(mSynth)
        # Now set up the problem to do some minimization
        dmis = DataMisfit.l2_DataMisfit(survey)
        reg = Regularization.Tikhonov(mesh)
        opt = Optimization.InexactGaussNewton(maxIterLS=20,
                                              maxIter=10,
                                              tolF=1e-6,
                                              tolX=1e-6,
                                              tolG=1e-6,
                                              maxIterCG=6)
        invProb = InvProblem.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