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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26