Added labels to cells, surfaces, lattices and materials

This commit is contained in:
Will Boyd 2015-04-01 18:32:01 -04:00
parent a58953ca07
commit b48dc23e69
6 changed files with 82 additions and 15 deletions

View file

@ -22,6 +22,7 @@ module geometry_header
type, abstract :: Lattice
integer :: id ! Universe number for lattice
character(len=52) :: label = "" ! User-defined label
real(8), allocatable :: pitch(:) ! Pitch along each axis
integer, allocatable :: universes(:,:,:) ! Specified universes
integer :: outside ! Material to fill area outside
@ -116,6 +117,7 @@ module geometry_header
type Surface
integer :: id ! Unique ID
character(len=52) :: label = "" ! User-defined label
integer :: type ! Type of surface
real(8), allocatable :: coeffs(:) ! Definition of surface
integer, allocatable :: &
@ -130,6 +132,7 @@ module geometry_header
type Cell
integer :: id ! Unique ID
character(len=52) :: label = "" ! User-defined label
integer :: type ! Type of cell (normal, universe, lattice)
integer :: universe ! universe # this cell is in
integer :: fill ! universe # filling this cell

View file

@ -127,6 +127,10 @@ contains
call su % write_data(i, "index", &
group="geometry/cells/cell " // trim(to_str(c % id)))
! Write label for this cell
call su % write_data(c % label, "label", &
group="geometry/cells/cell " // trim(to_str(c % id)))
! Write universe for this cell
call su % write_data(universes(c % universe) % id, "universe", &
group="geometry/cells/cell " // trim(to_str(c % id)))
@ -200,6 +204,10 @@ contains
call su % write_data(i, "index", &
group="geometry/surfaces/surface " // trim(to_str(s % id)))
! Write label for this surface
call su % write_data(s % label, "label", &
group="geometry/surfaces/surface " // trim(to_str(s % id)))
! Write surface type
select case (s % type)
case (SURF_PX)
@ -311,6 +319,10 @@ contains
call su % write_data(i, "index", &
group="geometry/lattices/lattice " // trim(to_str(lat % id)))
! Write label for this lattice
call su % write_data(lat % label, "label", &
group="geometry/lattices/lattice " // trim(to_str(lat % id)))
! Write lattice type
select type (lat)
type is (RectLattice)
@ -437,6 +449,10 @@ contains
call su % write_data(i, "index", &
group="materials/material " // trim(to_str(m % id)))
! Write label for this material
call su % write_data(m % label, "label", &
group="materials/material " // trim(to_str(m % id)))
! Write atom density with units
call su % write_data(m % density, "atom_density", &
group="materials/material " // trim(to_str(m % id)))

View file

@ -972,6 +972,13 @@ contains
else
call fatal_error("Must specify id of cell in geometry XML file.")
end if
! Copy cell label
c % label = ''
if (check_for_node(node_cell, "label")) then
call get_node_value(node_cell, "label", c % label)
end if
if (check_for_node(node_cell, "universe")) then
call get_node_value(node_cell, "universe", c % universe)
else
@ -1151,6 +1158,12 @@ contains
&// to_str(s % id))
end if
! Copy surface label
s % label = ''
if (check_for_node(node_surf, "label")) then
call get_node_value(node_surf, "label", s % label)
end if
! Copy and interpret surface type
word = ''
if (check_for_node(node_surf, "type")) &
@ -1273,6 +1286,12 @@ contains
&// to_str(lat % id))
end if
! Copy lattice label
lat % label = ''
if (check_for_node(node_lat, "label")) then
call get_node_value(node_lat, "label", lat % label)
end if
! Read number of lattice cells in each dimension
n = get_arraysize_integer(node_lat, "dimension")
if (n == 2) then
@ -1396,6 +1415,12 @@ contains
&// to_str(lat % id))
end if
! Copy lattice label
lat % label = ''
if (check_for_node(node_lat, "label")) then
call get_node_value(node_lat, "label", lat % label)
end if
! Read number of lattice cells in each dimension
call get_node_value(node_lat, "n_rings", lat % n_rings)
if (check_for_node(node_lat, "n_axial")) then
@ -1641,6 +1666,12 @@ contains
&// to_str(mat % id))
end if
! Copy material label
mat % label = ''
if (check_for_node(node_mat, "label")) then
call get_node_value(node_mat, "label", mat % label)
end if
if (run_mode == MODE_PLOTTING) then
! add to the dictionary and skip xs processing
call material_dict % add_key(mat % id, i)

View file

@ -8,6 +8,7 @@ module material_header
type Material
integer :: id ! unique identifier
character(len=52) :: label = "" ! User-defined label
integer :: n_nuclides ! number of nuclides
integer, allocatable :: nuclide(:) ! index in nuclides array
real(8) :: density ! total atom density in atom/b-cm

View file

@ -369,6 +369,9 @@ contains
! Write user-specified id for cell
write(unit_,*) 'Cell ' // to_str(c % id)
! Write user-specified label for cell
write(unit_,*) ' Label = ' // c % label
! Find index in cells array and write
index_cell = cell_dict % get_key(c % id)
write(unit_,*) ' Array Index = ' // to_str(index_cell)
@ -487,6 +490,9 @@ contains
! Write information about lattice
write(unit_,*) 'Lattice ' // to_str(lat % id)
! Write user-specified label for lattice
write(unit_,*) ' Label = ' // lat % label
select type(lat)
type is (RectLattice)
! Write dimension of lattice.
@ -572,6 +578,9 @@ contains
! Write user-specified id of surface
write(unit_,*) 'Surface ' // to_str(surf % id)
! Write user-specified label for surface
write(unit_,*) ' Label = ' // surf % label
! Write type of surface
select case (surf % type)
case (SURF_PX)
@ -668,6 +677,9 @@ contains
! Write identifier for material
write(unit_,*) 'Material ' // to_str(mat % id)
! Write user-specified label for material
write(unit_,*) ' Label = ' // mat % label
! Write total atom density in atom/b-cm
write(unit_,*) ' Atom Density = ' // trim(to_str(mat % density)) &
// ' atom/b-cm'

View file

@ -106,6 +106,7 @@ class Summary(object):
material_id = int(key.lstrip('material '))
index = self._f['materials'][key]['index'][0]
name = self._f['materials'][key]['label'][0]
density = self._f['materials'][key]['atom_density'][0]
nuc_densities = self._f['materials'][key]['nuclide_densities'][...]
nuclides = self._f['materials'][key]['nuclides'][...]
@ -124,7 +125,7 @@ class Summary(object):
sab_xs.append(sab_table.split('.')[1])
# Create the Material
material = openmc.Material(material_id=material_id)
material = openmc.Material(material_id=material_id, name=name)
# Set the Material's density to g/cm3 - this is what is used in OpenMC
material.set_density(density=density, units='g/cm3')
@ -165,6 +166,7 @@ class Summary(object):
surface_id = int(key.lstrip('surface '))
index = self._f['geometry/surfaces'][key]['index'][0]
name = self._f['geometry/surfaces'][key]['label'][0]
surf_type = self._f['geometry/surfaces'][key]['type'][...][0]
bc = self._f['geometry/surfaces'][key]['boundary_condition'][...][0]
coeffs = self._f['geometry/surfaces'][key]['coefficients'][...]
@ -173,47 +175,47 @@ class Summary(object):
if surf_type == 'X Plane':
x0 = coeffs[0]
surface = openmc.XPlane(surface_id, bc, x0)
surface = openmc.XPlane(surface_id, bc, x0, name)
elif surf_type == 'Y Plane':
y0 = coeffs[0]
surface = openmc.YPlane(surface_id, bc, y0)
surface = openmc.YPlane(surface_id, bc, y0, name)
elif surf_type == 'Z Plane':
z0 = coeffs[0]
surface = openmc.ZPlane(surface_id, bc, z0)
surface = openmc.ZPlane(surface_id, bc, z0, name)
elif surf_type == 'Plane':
A = coeffs[0]
B = coeffs[1]
C = coeffs[2]
D = coeffs[3]
surface = openmc.Plane(surface_id, bc, A, B, C, D)
surface = openmc.Plane(surface_id, bc, A, B, C, D, name)
elif surf_type == 'X Cylinder':
y0 = coeffs[0]
z0 = coeffs[1]
R = coeffs[2]
surface = openmc.XCylinder(surface_id, bc, y0, z0, R)
surface = openmc.XCylinder(surface_id, bc, y0, z0, R, name)
elif surf_type == 'Y Cylinder':
x0 = coeffs[0]
z0 = coeffs[1]
R = coeffs[2]
surface = openmc.YCylinder(surface_id, bc, x0, z0, R)
surface = openmc.YCylinder(surface_id, bc, x0, z0, R, name)
elif surf_type == 'Z Cylinder':
x0 = coeffs[0]
y0 = coeffs[1]
R = coeffs[2]
surface = openmc.ZCylinder(surface_id, bc, x0, y0, R)
surface = openmc.ZCylinder(surface_id, bc, x0, y0, R, name)
elif surf_type == 'Sphere':
x0 = coeffs[0]
y0 = coeffs[1]
z0 = coeffs[2]
R = coeffs[3]
surface = openmc.Sphere(surface_id, bc, x0, y0, z0, R)
surface = openmc.Sphere(surface_id, bc, x0, y0, z0, R, name)
elif surf_type in ['X Cone', 'Y Cone', 'Z Cone']:
x0 = coeffs[0]
@ -222,11 +224,11 @@ class Summary(object):
R2 = coeffs[3]
if surf_type == 'X Cone':
surface = openmc.XCone(surface_id, bc, x0, y0, z0, R2)
surface = openmc.XCone(surface_id, bc, x0, y0, z0, R2, name)
if surf_type == 'Y Cone':
surface = openmc.YCone(surface_id, bc, x0, y0, z0, R2)
surface = openmc.YCone(surface_id, bc, x0, y0, z0, R2, name)
if surf_type == 'Z Cone':
surface = openmc.ZCone(surface_id, bc, x0, y0, z0, R2)
surface = openmc.ZCone(surface_id, bc, x0, y0, z0, R2, name)
# Add Surface to global dictionary of all Surfaces
self.surfaces[index] = surface
@ -256,6 +258,7 @@ class Summary(object):
cell_id = int(key.lstrip('cell '))
index = self._f['geometry/cells'][key]['index'][0]
name = self._f['geometry/cells'][key]['label'][0]
fill_type = self._f['geometry/cells'][key]['fill_type'][...][0]
if fill_type == 'normal':
@ -271,7 +274,7 @@ class Summary(object):
surfaces = list()
# Create this Cell
cell = openmc.Cell(cell_id=cell_id)
cell = openmc.Cell(cell_id=cell_id, name)
if fill_type == 'universe':
translated = self._f['geometry/cells'][key]['translated'][0]
@ -349,6 +352,7 @@ class Summary(object):
lattice_id = int(key.lstrip('lattice '))
index = self._f['geometry/lattices'][key]['index'][0]
name = self._f['geometry/lattices'][key]['label'][0]
lattice_type = self._f['geometry/lattices'][key]['type'][...][0]
if lattice_type == 'rectangular':
@ -364,7 +368,7 @@ class Summary(object):
universe_ids = np.swapaxes(universe_ids, 1, 2)
# Create the Lattice
lattice = openmc.RectLattice(lattice_id=lattice_id)
lattice = openmc.RectLattice(lattice_id=lattice_id, name=name)
lattice.set_dimension(tuple(dimension))
lattice.set_lower_left(lower_left)
lattice.set_pitch(pitch)
@ -404,7 +408,7 @@ class Summary(object):
self._f['geometry/lattices'][key]['universes'][...]
# Create the Lattice
lattice = openmc.HexLattice(lattice_id=lattice_id)
lattice = openmc.HexLattice(lattice_id=lattice_id, name=name)
lattice.set_num_rings(n_rings)
lattice.set_num_axial(n_axial)
lattice.set_center(center)