Skip to content

Commit 8ed6d2c

Browse files
committed
moved common functionality from step_1 (#1)
* moved common functionality from step_1 * adding underscore on private functions
1 parent a7dc517 commit 8ed6d2c

File tree

1 file changed

+46
-37
lines changed

1 file changed

+46
-37
lines changed

scripts/gtcadis.py

Lines changed: 46 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,7 @@ def setup():
6363
print('File "{}" has been written'.format(config_filename))
6464
print('Fill out the fields in these filse then run ">> gtcadis.py step1"')
6565

66-
def step1():
67-
config = ConfigParser.ConfigParser()
68-
config.read(config_filename)
69-
70-
hdf5 = config.get('step1', 'geom_file')
71-
cells = [config.get('step1', 'src_cell')]
72-
print ('cells', len(cells))
73-
xmesh = config.get('step1', 'xmesh').split(',')
74-
ymesh = config.get('step1', 'ymesh').split(',')
75-
zmesh = config.get('step1', 'zmesh').split(',')
76-
#intensities = [config.get('step1', 'intensities')]
77-
#print (len(intensities))
78-
src_vol = [config.getfloat('step1', 'src_vol')]
79-
print ('src vol', len(src_vol))
80-
66+
def _names_dict():
8167
names = ['h1', 'd', 'h3', 'he3', 'he4', 'li6', 'li7', 'be9', 'b10', 'b11',
8268
'c12', 'n14', 'n15', 'o16', 'f19', 'na23', 'mgnat', 'al27', 'si28', 'si29',
8369
'si30', 'p31', 'snat', 'cl35', 'cl37', 'knat', 'canat', 'ti46', 'ti47', 'ti48',
@@ -86,7 +72,7 @@ def step1():
8672
'ganat', 'zrnat', 'nb93', 'mo92', 'mo94', 'mo95', 'mo96', 'mo97', 'mo98',
8773
'mo100', 'snnat', 'ta181', 'w182', 'w183', 'w184', 'w186', 'au197', 'pb206',
8874
'pb207', 'pb208', 'bi209']
89-
75+
9076
names_formatted = ['h1', 'h2', 'h3', 'he3', 'he4', 'li6', 'li7', 'be9', 'b10', 'b11',
9177
'c12', 'n14', 'n15', 'o16', 'f19', 'na23', 'mg', 'al27', 'si28', 'si29',
9278
'si30', 'p31', 's', 'cl35', 'cl37', 'k', 'ca', 'ti46', 'ti47', 'ti48',
@@ -95,8 +81,50 @@ def step1():
9581
'ga', 'zr', 'nb93', 'mo92', 'mo94', 'mo95', 'mo96', 'mo97', 'mo98',
9682
'mo100', 'sn', 'ta181', 'w182', 'w183', 'w184', 'w186', 'au197', 'pb206',
9783
'pb207', 'pb208', 'bi209']
98-
84+
9985
names_dict = {nucname.id(x):y for x, y in zip(names_formatted, names)}
86+
87+
return names_dict
88+
89+
def _cards():
90+
cards = {"block1": {"isn": 16,
91+
"maxscm": '3E8',
92+
"maxlcm": '6E8',
93+
},
94+
"block3": {"lib": "xsf21-71", # name of cross section library
95+
"lng":175,
96+
"maxord": 5,
97+
"ihm": 227,
98+
"iht": 10,
99+
"ihs": 11,
100+
"ifido": 1,
101+
"ititl": 1,
102+
"i2lp1": 0,
103+
"savbxs": 0,
104+
"kwikrd": 0
105+
},
106+
"block5": {"source": source,
107+
"ith":1,
108+
"isct":5}
109+
}
110+
return cards
111+
112+
def step1():
113+
config = ConfigParser.ConfigParser()
114+
config.read(config_filename)
115+
116+
hdf5 = config.get('step1', 'geom_file')
117+
cells = [config.get('step1', 'src_cell')]
118+
print ('cells', len(cells))
119+
xmesh = config.get('step1', 'xmesh').split(',')
120+
ymesh = config.get('step1', 'ymesh').split(',')
121+
zmesh = config.get('step1', 'zmesh').split(',')
122+
#intensities = [config.get('step1', 'intensities')]
123+
#print (len(intensities))
124+
src_vol = [config.getfloat('step1', 'src_vol')]
125+
print ('src vol', len(src_vol))
126+
127+
names_dict = _names_dict()
100128

101129
sc = [np.linspace(float(xmesh[0]), float(xmesh[1]), float(xmesh[2])),
102130
np.linspace(float(ymesh[0]), float(ymesh[1]), float(ymesh[2])),
@@ -132,26 +160,7 @@ def step1():
132160
source, dg = isotropic_vol_source(hdf5, mesh, cells, spectra, intensities)
133161

134162
ngroup = 217
135-
cards = {"block1": {"isn": 16,
136-
"maxscm": '3E8',
137-
"maxlcm": '6E8',
138-
},
139-
"block3": {"lib": "xsf21-71", # name of cross section library
140-
"lng":175,
141-
"maxord": 5,
142-
"ihm": 227,
143-
"iht": 10,
144-
"ihs": 11,
145-
"ifido": 1,
146-
"ititl": 1,
147-
"i2lp1": 0,
148-
"savbxs": 0,
149-
"kwikrd": 0
150-
},
151-
"block5": {"source": source,
152-
"ith":1,
153-
"isct":5}
154-
}
163+
cards = _cards()
155164

156165
write_partisn_input(mesh, hdf5, ngroup, cards=cards, dg=dg, names_dict=names_dict, data_hdf5path="/materials", nuc_hdf5path="/nucid", fine_per_coarse=1)
157166

0 commit comments

Comments
 (0)