~vcs-imports/escript-finley/trunk

« back to all changes in this revision

Viewing changes to modellib/test/python/run_convection.py

  • Committer: jfenwick
  • Date: 2010-10-11 01:48:14 UTC
  • Revision ID: svn-v4:77569008-7704-0410-b7a0-a92fef0b09fd:trunk:3259
Merging dudley and scons updates from branches

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
from esys.modellib.materials import SimpleEarthModel,GravityForce
34
34
from esys.modellib.visualization import WriteVTK
35
35
 
 
36
import esys.dudley
 
37
 
36
38
try: 
37
39
   WORKDIR=os.environ['MODELLIB_WORKDIR']
38
40
except KeyError:
41
43
 
42
44
dom=RectangularDomain()
43
45
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()
 
46
def Test(dom):
 
47
        temp_val=InterpolateOverBox()
 
48
        temp_val.domain=Link(dom,"domain")
 
49
        temp_val.value_left_bottom_front=1.
 
50
        temp_val.value_right_bottom_front=1.
 
51
        temp_val.value_left_top_front=0.
 
52
        temp_val.value_right_top_front=0.
 
53
        temp_val.value_left_bottom_back=1.
 
54
        temp_val.value_right_bottom_back=1.
 
55
        temp_val.value_left_top_back=0.
 
56
        temp_val.value_right_top_back=0.
 
57
        
 
58
        temp_constraints=ScalarConstrainerOverBox()
 
59
        temp_constraints.domain=Link(dom)
 
60
        temp_constraints.top=1
 
61
        temp_constraints.bottom=1
 
62
        
 
63
        vel_constraints=VectorConstrainerOverBox()
 
64
        vel_constraints.domain=Link(dom)
 
65
        vel_constraints.left=[1,0,0]
 
66
        vel_constraints.right=[1,0,0]
 
67
        vel_constraints.top=[0,1,0]
 
68
        vel_constraints.bottom=[0,1,0]
 
69
        vel_constraints.front=[0,0,1]
 
70
        vel_constraints.back=[0,0,1]
 
71
        
 
72
        mat=SimpleEarthModel()
 
73
        mat.density0=1.
 
74
        mat.viscocity0=1.
 
75
        mat.rayleigh_number=10000.
 
76
        mat.alpha=0.001
 
77
        
 
78
        temp=TemperatureAdvection(debug=True)
 
79
        temp.domain=Link(dom)
 
80
        temp.density=Link(mat,"density0")
 
81
        temp.heat_capacity=Link(mat,"heat_capacity")
 
82
        temp.location_fixed_temperature=Link(temp_constraints,"location_of_constraint")
 
83
        temp.fixed_temperature=Link(temp_val,"out")
 
84
        temp.safety_factor=0.01
 
85
        mat.temperature=Link(temp,"temperature")
 
86
        
 
87
        
 
88
        grav=GravityForce()
 
89
        grav.domain=Link(dom,"domain")
 
90
        grav.direction=[0.,-1.,0.]
 
91
        grav.density=Link(mat,"density")
 
92
        grav.gravity=Link(mat,"gravity")
 
93
        
 
94
        
 
95
        vel=SteadyIncompressibleFlow(debug=True)
 
96
        vel.domain=Link(dom)
 
97
        vel.internal_force=Link(grav,"gravity_force")
 
98
        vel.viscosity=Link(mat,"viscosity")
 
99
        vel.location_prescribed_velocity=Link(vel_constraints,"location_of_constraint")
 
100
        vel.rel_tol=1.e-6
 
101
        temp.velocity=Link(vel,"velocity")
 
102
        
 
103
        sq=Sequencer()
 
104
        sq.t_end=0.001
 
105
        
 
106
        vis=WriteVTK()
 
107
        vis.t=Link(sq)
 
108
        vis.data0=Link(temp,"temperature")
 
109
        vis.data1=Link(vel,"velocity")
 
110
        vis.dt=0.0001
 
111
        vis.filename=os.path.join(WORKDIR,"temp.xml")
 
112
        
 
113
        per=GaussianProfile()
 
114
        per.domain=Link(dom)
 
115
        per.x_c=[0.5,0.5,0.5]
 
116
        per.A=0.0001
 
117
        per.width=0.01
 
118
        per.r=0
 
119
        
 
120
        lc=LinearCombination()
 
121
        lc.f0=1.
 
122
        lc.v0=Link(per,"out")
 
123
        lc.f1=1.
 
124
        lc.v1=Link(temp_val,"out")
 
125
        temp.temperature=Link(lc,"out")
 
126
        
 
127
        s=Simulation([sq,vel_constraints, temp_constraints,Simulation([vel],debug=True),temp,vis],debug=True)
 
128
        s.writeXML()
 
129
        s.run()
 
130
 
 
131
Test(dom)
 
132
dom=RectangularDomain(esys.dudley)
 
133
dom.order=1
 
134
Test(dom)
 
 
b'\\ No newline at end of file'