source: CIVL/examples/xsbench/src/Materials.c

main
Last change on this file was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 6.2 KB
Line 
1// Material data is hard coded into the functions in this file.
2// Note that there are 12 materials present in H-M (large or small)
3
4#include "XSbench_header.h"
5
6// num_nucs represents the number of nuclides that each material contains
7int * load_num_nucs(long n_isotopes)
8{
9 int * num_nucs = (int*)malloc(12*sizeof(int));
10
11 // Material 0 is a special case (fuel). The H-M small reactor uses
12 // 34 nuclides, while H-M larges uses 300.
13 if( n_isotopes == 68 )
14 num_nucs[0] = 34; // HM Small is 34, H-M Large is 321
15 else
16 num_nucs[0] = 321; // HM Small is 34, H-M Large is 321
17
18 num_nucs[1] = 5;
19 num_nucs[2] = 4;
20 num_nucs[3] = 4;
21 num_nucs[4] = 27;
22 num_nucs[5] = 21;
23 num_nucs[6] = 21;
24 num_nucs[7] = 21;
25 num_nucs[8] = 21;
26 num_nucs[9] = 21;
27 num_nucs[10] = 9;
28 num_nucs[11] = 9;
29
30 return num_nucs;
31}
32
33// Assigns an array of nuclide ID's to each material
34int ** load_mats( int * num_nucs, long n_isotopes )
35{
36 int ** mats = (int **) malloc( 12 * sizeof(int *) );
37 for( int i = 0; i < 12; i++ )
38 mats[i] = (int *) malloc(num_nucs[i] * sizeof(int) );
39
40 // Small H-M has 34 fuel nuclides
41 int mats0_Sml[] = { 58, 59, 60, 61, 40, 42, 43, 44, 45, 46, 1, 2, 3, 7,
42 8, 9, 10, 29, 57, 47, 48, 0, 62, 15, 33, 34, 52, 53,
43 54, 55, 56, 18, 23, 41 }; //fuel
44 // Large H-M has 300 fuel nuclides
45 int mats0_Lrg[321] = { 58, 59, 60, 61, 40, 42, 43, 44, 45, 46, 1, 2, 3, 7,
46 8, 9, 10, 29, 57, 47, 48, 0, 62, 15, 33, 34, 52, 53,
47 54, 55, 56, 18, 23, 41 }; //fuel
48 for( int i = 0; i < 321-34; i++ )
49 mats0_Lrg[34+i] = 68 + i; // H-M large adds nuclides to fuel only
50
51 // These are the non-fuel materials
52 int mats1[] = { 63, 64, 65, 66, 67 }; // cladding
53 int mats2[] = { 24, 41, 4, 5 }; // cold borated water
54 int mats3[] = { 24, 41, 4, 5 }; // hot borated water
55 int mats4[] = { 19, 20, 21, 22, 35, 36, 37, 38, 39, 25, 27, 28, 29,
56 30, 31, 32, 26, 49, 50, 51, 11, 12, 13, 14, 6, 16,
57 17 }; // RPV
58 int mats5[] = { 24, 41, 4, 5, 19, 20, 21, 22, 35, 36, 37, 38, 39, 25,
59 49, 50, 51, 11, 12, 13, 14 }; // lower radial reflector
60 int mats6[] = { 24, 41, 4, 5, 19, 20, 21, 22, 35, 36, 37, 38, 39, 25,
61 49, 50, 51, 11, 12, 13, 14 }; // top reflector / plate
62 int mats7[] = { 24, 41, 4, 5, 19, 20, 21, 22, 35, 36, 37, 38, 39, 25,
63 49, 50, 51, 11, 12, 13, 14 }; // bottom plate
64 int mats8[] = { 24, 41, 4, 5, 19, 20, 21, 22, 35, 36, 37, 38, 39, 25,
65 49, 50, 51, 11, 12, 13, 14 }; // bottom nozzle
66 int mats9[] = { 24, 41, 4, 5, 19, 20, 21, 22, 35, 36, 37, 38, 39, 25,
67 49, 50, 51, 11, 12, 13, 14 }; // top nozzle
68 int mats10[] = { 24, 41, 4, 5, 63, 64, 65, 66, 67 }; // top of FA's
69 int mats11[] = { 24, 41, 4, 5, 63, 64, 65, 66, 67 }; // bottom FA's
70
71 // H-M large v small dependency
72 if( n_isotopes == 68 )
73 memcpy( mats[0], mats0_Sml, num_nucs[0] * sizeof(int) );
74 else
75 memcpy( mats[0], mats0_Lrg, num_nucs[0] * sizeof(int) );
76
77 // Copy other materials
78 memcpy( mats[1], mats1, num_nucs[1] * sizeof(int) );
79 memcpy( mats[2], mats2, num_nucs[2] * sizeof(int) );
80 memcpy( mats[3], mats3, num_nucs[3] * sizeof(int) );
81 memcpy( mats[4], mats4, num_nucs[4] * sizeof(int) );
82 memcpy( mats[5], mats5, num_nucs[5] * sizeof(int) );
83 memcpy( mats[6], mats6, num_nucs[6] * sizeof(int) );
84 memcpy( mats[7], mats7, num_nucs[7] * sizeof(int) );
85 memcpy( mats[8], mats8, num_nucs[8] * sizeof(int) );
86 memcpy( mats[9], mats9, num_nucs[9] * sizeof(int) );
87 memcpy( mats[10], mats10, num_nucs[10] * sizeof(int) );
88 memcpy( mats[11], mats11, num_nucs[11] * sizeof(int) );
89
90 // test
91 /*
92 for( int i = 0; i < 12; i++ )
93 for( int j = 0; j < num_nucs[i]; j++ )
94 printf("material %d - Nuclide %d: %d\n",
95 i, j, mats[i][j]);
96 */
97
98 return mats;
99}
100
101// Creates a randomized array of 'concentrations' of nuclides in each mat
102double ** load_concs( int * num_nucs )
103{
104 double ** concs = (double **)malloc( 12 * sizeof( double *) );
105
106 for( int i = 0; i < 12; i++ )
107 concs[i] = (double *)malloc( num_nucs[i] * sizeof(double) );
108
109 for( int i = 0; i < 12; i++ )
110 for( int j = 0; j < num_nucs[i]; j++ )
111 concs[i][j] = (double) rand() / (double) RAND_MAX;
112
113 // test
114 /*
115 for( int i = 0; i < 12; i++ )
116 for( int j = 0; j < num_nucs[i]; j++ )
117 printf("concs[%d][%d] = %lf\n", i, j, concs[i][j] );
118 */
119
120 return concs;
121}
122
123// Verification version of this function (tighter control over RNG)
124double ** load_concs_v( int * num_nucs )
125{
126 double ** concs = (double **)malloc( 12 * sizeof( double *) );
127
128 for( int i = 0; i < 12; i++ )
129 concs[i] = (double *)malloc( num_nucs[i] * sizeof(double) );
130
131 for( int i = 0; i < 12; i++ )
132 for( int j = 0; j < num_nucs[i]; j++ )
133 concs[i][j] = rn_v();
134
135 // test
136 /*
137 for( int i = 0; i < 12; i++ )
138 for( int j = 0; j < num_nucs[i]; j++ )
139 printf("concs[%d][%d] = %lf\n", i, j, concs[i][j] );
140 */
141
142 return concs;
143}
144
145// picks a material based on a probabilistic distribution
146int pick_mat( unsigned long * seed )
147{
148 // I have a nice spreadsheet supporting these numbers. They are
149 // the fractions (by volume) of material in the core. Not a
150 // *perfect* approximation of where XS lookups are going to occur,
151 // but this will do a good job of biasing the system nonetheless.
152
153 // Also could be argued that doing fractions by weight would be
154 // a better approximation, but volume does a good enough job for now.
155
156 double dist[12];
157 dist[0] = 0.140; // fuel
158 dist[1] = 0.052; // cladding
159 dist[2] = 0.275; // cold, borated water
160 dist[3] = 0.134; // hot, borated water
161 dist[4] = 0.154; // RPV
162 dist[5] = 0.064; // Lower, radial reflector
163 dist[6] = 0.066; // Upper reflector / top plate
164 dist[7] = 0.055; // bottom plate
165 dist[8] = 0.008; // bottom nozzle
166 dist[9] = 0.015; // top nozzle
167 dist[10] = 0.025; // top of fuel assemblies
168 dist[11] = 0.013; // bottom of fuel assemblies
169
170 //double roll = (double) rand() / (double) RAND_MAX;
171 #ifdef VERIFICATION
172 double roll = rn_v();
173 #else
174 double roll = rn(seed);
175 #endif
176
177 // makes a pick based on the distro
178 for( int i = 0; i < 12; i++ )
179 {
180 double running = 0;
181 for( int j = i; j > 0; j-- )
182 running += dist[j];
183 if( roll < running )
184 return i;
185 }
186
187 return 0;
188}
Note: See TracBrowser for help on using the repository browser.