/[escript]/trunk/finley/test/python/run_models.py
ViewVC logotype

Diff of /trunk/finley/test/python/run_models.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3528 by gross, Tue May 24 07:02:08 2011 UTC revision 3981 by jfenwick, Fri Sep 21 02:47:54 2012 UTC
# Line 1  Line 1 
1  # -*- coding: utf-8 -*-  # -*- coding: utf-8 -*-
2    
3  ########################################################  ##############################################################################
4  #  #
5  # Copyright (c) 2003-2010 by University of Queensland  # Copyright (c) 2003-2012 by University of Queensland
6  # Earth Systems Science Computational Center (ESSCC)  # http://www.uq.edu.au
 # http://www.uq.edu.au/esscc  
7  #  #
8  # Primary Business: Queensland, Australia  # Primary Business: Queensland, Australia
9  # Licensed under the Open Software License version 3.0  # Licensed under the Open Software License version 3.0
10  # http://www.opensource.org/licenses/osl-3.0.php  # http://www.opensource.org/licenses/osl-3.0.php
11  #  #
12  ########################################################  # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
13    # Development since 2012 by School of Earth Sciences
14    #
15    ##############################################################################
16    
17  __copyright__="""Copyright (c) 2003-2010 by University of Queensland  __copyright__="""Copyright (c) 2003-2012 by University of Queensland
18  Earth Systems Science Computational Center (ESSCC)  http://www.uq.edu.au
 http://www.uq.edu.au/esscc  
