Skip to content

Commit

Permalink
also writting openmc python, phits and serpent files
Browse files Browse the repository at this point in the history
  • Loading branch information
shimwell committed Apr 29, 2024
1 parent 8e2fd7f commit 3f17dde
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
9 changes: 9 additions & 0 deletions src/geouned/GEOUNED/Write/WriteFiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ def writeGeometry(UniverseBox, MetaList, Surfaces, code_setting):

baseName = code_setting["geometryName"]

# Currently there are two was of setting outFormat (via a .set method and
# a class attribute. Once we have a single method then move this validating
# input code to the attribute @setter
supported_mc_codes = ('mcnp', 'openMC_XML', 'openMC_PY', 'serpent', 'phits')
for out_format in code_setting['outFormat']:
if out_format not in supported_mc_codes:
msg = f'outFormat {out_format} not in supported MC codes ({supported_mc_codes})'
raise ValueError(msg)

# write cells comments in file
if code_setting["cellCommentFile"]:
OutFiles.commentsWrite(baseName, MetaList)
Expand Down
13 changes: 7 additions & 6 deletions tests/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_conversion(input_step_file):
"title" : 'Input Test' ,
"stepFile" : f"{input_step_file.resolve()}" ,
"geometryName" : f"{output_filename_stem.resolve()}" ,
"outFormat" : ('mcnp', 'openMC_XML') ,
"outFormat" : ('mcnp', 'openMC_XML', 'openMC_PY', 'serpent', 'phits'),
"compSolids" : False ,
"volCARD" : False ,
"volSDEF" : True ,
Expand All @@ -39,9 +39,10 @@ def test_conversion(input_step_file):
"nPlaneReverse" : 0 ,
}

# deletes the output openmc and mcnp output files if it already exists
output_filename_stem.with_suffix(".mcnp").unlink(missing_ok=True)
output_filename_stem.with_suffix(".xml").unlink(missing_ok=True)
# deletes the output MC files if they already exists
suffixes = ('.mcnp', '.xml', '.inp', '.py', '.serp')
for suffix in suffixes:
output_filename_stem.with_suffix(suffix).unlink(missing_ok=True)

GEO = CadToCsg('Input Test')

Expand All @@ -51,5 +52,5 @@ def test_conversion(input_step_file):

GEO.Start()

assert output_filename_stem.with_suffix(".mcnp").exists()
assert output_filename_stem.with_suffix(".xml").exists()
for suffix in suffixes:
assert output_filename_stem.with_suffix(suffix).exists()

0 comments on commit 3f17dde

Please sign in to comment.