/[escript]/trunk/esys2/modellib/py_src/flow.py
ViewVC logotype

Diff of /trunk/esys2/modellib/py_src/flow.py

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

revision 147 by jgs, Fri Aug 12 01:45:47 2005 UTC revision 149 by jgs, Thu Sep 1 03:31:39 2005 UTC
# Line 1  Line 1 
1  # $Id$  # $Id$
2    
3  from escript.escript import *  from esys.escript import *
4  from escript.modelframe import Model,IterationDivergenceError  from esys.escript.modelframe import Model,IterationDivergenceError
5  from escript.linearPDEs import LameEquation  from esys.escript.linearPDEs import LameEquation
6    
7  class SteadyIncompressibleFlow(Model):  class SteadyIncompressibleFlow(Model):
8         """         """
9    
10                     \f[         M{-\left(\eta\left(v_{i,j}+v_{j,i}\right)\right)_{,j}+p_{,i}=F_i}
11                     -\left(\eta\left(v_{i,j}+v_{j,i}\right)\right)_{,j}+p_{,i}=F_i        
12                     \f]         M{\sigma_{ij}=2\eta D_{ij}-p\,\delta_{ij}}
13    
14                     \f[         M{D_{ij}=\frac{1}{2}\left( v_{j,i} + v_{i,j }\right)}
15                     \sigma_{ij}=2\eta D_{ij}-p\,\delta_{ij}        
16                     \f[         M{v_{k,k} = 0}
                    D_{ij}=\frac{1}{2}\left( v_{j,i} + v_{i,j }\right) \; .  
                    \f]  
   
                    \f[  
                    -v_{k,k} = 0 \; .  
                    \f]  
17    
18         """         """
19    
20         def __init__(self,debug=False):         def __init__(self,debug=False):
21             """set up model"""             """
22               set up model
23               """
24             Model.__init__(self,debug=debug)             Model.__init__(self,debug=debug)
25             self.declareParameter(domain=None, \             self.declareParameter(domain=None, \
26                                   velocity=0., \                                   velocity=0., \
# Line 37  class SteadyIncompressibleFlow(Model): Line 33  class SteadyIncompressibleFlow(Model):
33             self.__iter=0             self.__iter=0
34    
35         def doInitialization(self):         def doInitialization(self):
36             """initialize model"""             """
37               initialize model
38               """
39             self.__p_old=None             self.__p_old=None
40             self.__p_very_old=None             self.__p_very_old=None
41             self.__dt_old=None             self.__dt_old=None
42             self.__pde=LameEquation(self.domain)             self.__pde=LameEquation(self.domain)
43    
44         def stress(self):         def stress(self):
45             """returns current stress"""             """
46               returns current stress"""
47             return 2*self.viscosity*self.stretching-self.pressure*kronecker(self.domain)             return 2*self.viscosity*self.stretching-self.pressure*kronecker(self.domain)
48    
49         def stretching(self):         def stretching(self):
50             """returns stertching tensor"""             """
51               returns stertching tensor
52               """
53             g=grad(self.velocity)             g=grad(self.velocity)
54             return (g+transpose(g))/2             return (g+transpose(g))/2
55    
56         def doStepPreprocessing(self,dt):         def doStepPreprocessing(self,dt):
57              """              """
58                 step up pressure iteration              step up pressure iteration
59    
60                 if run within a time dependend problem extrapolation of pressure from previous time steps is used to              if run within a time dependend problem extrapolation of pressure from previous time steps is used to
61                 get an initial guess (that needs some work!!!!!!!)              get an initial guess (that needs some work!!!!!!!)
62              """              """
63              self.__iter=0              self.__iter=0
64              self.__diff=1.e40              self.__diff=1.e40
# Line 70  class SteadyIncompressibleFlow(Model): Line 71  class SteadyIncompressibleFlow(Model):
71         def doStep(self,dt):         def doStep(self,dt):
72            """            """
73    
74               performs an iteration step of the penalty method.            performs an iteration step of the penalty method.
75               IterationDivergenceError is raised if pressure error cannot be reduced or max_iter is reached.            IterationDivergenceError is raised if pressure error cannot be reduced or max_iter is reached.
76    
77            """            """
78            penalty=self.viscosity/self.relaxation            penalty=self.viscosity/self.relaxation
# Line 84  class SteadyIncompressibleFlow(Model): Line 85  class SteadyIncompressibleFlow(Model):
85            self.__pde.setTolerance(self.rel_tol/10.)            self.__pde.setTolerance(self.rel_tol/10.)
86            self.velocity=self.__pde.getSolution()            self.velocity=self.__pde.getSolution()
87            update=penalty*div(self.velocity)            update=penalty*div(self.velocity)
           print "f=",inf(update),sup(update)  
88            self.pressure=self.pressure-update            self.pressure=self.pressure-update
89            self.__diff,diff_old=Lsup(update),self.__diff            self.__diff,diff_old=Lsup(update),self.__diff
90            self.__iter+=1            self.__iter+=1

Legend:
Removed from v.147  
changed lines
  Added in v.149

  ViewVC Help
Powered by ViewVC 1.1.26