Chi-Tech
Tutorial_03_TransportSim.h
Go to the documentation of this file.
1/** \page Tutorial03 Tutorial 3: Basic transport simulation
2
3Let 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
18As was done in Tutorials 1 and 2 we create the 3D mesh as follows:
19
20\code
21chiMeshHandlerCreate()
22
23nodes={}
24N=32
25ds=2.0/N
26for i=0,N do
27 nodes[i+1] = -1.0 + i*ds
28end
29surf_mesh,region1 = chiMeshCreateUnpartitioned3DOrthoMesh(nodes,nodes,nodes)
30
31chiVolumeMesherExecute();
32\endcode
33
34Next we set the material IDs:
35
36\code
37-- Set Material IDs
38vol0 = chiLogicalVolumeCreate(RPP,-1000,1000,-1000,1000,-1000,1000)
39chiVolumeMesherSetProperty(MATID_FROMLOGICAL,vol0,0)
40\endcode
41
42## Step 3 - Add a material with a transport cross-section
43
44Similar 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
48material0 = chiPhysicsAddMaterial("Test Material");
49
50chiPhysicsMaterialAddProperty(material0,TRANSPORT_XSECTIONS)
51num_groups = 1
52chiPhysicsMaterialSetProperty(material0,
53 TRANSPORT_XSECTIONS,
54 SIMPLEXS1,
55 num_groups, --Num grps
56 1.0, --Sigma_t
57 0.2) --Scattering ratio
58\endcode
59
60The 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
69phys1 = chiLBSCreateSolver()
70chiSolverAddRegion(phys1,region1)
71
72for k=1,num_groups do
73 chiLBSCreateGroup(phys1)
74end
75
76pquad = chiCreateProductQuadrature(GAUSS_LEGENDRE_CHEBYSHEV,4,4)
77
78--========== Groupset def
79gs0 = chiLBSCreateGroupset(phys1)
80chiLBSGroupsetAddGroups(phys1,gs0,0,num_groups-1)
81chiLBSGroupsetSetQuadrature(phys1,gs0,pquad)
82chiLBSGroupsetSetAngleAggregationType(phys1,gs0,LBSGroupset.ANGLE_AGG_SINGLE)
83chiLBSGroupsetSetIterativeMethod(NPT_GMRES_CYCLES)
84
85--========== Boundary conditions
86bsrc = {}
87for k=1,num_groups do
88 bsrc[k] = 0.0
89end
90bsrc[1] = 0.5
91chiLBSSetProperty(phys1,BOUNDARY_CONDITION,
92 YMIN,LBSBoundaryTypes.INCIDENT_ISOTROPIC,bsrc);
93
94--========== Solvers
95chiLBSSetProperty(phys1,DISCRETIZATION_METHOD,PWLD1D)
96chiLBSSetProperty(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
125chiLBSInitialize(phys1)
126chiLBSExecute(phys1)
127\endcode
128
129This should be intuitive.
130
131## Step 6 - Add output
132
133\code
134fflist,count = chiLBSGetScalarFieldFunctionList(phys1)
135
136cline = chiFFInterpolationCreate(LINE)
137chiFFInterpolationSetProperty(cline,LINE_FIRSTPOINT,0.0,-1.0,-1.0)
138chiFFInterpolationSetProperty(cline,LINE_SECONDPOINT,0.0, 1.0,1.0)
139chiFFInterpolationSetProperty(cline,LINE_NUMBEROFPOINTS, 50)
140
141chiFFInterpolationSetProperty(cline,ADD_FIELDFUNCTION,fflist[1])
142
143
144chiFFInterpolationInitialize(cline)
145chiFFInterpolationExecute(cline)
146chiFFInterpolationExportPython(cline)
147
148if (chi_location_id == 0) then
149 local handle = io.popen("python ZLFFI00.py")
150end
151\endcode
152
153Instead 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
167chiMeshHandlerCreate()
168
169nodes={}
170N=32
171ds=2.0/N
172for i=0,N do
173 nodes[i+1] = -1.0 + i*ds
174end
175surf_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
182chiVolumeMesherExecute();
183
184-- Set Material IDs
185vol0 = chiLogicalVolumeCreate(RPP,-1000,1000,-1000,1000,-1000,1000)
186chiVolumeMesherSetProperty(MATID_FROMLOGICAL,vol0,0)
187
188--############################################### Add material
189material0 = chiPhysicsAddMaterial("Test Material");
190
191chiPhysicsMaterialAddProperty(material0,TRANSPORT_XSECTIONS)
192num_groups = 1
193chiPhysicsMaterialSetProperty(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
201phys1 = chiLBSCreateSolver()
202chiSolverAddRegion(phys1,region1)
203
204for k=1,num_groups do
205 chiLBSCreateGroup(phys1)
206end
207
208pquad = chiCreateProductQuadrature(GAUSS_LEGENDRE_CHEBYSHEV,2,2)
209
210--========== Groupset def
211gs0 = chiLBSCreateGroupset(phys1)
212chiLBSGroupsetAddGroups(phys1,gs0,0,num_groups-1)
213chiLBSGroupsetSetQuadrature(phys1,gs0,pquad)
214chiLBSGroupsetSetAngleAggregationType(phys1,gs0,LBSGroupset.ANGLE_AGG_SINGLE)
215chiLBSGroupsetSetIterativeMethod(phys1,gs0,NPT_GMRES_CYCLES)
216
217--========== Boundary conditions
218bsrc = {}
219for k=1,num_groups do
220 bsrc[k] = 0.0
221end
222bsrc[1] = 0.5
223chiLBSSetProperty(phys1,BOUNDARY_CONDITION,
224 YMIN,LBSBoundaryTypes.INCIDENT_ISOTROPIC,bsrc);
225
226--========== Solvers
227chiLBSSetProperty(phys1,DISCRETIZATION_METHOD,PWLD)
228chiLBSSetProperty(phys1,SCATTERING_ORDER,0)
229
230chiLBSInitialize(phys1)
231chiLBSExecute(phys1)
232
233--############################################### Setup Output
234fflist,count = chiLBSGetScalarFieldFunctionList(phys1)
235
236cline = chiFFInterpolationCreate(LINE)
237chiFFInterpolationSetProperty(cline,LINE_FIRSTPOINT,0.0,-1.0,-1.0)
238chiFFInterpolationSetProperty(cline,LINE_SECONDPOINT,0.0, 1.0,1.0)
239chiFFInterpolationSetProperty(cline,LINE_NUMBEROFPOINTS, 50)
240
241chiFFInterpolationSetProperty(cline,ADD_FIELDFUNCTION,fflist[1])
242
243
244chiFFInterpolationInitialize(cline)
245chiFFInterpolationExecute(cline)
246chiFFInterpolationExportPython(cline)
247
248chiExportFieldFunctionToVTK(fflist[1],"Tutorial3Output","Phi")
249
250if (chi_location_id == 0) then
251 local handle = io.popen("python ZLFFI00.py")
252end
253\endcode
254
255
256*/