diff --git a/csg2csg/Input.py b/csg2csg/Input.py index 9a236c6..620642b 100644 --- a/csg2csg/Input.py +++ b/csg2csg/Input.py @@ -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 = "" @@ -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 diff --git a/csg2csg/MCNPInput.py b/csg2csg/MCNPInput.py index 142923f..49329ec 100644 --- a/csg2csg/MCNPInput.py +++ b/csg2csg/MCNPInput.py @@ -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() diff --git a/csg2csg/SerpentInput.py b/csg2csg/SerpentInput.py index 3075014..4f58035 100644 --- a/csg2csg/SerpentInput.py +++ b/csg2csg/SerpentInput.py @@ -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): @@ -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 diff --git a/csg2csg/SerpentMaterialCard.py b/csg2csg/SerpentMaterialCard.py index ad05104..a7cb075 100644 --- a/csg2csg/SerpentMaterialCard.py +++ b/csg2csg/SerpentMaterialCard.py @@ -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) + " " @@ -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 diff --git a/csg2csg/__main__.py b/csg2csg/__main__.py index 2fa8d90..7dcafa9 100755 --- a/csg2csg/__main__.py +++ b/csg2csg/__main__.py @@ -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) @@ -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":