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

Contents of /trunk/dudley/test/python/run_models.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4984 - (show annotations)
Mon Jun 2 02:50:34 2014 UTC (4 years, 10 months ago) by sshaw
File MIME type: text/x-python
File size: 77023 byte(s)
revamping testrunners, now uses automated discovery and allows running specific tests without modifying files (see escriptcore/py_src/testing.py for more info/examples)

1 # -*- coding: utf-8 -*-
2
3 ##############################################################################
4 #
5 # Copyright (c) 2003-2014 by 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
18
19 __copyright__="""Copyright (c) 2003-2014 by 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 StokesProblemCartesian, PowerLaw, IncompressibleIsotropicFlowCartesian, FaultSystem, DarcyFlow
33 from esys.escript.models import Mountains
34 from esys.dudley import Rectangle, Brick
35
36 from math import pi
37 import numpy, os, sys, tempfile
38 #==============================================================================
39 try:
40 DUDLEY_WORKDIR=os.environ['DUDLEY_WORKDIR']
41 except KeyError:
42 DUDLEY_WORKDIR='.'
43
44 #==============================================================================
45 @unittest.skip("Test not previously tested")
46 class Test_StokesProblemCartesian2D(unittest.TestCase):
47 def setUp(self):
48 NE=6
49 self.TOL=1e-3
50 self.domain=Rectangle(NE,NE,order=-1)
51 def tearDown(self):
52 del self.domain
53 def test_PCG_P_0(self):
54 ETA=1.
55 P1=0.
56
57 x=self.domain.getX()
58 F=-P1*x[1]*[1.,0]+(2*ETA-P1*x[0])*[0.,1.]
59 mask=whereZero(x[0]) * [1.,1.] \
60 +whereZero(x[0]-1) * [1.,1.] \
61 +whereZero(x[1]) * [1.,0.] \
62 +whereZero(x[1]-1) * [1.,1.]
63
64 sp=StokesProblemCartesian(self.domain)
65
66 sp.initialize(f=F,fixed_u_mask=mask,eta=ETA)
67 u0=(1-x[0])*x[0]*[0.,1.]
68 p0=Scalar(-P1,ReducedSolution(self.domain))
69 sp.setTolerance(self.TOL)
70 u,p=sp.solve(u0*mask,p0,verbose=VERBOSE,max_iter=100,usePCG=True)
71
72 error_v0=Lsup(u[0]-u0[0])
73 error_v1=Lsup(u[1]-u0[1])/0.25
74 error_p=Lsup(p+P1*x[0]*x[1])
75 self.assertTrue(error_p<10*self.TOL, "pressure error too large.")
76 self.assertTrue(error_v0<10*self.TOL, "0-velocity error too large.")
77 self.assertTrue(error_v1<10*self.TOL, "1-velocity error too large.")
78
79 def test_PCG_P_small(self):
80 ETA=1.
81 P1=1.
82
83 x=self.domain.getX()
84 F=-P1*x[1]*[1.,0]+(2*ETA-P1*x[0])*[0.,1.]
85 mask=whereZero(x[0]) * [1.,1.] \
86 +whereZero(x[0]-1) * [1.,1.] \
87 +whereZero(x[1]) * [1.,0.] \
88 +whereZero(x[1]-1) * [1.,1.]
89
90 sp=StokesProblemCartesian(self.domain)
91
92 sp.initialize(f=F,fixed_u_mask=mask,eta=ETA)
93 u0=(1-x[0])*x[0]*[0.,1.]
94 p0=Scalar(-P1,ReducedSolution(self.domain))
95 sp.setTolerance(self.TOL)
96 u,p=sp.solve(u0,p0, verbose=VERBOSE,max_iter=100,usePCG=True)
97 error_v0=Lsup(u[0]-u0[0])
98 error_v1=Lsup(u[1]-u0[1])/0.25
99 error_p=Lsup(P1*x[0]*x[1]+p)
100 self.assertTrue(error_v0<10*self.TOL, "0-velocity error too large.")
101 self.assertTrue(error_v1<10*self.TOL, "1-velocity error too large.")
102 self.assertTrue(error_p<10*self.TOL, "pressure error too large.")
103
104 def test_PCG_P_large(self):
105 ETA=1.
106 P1=1000.
107
108 x=self.domain.getX()
109 F=-P1*x[1]*[1.,0]+(2*ETA-P1*x[0])*[0.,1.]
110 mask=whereZero(x[0]) * [1.,1.] \
111 +whereZero(x[0]-1) * [1.,1.] \
112 +whereZero(x[1]) * [1.,0.] \
113 +whereZero(x[1]-1) * [1.,1.]
114
115 sp=StokesProblemCartesian(self.domain)
116
117 sp.initialize(f=F,fixed_u_mask=mask,eta=ETA)
118 u0=(1-x[0])*x[0]*[0.,1.]
119 p0=Scalar(-P1,ReducedSolution(self.domain))
120 sp.setTolerance(self.TOL)
121 u,p=sp.solve(u0,p0, verbose=VERBOSE,max_iter=100,usePCG=True)
122 # u,p=sp.solve(u0,p0, verbose=VERBOSE,max_iter=100,usePCG=True)
123
124 error_v0=Lsup(u[0]-u0[0])
125 error_v1=Lsup(u[1]-u0[1])/0.25
126 error_p=Lsup(P1*x[0]*x[1]+p)/P1
127 self.assertTrue(error_p<10*self.TOL, "pressure error too large.")
128 self.assertTrue(error_v0<10*self.TOL, "0-velocity error too large.")
129 self.assertTrue(error_v1<10*self.TOL, "1-velocity error too large.")
130
131 def test_GMRES_P_0(self):
132 ETA=1.
133 P1=0.
134
135 x=self.domain.getX()
136 F=-P1*x[1]*[1.,0]+(2*ETA-P1*x[0])*[0.,1.]
137 mask=whereZero(x[0]) * [1.,1.] \
138 +whereZero(x[0]-1) * [1.,1.] \
139 +whereZero(x[1]) * [1.,0.] \
140 +whereZero(x[1]-1) * [1.,1.]
141
142 sp=StokesProblemCartesian(self.domain)
143
144 sp.initialize(f=F,fixed_u_mask=mask,eta=ETA)
145 u0=(1-x[0])*x[0]*[0.,1.]
146 p0=Scalar(-P1,ReducedSolution(self.domain))
147 sp.setTolerance(self.TOL)
148 u,p=sp.solve(u0,p0, verbose=VERBOSE,max_iter=50,usePCG=False,iter_restart=18)
149
150 error_v0=Lsup(u[0]-u0[0])
151 error_v1=Lsup(u[1]-u0[1])/0.25
152 error_p=Lsup(P1*x[0]*x[1]+p)
153 self.assertTrue(error_p<10*self.TOL, "pressure error too large.")
154 self.assertTrue(error_v0<10*self.TOL, "0-velocity error too large.")
155 self.assertTrue(error_v1<10*self.TOL, "1-velocity error too large.")
156
157 def test_GMRES_P_small(self):
158 ETA=1.
159 P1=1.
160
161 x=self.domain.getX()
162 F=-P1*x[1]*[1.,0]+(2*ETA-P1*x[0])*[0.,1.]
163 mask=whereZero(x[0]) * [1.,1.] \
164 +whereZero(x[0]-1) * [1.,1.] \
165 +whereZero(x[1]) * [1.,0.] \
166 +whereZero(x[1]-1) * [1.,1.]
167
168 sp=StokesProblemCartesian(self.domain)
169
170 sp.initialize(f=F,fixed_u_mask=mask,eta=ETA)
171 u0=(1-x[0])*x[0]*[0.,1.]
172 p0=Scalar(-P1,ReducedSolution(self.domain))
173 sp.setTolerance(self.TOL)
174 u,p=sp.solve(u0,p0, verbose=VERBOSE,max_iter=20,usePCG=False)
175
176 error_v0=Lsup(u[0]-u0[0])
177 error_v1=Lsup(u[1]-u0[1])/0.25
178 error_p=Lsup(P1*x[0]*x[1]+p)
179
180 self.assertTrue(error_p<10*self.TOL, "pressure error too large.")
181 self.assertTrue(error_v0<10*self.TOL, "0-velocity error too large.")
182 self.assertTrue(error_v1<10*self.TOL, "1-velocity error too large.")
183
184 def test_GMRES_P_large(self):
185 ETA=1.
186 P1=1000.
187
188 x=self.domain.getX()
189 F=-P1*x[1]*[1.,0]+(2*ETA-P1*x[0])*[0.,1.]
190 mask=whereZero(x[0]) * [1.,1.] \
191 +whereZero(x[0]-1) * [1.,1.] \
192 +whereZero(x[1]) * [1.,0.] \
193 +whereZero(x[1]-1) * [1.,1.]
194
195 sp=StokesProblemCartesian(self.domain)
196
197 sp.initialize(f=F,fixed_u_mask=mask,eta=ETA)
198 u0=(1-x[0])*x[0]*[0.,1.]
199 p0=Scalar(-P1,ReducedSolution(self.domain))
200 sp.setTolerance(self.TOL)
201 u,p=sp.solve(u0,p0, verbose=VERBOSE,max_iter=100,usePCG=False)
202
203 error_v0=Lsup(u[0]-u0[0])
204 error_v1=Lsup(u[1]-u0[1])/0.25
205 error_p=Lsup(P1*x[0]*x[1]+p)/P1
206 self.assertTrue(error_p<10*self.TOL, "pressure error too large.")
207 self.assertTrue(error_v0<10*self.TOL, "0-velocity error too large.")
208 self.assertTrue(error_v1<10*self.TOL, "1-velocity error too large.")
209 #==============================================================================
210 @unittest.skip("Test not previously tested")
211 class Test_StokesProblemCartesian3D(unittest.TestCase):
212 def setUp(self):
213 NE=6
214 self.TOL=1e-4
215 self.domain=Brick(NE,NE,NE,order=-1)
216 def tearDown(self):
217 del self.domain
218 def test_PCG_P_0(self):
219 ETA=1.
220 P1=0.
221
222 x=self.domain.getX()
223 F=-P1*x[1]*x[2]*[1.,0.,0.]-P1*x[0]*x[2]*[0.,1.,0.]+(2*ETA*((1-x[0])*x[0]+(1-x[1])*x[1])-P1*x[0]*x[1])*[0.,0.,1.]
224 x=self.domain.getX()
225 mask=whereZero(x[0]) * [1.,1.,1.] \
226 +whereZero(x[0]-1) * [1.,1.,1.] \
227 +whereZero(x[1]) * [1.,0.,1.] \
228 +whereZero(x[1]-1) * [1.,1.,1.] \
229 +whereZero(x[2]) * [1.,1.,0.] \
230 +whereZero(x[2]-1) * [1.,1.,1.]
231
232
233 sp=StokesProblemCartesian(self.domain)
234
235 sp.initialize(f=F,fixed_u_mask=mask,eta=ETA)
236 u0=(1-x[0])*x[0]*(1-x[1])*x[1]*[0.,0.,1.]
237 p0=Scalar(-P1,ReducedSolution(self.domain))
238 sp.setTolerance(self.TOL)
239 u,p=sp.solve(u0,p0, verbose=VERBOSE ,max_iter=100,usePCG=True)
240
241 error_v0=Lsup(u[0]-u0[0])
242 error_v1=Lsup(u[1]-u0[1])
243 error_v2=Lsup(u[2]-u0[2])/0.25**2
244 error_p=Lsup(P1*x[0]*x[1]*x[2]+p)
245 self.assertTrue(error_p<10*self.TOL, "pressure error too large.")
246 self.assertTrue(error_v0<10*self.TOL, "0-velocity error too large.")
247 self.assertTrue(error_v1<10*self.TOL, "1-velocity error too large.")
248 self.assertTrue(error_v2<10*self.TOL, "2-velocity error too large.")
249
250 def test_PCG_P_small(self):
251 ETA=1.
252 P1=1.
253
254 x=self.domain.getX()
255 F=-P1*x[1]*x[2]*[1.,0.,0.]-P1*x[0]*x[2]*[0.,1.,0.]+(2*ETA*((1-x[0])*x[0]+(1-x[1])*x[1])-P1*x[0]*x[1])*[0.,0.,1.]
256 mask=whereZero(x[0]) * [1.,1.,1.] \
257 +whereZero(x[0]-1) * [1.,1.,1.] \
258 +whereZero(x[1]) * [1.,0.,1.] \
259 +whereZero(x[1]-1) * [1.,1.,1.] \
260 +whereZero(x[2]) * [1.,1.,0.] \
261 +whereZero(x[2]-1) * [1.,1.,1.]
262
263
264 sp=StokesProblemCartesian(self.domain)
265
266 sp.initialize(f=F,fixed_u_mask=mask,eta=ETA)
267 u0=(1-x[0])*x[0]*(1-x[1])*x[1]*[0.,0.,1.]
268 p0=Scalar(-P1,ReducedSolution(self.domain))
269 sp.setTolerance(self.TOL)
270 u,p=sp.solve(u0,p0, verbose=VERBOSE ,max_iter=100,usePCG=True)
271 error_v0=Lsup(u[0]-u0[0])
272 error_v1=Lsup(u[1]-u0[1])
273 error_v2=Lsup(u[2]-u0[2])/0.25**2
274 error_p=Lsup(P1*x[0]*x[1]*x[2]+p)
275 self.assertTrue(error_p<10*self.TOL, "pressure error too large.")
276 self.assertTrue(error_v0<10*self.TOL, "0-velocity error too large.")
277 self.assertTrue(error_v1<10*self.TOL, "1-velocity error too large.")
278 self.assertTrue(error_v2<10*self.TOL, "2-velocity error too large.")
279
280 def test_PCG_P_large(self):
281 ETA=1.
282 P1=1000.
283
284 x=self.domain.getX()
285 F=-P1*x[1]*x[2]*[1.,0.,0.]-P1*x[0]*x[2]*[0.,1.,0.]+(2*ETA*((1-x[0])*x[0]+(1-x[1])*x[1])-P1*x[0]*x[1])*[0.,0.,1.]
286 mask=whereZero(x[0]) * [1.,1.,1.] \
287 +whereZero(x[0]-1) * [1.,1.,1.] \
288 +whereZero(x[1]) * [1.,0.,1.] \
289 +whereZero(x[1]-1) * [1.,1.,1.] \
290 +whereZero(x[2]) * [1.,1.,0.] \
291 +whereZero(x[2]-1) * [1.,1.,1.]
292
293
294 sp=StokesProblemCartesian(self.domain)
295
296 sp.initialize(f=F,fixed_u_mask=mask,eta=ETA)
297 u0=(1-x[0])*x[0]*(1-x[1])*x[1]*[0.,0.,1.]
298 p0=Scalar(-P1,ReducedSolution(self.domain))
299 sp.setTolerance(self.TOL)
300 u,p=sp.solve(u0,p0, verbose=VERBOSE ,max_iter=100,usePCG=True)
301
302 error_v0=Lsup(u[0]-u0[0])
303 error_v1=Lsup(u[1]-u0[1])
304 error_v2=Lsup(u[2]-u0[2])/0.25**2
305 error_p=Lsup(P1*x[0]*x[1]*x[2]+p)/P1
306 self.assertTrue(error_p<10*self.TOL, "pressure error too large.")
307 self.assertTrue(error_v0<10*self.TOL, "0-velocity error too large.")
308 self.assertTrue(error_v1<10*self.TOL, "1-velocity error too large.")
309 self.assertTrue(error_v2<10*self.TOL, "2-velocity error too large.")
310
311 def test_GMRES_P_0(self):
312 ETA=1.
313 P1=0.
314
315 x=self.domain.getX()
316 F=-P1*x[1]*x[2]*[1.,0.,0.]-P1*x[0]*x[2]*[0.,1.,0.]+(2*ETA*((1-x[0])*x[0]+(1-x[1])*x[1])-P1*x[0]*x[1])*[0.,0.,1.]
317 x=self.domain.getX()
318 mask=whereZero(x[0]) * [1.,1.,1.] \
319 +whereZero(x[0]-1) * [1.,1.,1.] \
320 +whereZero(x[1]) * [1.,1.,1.] \
321 +whereZero(x[1]-1) * [1.,1.,1.] \
322 +whereZero(x[2]) * [1.,1.,0.] \
323 +whereZero(x[2]-1) * [1.,1.,1.]
324
325
326 sp=StokesProblemCartesian(self.domain)
327
328 sp.initialize(f=F,fixed_u_mask=mask,eta=ETA)
329 u0=(1-x[0])*x[0]*(1-x[1])*x[1]*[0.,0.,1.]
330 p0=Scalar(-P1,ReducedSolution(self.domain))
331 sp.setTolerance(self.TOL)
332 u,p=sp.solve(u0,p0, verbose=VERBOSE,max_iter=100,usePCG=False,iter_restart=20)
333
334 error_v0=Lsup(u[0]-u0[0])
335 error_v1=Lsup(u[1]-u0[1])
336 error_v2=Lsup(u[2]-u0[2])/0.25**2
337 error_p=Lsup(P1*x[0]*x[1]*x[2]+p)
338 self.assertTrue(error_p<10*self.TOL, "pressure error too large.")
339 self.assertTrue(error_v0<10*self.TOL, "0-velocity error too large.")
340 self.assertTrue(error_v1<10*self.TOL, "1-velocity error too large.")
341 self.assertTrue(error_v2<10*self.TOL, "2-velocity error too large.")
342 def test_GMRES_P_small(self):
343 ETA=1.
344 P1=1.
345
346 x=self.domain.getX()
347 F=-P1*x[1]*x[2]*[1.,0.,0.]-P1*x[0]*x[2]*[0.,1.,0.]+(2*ETA*((1-x[0])*x[0]+(1-x[1])*x[1])-P1*x[0]*x[1])*[0.,0.,1.]
348 mask=whereZero(x[0]) * [1.,1.,1.] \
349 +whereZero(x[0]-1) * [1.,1.,1.] \
350 +whereZero(x[1]) * [1.,1.,1.] \
351 +whereZero(x[1]-1) * [1.,1.,1.] \
352 +whereZero(x[2]) * [1.,1.,0.] \
353 +whereZero(x[2]-1) * [1.,1.,1.]
354
355
356 sp=StokesProblemCartesian(self.domain)
357
358 sp.initialize(f=F,fixed_u_mask=mask,eta=ETA)
359 u0=(1-x[0])*x[0]*(1-x[1])*x[1]*[0.,0.,1.]
360 p0=Scalar(-P1,ReducedSolution(self.domain))
361 sp.setTolerance(self.TOL/10)
362 u,p=sp.solve(u0,p0, verbose=VERBOSE,max_iter=100,usePCG=False)
363
364 error_v0=Lsup(u[0]-u0[0])
365 error_v1=Lsup(u[1]-u0[1])
366 error_v2=Lsup(u[2]-u0[2])/0.25**2
367 error_p=Lsup(P1*x[0]*x[1]*x[2]+p)/P1
368 self.assertTrue(error_v0<10*self.TOL, "0-velocity error too large.")
369 self.assertTrue(error_v1<10*self.TOL, "1-velocity error too large.")
370 self.assertTrue(error_v2<10*self.TOL, "2-velocity error too large.")
371 self.assertTrue(error_p<10*self.TOL, "pressure error too large.")
372 def test_GMRES_P_large(self):
373 ETA=1.
374 P1=1000.
375
376 x=self.domain.getX()
377 F=-P1*x[1]*x[2]*[1.,0.,0.]-P1*x[0]*x[2]*[0.,1.,0.]+(2*ETA*((1-x[0])*x[0]+(1-x[1])*x[1])-P1*x[0]*x[1])*[0.,0.,1.]
378 mask=whereZero(x[0]) * [1.,1.,1.] \
379 +whereZero(x[0]-1) * [1.,1.,1.] \
380 +whereZero(x[1]) * [1.,0.,1.] \
381 +whereZero(x[1]-1) * [1.,1.,1.] \
382 +whereZero(x[2]) * [1.,1.,0.] \
383 +whereZero(x[2]-1) * [1.,1.,1.]
384
385
386 sp=StokesProblemCartesian(self.domain)
387
388 sp.initialize(f=F,fixed_u_mask=mask,eta=ETA)
389 u0=(1-x[0])*x[0]*(1-x[1])*x[1]*[0.,0.,1.]
390 p0=Scalar(-P1,ReducedSolution(self.domain))
391 sp.setTolerance(self.TOL)
392 u,p=sp.solve(u0,p0, verbose=VERBOSE ,max_iter=100,usePCG=False)
393
394 error_v0=Lsup(u[0]-u0[0])
395 error_v1=Lsup(u[1]-u0[1])
396 error_v2=Lsup(u[2]-u0[2])/0.25**2
397 error_p=Lsup(P1*x[0]*x[1]*x[2]+p)/P1
398 self.assertTrue(error_p<10*self.TOL, "pressure error too large.")
399 self.assertTrue(error_v0<10*self.TOL, "0-velocity error too large.")
400 self.assertTrue(error_v1<10*self.TOL, "1-velocity error too large.")
401 self.assertTrue(error_v2<10*self.TOL, "2-velocity error too large.")
402 #==============================================================================
403 class Darcy(unittest.TestCase):
404 # this is a simple test for the darcy flux problem
405 #
406 #
407 # p = 1/k * ( 1/2* (fb-f0)/xb* x **2 + f0 * x - ub*x ) + p0
408 #
409 # with f = (fb-f0)/xb* x + f0
410 #
411 # u = f - k * p,x = ub
412 #
413 # we prescribe pressure at x=x0=0 to p0
414 #
415 # if we prescribe the pressure on the bottom x=xb we set
416 #
417 # pb= 1/k * ( 1/2* (fb-f0)* xb + f0 * xb - ub*xb ) + p0 = 1/k * ((fb+f0)/2 - ub ) * xb + p0
418 #
419 # which leads to ub = (fb+f0)/2-k*(pb-p0)/xb
420 #
421 def rescaleDomain(self):
422 x=self.dom.getX().copy()
423 for i in range(self.dom.getDim()):
424 x_inf=inf(x[i])
425 x_sup=sup(x[i])
426 if i == self.dom.getDim()-1:
427 x[i]=-self.WIDTH*(x[i]-x_sup)/(x_inf-x_sup)
428 else:
429 x[i]=self.WIDTH*(x[i]-x_inf)/(x_sup-x_inf)
430 self.dom.setX(x)
431 def getScalarMask(self,include_bottom=True):
432 x=self.dom.getX().copy()
433 x_inf=inf(x[self.dom.getDim()-1])
434 x_sup=sup(x[self.dom.getDim()-1])
435 out=whereZero(x[self.dom.getDim()-1]-x_sup)
436 if include_bottom: out+=whereZero(x[self.dom.getDim()-1]-x_inf)
437 return wherePositive(out)
438 def getVectorMask(self,include_bottom=True):
439 x=self.dom.getX().copy()
440 out=Vector(0.,Solution(self.dom))
441 for i in range(self.dom.getDim()):
442 x_inf=inf(x[i])
443 x_sup=sup(x[i])
444 if i != self.dom.getDim()-1: out[i]+=whereZero(x[i]-x_sup)
445 if i != self.dom.getDim()-1 or include_bottom: out[i]+=whereZero(x[i]-x_inf)
446 return wherePositive(out)
447
448 def setSolutionFixedBottom(self, p0, pb, f0, fb, k):
449 d=self.dom.getDim()
450 x=self.dom.getX()[d-1]
451 xb=inf(x)
452 u=Vector(0.,Solution(self.dom))+kronecker(d)[d-1]*((f0+fb)/2.-k*(pb-p0)/xb)
453 p=1./k*((fb-f0)/(xb*2.)* x**2 - (fb-f0)/2.*x)+(pb-p0)/xb*x + p0
454 f= ((fb-f0)/xb* x + f0)*kronecker(Function(self.dom))[d-1]
455 return u,p,f
456
457 def testConstF_FixedBottom_smallK(self):
458 k=1.e-10
459 mp=self.getScalarMask(include_bottom=True)
460 mv=self.getVectorMask(include_bottom=False)
461 u_ref,p_ref,f=self.setSolutionFixedBottom(p0=2500,pb=4000.,f0=10.,fb=10.,k=k)
462 p=p_ref*mp
463 u=u_ref*mv
464 df=DarcyFlow(self.dom)
465 df.setValue(g=f,
466 location_of_fixed_pressure=mp,
467 location_of_fixed_flux=mv,
468 permeability=Scalar(k,Function(self.dom)))
469 #df.setTolerance(rtol=self.TOL)
470 v,p=df.solve(u_ref,p)
471 self.assertTrue(Lsup(v-u_ref)<self.TEST_TOL*Lsup(u_ref), "flux error too big.")
472 self.assertTrue(Lsup(p-p_ref)<self.TEST_TOL*Lsup(p_ref), "pressure error too big.")
473 def testConstF_FixedBottom_mediumK(self):
474 k=1.
475 mp=self.getScalarMask(include_bottom=True)
476 mv=self.getVectorMask(include_bottom=False)
477 u_ref,p_ref,f=self.setSolutionFixedBottom(p0=2500,pb=4000.,f0=10.,fb=10.,k=k)
478 p=p_ref*mp
479 u=u_ref*mv
480 df=DarcyFlow(self.dom)
481 df.setValue(g=f,
482 location_of_fixed_pressure=mp,
483 location_of_fixed_flux=mv,
484 permeability=Scalar(k,Function(self.dom)))
485 #df.setTolerance(rtol=self.TOL)
486 v,p=df.solve(u,p )
487 self.assertTrue(Lsup(p-p_ref)<self.TEST_TOL*Lsup(p_ref), "pressure error too big.")
488 self.assertTrue(Lsup(v-u_ref)<self.TEST_TOL*Lsup(u_ref), "flux error too big.")
489
490 def testConstF_FixedBottom_largeK(self):
491 k=1.e10
492 mp=self.getScalarMask(include_bottom=True)
493 mv=self.getVectorMask(include_bottom=False)
494 u_ref,p_ref,f=self.setSolutionFixedBottom(p0=2500,pb=4000.,f0=10.,fb=10.,k=k)
495 p=p_ref*mp
496 u=u_ref*mv
497 df=DarcyFlow(self.dom)
498 df.setValue(g=f,
499 location_of_fixed_pressure=mp,
500 location_of_fixed_flux=mv,
501 permeability=Scalar(k,Function(self.dom)))
502 #df.setTolerance(rtol=self.TOL)
503 v,p=df.solve(u,p )
504 self.assertTrue(Lsup(v-u_ref)<self.TEST_TOL*Lsup(u_ref), "flux error too big.")
505 self.assertTrue(Lsup(p-p_ref)<self.TEST_TOL*Lsup(p_ref), "pressure error too big.")
506
507 def testVarioF_FixedBottom_smallK(self):
508 k=1.e-10
509 mp=self.getScalarMask(include_bottom=True)
510 mv=self.getVectorMask(include_bottom=False)
511 u_ref,p_ref,f=self.setSolutionFixedBottom(p0=2500,pb=4000.,f0=10.,fb=30.,k=k)
512 p=p_ref*mp
513 u=u_ref*mv
514 df=DarcyFlow(self.dom)
515 #df.getSolverOptionsPressure().setVerbosityOn()
516 df.setValue(g=f,
517 location_of_fixed_pressure=mp,
518 location_of_fixed_flux=mv,
519 permeability=Scalar(k,Function(self.dom)))
520 #df.setTolerance(rtol=self.TOL)
521 v,p=df.solve(u,p )
522
523 self.assertTrue(Lsup(v-u_ref)<self.TEST_TOL*Lsup(u_ref), "flux error too big.")
524 self.assertTrue(Lsup(p-p_ref)<self.TEST_TOL*Lsup(p_ref), "pressure error too big.")
525
526 def testVarioF_FixedBottom_mediumK(self):
527 k=1.
528 mp=self.getScalarMask(include_bottom=True)
529 mv=self.getVectorMask(include_bottom=False)
530 u_ref,p_ref,f=self.setSolutionFixedBottom(p0=2500,pb=4000.,f0=10.,fb=30.,k=k)
531 p=p_ref*mp
532 u=u_ref*mv
533 df=DarcyFlow(self.dom)
534 df.setValue(g=f,
535 location_of_fixed_pressure=mp,
536 location_of_fixed_flux=mv,
537 permeability=Scalar(k,Function(self.dom)))
538 #df.setTolerance(rtol=self.TOL)
539 v,p=df.solve(u,p )
540 self.assertTrue(Lsup(v-u_ref)<self.TEST_TOL*Lsup(u_ref), "flux error too big.")
541 self.assertTrue(Lsup(p-p_ref)<self.TEST_TOL*Lsup(p_ref), "pressure error too big.")
542
543 def testVarioF_FixedBottom_largeK(self):
544 k=1.e10
545 mp=self.getScalarMask(include_bottom=True)
546 mv=self.getVectorMask(include_bottom=False)
547 u_ref,p_ref,f=self.setSolutionFixedBottom(p0=2500,pb=4000.,f0=10.,fb=30.,k=k)
548 p=p_ref*mp
549 u=u_ref*mv
550 df=DarcyFlow(self.dom)
551 df.setValue(g=f,
552 location_of_fixed_pressure=mp,
553 location_of_fixed_flux=mv,
554 permeability=Scalar(k,Function(self.dom)))
555 #df.setTolerance(rtol=self.TOL)
556 v,p=df.solve(u,p )
557 self.assertTrue(Lsup(v-u_ref)<self.TEST_TOL*Lsup(u_ref), "flux error too big.")
558 self.assertTrue(Lsup(p-p_ref)<self.TEST_TOL*Lsup(p_ref), "pressure error too big.")
559
560 def testConstF_FreeBottom_smallK(self):
561 k=1.e-10
562 mp=self.getScalarMask(include_bottom=False)
563 mv=self.getVectorMask(include_bottom=True)
564 u_ref,p_ref,f=self.setSolutionFixedBottom(p0=2500,pb=4000.,f0=10.,fb=10.,k=k)
565 p=p_ref*mp
566 u=u_ref*mv
567 df=DarcyFlow(self.dom)
568 df.setValue(g=f,
569 location_of_fixed_pressure=mp,
570 location_of_fixed_flux=mv,
571 permeability=Scalar(k,Function(self.dom)))
572 #df.setTolerance(rtol=self.TOL)
573 v,p=df.solve(u,p)
574
575
576 self.assertTrue(Lsup(v-u_ref)<self.TEST_TOL*Lsup(u_ref), "flux error too big.")
577 self.assertTrue(Lsup(p-p_ref)<self.TEST_TOL*Lsup(p_ref), "pressure error too big.")
578
579 def testConstF_FreeBottom_mediumK(self):
580 k=1.
581 mp=self.getScalarMask(include_bottom=False)
582 mv=self.getVectorMask(include_bottom=True)
583 u_ref,p_ref,f=self.setSolutionFixedBottom(p0=2500,pb=4000.,f0=10.,fb=10.,k=k)
584 p=p_ref*mp
585 u=u_ref*mv
586 df=DarcyFlow(self.dom)
587 df.setValue(g=f,
588 location_of_fixed_pressure=mp,
589 location_of_fixed_flux=mv,
590 permeability=Scalar(k,Function(self.dom)))
591 #df.setTolerance(rtol=self.TOL)
592 v,p=df.solve(u,p)
593 self.assertTrue(Lsup(v-u_ref)<self.TEST_TOL*Lsup(u_ref), "flux error too big.")
594 self.assertTrue(Lsup(p-p_ref)<self.TEST_TOL*Lsup(p_ref), "pressure error too big.")
595
596 def testConstF_FreeBottom_largeK(self):
597 k=1.e10
598 mp=self.getScalarMask(include_bottom=False)
599 mv=self.getVectorMask(include_bottom=True)
600 u_ref,p_ref,f=self.setSolutionFixedBottom(p0=2500,pb=4000.,f0=10.,fb=10.,k=k)
601 p=p_ref*mp
602 u=u_ref*mv
603 df=DarcyFlow(self.dom)
604 df.setValue(g=f,
605 location_of_fixed_pressure=mp,
606 location_of_fixed_flux=mv,
607 permeability=Scalar(k,Function(self.dom)))
608 #df.setTolerance(rtol=self.TOL)
609 v,p=df.solve(u,p)
610 self.assertTrue(Lsup(v-u_ref)<self.TEST_TOL*Lsup(u_ref), "flux error too big.")
611 self.assertTrue(Lsup(p-p_ref)<self.TEST_TOL*Lsup(p_ref), "pressure error too big.")
612
613 def testVarioF_FreeBottom_smallK(self):
614 k=1.e-10
615 mp=self.getScalarMask(include_bottom=False)
616 mv=self.getVectorMask(include_bottom=True)
617 u_ref,p_ref,f=self.setSolutionFixedBottom(p0=2500,pb=4000.,f0=10.,fb=30.,k=k)
618 p=p_ref*mp
619 u=u_ref*mv
620 df=DarcyFlow(self.dom)
621 df.setValue(g=f,
622 location_of_fixed_pressure=mp,
623 location_of_fixed_flux=mv,
624 permeability=Scalar(k,Function(self.dom)))
625 #df.setTolerance(rtol=self.TOL)
626 v,p=df.solve(u,p)
627 self.assertTrue(Lsup(v-u_ref)<self.TEST_TOL*Lsup(u_ref), "flux error too big.")
628 self.assertTrue(Lsup(p-p_ref)<self.TEST_TOL*Lsup(p_ref), "pressure error too big.")
629
630 def testVarioF_FreeBottom_mediumK(self):
631 k=1.
632 mp=self.getScalarMask(include_bottom=False)
633 mv=self.getVectorMask(include_bottom=True)
634 u_ref,p_ref,f=self.setSolutionFixedBottom(p0=2500,pb=4000.,f0=10.,fb=30.,k=k)
635 p=p_ref*mp
636 u=u_ref*mv
637 df=DarcyFlow(self.dom)
638 df.setValue(g=f,
639 location_of_fixed_pressure=mp,
640 location_of_fixed_flux=mv,
641 permeability=Scalar(k,Function(self.dom)))
642 #df.setTolerance(rtol=self.TOL)
643 v,p=df.solve(u,p)
644 self.assertTrue(Lsup(v-u_ref)<self.TEST_TOL*Lsup(u_ref), "flux error too big.")
645 self.assertTrue(Lsup(p-p_ref)<self.TEST_TOL*Lsup(p_ref), "pressure error too big.")
646
647 def testVarioF_FreeBottom_largeK(self):
648 k=1.e10
649 mp=self.getScalarMask(include_bottom=False)
650 mv=self.getVectorMask(include_bottom=True)
651 u_ref,p_ref,f=self.setSolutionFixedBottom(p0=2500,pb=4000.,f0=10.,fb=30.,k=k)
652 p=p_ref*mp
653 u=u_ref*mv
654 df=DarcyFlow(self.dom)
655 df.setValue(g=f,
656 location_of_fixed_pressure=mp,
657 location_of_fixed_flux=mv,
658 permeability=Scalar(k,Function(self.dom)))
659 #df.setTolerance(rtol=self.TOL)
660 v,p=df.solve(u,p)
661 self.assertTrue(Lsup(v-u_ref)<self.TEST_TOL*Lsup(u_ref), "flux error too big.")
662 self.assertTrue(Lsup(p-p_ref)<self.TEST_TOL*Lsup(p_ref), "pressure error too big.")
663
664 class Darcy2D(Darcy):
665 TOL=1e-6
666 TEST_TOL=2.e-3
667 WIDTH=1.
668 def setUp(self):
669 NE=40 # wrning smaller NE may case a failure for VarioF tests due to discretization errors.
670 self.dom = Rectangle(NE/2,NE)
671 self.rescaleDomain()
672 def tearDown(self):
673 del self.dom
674
675 class Darcy3D(Darcy):
676 TOL=1e-6
677 WIDTH=1.
678 TEST_TOL=4.e-3
679 def setUp(self):
680 NE=25 # wrning smaller NE may case a failure for VarioF tests due to discretization errors.
681 self.dom = Brick(NE,NE,NE)
682 self.rescaleDomain()
683 def tearDown(self):
684 del self.dom
685
686 class Test_Rheologies(unittest.TestCase):
687 """
688 this is the program used to generate the powerlaw tests:
689
690 TAU_Y=100.
691 N=10
692 M=5
693
694 def getE(tau):
695 if tau<=TAU_Y:
696 return 1./(0.5+20*sqrt(tau))
697 else:
698 raise ValueError,"out of range."
699 tau=[ i* (TAU_Y/N) for i in range(N+1)] + [TAU_Y for i in range(M)]
700 e=[ tau[i]/getE(tau[i]) for i in range(N+1)]
701 e+= [ (i+1+j)* (max(e)/N) for j in range(M) ]
702
703 print tau
704 print e
705 """
706 TOL=1.e-8
707 def test_PowerLaw_Init(self):
708 pl=PowerLaw(numMaterials=3,verbose=VERBOSE)
709
710 self.assertEqual(pl.getNumMaterials(),3,"num materials is wrong")
711 self.assertEqual(pl.validMaterialId(0),True,"material id 0 not found")
712 self.assertEqual(pl.validMaterialId(1),True,"material id 1 not found")
713 self.assertEqual(pl.validMaterialId(2),True,"material id 2 not found")
714 self.assertEqual(pl.validMaterialId(3),False,"material id 3 not found")
715
716 self.assertEqual(pl.getFriction(),None,"initial friction wrong.")
717 self.assertEqual(pl.getTauY(),None,"initial tau y wrong.")
718 pl.setDruckerPragerLaw(tau_Y=10,friction=3)
719 self.assertEqual(pl.getFriction(),3,"friction wrong.")
720 self.assertEqual(pl.getTauY(),10,"tau y wrong.")
721
722 self.assertEqual(pl.getElasticShearModulus(),None,"initial shear modulus is wrong")
723 pl.setElasticShearModulus(1000)
724 self.assertEqual(pl.getElasticShearModulus(),1000.,"shear modulus is wrong")
725
726 e=pl.getEtaN()
727 self.assertEqual(len(e),3,"initial length of etaN is wrong.")
728 self.assertEqual(e,[None, None, None],"initial etaN are wrong.")
729 self.assertEqual(pl.getEtaN(0),None,"initial material id 0 is wrong")
730 self.assertEqual(pl.getEtaN(1),None,"initial material id 1 is wrong")
731 self.assertEqual(pl.getEtaN(2),None,"initial material id 2 is wrong")
732 self.assertRaises(ValueError, pl.getEtaN, 3)
733
734 self.assertRaises(ValueError,pl.setPowerLaws,eta_N=[10,20,30,40],tau_t=[2], power=[5,6,7])
735 self.assertRaises(ValueError,pl.setPowerLaws,eta_N=[10,20,30],tau_t=[2,4,5,5], power=[5,6,7])
736 self.assertRaises(ValueError,pl.setPowerLaws,eta_N=[10,20,30],tau_t=[2,1,2], power=[5,6,7,7])
737
738 pl.setPowerLaws(eta_N=[10,20,30],tau_t=[100,200,300], power=[1,2,3])
739 self.assertEqual(pl.getPower(),[1,2,3],"powers are wrong.")
740 self.assertEqual(pl.getTauT(),[100,200,300],"tau t are wrong.")
741 self.assertEqual(pl.getEtaN(),[10,20,30],"etaN are wrong.")
742
743 pl.setPowerLaw(id=0,eta_N=40,tau_t=400, power=4)
744 self.assertEqual(pl.getPower(),[4,2,3],"powers are wrong.")
745 self.assertEqual(pl.getTauT(),[400,200,300],"tau t are wrong.")
746 self.assertEqual(pl.getEtaN(),[40,20,30],"etaN are wrong.")
747
748 self.assertRaises(ValueError,pl.getPower,-1)
749 self.assertEqual(pl.getPower(0),4,"power 0 is wrong.")
750 self.assertEqual(pl.getPower(1),2,"power 1 is wrong.")
751 self.assertEqual(pl.getPower(2),3,"power 2 is wrong.")
752 self.assertRaises(ValueError,pl.getPower,3)
753
754 self.assertRaises(ValueError,pl.getTauT,-1)
755 self.assertEqual(pl.getTauT(0),400,"tau t 0 is wrong.")
756 self.assertEqual(pl.getTauT(1),200,"tau t 1 is wrong.")
757 self.assertEqual(pl.getTauT(2),300,"tau t 2 is wrong.")
758 self.assertRaises(ValueError,pl.getTauT,3)
759
760 self.assertRaises(ValueError,pl.getEtaN,-1)
761 self.assertEqual(pl.getEtaN(0),40,"eta n 0 is wrong.")
762 self.assertEqual(pl.getEtaN(1),20,"eta n 1 is wrong.")
763 self.assertEqual(pl.getEtaN(2),30,"eta n 2 is wrong.")
764 self.assertRaises(ValueError,pl.getEtaN,3)
765
766 def checkResult(self,id,gamma_dot_, eta, tau_ref):
767 self.assertTrue(eta>=0,"eta needs to be positive (test %s)"%id)
768 error=abs(gamma_dot_*eta-tau_ref)
769 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))
770
771 def test_PowerLaw_Linear(self):
772 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]
773 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]
774 pl=PowerLaw(numMaterials=1,verbose=VERBOSE)
775 pl.setDruckerPragerLaw(tau_Y=100.)
776 pl.setPowerLaw(eta_N=2.)
777 pl.setEtaTolerance(self.TOL)
778 for i in range(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i]),taus[i])
779
780 def test_PowerLaw_QuadLarge(self):
781 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]
782 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]
783 pl=PowerLaw(numMaterials=2,verbose=VERBOSE)
784 pl.setDruckerPragerLaw(tau_Y=100.)
785 pl.setPowerLaws(eta_N=[2.,0.01],tau_t=[1, 25.], power=[1,2])
786 pl.setEtaTolerance(self.TOL)
787 for i in range(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i]),taus[i])
788
789 def test_PowerLaw_QuadSmall(self):
790 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]
791 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]
792 pl=PowerLaw(numMaterials=2,verbose=VERBOSE)
793 pl.setDruckerPragerLaw(tau_Y=100.)
794 pl.setPowerLaws(eta_N=[2.,10.],tau_t=[1, 25.], power=[1,2])
795 pl.setEtaTolerance(self.TOL)
796 for i in range(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i]),taus[i])
797
798 def test_PowerLaw_CubeLarge(self):
799 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]
800 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]
801 pl=PowerLaw(numMaterials=2,verbose=VERBOSE)
802 pl.setDruckerPragerLaw(tau_Y=100.)
803 pl.setPowerLaws(eta_N=[2.,1./16.],tau_t=[1, 64.], power=[1,3])
804 pl.setEtaTolerance(self.TOL)
805 for i in range(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i]),taus[i])
806
807 def test_PowerLaw_CubeSmall(self):
808 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]
809 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]
810 pl=PowerLaw(numMaterials=2,verbose=VERBOSE)
811 pl.setDruckerPragerLaw(tau_Y=100.)
812 pl.setPowerLaws(eta_N=[2.,25./4.],tau_t=[1, 64.], power=[1,3])
813 pl.setEtaTolerance(self.TOL)
814 for i in range(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i]),taus[i])
815
816 def test_PowerLaw_QuadLarge_CubeLarge(self):
817 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]
818 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]
819
820 pl=PowerLaw(numMaterials=3,verbose=VERBOSE)
821 pl.setDruckerPragerLaw(tau_Y=100.)
822 pl.setPowerLaws(eta_N=[2.,0.01,1./16.],tau_t=[1, 25.,64.], power=[1,2,3])
823 pl.setEtaTolerance(self.TOL)
824 for i in range(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i]),taus[i])
825
826 def test_PowerLaw_QuadLarge_CubeSmall(self):
827 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]
828 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]
829
830 pl=PowerLaw(numMaterials=3,verbose=VERBOSE)
831 pl.setDruckerPragerLaw(tau_Y=100.)
832 pl.setPowerLaws(eta_N=[2.,0.01,25./4.],tau_t=[1, 25.,64.], power=[1,2,3])
833 pl.setEtaTolerance(self.TOL)
834 for i in range(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i]),taus[i])
835
836 def test_PowerLaw_QuadSmall_CubeLarge(self):
837 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]
838 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]
839 pl=PowerLaw(numMaterials=3,verbose=VERBOSE)
840 pl.setDruckerPragerLaw(tau_Y=100.)
841 pl.setPowerLaws(eta_N=[2.,10.,1./16.],tau_t=[1, 25.,64.], power=[1,2,3])
842 pl.setEtaTolerance(self.TOL)
843 for i in range(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i]),taus[i])
844
845 def test_PowerLaw_QuadSmall_CubeSmall(self):
846 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]
847 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]
848 pl=PowerLaw(numMaterials=3,verbose=VERBOSE)
849 pl.setDruckerPragerLaw(tau_Y=100.)
850 pl.setPowerLaws(eta_N=[2.,10.,25./4.],tau_t=[1, 25.,64.], power=[1,2,3])
851 pl.setEtaTolerance(self.TOL)
852 for i in range(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i]),taus[i])
853
854 def test_PowerLaw_withShear(self):
855 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]
856 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]
857 pl=PowerLaw(numMaterials=1,verbose=VERBOSE)
858 pl.setDruckerPragerLaw(tau_Y=100.)
859 pl.setPowerLaw(eta_N=2.)
860 pl.setElasticShearModulus(3.)
861 dt=1./3.
862 pl.setEtaTolerance(self.TOL)
863 self.assertRaises(ValueError, pl.getEtaEff,gamma_dot_s[0])
864 for i in range(len(taus)): self.checkResult(i,gamma_dot_s[i], pl.getEtaEff(gamma_dot_s[i],dt=dt),taus[i])
865
866
867 class Test_FaultSystem(unittest.TestCase):
868 EPS=1.e-8
869 NE=10
870 def test_Fault_MaxValue(self):
871 dom=Rectangle(2*self.NE,2*self.NE)
872 x=dom.getX()
873 f=FaultSystem(dim=2)
874 f.addFault(V0=[0.5,0.], strikes=[3.*pi/4], ls=[0.70710678118654757], tag=1)
875 f.addFault(V0=[1.,0.5], strikes=[pi, pi/2], ls=[0.5,0.5], tag=2)
876
877 u=x[0]*(1.-x[0])*(1-x[1])
878 t, loc=f.getMaxValue(u)
879 p=f.getParametrization(x,t)[0]
880 m, l=loc(u), loc(p)
881 self.assertTrue( m == 0.25, "wrong max value")
882 self.assertTrue( t == 1, "wrong max tag")
883 self.assertTrue( l == 0., "wrong max location")
884
885 u=x[1]*(1.-x[1])*(1-x[0])*x[0]
886 t, loc=f.getMaxValue(u)
887 p=f.getParametrization(x,t)[0]
888 m, l=loc(u), loc(p)
889 self.assertTrue( m == 0.0625, "wrong max value")
890 self.assertTrue( t == 2, "wrong max tag")
891 self.assertTrue( l == 0.5, "wrong max location")
892
893 u=x[0]*(1.-x[0])*x[1]
894 t, loc=f.getMaxValue(u)
895 p=f.getParametrization(x,t)[0]
896 m, l=loc(u), loc(p)
897 self.assertTrue( m == 0.25, "wrong max value")
898 self.assertTrue( t == 2, "wrong max tag")
899 self.assertTrue( l == 1.0, "wrong max location")
900
901 u=x[1]*(1.-x[1])*x[0]
902 t, loc=f.getMaxValue(u)
903 p=f.getParametrization(x,t)[0]
904 m, l=loc(u), loc(p)
905 self.assertTrue( m == 0.25, "wrong max value")
906 self.assertTrue( t == 2, "wrong max tag")
907 self.assertTrue( l == 0., "wrong max location")
908
909 u=x[1]*(1.-x[1])*(1.-x[0])
910 t, loc=f.getMaxValue(u)
911 p=f.getParametrization(x,t)[0]
912 m, l=loc(u), loc(p)
913 self.assertTrue( m == 0.25, "wrong max value")
914 self.assertTrue( t == 1, "wrong max tag")
915 self.assertTrue( abs(l-0.70710678118654) <= self.EPS, "wrong max location")
916 def test_Fault_MinValue(self):
917 dom=Rectangle(2*self.NE,2*self.NE)
918 x=dom.getX()
919 f=FaultSystem(dim=2)
920 f.addFault(V0=[0.5,0.], strikes=[3.*pi/4], ls=[0.70710678118654757], tag=1)
921 f.addFault(V0=[1.,0.5], strikes=[pi, pi/2], ls=[0.5,0.5], tag=2)
922
923 u=-x[0]*(1.-x[0])*(1-x[1])
924 t, loc=f.getMinValue(u)
925 p=f.getParametrization(x,t)[0]
926 m, l=loc(u), loc(p)
927 self.assertTrue( m == -0.25, "wrong min value")
928 self.assertTrue( t == 1, "wrong min tag")
929 self.assertTrue( l == 0., "wrong min location")
930 u=-x[1]*(1.-x[1])*(1-x[0])*x[0]
931 t, loc=f.getMinValue(u)
932 p=f.getParametrization(x,t)[0]
933 m, l=loc(u), loc(p)
934 self.assertTrue( m == -0.0625, "wrong min value")
935 self.assertTrue( t == 2, "wrong min tag")
936 self.assertTrue( l == 0.5, "wrong min location")
937 u=-x[0]*(1.-x[0])*x[1]
938 t, loc=f.getMinValue(u)
939 p=f.getParametrization(x,t)[0]
940 m, l=loc(u), loc(p)
941 self.assertTrue( m == -0.25, "wrong min value")
942 self.assertTrue( t == 2, "wrong min tag")
943 self.assertTrue( l == 1.0, "wrong min location")
944 u=-x[1]*(1.-x[1])*x[0]
945 t, loc=f.getMinValue(u)
946 p=f.getParametrization(x,t)[0]
947 m, l=loc(u), loc(p)
948 self.assertTrue( m == -0.25, "wrong min value")
949 self.assertTrue( t == 2, "wrong min tag")
950 self.assertTrue( l == 0., "wrong min location")
951 u=-x[1]*(1.-x[1])*(1.-x[0])
952 t, loc=f.getMinValue(u)
953 p=f.getParametrization(x,t)[0]
954 m, l=loc(u), loc(p)
955 self.assertTrue( m == -0.25, "wrong min value")
956 self.assertTrue( t == 1, "wrong min tag")
957 self.assertTrue( abs(l-0.70710678118654) <= self.EPS, "wrong min location")
958
959
960 def test_Fault2D(self):
961 f=FaultSystem(dim=2)
962 top1=[ [1.,0.], [1.,1.], [0.,1.] ]
963 self.assertRaises(ValueError,f.addFault,V0=[1.,0],strikes=[pi/2, pi/2],ls=[1.,1.],tag=1,dips=top1)
964 f.addFault(V0=[1.,0],strikes=[pi/2, pi],ls=[1.,1.],tag=1)
965 self.assertTrue(f.getDim() == 2, "wrong dimension")
966 self.assertTrue( [ 1 ] == f.getTags(), "tags wrong")
967 self.assertTrue( 2. == f.getTotalLength(1), "length wrong")
968 self.assertTrue( 0. == f.getMediumDepth(1), "depth wrong")
969 self.assertTrue( (0., 2.) == f.getW0Range(1)," wrong W0 range")
970 self.assertTrue( (0., 0.) == f.getW1Range(1)," wrong W1 range")
971 self.assertTrue( [0., 1., 2.] == f.getW0Offsets(1)," wrong W0 offsets")
972 segs=f.getTopPolyline(1)
973 self.assertTrue( len(segs) == 3, "wrong number of segments")
974 self.assertTrue( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")
975 self.assertTrue( segs[0].size == 2, "seg 0 has wrong size.")
976 self.assertTrue( numpy.linalg.norm(segs[0]-[1.,0.]) < self.EPS, "wrong vertex. 0 ")
977 self.assertTrue( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1")
978 self.assertTrue( segs[1].size == 2, "seg 1 has wrong size.")
979 self.assertTrue( numpy.linalg.norm(segs[1]-[1.,1.]) < self.EPS, "wrong vertex. 1 ")
980 self.assertTrue( isinstance(segs[2], numpy.ndarray), "wrong class of vertex 2")
981 self.assertTrue( segs[2].size == 2, "seg 2 has wrong size.")
982 self.assertTrue( numpy.linalg.norm(segs[2]-[0.,1.]) < self.EPS, "wrong vertex. 2 ")
983 c=f.getCenterOnSurface()
984 self.assertTrue( isinstance(c, numpy.ndarray), "center has wrong class")
985 self.assertTrue( c.size == 2, "center size is wrong")
986 self.assertTrue( numpy.linalg.norm(c-[2./3.,2./3.]) < self.EPS, "center has wrong coordinates.")
987 o=f.getOrientationOnSurface()/pi*180.
988 self.assertTrue( abs(o+45.) < self.EPS, "wrong orientation.")
989
990 top2=[ [10.,0.], [0.,10.] ]
991 f.addFault(V0=[10.,0],strikes=[3.*pi/4],ls=[14.142135623730951], tag=2, w0_offsets=[0,20], w1_max=20)
992 self.assertTrue( [ 1, 2 ] == f.getTags(), "tags wrong")
993 self.assertTrue( abs(f.getTotalLength(2)-14.1421356237) < self.EPS * 14.1421356237, "wrong length")
994 self.assertTrue( 0. == f.getMediumDepth(2), "depth wrong")
995 self.assertTrue( (0., 20.) == f.getW0Range(2)," wrong W0 range")
996 self.assertTrue( (0., 0.) == f.getW1Range(2)," wrong W1 range")
997 self.assertTrue( [0., 20.] == f.getW0Offsets(2)," wrong W0 offsets")
998 segs=f.getTopPolyline(2)
999 self.assertTrue( len(segs) == 2, "wrong number of segments")
1000 self.assertTrue( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")
1001 self.assertTrue( numpy.linalg.norm(segs[0]-[10.,0.]) < self.EPS, "wrong vertex. 0 ")
1002 self.assertTrue( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1")
1003 self.assertTrue( numpy.linalg.norm(segs[1]-[0.,10.]) < self.EPS, "wrong vertex. 1 ")
1004 c=f.getCenterOnSurface()
1005 self.assertTrue( isinstance(c, numpy.ndarray), "center has wrong class")
1006 self.assertTrue( c.size == 2, "center size is wrong")
1007 self.assertTrue( numpy.linalg.norm(c-[12./5.,12./5.]) < self.EPS, "center has wrong coordinates.")
1008 o=f.getOrientationOnSurface()/pi*180.
1009 self.assertTrue( abs(o+45.) < self.EPS, "wrong orientation.")
1010
1011 s,d=f.getSideAndDistance([0.,0.], tag=1)
1012 self.assertTrue( s<0, "wrong side.")
1013 self.assertTrue( abs(d-1.)<self.EPS, "wrong distance.")
1014 s,d=f.getSideAndDistance([0.,2.], tag=1)
1015 self.assertTrue( s>0, "wrong side.")
1016 self.assertTrue( abs(d-1.)<self.EPS, "wrong distance.")
1017 s,d=f.getSideAndDistance([1.,2.], tag=1)
1018 self.assertTrue( s>0, "wrong side.")
1019 self.assertTrue( abs(d-1.)<self.EPS, "wrong distance.")
1020 s,d=f.getSideAndDistance([2.,1.], tag=1)
1021 self.assertTrue( s>0, "wrong side.")
1022 self.assertTrue( abs(d-1.)<self.EPS, "wrong distance.")
1023 s,d=f.getSideAndDistance([2.,0.], tag=1)
1024 self.assertTrue( s>0, "wrong side.")
1025 self.assertTrue( abs(d-1.)<self.EPS, "wrong distance.")
1026 s,d=f.getSideAndDistance([0.,-1.], tag=1)
1027 self.assertTrue( s<0, "wrong side.")
1028 self.assertTrue( abs(d-1.41421356237)<self.EPS, "wrong distance.")
1029 s,d=f.getSideAndDistance([-1.,0], tag=1)
1030 self.assertTrue( s<0, "wrong side.")
1031 self.assertTrue( abs(d-1.41421356237)<self.EPS, "wrong distance.")
1032
1033
1034 f.transform(rot=-pi/2., shift=[-1.,-1.])
1035 self.assertTrue( [ 1, 2 ] == f.getTags(), "tags after transformation wrong")
1036 self.assertTrue( 2. == f.getTotalLength(1), "length after transformation wrong")
1037 self.assertTrue( 0. == f.getMediumDepth(1), "depth after transformation wrong")
1038 self.assertTrue( (0., 2.) == f.getW0Range(1)," wrong W0 after transformation range")
1039 self.assertTrue( (0., 0.) == f.getW1Range(1)," wrong W1 rangeafter transformation ")
1040 self.assertTrue( [0., 1., 2.] == f.getW0Offsets(1)," wrong W0 offsetsafter transformation ")
1041 segs=f.getTopPolyline(1)
1042 self.assertTrue( len(segs) == 3, "wrong number of segmentsafter transformation ")
1043 self.assertTrue( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0 after transformation")
1044 self.assertTrue( segs[0].size == 2, "seg 0 has wrong size after transformation.")
1045 self.assertTrue( numpy.linalg.norm(segs[0]-[-1.,0.]) < self.EPS, "wrong vertex. 0 after transformation")
1046 self.assertTrue( isinstance(segs[1], numpy.ndarray), "wrong class of vertex after transformation1")
1047 self.assertTrue( segs[1].size == 2, "seg 1 has wrong size after transformation.")
1048 self.assertTrue( numpy.linalg.norm(segs[1]-[0.,0.]) < self.EPS, "wrong vertex. after transformation1 ")
1049 self.assertTrue( isinstance(segs[2], numpy.ndarray), "wrong class of vertex after transformation2")
1050 self.assertTrue( segs[2].size == 2, "seg 2 has wrong size after transformation.")
1051 self.assertTrue( numpy.linalg.norm(segs[2]-[0., 1.]) < self.EPS, "wrong vertex after transformation. 2 ")
1052 self.assertTrue( abs(f.getTotalLength(2)-14.1421356237) < self.EPS * 14.1421356237, "wrong length after transformation")
1053 self.assertTrue( 0. == f.getMediumDepth(2), "depth wrong after transformation")
1054 self.assertTrue( (0., 20.) == f.getW0Range(2)," wrong W0 range after transformation")
1055 self.assertTrue( (0., 0.) == f.getW1Range(2)," wrong W1 range after transformation")
1056 self.assertTrue( [0., 20.] == f.getW0Offsets(2)," wrong W0 offsets after transformation")
1057 segs=f.getTopPolyline(2)
1058 self.assertTrue( len(segs) == 2, "wrong number of segments after transformation")
1059 self.assertTrue( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0 after transformation")
1060 self.assertTrue( numpy.linalg.norm(segs[0]-[-1.,-9]) < self.EPS, "wrong vertex. 0 after transformation")
1061 self.assertTrue( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1 after transformation")
1062 self.assertTrue( numpy.linalg.norm(segs[1]-[9.,1.]) < self.EPS, "wrong vertex. 1 after transformation")
1063
1064 c=f.getCenterOnSurface()
1065 self.assertTrue( isinstance(c, numpy.ndarray), "center has wrong class")
1066 self.assertTrue( c.size == 2, "center size is wrong")
1067 self.assertTrue( numpy.linalg.norm(c-[7./5.,-7./5.]) < self.EPS, "center has wrong coordinates.")
1068 o=f.getOrientationOnSurface()/pi*180.
1069 self.assertTrue( abs(o-45.) < self.EPS, "wrong orientation.")
1070
1071 p=f.getParametrization([-1.,0.],1)
1072 self.assertTrue(p[1]==1., "wrong value.")
1073 self.assertTrue(abs(p[0])<self.EPS, "wrong value.")
1074 p=f.getParametrization([-0.5,0.],1)
1075 self.assertTrue(p[1]==1., "wrong value.")
1076 self.assertTrue(abs(p[0]-0.5)<self.EPS* 0.5, "wrong value.")
1077 p=f.getParametrization([0.,0.],1)
1078 self.assertTrue(p[1]==1., "wrong value.")
1079 self.assertTrue(abs(p[0]-1.)<self.EPS, "wrong value.")
1080 p=f.getParametrization([0.0000001,0.0000001],1, tol=1.e-8)
1081 self.assertTrue(p[1]==0., "wrong value.")
1082 p=f.getParametrization([0.0000001,0.0000001],1, tol=1.e-6)
1083 self.assertTrue(p[1]==1., "wrong value.")
1084 self.assertTrue(abs(p[0]-1.0000001)<self.EPS, "wrong value.")
1085 p=f.getParametrization([0.,0.5],1)
1086 self.assertTrue(p[1]==1., "wrong value.")
1087 self.assertTrue(abs(p[0]-1.5)<self.EPS, "wrong value.")
1088 p=f.getParametrization([0,1.],1)
1089 self.assertTrue(p[1]==1., "wrong value.")
1090 self.assertTrue(abs(p[0]-2.)<self.EPS, "wrong value.")
1091 p=f.getParametrization([1.,1.],1)
1092 self.assertTrue(p[1]==0., "wrong value.")
1093 p=f.getParametrization([0,1.11],1)
1094 self.assertTrue(p[1]==0., "wrong value.")
1095 p=f.getParametrization([-1,-9.],2)
1096 self.assertTrue(p[1]==1., "wrong value.")
1097 self.assertTrue(abs(p[0])<self.EPS, "wrong value.")
1098 p=f.getParametrization([9,1],2)
1099 self.assertTrue(p[1]==1., "wrong value.")
1100 self.assertTrue(abs(p[0]-20.)<self.EPS, "wrong value.")
1101
1102 def test_Fault3D(self):
1103 f=FaultSystem(dim=3)
1104 self.assertTrue(f.getDim() == 3, "wrong dimension")
1105
1106 top1=[ [0.,0.,0.], [1., 0., 0.] ]
1107 f.addFault(V0=[0.,0,0],strikes=[0.],ls=[1.,], dips=pi/2, depths=20.,tag=1)
1108 self.assertTrue( [ 1 ] == f.getTags(), "tags wrong")
1109 self.assertTrue( 1. == f.getTotalLength(1), "length wrong")
1110 self.assertTrue( 20. == f.getMediumDepth(1), "depth wrong")
1111 self.assertTrue( (0., 1.) == f.getW0Range(1)," wrong W0 range")
1112 self.assertTrue( (-20., 0.) == f.getW1Range(1)," wrong W1 range")
1113 self.assertTrue( [0., 1.] == f.getW0Offsets(1)," wrong W0 offsets")
1114 segs=f.getTopPolyline(1)
1115 self.assertTrue( len(segs) == 2, "wrong number of segments")
1116 self.assertTrue( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")
1117 self.assertTrue( segs[0].size == 3, "seg 0 has wrong size.")
1118 self.assertTrue( numpy.linalg.norm(segs[0]-[0.,0.,0.]) < self.EPS, "wrong vertex. 0 ")
1119 self.assertTrue( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1")
1120 self.assertTrue( segs[1].size == 3, "seg 1 has wrong size.")
1121 self.assertTrue( numpy.linalg.norm(segs[1]-[1.,0.,0]) < self.EPS, "wrong vertex. 1 ")
1122 c=f.getCenterOnSurface()
1123 self.assertTrue( isinstance(c, numpy.ndarray), "center has wrong class")
1124 self.assertTrue( c.size == 3, "center size is wrong")
1125 self.assertTrue( numpy.linalg.norm(c-[0.5,0.,0.]) < self.EPS, "center has wrong coordinates.")
1126 o=f.getOrientationOnSurface()/pi*180.
1127 self.assertTrue( abs(o) < self.EPS, "wrong orientation.")
1128 d=f.getDips(1)
1129 self.assertTrue( len(d) == 1, "wrong number of dips")
1130 self.assertTrue( abs(d[0]-1.5707963267948966) < self.EPS, "wrong dip 0")
1131 sn=f.getSegmentNormals(1)
1132 self.assertTrue( len(sn) == 1, "wrong number of normals")
1133 self.assertTrue( isinstance(sn[0], numpy.ndarray), "wrong class of bottom vertex 0")
1134 self.assertTrue( numpy.linalg.norm(sn[0]-[0, -1., 0.]) < self.EPS, "wrong bottom vertex 1 ")
1135 dv=f.getDepthVectors(1)
1136 self.assertTrue( len(dv) == 2, "wrong number of depth vectors.")
1137 self.assertTrue( isinstance(dv[0], numpy.ndarray), "wrong class of depth vector 0")
1138 self.assertTrue( numpy.linalg.norm(dv[0]-[0., 0., -20.]) < self.EPS, "wrong depth vector 0 ")
1139 self.assertTrue( isinstance(dv[1], numpy.ndarray), "wrong class of depth vector 1")
1140 self.assertTrue( numpy.linalg.norm(dv[1]-[0., 0., -20.]) < self.EPS, "wrong depth vector 1 ")
1141 b=f.getBottomPolyline(1)
1142 self.assertTrue( len(b) == 2, "wrong number of bottom vertices")
1143 self.assertTrue( isinstance(b[0], numpy.ndarray), "wrong class of bottom vertex 0")
1144 self.assertTrue( numpy.linalg.norm(b[0]-[0., 0., -20.]) < self.EPS, "wrong bottom vertex 0 ")
1145 self.assertTrue( isinstance(b[1], numpy.ndarray), "wrong class of bottom vertex 1")
1146 self.assertTrue( numpy.linalg.norm(b[1]-[1., 0., -20.]) < self.EPS, "wrong bottom vertex 1 ")
1147 ds=f.getDepths(1)
1148 self.assertTrue( len(ds) == 2, "wrong number of depth")
1149 self.assertTrue( abs(ds[0]-20.) < self.EPS, "wrong depth at vertex 0 ")
1150 self.assertTrue( abs(ds[1]-20.) < self.EPS, "wrong depth at vertex 1 ")
1151
1152 top2=[ [0.,0.,0.], [0., 10., 0.] ]
1153 f.addFault(V0=[0.,0,0],strikes=[pi/2],ls=[10.,], dips=pi/2, depths=20.,tag=2)
1154 self.assertTrue( [ 1, 2 ] == f.getTags(), "tags wrong")
1155 self.assertTrue( 10. == f.getTotalLength(2), "length wrong")
1156 self.assertTrue( 20. == f.getMediumDepth(2), "depth wrong")
1157 self.assertTrue( (0., 10.) == f.getW0Range(2)," wrong W0 range")
1158 self.assertTrue( (-20., 0.) == f.getW1Range(2)," wrong W1 range")
1159 self.assertTrue( [0., 10.] == f.getW0Offsets(2)," wrong W0 offsets")
1160 segs=f.getTopPolyline(2)
1161 self.assertTrue( len(segs) == 2, "wrong number of segments")
1162 self.assertTrue( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")
1163 self.assertTrue( segs[0].size == 3, "seg 0 has wrong size.")
1164 self.assertTrue( numpy.linalg.norm(segs[0]-[0.,0.,0.]) < self.EPS, "wrong vertex. 0 ")
1165 self.assertTrue( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1")
1166 self.assertTrue( segs[1].size == 3, "seg 1 has wrong size.")
1167 self.assertTrue( numpy.linalg.norm(segs[1]-[0., 10., 0]) < self.EPS, "wrong vertex. 1 ")
1168 d=f.getDips(2)
1169 self.assertTrue( len(d) == 1, "wrong number of dips")
1170 self.assertTrue( abs(d[0]-1.5707963267948966) < self.EPS, "wrong dip 0")
1171 sn=f.getSegmentNormals(2)
1172 self.assertTrue( len(sn) == 1, "wrong number of normals")
1173 self.assertTrue( isinstance(sn[0], numpy.ndarray), "wrong class of bottom vertex 0")
1174 self.assertTrue( numpy.linalg.norm(sn[0]-[1, 0., 0.]) < self.EPS, "wrong bottom vertex 1 ")
1175 dv=f.getDepthVectors(2)
1176 self.assertTrue( len(dv) == 2, "wrong number of depth vectors.")
1177 self.assertTrue( isinstance(dv[0], numpy.ndarray), "wrong class of depth vector 0")
1178 self.assertTrue( numpy.linalg.norm(dv[0]-[0., 0., -20.]) < self.EPS, "wrong depth vector 0 ")
1179 self.assertTrue( isinstance(dv[1], numpy.ndarray), "wrong class of depth vector 1")
1180 self.assertTrue( numpy.linalg.norm(dv[1]-[0., 0., -20.]) < self.EPS, "wrong depth vector 1 ")
1181 b=f.getBottomPolyline(2)
1182 self.assertTrue( len(b) == 2, "wrong number of bottom vertices")
1183 self.assertTrue( isinstance(b[0], numpy.ndarray), "wrong class of bottom vertex 0")
1184 self.assertTrue( numpy.linalg.norm(b[0]-[0., 0., -20.]) < self.EPS, "wrong bottom vertex 0 ")
1185 self.assertTrue( isinstance(b[1], numpy.ndarray), "wrong class of bottom vertex 1")
1186 self.assertTrue( numpy.linalg.norm(b[1]-[0., 10., -20.]) < self.EPS, "wrong bottom vertex 1 ")
1187 ds=f.getDepths(2)
1188 self.assertTrue( len(ds) == 2, "wrong number of depth")
1189 self.assertTrue( abs(ds[0]-20.) < self.EPS, "wrong depth at vertex 0 ")
1190 self.assertTrue( abs(ds[1]-20.) < self.EPS, "wrong depth at vertex 1 ")
1191
1192 top2=[ [10.,0.,0.], [0., 10., 0.] ]
1193 f.addFault(V0=[10.,0,0],strikes=3*pi/4,ls=14.142135623730951, dips=pi/2, depths=30.,tag=2)
1194 self.assertTrue( [ 1, 2 ] == f.getTags(), "tags wrong")
1195 self.assertTrue( abs(14.142135623730951 - f.getTotalLength(2)) <self.EPS, "length wrong")
1196 self.assertTrue( 30. == f.getMediumDepth(2), "depth wrong")
1197 self.assertTrue( (-30., 0.) == f.getW1Range(2)," wrong W1 range")
1198 segs=f.getTopPolyline(2)
1199 self.assertTrue( len(segs) == 2, "wrong number of segments")
1200 self.assertTrue( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")
1201 self.assertTrue( segs[0].size == 3, "seg 0 has wrong size.")
1202 self.assertTrue( numpy.linalg.norm(segs[0]-[10.,0.,0.]) < self.EPS, "wrong vertex. 0 ")
1203 self.assertTrue( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1")
1204 self.assertTrue( segs[1].size == 3, "seg 1 has wrong size.")
1205 self.assertTrue( numpy.linalg.norm(segs[1]-[0., 10., 0]) < self.EPS, "wrong vertex. 1 ")
1206 d=f.getDips(2)
1207 self.assertTrue( len(d) == 1, "wrong number of dips")
1208 self.assertTrue( abs(d[0]-1.5707963267948966) < self.EPS, "wrong dip 0")
1209 sn=f.getSegmentNormals(2)
1210 self.assertTrue( len(sn) == 1, "wrong number of normals")
1211 self.assertTrue( isinstance(sn[0], numpy.ndarray), "wrong class of bottom vertex 0")
1212 self.assertTrue( numpy.linalg.norm(sn[0]-[0.70710678118654746, 0.70710678118654746, 0.]) < self.EPS, "wrong bottom vertex 1 ")
1213 dv=f.getDepthVectors(2)
1214 self.assertTrue( len(dv) == 2, "wrong number of depth vectors.")
1215 self.assertTrue( isinstance(dv[0], numpy.ndarray), "wrong class of depth vector 0")
1216 self.assertTrue( numpy.linalg.norm(dv[0]-[0., 0., -30.]) < self.EPS, "wrong depth vector 0 ")
1217 self.assertTrue( isinstance(dv[1], numpy.ndarray), "wrong class of depth vector 1")
1218 self.assertTrue( numpy.linalg.norm(dv[1]-[0., 0., -30.]) < self.EPS, "wrong depth vector 1 ")
1219 b=f.getBottomPolyline(2)
1220 self.assertTrue( len(b) == 2, "wrong number of bottom vertices")
1221 self.assertTrue( isinstance(b[0], numpy.ndarray), "wrong class of bottom vertex 0")
1222 self.assertTrue( numpy.linalg.norm(b[0]-[10., 0., -30.]) < self.EPS, "wrong bottom vertex 0 ")
1223 self.assertTrue( isinstance(b[1], numpy.ndarray), "wrong class of bottom vertex 1")
1224 self.assertTrue( numpy.linalg.norm(b[1]-[0., 10., -30.]) < self.EPS, "wrong bottom vertex 1 ")
1225 ds=f.getDepths(2)
1226 self.assertTrue( len(ds) == 2, "wrong number of depth")
1227 self.assertTrue( abs(ds[0]-30.) < self.EPS, "wrong depth at vertex 0 ")
1228 self.assertTrue( abs(ds[1]-30.) < self.EPS, "wrong depth at vertex 1 ")
1229
1230 top2=[ [10.,0.,0.], [0., 10., 0.] ]
1231 f.addFault(V0=[10.,0,0],strikes=3*pi/4,ls=14.142135623730951, dips=pi/4, depths=50.,tag=2)
1232 self.assertTrue( [ 1, 2 ] == f.getTags(), "tags wrong")
1233 self.assertTrue( abs(14.142135623730951 - f.getTotalLength(2)) <self.EPS, "length wrong")
1234 self.assertTrue( 50. == f.getMediumDepth(2), "depth wrong")
1235 self.assertTrue( (-50., 0.) == f.getW1Range(2)," wrong W1 range")
1236 segs=f.getTopPolyline(2)
1237 self.assertTrue( len(segs) == 2, "wrong number of segments")
1238 self.assertTrue( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")
1239 self.assertTrue( segs[0].size == 3, "seg 0 has wrong size.")
1240 self.assertTrue( numpy.linalg.norm(segs[0]-[10.,0.,0.]) < self.EPS, "wrong vertex. 0 ")
1241 self.assertTrue( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1")
1242 self.assertTrue( segs[1].size == 3, "seg 1 has wrong size.")
1243 self.assertTrue( numpy.linalg.norm(segs[1]-[0., 10., 0]) < self.EPS, "wrong vertex. 1 ")
1244 d=f.getDips(2)
1245 self.assertTrue( len(d) == 1, "wrong number of dips")
1246 self.assertTrue( abs(d[0]-0.78539816339744828) < self.EPS, "wrong dip 0")
1247 sn=f.getSegmentNormals(2)
1248 self.assertTrue( len(sn) == 1, "wrong number of normals")
1249 self.assertTrue( isinstance(sn[0], numpy.ndarray), "wrong class of bottom vertex 0")
1250 self.assertTrue( numpy.linalg.norm(sn[0]-[0.5,0.5,0.70710678118654746]) < self.EPS, "wrong bottom vertex 1 ")
1251 dv=f.getDepthVectors(2)
1252 self.assertTrue( len(dv) == 2, "wrong number of depth vectors.")
1253 self.assertTrue( isinstance(dv[0], numpy.ndarray), "wrong class of depth vector 0")
1254 self.assertTrue( numpy.linalg.norm(dv[0]-[25., 25., -35.355339059327378]) < self.EPS, "wrong depth vector 0 ")
1255 self.assertTrue( isinstance(dv[1], numpy.ndarray), "wrong class of depth vector 1")
1256 self.assertTrue( numpy.linalg.norm(dv[1]-[25.,25., -35.355339059327378]) < self.EPS, "wrong depth vector 1 ")
1257 b=f.getBottomPolyline(2)
1258 self.assertTrue( len(b) == 2, "wrong number of bottom vertices")
1259 self.assertTrue( isinstance(b[0], numpy.ndarray), "wrong class of bottom vertex 0")
1260 self.assertTrue( numpy.linalg.norm(b[0]-[35., 25., -35.355339059327378]) < self.EPS, "wrong bottom vertex 0 ")
1261 self.assertTrue( isinstance(b[1], numpy.ndarray), "wrong class of bottom vertex 1")
1262 self.assertTrue( numpy.linalg.norm(b[1]-[25, 35., -35.355339059327378]) < self.EPS, "wrong bottom vertex 1 ")
1263 ds=f.getDepths(2)
1264 self.assertTrue( len(ds) == 2, "wrong number of depth")
1265 self.assertTrue( abs(ds[0]-50.) < self.EPS, "wrong depth at vertex 0 ")
1266 self.assertTrue( abs(ds[1]-50.) < self.EPS, "wrong depth at vertex 1 ")
1267
1268 top1=[ [10.,0.,0], [10.,10.,0], [0.,10.,0] ]
1269 f.addFault(V0=[10.,0.,0.],strikes=[pi/2, pi],ls=[10.,10.],tag=1, dips=pi/4, depths=20.)
1270 self.assertTrue( 20. == f.getTotalLength(1), "length wrong")
1271 self.assertTrue( 20. == f.getMediumDepth(1), "depth wrong")
1272 segs=f.getTopPolyline(1)
1273 self.assertTrue( len(segs) == 3, "wrong number of segments")
1274 self.assertTrue( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")
1275 self.assertTrue( segs[0].size == 3, "seg 0 has wrong size.")
1276 self.assertTrue( numpy.linalg.norm(segs[0]-[10.,0.,0.]) < self.EPS, "wrong vertex. 0 ")
1277 self.assertTrue( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1")
1278 self.assertTrue( segs[1].size == 3, "seg 1 has wrong size.")
1279 self.assertTrue( numpy.linalg.norm(segs[1]-[10.,10.,0.]) < self.EPS, "wrong vertex. 1 ")
1280 self.assertTrue( isinstance(segs[2], numpy.ndarray), "wrong class of vertex 2")
1281 self.assertTrue( segs[2].size == 3, "seg 2 has wrong size.")
1282 self.assertTrue( numpy.linalg.norm(segs[2]-[0.,10.,0.]) < self.EPS, "wrong vertex. 2 ")
1283 d=f.getDips(1)
1284 self.assertTrue( len(d) == 2, "wrong number of dips")
1285 self.assertTrue( abs(d[0]-0.78539816339744828) < self.EPS, "wrong dip 0")
1286 self.assertTrue( abs(d[1]-0.78539816339744828) < self.EPS, "wrong dip 0")
1287 ds=f.getDepths(1)
1288 self.assertTrue( len(ds) == 3, "wrong number of depth")
1289 self.assertTrue( abs(ds[0]-20.) < self.EPS, "wrong depth at vertex 0 ")
1290 self.assertTrue( abs(ds[1]-20.) < self.EPS, "wrong depth at vertex 1 ")
1291 sn=f.getSegmentNormals(1)
1292 self.assertTrue( len(sn) == 2, "wrong number of normals")
1293 self.assertTrue( isinstance(sn[0], numpy.ndarray), "wrong class of bottom vertex 0")
1294 self.assertTrue( numpy.linalg.norm(sn[0]-[0.70710678118654746,0.,0.70710678118654746]) < self.EPS, "wrong bottom vertex 1 ")
1295 self.assertTrue( isinstance(sn[1], numpy.ndarray), "wrong class of bottom vertex 0")
1296 self.assertTrue( numpy.linalg.norm(sn[1]-[0.,0.70710678118654746,0.70710678118654746]) < self.EPS, "wrong bottom vertex 1 ")
1297 dv=f.getDepthVectors(1)
1298 self.assertTrue( len(dv) == 3, "wrong number of depth vectors.")
1299 self.assertTrue( isinstance(dv[0], numpy.ndarray), "wrong class of depth vector 0")
1300 self.assertTrue( numpy.linalg.norm(dv[0]-[14.142135623730951, 0., -14.142135623730951]) < self.EPS, "wrong depth vector 0 ")
1301 self.assertTrue( isinstance(dv[1], numpy.ndarray), "wrong class of depth vector 1")
1302 self.assertTrue( numpy.linalg.norm(dv[1]-[11.547005383792515,11.547005383792515, -11.547005383792515]) < self.EPS, "wrong depth vector 2 ")
1303 self.assertTrue( isinstance(dv[2], numpy.ndarray), "wrong class of depth vector 1")
1304 self.assertTrue( numpy.linalg.norm(dv[2]-[0.,14.142135623730951, -14.142135623730951]) < self.EPS, "wrong depth vector 2 ")
1305 segs=f.getBottomPolyline(1)
1306 self.assertTrue( len(segs) == 3, "wrong number of segments")
1307 self.assertTrue( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")
1308 self.assertTrue( segs[0].size == 3, "seg 0 has wrong size.")
1309 self.assertTrue( numpy.linalg.norm(segs[0]-[24.142135623730951,0.,-14.142135623730951]) < self.EPS, "wrong vertex. 0 ")
1310 self.assertTrue( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1")
1311 self.assertTrue( segs[1].size == 3, "seg 1 has wrong size.")
1312 self.assertTrue( numpy.linalg.norm(segs[1]-[21.547005383792515,21.547005383792515, -11.547005383792515]) < self.EPS, "wrong vertex. 1 ")
1313 self.assertTrue( isinstance(segs[2], numpy.ndarray), "wrong class of vertex 2")
1314 self.assertTrue( segs[2].size == 3, "seg 2 has wrong size.")
1315 self.assertTrue( numpy.linalg.norm(segs[2]-[0., 24.142135623730951, -14.142135623730951]) < self.EPS, "wrong vertex. 2 ")
1316 self.assertTrue( abs(0.-f.getW0Range(1)[0]) <=self.EPS," wrong W0 range (0)")
1317 self.assertTrue( abs(31.857329272664341-f.getW0Range(1)[1]) <=self.EPS," wrong W0 range (1)")
1318 self.assertTrue( abs(-20. - f.getW1Range(1)[0]) <=self.EPS," wrong W1 range (0)")
1319 self.assertTrue( abs(0. - f.getW1Range(1)[1]) <=self.EPS," wrong W1 range (1)")
1320 self.assertTrue( abs(0.0-f.getW0Offsets(1)[0])<=self.EPS," wrong W0 offsets (0)")
1321 self.assertTrue( abs(15.92866463633217-f.getW0Offsets(1)[1])<=self.EPS," wrong W0 offsets (1)")
1322 self.assertTrue( abs(31.857329272664341-f.getW0Offsets(1)[2])<=self.EPS," wrong W0 offsets(2)")
1323 #
1324 # ============ fresh start ====================
1325 #
1326 f.addFault(V0=[1.,0,0.],strikes=[pi/2, pi],ls=[1.,1.], dips=pi/2,depths=20,tag=1)
1327 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)
1328 c=f.getCenterOnSurface()
1329 self.assertTrue( isinstance(c, numpy.ndarray), "center has wrong class")
1330 self.assertTrue( c.size == 3, "center size is wrong")
1331 self.assertTrue( numpy.linalg.norm(c-[12./5.,12./5.,0.]) < self.EPS, "center has wrong coordinates.")
1332 o=f.getOrientationOnSurface()/pi*180.
1333 self.assertTrue( abs(o+45.) < self.EPS, "wrong orientation.")
1334
1335 f.transform(rot=-pi/2., shift=[-1.,-1.,0.])
1336 self.assertTrue( [ 1, 2 ] == f.getTags(), "tags after transformation wrong")
1337 self.assertTrue( 2. == f.getTotalLength(1), "length after transformation wrong")
1338 self.assertTrue( 20. == f.getMediumDepth(1), "depth after transformation wrong")
1339 rw0=f.getW0Range(1)
1340 self.assertTrue( len(rw0) ==2, "wo range has wrong length")
1341 self.assertTrue( abs(rw0[0]) < self.EPS,"W0 0 wrong.")
1342 self.assertTrue( abs(rw0[1]-2.) < self.EPS,"W0 1 wrong.")
1343 self.assertTrue( (-20., 0.) == f.getW1Range(1)," wrong W1 rangeafter transformation ")
1344 dips=f.getDips(1)
1345 self.assertTrue(len(dips) == 2, "wrong number of dips.")
1346 self.assertTrue( abs(dips[0]-1.5707963267948966) <= self.EPS, "wrong dip")
1347 self.assertTrue( abs(dips[1]-1.5707963267948966) <= self.EPS, "wrong dip")
1348 ds=f.getDepths(1)
1349 self.assertTrue( len(ds) == 3, "wrong number of depth")
1350 self.assertTrue( abs(ds[0]-20.) < self.EPS, "wrong depth at vertex 0 ")
1351 self.assertTrue( abs(ds[1]-20.) < self.EPS, "wrong depth at vertex 1 ")
1352 self.assertTrue( abs(ds[2]-20.) < self.EPS, "wrong depth at vertex 1 ")
1353 segs=f.getTopPolyline(1)
1354 self.assertTrue( len(segs) == 3, "wrong number of segmentsafter transformation ")
1355 self.assertTrue( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0 after transformation")
1356 self.assertTrue( segs[0].size == 3, "seg 0 has wrong size after transformation.")
1357 self.assertTrue( numpy.linalg.norm(segs[0]-[-1.,0.,0.]) < self.EPS, "wrong vertex. 0 after transformation")
1358 self.assertTrue( isinstance(segs[1], numpy.ndarray), "wrong class of vertex after transformation1")
1359 self.assertTrue( segs[1].size == 3, "seg 1 has wrong size after transformation.")
1360 self.assertTrue( numpy.linalg.norm(segs[1]-[0.,0.,0.]) < self.EPS, "wrong vertex. after transformation1 ")
1361 self.assertTrue( isinstance(segs[2], numpy.ndarray), "wrong class of vertex after transformation2")
1362 self.assertTrue( segs[2].size == 3, "seg 2 has wrong size after transformation.")
1363 self.assertTrue( numpy.linalg.norm(segs[2]-[0., 1.,0.]) < self.EPS, "wrong vertex after transformation. 2 ")
1364 self.assertTrue( abs(f.getTotalLength(2)-14.1421356237) < self.EPS * 14.1421356237, "wrong length after transformation")
1365 self.assertTrue( 20. == f.getMediumDepth(2), "depth wrong after transformation")
1366 rw0=f.getW0Range(2)
1367 self.assertTrue( len(rw0) ==2, "wo range has wrong length")
1368 self.assertTrue( abs(rw0[0]) < self.EPS,"W0 0 wrong.")
1369 self.assertTrue( abs(rw0[1]-20.) < self.EPS,"W0 1 wrong.")
1370 self.assertTrue( (-20., 0.) == f.getW1Range(2)," wrong W1 range after transformation")
1371 self.assertTrue( [0., 20.] == f.getW0Offsets(2)," wrong W0 offsets after transformation")
1372 dips=f.getDips(2)
1373 self.assertTrue(len(dips) == 1, "wrong number of dips.")
1374 self.assertTrue( abs(dips[0]-1.5707963267948966) <= self.EPS, "wrong dip")
1375 ds=f.getDepths(2)
1376 self.assertTrue( len(ds) == 2, "wrong number of depth")
1377 self.assertTrue( abs(ds[0]-20.) < self.EPS, "wrong depth at vertex 0 ")
1378 self.assertTrue( abs(ds[1]-20.) < self.EPS, "wrong depth at vertex 1 ")
1379 segs=f.getTopPolyline(2)
1380 self.assertTrue( len(segs) == 2, "wrong number of segments after transformation")
1381 self.assertTrue( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0 after transformation")
1382 self.assertTrue( numpy.linalg.norm(segs[0]-[-1.,-9,0.]) < self.EPS, "wrong vertex. 0 after transformation")
1383 self.assertTrue( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1 after transformation")
1384 self.assertTrue( numpy.linalg.norm(segs[1]-[9.,1.,0.]) < self.EPS, "wrong vertex. 1 after transformation")
1385 #
1386 # ============ fresh start ====================
1387 #
1388 f=FaultSystem(dim=3)
1389
1390 top1=[ [0.,0.,0.], [1., 0., 0.] ]
1391 f.addFault(V0=[0.,0,0],strikes=[0.],ls=[1.,], dips=pi/2, depths=1.,tag=1)
1392 top1=[ [10.,0.,0], [10.,10.,0], [0.,10.,0] ]
1393 f.addFault(V0=[10.,0.,0.],strikes=[pi/2, pi],ls=[10.,10.],tag=2, dips=pi/4, depths=20.)
1394
1395 p,m=f.getParametrization([0.3,0.,-0.5],1)
1396 self.assertTrue(length(p-[0.3,-0.5]) <= self.EPS, "wrong value.")
1397 self.assertTrue(m==1., "wrong value.")
1398
1399 p,m=f.getParametrization([0.5,0.,-0.5],1)
1400 self.assertTrue(length(p-[0.5,-0.5]) <= self.EPS, "wrong value.")
1401 self.assertTrue(m==1., "wrong value.")
1402
1403 p,m=f.getParametrization([0.25,0.,-0.5],1)
1404 self.assertTrue(length(p-[0.25,-0.5]) <= self.EPS, "wrong value.")
1405 self.assertTrue(m==1., "wrong value.")
1406
1407 p,m=f.getParametrization([0.5,0.,-0.25],1)
1408 self.assertTrue(length(p-[0.5,-0.25]) <= self.EPS, "wrong value.")
1409 self.assertTrue(m==1., "wrong value.")
1410
1411 p,m=f.getParametrization([0.001,0.,-0.001],1)
1412 self.assertTrue(length(p-[0.001, -0.001]) <= self.EPS, "wrong value.")
1413 self.assertTrue(m==1., "wrong value.")
1414
1415 p,m=f.getParametrization([0.001,0.,0.001],1)
1416 self.assertTrue(m==0., "wrong value.")
1417
1418 p,m=f.getParametrization([0.999,0.,0.001],1)
1419 self.assertTrue(m==0., "wrong value.")
1420
1421 p,m=f.getParametrization([1.001,0.,-0.001],1)
1422 self.assertTrue(m==0., "wrong value.")
1423 p,m=f.getParametrization([1.001,0.,-0.1],1)
1424 self.assertTrue(m==0., "wrong value.")
1425 p,m=f.getParametrization([1.001,0.,-0.000000001],1)
1426 self.assertTrue(m==0., "wrong value.")
1427
1428 p,m=f.getParametrization([0.999,0.,-0.001],1)
1429 self.assertTrue(length(p-[0.999, -0.001]) <= self.EPS, "wrong value.")
1430 self.assertTrue(m==1., "wrong value.")
1431
1432 p,m=f.getParametrization([ 16.29252873 , 6.46410161 ,-6.29252873], 2, tol=1.e-7)
1433 self.assertTrue(m==1., "wrong value.")
1434 self.assertTrue(length(p-[4.7785993908996511, -10]) <= self.EPS*10., "wrong value.")
1435 p,m=f.getParametrization([15.77350269, 12.77350269, -5.77350269], 2, tol=1.e-7)
1436 self.assertTrue(m==1., "wrong value.")
1437 self.assertTrue(length(p-[11.150065245432518, -10]) <= self.EPS*10., "wrong value.")
1438
1439 p,m=f.getParametrization([ 3., 17.0710678, -7.0710678], 2, tol=1.e-7)
1440 self.assertTrue(m==1., "wrong value.")
1441 self.assertTrue(length(p-[27.078729881764687, -10]) <= self.EPS*10., "wrong value.")
1442 p,m=f.getParametrization([9.30940108, 16.55204176, -6.55204176], 2, tol=1.e-7)
1443 self.assertTrue(m==1., "wrong value.")
1444 self.assertTrue(length(p-[20.707264027231822, -10]) <= self.EPS*10., "wrong value.")
1445
1446 p,m=f.getParametrization([ 21.54700538, 21.54700538, -11.54700538], 2, tol=1.e-7)
1447 self.assertTrue(m==1., "wrong value.")
1448 self.assertTrue(length(p-[15.92866463633217, -20]) <= self.EPS*10., "wrong value.")
1449
1450 p,m=f.getParametrization([ 0.,0.,0.], 2, tol=1.e-7)
1451 self.assertTrue(m==0., "wrong value.")
1452
1453 p,m=f.getParametrization([ 11.,11.,0.], 2, tol=1.e-7)
1454 self.assertTrue(m==0., "wrong value.")
1455
1456
1457 s,d=f.getSideAndDistance([0.,-1.,0.], tag=1)
1458 self.assertTrue( s>0, "wrong side.")
1459 self.assertTrue( abs(d-1.)<self.EPS, "wrong distance.")
1460 s,d=f.getSideAndDistance([1.,-1.,0.], tag=1)
1461 self.assertTrue( s>0, "wrong side.")
1462 self.assertTrue( abs(d-1.)<self.EPS, "wrong distance.")
1463 s,d=f.getSideAndDistance([0.,1.,0.], tag=1)
1464 self.assertTrue( s<0, "wrong side.")
1465 self.assertTrue( abs(d-1.)<self.EPS, "wrong distance.")
1466 s,d=f.getSideAndDistance([1.,1.,0.], tag=1)
1467 self.assertTrue( s<0, "wrong side.")
1468 self.assertTrue( abs(d-1.)<self.EPS, "wrong distance.")
1469
1470
1471 s,d=f.getSideAndDistance([0.,0.,0.], tag=2)
1472 self.assertTrue( s<0, "wrong side.")
1473 self.assertTrue( abs(d-10.)<self.EPS, "wrong distance.")
1474 s,d=f.getSideAndDistance([5.,5.,0.], tag=2)
1475 self.assertTrue( s<0, "wrong side.")
1476 self.assertTrue( abs(d-5.)<self.EPS, "wrong distance.")
1477
1478 s,d=f.getSideAndDistance([10.,10.,-1.], tag=2)
1479 self.assertTrue( s<0, "wrong side.")
1480 self.assertTrue( abs(d-0.70710678118654757)<self.EPS, "wrong distance.")
1481 s,d=f.getSideAndDistance([10.,10.,-2.], tag=2)
1482 self.assertTrue( s<0, "wrong side.")
1483 self.assertTrue( abs(d-2.*0.70710678118654757)<self.EPS, "wrong distance.")
1484 s,d=f.getSideAndDistance([10.,10.,-3.], tag=2)
1485 self.assertTrue( s<0, "wrong side.")
1486 self.assertTrue( abs(d-3.*0.70710678118654757)<self.EPS, "wrong distance.")
1487
1488 s,d=f.getSideAndDistance([5.,12.,0], tag=2)
1489 self.assertTrue( s>0, "wrong side.")
1490 self.assertTrue( abs(d-2*0.70710678118654757)<self.EPS, "wrong distance.")
1491 s,d=f.getSideAndDistance([5.,12.,-1], tag=2)
1492 self.assertTrue( s>0, "wrong side.")
1493 self.assertTrue( abs(d-0.70710678118654757)<self.EPS, "wrong distance.")
1494 s,d=f.getSideAndDistance([5.,12.,-2], tag=2)
1495 # s not checked as it is undefined.
1496 self.assertTrue( abs(d)<self.EPS, "wrong distance.")
1497 s,d=f.getSideAndDistance([5.,12.,-3], tag=2)
1498 self.assertTrue( s<0, "wrong side.")
1499 self.assertTrue( abs(d-0.70710678118654757)<self.EPS, "wrong distance.")
1500 s,d=f.getSideAndDistance([5.,12.,-4], tag=2)
1501 self.assertTrue( s<0, "wrong side.")
1502 self.assertTrue( abs(d-2.*0.70710678118654757)<self.EPS, "wrong distance.")
1503
1504 if __name__ == '__main__':
1505 run_tests(__name__, exit_on_failure=True)
1506

  ViewVC Help
Powered by ViewVC 1.1.26