def setUp(self): aSpacing=2.5 nElecs=5 surveySize = nElecs*aSpacing - aSpacing cs = surveySize/nElecs/4 mesh = Mesh.TensorMesh([ [(cs,10, -1.3),(cs,surveySize/cs),(cs,10, 1.3)], [(cs,3, -1.3),(cs,3,1.3)], # [(cs,5, -1.3),(cs,10)] ],'CN') srcList = DC.Utils.WennerSrcList(nElecs, aSpacing, in2D=True) survey = IP.Survey(srcList) sigma = np.ones(mesh.nC) problem = IP.Problem3D_N(mesh, sigma=sigma) 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
def test_Problem3D_N(self): problemDC = DC.Problem3D_N(self.mesh) problemDC.Solver = self.Solver problemDC.pair(self.surveyDC) data0 = self.surveyDC.dpred(self.sigma0) finf = problemDC.fields(self.sigmaInf) datainf = self.surveyDC.dpred(self.sigmaInf, f=finf) problemIP = IP.Problem3D_N(self.mesh, sigma=self.sigmaInf, Ainv=problemDC.Ainv, f=finf) problemIP.Solver = self.Solver surveyIP = IP.Survey([self.src]) 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 Problem3D_N is passed" else: passed = False print ">> IP forward test for Problem3D_N is failed" self.assertTrue(passed)