def test_sum(self): M2 = discretize.TensorMesh([np.ones(10), np.ones(20)], "CC") block = maps.ParametricEllipsoid(M2) * maps.Projection( 7, np.r_[1, 2, 3, 4, 5, 6]) background = (maps.ExpMap(M2) * maps.SurjectFull(M2) * maps.Projection(7, np.r_[0])) summap0 = maps.SumMap([block, background]) summap1 = block + background m0 = np.hstack([ np.random.rand(3), np.r_[M2.x0[0], 2 * M2.hx.min()], np.r_[M2.x0[1], 4 * M2.hy.min()], ]) self.assertTrue(np.all(summap0 * m0 == summap1 * m0)) self.assertTrue(summap0.test(m0)) self.assertTrue(summap1.test(m0))
def test_Projection(self): nP = 10 m = np.arange(nP) self.assertTrue(np.all(maps.Projection(nP, slice(5)) * m == m[:5])) self.assertTrue( np.all(maps.Projection(nP, slice(5, None)) * m == m[5:])) self.assertTrue( np.all( maps.Projection(nP, np.r_[1, 5, 3, 2, 9, 9]) * m == np.r_[1, 5, 3, 2, 9, 9])) self.assertTrue( np.all( maps.Projection(nP, [1, 5, 3, 2, 9, 9]) * m == np.r_[1, 5, 3, 2, 9, 9])) with self.assertRaises(AssertionError): maps.Projection(nP, np.r_[10]) * m mapping = maps.Projection(nP, np.r_[1, 2, 6, 1, 3, 5, 4, 9, 9, 8, 0]) mapping.test()
csx, ncx, npadx = 25.0, 16, 10 csz, ncz, npadz = 25.0, 8, 10 pf = 1.5 # primary mesh hx = [(csx, ncx), (csx, npadx, pf)] hz = [(csz, npadz, -pf), (csz, ncz), (csz, npadz, pf)] meshp = discretize.CylMesh([hx, 1.0, hz], x0="0CC") # secondary mesh h = [(csz, npadz - 4, -pf), (csz, ncz), (csz, npadz - 4, pf)] meshs = discretize.TensorMesh(3 * [h], x0="CCC") # mappings primaryMapping = (maps.ExpMap(meshp) * maps.SurjectFull(meshp) * maps.Projection(nP=8, index=[0])) mapping = ( maps.ExpMap(meshs) * maps.ParametricBlockInLayer(meshs) * maps.Projection(nP=8, index=np.hstack([np.r_[0], np.arange(0, 8)]))) primaryMap2Meshs = (maps.ExpMap(meshs) * maps.SurjectFull(meshs) * maps.Projection(nP=8, index=[0])) class PrimSecFDEMTest(object): # --------------------- Run some tests! --------------------- # def DataTest(self): print("\nTesting Data") dpred_primsec = self.secondarySimulation.dpred(model,