/[escript]/branches/trilinos_from_5897/dudley/test/python/run_models.py
ViewVC logotype

Contents of /branches/trilinos_from_5897/dudley/test/python/run_models.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6079 - (show annotations)
Mon Mar 21 12:22:38 2016 UTC (2 years, 10 months ago) by caltinay
File MIME type: text/x-python
File size: 62489 byte(s)
Big commit - making dudley much more like finley to make it more
managable. Fixed quite a few issues that had been fixed in finley.
Disposed of all ReducedNode/ReducedDOF entities that dudley never supported.
Compiles and passes tests.

1 # -*- coding: utf-8 -*-
2
3 ##############################################################################
4 #
5 # Copyright (c) 2003-2016 by The University of Queensland
6 # http://www.uq.edu.au
7 #
8 # Primary Business: Queensland, Australia
9 # Licensed under the Open Software License version 3.0
10 # 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 from __future__ import print_function, division
18
19 __copyright__="""Copyright (c) 2003-2016 by The University of Queensland
20 http://www.uq.edu.au
21 Primary Business: Queensland, Australia"""
22 __license__="""Licensed under the Open Software License version 3.0
23 http://www.opensource.org/licenses/osl-3.0.php"""
24 __url__="https://launchpad.net/escript-finley"
25
26 import esys.escriptcore.utestselect as unittest
27 from esys.escriptcore.testing import *
28
29 VERBOSE = False
30
31 from esys.escript import *
32 from esys.escript.models import PowerLaw, FaultSystem, DarcyFlow
33 from esys.dudley import Rectangle, Brick
34
35 from math import pi
36 import numpy, os, sys, tempfile
37
38
39 class Darcy(unittest.TestCase): #subclassing required
40 # this is a simple test for the darcy flux problem
41 #
42 #
43 # p = 1/k * ( 1/2* (fb-f0)/xb* x **2 + f0 * x - ub*x ) + p0
44 #
45 # with f = (fb-f0)/xb* x + f0
46 #
47 # u = f - k * p,x = ub
48 #
49 # we prescribe pressure at x=x0=0 to p0
50 #
51 # if we prescribe the pressure on the bottom x=xb we set
52 #
53 # pb= 1/k * ( 1/2* (fb-f0)* xb + f0 * xb - ub*xb ) + p0 = 1/k * ((fb+f0)/2 - ub ) * xb + p0
54 #
55 # which leads to ub = (fb+f0)/2-k*(pb-p0)/xb
56 #
57 def rescaleDomain(self):
58 x=self.dom.getX().copy()
59 for i in range(self.dom.getDim()):
60 x_inf=inf(x[i])
61 x_sup=sup(x[i])
62 if i == self.dom.getDim()-1:
63 x[i]=-self.WIDTH*(x[i]-x_sup)/(x_inf-x_sup)
64 else:
65 x[i]=self.WIDTH*(x[i]-x_inf)/(x_sup-x_inf)
66 self.dom.setX(x)
67 def getScalarMask(self,include_bottom=True):
68 x=self.dom.getX().copy()
69 x_inf=inf(x[self.dom.getDim()-1])
70 x_sup=sup(x[self.dom.getDim()-1])
71 out=whereZero(x[self.dom.getDim()-1]-x_sup)
72 if include_bottom: out+=whereZero(x[self.dom.getDim()-1]-x_inf)
73 return wherePositive(out)
74 def getVectorMask(self,include_bottom=True):
75 x=self.dom.getX().copy()
76 out=Vector(0.,Solution(self.dom))
77 for i in range(self.dom.getDim()):
78 x_inf=inf(x[i])
79 x_sup=sup(x[i])
80 if i != self.dom.getDim()-1: out[i]+=whereZero(x[i]-x_sup)
81 if i != self.dom.getDim()-1 or include_bottom: out[i]+=whereZero(x[i]-x_inf)
82 return wherePositive(out)
83
84 def setSolutionFixedBottom(self, p0, pb, f0, fb, k):
85 d=self.dom.getDim()
86 x=self.dom.getX()[d-1]
87 xb=inf(x)
88 u=Vector(0.,Solution(self.dom))+kronecker(d)[d-1]*((f0+fb)/2.-k*(pb-p0)/xb)
89 p=1./k*((fb-f0)/(xb*2.)* x**2 - (fb-f0)/2.*x)+(pb-p0)/xb*x + p0
90 f= ((fb-f0)/xb* x + f0)*kronecker(Function(self.dom))[d-1]
91 return u,p,f
92
93 def testConstF_FixedBottom_smallK(self):
94 k=1.e-10
95 mp=self.getScalarMask(include_bottom=True)
96 mv=self.getVectorMask(include_bottom=False)
97 u_ref,p_ref,f=self.setSolutionFixedBottom(p0=2500,pb=4000.,f0=10.,fb=10.,k=k)
98 p=p_ref*mp
99 u=u_ref*mv
100 df=DarcyFlow(self.dom)
101 df.setValue(g=f,
102 location_of_fixed_pressure=mp,
103 location_of_fixed_flux=mv,
104 permeability=Scalar(k,Function(self.dom)))
105 #df.setTolerance(rtol=self.TOL)
106 v,p=df.solve(u_ref,p)
107 self.assertTrue(Lsup(v-u_ref)<self.TEST_TOL*Lsup(u_ref), "flux error too big.")
108 self.assertTrue(Lsup(p-p_ref)<self.TEST_TOL*Lsup(p_ref), "pressure error too big.")
109 def testConstF_FixedBottom_mediumK(self):
110 k=1.
111 mp=self.getScalarMask(include_bottom=True)
112 mv=self.getVectorMask(include_bottom=False)
113 u_ref,p_ref,f=self.setSolutionFixedBottom(p0=2500,pb=4000.,f0=10.,fb=10.,k=k)
114 p=p_ref*mp
115 u=u_ref*mv
116 df=DarcyFlow(self.dom)
117 df.setValue(g=f,
118 location_of_fixed_pressure=mp,
119 location_of_fixed_flux=mv,
120 permeability=Scalar(k,Function(self.dom)))
121 #df.setTolerance(rtol=self.TOL)
122 v,p=df.solve(u,p )
123 self.assertTrue(Lsup(p-p_ref)<self.TEST_TOL*Lsup(p_ref), "pressure error too big.")
124 self.assertTrue(Lsup(v-u_ref)<self.TEST_TOL*Lsup(u_ref), "flux error too big.")
125
126 def testConstF_FixedBottom_largeK(self):
127 k=1.e10
128 mp=self.getScalarMask(include_bottom=True)
129 mv=self.getVectorMask(include_bottom=False)
130 u_ref,p_ref,f=self.setSolutionFixedBottom(p0=2500,pb=4000.,f0=10.,fb=10.,k=k)
131 p=p_ref*mp
132 u=u_ref*mv
133 df=DarcyFlow(self.dom)
134 df.setValue(g=f,
135 location_of_fixed_pressure=mp,
136 location_of_fixed_flux=mv,
137 permeability=Scalar(k,Function(self.dom)))
138 #df.setTolerance(rtol=self.TOL)
139 v,p=df.solve(u,p )
140 self.assertTrue(Lsup(v-u_ref)<self.TEST_TOL*Lsup(u_ref), "flux error too big.")
141 self.assertTrue(Lsup(p-p_ref)<self.TEST_TOL*Lsup(p_ref), "pressure error too big.")
142
143 def testVarioF_FixedBottom_smallK(self):
144 k=1.e-10
145 mp=self.getScalarMask(include_bottom=True)
146 mv=self.getVectorMask(include_bottom=False)
147 u_ref,p_ref,f=self.setSolutionFixedBottom(p0=2500,pb=4000.,f0=10.,fb=30.,k=k)
148 p=p_ref*mp
149 u=u_ref*mv
150 df=DarcyFlow(self.dom)
151 #df.getSolverOptionsPressure().setVerbosityOn()
152 df.setValue(g=f,
153 location_of_fixed_pressure=mp,
154 location_of_fixed_flux=mv,
155 permeability=Scalar(k,Function(self.dom)))
156 #df.setTolerance(rtol=self.TOL)
157 v,p=df.solve(u,p )
158
159 self.assertTrue(Lsup(v-u_ref)<self.TEST_TOL*Lsup(u_ref), "flux error too big.")
160 self.assertTrue(Lsup(p-p_ref)<self.TEST_TOL*Lsup(p_ref), "pressure error too big.")
161
162 def testVarioF_FixedBottom_mediumK(self):
163 k=1.
164 mp=self.getScalarMask(include_bottom=True)
165 mv=self.getVectorMask(include_bottom=False)
166 u_ref,p_ref,f=self.setSolutionFixedBottom(p0=2500,pb=4000.,f0=10.,fb=30.,k=k)
167 p=p_ref*mp
168 u=u_ref*mv
169 df=DarcyFlow(self.dom)
170 df.setValue(g=f,
171 location_of_fixed_pressure=mp,
172 location_of_fixed_flux=mv,
173 permeability=Scalar(k,Function(self.dom)))
174 #df.setTolerance(rtol=self.TOL)
175 v,p=df.solve(u,p )
176 self.assertTrue(Lsup(v-u_ref)<self.TEST_TOL*Lsup(u_ref), "flux error too big.")
177 self.assertTrue(Lsup(p-p_ref)<self.TEST_TOL*Lsup(p_ref), "pressure error too big.")
178
179 def testVarioF_FixedBottom_largeK(self):
180 k=1.e10
181 mp=self.getScalarMask(include_bottom=True)
182 mv=self.getVectorMask(include_bottom=False)
183 u_ref,p_ref,f=self.setSolutionFixedBottom(p0=2500,pb=4000.,f0=10.,fb=30.,k=k)
184 p=p_ref*mp
185 u=u_ref*mv
186 df=DarcyFlow(self.dom)
187 df.setValue(g=f,
188 location_of_fixed_pressure=mp,
189 location_of_fixed_flux=mv,
190 permeability=Scalar(k,Function(self.dom)))
191 #df.setTolerance(rtol=self.TOL)
192 v,p=df.solve(u,p )
193 self.assertTrue(Lsup(v-u_ref)<self.TEST_TOL*Lsup(u_ref), "flux error too big.")
194 self.assertTrue(Lsup(p-p_ref)<self.TEST_TOL*Lsup(p_ref), "pressure error too big.")
195
196 def testConstF_FreeBottom_smallK(self):
197 k=1.e-10
198 mp=self.getScalarMask(include_bottom=False)
199 mv=self.getVectorMask(include_bottom=True)
200 u_ref,p_ref,f=self.setSolutionFixedBottom(p0=2500,pb=4000.,f0=10.,fb=10.,k=k)
201 p=p_ref*mp
202 u=u_ref*mv
203 df=DarcyFlow(self.dom)
204 df.setValue(g=f,
205 location_of_fixed_pressure=mp,
206 location_of_fixed_flux=mv,
207 permeability=Scalar(k,Function(self.dom)))
208 #df.setTolerance(rtol=self.TOL)
209 v,p=df.solve(u,p)
210
211
212 self.assertTrue(Lsup(v-u_ref)<self.TEST_TOL*Lsup(u_ref), "flux error too big.")
213 self.assertTrue(Lsup(p-p_ref)<self.TEST_TOL*Lsup(p_ref), "pressure error too big.")
214
215 def testConstF_FreeBottom_mediumK(self):
216 k=1.
217 mp=self.getScalarMask(include_bottom=False)
218 mv=self.getVectorMask(include_bottom=True)
219 u_ref,p_ref,f=self.setSolutionFixedBottom(p0=2500,pb=4000.,f0=10.,fb=10.,k=k)
220 p=p_ref*mp
221 u=u_ref*mv
222 df=DarcyFlow(self.dom)
223 df.setValue(g=f,
224 location_of_fixed_pressure=mp,
225 location_of_fixed_flux=mv,
226 permeability=Scalar(k,Function(self.dom)))
227 #df.setTolerance(rtol=self.TOL)
228 v,p=df.solve(u,p)
229 self.assertTrue(Lsup(v-u_ref)<self.TEST_TOL*Lsup(u_ref), "flux error too big.")
230 self.assertTrue(Lsup(p-p_ref)<self.TEST_TOL*Lsup(p_ref), "pressure error too big.")
231
232 def testConstF_FreeBottom_largeK(self):
233 k=1.e10
234 mp=self.getScalarMask(include_bottom=False)
235 mv=self.getVectorMask(include_bottom=True)
236 u_ref,p_ref,f=self.setSolutionFixedBottom(p0=2500,pb=4000.,f0=10.,fb=10.,k=k)
237 p=p_ref*mp
238 u=u_ref*mv
239 df=DarcyFlow(self.dom)
240 df.setValue(g=f,
241 location_of_fixed_pressure=mp,
242 location_of_fixed_flux=mv,
243 permeability=Scalar(k,Function(self.dom)))
244 #df.setTolerance(rtol=self.TOL)
245 v,p=df.solve(u,p)
246 self.assertTrue(Lsup(v-u_ref)<self.TEST_TOL*Lsup(u_ref), "flux error too big.")
247 self.assertTrue(Lsup(p-p_ref)<self.TEST_TOL*Lsup(p_ref), "pressure error too big.")
248
249 def testVarioF_FreeBottom_smallK(self):
250 k=1.e-10
251 mp=self.getScalarMask(include_bottom=False)
252 mv=self.getVectorMask(include_bottom=True)
253 u_ref,p_ref,f=self.setSolutionFixedBottom(p0=2500,pb=4000.,f0=10.,fb=30.,k=k)
254 p=p_ref*mp
255 u=u_ref*mv
256 df=DarcyFlow(self.dom)
257 df.setValue(g=f,
258 location_of_fixed_pressure=mp,
259 location_of_fixed_flux=mv,
260 permeability=Scalar(k,Function(self.dom)))
261 #df.setTolerance(rtol=self.TOL)
262 v,p=df.solve(u,p)
263 self.assertTrue(Lsup(v-u_ref)<self.TEST_TOL*Lsup(u_ref), "flux error too big.")
264 self.assertTrue(Lsup(p-p_ref)<self.TEST_TOL*Lsup(p_ref), "pressure error too big.")
265
266 def testVarioF_FreeBottom_mediumK(self):
267 k=1.
268 mp=self.getScalarMask(include_bottom=False)
269 mv=self.getVectorMask(include_bottom=True)
270 u_ref,p_ref,f=self.setSolutionFixedBottom(p0=2500,pb=4000.,f0=10.,fb=30.,k=k)
271 p=p_ref*mp
272 u=u_ref*mv
273 df=DarcyFlow(self.dom)
274 df.setValue(g=f,
275 location_of_fixed_pressure=mp,
276 location_of_fixed_flux=mv,
277 permeability=Scalar(k,Function(self.dom)))
278 #df.setTolerance(rtol=self.TOL)
279 v,p=df.solve(u,p)
280 self.assertTrue(Lsup(v-u_ref)<self.TEST_TOL*Lsup(u_ref), "flux error too big.")
281 self.assertTrue(Lsup(p-p_ref)<self.TEST_TOL*Lsup(p_ref), "pressure error too big.")
282
283 def testVarioF_FreeBottom_largeK(self):
284 k=1.e10
285 mp=self.getScalarMask(include_bottom=False)
286 mv=self.getVectorMask(include_bottom=True)
287 u_ref,p_ref,f=self.setSolutionFixedBottom(p0=2500,pb=4000.,f0=10.,fb=30.,k=k)
288 p=p_ref*mp
289 u=u_ref*mv
290 df=DarcyFlow(self.dom)
291 df.setValue(g=f,
292 location_of_fixed_pressure=mp,
293 location_of_fixed_flux=mv,
294 permeability=Scalar(k,Function(self.dom)))
295 #df.setTolerance(rtol=self.TOL)
296 v,p=df.solve(u,p)
297 self.assertTrue(Lsup(v-u_ref)<self.TEST_TOL*Lsup(u_ref), "flux error too big.")
298 self.assertTrue(Lsup(p-p_ref)<self.TEST_TOL*Lsup(p_ref), "pressure error too big.")
299
300 class Test_Darcy2D(Darcy):
301 TOL=1e-6
302 TEST_TOL=2.e-3
303 WIDTH=1.
304 def setUp(self):
305 NE=40 # wrning smaller NE may case a failure for VarioF tests due to discretization errors.
306 self.dom = Rectangle(NE/2,NE)
307 self.rescaleDomain()
308 def tearDown(self):
309 del self.dom
310
311 class Test_Darcy3D(Darcy):
312 TOL=1e-6
313 WIDTH=1.
314 TEST_TOL=4.e-3
315 def setUp(self):
316 NE=25 # wrning smaller NE may case a failure for VarioF tests due to discretization errors.
317 self.dom = Brick(NE,NE,NE)
318 self.rescaleDomain()
319 def tearDown(self):
320 del self.dom
321
322 class Test_Rheologies(unittest.TestCase):
323 """
324 this is the program used to generate the powerlaw tests:
325
326 TAU_Y=100.
327 N=10
328 M=5
329
330 def getE(tau):
331 if tau<=TAU_Y:
332 return 1./(0.5+20*sqrt(tau))
333 else:
334 raise ValueError,"out of range."
335 tau=[ i* (TAU_Y/N) for i in range(N+1)] + [TAU_Y for i in range(M)]
336 e=[ tau[i]/getE(tau[i]) for i in range(N+1)]
337 e+= [ (i+1+j)* (max(e)/N) for j in range(M) ]
338
339 print tau
340 print e
341 """
342 TOL=1.e-8
343 def test_PowerLaw_Init(self):
344 pl=PowerLaw(numMaterials=3,verbose=VERBOSE)
345
346 self.assertEqual(pl.getNumMaterials(),3,"num materials is wrong")
347 self.assertEqual(pl.validMaterialId(0),True,"material id 0 not found")
348 self.assertEqual(pl.validMaterialId(1),True,"material id 1 not found")
349 self.assertEqual(pl.validMaterialId(2),True,"material id 2 not found")
350 self.assertEqual(pl.validMaterialId(3),False,"material id 3 not found")
351
352 self.assertEqual(pl.getFriction(),None,"initial friction wrong.")
353 self.assertEqual(pl.getTauY(),None,"initial tau y wrong.")
354 pl.setDruckerPragerLaw(tau_Y=10,friction=3)
355 self.assertEqual(pl.getFriction(),3,"friction wrong.")
356 self.assertEqual(pl.getTauY(),10,"tau y wrong.")
357
358 self.assertEqual(pl.getElasticShearModulus(),None,"initial shear modulus is wrong")
359 pl.setElasticShearModulus(1000)
360 self.assertEqual(pl.getElasticShearModulus(),1000.,"shear modulus is wrong")
361
362 e=pl.getEtaN()
363 self.assertEqual(len(e),3,"initial length of etaN is wrong.")
364 self.assertEqual(e,[None, None, None],"initial etaN are wrong.")
365 self.assertEqual(pl.getEtaN(0),None,"initial material id 0 is wrong")
366 self.assertEqual(pl.getEtaN(1),None,"initial material id 1 is wrong")
367 self.assertEqual(pl.getEtaN(2),None,"initial material id 2 is wrong")
368 self.assertRaises(ValueError, pl.getEtaN, 3)
369
370 self.assertRaises(ValueError,pl.setPowerLaws,eta_N=[10,20,30,40],tau_t=[2], power=[5,6,7])
371 self.assertRaises(ValueError,pl.setPowerLaws,eta_N=[10,20,30],tau_t=[2,4,5,5], power=[5,6,7])
372 self.assertRaises(ValueError,pl.setPowerLaws,eta_N=[10,20,30],tau_t=[2,1,2], power=[5,6,7,7])
373
374 pl.setPowerLaws(eta_N=[10,20,30],tau_t=[100,200,300], power=[1,2,3])
375 self.assertEqual(pl.getPower(),[1,2,3],"powers are wrong.")
376 self.assertEqual(pl.getTauT(),[100,200,300],"tau t are wrong.")
377 self.assertEqual(pl.getEtaN(),[10,20,30],"etaN are wrong.")
378
379 pl.setPowerLaw(id=0,eta_N=40,tau_t=400, power=4)
380 self.assertEqual(pl.getPower(),[4,2,3],"powers are wrong.")
381 self.assertEqual(pl.getTauT(),[400,200,300],"tau t are wrong.")
382 self.assertEqual(pl.getEtaN(),[40,20,30],"etaN are wrong.")
383
384 self.assertRaises(ValueError,pl.getPower,-1)
385 self.assertEqual(pl.getPower(0),4,"power 0 is wrong.")
386 self.assertEqual(pl.getPower(1),2,"power 1 is wrong.")
387 self.assertEqual(pl.getPower(2),3,"power 2 is wrong.")
388 self.assertRaises(ValueError,pl.getPower,3)
389
390 self.assertRaises(ValueError,pl.getTauT,-1)
391 self.assertEqual(pl.getTauT(0),400,"tau t 0 is wrong.")
392 self.assertEqual(pl.getTauT(1),200,"tau t 1 is wrong.")
393 self.assertEqual(pl.getTauT(2),300,"tau t 2 is wrong.")
394 self.assertRaises(ValueError,pl.getTauT,3)
395
396 self.assertRaises(ValueError,pl.getEtaN,-1)
397 self.assertEqual(pl.getEtaN(0),40,"eta n 0 is wrong.")
398 self.assertEqual(pl.getEtaN(1),20,"eta n 1 is wrong.")
399 self.assertEqual(pl.getEtaN(2),30,"eta n 2 is wrong.")
400 self.assertRaises(ValueError,pl.getEtaN,3)
401
402 def checkResult(self,id,gamma_dot_, eta, tau_ref):
403 self.assertTrue(eta>=0,"eta needs to be positive (test %s)"%id)
404 error=abs(gamma_dot_*eta-tau_ref)
405 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))
406
407 def test_PowerLaw_Linear(self):
408 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]
409 gamma_dot_s=[0.0, 5.0, 10.0, 15.0, 20.0, 25.0, 30.0, 35.0, 40.0, 45.0, 50.0, 55.0, 60.0, 65.0, 70.0, 75.0]
410 pl=PowerLaw(numMaterials=1,verbose=VERBOSE)
411 pl.setDruckerPragerLaw(tau_Y=100.)
412 pl.setPowerLaw(eta_N=2.)
413 pl.setEtaTolerance(self.TOL)
414 for i in range(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i]),taus[i])
415
416 def test_PowerLaw_QuadLarge(self):
417 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]
418 gamma_dot_s=[0.0, 405.0, 1610.0, 3615.0, 6420.0, 10025.0, 14430.0, 19635.0, 25640.0, 32445.0, 40050.0, 44055.0, 48060.0, 52065.0, 56070.0, 60075.0]
419 pl=PowerLaw(numMaterials=2,verbose=VERBOSE)
420 pl.setDruckerPragerLaw(tau_Y=100.)
421 pl.setPowerLaws(eta_N=[2.,0.01],tau_t=[1, 25.], power=[1,2])
422 pl.setEtaTolerance(self.TOL)
423 for i in range(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i]),taus[i])
424
425 def test_PowerLaw_QuadSmall(self):
426 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]
427 gamma_dot_s=[0.0, 5.4, 11.6, 18.6, 26.4, 35.0, 44.4, 54.6, 65.6, 77.4, 90.0, 99.0, 108.0, 117.0, 126.0, 135.0]
428 pl=PowerLaw(numMaterials=2,verbose=VERBOSE)
429 pl.setDruckerPragerLaw(tau_Y=100.)
430 pl.setPowerLaws(eta_N=[2.,10.],tau_t=[1, 25.], power=[1,2])
431 pl.setEtaTolerance(self.TOL)
432 for i in range(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i]),taus[i])
433
434 def test_PowerLaw_CubeLarge(self):
435 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]
436 gamma_dot_s=[0.0, 8.90625, 41.25, 120.46875, 270.0, 513.28125, 873.75, 1374.84375, 2040.0, 2892.65625, 3956.25, 4351.875, 4747.5, 5143.125, 5538.75, 5934.375]
437 pl=PowerLaw(numMaterials=2,verbose=VERBOSE)
438 pl.setDruckerPragerLaw(tau_Y=100.)
439 pl.setPowerLaws(eta_N=[2.,1./16.],tau_t=[1, 64.], power=[1,3])
440 pl.setEtaTolerance(self.TOL)
441 for i in range(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i]),taus[i])
442
443 def test_PowerLaw_CubeSmall(self):
444 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]
445 gamma_dot_s=[0.0, 5.0390625, 10.3125, 16.0546875, 22.5, 29.8828125, 38.4375, 48.3984375, 60.0, 73.4765625, 89.0625, 97.96875, 106.875, 115.78125, 124.6875, 133.59375]
446 pl=PowerLaw(numMaterials=2,verbose=VERBOSE)
447 pl.setDruckerPragerLaw(tau_Y=100.)
448 pl.setPowerLaws(eta_N=[2.,25./4.],tau_t=[1, 64.], power=[1,3])
449 pl.setEtaTolerance(self.TOL)
450 for i in range(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i]),taus[i])
451
452 def test_PowerLaw_QuadLarge_CubeLarge(self):
453 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]
454 gamma_dot_s=[0.0, 408.90625, 1641.25, 3720.46875, 6670.0, 10513.28125, 15273.75, 20974.84375, 27640.000000000004, 35292.65625, 43956.25, 48351.875, 52747.5, 57143.125, 61538.75, 65934.375]
455
456 pl=PowerLaw(numMaterials=3,verbose=VERBOSE)
457 pl.setDruckerPragerLaw(tau_Y=100.)
458 pl.setPowerLaws(eta_N=[2.,0.01,1./16.],tau_t=[1, 25.,64.], power=[1,2,3])
459 pl.setEtaTolerance(self.TOL)
460 for i in range(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i]),taus[i])
461
462 def test_PowerLaw_QuadLarge_CubeSmall(self):
463 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]
464 gamma_dot_s=[0.0, 405.0390625, 1610.3125, 3616.0546875, 6422.5, 10029.8828125, 14438.4375, 19648.3984375, 25660.0, 32473.4765625, 40089.0625, 44097.96875, 48106.875, 52115.78125, 56124.6875, 60133.59375]
465
466 pl=PowerLaw(numMaterials=3,verbose=VERBOSE)
467 pl.setDruckerPragerLaw(tau_Y=100.)
468 pl.setPowerLaws(eta_N=[2.,0.01,25./4.],tau_t=[1, 25.,64.], power=[1,2,3])
469 pl.setEtaTolerance(self.TOL)
470 for i in range(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i]),taus[i])
471
472 def test_PowerLaw_QuadSmall_CubeLarge(self):
473 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]
474 gamma_dot_s=[0.0, 9.30625, 42.85, 124.06875, 276.4, 523.28125, 888.15, 1394.44375, 2065.6, 2925.05625, 3996.25, 4395.875, 4795.5, 5195.125, 5594.75, 5994.375]
475 pl=PowerLaw(numMaterials=3,verbose=VERBOSE)
476 pl.setDruckerPragerLaw(tau_Y=100.)
477 pl.setPowerLaws(eta_N=[2.,10.,1./16.],tau_t=[1, 25.,64.], power=[1,2,3])
478 pl.setEtaTolerance(self.TOL)
479 for i in range(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i]),taus[i])
480
481 def test_PowerLaw_QuadSmall_CubeSmall(self):
482 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]
483 gamma_dot_s=[0.0, 5.4390625, 11.9125, 19.6546875, 28.9, 39.8828125, 52.8375, 67.9984375, 85.6, 105.8765625, 129.0625, 141.96875, 154.875, 167.78125, 180.6875, 193.59375]
484 pl=PowerLaw(numMaterials=3,verbose=VERBOSE)
485 pl.setDruckerPragerLaw(tau_Y=100.)
486 pl.setPowerLaws(eta_N=[2.,10.,25./4.],tau_t=[1, 25.,64.], power=[1,2,3])
487 pl.setEtaTolerance(self.TOL)
488 for i in range(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i]),taus[i])
489
490 def test_PowerLaw_withShear(self):
491 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]
492 gamma_dot_s=[0.0, 15.0, 30.0, 45.0, 60.0, 75.0, 90.0, 105.0, 120.0, 135.0, 150.0, 165.0, 180.0, 195.0, 210.0, 225.0]
493 pl=PowerLaw(numMaterials=1,verbose=VERBOSE)
494 pl.setDruckerPragerLaw(tau_Y=100.)
495 pl.setPowerLaw(eta_N=2.)
496 pl.setElasticShearModulus(3.)
497 dt=1./3.
498 pl.setEtaTolerance(self.TOL)
499 self.assertRaises(ValueError, pl.getEtaEff,gamma_dot_s[0])
500 for i in range(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i],dt=dt),taus[i])
501
502
503 class Test_FaultSystem(unittest.TestCase):
504 EPS=1.e-8
505 NE=10
506 def test_Fault_MaxValue(self):
507 dom=Rectangle(2*self.NE,2*self.NE)
508 x=dom.getX()
509 f=FaultSystem(dim=2)
510 f.addFault(V0=[0.5,0.], strikes=[3.*pi/4], ls=[0.70710678118654757], tag=1)
511 f.addFault(V0=[1.,0.5], strikes=[pi, pi/2], ls=[0.5,0.5], tag=2)
512
513 u=x[0]*(1.-x[0])*(1-x[1])
514 t, loc=f.getMaxValue(u)
515 p=f.getParametrization(x,t)[0]
516 m, l=loc(u), loc(p)
517 self.assertTrue( m == 0.25, "wrong max value")
518 self.assertTrue( t == 1, "wrong max tag")
519 self.assertTrue( l == 0., "wrong max location")
520
521 u=x[1]*(1.-x[1])*(1-x[0])*x[0]
522 t, loc=f.getMaxValue(u)
523 p=f.getParametrization(x,t)[0]
524 m, l=loc(u), loc(p)
525 self.assertTrue( m == 0.0625, "wrong max value")
526 self.assertTrue( t == 2, "wrong max tag")
527 self.assertTrue( l == 0.5, "wrong max location")
528
529 u=x[0]*(1.-x[0])*x[1]
530 t, loc=f.getMaxValue(u)
531 p=f.getParametrization(x,t)[0]
532 m, l=loc(u), loc(p)
533 self.assertTrue( m == 0.25, "wrong max value")
534 self.assertTrue( t == 2, "wrong max tag")
535 self.assertTrue( l == 1.0, "wrong max location")
536
537 u=x[1]*(1.-x[1])*x[0]
538 t, loc=f.getMaxValue(u)
539 p=f.getParametrization(x,t)[0]
540 m, l=loc(u), loc(p)
541 self.assertTrue( m == 0.25, "wrong max value")
542 self.assertTrue( t == 2, "wrong max tag")
543 self.assertTrue( l == 0., "wrong max location")
544
545 u=x[1]*(1.-x[1])*(1.-x[0])
546 t, loc=f.getMaxValue(u)
547 p=f.getParametrization(x,t)[0]
548 m, l=loc(u), loc(p)
549 self.assertTrue( m == 0.25, "wrong max value")
550 self.assertTrue( t == 1, "wrong max tag")
551 self.assertTrue( abs(l-0.70710678118654) <= self.EPS, "wrong max location")
552 def test_Fault_MinValue(self):
553 dom=Rectangle(2*self.NE,2*self.NE)
554 x=dom.getX()
555 f=FaultSystem(dim=2)
556 f.addFault(V0=[0.5,0.], strikes=[3.*pi/4], ls=[0.70710678118654757], tag=1)
557 f.addFault(V0=[1.,0.5], strikes=[pi, pi/2], ls=[0.5,0.5], tag=2)
558
559 u=-x[0]*(1.-x[0])*(1-x[1])
560 t, loc=f.getMinValue(u)
561 p=f.getParametrization(x,t)[0]
562 m, l=loc(u), loc(p)
563 self.assertTrue( m == -0.25, "wrong min value")
564 self.assertTrue( t == 1, "wrong min tag")
565 self.assertTrue( l == 0., "wrong min location")
566 u=-x[1]*(1.-x[1])*(1-x[0])*x[0]
567 t, loc=f.getMinValue(u)
568 p=f.getParametrization(x,t)[0]
569 m, l=loc(u), loc(p)
570 self.assertTrue( m == -0.0625, "wrong min value")
571 self.assertTrue( t == 2, "wrong min tag")
572 self.assertTrue( l == 0.5, "wrong min location")
573 u=-x[0]*(1.-x[0])*x[1]
574 t, loc=f.getMinValue(u)
575 p=f.getParametrization(x,t)[0]
576 m, l=loc(u), loc(p)
577 self.assertTrue( m == -0.25, "wrong min value")
578 self.assertTrue( t == 2, "wrong min tag")
579 self.assertTrue( l == 1.0, "wrong min location")
580 u=-x[1]*(1.-x[1])*x[0]
581 t, loc=f.getMinValue(u)
582 p=f.getParametrization(x,t)[0]
583 m, l=loc(u), loc(p)
584 self.assertTrue( m == -0.25, "wrong min value")
585 self.assertTrue( t == 2, "wrong min tag")
586 self.assertTrue( l == 0., "wrong min location")
587 u=-x[1]*(1.-x[1])*(1.-x[0])
588 t, loc=f.getMinValue(u)
589 p=f.getParametrization(x,t)[0]
590 m, l=loc(u), loc(p)
591 self.assertTrue( m == -0.25, "wrong min value")
592 self.assertTrue( t == 1, "wrong min tag")
593 self.assertTrue( abs(l-0.70710678118654) <= self.EPS, "wrong min location")
594
595
596 def test_Fault2D(self):
597 f=FaultSystem(dim=2)
598 top1=[ [1.,0.], [1.,1.], [0.,1.] ]
599 self.assertRaises(ValueError,f.addFault,V0=[1.,0],strikes=[pi/2, pi/2],ls=[1.,1.],tag=1,dips=top1)
600 f.addFault(V0=[1.,0],strikes=[pi/2, pi],ls=[1.,1.],tag=1)
601 self.assertTrue(f.getDim() == 2, "wrong dimension")
602 self.assertTrue( [ 1 ] == f.getTags(), "tags wrong")
603 self.assertTrue( 2. == f.getTotalLength(1), "length wrong")
604 self.assertTrue( 0. == f.getMediumDepth(1), "depth wrong")
605 self.assertTrue( (0., 2.) == f.getW0Range(1)," wrong W0 range")
606 self.assertTrue( (0., 0.) == f.getW1Range(1)," wrong W1 range")
607 self.assertTrue( [0., 1., 2.] == f.getW0Offsets(1)," wrong W0 offsets")
608 segs=f.getTopPolyline(1)
609 self.assertTrue( len(segs) == 3, "wrong number of segments")
610 self.assertTrue( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")
611 self.assertTrue( segs[0].size == 2, "seg 0 has wrong size.")
612 self.assertTrue( numpy.linalg.norm(segs[0]-[1.,0.]) < self.EPS, "wrong vertex. 0 ")
613 self.assertTrue( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1")
614 self.assertTrue( segs[1].size == 2, "seg 1 has wrong size.")
615 self.assertTrue( numpy.linalg.norm(segs[1]-[1.,1.]) < self.EPS, "wrong vertex. 1 ")
616 self.assertTrue( isinstance(segs[2], numpy.ndarray), "wrong class of vertex 2")
617 self.assertTrue( segs[2].size == 2, "seg 2 has wrong size.")
618 self.assertTrue( numpy.linalg.norm(segs[2]-[0.,1.]) < self.EPS, "wrong vertex. 2 ")
619 c=f.getCenterOnSurface()
620 self.assertTrue( isinstance(c, numpy.ndarray), "center has wrong class")
621 self.assertTrue( c.size == 2, "center size is wrong")
622 self.assertTrue( numpy.linalg.norm(c-[2./3.,2./3.]) < self.EPS, "center has wrong coordinates.")
623 o=f.getOrientationOnSurface()/pi*180.
624 self.assertTrue( abs(o+45.) < self.EPS, "wrong orientation.")
625
626 top2=[ [10.,0.], [0.,10.] ]
627 f.addFault(V0=[10.,0],strikes=[3.*pi/4],ls=[14.142135623730951], tag=2, w0_offsets=[0,20], w1_max=20)
628 self.assertTrue( [ 1, 2 ] == f.getTags(), "tags wrong")
629 self.assertTrue( abs(f.getTotalLength(2)-14.1421356237) < self.EPS * 14.1421356237, "wrong length")
630 self.assertTrue( 0. == f.getMediumDepth(2), "depth wrong")
631 self.assertTrue( (0., 20.) == f.getW0Range(2)," wrong W0 range")
632 self.assertTrue( (0., 0.) == f.getW1Range(2)," wrong W1 range")
633 self.assertTrue( [0., 20.] == f.getW0Offsets(2)," wrong W0 offsets")
634 segs=f.getTopPolyline(2)
635 self.assertTrue( len(segs) == 2, "wrong number of segments")
636 self.assertTrue( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")
637 self.assertTrue( numpy.linalg.norm(segs[0]-[10.,0.]) < self.EPS, "wrong vertex. 0 ")
638 self.assertTrue( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1")
639 self.assertTrue( numpy.linalg.norm(segs[1]-[0.,10.]) < self.EPS, "wrong vertex. 1 ")
640 c=f.getCenterOnSurface()
641 self.assertTrue( isinstance(c, numpy.ndarray), "center has wrong class")
642 self.assertTrue( c.size == 2, "center size is wrong")
643 self.assertTrue( numpy.linalg.norm(c-[12./5.,12./5.]) < self.EPS, "center has wrong coordinates.")
644 o=f.getOrientationOnSurface()/pi*180.
645 self.assertTrue( abs(o+45.) < self.EPS, "wrong orientation.")
646
647 s,d=f.getSideAndDistance([0.,0.], tag=1)
648 self.assertTrue( s<0, "wrong side.")
649 self.assertTrue( abs(d-1.)<self.EPS, "wrong distance.")
650 s,d=f.getSideAndDistance([0.,2.], tag=1)
651 self.assertTrue( s>0, "wrong side.")
652 self.assertTrue( abs(d-1.)<self.EPS, "wrong distance.")
653 s,d=f.getSideAndDistance([1.,2.], tag=1)
654 self.assertTrue( s>0, "wrong side.")
655 self.assertTrue( abs(d-1.)<self.EPS, "wrong distance.")
656 s,d=f.getSideAndDistance([2.,1.], tag=1)
657 self.assertTrue( s>0, "wrong side.")
658 self.assertTrue( abs(d-1.)<self.EPS, "wrong distance.")
659 s,d=f.getSideAndDistance([2.,0.], tag=1)
660 self.assertTrue( s>0, "wrong side.")
661 self.assertTrue( abs(d-1.)<self.EPS, "wrong distance.")
662 s,d=f.getSideAndDistance([0.,-1.], tag=1)
663 self.assertTrue( s<0, "wrong side.")
664 self.assertTrue( abs(d-1.41421356237)<self.EPS, "wrong distance.")
665 s,d=f.getSideAndDistance([-1.,0], tag=1)
666 self.assertTrue( s<0, "wrong side.")
667 self.assertTrue( abs(d-1.41421356237)<self.EPS, "wrong distance.")
668
669
670 f.transform(rot=-pi/2., shift=[-1.,-1.])
671 self.assertTrue( [ 1, 2 ] == f.getTags(), "tags after transformation wrong")
672 self.assertTrue( 2. == f.getTotalLength(1), "length after transformation wrong")
673 self.assertTrue( 0. == f.getMediumDepth(1), "depth after transformation wrong")
674 self.assertTrue( (0., 2.) == f.getW0Range(1)," wrong W0 after transformation range")
675 self.assertTrue( (0., 0.) == f.getW1Range(1)," wrong W1 rangeafter transformation ")
676 self.assertTrue( [0., 1., 2.] == f.getW0Offsets(1)," wrong W0 offsetsafter transformation ")
677 segs=f.getTopPolyline(1)
678 self.assertTrue( len(segs) == 3, "wrong number of segmentsafter transformation ")
679 self.assertTrue( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0 after transformation")
680 self.assertTrue( segs[0].size == 2, "seg 0 has wrong size after transformation.")
681 self.assertTrue( numpy.linalg.norm(segs[0]-[-1.,0.]) < self.EPS, "wrong vertex. 0 after transformation")
682 self.assertTrue( isinstance(segs[1], numpy.ndarray), "wrong class of vertex after transformation1")
683 self.assertTrue( segs[1].size == 2, "seg 1 has wrong size after transformation.")
684 self.assertTrue( numpy.linalg.norm(segs[1]-[0.,0.]) < self.EPS, "wrong vertex. after transformation1 ")
685 self.assertTrue( isinstance(segs[2], numpy.ndarray), "wrong class of vertex after transformation2")
686 self.assertTrue( segs[2].size == 2, "seg 2 has wrong size after transformation.")
687 self.assertTrue( numpy.linalg.norm(segs[2]-[0., 1.]) < self.EPS, "wrong vertex after transformation. 2 ")
688 self.assertTrue( abs(f.getTotalLength(2)-14.1421356237) < self.EPS * 14.1421356237, "wrong length after transformation")
689 self.assertTrue( 0. == f.getMediumDepth(2), "depth wrong after transformation")
690 self.assertTrue( (0., 20.) == f.getW0Range(2)," wrong W0 range after transformation")
691 self.assertTrue( (0., 0.) == f.getW1Range(2)," wrong W1 range after transformation")
692 self.assertTrue( [0., 20.] == f.getW0Offsets(2)," wrong W0 offsets after transformation")
693 segs=f.getTopPolyline(2)
694 self.assertTrue( len(segs) == 2, "wrong number of segments after transformation")
695 self.assertTrue( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0 after transformation")
696 self.assertTrue( numpy.linalg.norm(segs[0]-[-1.,-9]) < self.EPS, "wrong vertex. 0 after transformation")
697 self.assertTrue( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1 after transformation")
698 self.assertTrue( numpy.linalg.norm(segs[1]-[9.,1.]) < self.EPS, "wrong vertex. 1 after transformation")
699
700 c=f.getCenterOnSurface()
701 self.assertTrue( isinstance(c, numpy.ndarray), "center has wrong class")
702 self.assertTrue( c.size == 2, "center size is wrong")
703 self.assertTrue( numpy.linalg.norm(c-[7./5.,-7./5.]) < self.EPS, "center has wrong coordinates.")
704 o=f.getOrientationOnSurface()/pi*180.
705 self.assertTrue( abs(o-45.) < self.EPS, "wrong orientation.")
706
707 p=f.getParametrization([-1.,0.],1)
708 self.assertTrue(p[1]==1., "wrong value.")
709 self.assertTrue(abs(p[0])<self.EPS, "wrong value.")
710 p=f.getParametrization([-0.5,0.],1)
711 self.assertTrue(p[1]==1., "wrong value.")
712 self.assertTrue(abs(p[0]-0.5)<self.EPS* 0.5, "wrong value.")
713 p=f.getParametrization([0.,0.],1)
714 self.assertTrue(p[1]==1., "wrong value.")
715 self.assertTrue(abs(p[0]-1.)<self.EPS, "wrong value.")
716 p=f.getParametrization([0.0000001,0.0000001],1, tol=1.e-8)
717 self.assertTrue(p[1]==0., "wrong value.")
718 p=f.getParametrization([0.0000001,0.0000001],1, tol=1.e-6)
719 self.assertTrue(p[1]==1., "wrong value.")
720 self.assertTrue(abs(p[0]-1.0000001)<self.EPS, "wrong value.")
721 p=f.getParametrization([0.,0.5],1)
722 self.assertTrue(p[1]==1., "wrong value.")
723 self.assertTrue(abs(p[0]-1.5)<self.EPS, "wrong value.")
724 p=f.getParametrization([0,1.],1)
725 self.assertTrue(p[1]==1., "wrong value.")
726 self.assertTrue(abs(p[0]-2.)<self.EPS, "wrong value.")
727 p=f.getParametrization([1.,1.],1)
728 self.assertTrue(p[1]==0., "wrong value.")
729 p=f.getParametrization([0,1.11],1)
730 self.assertTrue(p[1]==0., "wrong value.")
731 p=f.getParametrization([-1,-9.],2)
732 self.assertTrue(p[1]==1., "wrong value.")
733 self.assertTrue(abs(p[0])<self.EPS, "wrong value.")
734 p=f.getParametrization([9,1],2)
735 self.assertTrue(p[1]==1., "wrong value.")
736 self.assertTrue(abs(p[0]-20.)<self.EPS, "wrong value.")
737
738 def test_Fault3D(self):
739 f=FaultSystem(dim=3)
740 self.assertTrue(f.getDim() == 3, "wrong dimension")
741
742 top1=[ [0.,0.,0.], [1., 0., 0.] ]
743 f.addFault(V0=[0.,0,0],strikes=[0.],ls=[1.,], dips=pi/2, depths=20.,tag=1)
744 self.assertTrue( [ 1 ] == f.getTags(), "tags wrong")
745 self.assertTrue( 1. == f.getTotalLength(1), "length wrong")
746 self.assertTrue( 20. == f.getMediumDepth(1), "depth wrong")
747 self.assertTrue( (0., 1.) == f.getW0Range(1)," wrong W0 range")
748 self.assertTrue( (-20., 0.) == f.getW1Range(1)," wrong W1 range")
749 self.assertTrue( [0., 1.] == f.getW0Offsets(1)," wrong W0 offsets")
750 segs=f.getTopPolyline(1)
751 self.assertTrue( len(segs) == 2, "wrong number of segments")
752 self.assertTrue( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")
753 self.assertTrue( segs[0].size == 3, "seg 0 has wrong size.")
754 self.assertTrue( numpy.linalg.norm(segs[0]-[0.,0.,0.]) < self.EPS, "wrong vertex. 0 ")
755 self.assertTrue( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1")
756 self.assertTrue( segs[1].size == 3, "seg 1 has wrong size.")
757 self.assertTrue( numpy.linalg.norm(segs[1]-[1.,0.,0]) < self.EPS, "wrong vertex. 1 ")
758 c=f.getCenterOnSurface()
759 self.assertTrue( isinstance(c, numpy.ndarray), "center has wrong class")
760 self.assertTrue( c.size == 3, "center size is wrong")
761 self.assertTrue( numpy.linalg.norm(c-[0.5,0.,0.]) < self.EPS, "center has wrong coordinates.")
762 o=f.getOrientationOnSurface()/pi*180.
763 self.assertTrue( abs(o) < self.EPS, "wrong orientation.")
764 d=f.getDips(1)
765 self.assertTrue( len(d) == 1, "wrong number of dips")
766 self.assertTrue( abs(d[0]-1.5707963267948966) < self.EPS, "wrong dip 0")
767 sn=f.getSegmentNormals(1)
768 self.assertTrue( len(sn) == 1, "wrong number of normals")
769 self.assertTrue( isinstance(sn[0], numpy.ndarray), "wrong class of bottom vertex 0")
770 self.assertTrue( numpy.linalg.norm(sn[0]-[0, -1., 0.]) < self.EPS, "wrong bottom vertex 1 ")
771 dv=f.getDepthVectors(1)
772 self.assertTrue( len(dv) == 2, "wrong number of depth vectors.")
773 self.assertTrue( isinstance(dv[0], numpy.ndarray), "wrong class of depth vector 0")
774 self.assertTrue( numpy.linalg.norm(dv[0]-[0., 0., -20.]) < self.EPS, "wrong depth vector 0 ")
775 self.assertTrue( isinstance(dv[1], numpy.ndarray), "wrong class of depth vector 1")
776 self.assertTrue( numpy.linalg.norm(dv[1]-[0., 0., -20.]) < self.EPS, "wrong depth vector 1 ")
777 b=f.getBottomPolyline(1)
778 self.assertTrue( len(b) == 2, "wrong number of bottom vertices")
779 self.assertTrue( isinstance(b[0], numpy.ndarray), "wrong class of bottom vertex 0")
780 self.assertTrue( numpy.linalg.norm(b[0]-[0., 0., -20.]) < self.EPS, "wrong bottom vertex 0 ")
781 self.assertTrue( isinstance(b[1], numpy.ndarray), "wrong class of bottom vertex 1")
782 self.assertTrue( numpy.linalg.norm(b[1]-[1., 0., -20.]) < self.EPS, "wrong bottom vertex 1 ")
783 ds=f.getDepths(1)
784 self.assertTrue( len(ds) == 2, "wrong number of depth")
785 self.assertTrue( abs(ds[0]-20.) < self.EPS, "wrong depth at vertex 0 ")
786 self.assertTrue( abs(ds[1]-20.) < self.EPS, "wrong depth at vertex 1 ")
787
788 top2=[ [0.,0.,0.], [0., 10., 0.] ]
789 f.addFault(V0=[0.,0,0],strikes=[pi/2],ls=[10.,], dips=pi/2, depths=20.,tag=2)
790 self.assertTrue( [ 1, 2 ] == f.getTags(), "tags wrong")
791 self.assertTrue( 10. == f.getTotalLength(2), "length wrong")
792 self.assertTrue( 20. == f.getMediumDepth(2), "depth wrong")
793 self.assertTrue( (0., 10.) == f.getW0Range(2)," wrong W0 range")
794 self.assertTrue( (-20., 0.) == f.getW1Range(2)," wrong W1 range")
795 self.assertTrue( [0., 10.] == f.getW0Offsets(2)," wrong W0 offsets")
796 segs=f.getTopPolyline(2)
797 self.assertTrue( len(segs) == 2, "wrong number of segments")
798 self.assertTrue( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")
799 self.assertTrue( segs[0].size == 3, "seg 0 has wrong size.")
800 self.assertTrue( numpy.linalg.norm(segs[0]-[0.,0.,0.]) < self.EPS, "wrong vertex. 0 ")
801 self.assertTrue( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1")
802 self.assertTrue( segs[1].size == 3, "seg 1 has wrong size.")
803 self.assertTrue( numpy.linalg.norm(segs[1]-[0., 10., 0]) < self.EPS, "wrong vertex. 1 ")
804 d=f.getDips(2)
805 self.assertTrue( len(d) == 1, "wrong number of dips")
806 self.assertTrue( abs(d[0]-1.5707963267948966) < self.EPS, "wrong dip 0")
807 sn=f.getSegmentNormals(2)
808 self.assertTrue( len(sn) == 1, "wrong number of normals")
809 self.assertTrue( isinstance(sn[0], numpy.ndarray), "wrong class of bottom vertex 0")
810 self.assertTrue( numpy.linalg.norm(sn[0]-[1, 0., 0.]) < self.EPS, "wrong bottom vertex 1 ")
811 dv=f.getDepthVectors(2)
812 self.assertTrue( len(dv) == 2, "wrong number of depth vectors.")
813 self.assertTrue( isinstance(dv[0], numpy.ndarray), "wrong class of depth vector 0")
814 self.assertTrue( numpy.linalg.norm(dv[0]-[0., 0., -20.]) < self.EPS, "wrong depth vector 0 ")
815 self.assertTrue( isinstance(dv[1], numpy.ndarray), "wrong class of depth vector 1")
816 self.assertTrue( numpy.linalg.norm(dv[1]-[0., 0., -20.]) < self.EPS, "wrong depth vector 1 ")
817 b=f.getBottomPolyline(2)
818 self.assertTrue( len(b) == 2, "wrong number of bottom vertices")
819 self.assertTrue( isinstance(b[0], numpy.ndarray), "wrong class of bottom vertex 0")
820 self.assertTrue( numpy.linalg.norm(b[0]-[0., 0., -20.]) < self.EPS, "wrong bottom vertex 0 ")
821 self.assertTrue( isinstance(b[1], numpy.ndarray), "wrong class of bottom vertex 1")
822 self.assertTrue( numpy.linalg.norm(b[1]-[0., 10., -20.]) < self.EPS, "wrong bottom vertex 1 ")
823 ds=f.getDepths(2)
824 self.assertTrue( len(ds) == 2, "wrong number of depth")
825 self.assertTrue( abs(ds[0]-20.) < self.EPS, "wrong depth at vertex 0 ")
826 self.assertTrue( abs(ds[1]-20.) < self.EPS, "wrong depth at vertex 1 ")
827
828 top2=[ [10.,0.,0.], [0., 10., 0.] ]
829 f.addFault(V0=[10.,0,0],strikes=3*pi/4,ls=14.142135623730951, dips=pi/2, depths=30.,tag=2)
830 self.assertTrue( [ 1, 2 ] == f.getTags(), "tags wrong")
831 self.assertTrue( abs(14.142135623730951 - f.getTotalLength(2)) <self.EPS, "length wrong")
832 self.assertTrue( 30. == f.getMediumDepth(2), "depth wrong")
833 self.assertTrue( (-30., 0.) == f.getW1Range(2)," wrong W1 range")
834 segs=f.getTopPolyline(2)
835 self.assertTrue( len(segs) == 2, "wrong number of segments")
836 self.assertTrue( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")
837 self.assertTrue( segs[0].size == 3, "seg 0 has wrong size.")
838 self.assertTrue( numpy.linalg.norm(segs[0]-[10.,0.,0.]) < self.EPS, "wrong vertex. 0 ")
839 self.assertTrue( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1")
840 self.assertTrue( segs[1].size == 3, "seg 1 has wrong size.")
841 self.assertTrue( numpy.linalg.norm(segs[1]-[0., 10., 0]) < self.EPS, "wrong vertex. 1 ")
842 d=f.getDips(2)
843 self.assertTrue( len(d) == 1, "wrong number of dips")
844 self.assertTrue( abs(d[0]-1.5707963267948966) < self.EPS, "wrong dip 0")
845 sn=f.getSegmentNormals(2)
846 self.assertTrue( len(sn) == 1, "wrong number of normals")
847 self.assertTrue( isinstance(sn[0], numpy.ndarray), "wrong class of bottom vertex 0")
848 self.assertTrue( numpy.linalg.norm(sn[0]-[0.70710678118654746, 0.70710678118654746, 0.]) < self.EPS, "wrong bottom vertex 1 ")
849 dv=f.getDepthVectors(2)
850 self.assertTrue( len(dv) == 2, "wrong number of depth vectors.")
851 self.assertTrue( isinstance(dv[0], numpy.ndarray), "wrong class of depth vector 0")
852 self.assertTrue( numpy.linalg.norm(dv[0]-[0., 0., -30.]) < self.EPS, "wrong depth vector 0 ")
853 self.assertTrue( isinstance(dv[1], numpy.ndarray), "wrong class of depth vector 1")
854 self.assertTrue( numpy.linalg.norm(dv[1]-[0., 0., -30.]) < self.EPS, "wrong depth vector 1 ")
855 b=f.getBottomPolyline(2)
856 self.assertTrue( len(b) == 2, "wrong number of bottom vertices")
857 self.assertTrue( isinstance(b[0], numpy.ndarray), "wrong class of bottom vertex 0")
858 self.assertTrue( numpy.linalg.norm(b[0]-[10., 0., -30.]) < self.EPS, "wrong bottom vertex 0 ")
859 self.assertTrue( isinstance(b[1], numpy.ndarray), "wrong class of bottom vertex 1")
860 self.assertTrue( numpy.linalg.norm(b[1]-[0., 10., -30.]) < self.EPS, "wrong bottom vertex 1 ")
861 ds=f.getDepths(2)
862 self.assertTrue( len(ds) == 2, "wrong number of depth")
863 self.assertTrue( abs(ds[0]-30.) < self.EPS, "wrong depth at vertex 0 ")
864 self.assertTrue( abs(ds[1]-30.) < self.EPS, "wrong depth at vertex 1 ")
865
866 top2=[ [10.,0.,0.], [0., 10., 0.] ]
867 f.addFault(V0=[10.,0,0],strikes=3*pi/4,ls=14.142135623730951, dips=pi/4, depths=50.,tag=2)
868 self.assertTrue( [ 1, 2 ] == f.getTags(), "tags wrong")
869 self.assertTrue( abs(14.142135623730951 - f.getTotalLength(2)) <self.EPS, "length wrong")
870 self.assertTrue( 50. == f.getMediumDepth(2), "depth wrong")
871 self.assertTrue( (-50., 0.) == f.getW1Range(2)," wrong W1 range")
872 segs=f.getTopPolyline(2)
873 self.assertTrue( len(segs) == 2, "wrong number of segments")
874 self.assertTrue( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")
875 self.assertTrue( segs[0].size == 3, "seg 0 has wrong size.")
876 self.assertTrue( numpy.linalg.norm(segs[0]-[10.,0.,0.]) < self.EPS, "wrong vertex. 0 ")
877 self.assertTrue( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1")
878 self.assertTrue( segs[1].size == 3, "seg 1 has wrong size.")
879 self.assertTrue( numpy.linalg.norm(segs[1]-[0., 10., 0]) < self.EPS, "wrong vertex. 1 ")
880 d=f.getDips(2)
881 self.assertTrue( len(d) == 1, "wrong number of dips")
882 self.assertTrue( abs(d[0]-0.78539816339744828) < self.EPS, "wrong dip 0")
883 sn=f.getSegmentNormals(2)
884 self.assertTrue( len(sn) == 1, "wrong number of normals")
885 self.assertTrue( isinstance(sn[0], numpy.ndarray), "wrong class of bottom vertex 0")
886 self.assertTrue( numpy.linalg.norm(sn[0]-[0.5,0.5,0.70710678118654746]) < self.EPS, "wrong bottom vertex 1 ")
887 dv=f.getDepthVectors(2)
888 self.assertTrue( len(dv) == 2, "wrong number of depth vectors.")
889 self.assertTrue( isinstance(dv[0], numpy.ndarray), "wrong class of depth vector 0")
890 self.assertTrue( numpy.linalg.norm(dv[0]-[25., 25., -35.355339059327378]) < self.EPS, "wrong depth vector 0 ")
891 self.assertTrue( isinstance(dv[1], numpy.ndarray), "wrong class of depth vector 1")
892 self.assertTrue( numpy.linalg.norm(dv[1]-[25.,25., -35.355339059327378]) < self.EPS, "wrong depth vector 1 ")
893 b=f.getBottomPolyline(2)
894 self.assertTrue( len(b) == 2, "wrong number of bottom vertices")
895 self.assertTrue( isinstance(b[0], numpy.ndarray), "wrong class of bottom vertex 0")
896 self.assertTrue( numpy.linalg.norm(b[0]-[35., 25., -35.355339059327378]) < self.EPS, "wrong bottom vertex 0 ")
897 self.assertTrue( isinstance(b[1], numpy.ndarray), "wrong class of bottom vertex 1")
898 self.assertTrue( numpy.linalg.norm(b[1]-[25, 35., -35.355339059327378]) < self.EPS, "wrong bottom vertex 1 ")
899 ds=f.getDepths(2)
900 self.assertTrue( len(ds) == 2, "wrong number of depth")
901 self.assertTrue( abs(ds[0]-50.) < self.EPS, "wrong depth at vertex 0 ")
902 self.assertTrue( abs(ds[1]-50.) < self.EPS, "wrong depth at vertex 1 ")
903
904 top1=[ [10.,0.,0], [10.,10.,0], [0.,10.,0] ]
905 f.addFault(V0=[10.,0.,0.],strikes=[pi/2, pi],ls=[10.,10.],tag=1, dips=pi/4, depths=20.)
906 self.assertTrue( 20. == f.getTotalLength(1), "length wrong")
907 self.assertTrue( 20. == f.getMediumDepth(1), "depth wrong")
908 segs=f.getTopPolyline(1)
909 self.assertTrue( len(segs) == 3, "wrong number of segments")
910 self.assertTrue( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")
911 self.assertTrue( segs[0].size == 3, "seg 0 has wrong size.")
912 self.assertTrue( numpy.linalg.norm(segs[0]-[10.,0.,0.]) < self.EPS, "wrong vertex. 0 ")
913 self.assertTrue( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1")
914 self.assertTrue( segs[1].size == 3, "seg 1 has wrong size.")
915 self.assertTrue( numpy.linalg.norm(segs[1]-[10.,10.,0.]) < self.EPS, "wrong vertex. 1 ")
916 self.assertTrue( isinstance(segs[2], numpy.ndarray), "wrong class of vertex 2")
917 self.assertTrue( segs[2].size == 3, "seg 2 has wrong size.")
918 self.assertTrue( numpy.linalg.norm(segs[2]-[0.,10.,0.]) < self.EPS, "wrong vertex. 2 ")
919 d=f.getDips(1)
920 self.assertTrue( len(d) == 2, "wrong number of dips")
921 self.assertTrue( abs(d[0]-0.78539816339744828) < self.EPS, "wrong dip 0")
922 self.assertTrue( abs(d[1]-0.78539816339744828) < self.EPS, "wrong dip 0")
923 ds=f.getDepths(1)
924 self.assertTrue( len(ds) == 3, "wrong number of depth")
925 self.assertTrue( abs(ds[0]-20.) < self.EPS, "wrong depth at vertex 0 ")
926 self.assertTrue( abs(ds[1]-20.) < self.EPS, "wrong depth at vertex 1 ")
927 sn=f.getSegmentNormals(1)
928 self.assertTrue( len(sn) == 2, "wrong number of normals")
929 self.assertTrue( isinstance(sn[0], numpy.ndarray), "wrong class of bottom vertex 0")
930 self.assertTrue( numpy.linalg.norm(sn[0]-[0.70710678118654746,0.,0.70710678118654746]) < self.EPS, "wrong bottom vertex 1 ")
931 self.assertTrue( isinstance(sn[1], numpy.ndarray), "wrong class of bottom vertex 0")
932 self.assertTrue( numpy.linalg.norm(sn[1]-[0.,0.70710678118654746,0.70710678118654746]) < self.EPS, "wrong bottom vertex 1 ")
933 dv=f.getDepthVectors(1)
934 self.assertTrue( len(dv) == 3, "wrong number of depth vectors.")
935 self.assertTrue( isinstance(dv[0], numpy.ndarray), "wrong class of depth vector 0")
936 self.assertTrue( numpy.linalg.norm(dv[0]-[14.142135623730951, 0., -14.142135623730951]) < self.EPS, "wrong depth vector 0 ")
937 self.assertTrue( isinstance(dv[1], numpy.ndarray), "wrong class of depth vector 1")
938 self.assertTrue( numpy.linalg.norm(dv[1]-[11.547005383792515,11.547005383792515, -11.547005383792515]) < self.EPS, "wrong depth vector 2 ")
939 self.assertTrue( isinstance(dv[2], numpy.ndarray), "wrong class of depth vector 1")
940 self.assertTrue( numpy.linalg.norm(dv[2]-[0.,14.142135623730951, -14.142135623730951]) < self.EPS, "wrong depth vector 2 ")
941 segs=f.getBottomPolyline(1)
942 self.assertTrue( len(segs) == 3, "wrong number of segments")
943 self.assertTrue( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")
944 self.assertTrue( segs[0].size == 3, "seg 0 has wrong size.")
945 self.assertTrue( numpy.linalg.norm(segs[0]-[24.142135623730951,0.,-14.142135623730951]) < self.EPS, "wrong vertex. 0 ")
946 self.assertTrue( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1")
947 self.assertTrue( segs[1].size == 3, "seg 1 has wrong size.")
948 self.assertTrue( numpy.linalg.norm(segs[1]-[21.547005383792515,21.547005383792515, -11.547005383792515]) < self.EPS, "wrong vertex. 1 ")
949 self.assertTrue( isinstance(segs[2], numpy.ndarray), "wrong class of vertex 2")
950 self.assertTrue( segs[2].size == 3, "seg 2 has wrong size.")
951 self.assertTrue( numpy.linalg.norm(segs[2]-[0., 24.142135623730951, -14.142135623730951]) < self.EPS, "wrong vertex. 2 ")
952 self.assertTrue( abs(0.-f.getW0Range(1)[0]) <=self.EPS," wrong W0 range (0)")
953 self.assertTrue( abs(31.857329272664341-f.getW0Range(1)[1]) <=self.EPS," wrong W0 range (1)")
954 self.assertTrue( abs(-20. - f.getW1Range(1)[0]) <=self.EPS," wrong W1 range (0)")
955 self.assertTrue( abs(0. - f.getW1Range(1)[1]) <=self.EPS," wrong W1 range (1)")
956 self.assertTrue( abs(0.0-f.getW0Offsets(1)[0])<=self.EPS," wrong W0 offsets (0)")
957 self.assertTrue( abs(15.92866463633217-f.getW0Offsets(1)[1])<=self.EPS," wrong W0 offsets (1)")
958 self.assertTrue( abs(31.857329272664341-f.getW0Offsets(1)[2])<=self.EPS," wrong W0 offsets(2)")
959 #
960 # ============ fresh start ====================
961 #
962 f.addFault(V0=[1.,0,0.],strikes=[pi/2, pi],ls=[1.,1.], dips=pi/2,depths=20,tag=1)
963 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)
964 c=f.getCenterOnSurface()
965 self.assertTrue( isinstance(c, numpy.ndarray), "center has wrong class")
966 self.assertTrue( c.size == 3, "center size is wrong")
967 self.assertTrue( numpy.linalg.norm(c-[12./5.,12./5.,0.]) < self.EPS, "center has wrong coordinates.")
968 o=f.getOrientationOnSurface()/pi*180.
969 self.assertTrue( abs(o+45.) < self.EPS, "wrong orientation.")
970
971 f.transform(rot=-pi/2., shift=[-1.,-1.,0.])
972 self.assertTrue( [ 1, 2 ] == f.getTags(), "tags after transformation wrong")
973 self.assertTrue( 2. == f.getTotalLength(1), "length after transformation wrong")
974 self.assertTrue( 20. == f.getMediumDepth(1), "depth after transformation wrong")
975 rw0=f.getW0Range(1)
976 self.assertTrue( len(rw0) ==2, "wo range has wrong length")
977 self.assertTrue( abs(rw0[0]) < self.EPS,"W0 0 wrong.")
978 self.assertTrue( abs(rw0[1]-2.) < self.EPS,"W0 1 wrong.")
979 self.assertTrue( (-20., 0.) == f.getW1Range(1)," wrong W1 rangeafter transformation ")
980 dips=f.getDips(1)
981 self.assertTrue(len(dips) == 2, "wrong number of dips.")
982 self.assertTrue( abs(dips[0]-1.5707963267948966) <= self.EPS, "wrong dip")
983 self.assertTrue( abs(dips[1]-1.5707963267948966) <= self.EPS, "wrong dip")
984 ds=f.getDepths(1)
985 self.assertTrue( len(ds) == 3, "wrong number of depth")
986 self.assertTrue( abs(ds[0]-20.) < self.EPS, "wrong depth at vertex 0 ")
987 self.assertTrue( abs(ds[1]-20.) < self.EPS, "wrong depth at vertex 1 ")
988 self.assertTrue( abs(ds[2]-20.) < self.EPS, "wrong depth at vertex 1 ")
989 segs=f.getTopPolyline(1)
990 self.assertTrue( len(segs) == 3, "wrong number of segmentsafter transformation ")
991 self.assertTrue( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0 after transformation")
992 self.assertTrue( segs[0].size == 3, "seg 0 has wrong size after transformation.")
993 self.assertTrue( numpy.linalg.norm(segs[0]-[-1.,0.,0.]) < self.EPS, "wrong vertex. 0 after transformation")
994 self.assertTrue( isinstance(segs[1], numpy.ndarray), "wrong class of vertex after transformation1")
995 self.assertTrue( segs[1].size == 3, "seg 1 has wrong size after transformation.")
996 self.assertTrue( numpy.linalg.norm(segs[1]-[0.,0.,0.]) < self.EPS, "wrong vertex. after transformation1 ")
997 self.assertTrue( isinstance(segs[2], numpy.ndarray), "wrong class of vertex after transformation2")
998 self.assertTrue( segs[2].size == 3, "seg 2 has wrong size after transformation.")
999 self.assertTrue( numpy.linalg.norm(segs[2]-[0., 1.,0.]) < self.EPS, "wrong vertex after transformation. 2 ")
1000 self.assertTrue( abs(f.getTotalLength(2)-14.1421356237) < self.EPS * 14.1421356237, "wrong length after transformation")
1001 self.assertTrue( 20. == f.getMediumDepth(2), "depth wrong after transformation")
1002 rw0=f.getW0Range(2)
1003 self.assertTrue( len(rw0) ==2, "wo range has wrong length")
1004 self.assertTrue( abs(rw0[0]) < self.EPS,"W0 0 wrong.")
1005 self.assertTrue( abs(rw0[1]-20.) < self.EPS,"W0 1 wrong.")
1006 self.assertTrue( (-20., 0.) == f.getW1Range(2)," wrong W1 range after transformation")
1007 self.assertTrue( [0., 20.] == f.getW0Offsets(2)," wrong W0 offsets after transformation")
1008 dips=f.getDips(2)
1009 self.assertTrue(len(dips) == 1, "wrong number of dips.")
1010 self.assertTrue( abs(dips[0]-1.5707963267948966) <= self.EPS, "wrong dip")
1011 ds=f.getDepths(2)
1012 self.assertTrue( len(ds) == 2, "wrong number of depth")
1013 self.assertTrue( abs(ds[0]-20.) < self.EPS, "wrong depth at vertex 0 ")
1014 self.assertTrue( abs(ds[1]-20.) < self.EPS, "wrong depth at vertex 1 ")
1015 segs=f.getTopPolyline(2)
1016 self.assertTrue( len(segs) == 2, "wrong number of segments after transformation")
1017 self.assertTrue( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0 after transformation")
1018 self.assertTrue( numpy.linalg.norm(segs[0]-[-1.,-9,0.]) < self.EPS, "wrong vertex. 0 after transformation")
1019 self.assertTrue( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1 after transformation")
1020 self.assertTrue( numpy.linalg.norm(segs[1]-[9.,1.,0.]) < self.EPS, "wrong vertex. 1 after transformation")
1021 #
1022 # ============ fresh start ====================
1023 #
1024 f=FaultSystem(dim=3)
1025
1026 top1=[ [0.,0.,0.], [1., 0., 0.] ]
1027 f.addFault(V0=[0.,0,0],strikes=[0.],ls=[1.,], dips=pi/2, depths=1.,tag=1)
1028 top1=[ [10.,0.,0], [10.,10.,0], [0.,10.,0] ]
1029 f.addFault(V0=[10.,0.,0.],strikes=[pi/2, pi],ls=[10.,10.],tag=2, dips=pi/4, depths=20.)
1030
1031 p,m=f.getParametrization([0.3,0.,-0.5],1)
1032 self.assertTrue(length(p-[0.3,-0.5]) <= self.EPS, "wrong value.")
1033 self.assertTrue(m==1., "wrong value.")
1034
1035 p,m=f.getParametrization([0.5,0.,-0.5],1)
1036 self.assertTrue(length(p-[0.5,-0.5]) <= self.EPS, "wrong value.")
1037 self.assertTrue(m==1., "wrong value.")
1038
1039 p,m=f.getParametrization([0.25,0.,-0.5],1)
1040 self.assertTrue(length(p-[0.25,-0.5]) <= self.EPS, "wrong value.")
1041 self.assertTrue(m==1., "wrong value.")
1042
1043 p,m=f.getParametrization([0.5,0.,-0.25],1)
1044 self.assertTrue(length(p-[0.5,-0.25]) <= self.EPS, "wrong value.")
1045 self.assertTrue(m==1., "wrong value.")
1046
1047 p,m=f.getParametrization([0.001,0.,-0.001],1)
1048 self.assertTrue(length(p-[0.001, -0.001]) <= self.EPS, "wrong value.")
1049 self.assertTrue(m==1., "wrong value.")
1050
1051 p,m=f.getParametrization([0.001,0.,0.001],1)
1052 self.assertTrue(m==0., "wrong value.")
1053
1054 p,m=f.getParametrization([0.999,0.,0.001],1)
1055 self.assertTrue(m==0., "wrong value.")
1056
1057 p,m=f.getParametrization([1.001,0.,-0.001],1)
1058 self.assertTrue(m==0., "wrong value.")
1059 p,m=f.getParametrization([1.001,0.,-0.1],1)
1060 self.assertTrue(m==0., "wrong value.")
1061 p,m=f.getParametrization([1.001,0.,-0.000000001],1)
1062 self.assertTrue(m==0., "wrong value.")
1063
1064 p,m=f.getParametrization([0.999,0.,-0.001],1)
1065 self.assertTrue(length(p-[0.999, -0.001]) <= self.EPS, "wrong value.")
1066 self.assertTrue(m==1., "wrong value.")
1067
1068 p,m=f.getParametrization([ 16.29252873 , 6.46410161 ,-6.29252873], 2, tol=1.e-7)
1069 self.assertTrue(m==1., "wrong value.")
1070 self.assertTrue(length(p-[4.7785993908996511, -10]) <= self.EPS*10., "wrong value.")
1071 p,m=f.getParametrization([15.77350269, 12.77350269, -5.77350269], 2, tol=1.e-7)
1072 self.assertTrue(m==1., "wrong value.")
1073 self.assertTrue(length(p-[11.150065245432518, -10]) <= self.EPS*10., "wrong value.")
1074
1075 p,m=f.getParametrization([ 3., 17.0710678, -7.0710678], 2, tol=1.e-7)
1076 self.assertTrue(m==1., "wrong value.")
1077 self.assertTrue(length(p-[27.078729881764687, -10]) <= self.EPS*10., "wrong value.")
1078 p,m=f.getParametrization([9.30940108, 16.55204176, -6.55204176], 2, tol=1.e-7)
1079 self.assertTrue(m==1., "wrong value.")
1080 self.assertTrue(length(p-[20.707264027231822, -10]) <= self.EPS*10., "wrong value.")
1081
1082 p,m=f.getParametrization([ 21.54700538, 21.54700538, -11.54700538], 2, tol=1.e-7)
1083 self.assertTrue(m==1., "wrong value.")
1084 self.assertTrue(length(p-[15.92866463633217, -20]) <= self.EPS*10., "wrong value.")
1085
1086 p,m=f.getParametrization([ 0.,0.,0.], 2, tol=1.e-7)
1087 self.assertTrue(m==0., "wrong value.")
1088
1089 p,m=f.getParametrization([ 11.,11.,0.], 2, tol=1.e-7)
1090 self.assertTrue(m==0., "wrong value.")
1091
1092
1093 s,d=f.getSideAndDistance([0.,-1.,0.], tag=1)
1094 self.assertTrue( s>0, "wrong side.")
1095 self.assertTrue( abs(d-1.)<self.EPS, "wrong distance.")
1096 s,d=f.getSideAndDistance([1.,-1.,0.], tag=1)
1097 self.assertTrue( s>0, "wrong side.")
1098 self.assertTrue( abs(d-1.)<self.EPS, "wrong distance.")
1099 s,d=f.getSideAndDistance([0.,1.,0.], tag=1)
1100 self.assertTrue( s<0, "wrong side.")
1101 self.assertTrue( abs(d-1.)<self.EPS, "wrong distance.")
1102 s,d=f.getSideAndDistance([1.,1.,0.], tag=1)
1103 self.assertTrue( s<0, "wrong side.")
1104 self.assertTrue( abs(d-1.)<self.EPS, "wrong distance.")
1105
1106
1107 s,d=f.getSideAndDistance([0.,0.,0.], tag=2)
1108 self.assertTrue( s<0, "wrong side.")
1109 self.assertTrue( abs(d-10.)<self.EPS, "wrong distance.")
1110 s,d=f.getSideAndDistance([5.,5.,0.], tag=2)
1111 self.assertTrue( s<0, "wrong side.")
1112 self.assertTrue( abs(d-5.)<self.EPS, "wrong distance.")
1113
1114 s,d=f.getSideAndDistance([10.,10.,-1.], tag=2)
1115 self.assertTrue( s<0, "wrong side.")
1116 self.assertTrue( abs(d-0.70710678118654757)<self.EPS, "wrong distance.")
1117 s,d=f.getSideAndDistance([10.,10.,-2.], tag=2)
1118 self.assertTrue( s<0, "wrong side.")
1119 self.assertTrue( abs(d-2.*0.70710678118654757)<self.EPS, "wrong distance.")
1120 s,d=f.getSideAndDistance([10.,10.,-3.], tag=2)
1121 self.assertTrue( s<0, "wrong side.")
1122 self.assertTrue( abs(d-3.*0.70710678118654757)<self.EPS, "wrong distance.")
1123
1124 s,d=f.getSideAndDistance([5.,12.,0], tag=2)
1125 self.assertTrue( s>0, "wrong side.")
1126 self.assertTrue( abs(d-2*0.70710678118654757)<self.EPS, "wrong distance.")
1127 s,d=f.getSideAndDistance([5.,12.,-1], tag=2)
1128 self.assertTrue( s>0, "wrong side.")
1129 self.assertTrue( abs(d-0.70710678118654757)<self.EPS, "wrong distance.")
1130 s,d=f.getSideAndDistance([5.,12.,-2], tag=2)
1131 # s not checked as it is undefined.
1132 self.assertTrue( abs(d)<self.EPS, "wrong distance.")
1133 s,d=f.getSideAndDistance([5.,12.,-3], tag=2)
1134 self.assertTrue( s<0, "wrong side.")
1135 self.assertTrue( abs(d-0.70710678118654757)<self.EPS, "wrong distance.")
1136 s,d=f.getSideAndDistance([5.,12.,-4], tag=2)
1137 self.assertTrue( s<0, "wrong side.")
1138 self.assertTrue( abs(d-2.*0.70710678118654757)<self.EPS, "wrong distance.")
1139
1140 if __name__ == '__main__':
1141 run_tests(__name__, exit_on_failure=True)
1142

  ViewVC Help
Powered by ViewVC 1.1.26