From 25d9f8b2a3adcaae699813be8921b6b33445ff0f Mon Sep 17 00:00:00 2001 From: Will Boyd Date: Mon, 27 Apr 2015 00:52:49 -0400 Subject: [PATCH] Added routines to Python API for nuclide-based scattering laws --- src/utils/openmc/material.py | 14 ++++++++++++++ src/utils/openmc/nuclide.py | 24 ++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/utils/openmc/material.py b/src/utils/openmc/material.py index 87255083bd..c7292416e6 100644 --- a/src/utils/openmc/material.py +++ b/src/utils/openmc/material.py @@ -271,6 +271,12 @@ class Material(object): self._sab.append((name, xs)) + def make_isotropic_in_lab(self): + + for nuclide_name in self._nuclides: + self._nuclides[nuclide_name][0].make_isotropic_in_lab() + + def get_all_nuclides(self): nuclides = {} @@ -331,6 +337,9 @@ class Material(object): if not nuclide[0]._xs is None: xml_element.set("xs", nuclide[0]._xs) + if not nuclide[0]._scattering is None: + xml_element.set("scattering", nuclide[0]._scattering) + return xml_element @@ -496,6 +505,11 @@ class MaterialsFile(object): self._materials.remove(material) + def make_isotropic_in_lab(self): + + for material in self._materials: + materials.make_isotropic_in_lab() + def create_material_subelements(self): diff --git a/src/utils/openmc/nuclide.py b/src/utils/openmc/nuclide.py index c2287b23d9..d9d49d039e 100644 --- a/src/utils/openmc/nuclide.py +++ b/src/utils/openmc/nuclide.py @@ -9,6 +9,7 @@ class Nuclide(object): self._name = '' self._xs = None self._zaid = None + self._scattering = None # Set the Material class attributes self.name = name @@ -54,6 +55,11 @@ class Nuclide(object): return self._zaid + @property + def scattering(self): + return self._scattering + + @name.setter def name(self, name): @@ -87,10 +93,24 @@ class Nuclide(object): self._zaid = zaid + @scattering.setter + def scattering(self, scattering): + + if not scattering in ['ace', 'lab']: + msg = 'Unable to set scattering for Nuclide to {0} ' \ + 'which is not "ace" or "lab"'.format(scattering) + raise ValueError(msg) + + self._scattering = scattering + + def __repr__(self): string = 'Nuclide - {0}\n'.format(self._name) string += '{0: <16}{1}{2}\n'.format('\tXS', '=\t', self._xs) if self._zaid is not None: - string += '{0: <16}{1}{2}\n'.format('\tZAID', '=\t', self._zaid) - return string \ No newline at end of file + string += '{0: <16}{1}{2}\n'.format('\tZAID', '=\t', self._zaid) + if self._scattering is not None: + string += '{0: <16}{1}{2}\n'.format('\tscattering', '=\t', + self._scattering) + return string