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

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

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

revision 1414 by gross, Thu Feb 14 10:01:43 2008 UTC revision 1471 by gross, Thu Apr 3 05:19:06 2008 UTC
# Line 41  class Test_Simple2DModels(unittest.TestC Line 41  class Test_Simple2DModels(unittest.TestC
41         self.domain=Rectangle(NE,NE,order=2,useFullElementOrder=True)         self.domain=Rectangle(NE,NE,order=2,useFullElementOrder=True)
42     def tearDown(self):     def tearDown(self):
43         del self.domain         del self.domain
44     def test_StokesProblemCartesian_P_0(self):     def test_StokesProblemCartesian_PCG_P_0(self):
45         ETA=1.         ETA=1.
46         P1=0.         P1=0.
47    
# Line 57  class Test_Simple2DModels(unittest.TestC Line 57  class Test_Simple2DModels(unittest.TestC
57         sp.initialize(f=F,fixed_u_mask=mask,eta=ETA)         sp.initialize(f=F,fixed_u_mask=mask,eta=ETA)
58         u0=(1-x[0])*x[0]*[0.,1.]         u0=(1-x[0])*x[0]*[0.,1.]
59         p0=Scalar(P1,ReducedSolution(self.domain))         p0=Scalar(P1,ReducedSolution(self.domain))
60         u,p=sp.solve(u0,p0,show_details=VERBOSE, verbose=VERBOSE,max_iter=100)         u,p=sp.solve(u0,p0,show_details=VERBOSE, verbose=VERBOSE,max_iter=100,solver="PCG")
61                
62         error_v0=Lsup(u[0]-u0[0])         error_v0=Lsup(u[0]-u0[0])
63         error_v1=Lsup(u[1]-u0[1])/0.25         error_v1=Lsup(u[1]-u0[1])/0.25
# Line 68  class Test_Simple2DModels(unittest.TestC Line 68  class Test_Simple2DModels(unittest.TestC
68         self.failUnless(error_v0<TOL,"0-velocity error too large.")         self.failUnless(error_v0<TOL,"0-velocity error too large.")
69         self.failUnless(error_v1<TOL,"1-velocity error too large.")         self.failUnless(error_v1<TOL,"1-velocity error too large.")
70    
71     def test_StokesProblemCartesian_P_small(self):     def test_StokesProblemCartesian_PCG_P_small(self):
72         ETA=1.         ETA=1.
73         P1=1.         P1=1.
74    
# Line 84  class Test_Simple2DModels(unittest.TestC Line 84  class Test_Simple2DModels(unittest.TestC
84         sp.initialize(f=F,fixed_u_mask=mask,eta=ETA)         sp.initialize(f=F,fixed_u_mask=mask,eta=ETA)
85         u0=(1-x[0])*x[0]*[0.,1.]         u0=(1-x[0])*x[0]*[0.,1.]
86         p0=Scalar(P1,ReducedSolution(self.domain))         p0=Scalar(P1,ReducedSolution(self.domain))
87         u,p=sp.solve(u0,p0,show_details=VERBOSE, verbose=VERBOSE,max_iter=100)         u,p=sp.solve(u0,p0,show_details=VERBOSE, verbose=VERBOSE,max_iter=100,solver="PCG")
88                
89         error_v0=Lsup(u[0]-u0[0])         error_v0=Lsup(u[0]-u0[0])
90         error_v1=Lsup(u[1]-u0[1])/0.25         error_v1=Lsup(u[1]-u0[1])/0.25
# Line 95  class Test_Simple2DModels(unittest.TestC Line 95  class Test_Simple2DModels(unittest.TestC
95         self.failUnless(error_v0<TOL,"0-velocity error too large.")         self.failUnless(error_v0<TOL,"0-velocity error too large.")
96         self.failUnless(error_v1<TOL,"1-velocity error too large.")         self.failUnless(error_v1<TOL,"1-velocity error too large.")
97    
98     def test_StokesProblemCartesian_P_large(self):     def test_StokesProblemCartesian_PCG_P_large(self):
99         ETA=1.         ETA=1.
100         P1=1000.         P1=1000.
101    
# Line 111  class Test_Simple2DModels(unittest.TestC Line 111  class Test_Simple2DModels(unittest.TestC
111         sp.initialize(f=F,fixed_u_mask=mask,eta=ETA)         sp.initialize(f=F,fixed_u_mask=mask,eta=ETA)
112         u0=(1-x[0])*x[0]*[0.,1.]         u0=(1-x[0])*x[0]*[0.,1.]
113         p0=Scalar(P1,ReducedSolution(self.domain))         p0=Scalar(P1,ReducedSolution(self.domain))
114         u,p=sp.solve(u0,p0,show_details=VERBOSE, verbose=VERBOSE,max_iter=100)         u,p=sp.solve(u0,p0,show_details=VERBOSE, verbose=VERBOSE,max_iter=100,solver="PCG")
115          
116           error_v0=Lsup(u[0]-u0[0])
117           error_v1=Lsup(u[1]-u0[1])/0.25
118           zz=P1*x[0]*x[1]-p
119           error_p=Lsup(zz-integrate(zz))/P1
120           # print error_p, error_v0,error_v1
121           self.failUnless(error_p<TOL,"pressure error too large.")
122           self.failUnless(error_v0<TOL,"0-velocity error too large.")
123           self.failUnless(error_v1<TOL,"1-velocity error too large.")
124    
125       def test_StokesProblemCartesian_GMRES_P_0(self):
126           ETA=1.
127           P1=0.
128    
129           x=self.domain.getX()
130           F=-P1*x[1]*[1.,0]+(2*ETA-P1*x[0])*[0.,1.]
131           mask=whereZero(x[0])    * [1.,1.] \
132                  +whereZero(x[0]-1)  * [1.,1.] \
133                  +whereZero(x[1])    * [1.,0.] \
134                  +whereZero(x[1]-1)  * [1.,1.]
135          
136           sp=StokesProblemCartesian(self.domain)
137          
138           sp.initialize(f=F,fixed_u_mask=mask,eta=ETA)
139           u0=(1-x[0])*x[0]*[0.,1.]
140           p0=Scalar(P1,ReducedSolution(self.domain))
141           u,p=sp.solve(u0,p0,show_details=VERBOSE, verbose=VERBOSE,max_iter=100,solver="GMRES")
142          
143           error_v0=Lsup(u[0]-u0[0])
144           error_v1=Lsup(u[1]-u0[1])/0.25
145           zz=P1*x[0]*x[1]-p
146           error_p=Lsup(zz-integrate(zz))
147           # print error_p, error_v0,error_v1
148           self.failUnless(error_p<TOL,"pressure error too large.")
149           self.failUnless(error_v0<TOL,"0-velocity error too large.")
150           self.failUnless(error_v1<TOL,"1-velocity error too large.")
151    
152       def test_StokesProblemCartesian_GMRES_P_small(self):
153           ETA=1.
154           P1=1.
155    
156           x=self.domain.getX()
157           F=-P1*x[1]*[1.,0]+(2*ETA-P1*x[0])*[0.,1.]
158           mask=whereZero(x[0])    * [1.,1.] \
159                  +whereZero(x[0]-1)  * [1.,1.] \
160                  +whereZero(x[1])    * [1.,0.] \
161                  +whereZero(x[1]-1)  * [1.,1.]
162          
163           sp=StokesProblemCartesian(self.domain)
164          
165           sp.initialize(f=F,fixed_u_mask=mask,eta=ETA)
166           u0=(1-x[0])*x[0]*[0.,1.]
167           p0=Scalar(P1,ReducedSolution(self.domain))
168           u,p=sp.solve(u0,p0,show_details=VERBOSE, verbose=VERBOSE,max_iter=100,solver="GMRES")
169          
170           error_v0=Lsup(u[0]-u0[0])
171           error_v1=Lsup(u[1]-u0[1])/0.25
172           zz=P1*x[0]*x[1]-p
173           error_p=Lsup(zz-integrate(zz))
174           # print error_p, error_v0,error_v1
175           self.failUnless(error_p<TOL,"pressure error too large.")
176           self.failUnless(error_v0<TOL,"0-velocity error too large.")
177           self.failUnless(error_v1<TOL,"1-velocity error too large.")
178    
179       def test_StokesProblemCartesian_GMRES_P_large(self):
180           ETA=1.
181           P1=1000.
182    
183           x=self.domain.getX()
184           F=-P1*x[1]*[1.,0]+(2*ETA-P1*x[0])*[0.,1.]
185           mask=whereZero(x[0])    * [1.,1.] \
186                  +whereZero(x[0]-1)  * [1.,1.] \
187                  +whereZero(x[1])    * [1.,0.] \
188                  +whereZero(x[1]-1)  * [1.,1.]
189          
190           sp=StokesProblemCartesian(self.domain)
191          
192           sp.initialize(f=F,fixed_u_mask=mask,eta=ETA)
193           u0=(1-x[0])*x[0]*[0.,1.]
194           p0=Scalar(P1,ReducedSolution(self.domain))
195           u,p=sp.solve(u0,p0,show_details=VERBOSE, verbose=VERBOSE,max_iter=100,solver="GMRES")
196                
197         error_v0=Lsup(u[0]-u0[0])         error_v0=Lsup(u[0]-u0[0])
198         error_v1=Lsup(u[1]-u0[1])/0.25         error_v1=Lsup(u[1]-u0[1])/0.25
# Line 128  class Test_Simple3DModels(unittest.TestC Line 209  class Test_Simple3DModels(unittest.TestC
209         self.domain=Brick(NE,NE,NE,order=2,useFullElementOrder=True)         self.domain=Brick(NE,NE,NE,order=2,useFullElementOrder=True)
210     def tearDown(self):     def tearDown(self):
211         del self.domain         del self.domain
212     def test_StokesProblemCartesian_P_0(self):     def test_StokesProblemCartesian_PCG_P_0(self):
213           ETA=1.
214           P1=0.
215    
216           x=self.domain.getX()
217           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.]
218           x=self.domain.getX()
219           mask=whereZero(x[0])    * [1.,1.,1.] \
220                  +whereZero(x[0]-1)  * [1.,1.,1.] \
221                  +whereZero(x[1])    * [1.,1.,1.] \
222                  +whereZero(x[1]-1)  * [1.,1.,1.] \
223                  +whereZero(x[2])    * [1.,1.,0.] \
224                  +whereZero(x[2]-1)  * [1.,1.,1.]
225          
226          
227           sp=StokesProblemCartesian(self.domain)
228          
229           sp.initialize(f=F,fixed_u_mask=mask,eta=ETA)
230           u0=(1-x[0])*x[0]*(1-x[1])*x[1]*[0.,0.,1.]
231           p0=Scalar(P1,ReducedSolution(self.domain))
232           u,p=sp.solve(u0,p0,show_details=VERBOSE, verbose=VERBOSE,max_iter=100,solver="PCG")
233          
234           error_v0=Lsup(u[0]-u0[0])
235           error_v1=Lsup(u[1]-u0[1])
236           error_v2=Lsup(u[2]-u0[2])/0.25**2
237           zz=P1*x[0]*x[1]*x[2]-p
238           error_p=Lsup(zz-integrate(zz))
239           # print error_p, error_v0,error_v1,error_v2
240           self.failUnless(error_p<TOL,"pressure error too large.")
241           self.failUnless(error_v0<TOL,"0-velocity error too large.")
242           self.failUnless(error_v1<TOL,"1-velocity error too large.")
243           self.failUnless(error_v2<TOL,"2-velocity error too large.")
244       def test_StokesProblemCartesian_PCG_P_small(self):
245           ETA=1.
246           P1=1.
247    
248           x=self.domain.getX()
249           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.]
250           mask=whereZero(x[0])    * [1.,1.,1.] \
251                  +whereZero(x[0]-1)  * [1.,1.,1.] \
252                  +whereZero(x[1])    * [1.,1.,1.] \
253                  +whereZero(x[1]-1)  * [1.,1.,1.] \
254                  +whereZero(x[2])    * [1.,1.,0.] \
255                  +whereZero(x[2]-1)  * [1.,1.,1.]
256          
257          
258           sp=StokesProblemCartesian(self.domain)
259          
260           sp.initialize(f=F,fixed_u_mask=mask,eta=ETA)
261           u0=(1-x[0])*x[0]*(1-x[1])*x[1]*[0.,0.,1.]
262           p0=Scalar(P1,ReducedSolution(self.domain))
263           u,p=sp.solve(u0,p0,show_details=VERBOSE, verbose=VERBOSE,max_iter=100,solver="PCG")
264          
265           error_v0=Lsup(u[0]-u0[0])
266           error_v1=Lsup(u[1]-u0[1])
267           error_v2=Lsup(u[2]-u0[2])/0.25**2
268           zz=P1*x[0]*x[1]*x[2]-p
269           error_p=Lsup(zz-integrate(zz))/P1
270           # print error_p, error_v0,error_v1,error_v2
271           self.failUnless(error_p<TOL,"pressure error too large.")
272           self.failUnless(error_v0<TOL,"0-velocity error too large.")
273           self.failUnless(error_v1<TOL,"1-velocity error too large.")
274           self.failUnless(error_v2<TOL,"2-velocity error too large.")
275       def test_StokesProblemCartesian_PCG_P_large(self):
276           ETA=1.
277           P1=1000.
278    
279           x=self.domain.getX()
280           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.]
281           mask=whereZero(x[0])    * [1.,1.,1.] \
282                  +whereZero(x[0]-1)  * [1.,1.,1.] \
283                  +whereZero(x[1])    * [1.,1.,1.] \
284                  +whereZero(x[1]-1)  * [1.,1.,1.] \
285                  +whereZero(x[2])    * [1.,1.,0.] \
286                  +whereZero(x[2]-1)  * [1.,1.,1.]
287          
288          
289           sp=StokesProblemCartesian(self.domain)
290          
291           sp.initialize(f=F,fixed_u_mask=mask,eta=ETA)
292           u0=(1-x[0])*x[0]*(1-x[1])*x[1]*[0.,0.,1.]
293           p0=Scalar(P1,ReducedSolution(self.domain))
294           u,p=sp.solve(u0,p0,show_details=VERBOSE, verbose=VERBOSE,max_iter=100,solver="PCG")
295          
296           error_v0=Lsup(u[0]-u0[0])
297           error_v1=Lsup(u[1]-u0[1])
298           error_v2=Lsup(u[2]-u0[2])/0.25**2
299           zz=P1*x[0]*x[1]*x[2]-p
300           error_p=Lsup(zz-integrate(zz))/P1
301           # print error_p, error_v0,error_v1,error_v2
302           self.failUnless(error_p<TOL,"pressure error too large.")
303           self.failUnless(error_v0<TOL,"0-velocity error too large.")
304           self.failUnless(error_v1<TOL,"1-velocity error too large.")
305           self.failUnless(error_v2<TOL,"2-velocity error too large.")
306    
307       def test_StokesProblemCartesian_GMRES_P_0(self):
308         ETA=1.         ETA=1.
309         P1=0.         P1=0.
310    
# Line 148  class Test_Simple3DModels(unittest.TestC Line 324  class Test_Simple3DModels(unittest.TestC
324         sp.initialize(f=F,fixed_u_mask=mask,eta=ETA)         sp.initialize(f=F,fixed_u_mask=mask,eta=ETA)
325         u0=(1-x[0])*x[0]*(1-x[1])*x[1]*[0.,0.,1.]         u0=(1-x[0])*x[0]*(1-x[1])*x[1]*[0.,0.,1.]
326         p0=Scalar(P1,ReducedSolution(self.domain))         p0=Scalar(P1,ReducedSolution(self.domain))
327         u,p=sp.solve(u0,p0,show_details=VERBOSE, verbose=VERBOSE,max_iter=100)         u,p=sp.solve(u0,p0,show_details=VERBOSE, verbose=VERBOSE,max_iter=100,solver="GMRES")
328                
329         error_v0=Lsup(u[0]-u0[0])         error_v0=Lsup(u[0]-u0[0])
330         error_v1=Lsup(u[1]-u0[1])         error_v1=Lsup(u[1]-u0[1])
# Line 160  class Test_Simple3DModels(unittest.TestC Line 336  class Test_Simple3DModels(unittest.TestC
336         self.failUnless(error_v0<TOL,"0-velocity error too large.")         self.failUnless(error_v0<TOL,"0-velocity error too large.")
337         self.failUnless(error_v1<TOL,"1-velocity error too large.")         self.failUnless(error_v1<TOL,"1-velocity error too large.")
338         self.failUnless(error_v2<TOL,"2-velocity error too large.")         self.failUnless(error_v2<TOL,"2-velocity error too large.")
339     def test_StokesProblemCartesian_P_small(self):     def test_StokesProblemCartesian_GMRES_P_small(self):
340         ETA=1.         ETA=1.
341         P1=1.         P1=1.
342    
# Line 179  class Test_Simple3DModels(unittest.TestC Line 355  class Test_Simple3DModels(unittest.TestC
355         sp.initialize(f=F,fixed_u_mask=mask,eta=ETA)         sp.initialize(f=F,fixed_u_mask=mask,eta=ETA)
356         u0=(1-x[0])*x[0]*(1-x[1])*x[1]*[0.,0.,1.]         u0=(1-x[0])*x[0]*(1-x[1])*x[1]*[0.,0.,1.]
357         p0=Scalar(P1,ReducedSolution(self.domain))         p0=Scalar(P1,ReducedSolution(self.domain))
358         u,p=sp.solve(u0,p0,show_details=VERBOSE, verbose=VERBOSE,max_iter=100)         u,p=sp.solve(u0,p0,show_details=VERBOSE, verbose=VERBOSE,max_iter=100,solver="GMRES")
359                
360         error_v0=Lsup(u[0]-u0[0])         error_v0=Lsup(u[0]-u0[0])
361         error_v1=Lsup(u[1]-u0[1])         error_v1=Lsup(u[1]-u0[1])
# Line 191  class Test_Simple3DModels(unittest.TestC Line 367  class Test_Simple3DModels(unittest.TestC
367         self.failUnless(error_v0<TOL,"0-velocity error too large.")         self.failUnless(error_v0<TOL,"0-velocity error too large.")
368         self.failUnless(error_v1<TOL,"1-velocity error too large.")         self.failUnless(error_v1<TOL,"1-velocity error too large.")
369         self.failUnless(error_v2<TOL,"2-velocity error too large.")         self.failUnless(error_v2<TOL,"2-velocity error too large.")
370     def test_StokesProblemCartesian_P_large(self):     def test_StokesProblemCartesian_GMRES_P_large(self):
371         ETA=1.         ETA=1.
372         P1=1000.         P1=1000.
373    
# Line 210  class Test_Simple3DModels(unittest.TestC Line 386  class Test_Simple3DModels(unittest.TestC
386         sp.initialize(f=F,fixed_u_mask=mask,eta=ETA)         sp.initialize(f=F,fixed_u_mask=mask,eta=ETA)
387         u0=(1-x[0])*x[0]*(1-x[1])*x[1]*[0.,0.,1.]         u0=(1-x[0])*x[0]*(1-x[1])*x[1]*[0.,0.,1.]
388         p0=Scalar(P1,ReducedSolution(self.domain))         p0=Scalar(P1,ReducedSolution(self.domain))
389         u,p=sp.solve(u0,p0,show_details=VERBOSE, verbose=VERBOSE,max_iter=100)         u,p=sp.solve(u0,p0,show_details=VERBOSE, verbose=VERBOSE,max_iter=100,solver="GMRES")
390                
391         error_v0=Lsup(u[0]-u0[0])         error_v0=Lsup(u[0]-u0[0])
392         error_v1=Lsup(u[1]-u0[1])         error_v1=Lsup(u[1]-u0[1])

Legend:
Removed from v.1414  
changed lines
  Added in v.1471

  ViewVC Help
Powered by ViewVC 1.1.26