/[escript]/trunk/escript/test/python/test_pdetools.py
ViewVC logotype

Diff of /trunk/escript/test/python/test_pdetools.py

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

revision 2155 by gross, Wed Nov 26 08:13:00 2008 UTC revision 2156 by gross, Mon Dec 15 05:09:02 2008 UTC
# Line 332  class Test_pdetools_noLumping(unittest.T Line 332  class Test_pdetools_noLumping(unittest.T
332        u=p.getSolution()        u=p.getSolution()
333        u_ex=2.        u_ex=2.
334        self.failUnless(Lsup(u_ex-u)<Lsup(u_ex)*self.RES_TOL,"value wrong")        self.failUnless(Lsup(u_ex-u)<Lsup(u_ex)*self.RES_TOL,"value wrong")
335        #=====
336      def testPCG(self):      def testPCG(self):
337        from numarray import array,matrixmultiply, zeros, dot, size, Float64        from numarray import array,matrixmultiply, zeros, dot, size, Float64
338        from math import sqrt        from math import sqrt
# Line 404  class Test_pdetools_noLumping(unittest.T Line 404  class Test_pdetools_noLumping(unittest.T
404            return out            return out
405    
406        tol=1.e-4        tol=1.e-4
407        x,r=PCG(b*1.,Ap,Ms,dot, atol=0, rtol=tol,x=x_ref*1.5, iter_max=12)        x,r=PCG(b*1.,Ap,x_ref*0.,Ms,dot, atol=0, rtol=tol, iter_max=12)
408        self.failUnless(Lsup(x-x_ref)<=Lsup(x_ref)*tol*10.,"wrong solution")        self.failUnless(Lsup(x-x_ref)<=Lsup(x_ref)*tol*10.,"wrong solution")
409        self.failUnless(Lsup(r-(b-matrixmultiply(A,x)))<=Lsup(b)*EPSILON*100.,"wrong solution")        self.failUnless(Lsup(r-(b-matrixmultiply(A,x)))<=Lsup(b)*EPSILON*100.,"wrong solution")
410    
# Line 479  class Test_pdetools_noLumping(unittest.T Line 479  class Test_pdetools_noLumping(unittest.T
479            return out            return out
480    
481        tol=1.e-4        tol=1.e-4
482        x=MINRES(b*1.,Ap,Ms,dot, atol=0, rtol=tol,x=x_ref*1.5, iter_max=12)        x=MINRES(b*1.,Ap,x_ref*0,Ms,dot, atol=0, rtol=tol, iter_max=12)
483        self.failUnless(Lsup(x-x_ref)<=Lsup(x_ref)*tol*10.,"wrong solution")        self.failUnless(Lsup(x-x_ref)<=Lsup(x_ref)*tol*10.,"wrong solution")
484    
485      def testTFQMR(self):      def testTFQMR(self):
# Line 545  class Test_pdetools_noLumping(unittest.T Line 545  class Test_pdetools_noLumping(unittest.T
545                  -8.7934289814322  ])                  -8.7934289814322  ])
546    
547        def Ap(x):        def Ap(x):
548            return matrixmultiply(A,x)            out=matrixmultiply(A,x)
549        def Ms(b):            for i in xrange(size(x)):
550            out=zeros((size(b),),Float64)              out[i]/=A[i,i]
           for i in xrange(size(b)):  
             out[i]=b[i]/A[i,i]  
551            return out            return out
552    
553        tol=1.e-5        tol=1.e-5
554        x=TFQMR(b*1.,Ap,Ms,dot, atol=0, rtol=tol,x=x_ref*1.5, iter_max=12)        for i in xrange(size(b)): b[i]/=A[i,i]
555          x=TFQMR(b,Ap,x_ref*0,dot, atol=0, rtol=tol, iter_max=12)
556        self.failUnless(Lsup(x-x_ref)<=Lsup(x_ref)*tol*10.,"wrong solution")        self.failUnless(Lsup(x-x_ref)<=Lsup(x_ref)*tol*10.,"wrong solution")
557    
558      def testGMRES(self):      def testGMRES(self):
# Line 626  class Test_pdetools_noLumping(unittest.T Line 625  class Test_pdetools_noLumping(unittest.T
625    
626        tol=1.e-4        tol=1.e-4
627        for i in xrange(size(b)): b[i]/=A[i,i]        for i in xrange(size(b)): b[i]/=A[i,i]
628        x=GMRES(b*1.,Ap,dot,atol=0, rtol=tol,x=x_ref*1.5, iter_max=12)        x=GMRES(b,Ap,x_ref*0,dot,atol=0, rtol=tol, iter_max=12)
629        self.failUnless(Lsup(x-x_ref)<=Lsup(x_ref)*tol*10.,"wrong solution")        self.failUnless(Lsup(x-x_ref)<=Lsup(x_ref)*tol*10.,"wrong solution")
630    
631      def testNewtonGMRES(self):      def testNewtonGMRES(self):

Legend:
Removed from v.2155  
changed lines
  Added in v.2156

  ViewVC Help
Powered by ViewVC 1.1.26