def test_Simulation2DCellCentered(self): simDC = dc.Simulation2DCellCentered( 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.Simulation2DCellCentered( self.mesh, sigma=self.sigmaInf, etaMap=maps.IdentityMap(self.mesh), solver=Solver, survey=self.survey_ip, ) data = simIP.dpred(self.eta) 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)
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)