-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add variable to specify ZAID-format #187
Changes from all commits
2777bcc
e90fe06
2c5d14b
fb05f57
0d4b94b
710516b
62d423b
95de3cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,8 @@ def __init__(self, | |
output_path, | ||
exec_path, | ||
template_input_file_path, | ||
geo_file_paths): | ||
geo_file_paths, | ||
zaid_convention): | ||
"""Initialize a SerpentDepcode object. | ||
|
||
Parameters | ||
|
@@ -52,10 +53,21 @@ def __init__(self, | |
Path to Serpent2 executable. | ||
template_input_file_path : str | ||
Path to user input file for Serpent2 | ||
geo_file_paths : str or list, optional | ||
geo_file_paths : str or list | ||
Path to file that contains the reactor geometry. | ||
List of `str` if reactivity control by | ||
switching geometry is `On` or just `str` otherwise. | ||
zaid_convention : str | ||
ZAID naming convention for nuclide codes. | ||
|
||
'serpent' - The third digit in ZA for nuclides in isomeric states | ||
is 3 (e.g. 47310 for for Ag-110m). | ||
|
||
'mcnp' - ZA = Z*1000 + A + (300 + 100*m). where m is the mth | ||
isomeric state (e.g. 47510 for Ag-110m) | ||
|
||
'nndc' - Identical to 'mcnp', except Am242m1 is 95242 and Am242 | ||
is 95642 | ||
|
||
""" | ||
super().__init__("serpent", | ||
|
@@ -66,6 +78,7 @@ def __init__(self, | |
self.runtime_inputfile = \ | ||
str((output_path / 'runtime_input.serpent').resolve()) | ||
self.runtime_matfile = str((output_path / 'runtime_mat.ini').resolve()) | ||
self.zaid_convention = zaid_convention | ||
|
||
def get_neutron_settings(self, file_lines): | ||
"""Get neutron settings (no. of neutrons per cycle, no. of active and | ||
|
@@ -175,20 +188,33 @@ def convert_nuclide_code_to_name(self, nuc_code): | |
""" | ||
|
||
if '.' in str(nuc_code): | ||
nuc_code = pyname.zzzaaa_to_id(int(nuc_code.split('.')[0])) | ||
nuc_code = int(nuc_code.split('.')[0]) | ||
if self.zaid_convention == 'serpent': | ||
nuc_code = pyname.zzzaaa_to_id(nuc_code) | ||
if self.zaid_convention in ('mcnp', 'nndc'): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider changing to |
||
if self.zaid_convention == 'mcnp' and nuc_code in (95242, 95642): | ||
if nuc_code == 95242: | ||
nuc_code = 95642 | ||
else: | ||
nuc_code = 95242 | ||
Comment on lines
+195
to
+199
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Based on your documentation I thought 95642 was for the NNDC ZAIDs, not the OpenMC ones. This function makes it seem the opposite. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This has nothing to do with OpenMC. It is all about where the nuclide cross section data is sourced from, since their ZAIDs will have slightly different conventions for metastable isotopes. This is a bit confusing so I'm going to go through this step-by-step.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That all mostly makes sense (I meant to say MCNP, but had OpenMC on my mind when I made the comment, apologies). Just to make sure I understand this correctly: In MCNP:
Your function here says that if you are using MCNP and you give it 95242 (Am242 in MCNP), then it converts it to 95642 (Am242m in MCNP). If you give it 95642 (Am242m in MCNP), then it converts it to 95242 (Am242). So that gets switched. This assumes that you are providing NNDC nomenclature and trying to use MCNP. What if you are using MCNP nomenclature already and don't need to switch it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You have the first right.
The reason we do the swap is because PyNE assumes an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That makes sense. I'm making sure that there is no situation in which these ZAIDs would be switched when they don't have to be. |
||
nuc_code = pyname.mcnp_to_id(nuc_code) | ||
|
||
zz = pyname.znum(nuc_code) | ||
aa = pyname.anum(nuc_code) | ||
aa_str = str(aa) | ||
if aa > 300: | ||
if zz > 76: | ||
aa_str = str(aa - 100) + 'm1' | ||
aa = aa - 100 | ||
else: | ||
aa_str = str(aa - 200) + 'm1' | ||
aa = aa - 200 | ||
nuc_zzaaam = str(zz) + str(aa) + '1' | ||
elif aa == 0: | ||
aa_str = 'nat' | ||
if self.zaid_convention == 'serpent': | ||
if aa > 300: | ||
if zz > 76: | ||
aa_str = str(aa - 100) + 'm1' | ||
else: | ||
aa_str = str(aa - 200) + 'm1' | ||
elif aa == 0: | ||
aa_str = 'nat' | ||
if self.zaid_convention in ('mcnp', 'nndc'): | ||
mm = pyname.snum(nuc_code) | ||
if mm != 0: | ||
aa_str = str(aa) + f'm{mm}' | ||
|
||
nuc_name = pyname.zz_name[zz] + aa_str | ||
else: | ||
meta_flag = pyname.snum(nuc_code) | ||
|
@@ -233,10 +259,23 @@ def map_nuclide_code_zam_to_serpent(self): | |
line = line.split() | ||
nuc_code = line[2] | ||
if '.' in str(nuc_code): | ||
nuc_code = pyname.zzzaaa_to_id(int(nuc_code.split('.')[0])) | ||
|
||
zzaaam = \ | ||
self.convert_nuclide_code_to_zam(pyname.zzaaam(nuc_code)) | ||
nuc_code = int(nuc_code.split('.')[0]) | ||
# In MCNP format the ground state of Am-242 is 95242, | ||
# but PyNE seems to disagree | ||
if self.zaid_convention == 'serpent': | ||
nuc_code = pyname.zzzaaa_to_id(nuc_code) | ||
zzaaam = \ | ||
self.convert_nuclide_code_to_zam(pyname.zzaaam(nuc_code)) | ||
if self.zaid_convention == 'nndc' or self.zaid_convention == 'mcnp': | ||
if self.zaid_convention == 'mcnp' and nuc_code in (95242, 95642): | ||
if nuc_code == 95242: | ||
nuc_code = 95642 | ||
else: | ||
nuc_code = 95242 | ||
abachma2 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
nuc_code = pyname.mcnp_to_id(nuc_code) | ||
zzaaam = pyname.zzaaam(nuc_code) | ||
else: | ||
zzaaam = int(nuc_code) | ||
|
||
nuc_code_map.update({zzaaam: line[2]}) | ||
return nuc_code_map | ||
|
@@ -436,15 +475,15 @@ def run_depletion_step(self, cores, nodes): | |
args = (self.exec_path, '-omp', str(cores), self.runtime_inputfile) | ||
print('Running %s' % (self.codename)) | ||
try: | ||
subprocess.check_output( | ||
subprocess.run( | ||
args, | ||
cwd=os.path.split(self.template_input_file_path)[0], | ||
stderr=subprocess.STDOUT) | ||
capture_output=True) | ||
print('Finished Serpent2 Run') | ||
except subprocess.CalledProcessError as error: | ||
print(error.output.decode("utf-8")) | ||
raise RuntimeError('\n %s RUN FAILED\n see error message above' | ||
% (self.codename)) | ||
print('Finished Serpent2 Run') | ||
|
||
def convert_nuclide_code_to_zam(self, nuc_code): | ||
"""Converts nuclide code from Serpent2 format to zam format. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious why you included NNDC in this, when it looks like your stuff just uses Serpent and OpenMC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NNDC provides cross section libraries using their own ZAID convention for metastable nuclides. It is slightly different than the convention used by cross section libraries shipped with MCNP. Notice that this variable only appears in the
depcode
object ifcodename
isserpent
. This is because Serpent uses ZAID codes to get cross section data for nuclides. This variable has no effect on how OpenMC will handle it's XS libraries, as that is all internally consistent within OpenMC.