mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-26 13:15:39 -04:00
Allow volume information to be added to materials and universes
This commit is contained in:
parent
9849f2533e
commit
acdf287c01
4 changed files with 65 additions and 2 deletions
|
|
@ -63,6 +63,14 @@ class Geometry(object):
|
|||
for cell in self.get_all_cells():
|
||||
if cell.id in volume_calc.results:
|
||||
cell.add_volume_information(volume_calc)
|
||||
elif volume_calc.domain_type == 'material':
|
||||
for material in self.get_all_materials():
|
||||
if material.id in volume_calc.results:
|
||||
material.add_volume_information(volume_calc)
|
||||
elif volume_calc.domain_type == 'universe':
|
||||
for universe in self.get_all_universes():
|
||||
if universe.id in volume_calc.results:
|
||||
universe.add_volume_information(volume_calc)
|
||||
|
||||
def export_to_xml(self, path='geometry.xml'):
|
||||
"""Export geometry to an XML file.
|
||||
|
|
|
|||
|
|
@ -71,6 +71,10 @@ class Material(object):
|
|||
The average molar mass of nuclides in the material in units of grams per
|
||||
mol. For example, UO2 with 3 nuclides will have an average molar mass
|
||||
of 270 / 3 = 90 g / mol.
|
||||
volume_information : dict
|
||||
Estimate of the volume and total number of atoms of each nuclide from a
|
||||
stochastic volume calculation. This information is set with the
|
||||
:meth:`Material.add_volume_information` method.
|
||||
|
||||
"""
|
||||
|
||||
|
|
@ -82,6 +86,7 @@ class Material(object):
|
|||
self._density = None
|
||||
self._density_units = ''
|
||||
self._depletable = False
|
||||
self._volume_information = None
|
||||
|
||||
# A list of tuples (nuclide, percent, percent type)
|
||||
self._nuclides = []
|
||||
|
|
@ -226,6 +231,10 @@ class Material(object):
|
|||
# Compute and return the molar mass
|
||||
return mass / moles
|
||||
|
||||
@property
|
||||
def volume_information(self):
|
||||
return self._volume_information
|
||||
|
||||
@id.setter
|
||||
def id(self, material_id):
|
||||
|
||||
|
|
@ -302,6 +311,25 @@ class Material(object):
|
|||
|
||||
return material
|
||||
|
||||
def add_volume_information(self, volume_calc):
|
||||
"""Add volume information to a material.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
volume_calc : openmc.VolumeCalculation
|
||||
Results from a stochastic volume calculation
|
||||
|
||||
"""
|
||||
if volume_calc.domain_type == 'material':
|
||||
for mat_id in volume_calc.results:
|
||||
if mat_id == self.id:
|
||||
self._volume_information = volume_calc.results[mat_id]
|
||||
break
|
||||
else:
|
||||
raise ValueError('No volume information found for this material.')
|
||||
else:
|
||||
raise ValueError('No volume information found for this material.')
|
||||
|
||||
def set_density(self, units, density=None):
|
||||
"""Set the density of the material
|
||||
|
||||
|
|
|
|||
|
|
@ -42,6 +42,10 @@ class Universe(object):
|
|||
cells : collections.OrderedDict
|
||||
Dictionary whose keys are cell IDs and values are :class:`Cell`
|
||||
instances
|
||||
volume_information : dict
|
||||
Estimate of the volume and total number of atoms of each nuclide from a
|
||||
stochastic volume calculation. This information is set with the
|
||||
:meth:`Universe.add_volume_information` method.
|
||||
|
||||
"""
|
||||
|
||||
|
|
@ -49,6 +53,7 @@ class Universe(object):
|
|||
# Initialize Cell class attributes
|
||||
self.id = universe_id
|
||||
self.name = name
|
||||
self._volume_information = None
|
||||
|
||||
# Keys - Cell IDs
|
||||
# Values - Cells
|
||||
|
|
@ -99,6 +104,10 @@ class Universe(object):
|
|||
def cells(self):
|
||||
return self._cells
|
||||
|
||||
@property
|
||||
def volume_information(self):
|
||||
return self._volume_information
|
||||
|
||||
@id.setter
|
||||
def id(self, universe_id):
|
||||
if universe_id is None:
|
||||
|
|
@ -147,6 +156,25 @@ class Universe(object):
|
|||
|
||||
return universe
|
||||
|
||||
def add_volume_information(self, volume_calc):
|
||||
"""Add volume information to a universe.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
volume_calc : openmc.VolumeCalculation
|
||||
Results from a stochastic volume calculation
|
||||
|
||||
"""
|
||||
if volume_calc.domain_type == 'cell':
|
||||
for univ_id in volume_calc.results:
|
||||
if univ_id == self.id:
|
||||
self._volume_information = volume_calc.results[univ_id]
|
||||
break
|
||||
else:
|
||||
raise ValueError('No volume information found for this universe.')
|
||||
else:
|
||||
raise ValueError('No volume information found for this universe.')
|
||||
|
||||
def find(self, point):
|
||||
"""Find cells/universes/lattices which contain a given point
|
||||
|
||||
|
|
|
|||
|
|
@ -38,8 +38,7 @@ class VolumeTest(PyAPITestHarness):
|
|||
bottom_hemisphere = openmc.Cell(3, fill=water, region=-bottom_sphere & -top_plane)
|
||||
root = openmc.Universe(0, cells=(inside_cyl, top_hemisphere, bottom_hemisphere))
|
||||
|
||||
geometry = openmc.Geometry()
|
||||
geometry.root_universe = root
|
||||
geometry = openmc.Geometry(root)
|
||||
geometry.export_to_xml()
|
||||
|
||||
# Set up stochastic volume calculation
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue