Skip to content

Commit

Permalink
Add the name to the cells in OpenMC to improve identification (#61)
Browse files Browse the repository at this point in the history
The name is the same that is used in MCNP inputs cell.Comments
  • Loading branch information
ecasglez authored Apr 23, 2024
1 parent 44ee8fa commit a96e19d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/GEOUNED/Write/OpenMCFormat.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,18 @@ def __write_xml_surface_block__(self):
def __write_xml_cells__(self,cell):
""" Write the cell in xml OpenMC format """
index = cell.label
cellName = ". ".join(cell.Comments.splitlines())
if cell.__id__ is None : return

if cell.Material == 0:
matName = 'void'
else:
matName = '{}'.format(cell.Material)

OMCcell = ' <cell id="{}" material="{}" region="{}" universe="1"/>\n'.format( \
OMCcell = ' <cell id="{}" material="{}" name="{}" region="{}" universe="1"/>\n'.format( \
index,\
matName,\
cellName,\
writeOpenMCregion(cell.Definition,'XML') )
self.inpfile.write(OMCcell)
return
Expand Down Expand Up @@ -146,7 +148,7 @@ def __write_py_surface_block__(self):


def __write_py_surfaces__(self,surface,boundary=False):
""" Write the surfaces in xml OpenMC format """
""" Write the surfaces in python OpenMC format """

surfType,coeffs = OpenMCSurface(surface.Type, surface.Surf, outXML = False, quadricForm = opt.quadricPY)

Expand Down Expand Up @@ -174,15 +176,16 @@ def __write_py_cell_block__(self):


def __write_py_cells__(self,cell):
""" Write the cell in xml OpenMC format """
""" Write the cell in python OpenMC format """
index = cell.label
cellName = ". ".join(cell.Comments.splitlines())
if cell.__id__ is None : return

if cell.Material == 0:
OMCcell = 'C{} = openmc.Cell(region={})\n'.format(index, writeOpenMCregion(cell.Definition,'PY') )
OMCcell = 'C{} = openmc.Cell(name="{}", region={})\n'.format(index, cellName, writeOpenMCregion(cell.Definition,'PY') )
else:
matName = 'M{}'.format(cell.Material)
OMCcell = 'C{} = openmc.Cell(fill={}, region={})\n'.format(index, matName, writeOpenMCregion(cell.Definition,'PY') )
OMCcell = 'C{} = openmc.Cell(name="{}", fill={}, region={})\n'.format(index, cellName, matName, writeOpenMCregion(cell.Definition,'PY') )
self.inpfile.write(OMCcell)
return

Expand Down

0 comments on commit a96e19d

Please sign in to comment.