19  Primary Business: Queensland, Australia"""  Primary Business: Queensland, Australia"""
20  __license__="""Licensed under the Open Software License version 3.0  __license__="""Licensed under the Open Software License version 3.0
21  http://www.opensource.org/licenses/osl-3.0.php"""  http://www.opensource.org/licenses/osl-3.0.php"""
# Line 47  class Test_StokesProblemCartesian2D(unit Line 48  class Test_StokesProblemCartesian2D(unit
48     def setUp(self):     def setUp(self):
49         NE=6         NE=6
50         self.TOL=1e-3         self.TOL=1e-3
51         self.domain=Rectangle(NE,NE,order=-1)         self.domain=Rectangle(NE,NE,order=-1,useElementsOnFace=0)
52     def tearDown(self):     def tearDown(self):
53         del self.domain         del self.domain
54     def test_PCG_P_0(self):     def test_PCG_P_0(self):
# Line 72  class Test_StokesProblemCartesian2D(unit Line 73  class Test_StokesProblemCartesian2D(unit
73         error_v0=Lsup(u[0]-u0[0])         error_v0=Lsup(u[0]-u0[0])
74         error_v1=Lsup(u[1]-u0[1])/0.25         error_v1=Lsup(u[1]-u0[1])/0.25
75         error_p=Lsup(p+P1*x[0]*x[1])         error_p=Lsup(p+P1*x[0]*x[1])
76         self.failUnless(error_p<10*self.TOL, "pressure error too large.")         self.assertTrue(error_p<10*self.TOL, "pressure error too large.")
77         self.failUnless(error_v0<10*self.TOL, "0-velocity error too large.")         self.assertTrue(error_v0<10*self.TOL, "0-velocity error too large.")
78         self.failUnless(error_v1<10*self.TOL, "1-velocity error too large.")         self.assertTrue(error_v1<10*self.TOL, "1-velocity error too large.")
79    
80     def test_PCG_P_small(self):     def test_PCG_P_small(self):
81         ETA=1.         ETA=1.
# Line 97  class Test_StokesProblemCartesian2D(unit Line 98  class Test_StokesProblemCartesian2D(unit
98         error_v0=Lsup(u[0]-u0[0])         error_v0=Lsup(u[0]-u0[0])
99         error_v1=Lsup(u[1]-u0[1])/0.25         error_v1=Lsup(u[1]-u0[1])/0.25
100         error_p=Lsup(P1*x[0]*x[1]+p)         error_p=Lsup(P1*x[0]*x[1]+p)
101         self.failUnless(error_v0<10*self.TOL, "0-velocity error too large.")         self.assertTrue(error_v0<10*self.TOL, "0-velocity error too large.")
102         self.failUnless(error_v1<10*self.TOL, "1-velocity error too large.")         self.assertTrue(error_v1<10*self.TOL, "1-velocity error too large.")
103         self.failUnless(error_p<10*self.TOL, "pressure error too large.")         self.assertTrue(error_p<10*self.TOL, "pressure error too large.")
104    
105     def test_PCG_P_large(self):     def test_PCG_P_large(self):
106         ETA=1.         ETA=1.
# Line 124  class Test_StokesProblemCartesian2D(unit Line 125  class Test_StokesProblemCartesian2D(unit
125         error_v0=Lsup(u[0]-u0[0])         error_v0=Lsup(u[0]-u0[0])
126         error_v1=Lsup(u[1]-u0[1])/0.25         error_v1=Lsup(u[1]-u0[1])/0.25
127         error_p=Lsup(P1*x[0]*x[1]+p)/P1         error_p=Lsup(P1*x[0]*x[1]+p)/P1
128         self.failUnless(error_p<10*self.TOL, "pressure error too large.")         self.assertTrue(error_p<10*self.TOL, "pressure error too large.")
129         self.failUnless(error_v0<10*self.TOL, "0-velocity error too large.")         self.assertTrue(error_v0<10*self.TOL, "0-velocity error too large.")
130         self.failUnless(error_v1<10*self.TOL, "1-velocity error too large.")         self.assertTrue(error_v1<10*self.TOL, "1-velocity error too large.")
131    
132     def test_GMRES_P_0(self):     def test_GMRES_P_0(self):
133         ETA=1.         ETA=1.
# Line 150  class Test_StokesProblemCartesian2D(unit Line 151  class Test_StokesProblemCartesian2D(unit
151         error_v0=Lsup(u[0]-u0[0])         error_v0=Lsup(u[0]-u0[0])
152         error_v1=Lsup(u[1]-u0[1])/0.25         error_v1=Lsup(u[1]-u0[1])/0.25
153         error_p=Lsup(P1*x[0]*x[1]+p)         error_p=Lsup(P1*x[0]*x[1]+p)
154         self.failUnless(error_p<10*self.TOL, "pressure error too large.")         self.assertTrue(error_p<10*self.TOL, "pressure error too large.")
155         self.failUnless(error_v0<10*self.TOL, "0-velocity error too large.")         self.assertTrue(error_v0<10*self.TOL, "0-velocity error too large.")
156         self.failUnless(error_v1<10*self.TOL, "1-velocity error too large.")         self.assertTrue(error_v1<10*self.TOL, "1-velocity error too large.")
157    
158     def test_GMRES_P_small(self):     def test_GMRES_P_small(self):
159         ETA=1.         ETA=1.
# Line 177  class Test_StokesProblemCartesian2D(unit Line 178  class Test_StokesProblemCartesian2D(unit
178         error_v1=Lsup(u[1]-u0[1])/0.25         error_v1=Lsup(u[1]-u0[1])/0.25
179         error_p=Lsup(P1*x[0]*x[1]+p)         error_p=Lsup(P1*x[0]*x[1]+p)
180    
181         self.failUnless(error_p<10*self.TOL, "pressure error too large.")         self.assertTrue(error_p<10*self.TOL, "pressure error too large.")
182         self.failUnless(error_v0<10*self.TOL, "0-velocity error too large.")         self.assertTrue(error_v0<10*self.TOL, "0-velocity error too large.")
183         self.failUnless(error_v1<10*self.TOL, "1-velocity error too large.")         self.assertTrue(error_v1<10*self.TOL, "1-velocity error too large.")
184    
185     def test_GMRES_P_large(self):     def test_GMRES_P_large(self):
186         ETA=1.         ETA=1.
# Line 203  class Test_StokesProblemCartesian2D(unit Line 204  class Test_StokesProblemCartesian2D(unit
204         error_v0=Lsup(u[0]-u0[0])         error_v0=Lsup(u[0]-u0[0])
205         error_v1=Lsup(u[1]-u0[1])/0.25         error_v1=Lsup(u[1]-u0[1])/0.25
206         error_p=Lsup(P1*x[0]*x[1]+p)/P1         error_p=Lsup(P1*x[0]*x[1]+p)/P1
207         self.failUnless(error_p<10*self.TOL, "pressure error too large.")         self.assertTrue(error_p<10*self.TOL, "pressure error too large.")
208         self.failUnless(error_v0<10*self.TOL, "0-velocity error too large.")         self.assertTrue(error_v0<10*self.TOL, "0-velocity error too large.")
209         self.failUnless(error_v1<10*self.TOL, "1-velocity error too large.")         self.assertTrue(error_v1<10*self.TOL, "1-velocity error too large.")
210  #====================================================================================================================  #====================================================================================================================
211  class Test_StokesProblemCartesian3D(unittest.TestCase):  class Test_StokesProblemCartesian3D(unittest.TestCase):
212     def setUp(self):     def setUp(self):
213         NE=6         NE=6
214         self.TOL=1e-4         self.TOL=1e-4
215         self.domain=Brick(NE,NE,NE,order=-1)         self.domain=Brick(NE,NE,NE,order=-1,useElementsOnFace=0)
216     def tearDown(self):     def tearDown(self):
217         del self.domain         del self.domain
218     def test_PCG_P_0(self):     def test_PCG_P_0(self):
# Line 241  class Test_StokesProblemCartesian3D(unit Line 242  class Test_StokesProblemCartesian3D(unit
242         error_v1=Lsup(u[1]-u0[1])         error_v1=Lsup(u[1]-u0[1])
243         error_v2=Lsup(u[2]-u0[2])/0.25**2         error_v2=Lsup(u[2]-u0[2])/0.25**2
244         error_p=Lsup(P1*x[0]*x[1]*x[2]+p)         error_p=Lsup(P1*x[0]*x[1]*x[2]+p)
245         self.failUnless(error_p<10*self.TOL, "pressure error too large.")         self.assertTrue(error_p<10*self.TOL, "pressure error too large.")
246         self.failUnless(error_v0<10*self.TOL, "0-velocity error too large.")         self.assertTrue(error_v0<10*self.TOL, "0-velocity error too large.")
247         self.failUnless(error_v1<10*self.TOL, "1-velocity error too large.")         self.assertTrue(error_v1<10*self.TOL, "1-velocity error too large.")
248         self.failUnless(error_v2<10*self.TOL, "2-velocity error too large.")         self.assertTrue(error_v2<10*self.TOL, "2-velocity error too large.")
249    
250     def test_PCG_P_small(self):     def test_PCG_P_small(self):
251         ETA=1.         ETA=1.
# Line 271  class Test_StokesProblemCartesian3D(unit Line 272  class Test_StokesProblemCartesian3D(unit
272         error_v1=Lsup(u[1]-u0[1])         error_v1=Lsup(u[1]-u0[1])
273         error_v2=Lsup(u[2]-u0[2])/0.25**2         error_v2=Lsup(u[2]-u0[2])/0.25**2
274         error_p=Lsup(P1*x[0]*x[1]*x[2]+p)         error_p=Lsup(P1*x[0]*x[1]*x[2]+p)
275         self.failUnless(error_p<10*self.TOL, "pressure error too large.")         self.assertTrue(error_p<10*self.TOL, "pressure error too large.")
276         self.failUnless(error_v0<10*self.TOL, "0-velocity error too large.")         self.assertTrue(error_v0<10*self.TOL, "0-velocity error too large.")
277         self.failUnless(error_v1<10*self.TOL, "1-velocity error too large.")         self.assertTrue(error_v1<10*self.TOL, "1-velocity error too large.")
278         self.failUnless(error_v2<10*self.TOL, "2-velocity error too large.")         self.assertTrue(error_v2<10*self.TOL, "2-velocity error too large.")
279    
280     def test_PCG_P_large(self):     def test_PCG_P_large(self):
281         ETA=1.         ETA=1.
# Line 302  class Test_StokesProblemCartesian3D(unit Line 303  class Test_StokesProblemCartesian3D(unit
303         error_v1=Lsup(u[1]-u0[1])         error_v1=Lsup(u[1]-u0[1])
304         error_v2=Lsup(u[2]-u0[2])/0.25**2         error_v2=Lsup(u[2]-u0[2])/0.25**2
305         error_p=Lsup(P1*x[0]*x[1]*x[2]+p)/P1         error_p=Lsup(P1*x[0]*x[1]*x[2]+p)/P1
306         self.failUnless(error_p<10*self.TOL, "pressure error too large.")         self.assertTrue(error_p<10*self.TOL, "pressure error too large.")
307         self.failUnless(error_v0<10*self.TOL, "0-velocity error too large.")         self.assertTrue(error_v0<10*self.TOL, "0-velocity error too large.")
308         self.failUnless(error_v1<10*self.TOL, "1-velocity error too large.")         self.assertTrue(error_v1<10*self.TOL, "1-velocity error too large.")
309         self.failUnless(error_v2<10*self.TOL, "2-velocity error too large.")         self.assertTrue(error_v2<10*self.TOL, "2-velocity error too large.")
310    
311     def test_GMRES_P_0(self):     def test_GMRES_P_0(self):
312         ETA=1.         ETA=1.
# Line 334  class Test_StokesProblemCartesian3D(unit Line 335  class Test_StokesProblemCartesian3D(unit
335         error_v1=Lsup(u[1]-u0[1])         error_v1=Lsup(u[1]-u0[1])
336         error_v2=Lsup(u[2]-u0[2])/0.25**2         error_v2=Lsup(u[2]-u0[2])/0.25**2
337         error_p=Lsup(P1*x[0]*x[1]*x[2]+p)         error_p=Lsup(P1*x[0]*x[1]*x[2]+p)
338         self.failUnless(error_p<10*self.TOL, "pressure error too large.")         self.assertTrue(error_p<10*self.TOL, "pressure error too large.")
339         self.failUnless(error_v0<10*self.TOL, "0-velocity error too large.")         self.assertTrue(error_v0<10*self.TOL, "0-velocity error too large.")
340         self.failUnless(error_v1<10*self.TOL, "1-velocity error too large.")         self.assertTrue(error_v1<10*self.TOL, "1-velocity error too large.")
341         self.failUnless(error_v2<10*self.TOL, "2-velocity error too large.")         self.assertTrue(error_v2<10*self.TOL, "2-velocity error too large.")
342     def test_GMRES_P_small(self):     def test_GMRES_P_small(self):
343         ETA=1.         ETA=1.
344         P1=1.         P1=1.
# Line 364  class Test_StokesProblemCartesian3D(unit Line 365  class Test_StokesProblemCartesian3D(unit
365         error_v1=Lsup(u[1]-u0[1])         error_v1=Lsup(u[1]-u0[1])
366         error_v2=Lsup(u[2]-u0[2])/0.25**2         error_v2=Lsup(u[2]-u0[2])/0.25**2
367         error_p=Lsup(P1*x[0]*x[1]*x[2]+p)/P1         error_p=Lsup(P1*x[0]*x[1]*x[2]+p)/P1
368         self.failUnless(error_v0<10*self.TOL, "0-velocity error too large.")         self.assertTrue(error_v0<10*self.TOL, "0-velocity error too large.")
369         self.failUnless(error_v1<10*self.TOL, "1-velocity error too large.")         self.assertTrue(error_v1<10*self.TOL, "1-velocity error too large.")
370         self.failUnless(error_v2<10*self.TOL, "2-velocity error too large.")         self.assertTrue(error_v2<10*self.TOL, "2-velocity error too large.")
371         self.failUnless(error_p<10*self.TOL, "pressure error too large.")         self.assertTrue(error_p<10*self.TOL, "pressure error too large.")
372     def test_GMRES_P_large(self):     def test_GMRES_P_large(self):
373         ETA=1.         ETA=1.
374         P1=1000.         P1=1000.
# Line 394  class Test_StokesProblemCartesian3D(unit Line 395  class Test_StokesProblemCartesian3D(unit
395         error_v1=Lsup(u[1]-u0[1])         error_v1=Lsup(u[1]-u0[1])
396         error_v2=Lsup(u[2]-u0[2])/0.25**2         error_v2=Lsup(u[2]-u0[2])/0.25**2
397         error_p=Lsup(P1*x[0]*x[1]*x[2]+p)/P1         error_p=Lsup(P1*x[0]*x[1]*x[2]+p)/P1
398         self.failUnless(error_p<10*self.TOL, "pressure error too large.")         self.assertTrue(error_p<10*self.TOL, "pressure error too large.")
399         self.failUnless(error_v0<10*self.TOL, "0-velocity error too large.")         self.assertTrue(error_v0<10*self.TOL, "0-velocity error too large.")
400         self.failUnless(error_v1<10*self.TOL, "1-velocity error too large.")         self.assertTrue(error_v1<10*self.TOL, "1-velocity error too large.")
401         self.failUnless(error_v2<10*self.TOL, "2-velocity error too large.")         self.assertTrue(error_v2<10*self.TOL, "2-velocity error too large.")
402  #====================================================================================================================  #====================================================================================================================
403    
404  class Test_Mountains3D(unittest.TestCase):  class Test_Mountains3D(unittest.TestCase):
# Line 427  class Test_Mountains3D(unittest.TestCase Line 428  class Test_Mountains3D(unittest.TestCase
428         Z=mts.update()         Z=mts.update()
429                
430         error_int=abs(integrate(Z*whereZero(FunctionOnBoundary(self.domain).getX()[2]-1.)))         error_int=abs(integrate(Z*whereZero(FunctionOnBoundary(self.domain).getX()[2]-1.)))
431         self.failUnless(error_int<self.TOL, "Boundary intergral is too large.")         self.assertTrue(error_int<self.TOL, "Boundary intergral is too large.")
432    
433  class Test_Mountains2D(unittest.TestCase):  class Test_Mountains2D(unittest.TestCase):
434     def setUp(self):     def setUp(self):
# Line 454  class Test_Mountains2D(unittest.TestCase Line 455  class Test_Mountains2D(unittest.TestCase
455         Z=mts.update()         Z=mts.update()
456                
457         error_int=abs(integrate(Z*whereZero(FunctionOnBoundary(self.domain).getX()[1]-1.)))         error_int=abs(integrate(Z*whereZero(FunctionOnBoundary(self.domain).getX()[1]-1.)))
458         self.failUnless(error_int<self.TOL, "Boundary intergral is too large.")         self.assertTrue(error_int<self.TOL, "Boundary intergral is too large.")
459                
460    
461    
# Line 482  class Test_Rheologies(unittest.TestCase) Line 483  class Test_Rheologies(unittest.TestCase)
483       def test_PowerLaw_Init(self):       def test_PowerLaw_Init(self):
484           pl=PowerLaw(numMaterials=3,verbose=VERBOSE)           pl=PowerLaw(numMaterials=3,verbose=VERBOSE)
485    
486           self.failUnlessEqual(pl.getNumMaterials(),3,"num materials is wrong")           self.assertEqual(pl.getNumMaterials(),3,"num materials is wrong")
487           self.failUnlessEqual(pl.validMaterialId(0),True,"material id 0 not found")           self.assertEqual(pl.validMaterialId(0),True,"material id 0 not found")
488           self.failUnlessEqual(pl.validMaterialId(1),True,"material id 1 not found")           self.assertEqual(pl.validMaterialId(1),True,"material id 1 not found")
489           self.failUnlessEqual(pl.validMaterialId(2),True,"material id 2 not found")           self.assertEqual(pl.validMaterialId(2),True,"material id 2 not found")
490           self.failUnlessEqual(pl.validMaterialId(3),False,"material id 3 not found")           self.assertEqual(pl.validMaterialId(3),False,"material id 3 not found")
491    
492           self.failUnlessEqual(pl.getFriction(),None,"initial friction wrong.")           self.assertEqual(pl.getFriction(),None,"initial friction wrong.")
493           self.failUnlessEqual(pl.getTauY(),None,"initial tau y wrong.")           self.assertEqual(pl.getTauY(),None,"initial tau y wrong.")
494           pl.setDruckerPragerLaw(tau_Y=10,friction=3)           pl.setDruckerPragerLaw(tau_Y=10,friction=3)
495           self.failUnlessEqual(pl.getFriction(),3,"friction wrong.")           self.assertEqual(pl.getFriction(),3,"friction wrong.")
496           self.failUnlessEqual(pl.getTauY(),10,"tau y wrong.")           self.assertEqual(pl.getTauY(),10,"tau y wrong.")
497    
498           self.failUnlessEqual(pl.getElasticShearModulus(),None,"initial shear modulus is wrong")           self.assertEqual(pl.getElasticShearModulus(),None,"initial shear modulus is wrong")
499           pl.setElasticShearModulus(1000)           pl.setElasticShearModulus(1000)
500           self.failUnlessEqual(pl.getElasticShearModulus(),1000.,"shear modulus is wrong")           self.assertEqual(pl.getElasticShearModulus(),1000.,"shear modulus is wrong")
501    
502           e=pl.getEtaN()           e=pl.getEtaN()
503           self.failUnlessEqual(len(e),3,"initial length of etaN is wrong.")           self.assertEqual(len(e),3,"initial length of etaN is wrong.")
504           self.failUnlessEqual(e,[None, None, None],"initial etaN are wrong.")           self.assertEqual(e,[None, None, None],"initial etaN are wrong.")
505           self.failUnlessEqual(pl.getEtaN(0),None,"initial material id 0 is wrong")           self.assertEqual(pl.getEtaN(0),None,"initial material id 0 is wrong")
506           self.failUnlessEqual(pl.getEtaN(1),None,"initial material id 1 is wrong")           self.assertEqual(pl.getEtaN(1),None,"initial material id 1 is wrong")
507           self.failUnlessEqual(pl.getEtaN(2),None,"initial material id 2 is wrong")           self.assertEqual(pl.getEtaN(2),None,"initial material id 2 is wrong")
508           self.failUnlessRaises(ValueError, pl.getEtaN, 3)           self.assertRaises(ValueError, pl.getEtaN, 3)
509    
510           self.failUnlessRaises(ValueError,pl.setPowerLaws,eta_N=[10,20,30,40],tau_t=[2], power=[5,6,7])           self.assertRaises(ValueError,pl.setPowerLaws,eta_N=[10,20,30,40],tau_t=[2], power=[5,6,7])
511           self.failUnlessRaises(ValueError,pl.setPowerLaws,eta_N=[10,20,30],tau_t=[2,4,5,5], power=[5,6,7])           self.assertRaises(ValueError,pl.setPowerLaws,eta_N=[10,20,30],tau_t=[2,4,5,5], power=[5,6,7])
512           self.failUnlessRaises(ValueError,pl.setPowerLaws,eta_N=[10,20,30],tau_t=[2,1,2], power=[5,6,7,7])           self.assertRaises(ValueError,pl.setPowerLaws,eta_N=[10,20,30],tau_t=[2,1,2], power=[5,6,7,7])
513    
514           pl.setPowerLaws(eta_N=[10,20,30],tau_t=[100,200,300], power=[1,2,3])           pl.setPowerLaws(eta_N=[10,20,30],tau_t=[100,200,300], power=[1,2,3])
515           self.failUnlessEqual(pl.getPower(),[1,2,3],"powers are wrong.")           self.assertEqual(pl.getPower(),[1,2,3],"powers are wrong.")
516           self.failUnlessEqual(pl.getTauT(),[100,200,300],"tau t are wrong.")           self.assertEqual(pl.getTauT(),[100,200,300],"tau t are wrong.")
517           self.failUnlessEqual(pl.getEtaN(),[10,20,30],"etaN are wrong.")           self.assertEqual(pl.getEtaN(),[10,20,30],"etaN are wrong.")
518    
519           pl.setPowerLaw(id=0,eta_N=40,tau_t=400, power=4)           pl.setPowerLaw(id=0,eta_N=40,tau_t=400, power=4)
520           self.failUnlessEqual(pl.getPower(),[4,2,3],"powers are wrong.")           self.assertEqual(pl.getPower(),[4,2,3],"powers are wrong.")
521           self.failUnlessEqual(pl.getTauT(),[400,200,300],"tau t are wrong.")           self.assertEqual(pl.getTauT(),[400,200,300],"tau t are wrong.")
522           self.failUnlessEqual(pl.getEtaN(),[40,20,30],"etaN are wrong.")           self.assertEqual(pl.getEtaN(),[40,20,30],"etaN are wrong.")
523    
524           self.failUnlessRaises(ValueError,pl.getPower,-1)           self.assertRaises(ValueError,pl.getPower,-1)
525           self.failUnlessEqual(pl.getPower(0),4,"power 0 is wrong.")           self.assertEqual(pl.getPower(0),4,"power 0 is wrong.")
526           self.failUnlessEqual(pl.getPower(1),2,"power 1 is wrong.")           self.assertEqual(pl.getPower(1),2,"power 1 is wrong.")
527           self.failUnlessEqual(pl.getPower(2),3,"power 2 is wrong.")           self.assertEqual(pl.getPower(2),3,"power 2 is wrong.")
528           self.failUnlessRaises(ValueError,pl.getPower,3)           self.assertRaises(ValueError,pl.getPower,3)
529    
530           self.failUnlessRaises(ValueError,pl.getTauT,-1)           self.assertRaises(ValueError,pl.getTauT,-1)
531           self.failUnlessEqual(pl.getTauT(0),400,"tau t 0 is wrong.")           self.assertEqual(pl.getTauT(0),400,"tau t 0 is wrong.")
532           self.failUnlessEqual(pl.getTauT(1),200,"tau t 1 is wrong.")           self.assertEqual(pl.getTauT(1),200,"tau t 1 is wrong.")
533           self.failUnlessEqual(pl.getTauT(2),300,"tau t 2 is wrong.")           self.assertEqual(pl.getTauT(2),300,"tau t 2 is wrong.")
534           self.failUnlessRaises(ValueError,pl.getTauT,3)           self.assertRaises(ValueError,pl.getTauT,3)
535    
536           self.failUnlessRaises(ValueError,pl.getEtaN,-1)           self.assertRaises(ValueError,pl.getEtaN,-1)
537           self.failUnlessEqual(pl.getEtaN(0),40,"eta n 0 is wrong.")           self.assertEqual(pl.getEtaN(0),40,"eta n 0 is wrong.")
538           self.failUnlessEqual(pl.getEtaN(1),20,"eta n 1 is wrong.")           self.assertEqual(pl.getEtaN(1),20,"eta n 1 is wrong.")
539           self.failUnlessEqual(pl.getEtaN(2),30,"eta n 2 is wrong.")           self.assertEqual(pl.getEtaN(2),30,"eta n 2 is wrong.")
540           self.failUnlessRaises(ValueError,pl.getEtaN,3)           self.assertRaises(ValueError,pl.getEtaN,3)
541    
542       def checkResult(self,id,gamma_dot_, eta, tau_ref):       def checkResult(self,id,gamma_dot_, eta, tau_ref):
543           self.failUnless(eta>=0,"eta needs to be positive (test %s)"%id)           self.assertTrue(eta>=0,"eta needs to be positive (test %s)"%id)
544           error=abs(gamma_dot_*eta-tau_ref)           error=abs(gamma_dot_*eta-tau_ref)
545           self.failUnless(error<=self.TOL*tau_ref,"eta is wrong: error = gamma_dot_*eta-tau_ref = %s * %s - %s = %s (test %s)"%(gamma_dot_,eta,tau_ref,error,id))           self.assertTrue(error<=self.TOL*tau_ref,"eta is wrong: error = gamma_dot_*eta-tau_ref = %s * %s - %s = %s (test %s)"%(gamma_dot_,eta,tau_ref,error,id))
546                    
547       def test_PowerLaw_Linear(self):       def test_PowerLaw_Linear(self):
548           taus= [0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0]           taus= [0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0]
# Line 550  class Test_Rheologies(unittest.TestCase) Line 551  class Test_Rheologies(unittest.TestCase)
551           pl.setDruckerPragerLaw(tau_Y=100.)           pl.setDruckerPragerLaw(tau_Y=100.)
552           pl.setPowerLaw(eta_N=2.)           pl.setPowerLaw(eta_N=2.)
553           pl.setEtaTolerance(self.TOL)           pl.setEtaTolerance(self.TOL)
554           for i in xrange(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i]),taus[i])           for i in range(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i]),taus[i])
555                    
556       def test_PowerLaw_QuadLarge(self):       def test_PowerLaw_QuadLarge(self):
557           taus=[0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0]           taus=[0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0]
# Line 559  class Test_Rheologies(unittest.TestCase) Line 560  class Test_Rheologies(unittest.TestCase)
560           pl.setDruckerPragerLaw(tau_Y=100.)           pl.setDruckerPragerLaw(tau_Y=100.)
561           pl.setPowerLaws(eta_N=[2.,0.01],tau_t=[1, 25.], power=[1,2])           pl.setPowerLaws(eta_N=[2.,0.01],tau_t=[1, 25.], power=[1,2])
562           pl.setEtaTolerance(self.TOL)           pl.setEtaTolerance(self.TOL)
563           for i in xrange(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i]),taus[i])           for i in range(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i]),taus[i])
564    
565       def test_PowerLaw_QuadSmall(self):       def test_PowerLaw_QuadSmall(self):
566           taus=[0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0]           taus=[0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0]
# Line 568  class Test_Rheologies(unittest.TestCase) Line 569  class Test_Rheologies(unittest.TestCase)
569           pl.setDruckerPragerLaw(tau_Y=100.)           pl.setDruckerPragerLaw(tau_Y=100.)
570           pl.setPowerLaws(eta_N=[2.,10.],tau_t=[1, 25.], power=[1,2])           pl.setPowerLaws(eta_N=[2.,10.],tau_t=[1, 25.], power=[1,2])
571           pl.setEtaTolerance(self.TOL)           pl.setEtaTolerance(self.TOL)
572           for i in xrange(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i]),taus[i])           for i in range(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i]),taus[i])
573    
574       def test_PowerLaw_CubeLarge(self):       def test_PowerLaw_CubeLarge(self):
575           taus=[0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0]           taus=[0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0]
# Line 577  class Test_Rheologies(unittest.TestCase) Line 578  class Test_Rheologies(unittest.TestCase)
578           pl.setDruckerPragerLaw(tau_Y=100.)           pl.setDruckerPragerLaw(tau_Y=100.)
579           pl.setPowerLaws(eta_N=[2.,1./16.],tau_t=[1, 64.], power=[1,3])           pl.setPowerLaws(eta_N=[2.,1./16.],tau_t=[1, 64.], power=[1,3])
580           pl.setEtaTolerance(self.TOL)           pl.setEtaTolerance(self.TOL)
581           for i in xrange(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i]),taus[i])           for i in range(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i]),taus[i])
582    
583       def test_PowerLaw_CubeSmall(self):       def test_PowerLaw_CubeSmall(self):
584           taus=[0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0]           taus=[0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0]
# Line 586  class Test_Rheologies(unittest.TestCase) Line 587  class Test_Rheologies(unittest.TestCase)
587           pl.setDruckerPragerLaw(tau_Y=100.)           pl.setDruckerPragerLaw(tau_Y=100.)
588           pl.setPowerLaws(eta_N=[2.,25./4.],tau_t=[1, 64.], power=[1,3])           pl.setPowerLaws(eta_N=[2.,25./4.],tau_t=[1, 64.], power=[1,3])
589           pl.setEtaTolerance(self.TOL)           pl.setEtaTolerance(self.TOL)
590           for i in xrange(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i]),taus[i])           for i in range(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i]),taus[i])
591    
592       def test_PowerLaw_QuadLarge_CubeLarge(self):       def test_PowerLaw_QuadLarge_CubeLarge(self):
593           taus=[0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0]           taus=[0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0]
# Line 596  class Test_Rheologies(unittest.TestCase) Line 597  class Test_Rheologies(unittest.TestCase)
597           pl.setDruckerPragerLaw(tau_Y=100.)           pl.setDruckerPragerLaw(tau_Y=100.)
598           pl.setPowerLaws(eta_N=[2.,0.01,1./16.],tau_t=[1, 25.,64.], power=[1,2,3])           pl.setPowerLaws(eta_N=[2.,0.01,1./16.],tau_t=[1, 25.,64.], power=[1,2,3])
599           pl.setEtaTolerance(self.TOL)           pl.setEtaTolerance(self.TOL)
600           for i in xrange(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i]),taus[i])           for i in range(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i]),taus[i])
601    
602       def test_PowerLaw_QuadLarge_CubeSmall(self):       def test_PowerLaw_QuadLarge_CubeSmall(self):
603           taus=[0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0]           taus=[0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0]
# Line 606  class Test_Rheologies(unittest.TestCase) Line 607  class Test_Rheologies(unittest.TestCase)
607           pl.setDruckerPragerLaw(tau_Y=100.)           pl.setDruckerPragerLaw(tau_Y=100.)
608           pl.setPowerLaws(eta_N=[2.,0.01,25./4.],tau_t=[1, 25.,64.], power=[1,2,3])           pl.setPowerLaws(eta_N=[2.,0.01,25./4.],tau_t=[1, 25.,64.], power=[1,2,3])
609           pl.setEtaTolerance(self.TOL)           pl.setEtaTolerance(self.TOL)
610           for i in xrange(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i]),taus[i])           for i in range(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i]),taus[i])
611    
612       def test_PowerLaw_QuadSmall_CubeLarge(self):       def test_PowerLaw_QuadSmall_CubeLarge(self):
613           taus=[0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0]           taus=[0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0]
# Line 615  class Test_Rheologies(unittest.TestCase) Line 616  class Test_Rheologies(unittest.TestCase)
616           pl.setDruckerPragerLaw(tau_Y=100.)           pl.setDruckerPragerLaw(tau_Y=100.)
617           pl.setPowerLaws(eta_N=[2.,10.,1./16.],tau_t=[1, 25.,64.], power=[1,2,3])           pl.setPowerLaws(eta_N=[2.,10.,1./16.],tau_t=[1, 25.,64.], power=[1,2,3])
618           pl.setEtaTolerance(self.TOL)           pl.setEtaTolerance(self.TOL)
619           for i in xrange(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i]),taus[i])           for i in range(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i]),taus[i])
620    
621       def test_PowerLaw_QuadSmall_CubeSmall(self):       def test_PowerLaw_QuadSmall_CubeSmall(self):
622           taus=[0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0]           taus=[0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0]
# Line 624  class Test_Rheologies(unittest.TestCase) Line 625  class Test_Rheologies(unittest.TestCase)
625           pl.setDruckerPragerLaw(tau_Y=100.)           pl.setDruckerPragerLaw(tau_Y=100.)
626           pl.setPowerLaws(eta_N=[2.,10.,25./4.],tau_t=[1, 25.,64.], power=[1,2,3])           pl.setPowerLaws(eta_N=[2.,10.,25./4.],tau_t=[1, 25.,64.], power=[1,2,3])
627           pl.setEtaTolerance(self.TOL)           pl.setEtaTolerance(self.TOL)
628           for i in xrange(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i]),taus[i])           for i in range(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i]),taus[i])
629    
630       def test_PowerLaw_withShear(self):       def test_PowerLaw_withShear(self):
631           taus=[0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0]           taus=[0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0]
# Line 635  class Test_Rheologies(unittest.TestCase) Line 636  class Test_Rheologies(unittest.TestCase)
636           pl.setElasticShearModulus(3.)           pl.setElasticShearModulus(3.)
637           dt=1./3.           dt=1./3.
638           pl.setEtaTolerance(self.TOL)           pl.setEtaTolerance(self.TOL)
639           self.failUnlessRaises(ValueError, pl.getEtaEff,gamma_dot_s[0])           self.assertRaises(ValueError, pl.getEtaEff,gamma_dot_s[0])
640           for i in xrange(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i],dt=dt),taus[i])           for i in range(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i],dt=dt),taus[i])
641    
642  class Test_IncompressibleIsotropicFlowCartesian(unittest.TestCase):  class Test_IncompressibleIsotropicFlowCartesian(unittest.TestCase):
643     TOL=1.e-5     TOL=1.e-5
# Line 680  class Test_IncompressibleIsotropicFlowCa Line 681  class Test_IncompressibleIsotropicFlowCa
681        x=self.dom.getX()        x=self.dom.getX()
682        B=self.tau_Y/sqrt((self.dom.getDim()-1)*self.dom.getDim()*0.5)        B=self.tau_Y/sqrt((self.dom.getDim()-1)*self.dom.getDim()*0.5)
683        dt=B/int(self.N_dt/2)        dt=B/int(self.N_dt/2)
684        if self.VERBOSE: print "dt =",dt        if self.VERBOSE: print("dt =",dt)
685        if self.latestart:        if self.latestart:
686            t=dt            t=dt
687        else:        else:
# Line 730  class Test_IncompressibleIsotropicFlowCa Line 731  class Test_IncompressibleIsotropicFlowCa
731           error_s=Lsup(mod.getDeviatoricStress()-s_ref)/Lsup(s_ref)           error_s=Lsup(mod.getDeviatoricStress()-s_ref)/Lsup(s_ref)
732           error_v=Lsup(mod.getVelocity()-v_ref)/Lsup(v_ref)           error_v=Lsup(mod.getVelocity()-v_ref)/Lsup(v_ref)
733           error_t=abs(mod.getTime()-t_ref)/abs(t_ref)           error_t=abs(mod.getTime()-t_ref)/abs(t_ref)
734           if self.VERBOSE: print "time step ",N_t,"time = ",mod.getTime(),"errors s,p,v = ",error_s, error_p, error_v           if self.VERBOSE: print("time step ",N_t,"time = ",mod.getTime(),"errors s,p,v = ",error_s, error_p, error_v)
735           self.failUnless( error_p <= 10*self.TOL, "time step %s: pressure error %s too high."%(N_t,error_p) )           self.assertTrue( error_p <= 10*self.TOL, "time step %s: pressure error %s too high."%(N_t,error_p) )
736           self.failUnless( error_v <= 10*self.TOL, "time step %s: velocity error %s too high."%(N_t,error_v) )           self.assertTrue( error_v <= 10*self.TOL, "time step %s: velocity error %s too high."%(N_t,error_v) )
737           self.failUnless( error_t <= 10*self.TOL, "time step %s: time marker error %s too high."%(N_t,error_t) )           self.assertTrue( error_t <= 10*self.TOL, "time step %s: time marker error %s too high."%(N_t,error_t) )
738           self.failUnless( error_s <= 10*self.TOL, "time step %s: stress error %s too high."%(N_t,error_s) )           self.assertTrue( error_s <= 10*self.TOL, "time step %s: stress error %s too high."%(N_t,error_s) )
739     def tearDown(self):     def tearDown(self):
740          del self.dom          del self.dom
741    
# Line 835  class Test_FaultSystem(unittest.TestCase Line 836  class Test_FaultSystem(unittest.TestCase
836        t, loc=f.getMaxValue(u)        t, loc=f.getMaxValue(u)
837        p=f.getParametrization(x,t)[0]        p=f.getParametrization(x,t)[0]
838        m, l=loc(u), loc(p)        m, l=loc(u), loc(p)
839        self.failUnless(  m == 0.25, "wrong max value")        self.assertTrue(  m == 0.25, "wrong max value")
840        self.failUnless(  t == 1, "wrong max tag")        self.assertTrue(  t == 1, "wrong max tag")
841        self.failUnless(  l == 0., "wrong max location")        self.assertTrue(  l == 0., "wrong max location")
842    
843        u=x[1]*(1.-x[1])*(1-x[0])*x[0]        u=x[1]*(1.-x[1])*(1-x[0])*x[0]
844        t, loc=f.getMaxValue(u)        t, loc=f.getMaxValue(u)
845        p=f.getParametrization(x,t)[0]        p=f.getParametrization(x,t)[0]
846        m, l=loc(u), loc(p)        m, l=loc(u), loc(p)
847        self.failUnless(  m == 0.0625, "wrong max value")        self.assertTrue(  m == 0.0625, "wrong max value")
848        self.failUnless(  t == 2, "wrong max tag")        self.assertTrue(  t == 2, "wrong max tag")
849        self.failUnless(  l == 0.5, "wrong max location")        self.assertTrue(  l == 0.5, "wrong max location")
850    
851        u=x[0]*(1.-x[0])*x[1]        u=x[0]*(1.-x[0])*x[1]
852        t, loc=f.getMaxValue(u)        t, loc=f.getMaxValue(u)
853        p=f.getParametrization(x,t)[0]        p=f.getParametrization(x,t)[0]
854        m, l=loc(u), loc(p)        m, l=loc(u), loc(p)
855        self.failUnless(  m == 0.25, "wrong max value")        self.assertTrue(  m == 0.25, "wrong max value")
856        self.failUnless(  t == 2, "wrong max tag")        self.assertTrue(  t == 2, "wrong max tag")
857        self.failUnless(  l == 1.0, "wrong max location")        self.assertTrue(  l == 1.0, "wrong max location")
858    
859        u=x[1]*(1.-x[1])*x[0]        u=x[1]*(1.-x[1])*x[0]
860        t, loc=f.getMaxValue(u)        t, loc=f.getMaxValue(u)
861        p=f.getParametrization(x,t)[0]        p=f.getParametrization(x,t)[0]
862        m, l=loc(u), loc(p)        m, l=loc(u), loc(p)
863        self.failUnless(  m == 0.25, "wrong max value")        self.assertTrue(  m == 0.25, "wrong max value")
864        self.failUnless(  t == 2, "wrong max tag")        self.assertTrue(  t == 2, "wrong max tag")
865        self.failUnless(  l == 0., "wrong max location")        self.assertTrue(  l == 0., "wrong max location")
866    
867        u=x[1]*(1.-x[1])*(1.-x[0])        u=x[1]*(1.-x[1])*(1.-x[0])
868        t, loc=f.getMaxValue(u)        t, loc=f.getMaxValue(u)
869        p=f.getParametrization(x,t)[0]        p=f.getParametrization(x,t)[0]
870        m, l=loc(u), loc(p)        m, l=loc(u), loc(p)
871        self.failUnless(  m == 0.25, "wrong max value")        self.assertTrue(  m == 0.25, "wrong max value")
872        self.failUnless(  t == 1, "wrong max tag")        self.assertTrue(  t == 1, "wrong max tag")
873        self.failUnless(  abs(l-0.70710678118654) <= self.EPS,  "wrong max location")        self.assertTrue(  abs(l-0.70710678118654) <= self.EPS,  "wrong max location")
874     def test_Fault_MinValue(self):     def test_Fault_MinValue(self):
875        dom=Rectangle(2*self.NE,2*self.NE)        dom=Rectangle(2*self.NE,2*self.NE)
876        x=dom.getX()        x=dom.getX()
# Line 881  class Test_FaultSystem(unittest.TestCase Line 882  class Test_FaultSystem(unittest.TestCase
882        t, loc=f.getMinValue(u)        t, loc=f.getMinValue(u)
883        p=f.getParametrization(x,t)[0]        p=f.getParametrization(x,t)[0]
884        m, l=loc(u), loc(p)        m, l=loc(u), loc(p)
885        self.failUnless(  m == -0.25, "wrong min value")        self.assertTrue(  m == -0.25, "wrong min value")
886        self.failUnless(  t == 1, "wrong min tag")        self.assertTrue(  t == 1, "wrong min tag")
887        self.failUnless(  l == 0., "wrong min location")        self.assertTrue(  l == 0., "wrong min location")
888        u=-x[1]*(1.-x[1])*(1-x[0])*x[0]        u=-x[1]*(1.-x[1])*(1-x[0])*x[0]
889        t, loc=f.getMinValue(u)        t, loc=f.getMinValue(u)
890        p=f.getParametrization(x,t)[0]        p=f.getParametrization(x,t)[0]
891        m, l=loc(u), loc(p)        m, l=loc(u), loc(p)
892        self.failUnless(  m == -0.0625, "wrong min value")        self.assertTrue(  m == -0.0625, "wrong min value")
893        self.failUnless(  t == 2, "wrong min tag")        self.assertTrue(  t == 2, "wrong min tag")
894        self.failUnless(  l == 0.5, "wrong min location")        self.assertTrue(  l == 0.5, "wrong min location")
895        u=-x[0]*(1.-x[0])*x[1]        u=-x[0]*(1.-x[0])*x[1]
896        t, loc=f.getMinValue(u)        t, loc=f.getMinValue(u)
897        p=f.getParametrization(x,t)[0]        p=f.getParametrization(x,t)[0]
898        m, l=loc(u), loc(p)        m, l=loc(u), loc(p)
899        self.failUnless(  m == -0.25, "wrong min value")        self.assertTrue(  m == -0.25, "wrong min value")
900        self.failUnless(  t == 2, "wrong min tag")        self.assertTrue(  t == 2, "wrong min tag")
901        self.failUnless(  l == 1.0, "wrong min location")        self.assertTrue(  l == 1.0, "wrong min location")
902        u=-x[1]*(1.-x[1])*x[0]        u=-x[1]*(1.-x[1])*x[0]
903        t, loc=f.getMinValue(u)        t, loc=f.getMinValue(u)
904        p=f.getParametrization(x,t)[0]        p=f.getParametrization(x,t)[0]
905        m, l=loc(u), loc(p)        m, l=loc(u), loc(p)
906        self.failUnless(  m == -0.25, "wrong min value")        self.assertTrue(  m == -0.25, "wrong min value")
907        self.failUnless(  t == 2, "wrong min tag")        self.assertTrue(  t == 2, "wrong min tag")
908        self.failUnless(  l == 0., "wrong min location")        self.assertTrue(  l == 0., "wrong min location")
909        u=-x[1]*(1.-x[1])*(1.-x[0])        u=-x[1]*(1.-x[1])*(1.-x[0])
910        t, loc=f.getMinValue(u)        t, loc=f.getMinValue(u)
911        p=f.getParametrization(x,t)[0]        p=f.getParametrization(x,t)[0]
912        m, l=loc(u), loc(p)        m, l=loc(u), loc(p)
913        self.failUnless(  m == -0.25, "wrong min value")        self.assertTrue(  m == -0.25, "wrong min value")
914        self.failUnless(  t == 1, "wrong min tag")        self.assertTrue(  t == 1, "wrong min tag")
915        self.failUnless(  abs(l-0.70710678118654) <= self.EPS,  "wrong min location")        self.assertTrue(  abs(l-0.70710678118654) <= self.EPS,  "wrong min location")
916    
917                
918     def test_Fault2D(self):     def test_Fault2D(self):
919        f=FaultSystem(dim=2)        f=FaultSystem(dim=2)
920        top1=[ [1.,0.], [1.,1.], [0.,1.] ]        top1=[ [1.,0.], [1.,1.], [0.,1.] ]
921        self.failUnlessRaises(ValueError,f.addFault,V0=[1.,0],strikes=[pi/2, pi/2],ls=[1.,1.],tag=1,dips=top1)        self.assertRaises(ValueError,f.addFault,V0=[1.,0],strikes=[pi/2, pi/2],ls=[1.,1.],tag=1,dips=top1)
922        f.addFault(V0=[1.,0],strikes=[pi/2, pi],ls=[1.,1.],tag=1)        f.addFault(V0=[1.,0],strikes=[pi/2, pi],ls=[1.,1.],tag=1)
923        self.failUnless(f.getDim() == 2, "wrong dimension")        self.assertTrue(f.getDim() == 2, "wrong dimension")
924        self.failUnless( [ 1 ] == f.getTags(), "tags wrong")        self.assertTrue( [ 1 ] == f.getTags(), "tags wrong")
925        self.failUnless(  2. == f.getTotalLength(1), "length wrong")        self.assertTrue(  2. == f.getTotalLength(1), "length wrong")
926        self.failUnless(  0. == f.getMediumDepth(1), "depth wrong")        self.assertTrue(  0. == f.getMediumDepth(1), "depth wrong")
927        self.failUnless( (0., 2.) ==  f.getW0Range(1)," wrong W0 range")        self.assertTrue( (0., 2.) ==  f.getW0Range(1)," wrong W0 range")
928        self.failUnless( (0., 0.) ==  f.getW1Range(1)," wrong W1 range")        self.assertTrue( (0., 0.) ==  f.getW1Range(1)," wrong W1 range")
929        self.failUnless( [0., 1., 2.] ==  f.getW0Offsets(1)," wrong W0 offsets")        self.assertTrue( [0., 1., 2.] ==  f.getW0Offsets(1)," wrong W0 offsets")
930        segs=f.getTopPolyline(1)        segs=f.getTopPolyline(1)
931        self.failUnless( len(segs) == 3, "wrong number of segments")        self.assertTrue( len(segs) == 3, "wrong number of segments")
932        self.failUnless( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")        self.assertTrue( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")
933        self.failUnless( segs[0].size == 2, "seg 0 has wrong size.")        self.assertTrue( segs[0].size == 2, "seg 0 has wrong size.")
934        self.failUnless( numpy.linalg.norm(segs[0]-[1.,0.]) < self.EPS, "wrong vertex. 0 ")        self.assertTrue( numpy.linalg.norm(segs[0]-[1.,0.]) < self.EPS, "wrong vertex. 0 ")
935        self.failUnless( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1")        self.assertTrue( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1")
936        self.failUnless( segs[1].size == 2, "seg 1 has wrong size.")        self.assertTrue( segs[1].size == 2, "seg 1 has wrong size.")
937        self.failUnless( numpy.linalg.norm(segs[1]-[1.,1.]) < self.EPS, "wrong vertex. 1 ")        self.assertTrue( numpy.linalg.norm(segs[1]-[1.,1.]) < self.EPS, "wrong vertex. 1 ")
938        self.failUnless( isinstance(segs[2], numpy.ndarray), "wrong class of vertex 2")        self.assertTrue( isinstance(segs[2], numpy.ndarray), "wrong class of vertex 2")
939        self.failUnless( segs[2].size == 2, "seg 2 has wrong size.")        self.assertTrue( segs[2].size == 2, "seg 2 has wrong size.")
940        self.failUnless( numpy.linalg.norm(segs[2]-[0.,1.]) < self.EPS, "wrong vertex. 2 ")        self.assertTrue( numpy.linalg.norm(segs[2]-[0.,1.]) < self.EPS, "wrong vertex. 2 ")
941        c=f.getCenterOnSurface()        c=f.getCenterOnSurface()
942        self.failUnless( isinstance(c, numpy.ndarray), "center has wrong class")        self.assertTrue( isinstance(c, numpy.ndarray), "center has wrong class")
943        self.failUnless( c.size == 2, "center size is wrong")        self.assertTrue( c.size == 2, "center size is wrong")
944        self.failUnless( numpy.linalg.norm(c-[2./3.,2./3.]) < self.EPS, "center has wrong coordinates.")        self.assertTrue( numpy.linalg.norm(c-[2./3.,2./3.]) < self.EPS, "center has wrong coordinates.")
945        o=f.getOrientationOnSurface()/pi*180.        o=f.getOrientationOnSurface()/pi*180.
946        self.failUnless( abs(o+45.) < self.EPS, "wrong orientation.")        self.assertTrue( abs(o+45.) < self.EPS, "wrong orientation.")
947    
948        top2=[ [10.,0.], [0.,10.] ]        top2=[ [10.,0.], [0.,10.] ]
949        f.addFault(V0=[10.,0],strikes=[3.*pi/4],ls=[14.142135623730951], tag=2, w0_offsets=[0,20], w1_max=20)        f.addFault(V0=[10.,0],strikes=[3.*pi/4],ls=[14.142135623730951], tag=2, w0_offsets=[0,20], w1_max=20)
950        self.failUnless( [ 1, 2 ] == f.getTags(), "tags wrong")        self.assertTrue( [ 1, 2 ] == f.getTags(), "tags wrong")
951        self.failUnless(  abs(f.getTotalLength(2)-14.1421356237) < self.EPS * 14.1421356237, "wrong length")        self.assertTrue(  abs(f.getTotalLength(2)-14.1421356237) < self.EPS * 14.1421356237, "wrong length")
952        self.failUnless(  0. == f.getMediumDepth(2), "depth wrong")        self.assertTrue(  0. == f.getMediumDepth(2), "depth wrong")
953        self.failUnless( (0., 20.) ==  f.getW0Range(2)," wrong W0 range")        self.assertTrue( (0., 20.) ==  f.getW0Range(2)," wrong W0 range")
954        self.failUnless( (0., 0.) ==  f.getW1Range(2)," wrong W1 range")        self.assertTrue( (0., 0.) ==  f.getW1Range(2)," wrong W1 range")
955        self.failUnless( [0., 20.] ==  f.getW0Offsets(2)," wrong W0 offsets")        self.assertTrue( [0., 20.] ==  f.getW0Offsets(2)," wrong W0 offsets")
956        segs=f.getTopPolyline(2)        segs=f.getTopPolyline(2)
957        self.failUnless( len(segs) == 2, "wrong number of segments")        self.assertTrue( len(segs) == 2, "wrong number of segments")
958        self.failUnless( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")        self.assertTrue( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")
959        self.failUnless( numpy.linalg.norm(segs[0]-[10.,0.]) < self.EPS, "wrong vertex. 0 ")        self.assertTrue( numpy.linalg.norm(segs[0]-[10.,0.]) < self.EPS, "wrong vertex. 0 ")
960        self.failUnless( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1")        self.assertTrue( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1")
961        self.failUnless( numpy.linalg.norm(segs[1]-[0.,10.]) < self.EPS, "wrong vertex. 1 ")        self.assertTrue( numpy.linalg.norm(segs[1]-[0.,10.]) < self.EPS, "wrong vertex. 1 ")
962        c=f.getCenterOnSurface()        c=f.getCenterOnSurface()
963        self.failUnless( isinstance(c, numpy.ndarray), "center has wrong class")        self.assertTrue( isinstance(c, numpy.ndarray), "center has wrong class")
964        self.failUnless( c.size == 2, "center size is wrong")        self.assertTrue( c.size == 2, "center size is wrong")
965        self.failUnless( numpy.linalg.norm(c-[12./5.,12./5.]) < self.EPS, "center has wrong coordinates.")        self.assertTrue( numpy.linalg.norm(c-[12./5.,12./5.]) < self.EPS, "center has wrong coordinates.")
966        o=f.getOrientationOnSurface()/pi*180.        o=f.getOrientationOnSurface()/pi*180.
967        self.failUnless( abs(o+45.) < self.EPS, "wrong orientation.")        self.assertTrue( abs(o+45.) < self.EPS, "wrong orientation.")
968    
969        s,d=f.getSideAndDistance([0.,0.], tag=1)        s,d=f.getSideAndDistance([0.,0.], tag=1)
970        self.failUnless( s<0, "wrong side.")        self.assertTrue( s<0, "wrong side.")
971        self.failUnless( abs(d-1.)<self.EPS, "wrong distance.")        self.assertTrue( abs(d-1.)<self.EPS, "wrong distance.")
972        s,d=f.getSideAndDistance([0.,2.], tag=1)        s,d=f.getSideAndDistance([0.,2.], tag=1)
973        self.failUnless( s>0, "wrong side.")        self.assertTrue( s>0, "wrong side.")
974        self.failUnless( abs(d-1.)<self.EPS, "wrong distance.")        self.assertTrue( abs(d-1.)<self.EPS, "wrong distance.")
975        s,d=f.getSideAndDistance([1.,2.], tag=1)        s,d=f.getSideAndDistance([1.,2.], tag=1)
976        self.failUnless( s>0, "wrong side.")        self.assertTrue( s>0, "wrong side.")
977        self.failUnless( abs(d-1.)<self.EPS, "wrong distance.")        self.assertTrue( abs(d-1.)<self.EPS, "wrong distance.")
978        s,d=f.getSideAndDistance([2.,1.], tag=1)        s,d=f.getSideAndDistance([2.,1.], tag=1)
979        self.failUnless( s>0, "wrong side.")        self.assertTrue( s>0, "wrong side.")
980        self.failUnless( abs(d-1.)<self.EPS, "wrong distance.")        self.assertTrue( abs(d-1.)<self.EPS, "wrong distance.")
981        s,d=f.getSideAndDistance([2.,0.], tag=1)        s,d=f.getSideAndDistance([2.,0.], tag=1)
982        self.failUnless( s>0, "wrong side.")        self.assertTrue( s>0, "wrong side.")
983        self.failUnless( abs(d-1.)<self.EPS, "wrong distance.")        self.assertTrue( abs(d-1.)<self.EPS, "wrong distance.")
984        s,d=f.getSideAndDistance([0.,-1.], tag=1)        s,d=f.getSideAndDistance([0.,-1.], tag=1)
985        self.failUnless( s<0, "wrong side.")        self.assertTrue( s<0, "wrong side.")
986        self.failUnless( abs(d-1.41421356237)<self.EPS, "wrong distance.")        self.assertTrue( abs(d-1.41421356237)<self.EPS, "wrong distance.")
987        s,d=f.getSideAndDistance([-1.,0], tag=1)        s,d=f.getSideAndDistance([-1.,0], tag=1)
988        self.failUnless( s<0, "wrong side.")        self.assertTrue( s<0, "wrong side.")
989        self.failUnless( abs(d-1.41421356237)<self.EPS, "wrong distance.")        self.assertTrue( abs(d-1.41421356237)<self.EPS, "wrong distance.")
990    
991    
992        f.transform(rot=-pi/2., shift=[-1.,-1.])        f.transform(rot=-pi/2., shift=[-1.,-1.])
993        self.failUnless( [ 1, 2 ] == f.getTags(), "tags after transformation wrong")        self.assertTrue( [ 1, 2 ] == f.getTags(), "tags after transformation wrong")
994        self.failUnless(  2. == f.getTotalLength(1), "length after transformation wrong")        self.assertTrue(  2. == f.getTotalLength(1), "length after transformation wrong")
995        self.failUnless(  0. == f.getMediumDepth(1), "depth after transformation wrong")        self.assertTrue(  0. == f.getMediumDepth(1), "depth after transformation wrong")
996        self.failUnless( (0., 2.) ==  f.getW0Range(1)," wrong W0 after transformation range")        self.assertTrue( (0., 2.) ==  f.getW0Range(1)," wrong W0 after transformation range")
997        self.failUnless( (0., 0.) ==  f.getW1Range(1)," wrong W1 rangeafter transformation ")        self.assertTrue( (0., 0.) ==  f.getW1Range(1)," wrong W1 rangeafter transformation ")
998        self.failUnless( [0., 1., 2.] ==  f.getW0Offsets(1)," wrong W0 offsetsafter transformation ")        self.assertTrue( [0., 1., 2.] ==  f.getW0Offsets(1)," wrong W0 offsetsafter transformation ")
999        segs=f.getTopPolyline(1)        segs=f.getTopPolyline(1)
1000        self.failUnless( len(segs) == 3, "wrong number of segmentsafter transformation ")        self.assertTrue( len(segs) == 3, "wrong number of segmentsafter transformation ")
1001        self.failUnless( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0 after transformation")        self.assertTrue( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0 after transformation")
1002        self.failUnless( segs[0].size == 2, "seg 0 has wrong size after transformation.")        self.assertTrue( segs[0].size == 2, "seg 0 has wrong size after transformation.")
1003        self.failUnless( numpy.linalg.norm(segs[0]-[-1.,0.]) < self.EPS, "wrong vertex. 0  after transformation")        self.assertTrue( numpy.linalg.norm(segs[0]-[-1.,0.]) < self.EPS, "wrong vertex. 0  after transformation")
1004        self.failUnless( isinstance(segs[1], numpy.ndarray), "wrong class of vertex  after transformation1")        self.assertTrue( isinstance(segs[1], numpy.ndarray), "wrong class of vertex  after transformation1")
1005        self.failUnless( segs[1].size == 2, "seg 1 has wrong size after transformation.")        self.assertTrue( segs[1].size == 2, "seg 1 has wrong size after transformation.")
1006        self.failUnless( numpy.linalg.norm(segs[1]-[0.,0.]) < self.EPS, "wrong vertex.  after transformation1 ")        self.assertTrue( numpy.linalg.norm(segs[1]-[0.,0.]) < self.EPS, "wrong vertex.  after transformation1 ")
1007        self.failUnless( isinstance(segs[2], numpy.ndarray), "wrong class of vertex  after transformation2")        self.assertTrue( isinstance(segs[2], numpy.ndarray), "wrong class of vertex  after transformation2")
1008        self.failUnless( segs[2].size == 2, "seg 2 has wrong size after transformation.")        self.assertTrue( segs[2].size == 2, "seg 2 has wrong size after transformation.")
1009        self.failUnless( numpy.linalg.norm(segs[2]-[0., 1.]) < self.EPS, "wrong vertex after transformation. 2 ")        self.assertTrue( numpy.linalg.norm(segs[2]-[0., 1.]) < self.EPS, "wrong vertex after transformation. 2 ")
1010        self.failUnless(  abs(f.getTotalLength(2)-14.1421356237) < self.EPS * 14.1421356237, "wrong length after transformation")        self.assertTrue(  abs(f.getTotalLength(2)-14.1421356237) < self.EPS * 14.1421356237, "wrong length after transformation")
1011        self.failUnless(  0. == f.getMediumDepth(2), "depth wrong after transformation")        self.assertTrue(  0. == f.getMediumDepth(2), "depth wrong after transformation")
1012        self.failUnless( (0., 20.) ==  f.getW0Range(2)," wrong W0 range after transformation")        self.assertTrue( (0., 20.) ==  f.getW0Range(2)," wrong W0 range after transformation")
1013        self.failUnless( (0., 0.) ==  f.getW1Range(2)," wrong W1 range after transformation")        self.assertTrue( (0., 0.) ==  f.getW1Range(2)," wrong W1 range after transformation")
1014        self.failUnless( [0., 20.] ==  f.getW0Offsets(2)," wrong W0 offsets after transformation")        self.assertTrue( [0., 20.] ==  f.getW0Offsets(2)," wrong W0 offsets after transformation")
1015        segs=f.getTopPolyline(2)        segs=f.getTopPolyline(2)
1016        self.failUnless( len(segs) == 2, "wrong number of segments after transformation")        self.assertTrue( len(segs) == 2, "wrong number of segments after transformation")
1017        self.failUnless( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0 after transformation")        self.assertTrue( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0 after transformation")
1018        self.failUnless( numpy.linalg.norm(segs[0]-[-1.,-9]) < self.EPS, "wrong vertex. 0  after transformation")        self.assertTrue( numpy.linalg.norm(segs[0]-[-1.,-9]) < self.EPS, "wrong vertex. 0  after transformation")
1019        self.failUnless( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1 after transformation")        self.assertTrue( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1 after transformation")
1020        self.failUnless( numpy.linalg.norm(segs[1]-[9.,1.]) < self.EPS, "wrong vertex. 1  after transformation")        self.assertTrue( numpy.linalg.norm(segs[1]-[9.,1.]) < self.EPS, "wrong vertex. 1  after transformation")
1021    
1022        c=f.getCenterOnSurface()        c=f.getCenterOnSurface()
1023        self.failUnless( isinstance(c, numpy.ndarray), "center has wrong class")        self.assertTrue( isinstance(c, numpy.ndarray), "center has wrong class")
1024        self.failUnless( c.size == 2, "center size is wrong")        self.assertTrue( c.size == 2, "center size is wrong")
1025        self.failUnless( numpy.linalg.norm(c-[7./5.,-7./5.]) < self.EPS, "center has wrong coordinates.")        self.assertTrue( numpy.linalg.norm(c-[7./5.,-7./5.]) < self.EPS, "center has wrong coordinates.")
1026        o=f.getOrientationOnSurface()/pi*180.        o=f.getOrientationOnSurface()/pi*180.
1027        self.failUnless( abs(o-45.) < self.EPS, "wrong orientation.")        self.assertTrue( abs(o-45.) < self.EPS, "wrong orientation.")
1028    
1029        p=f.getParametrization([-1.,0.],1)        p=f.getParametrization([-1.,0.],1)
1030        self.failUnless(p[1]==1., "wrong value.")        self.assertTrue(p[1]==1., "wrong value.")
1031        self.failUnless(abs(p[0])<self.EPS, "wrong value.")        self.assertTrue(abs(p[0])<self.EPS, "wrong value.")
1032        p=f.getParametrization([-0.5,0.],1)        p=f.getParametrization([-0.5,0.],1)
1033        self.failUnless(p[1]==1., "wrong value.")        self.assertTrue(p[1]==1., "wrong value.")
1034        self.failUnless(abs(p[0]-0.5)<self.EPS* 0.5, "wrong value.")        self.assertTrue(abs(p[0]-0.5)<self.EPS* 0.5, "wrong value.")
1035        p=f.getParametrization([0.,0.],1)        p=f.getParametrization([0.,0.],1)
1036        self.failUnless(p[1]==1., "wrong value.")        self.assertTrue(p[1]==1., "wrong value.")
1037        self.failUnless(abs(p[0]-1.)<self.EPS, "wrong value.")        self.assertTrue(abs(p[0]-1.)<self.EPS, "wrong value.")
1038        p=f.getParametrization([0.0000001,0.0000001],1, tol=1.e-8)        p=f.getParametrization([0.0000001,0.0000001],1, tol=1.e-8)
1039        self.failUnless(p[1]==0., "wrong value.")        self.assertTrue(p[1]==0., "wrong value.")
1040        p=f.getParametrization([0.0000001,0.0000001],1, tol=1.e-6)        p=f.getParametrization([0.0000001,0.0000001],1, tol=1.e-6)
1041        self.failUnless(p[1]==1., "wrong value.")        self.assertTrue(p[1]==1., "wrong value.")
1042        self.failUnless(abs(p[0]-1.0000001)<self.EPS, "wrong value.")        self.assertTrue(abs(p[0]-1.0000001)<self.EPS, "wrong value.")
1043        p=f.getParametrization([0.,0.5],1)        p=f.getParametrization([0.,0.5],1)
1044        self.failUnless(p[1]==1., "wrong value.")        self.assertTrue(p[1]==1., "wrong value.")
1045        self.failUnless(abs(p[0]-1.5)<self.EPS, "wrong value.")        self.assertTrue(abs(p[0]-1.5)<self.EPS, "wrong value.")
1046        p=f.getParametrization([0,1.],1)        p=f.getParametrization([0,1.],1)
1047        self.failUnless(p[1]==1., "wrong value.")        self.assertTrue(p[1]==1., "wrong value.")
1048        self.failUnless(abs(p[0]-2.)<self.EPS, "wrong value.")        self.assertTrue(abs(p[0]-2.)<self.EPS, "wrong value.")
1049        p=f.getParametrization([1.,1.],1)        p=f.getParametrization([1.,1.],1)
1050        self.failUnless(p[1]==0., "wrong value.")        self.assertTrue(p[1]==0., "wrong value.")
1051        p=f.getParametrization([0,1.11],1)        p=f.getParametrization([0,1.11],1)
1052        self.failUnless(p[1]==0., "wrong value.")        self.assertTrue(p[1]==0., "wrong value.")
1053        p=f.getParametrization([-1,-9.],2)        p=f.getParametrization([-1,-9.],2)
1054        self.failUnless(p[1]==1., "wrong value.")        self.assertTrue(p[1]==1., "wrong value.")
1055        self.failUnless(abs(p[0])<self.EPS, "wrong value.")        self.assertTrue(abs(p[0])<self.EPS, "wrong value.")
1056        p=f.getParametrization([9,1],2)        p=f.getParametrization([9,1],2)
1057        self.failUnless(p[1]==1., "wrong value.")        self.assertTrue(p[1]==1., "wrong value.")
1058        self.failUnless(abs(p[0]-20.)<self.EPS, "wrong value.")        self.assertTrue(abs(p[0]-20.)<self.EPS, "wrong value.")
1059    
1060     def test_Fault3D(self):     def test_Fault3D(self):
1061        f=FaultSystem(dim=3)        f=FaultSystem(dim=3)
1062        self.failUnless(f.getDim() == 3, "wrong dimension")        self.assertTrue(f.getDim() == 3, "wrong dimension")
1063    
1064        top1=[ [0.,0.,0.], [1., 0., 0.] ]        top1=[ [0.,0.,0.], [1., 0., 0.] ]
1065        f.addFault(V0=[0.,0,0],strikes=[0.],ls=[1.,], dips=pi/2, depths=20.,tag=1)        f.addFault(V0=[0.,0,0],strikes=[0.],ls=[1.,], dips=pi/2, depths=20.,tag=1)
1066        self.failUnless( [ 1 ] == f.getTags(), "tags wrong")        self.assertTrue( [ 1 ] == f.getTags(), "tags wrong")
1067        self.failUnless(  1. == f.getTotalLength(1), "length wrong")        self.assertTrue(  1. == f.getTotalLength(1), "length wrong")
1068        self.failUnless(  20. == f.getMediumDepth(1), "depth wrong")        self.assertTrue(  20. == f.getMediumDepth(1), "depth wrong")
1069        self.failUnless( (0., 1.) ==  f.getW0Range(1)," wrong W0 range")        self.assertTrue( (0., 1.) ==  f.getW0Range(1)," wrong W0 range")
1070        self.failUnless( (-20., 0.) ==  f.getW1Range(1)," wrong W1 range")        self.assertTrue( (-20., 0.) ==  f.getW1Range(1)," wrong W1 range")
1071        self.failUnless( [0., 1.] ==  f.getW0Offsets(1)," wrong W0 offsets")        self.assertTrue( [0., 1.] ==  f.getW0Offsets(1)," wrong W0 offsets")
1072        segs=f.getTopPolyline(1)        segs=f.getTopPolyline(1)
1073        self.failUnless( len(segs) == 2, "wrong number of segments")        self.assertTrue( len(segs) == 2, "wrong number of segments")
1074        self.failUnless( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")        self.assertTrue( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")
1075        self.failUnless( segs[0].size == 3, "seg 0 has wrong size.")        self.assertTrue( segs[0].size == 3, "seg 0 has wrong size.")
1076        self.failUnless( numpy.linalg.norm(segs[0]-[0.,0.,0.]) < self.EPS, "wrong vertex. 0 ")        self.assertTrue( numpy.linalg.norm(segs[0]-[0.,0.,0.]) < self.EPS, "wrong vertex. 0 ")
1077        self.failUnless( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1")        self.assertTrue( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1")
1078        self.failUnless( segs[1].size == 3, "seg 1 has wrong size.")        self.assertTrue( segs[1].size == 3, "seg 1 has wrong size.")
1079        self.failUnless( numpy.linalg.norm(segs[1]-[1.,0.,0]) < self.EPS, "wrong vertex. 1 ")        self.assertTrue( numpy.linalg.norm(segs[1]-[1.,0.,0]) < self.EPS, "wrong vertex. 1 ")
1080        c=f.getCenterOnSurface()        c=f.getCenterOnSurface()
1081        self.failUnless( isinstance(c, numpy.ndarray), "center has wrong class")        self.assertTrue( isinstance(c, numpy.ndarray), "center has wrong class")
1082        self.failUnless( c.size == 3, "center size is wrong")        self.assertTrue( c.size == 3, "center size is wrong")
1083        self.failUnless( numpy.linalg.norm(c-[0.5,0.,0.]) < self.EPS, "center has wrong coordinates.")        self.assertTrue( numpy.linalg.norm(c-[0.5,0.,0.]) < self.EPS, "center has wrong coordinates.")
1084        o=f.getOrientationOnSurface()/pi*180.        o=f.getOrientationOnSurface()/pi*180.
1085        self.failUnless( abs(o) < self.EPS, "wrong orientation.")        self.assertTrue( abs(o) < self.EPS, "wrong orientation.")
1086        d=f.getDips(1)        d=f.getDips(1)
1087        self.failUnless( len(d) == 1, "wrong number of dips")        self.assertTrue( len(d) == 1, "wrong number of dips")
1088        self.failUnless(  abs(d[0]-1.5707963267948966) < self.EPS, "wrong dip 0")        self.assertTrue(  abs(d[0]-1.5707963267948966) < self.EPS, "wrong dip 0")
1089        sn=f.getSegmentNormals(1)        sn=f.getSegmentNormals(1)
1090        self.failUnless( len(sn) == 1, "wrong number of normals")        self.assertTrue( len(sn) == 1, "wrong number of normals")
1091        self.failUnless( isinstance(sn[0], numpy.ndarray), "wrong class of bottom vertex 0")        self.assertTrue( isinstance(sn[0], numpy.ndarray), "wrong class of bottom vertex 0")
1092        self.failUnless( numpy.linalg.norm(sn[0]-[0, -1., 0.]) < self.EPS, "wrong bottom vertex 1 ")        self.assertTrue( numpy.linalg.norm(sn[0]-[0, -1., 0.]) < self.EPS, "wrong bottom vertex 1 ")
1093        dv=f.getDepthVectors(1)        dv=f.getDepthVectors(1)
1094        self.failUnless( len(dv) == 2, "wrong number of depth vectors.")        self.assertTrue( len(dv) == 2, "wrong number of depth vectors.")
1095        self.failUnless( isinstance(dv[0], numpy.ndarray), "wrong class of depth vector 0")        self.assertTrue( isinstance(dv[0], numpy.ndarray), "wrong class of depth vector 0")
1096        self.failUnless( numpy.linalg.norm(dv[0]-[0., 0., -20.]) < self.EPS, "wrong depth vector 0 ")        self.assertTrue( numpy.linalg.norm(dv[0]-[0., 0., -20.]) < self.EPS, "wrong depth vector 0 ")
1097        self.failUnless( isinstance(dv[1], numpy.ndarray), "wrong class of depth vector 1")        self.assertTrue( isinstance(dv[1], numpy.ndarray), "wrong class of depth vector 1")
1098        self.failUnless( numpy.linalg.norm(dv[1]-[0., 0., -20.]) < self.EPS, "wrong depth vector 1 ")        self.assertTrue( numpy.linalg.norm(dv[1]-[0., 0., -20.]) < self.EPS, "wrong depth vector 1 ")
1099        b=f.getBottomPolyline(1)        b=f.getBottomPolyline(1)
1100        self.failUnless( len(b) == 2, "wrong number of bottom vertices")        self.assertTrue( len(b) == 2, "wrong number of bottom vertices")
1101        self.failUnless( isinstance(b[0], numpy.ndarray), "wrong class of bottom vertex 0")        self.assertTrue( isinstance(b[0], numpy.ndarray), "wrong class of bottom vertex 0")
1102        self.failUnless( numpy.linalg.norm(b[0]-[0., 0., -20.]) < self.EPS, "wrong bottom vertex 0 ")        self.assertTrue( numpy.linalg.norm(b[0]-[0., 0., -20.]) < self.EPS, "wrong bottom vertex 0 ")
1103        self.failUnless( isinstance(b[1], numpy.ndarray), "wrong class of bottom vertex 1")        self.assertTrue( isinstance(b[1], numpy.ndarray), "wrong class of bottom vertex 1")
1104        self.failUnless( numpy.linalg.norm(b[1]-[1., 0., -20.]) < self.EPS, "wrong bottom vertex 1 ")        self.assertTrue( numpy.linalg.norm(b[1]-[1., 0., -20.]) < self.EPS, "wrong bottom vertex 1 ")
1105        ds=f.getDepths(1)        ds=f.getDepths(1)
1106        self.failUnless( len(ds) == 2, "wrong number of depth")        self.assertTrue( len(ds) == 2, "wrong number of depth")
1107        self.failUnless( abs(ds[0]-20.) < self.EPS, "wrong depth at vertex 0 ")        self.assertTrue( abs(ds[0]-20.) < self.EPS, "wrong depth at vertex 0 ")
1108        self.failUnless( abs(ds[1]-20.) < self.EPS, "wrong depth at vertex 1 ")        self.assertTrue( abs(ds[1]-20.) < self.EPS, "wrong depth at vertex 1 ")
1109    
1110        top2=[ [0.,0.,0.], [0., 10., 0.] ]        top2=[ [0.,0.,0.], [0., 10., 0.] ]
1111        f.addFault(V0=[0.,0,0],strikes=[pi/2],ls=[10.,], dips=pi/2, depths=20.,tag=2)        f.addFault(V0=[0.,0,0],strikes=[pi/2],ls=[10.,], dips=pi/2, depths=20.,tag=2)
1112        self.failUnless( [ 1, 2 ] == f.getTags(), "tags wrong")        self.assertTrue( [ 1, 2 ] == f.getTags(), "tags wrong")
1113        self.failUnless(  10. == f.getTotalLength(2), "length wrong")        self.assertTrue(  10. == f.getTotalLength(2), "length wrong")
1114        self.failUnless(  20. == f.getMediumDepth(2), "depth wrong")        self.assertTrue(  20. == f.getMediumDepth(2), "depth wrong")
1115        self.failUnless( (0., 10.) ==  f.getW0Range(2)," wrong W0 range")        self.assertTrue( (0., 10.) ==  f.getW0Range(2)," wrong W0 range")
1116        self.failUnless( (-20., 0.) ==  f.getW1Range(2)," wrong W1 range")        self.assertTrue( (-20., 0.) ==  f.getW1Range(2)," wrong W1 range")
1117        self.failUnless( [0., 10.] ==  f.getW0Offsets(2)," wrong W0 offsets")        self.assertTrue( [0., 10.] ==  f.getW0Offsets(2)," wrong W0 offsets")
1118        segs=f.getTopPolyline(2)        segs=f.getTopPolyline(2)
1119        self.failUnless( len(segs) == 2, "wrong number of segments")        self.assertTrue( len(segs) == 2, "wrong number of segments")
1120        self.failUnless( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")        self.assertTrue( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")
1121        self.failUnless( segs[0].size == 3, "seg 0 has wrong size.")        self.assertTrue( segs[0].size == 3, "seg 0 has wrong size.")
1122        self.failUnless( numpy.linalg.norm(segs[0]-[0.,0.,0.]) < self.EPS, "wrong vertex. 0 ")        self.assertTrue( numpy.linalg.norm(segs[0]-[0.,0.,0.]) < self.EPS, "wrong vertex. 0 ")
1123        self.failUnless( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1")        self.assertTrue( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1")
1124        self.failUnless( segs[1].size == 3, "seg 1 has wrong size.")        self.assertTrue( segs[1].size == 3, "seg 1 has wrong size.")
1125        self.failUnless( numpy.linalg.norm(segs[1]-[0., 10., 0]) < self.EPS, "wrong vertex. 1 ")        self.assertTrue( numpy.linalg.norm(segs[1]-[0., 10., 0]) < self.EPS, "wrong vertex. 1 ")
1126        d=f.getDips(2)        d=f.getDips(2)
1127        self.failUnless( len(d) == 1, "wrong number of dips")        self.assertTrue( len(d) == 1, "wrong number of dips")
1128        self.failUnless(  abs(d[0]-1.5707963267948966) < self.EPS, "wrong dip 0")        self.assertTrue(  abs(d[0]-1.5707963267948966) < self.EPS, "wrong dip 0")
1129        sn=f.getSegmentNormals(2)        sn=f.getSegmentNormals(2)
1130        self.failUnless( len(sn) == 1, "wrong number of normals")        self.assertTrue( len(sn) == 1, "wrong number of normals")
1131        self.failUnless( isinstance(sn[0], numpy.ndarray), "wrong class of bottom vertex 0")        self.assertTrue( isinstance(sn[0], numpy.ndarray), "wrong class of bottom vertex 0")
1132        self.failUnless( numpy.linalg.norm(sn[0]-[1, 0., 0.]) < self.EPS, "wrong bottom vertex 1 ")        self.assertTrue( numpy.linalg.norm(sn[0]-[1, 0., 0.]) < self.EPS, "wrong bottom vertex 1 ")
1133        dv=f.getDepthVectors(2)        dv=f.getDepthVectors(2)
1134        self.failUnless( len(dv) == 2, "wrong number of depth vectors.")        self.assertTrue( len(dv) == 2, "wrong number of depth vectors.")
1135        self.failUnless( isinstance(dv[0], numpy.ndarray), "wrong class of depth vector 0")        self.assertTrue( isinstance(dv[0], numpy.ndarray), "wrong class of depth vector 0")
1136        self.failUnless( numpy.linalg.norm(dv[0]-[0., 0., -20.]) < self.EPS, "wrong depth vector 0 ")        self.assertTrue( numpy.linalg.norm(dv[0]-[0., 0., -20.]) < self.EPS, "wrong depth vector 0 ")
1137        self.failUnless( isinstance(dv[1], numpy.ndarray), "wrong class of depth vector 1")        self.assertTrue( isinstance(dv[1], numpy.ndarray), "wrong class of depth vector 1")
1138        self.failUnless( numpy.linalg.norm(dv[1]-[0., 0., -20.]) < self.EPS, "wrong depth vector 1 ")        self.assertTrue( numpy.linalg.norm(dv[1]-[0., 0., -20.]) < self.EPS, "wrong depth vector 1 ")
1139        b=f.getBottomPolyline(2)        b=f.getBottomPolyline(2)
1140        self.failUnless( len(b) == 2, "wrong number of bottom vertices")        self.assertTrue( len(b) == 2, "wrong number of bottom vertices")
1141        self.failUnless( isinstance(b[0], numpy.ndarray), "wrong class of bottom vertex 0")        self.assertTrue( isinstance(b[0], numpy.ndarray), "wrong class of bottom vertex 0")
1142        self.failUnless( numpy.linalg.norm(b[0]-[0., 0., -20.]) < self.EPS, "wrong bottom vertex 0 ")        self.assertTrue( numpy.linalg.norm(b[0]-[0., 0., -20.]) < self.EPS, "wrong bottom vertex 0 ")
1143        self.failUnless( isinstance(b[1], numpy.ndarray), "wrong class of bottom vertex 1")        self.assertTrue( isinstance(b[1], numpy.ndarray), "wrong class of bottom vertex 1")
1144        self.failUnless( numpy.linalg.norm(b[1]-[0., 10., -20.]) < self.EPS, "wrong bottom vertex 1 ")        self.assertTrue( numpy.linalg.norm(b[1]-[0., 10., -20.]) < self.EPS, "wrong bottom vertex 1 ")
1145        ds=f.getDepths(2)        ds=f.getDepths(2)
1146        self.failUnless( len(ds) == 2, "wrong number of depth")        self.assertTrue( len(ds) == 2, "wrong number of depth")
1147        self.failUnless( abs(ds[0]-20.) < self.EPS, "wrong depth at vertex 0 ")        self.assertTrue( abs(ds[0]-20.) < self.EPS, "wrong depth at vertex 0 ")
1148        self.failUnless( abs(ds[1]-20.) < self.EPS, "wrong depth at vertex 1 ")        self.assertTrue( abs(ds[1]-20.) < self.EPS, "wrong depth at vertex 1 ")
1149    
1150        top2=[ [10.,0.,0.], [0., 10., 0.] ]        top2=[ [10.,0.,0.], [0., 10., 0.] ]
1151        f.addFault(V0=[10.,0,0],strikes=3*pi/4,ls=14.142135623730951, dips=pi/2, depths=30.,tag=2)        f.addFault(V0=[10.,0,0],strikes=3*pi/4,ls=14.142135623730951, dips=pi/2, depths=30.,tag=2)
1152        self.failUnless( [ 1, 2 ] == f.getTags(), "tags wrong")        self.assertTrue( [ 1, 2 ] == f.getTags(), "tags wrong")
1153        self.failUnless(  abs(14.142135623730951 - f.getTotalLength(2)) <self.EPS, "length wrong")        self.assertTrue(  abs(14.142135623730951 - f.getTotalLength(2)) <self.EPS, "length wrong")
1154        self.failUnless(  30. == f.getMediumDepth(2), "depth wrong")        self.assertTrue(  30. == f.getMediumDepth(2), "depth wrong")
1155        self.failUnless( (-30., 0.) ==  f.getW1Range(2)," wrong W1 range")        self.assertTrue( (-30., 0.) ==  f.getW1Range(2)," wrong W1 range")
1156        segs=f.getTopPolyline(2)        segs=f.getTopPolyline(2)
1157        self.failUnless( len(segs) == 2, "wrong number of segments")        self.assertTrue( len(segs) == 2, "wrong number of segments")
1158        self.failUnless( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")        self.assertTrue( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")
1159        self.failUnless( segs[0].size == 3, "seg 0 has wrong size.")        self.assertTrue( segs[0].size == 3, "seg 0 has wrong size.")
1160        self.failUnless( numpy.linalg.norm(segs[0]-[10.,0.,0.]) < self.EPS, "wrong vertex. 0 ")        self.assertTrue( numpy.linalg.norm(segs[0]-[10.,0.,0.]) < self.EPS, "wrong vertex. 0 ")
1161        self.failUnless( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1")        self.assertTrue( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1")
1162        self.failUnless( segs[1].size == 3, "seg 1 has wrong size.")        self.assertTrue( segs[1].size == 3, "seg 1 has wrong size.")
1163        self.failUnless( numpy.linalg.norm(segs[1]-[0., 10., 0]) < self.EPS, "wrong vertex. 1 ")        self.assertTrue( numpy.linalg.norm(segs[1]-[0., 10., 0]) < self.EPS, "wrong vertex. 1 ")
1164        d=f.getDips(2)        d=f.getDips(2)
1165        self.failUnless( len(d) == 1, "wrong number of dips")        self.assertTrue( len(d) == 1, "wrong number of dips")
1166        self.failUnless(  abs(d[0]-1.5707963267948966) < self.EPS, "wrong dip 0")        self.assertTrue(  abs(d[0]-1.5707963267948966) < self.EPS, "wrong dip 0")
1167        sn=f.getSegmentNormals(2)        sn=f.getSegmentNormals(2)
1168        self.failUnless( len(sn) == 1, "wrong number of normals")        self.assertTrue( len(sn) == 1, "wrong number of normals")
1169        self.failUnless( isinstance(sn[0], numpy.ndarray), "wrong class of bottom vertex 0")        self.assertTrue( isinstance(sn[0], numpy.ndarray), "wrong class of bottom vertex 0")
1170        self.failUnless( numpy.linalg.norm(sn[0]-[0.70710678118654746, 0.70710678118654746, 0.]) < self.EPS, "wrong bottom vertex 1 ")        self.assertTrue( numpy.linalg.norm(sn[0]-[0.70710678118654746, 0.70710678118654746, 0.]) < self.EPS, "wrong bottom vertex 1 ")
1171        dv=f.getDepthVectors(2)        dv=f.getDepthVectors(2)
1172        self.failUnless( len(dv) == 2, "wrong number of depth vectors.")        self.assertTrue( len(dv) == 2, "wrong number of depth vectors.")
1173        self.failUnless( isinstance(dv[0], numpy.ndarray), "wrong class of depth vector 0")        self.assertTrue( isinstance(dv[0], numpy.ndarray), "wrong class of depth vector 0")
1174        self.failUnless( numpy.linalg.norm(dv[0]-[0., 0., -30.]) < self.EPS, "wrong depth vector 0 ")        self.assertTrue( numpy.linalg.norm(dv[0]-[0., 0., -30.]) < self.EPS, "wrong depth vector 0 ")
1175        self.failUnless( isinstance(dv[1], numpy.ndarray), "wrong class of depth vector 1")        self.assertTrue( isinstance(dv[1], numpy.ndarray), "wrong class of depth vector 1")
1176        self.failUnless( numpy.linalg.norm(dv[1]-[0., 0., -30.]) < self.EPS, "wrong depth vector 1 ")        self.assertTrue( numpy.linalg.norm(dv[1]-[0., 0., -30.]) < self.EPS, "wrong depth vector 1 ")
1177        b=f.getBottomPolyline(2)        b=f.getBottomPolyline(2)
1178        self.failUnless( len(b) == 2, "wrong number of bottom vertices")        self.assertTrue( len(b) == 2, "wrong number of bottom vertices")
1179        self.failUnless( isinstance(b[0], numpy.ndarray), "wrong class of bottom vertex 0")        self.assertTrue( isinstance(b[0], numpy.ndarray), "wrong class of bottom vertex 0")
1180        self.failUnless( numpy.linalg.norm(b[0]-[10., 0., -30.]) < self.EPS, "wrong bottom vertex 0 ")        self.assertTrue( numpy.linalg.norm(b[0]-[10., 0., -30.]) < self.EPS, "wrong bottom vertex 0 ")
1181        self.failUnless( isinstance(b[1], numpy.ndarray), "wrong class of bottom vertex 1")        self.assertTrue( isinstance(b[1], numpy.ndarray), "wrong class of bottom vertex 1")
1182        self.failUnless( numpy.linalg.norm(b[1]-[0., 10., -30.]) < self.EPS, "wrong bottom vertex 1 ")        self.assertTrue( numpy.linalg.norm(b[1]-[0., 10., -30.]) < self.EPS, "wrong bottom vertex 1 ")
1183        ds=f.getDepths(2)        ds=f.getDepths(2)
1184        self.failUnless( len(ds) == 2, "wrong number of depth")        self.assertTrue( len(ds) == 2, "wrong number of depth")
1185        self.failUnless( abs(ds[0]-30.) < self.EPS, "wrong depth at vertex 0 ")        self.assertTrue( abs(ds[0]-30.) < self.EPS, "wrong depth at vertex 0 ")
1186        self.failUnless( abs(ds[1]-30.) < self.EPS, "wrong depth at vertex 1 ")        self.assertTrue( abs(ds[1]-30.) < self.EPS, "wrong depth at vertex 1 ")
1187    
1188        top2=[ [10.,0.,0.], [0., 10., 0.] ]        top2=[ [10.,0.,0.], [0., 10., 0.] ]
1189        f.addFault(V0=[10.,0,0],strikes=3*pi/4,ls=14.142135623730951, dips=pi/4, depths=50.,tag=2)        f.addFault(V0=[10.,0,0],strikes=3*pi/4,ls=14.142135623730951, dips=pi/4, depths=50.,tag=2)
1190        self.failUnless( [ 1, 2 ] == f.getTags(), "tags wrong")        self.assertTrue( [ 1, 2 ] == f.getTags(), "tags wrong")
1191        self.failUnless(  abs(14.142135623730951 - f.getTotalLength(2)) <self.EPS, "length wrong")        self.assertTrue(  abs(14.142135623730951 - f.getTotalLength(2)) <self.EPS, "length wrong")
1192        self.failUnless(  50. == f.getMediumDepth(2), "depth wrong")        self.assertTrue(  50. == f.getMediumDepth(2), "depth wrong")
1193        self.failUnless( (-50., 0.) ==  f.getW1Range(2)," wrong W1 range")        self.assertTrue( (-50., 0.) ==  f.getW1Range(2)," wrong W1 range")
1194        segs=f.getTopPolyline(2)        segs=f.getTopPolyline(2)
1195        self.failUnless( len(segs) == 2, "wrong number of segments")        self.assertTrue( len(segs) == 2, "wrong number of segments")
1196        self.failUnless( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")        self.assertTrue( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")
1197        self.failUnless( segs[0].size == 3, "seg 0 has wrong size.")        self.assertTrue( segs[0].size == 3, "seg 0 has wrong size.")
1198        self.failUnless( numpy.linalg.norm(segs[0]-[10.,0.,0.]) < self.EPS, "wrong vertex. 0 ")        self.assertTrue( numpy.linalg.norm(segs[0]-[10.,0.,0.]) < self.EPS, "wrong vertex. 0 ")
1199        self.failUnless( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1")        self.assertTrue( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1")
1200        self.failUnless( segs[1].size == 3, "seg 1 has wrong size.")        self.assertTrue( segs[1].size == 3, "seg 1 has wrong size.")
1201        self.failUnless( numpy.linalg.norm(segs[1]-[0., 10., 0]) < self.EPS, "wrong vertex. 1 ")        self.assertTrue( numpy.linalg.norm(segs[1]-[0., 10., 0]) < self.EPS, "wrong vertex. 1 ")
1202        d=f.getDips(2)        d=f.getDips(2)
1203        self.failUnless( len(d) == 1, "wrong number of dips")        self.assertTrue( len(d) == 1, "wrong number of dips")
1204        self.failUnless(  abs(d[0]-0.78539816339744828) < self.EPS, "wrong dip 0")        self.assertTrue(  abs(d[0]-0.78539816339744828) < self.EPS, "wrong dip 0")
1205        sn=f.getSegmentNormals(2)        sn=f.getSegmentNormals(2)
1206        self.failUnless( len(sn) == 1, "wrong number of normals")        self.assertTrue( len(sn) == 1, "wrong number of normals")
1207        self.failUnless( isinstance(sn[0], numpy.ndarray), "wrong class of bottom vertex 0")        self.assertTrue( isinstance(sn[0], numpy.ndarray), "wrong class of bottom vertex 0")
1208        self.failUnless( numpy.linalg.norm(sn[0]-[0.5,0.5,0.70710678118654746]) < self.EPS, "wrong bottom vertex 1 ")        self.assertTrue( numpy.linalg.norm(sn[0]-[0.5,0.5,0.70710678118654746]) < self.EPS, "wrong bottom vertex 1 ")
1209        dv=f.getDepthVectors(2)        dv=f.getDepthVectors(2)
1210        self.failUnless( len(dv) == 2, "wrong number of depth vectors.")        self.assertTrue( len(dv) == 2, "wrong number of depth vectors.")
1211        self.failUnless( isinstance(dv[0], numpy.ndarray), "wrong class of depth vector 0")        self.assertTrue( isinstance(dv[0], numpy.ndarray), "wrong class of depth vector 0")
1212        self.failUnless( numpy.linalg.norm(dv[0]-[25., 25., -35.355339059327378]) < self.EPS, "wrong depth vector 0 ")        self.assertTrue( numpy.linalg.norm(dv[0]-[25., 25., -35.355339059327378]) < self.EPS, "wrong depth vector 0 ")
1213        self.failUnless( isinstance(dv[1], numpy.ndarray), "wrong class of depth vector 1")        self.assertTrue( isinstance(dv[1], numpy.ndarray), "wrong class of depth vector 1")
1214        self.failUnless( numpy.linalg.norm(dv[1]-[25.,25., -35.355339059327378]) < self.EPS, "wrong depth vector 1 ")        self.assertTrue( numpy.linalg.norm(dv[1]-[25.,25., -35.355339059327378]) < self.EPS, "wrong depth vector 1 ")
1215        b=f.getBottomPolyline(2)        b=f.getBottomPolyline(2)
1216        self.failUnless( len(b) == 2, "wrong number of bottom vertices")        self.assertTrue( len(b) == 2, "wrong number of bottom vertices")
1217        self.failUnless( isinstance(b[0], numpy.ndarray), "wrong class of bottom vertex 0")        self.assertTrue( isinstance(b[0], numpy.ndarray), "wrong class of bottom vertex 0")
1218        self.failUnless( numpy.linalg.norm(b[0]-[35., 25., -35.355339059327378]) < self.EPS, "wrong bottom vertex 0 ")        self.assertTrue( numpy.linalg.norm(b[0]-[35., 25., -35.355339059327378]) < self.EPS, "wrong bottom vertex 0 ")
1219        self.failUnless( isinstance(b[1], numpy.ndarray), "wrong class of bottom vertex 1")        self.assertTrue( isinstance(b[1], numpy.ndarray), "wrong class of bottom vertex 1")
1220        self.failUnless( numpy.linalg.norm(b[1]-[25, 35., -35.355339059327378]) < self.EPS, "wrong bottom vertex 1 ")        self.assertTrue( numpy.linalg.norm(b[1]-[25, 35., -35.355339059327378]) < self.EPS, "wrong bottom vertex 1 ")
1221        ds=f.getDepths(2)        ds=f.getDepths(2)
1222        self.failUnless( len(ds) == 2, "wrong number of depth")        self.assertTrue( len(ds) == 2, "wrong number of depth")
1223        self.failUnless( abs(ds[0]-50.) < self.EPS, "wrong depth at vertex 0 ")        self.assertTrue( abs(ds[0]-50.) < self.EPS, "wrong depth at vertex 0 ")
1224        self.failUnless( abs(ds[1]-50.) < self.EPS, "wrong depth at vertex 1 ")        self.assertTrue( abs(ds[1]-50.) < self.EPS, "wrong depth at vertex 1 ")
1225    
1226        top1=[ [10.,0.,0], [10.,10.,0], [0.,10.,0] ]        top1=[ [10.,0.,0], [10.,10.,0], [0.,10.,0] ]
1227        f.addFault(V0=[10.,0.,0.],strikes=[pi/2, pi],ls=[10.,10.],tag=1, dips=pi/4, depths=20.)        f.addFault(V0=[10.,0.,0.],strikes=[pi/2, pi],ls=[10.,10.],tag=1, dips=pi/4, depths=20.)
1228        self.failUnless(  20. == f.getTotalLength(1), "length wrong")        self.assertTrue(  20. == f.getTotalLength(1), "length wrong")
1229        self.failUnless(  20. == f.getMediumDepth(1), "depth wrong")        self.assertTrue(  20. == f.getMediumDepth(1), "depth wrong")
1230        segs=f.getTopPolyline(1)        segs=f.getTopPolyline(1)
1231        self.failUnless( len(segs) == 3, "wrong number of segments")        self.assertTrue( len(segs) == 3, "wrong number of segments")
1232        self.failUnless( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")        self.assertTrue( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")
1233        self.failUnless( segs[0].size == 3, "seg 0 has wrong size.")        self.assertTrue( segs[0].size == 3, "seg 0 has wrong size.")
1234        self.failUnless( numpy.linalg.norm(segs[0]-[10.,0.,0.]) < self.EPS, "wrong vertex. 0 ")        self.assertTrue( numpy.linalg.norm(segs[0]-[10.,0.,0.]) < self.EPS, "wrong vertex. 0 ")
1235        self.failUnless( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1")        self.assertTrue( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1")
1236        self.failUnless( segs[1].size == 3, "seg 1 has wrong size.")        self.assertTrue( segs[1].size == 3, "seg 1 has wrong size.")
1237        self.failUnless( numpy.linalg.norm(segs[1]-[10.,10.,0.]) < self.EPS, "wrong vertex. 1 ")        self.assertTrue( numpy.linalg.norm(segs[1]-[10.,10.,0.]) < self.EPS, "wrong vertex. 1 ")
1238        self.failUnless( isinstance(segs[2], numpy.ndarray), "wrong class of vertex 2")        self.assertTrue( isinstance(segs[2], numpy.ndarray), "wrong class of vertex 2")
1239        self.failUnless( segs[2].size == 3, "seg 2 has wrong size.")        self.assertTrue( segs[2].size == 3, "seg 2 has wrong size.")
1240        self.failUnless( numpy.linalg.norm(segs[2]-[0.,10.,0.]) < self.EPS, "wrong vertex. 2 ")        self.assertTrue( numpy.linalg.norm(segs[2]-[0.,10.,0.]) < self.EPS, "wrong vertex. 2 ")
1241        d=f.getDips(1)        d=f.getDips(1)
1242        self.failUnless( len(d) == 2, "wrong number of dips")        self.assertTrue( len(d) == 2, "wrong number of dips")
1243        self.failUnless(  abs(d[0]-0.78539816339744828) < self.EPS, "wrong dip 0")        self.assertTrue(  abs(d[0]-0.78539816339744828) < self.EPS, "wrong dip 0")
1244        self.failUnless(  abs(d[1]-0.78539816339744828) < self.EPS, "wrong dip 0")        self.assertTrue(  abs(d[1]-0.78539816339744828) < self.EPS, "wrong dip 0")
1245        ds=f.getDepths(1)        ds=f.getDepths(1)
1246        self.failUnless( len(ds) == 3, "wrong number of depth")        self.assertTrue( len(ds) == 3, "wrong number of depth")
1247        self.failUnless( abs(ds[0]-20.) < self.EPS, "wrong depth at vertex 0 ")        self.assertTrue( abs(ds[0]-20.) < self.EPS, "wrong depth at vertex 0 ")
1248        self.failUnless( abs(ds[1]-20.) < self.EPS, "wrong depth at vertex 1 ")        self.assertTrue( abs(ds[1]-20.) < self.EPS, "wrong depth at vertex 1 ")
1249        sn=f.getSegmentNormals(1)        sn=f.getSegmentNormals(1)
1250        self.failUnless( len(sn) == 2, "wrong number of normals")        self.assertTrue( len(sn) == 2, "wrong number of normals")
1251        self.failUnless( isinstance(sn[0], numpy.ndarray), "wrong class of bottom vertex 0")        self.assertTrue( isinstance(sn[0], numpy.ndarray), "wrong class of bottom vertex 0")
1252        self.failUnless( numpy.linalg.norm(sn[0]-[0.70710678118654746,0.,0.70710678118654746]) < self.EPS, "wrong bottom vertex 1 ")        self.assertTrue( numpy.linalg.norm(sn[0]-[0.70710678118654746,0.,0.70710678118654746]) < self.EPS, "wrong bottom vertex 1 ")
1253        self.failUnless( isinstance(sn[1], numpy.ndarray), "wrong class of bottom vertex 0")        self.assertTrue( isinstance(sn[1], numpy.ndarray), "wrong class of bottom vertex 0")
1254        self.failUnless( numpy.linalg.norm(sn[1]-[0.,0.70710678118654746,0.70710678118654746]) < self.EPS, "wrong bottom vertex 1 ")        self.assertTrue( numpy.linalg.norm(sn[1]-[0.,0.70710678118654746,0.70710678118654746]) < self.EPS, "wrong bottom vertex 1 ")
1255        dv=f.getDepthVectors(1)        dv=f.getDepthVectors(1)
1256        self.failUnless( len(dv) == 3, "wrong number of depth vectors.")        self.assertTrue( len(dv) == 3, "wrong number of depth vectors.")
1257        self.failUnless( isinstance(dv[0], numpy.ndarray), "wrong class of depth vector 0")        self.assertTrue( isinstance(dv[0], numpy.ndarray), "wrong class of depth vector 0")
1258        self.failUnless( numpy.linalg.norm(dv[0]-[14.142135623730951, 0., -14.142135623730951]) < self.EPS, "wrong depth vector 0 ")        self.assertTrue( numpy.linalg.norm(dv[0]-[14.142135623730951, 0., -14.142135623730951]) < self.EPS, "wrong depth vector 0 ")
1259        self.failUnless( isinstance(dv[1], numpy.ndarray), "wrong class of depth vector 1")        self.assertTrue( isinstance(dv[1], numpy.ndarray), "wrong class of depth vector 1")
1260        self.failUnless( numpy.linalg.norm(dv[1]-[11.547005383792515,11.547005383792515, -11.547005383792515]) < self.EPS, "wrong depth vector 2 ")        self.assertTrue( numpy.linalg.norm(dv[1]-[11.547005383792515,11.547005383792515, -11.547005383792515]) < self.EPS, "wrong depth vector 2 ")
1261        self.failUnless( isinstance(dv[2], numpy.ndarray), "wrong class of depth vector 1")        self.assertTrue( isinstance(dv[2], numpy.ndarray), "wrong class of depth vector 1")
1262        self.failUnless( numpy.linalg.norm(dv[2]-[0.,14.142135623730951, -14.142135623730951]) < self.EPS, "wrong depth vector 2 ")        self.assertTrue( numpy.linalg.norm(dv[2]-[0.,14.142135623730951, -14.142135623730951]) < self.EPS, "wrong depth vector 2 ")
1263        segs=f.getBottomPolyline(1)        segs=f.getBottomPolyline(1)
1264        self.failUnless( len(segs) == 3, "wrong number of segments")        self.assertTrue( len(segs) == 3, "wrong number of segments")
1265        self.failUnless( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")        self.assertTrue( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")
1266        self.failUnless( segs[0].size == 3, "seg 0 has wrong size.")        self.assertTrue( segs[0].size == 3, "seg 0 has wrong size.")
1267        self.failUnless( numpy.linalg.norm(segs[0]-[24.142135623730951,0.,-14.142135623730951]) < self.EPS, "wrong vertex. 0 ")        self.assertTrue( numpy.linalg.norm(segs[0]-[24.142135623730951,0.,-14.142135623730951]) < self.EPS, "wrong vertex. 0 ")
1268        self.failUnless( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1")        self.assertTrue( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1")
1269        self.failUnless( segs[1].size == 3, "seg 1 has wrong size.")        self.assertTrue( segs[1].size == 3, "seg 1 has wrong size.")
1270        self.failUnless( numpy.linalg.norm(segs[1]-[21.547005383792515,21.547005383792515, -11.547005383792515]) < self.EPS, "wrong vertex. 1 ")        self.assertTrue( numpy.linalg.norm(segs[1]-[21.547005383792515,21.547005383792515, -11.547005383792515]) < self.EPS, "wrong vertex. 1 ")
1271        self.failUnless( isinstance(segs[2], numpy.ndarray), "wrong class of vertex 2")        self.assertTrue( isinstance(segs[2], numpy.ndarray), "wrong class of vertex 2")
1272        self.failUnless( segs[2].size == 3, "seg 2 has wrong size.")        self.assertTrue( segs[2].size == 3, "seg 2 has wrong size.")
1273        self.failUnless( numpy.linalg.norm(segs[2]-[0., 24.142135623730951, -14.142135623730951]) < self.EPS, "wrong vertex. 2 ")        self.assertTrue( numpy.linalg.norm(segs[2]-[0., 24.142135623730951, -14.142135623730951]) < self.EPS, "wrong vertex. 2 ")
1274        self.failUnless( abs(0.-f.getW0Range(1)[0]) <=self.EPS," wrong W0 range (0)")        self.assertTrue( abs(0.-f.getW0Range(1)[0]) <=self.EPS," wrong W0 range (0)")
1275        self.failUnless( abs(31.857329272664341-f.getW0Range(1)[1]) <=self.EPS," wrong W0 range (1)")        self.assertTrue( abs(31.857329272664341-f.getW0Range(1)[1]) <=self.EPS," wrong W0 range (1)")
1276        self.failUnless( abs(-20. - f.getW1Range(1)[0]) <=self.EPS," wrong W1 range (0)")        self.assertTrue( abs(-20. - f.getW1Range(1)[0]) <=self.EPS," wrong W1 range (0)")
1277        self.failUnless( abs(0. - f.getW1Range(1)[1]) <=self.EPS," wrong W1 range (1)")        self.assertTrue( abs(0. - f.getW1Range(1)[1]) <=self.EPS," wrong W1 range (1)")
1278        self.failUnless( abs(0.0-f.getW0Offsets(1)[0])<=self.EPS," wrong W0 offsets (0)")        self.assertTrue( abs(0.0-f.getW0Offsets(1)[0])<=self.EPS," wrong W0 offsets (0)")
1279        self.failUnless( abs(15.92866463633217-f.getW0Offsets(1)[1])<=self.EPS," wrong W0 offsets (1)")        self.assertTrue( abs(15.92866463633217-f.getW0Offsets(1)[1])<=self.EPS," wrong W0 offsets (1)")
1280        self.failUnless( abs(31.857329272664341-f.getW0Offsets(1)[2])<=self.EPS," wrong W0 offsets(2)")        self.assertTrue( abs(31.857329272664341-f.getW0Offsets(1)[2])<=self.EPS," wrong W0 offsets(2)")
1281        #        #
1282        #    ============ fresh start ====================        #    ============ fresh start ====================
1283        #        #
1284        f.addFault(V0=[1.,0,0.],strikes=[pi/2, pi],ls=[1.,1.], dips=pi/2,depths=20,tag=1)        f.addFault(V0=[1.,0,0.],strikes=[pi/2, pi],ls=[1.,1.], dips=pi/2,depths=20,tag=1)
1285        f.addFault(V0=[10.,0,0],strikes=[3.*pi/4],ls=[14.142135623730951], tag=2, w0_offsets=[0,20], w1_max=20, dips=pi/2,depths=20)        f.addFault(V0=[10.,0,0],strikes=[3.*pi/4],ls=[14.142135623730951], tag=2, w0_offsets=[0,20], w1_max=20, dips=pi/2,depths=20)
1286        c=f.getCenterOnSurface()        c=f.getCenterOnSurface()
1287        self.failUnless( isinstance(c, numpy.ndarray), "center has wrong class")        self.assertTrue( isinstance(c, numpy.ndarray), "center has wrong class")
1288        self.failUnless( c.size == 3, "center size is wrong")        self.assertTrue( c.size == 3, "center size is wrong")
1289        self.failUnless( numpy.linalg.norm(c-[12./5.,12./5.,0.]) < self.EPS, "center has wrong coordinates.")        self.assertTrue( numpy.linalg.norm(c-[12./5.,12./5.,0.]) < self.EPS, "center has wrong coordinates.")
1290        o=f.getOrientationOnSurface()/pi*180.        o=f.getOrientationOnSurface()/pi*180.
1291        self.failUnless( abs(o+45.) < self.EPS, "wrong orientation.")        self.assertTrue( abs(o+45.) < self.EPS, "wrong orientation.")
1292    
1293        f.transform(rot=-pi/2., shift=[-1.,-1.,0.])        f.transform(rot=-pi/2., shift=[-1.,-1.,0.])
1294        self.failUnless( [ 1, 2 ] == f.getTags(), "tags after transformation wrong")        self.assertTrue( [ 1, 2 ] == f.getTags(), "tags after transformation wrong")
1295        self.failUnless(  2. == f.getTotalLength(1), "length after transformation wrong")        self.assertTrue(  2. == f.getTotalLength(1), "length after transformation wrong")
1296        self.failUnless(  20. == f.getMediumDepth(1), "depth after transformation wrong")        self.assertTrue(  20. == f.getMediumDepth(1), "depth after transformation wrong")
1297        rw0=f.getW0Range(1)        rw0=f.getW0Range(1)
1298        self.failUnless( len(rw0) ==2, "wo range has wrong length")        self.assertTrue( len(rw0) ==2, "wo range has wrong length")
1299        self.failUnless( abs(rw0[0]) < self.EPS,"W0 0 wrong.")        self.assertTrue( abs(rw0[0]) < self.EPS,"W0 0 wrong.")
1300        self.failUnless( abs(rw0[1]-2.) < self.EPS,"W0 1 wrong.")        self.assertTrue( abs(rw0[1]-2.) < self.EPS,"W0 1 wrong.")
1301        self.failUnless( (-20., 0.) ==  f.getW1Range(1)," wrong W1 rangeafter transformation ")        self.assertTrue( (-20., 0.) ==  f.getW1Range(1)," wrong W1 rangeafter transformation ")
1302        dips=f.getDips(1)        dips=f.getDips(1)
1303        self.failUnless(len(dips) == 2, "wrong number of dips.")        self.assertTrue(len(dips) == 2, "wrong number of dips.")
1304        self.failUnless( abs(dips[0]-1.5707963267948966) <= self.EPS, "wrong dip")        self.assertTrue( abs(dips[0]-1.5707963267948966) <= self.EPS, "wrong dip")
1305        self.failUnless( abs(dips[1]-1.5707963267948966) <= self.EPS, "wrong dip")        self.assertTrue( abs(dips[1]-1.5707963267948966) <= self.EPS, "wrong dip")
1306        ds=f.getDepths(1)        ds=f.getDepths(1)
1307        self.failUnless( len(ds) == 3, "wrong number of depth")        self.assertTrue( len(ds) == 3, "wrong number of depth")
1308        self.failUnless( abs(ds[0]-20.) < self.EPS, "wrong depth at vertex 0 ")        self.assertTrue( abs(ds[0]-20.) < self.EPS, "wrong depth at vertex 0 ")
1309        self.failUnless( abs(ds[1]-20.) < self.EPS, "wrong depth at vertex 1 ")        self.assertTrue( abs(ds[1]-20.) < self.EPS, "wrong depth at vertex 1 ")
1310        self.failUnless( abs(ds[2]-20.) < self.EPS, "wrong depth at vertex 1 ")        self.assertTrue( abs(ds[2]-20.) < self.EPS, "wrong depth at vertex 1 ")
1311        segs=f.getTopPolyline(1)        segs=f.getTopPolyline(1)
1312        self.failUnless( len(segs) == 3, "wrong number of segmentsafter transformation ")        self.assertTrue( len(segs) == 3, "wrong number of segmentsafter transformation ")
1313        self.failUnless( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0 after transformation")        self.assertTrue( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0 after transformation")
1314        self.failUnless( segs[0].size == 3, "seg 0 has wrong size after transformation.")        self.assertTrue( segs[0].size == 3, "seg 0 has wrong size after transformation.")
1315        self.failUnless( numpy.linalg.norm(segs[0]-[-1.,0.,0.]) < self.EPS, "wrong vertex. 0  after transformation")        self.assertTrue( numpy.linalg.norm(segs[0]-[-1.,0.,0.]) < self.EPS, "wrong vertex. 0  after transformation")
1316        self.failUnless( isinstance(segs[1], numpy.ndarray), "wrong class of vertex  after transformation1")        self.assertTrue( isinstance(segs[1], numpy.ndarray), "wrong class of vertex  after transformation1")
1317        self.failUnless( segs[1].size == 3, "seg 1 has wrong size after transformation.")        self.assertTrue( segs[1].size == 3, "seg 1 has wrong size after transformation.")
1318        self.failUnless( numpy.linalg.norm(segs[1]-[0.,0.,0.]) < self.EPS, "wrong vertex.  after transformation1 ")        self.assertTrue( numpy.linalg.norm(segs[1]-[0.,0.,0.]) < self.EPS, "wrong vertex.  after transformation1 ")
1319        self.failUnless( isinstance(segs[2], numpy.ndarray), "wrong class of vertex  after transformation2")        self.assertTrue( isinstance(segs[2], numpy.ndarray), "wrong class of vertex  after transformation2")
1320        self.failUnless( segs[2].size == 3, "seg 2 has wrong size after transformation.")        self.assertTrue( segs[2].size == 3, "seg 2 has wrong size after transformation.")
1321        self.failUnless( numpy.linalg.norm(segs[2]-[0., 1.,0.]) < self.EPS, "wrong vertex after transformation. 2 ")        self.assertTrue( numpy.linalg.norm(segs[2]-[0., 1.,0.]) < self.EPS, "wrong vertex after transformation. 2 ")
1322        self.failUnless(  abs(f.getTotalLength(2)-14.1421356237) < self.EPS * 14.1421356237, "wrong length after transformation")        self.assertTrue(  abs(f.getTotalLength(2)-14.1421356237) < self.EPS * 14.1421356237, "wrong length after transformation")
1323        self.failUnless(  20. == f.getMediumDepth(2), "depth wrong after transformation")        self.assertTrue(  20. == f.getMediumDepth(2), "depth wrong after transformation")
1324        rw0=f.getW0Range(2)        rw0=f.getW0Range(2)
1325        self.failUnless( len(rw0) ==2, "wo range has wrong length")        self.assertTrue( len(rw0) ==2, "wo range has wrong length")
1326        self.failUnless( abs(rw0[0]) < self.EPS,"W0 0 wrong.")        self.assertTrue( abs(rw0[0]) < self.EPS,"W0 0 wrong.")
1327        self.failUnless( abs(rw0[1]-20.) < self.EPS,"W0 1 wrong.")        self.assertTrue( abs(rw0[1]-20.) < self.EPS,"W0 1 wrong.")
1328        self.failUnless( (-20., 0.) ==  f.getW1Range(2)," wrong W1 range after transformation")        self.assertTrue( (-20., 0.) ==  f.getW1Range(2)," wrong W1 range after transformation")
1329        self.failUnless( [0., 20.] ==  f.getW0Offsets(2)," wrong W0 offsets after transformation")        self.assertTrue( [0., 20.] ==  f.getW0Offsets(2)," wrong W0 offsets after transformation")
1330        dips=f.getDips(2)        dips=f.getDips(2)
1331        self.failUnless(len(dips) == 1, "wrong number of dips.")        self.assertTrue(len(dips) == 1, "wrong number of dips.")
1332        self.failUnless( abs(dips[0]-1.5707963267948966) <= self.EPS, "wrong dip")        self.assertTrue( abs(dips[0]-1.5707963267948966) <= self.EPS, "wrong dip")
1333        ds=f.getDepths(2)        ds=f.getDepths(2)
1334        self.failUnless( len(ds) == 2, "wrong number of depth")        self.assertTrue( len(ds) == 2, "wrong number of depth")
1335        self.failUnless( abs(ds[0]-20.) < self.EPS, "wrong depth at vertex 0 ")        self.assertTrue( abs(ds[0]-20.) < self.EPS, "wrong depth at vertex 0 ")
1336        self.failUnless( abs(ds[1]-20.) < self.EPS, "wrong depth at vertex 1 ")        self.assertTrue( abs(ds[1]-20.) < self.EPS, "wrong depth at vertex 1 ")
1337        segs=f.getTopPolyline(2)        segs=f.getTopPolyline(2)
1338        self.failUnless( len(segs) == 2, "wrong number of segments after transformation")        self.assertTrue( len(segs) == 2, "wrong number of segments after transformation")
1339        self.failUnless( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0 after transformation")        self.assertTrue( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0 after transformation")
1340        self.failUnless( numpy.linalg.norm(segs[0]-[-1.,-9,0.]) < self.EPS, "wrong vertex. 0  after transformation")        self.assertTrue( numpy.linalg.norm(segs[0]-[-1.,-9,0.]) < self.EPS, "wrong vertex. 0  after transformation")
1341        self.failUnless( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1 after transformation")        self.assertTrue( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1 after transformation")
1342        self.failUnless( numpy.linalg.norm(segs[1]-[9.,1.,0.]) < self.EPS, "wrong vertex. 1  after transformation")        self.assertTrue( numpy.linalg.norm(segs[1]-[9.,1.,0.]) < self.EPS, "wrong vertex. 1  after transformation")
1343        #        #
1344        #    ============ fresh start ====================        #    ============ fresh start ====================
1345        #        #
# Line 1350  class Test_FaultSystem(unittest.TestCase Line 1351  class Test_FaultSystem(unittest.TestCase
1351        f.addFault(V0=[10.,0.,0.],strikes=[pi/2, pi],ls=[10.,10.],tag=2, dips=pi/4, depths=20.)        f.addFault(V0=[10.,0.,0.],strikes=[pi/2, pi],ls=[10.,10.],tag=2, dips=pi/4, depths=20.)
1352    
1353        p,m=f.getParametrization([0.3,0.,-0.5],1)        p,m=f.getParametrization([0.3,0.,-0.5],1)
1354        self.failUnless(length(p-[0.3,-0.5]) <= self.EPS, "wrong value.")        self.assertTrue(length(p-[0.3,-0.5]) <= self.EPS, "wrong value.")
1355        self.failUnless(m==1., "wrong value.")        self.assertTrue(m==1., "wrong value.")
1356    
1357        p,m=f.getParametrization([0.5,0.,-0.5],1)        p,m=f.getParametrization([0.5,0.,-0.5],1)
1358        self.failUnless(length(p-[0.5,-0.5]) <= self.EPS, "wrong value.")        self.assertTrue(length(p-[0.5,-0.5]) <= self.EPS, "wrong value.")
1359        self.failUnless(m==1., "wrong value.")        self.assertTrue(m==1., "wrong value.")
1360    
1361        p,m=f.getParametrization([0.25,0.,-0.5],1)        p,m=f.getParametrization([0.25,0.,-0.5],1)
1362        self.failUnless(length(p-[0.25,-0.5]) <= self.EPS, "wrong value.")        self.assertTrue(length(p-[0.25,-0.5]) <= self.EPS, "wrong value.")
1363        self.failUnless(m==1., "wrong value.")        self.assertTrue(m==1., "wrong value.")
1364    
1365        p,m=f.getParametrization([0.5,0.,-0.25],1)        p,m=f.getParametrization([0.5,0.,-0.25],1)
1366        self.failUnless(length(p-[0.5,-0.25]) <= self.EPS, "wrong value.")        self.assertTrue(length(p-[0.5,-0.25]) <= self.EPS, "wrong value.")
1367        self.failUnless(m==1., "wrong value.")        self.assertTrue(m==1., "wrong value.")
1368    
1369        p,m=f.getParametrization([0.001,0.,-0.001],1)        p,m=f.getParametrization([0.001,0.,-0.001],1)
1370        self.failUnless(length(p-[0.001, -0.001]) <= self.EPS, "wrong value.")        self.assertTrue(length(p-[0.001, -0.001]) <= self.EPS, "wrong value.")
1371        self.failUnless(m==1., "wrong value.")        self.assertTrue(m==1., "wrong value.")
1372    
1373        p,m=f.getParametrization([0.001,0.,0.001],1)        p,m=f.getParametrization([0.001,0.,0.001],1)
1374        self.failUnless(m==0., "wrong value.")        self.assertTrue(m==0., "wrong value.")
1375    
1376        p,m=f.getParametrization([0.999,0.,0.001],1)        p,m=f.getParametrization([0.999,0.,0.001],1)
1377        self.failUnless(m==0., "wrong value.")        self.assertTrue(m==0., "wrong value.")
1378    
1379        p,m=f.getParametrization([1.001,0.,-0.001],1)        p,m=f.getParametrization([1.001,0.,-0.001],1)
1380        self.failUnless(m==0., "wrong value.")        self.assertTrue(m==0., "wrong value.")
1381        p,m=f.getParametrization([1.001,0.,-0.1],1)        p,m=f.getParametrization([1.001,0.,-0.1],1)
1382        self.failUnless(m==0., "wrong value.")        self.assertTrue(m==0., "wrong value.")
1383        p,m=f.getParametrization([1.001,0.,-0.000000001],1)        p,m=f.getParametrization([1.001,0.,-0.000000001],1)
1384        self.failUnless(m==0., "wrong value.")        self.assertTrue(m==0., "wrong value.")
1385    
1386        p,m=f.getParametrization([0.999,0.,-0.001],1)        p,m=f.getParametrization([0.999,0.,-0.001],1)
1387        self.failUnless(length(p-[0.999, -0.001]) <= self.EPS, "wrong value.")        self.assertTrue(length(p-[0.999, -0.001]) <= self.EPS, "wrong value.")
1388        self.failUnless(m==1., "wrong value.")        self.assertTrue(m==1., "wrong value.")
1389    
1390        p,m=f.getParametrization([ 16.29252873 , 6.46410161 ,-6.29252873], 2, tol=1.e-7)        p,m=f.getParametrization([ 16.29252873 , 6.46410161 ,-6.29252873], 2, tol=1.e-7)
1391        self.failUnless(m==1., "wrong value.")        self.assertTrue(m==1., "wrong value.")
1392        self.failUnless(length(p-[4.7785993908996511, -10]) <= self.EPS*10., "wrong value.")        self.assertTrue(length(p-[4.7785993908996511, -10]) <= self.EPS*10., "wrong value.")
1393        p,m=f.getParametrization([15.77350269, 12.77350269, -5.77350269], 2, tol=1.e-7)        p,m=f.getParametrization([15.77350269, 12.77350269, -5.77350269], 2, tol=1.e-7)
1394        self.failUnless(m==1., "wrong value.")        self.assertTrue(m==1., "wrong value.")
1395        self.failUnless(length(p-[11.150065245432518, -10]) <= self.EPS*10., "wrong value.")        self.assertTrue(length(p-[11.150065245432518, -10]) <= self.EPS*10., "wrong value.")
1396    
1397        p,m=f.getParametrization([  3., 17.0710678, -7.0710678], 2, tol=1.e-7)        p,m=f.getParametrization([  3., 17.0710678, -7.0710678], 2, tol=1.e-7)
1398        self.failUnless(m==1., "wrong value.")        self.assertTrue(m==1., "wrong value.")
1399        self.failUnless(length(p-[27.078729881764687, -10]) <= self.EPS*10., "wrong value.")        self.assertTrue(length(p-[27.078729881764687, -10]) <= self.EPS*10., "wrong value.")
1400        p,m=f.getParametrization([9.30940108, 16.55204176, -6.55204176], 2, tol=1.e-7)        p,m=f.getParametrization([9.30940108, 16.55204176, -6.55204176], 2, tol=1.e-7)
1401        self.failUnless(m==1., "wrong value.")        self.assertTrue(m==1., "wrong value.")
1402        self.failUnless(length(p-[20.707264027231822, -10]) <= self.EPS*10., "wrong value.")        self.assertTrue(length(p-[20.707264027231822, -10]) <= self.EPS*10., "wrong value.")
1403    
1404        p,m=f.getParametrization([ 21.54700538,  21.54700538, -11.54700538], 2, tol=1.e-7)        p,m=f.getParametrization([ 21.54700538,  21.54700538, -11.54700538], 2, tol=1.e-7)
1405        self.failUnless(m==1., "wrong value.")        self.assertTrue(m==1., "wrong value.")
1406        self.failUnless(length(p-[15.92866463633217, -20]) <= self.EPS*10., "wrong value.")        self.assertTrue(length(p-[15.92866463633217, -20]) <= self.EPS*10., "wrong value.")
1407    
1408        p,m=f.getParametrization([ 0.,0.,0.], 2, tol=1.e-7)        p,m=f.getParametrization([ 0.,0.,0.], 2, tol=1.e-7)
1409        self.failUnless(m==0., "wrong value.")        self.assertTrue(m==0., "wrong value.")
1410    
1411        p,m=f.getParametrization([ 11.,11.,0.], 2, tol=1.e-7)        p,m=f.getParametrization([ 11.,11.,0.], 2, tol=1.e-7)
1412        self.failUnless(m==0., "wrong value.")        self.assertTrue(m==0., "wrong value.")
1413    
1414    
1415        s,d=f.getSideAndDistance([0.,-1.,0.], tag=1)        s,d=f.getSideAndDistance([0.,-1.,0.], tag=1)
1416        self.failUnless( s>0, "wrong side.")        self.assertTrue( s>0, "wrong side.")
1417        self.failUnless( abs(d-1.)<self.EPS, "wrong distance.")        self.assertTrue( abs(d-1.)<self.EPS, "wrong distance.")
1418        s,d=f.getSideAndDistance([1.,-1.,0.], tag=1)        s,d=f.getSideAndDistance([1.,-1.,0.], tag=1)
1419        self.failUnless( s>0, "wrong side.")        self.assertTrue( s>0, "wrong side.")
1420        self.failUnless( abs(d-1.)<self.EPS, "wrong distance.")        self.assertTrue( abs(d-1.)<self.EPS, "wrong distance.")
1421        s,d=f.getSideAndDistance([0.,1.,0.], tag=1)        s,d=f.getSideAndDistance([0.,1.,0.], tag=1)
1422        self.failUnless( s<0, "wrong side.")        self.assertTrue( s<0, "wrong side.")
1423        self.failUnless( abs(d-1.)<self.EPS, "wrong distance.")        self.assertTrue( abs(d-1.)<self.EPS, "wrong distance.")
1424        s,d=f.getSideAndDistance([1.,1.,0.], tag=1)        s,d=f.getSideAndDistance([1.,1.,0.], tag=1)
1425        self.failUnless( s<0, "wrong side.")        self.assertTrue( s<0, "wrong side.")
1426        self.failUnless( abs(d-1.)<self.EPS, "wrong distance.")        self.assertTrue( abs(d-1.)<self.EPS, "wrong distance.")
1427    
1428            
1429        s,d=f.getSideAndDistance([0.,0.,0.], tag=2)        s,d=f.getSideAndDistance([0.,0.,0.], tag=2)
1430        self.failUnless( s<0, "wrong side.")        self.assertTrue( s<0, "wrong side.")
1431        self.failUnless( abs(d-10.)<self.EPS, "wrong distance.")        self.assertTrue( abs(d-10.)<self.EPS, "wrong distance.")
1432        s,d=f.getSideAndDistance([5.,5.,0.], tag=2)        s,d=f.getSideAndDistance([5.,5.,0.], tag=2)
1433        self.failUnless( s<0, "wrong side.")        self.assertTrue( s<0, "wrong side.")
1434        self.failUnless( abs(d-5.)<self.EPS, "wrong distance.")        self.assertTrue( abs(d-5.)<self.EPS, "wrong distance.")
1435    
1436        s,d=f.getSideAndDistance([10.,10.,-1.], tag=2)        s,d=f.getSideAndDistance([10.,10.,-1.], tag=2)
1437        self.failUnless( s<0, "wrong side.")        self.assertTrue( s<0, "wrong side.")
1438        self.failUnless( abs(d-0.70710678118654757)<self.EPS, "wrong distance.")        self.assertTrue( abs(d-0.70710678118654757)<self.EPS, "wrong distance.")
1439        s,d=f.getSideAndDistance([10.,10.,-2.], tag=2)        s,d=f.getSideAndDistance([10.,10.,-2.], tag=2)
1440        self.failUnless( s<0, "wrong side.")        self.assertTrue( s<0, "wrong side.")
1441        self.failUnless( abs(d-2.*0.70710678118654757)<self.EPS, "wrong distance.")        self.assertTrue( abs(d-2.*0.70710678118654757)<self.EPS, "wrong distance.")
1442        s,d=f.getSideAndDistance([10.,10.,-3.], tag=2)        s,d=f.getSideAndDistance([10.,10.,-3.], tag=2)
1443        self.failUnless( s<0, "wrong side.")        self.assertTrue( s<0, "wrong side.")
1444        self.failUnless( abs(d-3.*0.70710678118654757)<self.EPS, "wrong distance.")        self.assertTrue( abs(d-3.*0.70710678118654757)<self.EPS, "wrong distance.")
1445    
1446        s,d=f.getSideAndDistance([5.,12.,0], tag=2)        s,d=f.getSideAndDistance([5.,12.,0], tag=2)
1447        self.failUnless( s>0, "wrong side.")        self.assertTrue( s>0, "wrong side.")
1448        self.failUnless( abs(d-2*0.70710678118654757)<self.EPS, "wrong distance.")        self.assertTrue( abs(d-2*0.70710678118654757)<self.EPS, "wrong distance.")
1449        s,d=f.getSideAndDistance([5.,12.,-1], tag=2)        s,d=f.getSideAndDistance([5.,12.,-1], tag=2)
1450        self.failUnless( s>0, "wrong side.")        self.assertTrue( s>0, "wrong side.")
1451        self.failUnless( abs(d-0.70710678118654757)<self.EPS, "wrong distance.")        self.assertTrue( abs(d-0.70710678118654757)<self.EPS, "wrong distance.")
1452        s,d=f.getSideAndDistance([5.,12.,-2], tag=2)        s,d=f.getSideAndDistance([5.,12.,-2], tag=2)
1453        # s not checked as it is undefined.        # s not checked as it is undefined.
1454        self.failUnless( abs(d)<self.EPS, "wrong distance.")        self.assertTrue( abs(d)<self.EPS, "wrong distance.")
1455        s,d=f.getSideAndDistance([5.,12.,-3], tag=2)        s,d=f.getSideAndDistance([5.,12.,-3], tag=2)
1456        self.failUnless( s<0, "wrong side.")        self.assertTrue( s<0, "wrong side.")
1457        self.failUnless( abs(d-0.70710678118654757)<self.EPS, "wrong distance.")        self.assertTrue( abs(d-0.70710678118654757)<self.EPS, "wrong distance.")
1458        s,d=f.getSideAndDistance([5.,12.,-4], tag=2)        s,d=f.getSideAndDistance([5.,12.,-4], tag=2)
1459        self.failUnless( s<0, "wrong side.")        self.assertTrue( s<0, "wrong side.")
1460        self.failUnless( abs(d-2.*0.70710678118654757)<self.EPS, "wrong distance.")        self.assertTrue( abs(d-2.*0.70710678118654757)<self.EPS, "wrong distance.")
1461    
1462  if __name__ == '__main__':  if __name__ == '__main__':
1463     suite = unittest.TestSuite()     suite = unittest.TestSuite()

Legend:
Removed from v.3528  
changed lines
  Added in v.3981

  ViewVC Help
Powered by ViewVC 1.1.26