From 0f8ac7bf8754d2341abae7ea0cde2b2046f69213 Mon Sep 17 00:00:00 2001 From: Sterling Harper Date: Wed, 3 Feb 2016 22:49:12 -0500 Subject: [PATCH] Update PyAPI for multipole --- openmc/summary.py | 3 +++ openmc/universe.py | 37 ++++++++++++++++++++++++-- src/summary.F90 | 8 ++++++ tests/test_distribmat/results_true.dat | 1 + 4 files changed, 47 insertions(+), 2 deletions(-) diff --git a/openmc/summary.py b/openmc/summary.py index eb14d3bb81..d8f8978306 100644 --- a/openmc/summary.py +++ b/openmc/summary.py @@ -264,6 +264,9 @@ class Summary(object): self._f['geometry/cells'][key]['rotation'][...] rotation = np.asarray(rotation, dtype=np.int) cell.rotation = rotation + elif fill_type == 'normal': + cell.temperature = \ + self._f['geometry/cells'][key]['temperature'][...] # Store Cell fill information for after Universe/Lattice creation self._cell_fills[index] = (fill_type, fill) diff --git a/openmc/universe.py b/openmc/universe.py index 237ddce1f7..027d43fc77 100644 --- a/openmc/universe.py +++ b/openmc/universe.py @@ -51,9 +51,13 @@ class Cell(object): name : str Name of the cell fill : Material or Universe or Lattice or 'void' or iterable of Material - Indicates what the region of space is filled with + Indicates what the region of space is filled with. Multiple materials + can be given to give each distributed cell instance a unique material. region : openmc.region.Region Region of space that is assigned to the cell. + temperature : float or iterable of float + Temperature of the cell in Kelvin. Multiple temperatures can be given + to give each distributed cell instance a unique temperature. rotation : ndarray If the cell is filled with a universe, this array specifies the angles in degrees about the x, y, and z axes that the filled universe should be @@ -75,6 +79,7 @@ class Cell(object): self._fill = None self._type = None self._region = None + self._temperature = None self._rotation = None self._translation = None self._offsets = None @@ -91,6 +96,8 @@ class Cell(object): return False elif self.region != other.region: return False + elif self.temperature != other.temperature: + return False elif self.rotation != other.rotation: return False elif self.translation != other.translation: @@ -126,6 +133,10 @@ class Cell(object): string += '{0: <16}{1}{2}\n'.format('\tRegion', '=\t', self._region) + if self.fill_type == 'material': + string += '\t{0: <15}=\t{1}\n'.format('Temperature', + self.temperature) + string += '{0: <16}{1}{2}\n'.format('\tRotation', '=\t', self._rotation) string += '{0: <16}{1}{2}\n'.format('\tTranslation', '=\t', @@ -150,7 +161,7 @@ class Cell(object): @property def fill_type(self): - if isinstance(self.fill, openmc.Material): + if isinstance(self.fill, (openmc.Material, Iterable)): return 'material' elif isinstance(self.fill, openmc.Universe): return 'universe' @@ -163,6 +174,10 @@ class Cell(object): def region(self): return self._region + @property + def temperature(self): + return self._temperature + @property def rotation(self): return self._rotation @@ -251,6 +266,17 @@ class Cell(object): cv.check_type('cell region', region, Region) self._region = region + @temperature.setter + def temperature(self, temperature): + cv.check_type('cell temperature', temperature, (Iterable, Real)) + if isinstance(temperature, Iterable): + cv.check_type('cell temperature', temperature, Iterable, Real) + for T in temperature: + cv.check_greater_than('cell temperature', T, 0.0, True) + else: + cv.check_greater_than('cell temperature', temperature, 0.0, True) + self._temperature = temperature + @distribcell_index.setter def distribcell_index(self, ind): cv.check_type('distribcell index', ind, Integral) @@ -445,6 +471,13 @@ class Cell(object): # Call the recursive function from the top node create_surface_elements(self.region, xml_element) + if self.temperature is not None: + if isinstance(self.temperature, Iterable): + element.set("temperature", ' '.join( + [str(t) for t in self.temperature])) + else: + element.set("temperature", str(self.temperature)) + if self.translation is not None: element.set("translation", ' '.join(map(str, self.translation))) diff --git a/src/summary.F90 b/src/summary.F90 index c06d2549c2..2d8001e845 100644 --- a/src/summary.F90 +++ b/src/summary.F90 @@ -108,6 +108,7 @@ contains integer :: i, j, k, m integer, allocatable :: lattice_universes(:,:,:) integer, allocatable :: cell_materials(:) + real(8), allocatable :: cell_temperatures(:) integer(HID_T) :: geom_group integer(HID_T) :: cells_group, cell_group integer(HID_T) :: surfaces_group, surface_group @@ -151,6 +152,7 @@ contains select case (c%type) case (CELL_NORMAL) call write_dataset(cell_group, "fill_type", "normal") + if (size(c % material) == 1) then if (c % material(1) == MATERIAL_VOID) then call write_dataset(cell_group, "material", MATERIAL_VOID) @@ -171,6 +173,12 @@ contains deallocate(cell_materials) end if + allocate(cell_temperatures(size(c % sqrtkT))) + cell_temperatures(:) = c % sqrtkT(:) + cell_temperatures(:) = cell_temperatures(:)**2 / K_BOLTZMANN + call write_dataset(cell_group, "temperature", cell_temperatures) + deallocate(cell_temperatures) + case (CELL_FILL) call write_dataset(cell_group, "fill_type", "universe") call write_dataset(cell_group, "fill", universes(c%fill)%id) diff --git a/tests/test_distribmat/results_true.dat b/tests/test_distribmat/results_true.dat index 70464fbc6c..73a48907cb 100644 --- a/tests/test_distribmat/results_true.dat +++ b/tests/test_distribmat/results_true.dat @@ -5,6 +5,7 @@ Cell Name = Material = [2, 3, void, 2] Region = -10000 + Temperature = [ 293.60594237 293.60594237 0. 293.60594237] Rotation = None Translation = None Offset = None