Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion csg2csg/Input.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ class InputDeck:
""" Constructor
"""

def __init__(self, filename, quick=False):
def __init__(self, filename, quick=False, preserve_xsid=False):
self.filename = filename
self.quick_process = quick
self.preserve_xsid = preserve_xsid

self.file_lines = ""
self.title = ""
Expand Down Expand Up @@ -72,6 +73,7 @@ def get_cell_with_id(self, id):
# instanciate from input
def from_input(self, InputDeckClass):
self.filename = InputDeckClass.filename
self.preserve_xsid = InputDeckClass.preserve_xsid
self.title = InputDeckClass.title
self.cell_list = InputDeckClass.cell_list
self.surface_list = InputDeckClass.surface_list
Expand Down
6 changes: 3 additions & 3 deletions csg2csg/MCNPInput.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
class MCNPInput(InputDeck):
"""MCNPInputDeck class - does the actuall processing"""

preserve_xsid = False
# preserve_xsid = False

# constructor
def __init__(self, filename="", quick=False):
InputDeck.__init__(self, filename, quick)
def __init__(self, filename="", quick=False, preserve_xsid=False):
InputDeck.__init__(self, filename, quick, preserve_xsid)

# self.process()

Expand Down
8 changes: 5 additions & 3 deletions csg2csg/SerpentInput.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class SerpentInput(InputDeck):
"""SerpentInput class - does the actual processing"""

# constructor
def __init__(self, filename=""):
InputDeck.__init__(self, filename)
def __init__(self, filename="", preserve_xsid=False):
InputDeck.__init__(self, filename, preserve_xsid)

# extract a material card from the start line until
def __get_material_card(self, start_line, mat_num):
Expand Down Expand Up @@ -118,7 +118,9 @@ def __write_serpent_surfaces(self, filestream):
def __write_serpent_materials(self, filestream):
filestream.write("% --- material definitions --- %\n")
for material in self.material_list:
write_serpent_material(filestream, self.material_list[material])
write_serpent_material(
filestream, self.material_list[material], self.preserve_xsid
)
return

# main write serpent method, depending upon where the geometry
Expand Down
9 changes: 7 additions & 2 deletions csg2csg/SerpentMaterialCard.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from csg2csg.MCNPFormatter import get_fortran_formatted_number

# write a specific serpent material card
def write_serpent_material(filestream, material):
def write_serpent_material(filestream, material, preserve_xs):

string = "% " + material.material_name + "\n"
string += "mat " + str(material.material_number) + " "
Expand All @@ -17,7 +17,12 @@ def write_serpent_material(filestream, material):
string += "\n"

for nuc in material.composition_dictionary:
string += "{} {:e} \n".format(nuc, material.composition_dictionary[nuc])
if preserve_xs:
string += "{}.{} {:e} \n".format(
nuc, material.xsid_dictionary[nuc], material.composition_dictionary[nuc]
)
else:
string += "{} {:e} \n".format(nuc, material.composition_dictionary[nuc])
filestream.write(string)
return

Expand Down
11 changes: 9 additions & 2 deletions csg2csg/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ def main():
action="store_true",
)

parser.add_argument(
"-xs",
"--preserve_xsid",
help="Retain xs library for materials",
action="store_true",
)

# parse the arguments
args = parser.parse_args(argv)

Expand All @@ -77,12 +84,12 @@ def main():

if args.format == "mcnp":
# read the mcnp input
input = MCNPInput(filename, args.quick)
input = MCNPInput(filename, args.quick, args.preserve_xsid)
input.read()
input.process()
elif args.format == "serpent":
# read the serpent input
input = SerpentInput(filename)
input = SerpentInput(filename, args.preserve_xsid)
input.read()
input.process()
elif args.format == "openmc":
Expand Down