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

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

  ViewVC Help
Powered by ViewVC 1.1.26