Chi-Tech
Tutorial_03_TransportSim.h
Go to the documentation of this file.
1
/** \page Tutorial03 Tutorial 3: Basic transport simulation
2
3
Let us tackle a basic transport simulation on a 3D mesh\n
4
5
\f[
6
\hat{\Omega} \nabla \Psi(\hat{\Omega}) + \sigma_t \Psi (\hat{\Omega}) =
7
\int_{\hat{\Omega}} \sigma_s (\hat{\Omega}' \to \hat{\Omega})
8
\Psi (\hat{\Omega}').d\hat{\Omega}' + q(\hat{\Omega})
9
\f]
10
11
## Step 1 - Create your input file, open it in a text editor
12
13
As before, go to the directory of your
14
choosing and make an input file of your choosing.
15
16
## Step 2 - Create a mesh
17
18
As was done in Tutorials 1 and 2 we create the 3D mesh as follows:
19
20
\code
21
chiMeshHandlerCreate()
22
23
nodes={}
24
N=32
25
ds=2.0/N
26
for i=0,N do
27
nodes[i+1] = -1.0 + i*ds
28
end
29
surf_mesh,region1 = chiMeshCreateUnpartitioned3DOrthoMesh(nodes,nodes,nodes)
30
31
chiVolumeMesherExecute();
32
\endcode
33
34
Next we set the material IDs:
35
36
\code
37
-- Set Material IDs
38
vol0 = chiLogicalVolumeCreate(RPP,-1000,1000,-1000,1000,-1000,1000)
39
chiVolumeMesherSetProperty(MATID_FROMLOGICAL,vol0,0)
40
\endcode
41
42
## Step 3 - Add a material with a transport cross-section
43
44
Similar to the diffusion tutorial we have to create a material, then add a
45
property to it, and then to set the property.
46
47
\code
48
material0 = chiPhysicsAddMaterial("Test Material");
49
50
chiPhysicsMaterialAddProperty(material0,TRANSPORT_XSECTIONS)
51
num_groups = 1
52
chiPhysicsMaterialSetProperty(material0,
53
TRANSPORT_XSECTIONS,
54
SIMPLEXS1,
55
num_groups, --Num grps
56
1.0, --Sigma_t
57
0.2) --Scattering ratio
58
\endcode
59
60
The general material property TRANSPORT_XSECTIONS is used for
61
non-fission transport materials. Simple cross-sections can be specified by
62
using the operation SIMPLEXS1 which expects the number of groups,
63
the total cross-section, and then the scattering ratio.
64
65
## Step 4 - Add Transport physics
66
67
\code
68
--############################################### Setup Physics
69
phys1 = chiLBSCreateSolver()
70
chiSolverAddRegion(phys1,region1)
71
72
for k=1,num_groups do
73
chiLBSCreateGroup(phys1)
74
end
75
76
pquad = chiCreateProductQuadrature(GAUSS_LEGENDRE_CHEBYSHEV,4,4)
77
78
--========== Groupset def
79
gs0 = chiLBSCreateGroupset(phys1)
80
chiLBSGroupsetAddGroups(phys1,gs0,0,num_groups-1)
81
chiLBSGroupsetSetQuadrature(phys1,gs0,pquad)
82
chiLBSGroupsetSetAngleAggregationType(phys1,gs0,LBSGroupset.ANGLE_AGG_SINGLE)
83
chiLBSGroupsetSetIterativeMethod(NPT_GMRES_CYCLES)
84
85
--========== Boundary conditions
86
bsrc = {}
87
for k=1,num_groups do
88
bsrc[k] = 0.0
89
end
90
bsrc[1] = 0.5
91
chiLBSSetProperty(phys1,BOUNDARY_CONDITION,
92
YMIN,LBSBoundaryTypes.INCIDENT_ISOTROPIC,bsrc);
93
94
--========== Solvers
95
chiLBSSetProperty(phys1,DISCRETIZATION_METHOD,PWLD1D)
96
chiLBSSetProperty(phys1,SCATTERING_ORDER,0)
97
\endcode
98
99
A transport solver is invoked by using a call to chiLBSCreateSolver().
100
This creates a derived object based on a base physics solver so the
101
mesh region gets added to the
102
solver using the generic call chiSolverAddRegion(). Past this point we need
103
to create the single required group with chiLBSCreateGroup(), although we put
104
this in a loop for in-case we want to increase the number of groups, and then a
105
quadrature rule for integration of the angular fluxes. Since we are dealing
106
with a 3D simulation we will be integrating over \f$ \theta \f$, the polar
107
angle, and \f$ \varphi \f$, the azimuthal angle. A quadrature with favorable
108
parallel properties is the Gauss-Legendre-Chebyshev quadrature. We create this
109
quadrature with a call to
110
chiCreateProductQuadrature() and specifying GAUSS_LEGENDRE_CHEBYSHEV as the rule
111
and we then specify 2 azimuthal angles per octant and 2 polar angles per octant.
112
113
The next step in the process is to assign a group-set. Group-sets are very
114
useful aggregation features in higher dimension simulations but here we
115
only have a single groupset. The group-set is created with a call to
116
chiLBSCreateGroupset(). Next we add groups to the group-set using a range,
117
however, since we only have one group here the range will be 0 to 0. The
118
final piece of a groupset is to add a quadrature which is achieved with a
119
call to chiLBSGroupsetSetQuadrature().
120
121
122
## Step 5 - Initialize and Execute
123
124
\code
125
chiLBSInitialize(phys1)
126
chiLBSExecute(phys1)
127
\endcode
128
129
This should be intuitive.
130
131
## Step 6 - Add output
132
133
\code
134
fflist,count = chiLBSGetScalarFieldFunctionList(phys1)
135
136
cline = chiFFInterpolationCreate(LINE)
137
chiFFInterpolationSetProperty(cline,LINE_FIRSTPOINT,0.0,-1.0,-1.0)
138
chiFFInterpolationSetProperty(cline,LINE_SECONDPOINT,0.0, 1.0,1.0)
139
chiFFInterpolationSetProperty(cline,LINE_NUMBEROFPOINTS, 50)
140
141
chiFFInterpolationSetProperty(cline,ADD_FIELDFUNCTION,fflist[1])
142
143
144
chiFFInterpolationInitialize(cline)
145
chiFFInterpolationExecute(cline)
146
chiFFInterpolationExportPython(cline)
147
148
if (chi_location_id == 0) then
149
local handle = io.popen("python ZLFFI00.py")
150
end
151
\endcode
152
153
Instead of using a SLICE interpolator we instead opt to use a LINE interpolator.
154
A line-interpolator needs two points as the initial and final point (i.e.
155
LINE_FIRSTPOINT and LINE_SECONDPOINT) as well as the total number of
156
points LINE_NUMBEROFPOINTS. Finally add the first available scalar field
157
field function to the interpolator.
158
159
The output should look as follows:
160
161
\image html "Physics/Tut3Output.png" "Figure 1 - Output of the 1D simulation" width=350px
162
163
## Fully commented code
164
165
\code
166
--############################################### Setup mesh
167
chiMeshHandlerCreate()
168
169
nodes={}
170
N=32
171
ds=2.0/N
172
for i=0,N do
173
nodes[i+1] = -1.0 + i*ds
174
end
175
surf_mesh,region1 = chiMeshCreateUnpartitioned3DOrthoMesh(nodes,nodes,nodes)
176
177
--chiSurfaceMesherSetProperty(PARTITION_X,2)
178
--chiSurfaceMesherSetProperty(PARTITION_Y,2)
179
--chiSurfaceMesherSetProperty(CUT_X,0.0)
180
--chiSurfaceMesherSetProperty(CUT_Y,0.0)
181
182
chiVolumeMesherExecute();
183
184
-- Set Material IDs
185
vol0 = chiLogicalVolumeCreate(RPP,-1000,1000,-1000,1000,-1000,1000)
186
chiVolumeMesherSetProperty(MATID_FROMLOGICAL,vol0,0)
187
188
--############################################### Add material
189
material0 = chiPhysicsAddMaterial("Test Material");
190
191
chiPhysicsMaterialAddProperty(material0,TRANSPORT_XSECTIONS)
192
num_groups = 1
193
chiPhysicsMaterialSetProperty(material0,
194
TRANSPORT_XSECTIONS,
195
SIMPLEXS1,
196
num_groups, --Num grps
197
1.0, --Sigma_t
198
0.2) --Scattering ratio
199
200
--############################################### Setup Physics
201
phys1 = chiLBSCreateSolver()
202
chiSolverAddRegion(phys1,region1)
203
204
for k=1,num_groups do
205
chiLBSCreateGroup(phys1)
206
end
207
208
pquad = chiCreateProductQuadrature(GAUSS_LEGENDRE_CHEBYSHEV,2,2)
209
210
--========== Groupset def
211
gs0 = chiLBSCreateGroupset(phys1)
212
chiLBSGroupsetAddGroups(phys1,gs0,0,num_groups-1)
213
chiLBSGroupsetSetQuadrature(phys1,gs0,pquad)
214
chiLBSGroupsetSetAngleAggregationType(phys1,gs0,LBSGroupset.ANGLE_AGG_SINGLE)
215
chiLBSGroupsetSetIterativeMethod(phys1,gs0,NPT_GMRES_CYCLES)
216
217
--========== Boundary conditions
218
bsrc = {}
219
for k=1,num_groups do
220
bsrc[k] = 0.0
221
end
222
bsrc[1] = 0.5
223
chiLBSSetProperty(phys1,BOUNDARY_CONDITION,
224
YMIN,LBSBoundaryTypes.INCIDENT_ISOTROPIC,bsrc);
225
226
--========== Solvers
227
chiLBSSetProperty(phys1,DISCRETIZATION_METHOD,PWLD)
228
chiLBSSetProperty(phys1,SCATTERING_ORDER,0)
229
230
chiLBSInitialize(phys1)
231
chiLBSExecute(phys1)
232
233
--############################################### Setup Output
234
fflist,count = chiLBSGetScalarFieldFunctionList(phys1)
235
236
cline = chiFFInterpolationCreate(LINE)
237
chiFFInterpolationSetProperty(cline,LINE_FIRSTPOINT,0.0,-1.0,-1.0)
238
chiFFInterpolationSetProperty(cline,LINE_SECONDPOINT,0.0, 1.0,1.0)
239
chiFFInterpolationSetProperty(cline,LINE_NUMBEROFPOINTS, 50)
240
241
chiFFInterpolationSetProperty(cline,ADD_FIELDFUNCTION,fflist[1])
242
243
244
chiFFInterpolationInitialize(cline)
245
chiFFInterpolationExecute(cline)
246
chiFFInterpolationExportPython(cline)
247
248
chiExportFieldFunctionToVTK(fflist[1],"Tutorial3Output","Phi")
249
250
if (chi_location_id == 0) then
251
local handle = io.popen("python ZLFFI00.py")
252
end
253
\endcode
254
255
256
*/
doc
PAGES
Tutorials
Tutorial_03_TransportSim.h
Generated by
1.9.3