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 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)