Contents of /trunk/doc/examples/geotutorial/forward_euler.py

Revision 2156 - (show annotations)
Mon Dec 15 05:09:02 2008 UTC (12 years, 9 months ago) by gross
File MIME type: text/x-python
File size: 1985 byte(s)
```some modifications to the iterative solver to make them easier to use.
There are also improved versions of the Darcy flux solver and the incompressible solver.

```
 1 ######################################################## 2 # 3 # Copyright (c) 2003-2008 by University of Queensland 4 # Earth Systems Science Computational Center (ESSCC) 5 6 # 7 # Primary Business: Queensland, Australia 8 # Licensed under the Open Software License version 3.0 9 10 # 11 ######################################################## 12 13 __copyright__="""Copyright (c) 2003-2008 by University of Queensland 14 Earth Systems Science Computational Center (ESSCC) 15 http://www.uq.edu.au/esscc 16 Primary Business: Queensland, Australia""" 17 __license__="""Licensed under the Open Software License version 3.0 18 19 __url__= 20 21 # import tools 22 from esys.escript import * 23 from esys.escript.linearPDEs import LinearPDE 24 from esys.finley import Rectangle 25 # end of simulation time 26 t_end=0.1 27 # dimensions: 28 L0=1.;L1=1. 29 # location, size and value of heat source 30 xc=[0.3,0.4]; r=0.1; Qc=3000 31 # material parameter 32 k=1.; rhocp=100; 33 # bottom temperature: 34 T_bot=100 35 # generate domain: 36 mydomain=Rectangle(l0=L0,l1=L1,n0=20,n1=20) 37 x=mydomain.getX() 38 # set boundray temperature: 39 T_D=T_bot/L1*(L1-x[1]) 40 # set heat source: 41 Q=Qc*whereNegative(length(x-xc)-r) 42 # time step size: 43 dt=0.01 44 # or use adaptive choice dt=0.05*inf(rhocp*mydomain.getSize()**2/k) 45 print "time step size = ",dt 46 # generate domain: 47 mypde=LinearPDE(mydomain) 48 mypde.setSymmetryOn() 49 # set PDE coefficients: 50 mypde.setValue(D=rhocp, 51 r=T_D, q=whereZero(x[1])+whereZero(x[1]-L1)) 52 # initial temperature 53 T=T_D 54 # step counter and time marker: 55 N=0; t=0 56 # stop when t_end is reached: 57 while t