/[escript]/trunk/modellib/test/python/run_convection.py
ViewVC logotype

Contents of /trunk/modellib/test/python/run_convection.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2416 - (show annotations)
Wed May 13 06:03:59 2009 UTC (11 years, 2 months ago) by gross
File MIME type: text/x-python
File size: 3545 byte(s)
* fix Windows MPI case: export system variables
* define ESCRIPT_NUM_PROC and ESCRIPT_NUM_NODES
* cleanup using os.path.join()
1
2 ########################################################
3 #
4 # Copyright (c) 2003-2008 by University of Queensland
5 # Earth Systems Science Computational Center (ESSCC)
6 # http://www.uq.edu.au/esscc
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 ########################################################
13
14 __copyright__="""Copyright (c) 2003-2008 by University of Queensland
15 Earth Systems Science Computational Center (ESSCC)
16 http://www.uq.edu.au/esscc
17 Primary Business: Queensland, Australia"""
18 __license__="""Licensed under the Open Software License version 3.0
19 http://www.opensource.org/licenses/osl-3.0.php"""
20 __url__="https://launchpad.net/escript-finley"
21
22 #
23 #
24 # a very simple convection model in model frame:
25 #
26
27 import os
28 from esys.escript.modelframe import Link,Simulation
29 from esys.modellib.geometry import RectangularDomain,ScalarConstrainerOverBox,VectorConstrainerOverBox
30 from esys.modellib.input import Sequencer,InterpolateOverBox,GaussianProfile,LinearCombination
31 from esys.modellib.flow import SteadyIncompressibleFlow
32 from esys.modellib.temperature import TemperatureAdvection
33 from esys.modellib.materials import SimpleEarthModel,GravityForce
34 from esys.modellib.visualization import WriteVTK
35
36 try:
37 WORKDIR=os.environ['MODELLIB_WORKDIR']
38 except KeyError:
39 WORKDIR='.'
40
41
42 dom=RectangularDomain()
43 dom.order=2
44
45 temp_val=InterpolateOverBox()
46 temp_val.domain=Link(dom,"domain")
47 temp_val.value_left_bottom_front=1.
48 temp_val.value_right_bottom_front=1.
49 temp_val.value_left_top_front=0.
50 temp_val.value_right_top_front=0.
51 temp_val.value_left_bottom_back=1.
52 temp_val.value_right_bottom_back=1.
53 temp_val.value_left_top_back=0.
54 temp_val.value_right_top_back=0.
55
56 temp_constraints=ScalarConstrainerOverBox()
57 temp_constraints.domain=Link(dom)
58 temp_constraints.top=1
59 temp_constraints.bottom=1
60
61 vel_constraints=VectorConstrainerOverBox()
62 vel_constraints.domain=Link(dom)
63 vel_constraints.left=[1,0,0]
64 vel_constraints.right=[1,0,0]
65 vel_constraints.top=[0,1,0]
66 vel_constraints.bottom=[0,1,0]
67 vel_constraints.front=[0,0,1]
68 vel_constraints.back=[0,0,1]
69
70 mat=SimpleEarthModel()
71 mat.density0=1.
72 mat.viscocity0=1.
73 mat.rayleigh_number=10000.
74 mat.alpha=0.001
75
76 temp=TemperatureAdvection(debug=True)
77 temp.domain=Link(dom)
78 temp.density=Link(mat,"density0")
79 temp.heat_capacity=Link(mat,"heat_capacity")
80 temp.location_fixed_temperature=Link(temp_constraints,"location_of_constraint")
81 temp.fixed_temperature=Link(temp_val,"out")
82 temp.safety_factor=0.01
83 mat.temperature=Link(temp,"temperature")
84
85
86 grav=GravityForce()
87 grav.domain=Link(dom,"domain")
88 grav.direction=[0.,-1.,0.]
89 grav.density=Link(mat,"density")
90 grav.gravity=Link(mat,"gravity")
91
92
93 vel=SteadyIncompressibleFlow(debug=True)
94 vel.domain=Link(dom)
95 vel.internal_force=Link(grav,"gravity_force")
96 vel.viscosity=Link(mat,"viscosity")
97 vel.location_prescribed_velocity=Link(vel_constraints,"location_of_constraint")
98 vel.rel_tol=1.e-6
99 temp.velocity=Link(vel,"velocity")
100
101 sq=Sequencer()
102 sq.t_end=0.001
103
104 vis=WriteVTK()
105 vis.t=Link(sq)
106 vis.data0=Link(temp,"temperature")
107 vis.data1=Link(vel,"velocity")
108 vis.dt=0.0001
109 vis.filename=os.path.join(WORKDIR,"temp.xml")
110
111 per=GaussianProfile()
112 per.domain=Link(dom)
113 per.x_c=[0.5,0.5,0.5]
114 per.A=0.0001
115 per.width=0.01
116 per.r=0
117
118 lc=LinearCombination()
119 lc.f0=1.
120 lc.v0=Link(per,"out")
121 lc.f1=1.
122 lc.v1=Link(temp_val,"out")
123 temp.temperature=Link(lc,"out")
124
125 s=Simulation([sq,vel_constraints, temp_constraints,Simulation([vel],debug=True),temp,vis],debug=True)
126 s.writeXML()
127 s.run()

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26