def test_SphericalTransformation2D(self): dom=Rectangle(NE,NE, l0=45., l1=10.) cs=SphericalReferenceSystem() tf=cs.createTransformation(dom) self.assertEqual(tf.getReferenceSystem(),cs , "wrong reference") self.assertEqual(tf.getDomain(),dom , "wrong reference") self.assertFalse(tf.isCartesian(), "wrong isCartesian check") R=6378137.0 x=esys.escript.Function(dom).getX() phi=(90.-x[0])/180.*pi h=x[1]*1000. r=h+R v=tf.getVolumeFactor() self.assertTrue(isinstance(v, esys.escript.Data), "wrong volume factor type") self.assertEqual(v.getFunctionSpace(), esys.escript.Function(dom), "wrong volume factor type") error=Lsup(v-r*pi/180.*1000.) self.assertTrue(error<=RTOL*R, "volume factor") s=tf.getScalingFactors() self.assertTrue(isinstance(s, esys.escript.Data), "scaling factor type") self.assertEqual(s.getShape(), (dom.getDim(),), "scaling factor length") self.assertEqual(s.getFunctionSpace(), esys.escript.Function(dom), "wrong 0-th scaling factor type") error=Lsup(s[0]-1./r/pi*180.) self.assertTrue(error<=RTOL/R/pi*180., "0-th scaling factor") error=Lsup(s[1]-1./1000) self.assertTrue(error<=RTOL/1000., "1-th scaling factor")
def test_CartesianTransformation2D(self): dom=Rectangle(NE,NE, l0=10, l1=10) cs=CartesianReferenceSystem() tf=cs.createTransformation(dom) self.assertEqual(tf.getReferenceSystem(),cs , "wrong reference") self.assertEqual(tf.getDomain(),dom , "wrong reference") self.assertTrue(tf.isCartesian(), "wrong isCartesian check") v=tf.getVolumeFactor() self.assertTrue(isinstance(v, esys.escript.Data), "wrong volume factor type") self.assertEqual(v.getFunctionSpace(), esys.escript.Function(dom), "wrong volume factor type") error=Lsup(v-1.) self.assertTrue(error<=RTOL, "volume factor") s=tf.getScalingFactors() self.assertTrue(isinstance(s, esys.escript.Data), "scaling factor type") self.assertEqual(s.getShape(), (dom.getDim(),), "scaling factor length") self.assertEqual(s.getFunctionSpace(), esys.escript.Function(dom), "wrong 0-th scaling factor type") error=Lsup(s[0]-1.) self.assertTrue(error<=RTOL, "0-th scaling factor") error=Lsup(s[1]-1.) self.assertTrue(error<=RTOL, "1-th scaling factor")
print("Width [m] = ",WIDTH) print("Depth [m] = ", DEPTH) print("Mesh size [m] = ", WIDTH/NEX) print("Number of cells in x direction = ", NEX) print("Number of cells in z direction = ", NEZ) print("Air layer [m] = ", L_AIR) print("periods [s] = ", PERIODS) #============================================== print("generating mesh ...") domain=Rectangle(NEX,NEZ,l0=WIDTH,l1=DEPTH) print("generating conductivity ...") # you can replace this by an interpolation table read from a CSV file. z=ReducedFunction(domain).getX()[domain.getDim()-1] sigma=Scalar(SIGMA0, z.getFunctionSpace()) rho=Scalar(1./SIGMA0, z.getFunctionSpace()) z_top=sup(domain.getX()[domain.getDim()-1]) m_top=0. for l, s in zip(LAYERS, SIGMA ): m2=wherePositive(z-z_top+l) m=m2-m_top sigma=(1-m)*sigma+m*s if s > 0: rho=(1-m)*rho+m*1./s else: rho=(1-m)*rho+m*0. # arbitray number as air_layer is backed out in TM mode. z_top, m_top=z_top-l, m2