Skip to content

Commit

Permalink
Merge pull request arfc#187 from yardasol/flexible-zaid-conventions
Browse files Browse the repository at this point in the history
Add variable to specify ZAID-format
  • Loading branch information
samgdotson committed Jan 30, 2023
2 parents 419447d + 95de3cc commit 1af46aa
Show file tree
Hide file tree
Showing 13 changed files with 273,063 additions and 27 deletions.
16 changes: 16 additions & 0 deletions doc/fileformatspec/depcode_input.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,22 @@ Serpent-specific properties
:pattern:
``^(.\\/)*(.*)$``

``zaid_convention``
~~~~~~~~~~~~~~~~~~~

:description:
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


:type:
``string``

:enum:
"serpent", "mcnp", "nndc"

:default:
"mcnp"


.. _openmc_specific_properties:

Expand Down
4 changes: 4 additions & 0 deletions doc/releasenotes/v0.5.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ Bug Fixes
..
Describe any bug fixes.
- `Fix bug where Serpent2 material temperatures are hardcoded to 900K in the JEFF 3.1.2 library format. <https://github.com/arfc/saltproc/pull/178>`
- `Fix bug where using MCNP-style ZAID codes results in an error in various SerpentDepcode functions <https://github.com/arfc/saltproc/issues/187>`



Expand Down Expand Up @@ -101,6 +103,7 @@ Python API Changes
- Chaged the ``-d`` command line argument to ``-s``/``--threads``.
- (new) → ``mpi_args``
- Added default values for certain input parameters
- Adds a ``zaid_convention`` input parameter
- Added depletion settings for OpenMC
- ``num_depsteps`` → ``n_depletion_steps``
- ``depcode['template_inputfile_path']`` → ``depcode['template_input_file_path']``
Expand Down Expand Up @@ -170,6 +173,7 @@ Python API Changes
- (new function) → ``get_neutron_settings()``
- (new function) → ``_get_burnable_materials_file()``
- (new function) → ``_get_burnable_material_card_data()``
- (new parameter) → ``zaid_convention``


- ``OpenMCDepcode`` is a ``Depcode`` subclass that interfaces with ``openmc``. This class implements the following functions
Expand Down
3 changes: 2 additions & 1 deletion examples/msbr/msbr_main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"depcode": {
"codename": "serpent",
"template_input_file_path": "msbr.serpent",
"geo_file_paths": ["geometry/msbr_full.ini"]
"geo_file_paths": ["geometry/msbr_full.ini"],
"zaid_convention": "serpent"
},
"simulation": {
"sim_name": "msbr_kl_100_simulation"
Expand Down
3 changes: 2 additions & 1 deletion examples/tap/tap_main.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"geometry/1338.ini",
"geometry/1498.ini",
"geometry/1668_all.ini"
]
],
"zaid_convention": "serpent"
},
"simulation": {
"sim_name": "tap_example_simulation",
Expand Down
8 changes: 7 additions & 1 deletion saltproc/input_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,13 @@
"exec_path": {
"default": "sss2"},
"template_input_file_path": {
"pattern": "^(.\\/)*(.*)$"}
"pattern": "^(.\\/)*(.*)$"},
"zaid_convention": {
"description": "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",
"type": "string",
"enum": ["serpent", "mcnp", "nndc"],
"default": "mcnp"
}
}
}
},
Expand Down
79 changes: 59 additions & 20 deletions saltproc/serpent_depcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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",
Expand All @@ -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
Expand Down Expand Up @@ -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'):
if self.zaid_convention == 'mcnp' and nuc_code in (95242, 95642):
if nuc_code == 95242:
nuc_code = 95642
else:
nuc_code = 95242
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)
Expand Down Expand Up @@ -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
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
Expand Down Expand Up @@ -445,15 +484,15 @@ def run_depletion_step(self, mpi_args=None, threads=None):

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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"depcode": {
"codename": "serpent",
"template_input_file_path": "tap_template.ini",
"geo_file_paths": ["tap_geometry_base.ini"]
"geo_file_paths": ["tap_geometry_base.ini"],
"zaid_convention": "serpent"
},
"simulation": {
"sim_name": "tap_constant_reprocessing"
Expand Down
3 changes: 2 additions & 1 deletion tests/integration_tests/run_no_reprocessing/test_input.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"depcode": {
"codename": "serpent",
"template_input_file_path": "test_input.ini",
"geo_file_paths": ["../../serpent_data/tap_geometry_base.ini"]
"geo_file_paths": ["../../serpent_data/tap_geometry_base.ini"],
"zaid_convention": "serpent"
},
"simulation": {
"sim_name": "test_no_reprocessing",
Expand Down
3 changes: 2 additions & 1 deletion tests/serpent_data/tap_input.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"depcode": {
"codename": "serpent",
"template_input_file_path": "tap_template.ini",
"geo_file_paths": ["tap_geometry_base.ini"]
"geo_file_paths": ["tap_geometry_base.ini"],
"zaid_convention": "serpent"
},
"simulation": {
"sim_name": "tap_test_simulation_serpent"
Expand Down
Loading

0 comments on commit 1af46aa

Please sign in to comment.