Exemplo n.º 1
0
def editArrayBlock(new_input):

# This module addresses changes needed for the array block in order to convert
# from Newt to Keno. The adjusted input is then returned.
#
# Adds 'nuz=1' for any arrays and removes any pinpow statements if present


# NOTE: if many exceptions in the input begin breaking this code. It may be more
#    robust to read only the things wanted (nux=9, fill, end fill, etc) 
#    r'^nux\D*(\d*)\b'   for example to get nux, then insert nuz=1

  print 'Running editArrayBlock'
  
  read_array = findLineNumWithComments(new_input, 'read arra')
  end_array = findLineNumWithComments(new_input, 'end arra',start_index=read_array)

# This adds 'nuz=1' to any arrays
  for line_num in range(read_array + 1, end_array):
    if 'ara' in new_input[line_num]:
      for new_line in range(line_num, end_array):
        if 'nuy' in new_input[new_line] and 'nuz' not in new_input[new_line]:
          tmp_list = string2list(new_input[new_line])
          for index in range(len(tmp_list)):
            if 'nuy' in tmp_list[index]:
              tmp_list.insert(index,'nuz=1')
              new_input[new_line] = '  '.join(tmp_list) + '\n'
              break



# This removes a pinpow statement if present
  for line_num in range(read_array + 1, end_array):
    if 'ara' in new_input[line_num]:
      for new_line in range(line_num, end_array):
        if 'pinpow' in new_input[new_line]:
          tmp_list = string2list(new_input[new_line])
          for index in range(len(tmp_list)):
            if 'pinpow' in tmp_list[index]:
              del(tmp_list[index])
              if '=' in tmp_list[index] or 'yes' in tmp_list[index] or 'no' in tmp_list[index]:
                del(tmp_list[index])
                if 'yes' in tmp_list[index] or 'no' in tmp_list[index]:
                  del(tmp_list[index])
                  new_input[new_line] = ' '.join(tmp_list[:]) + '\n'
                  break
                else:
                  new_input[new_line] = ' '.join(tmp_list[:]) + '\n'
                  break

                  
  return new_input
Exemplo n.º 2
0
def editGeomBlock(new_input):
  """ This module addresses changes needed for the geometry block in order to convert
   from Newt to Keno. The adjusted input is then returned.

   This module adds a z-dimension to the shapes that are described
   It removes any grid information from the "boundary" statement
   It adds an index and a position for the z-dimension for arrays

   Shorthand notation is identified if present for cuboids

   Note that '  '.join(tmp_list[0:x]) joins together elements 0 to x-1, with '  ' in between each element
  """

  print 'Running editGeomBlock'

  read_geom = findLineNumWithComments(new_input, 'read geom')
  end_geom = findLineNumWithComments(new_input, 'end geom',start_index=read_geom)
# In case some shorthand notation is used
  read_shorthand = re.compile(r'^(\d+)([sp])([a-zA-Z0-9.\-+]*)')   # ie for 4p5.43e-5 the returned list will contain ['4', 'p', '5.43e-5']


  for line_num in range(read_geom + 1, end_geom):
########### Cylinder
    if 'cylinder' in new_input[line_num]:
      tmp_list = string2list(new_input[line_num])
      new_input[line_num] = '  '.join(tmp_list[0:3]) + '  20.0  -20.0  '+ '  '.join(tmp_list[3:]) + '\n'
########### Cuboid
    elif 'cuboid' in new_input[line_num]:
      tmp_list = string2list(new_input[line_num])
      try:
        short = read_shorthand.search(tmp_list[2]).groups()
      except AttributeError:   # No shorthand used
        new_input[line_num] = '  '.join(tmp_list[0:6]) + '  20.0  -20.0  '+ '  '.join(tmp_list[6:]) + '\n'
      else:                    # There was shorthand
        new_input[line_num] = '  '.join(tmp_list[0:3]) + '  20.0  -20.0  '+ '  '.join(tmp_list[3:]) + '\n'
############ Boundary
    elif 'boundary' in new_input[line_num]:
      tmp_list = string2list(new_input[line_num])
      new_input[line_num] = 'boundary  ' + tmp_list[1] + '\n'
############ Array
    elif 'array' in new_input[line_num]:
      tmp_list = string2list(new_input[line_num])
      new_input[line_num] = '  '.join(tmp_list[0:6]) + '  1  ' + '  '.join(tmp_list[6:8]) + '  0.0  ' + '  '.join(tmp_list[8:]) + '\n'

  return new_input
Exemplo n.º 3
0
def getMixtureAssignments(lines):
############################################################################
# If the 'assign' keyword is used in the Depletion Block, this routine
# determines which mixture ID's are assigned so that they can be added
# to the composition block for the MCDancoff Input.

# If no assignments are present, set mixAssignmentsGivenParentMix = -1

  print 'Running getMixtureAssignments in getDepletionData'

#  mixAssignmentsGivenParentMix = {}   # This is the dictionary which will hold {mixtureID : [Assigned MixtureIDs]}
#  parentMixGivenAssignedMix = {}  # This dictionary holds {Assigned mixture ID : Parent mixture ID}

  mixAssignmentsGivenParentMix = -1
  parentMixGivenAssignedMix = -1

# Make sure comments are removed
  for line_num in range(len(lines)-2,-1,-1):    # Stepping back through input, need -2 cuz extra empty spot at end of list assigned
    if lines[line_num][0] == "'":
      del lines[line_num]         # delete the comments

# Check if depletion block exists
  start_depl = findLineNum(lines,'read dep')
  if start_depl == -1:
    print 'No Depletion Block Found: There are no mixtureID assignments'
  else:

    end_depl = findLineNum(lines,'end dep', start_index=start_depl)

  # Make into one long string
    all_lines = ' '
    for line_num in range(start_depl,end_depl+1):
      all_lines = all_lines + lines[line_num] + ' '

  # If assignments are present in the depletion block, then fill the dictionaries
    if 'assign' in all_lines:
      mixAssignmentsGivenParentMix = {}
      parentMixGivenAssignedMix = {}
    # Separate each word/number into a list
      depl_block = string2list(all_lines)
    # Now look for the keyword 'assign' to determine which mixtures aren't in the composition block
      for i in range(len(depl_block)):
        if depl_block[i] == 'assign':
          tmp_list = []
          for j in range(i+2, len(depl_block)):
            if depl_block[j] == 'end':
              mixAssignmentsGivenParentMix[int(depl_block[i+1])] = tmp_list
              for assignedMix in tmp_list:
                parentMixGivenAssignedMix[assignedMix] = int(depl_block[i+1])
              break
            else:
              tmp_list.append(int(depl_block[j]))
# Return the dictionaries
  data = [parentMixGivenAssignedMix, mixAssignmentsGivenParentMix]
  return data
Exemplo n.º 4
0
def parseGeometryKeywords(list_of_strings, unit):
  """ Given (1) a list of strings that define the geometry of a unit and (2) the
      unit number, this module will create a dictionary 'regionDict' that
      summarizes the unit geometry.
      This regionDict is then returned. """

#  print 'Running parseGeometryKeywords'

  regionDict = {}  # Temporary dictionary for holding data to be added to unitGeom

  media_counter = 1        # Initialize to 1 each time a new unit is parsed
  for new_line in range(len(list_of_strings)):
# Split the string new_line into a list of words/numbers called geomData
    geomData = string2list(list_of_strings[new_line])
    """ Check for shorthand notation, if no shorthand is used then none will be returned.
        Need an exception for the error this will cause. If shorthand found, expand it. """
    geomData = expandFIDO(geomData)
# Now that the geometry data has been parsed and shorthand has been expanded, read the values in a dictionary
    if not geomData: # skip if there is a blank line
      continue   
    elif geomData[0] == 'cylinder':
      regionDict[int(geomData[1])] = {'shape':geomData[0], 'radius':float(geomData[2])}
    elif geomData[0] =='cuboid':
      regionDict[int(geomData[1])] = {'shape':geomData[0],'dimension':{'x+':float(geomData[2]),'x-':float(geomData[3]),'y+':float(geomData[4]),'y-':float(geomData[5])}}
# For 'media', we want to assign a mixtureID to a regionID. Select the regionID by whichever one is not negative.
# Search among geomData[3:] since this is where composition numbers start
    elif geomData[0] == 'media':
      for z in range(3,len(geomData)):
        j = geomData[z].find('-')
        if j == -1:  
          regionID = geomData[z]
          break
      regionDict[int(regionID)]['mixtureID'] = int(geomData[1])
      regionDict[int(regionID)]['mediaOrder'] = media_counter     # This is needed for MCDancoff Inputs
      regionDict[int(regionID)]['densityMultiplier'] = float(geomData[2])
      media_counter += 1
      if float(geomData[2]) != 1.0:
        print 'Non-unity Density Multiplier in Unit ', unit, 'in region ', regionID
        print 'Value given is ', geomData[2]
        print 'WARNING - This is not accounted for yet when creating in Centrm Inputs '
    elif geomData[0] == 'hole':
      media_counter += 1
      print 'WARNING - Hole found in unit ', unit, '.  Nothing currently done with holes.'
    elif geomData[0] == 'boundary':
      regionDict['boundaryRegion'] = int(geomData[1])
#      unitGeom[unit] = regionDict
    elif geomData[0].find('com') != -1:
      continue  # This is just a comment
    else:
      continue
      print 'WARNING - Presently Unsupported Keyword In Unit ', unit
#      print regionDict
  return regionDict
Exemplo n.º 5
0
def getCompDataByMixtureID(lines):
    compDataByMixtureID = {}
    """ dictionary compDataByMixtureID will contain 
  {mixID : {materialIndex : [list of strings for the composition data]}}
  where mixID and materialIndex are integers. An example is below:

  uo2 500 den=10.19 0.97 948.45 92235 2.93 92234 0.0261 92236 0.0135 92238 97.0304 end
  gd2o3 500 den=10.19 0.03 948.45 end

  This would be stored as follows:
  {500 :{0 :['uo2', '500', 'den=10.19', '0.97', ... , 'end']}, {1 :['gd2o3', '500', 'den=10.19', '0.03', '948.45', 'end']}}
  """

    print 'Running getCompDataByMixtureID in getCompositionData'

    linesNoComm = lines[:]
    for line_num in range(
            len(linesNoComm) - 2, -1, -1
    ):  # Stepping back through input, need -2 cuz extra empty spot at end of list assigned
        if linesNoComm[line_num][0] == "'":
            del linesNoComm[line_num]  # delete the comments

    start_compNoComm = findLineNum(linesNoComm, 'read comp')
    end_compNoComm = findLineNum(linesNoComm,
                                 'end comp',
                                 start_index=start_compNoComm)

    # Need to add materials to the composition block that were "assigned" in the depletion block of the Newt input

    compString = ''
    for line_num in range(start_compNoComm + 1, end_compNoComm):
        if 'end' not in linesNoComm[line_num]:
            compString = compString + linesNoComm[line_num] + ' '
            continue
        else:
            compString = compString + linesNoComm[line_num]
            compData_list = string2list(compString)
            compString = ''
            # A mixture ID may be made of several materials, account for that here
            # If the mixture ID already exists then add a new material (index for materials counts up from 0)
            mixID = int(compData_list[1])
            if int(compData_list[1]) not in compDataByMixtureID.keys():
                compDataByMixtureID[mixID] = {0: compData_list}
            else:
                materialIndex = len(
                    compDataByMixtureID[mixID].keys()
                )  # If 0 is already taken, then len will return 1, which is used for the materialIndex
                compDataByMixtureID[mixID][materialIndex] = compData_list
    return compDataByMixtureID
Exemplo n.º 6
0
def getCompDataByMixtureID(lines):
  compDataByMixtureID = {}
  """ dictionary compDataByMixtureID will contain 
  {mixID : {materialIndex : [list of strings for the composition data]}}
  where mixID and materialIndex are integers. An example is below:

  uo2 500 den=10.19 0.97 948.45 92235 2.93 92234 0.0261 92236 0.0135 92238 97.0304 end
  gd2o3 500 den=10.19 0.03 948.45 end

  This would be stored as follows:
  {500 :{0 :['uo2', '500', 'den=10.19', '0.97', ... , 'end']}, {1 :['gd2o3', '500', 'den=10.19', '0.03', '948.45', 'end']}}
  """

  print 'Running getCompDataByMixtureID in getCompositionData'

  linesNoComm = lines[:]
  for line_num in range(len(linesNoComm)-2,-1,-1):    # Stepping back through input, need -2 cuz extra empty spot at end of list assigned
    if linesNoComm[line_num][0] == "'":
      del linesNoComm[line_num]         # delete the comments

  start_compNoComm = findLineNum(linesNoComm,'read comp')
  end_compNoComm = findLineNum(linesNoComm,'end comp',start_index=start_compNoComm)

# Need to add materials to the composition block that were "assigned" in the depletion block of the Newt input

  compString = ''
  for line_num in range(start_compNoComm+1, end_compNoComm):
    if 'end' not in linesNoComm[line_num]:
      compString = compString + linesNoComm[line_num] + ' '
      continue
    else:
      compString = compString + linesNoComm[line_num]
      compData_list = string2list(compString)
      compString = ''
# A mixture ID may be made of several materials, account for that here
# If the mixture ID already exists then add a new material (index for materials counts up from 0)
      mixID = int(compData_list[1])
      if int(compData_list[1]) not in compDataByMixtureID.keys():
        compDataByMixtureID[mixID] = {0:compData_list}
      else:
        materialIndex = len(compDataByMixtureID[mixID].keys())  # If 0 is already taken, then len will return 1, which is used for the materialIndex
        compDataByMixtureID[mixID][materialIndex] = compData_list
  return compDataByMixtureID
Exemplo n.º 7
0
def fixUnitsWithArrays(new_input,unitGeom=0,arrayData=0):
 
  print 'Running fixUnitsWithArrays'

  if unitGeom == 0:
    unitGeom = getUnitGeom(new_input)
  if arrayData == 0:
    arrayData = getArrayData(new_input)

  start_geom = findLineNumWithComments(new_input,'read geom')
  end_geom = findLineNumWithComments(new_input,'end geom', start_index=start_geom)

  """ Start by calculating the x and y dimensions of the array. 
        A) Find nux and nuy
        B) Make a list of units which span the x and y dimensions of the array
        C) Find the size of each of these units
          1)  Find which region is the boundary for the unit
          2) Find the dimension of that region
        D) Sum up the unit dimensions to ge the array dimension """

  # Remove any redundant spaces to make parsing simpler
  for line_num in range(start_geom,end_geom):
    new_input[line_num] = re.sub('[ ]+',' ', new_input[line_num])

  for array_num in arrayData.keys():
    units_x = []
    units_y = []
    nux = arrayData[array_num]['nux']
    nuy = arrayData[array_num]['nuy']
    for position in range(nux):
      units_x.append(arrayData[array_num]['unitGivenLocation'][position])
    # this units_y part will only work for a cuboidal array
    for position in range(0,nux*nuy,nux):
      units_y.append(arrayData[array_num]['unitGivenLocation'][position])
    unit_size = []
    array_size_x = 0.0
    for unit in units_x:
      boundary_region = unitGeom[unit]['boundaryRegion']
      unit_size = abs(unitGeom[unit][boundary_region]['dimension']['x+']) + abs(unitGeom[unit][boundary_region]['dimension']['x-'])
      array_size_x = array_size_x + unit_size
#    print array_size_x
    unit_size = []
    array_size_y = 0.0
    for unit in units_y:
      boundary_region = unitGeom[unit]['boundaryRegion']
      unit_size = abs(unitGeom[unit][boundary_region]['dimension']['y+']) + abs(unitGeom[unit][boundary_region]['dimension']['y-'])
      array_size_y = array_size_y + unit_size
#    print array_size_y

    """ Now for each array:
        E) go to the unit where the array is described
        F) Read the array definition
        G) Determine which surface is being filled in the array
        H) If this surface is larger than array_size_x and array_size_y
          1) Make a new surface that has dimensions array_size_x and array_size_y
            a) If array_size_x == array_size_y
              i) Adjust the x+ and x- equally to get the correct size surface
              ii) Adjust the y+ and y- equally to get the correct size surface
            b) If array_size_x != array_size_y
              i) Adjust the x+ dimension to get the correct size surface
              ii) Adjust the y- dimension to get the correct size surface
          2) Change the array definition such that this new_surface is the one being filled
          3) Add "-" + new_suface_number to the media describing the old surface number
    """
    # This is the unit where the array is used
    unit = arrayData[array_num]['locatedInUnit']
#    print 'The Unit we want is ', unit
    # Find the start and end of the desciption for the unit
    unit_search = re.compile(r'unit\s+(\d+)')
    search_line = start_geom
    for line_num in range(start_geom, end_geom):
      tmp_line_num = findLineNumWithComments(new_input,'unit',start_index=search_line)
      tmp_unit = int(unit_search.search(new_input[tmp_line_num]).groups()[0])
      if unit == tmp_unit:
        start_unit = tmp_line_num
        break
      else:
        search_line = tmp_line_num + 1
    end_unit = findLineNumWithComments(new_input,'boundary',start_index=start_unit)


    # Find where the array is described
    array_search = re.compile(r'array\s+(\d+)')
    for line_num in range(start_unit, end_unit):
      tmp_line_num = findLineNumWithComments(new_input,'array',start_index=line_num)
      possible_array = int(array_search.search(new_input[tmp_line_num]).groups()[0])
      if array_num == possible_array:
        array_line = tmp_line_num
        break
#    print new_input[array_line]

    # Read the array information
    array_reader = re.compile(r'array([a-zA-Z0-9.\-+ ]+)place')
    tmp_string = array_reader.search(new_input[array_line]).groups()[0]
    tmp_list = string2list(tmp_string)
    # The bounding surface for the array is the one that is not negative
    for i in range(1, len(tmp_list)):
      if tmp_list[i].find('-') == -1:
        array_surf = int(tmp_list[i])
#    print 'array surf is ', array_surf
    
    # Find the dimensions of the array surface being used
    x_plus = unitGeom[unit][array_surf]['dimension']['x+']
    x_minus = unitGeom[unit][array_surf]['dimension']['x-']
    y_plus = unitGeom[unit][array_surf]['dimension']['y+']
    y_minus = unitGeom[unit][array_surf]['dimension']['y-']
    surf_x_length = abs(x_plus - x_minus)
    surf_y_length = abs(y_plus - y_minus)

    # See if the array surface size is the same as the sum of the length of the units filling it
    if surf_x_length == array_size_x and surf_y_length == array_size_y:
      print 'Array', array_num, 'seems OK. Continuing...'
      pass
    else:
      print 'Array', array_num, ': The surface used to define the array is larger than the sum of the length of the units filling it.'
      print 'This will cause issues in KENO/MCDancoff.'
      print 'Attempting to fix the problem'
      x_diff = surf_x_length - array_size_x
      y_diff = surf_y_length - array_size_y
      if array_size_x == array_size_y:
        new_x_plus = x_plus - x_diff/2.0
        new_x_minus = x_minus + x_diff/2.0
        new_y_plus = y_plus - y_diff/2.0
        new_y_minus = y_minus + y_diff/2.0
      else:
        new_x_plus = x_plus - x_diff
        new_x_minus = x_minus
        new_y_plus = y_plus
        new_y_minus = y_minus + y_diff

      """ Start making the new surface for the array to be filled into """

      # Pick a new surface # that is not already in use
      tmp_list = unitGeom[unit].keys()
      new_surf_num = 999
      for num in range(999,0,-1):
        if new_surf_num in tmp_list:
          new_surf_num = new_surf_num - 1
        else:
          break

      # Make the new surface by copying the old one and editing it's values
      shape = unitGeom[unit][array_surf]['shape']
      array_surf_line = findLineNumWithComments(new_input, shape + ' ' + str(array_surf), start_index=start_unit)
      new_surf_list = string2list(new_input[array_surf_line])
#      print new_input[array_surf_line]
      new_surf_list[1] = str(new_surf_num)
      new_surf_list[2] = str(new_x_plus)
      new_surf_list[3] = str(new_x_minus)
      new_surf_list[4] = str(new_y_plus)
      new_surf_list[5] = str(new_y_minus)
      new_surf_definition = ' '.join(new_surf_list)
#      print new_surf_definition

      # Change the array definition to use the new surface
      new_array_list = string2list(new_input[array_line])
      # The bounding surface for the array is the one that is not negative
      for i in range(2, len(new_array_list)):
        if new_array_list[i].find('-') == -1:
          new_array_list[i] = str(new_surf_num)
          break
      new_array_definition = ' '.join(new_array_list)
#      print new_array_definition
      
      # Write the new surface definition to the input
      new_input.insert(array_surf_line, new_surf_definition + '\n')
      new_input.insert(array_surf_line, "'The new surface is defined below \n")

      # Write the new array definition to the input
      # Check if the array definition line number changed first
      if array_line > array_surf_line:
        array_line = array_line + 2
      new_input[array_line] = "'Old: " + new_input[array_line]
      new_input.insert(array_line, new_array_definition + '\n')
      new_input.insert(array_line, "'The new array is defined below \n")

      """ Now need to change the media that describes the original 
          surface number to also exclude the new surface number """
      # Find where the array is described, then append '-' + new_surf_num
      array_search = re.compile(r'array\s+(\d+)')
      for line_num in range(start_unit, end_unit):
        tmp_line_num = findLineNumWithComments(new_input,'media',start_index=tmp_line_num)
        tmp_list = string2list(new_input[tmp_line_num])
        if str(array_surf) in tmp_list[3:]:
          media_line = tmp_line_num
          tmp_list.append(' ' + '-' + str(new_surf_num))
          new_media_line = ' '.join(tmp_list)
          break
        else:
          tmp_line_num = tmp_line_num + 1

      new_input[media_line] = "'Old: " + new_input[media_line] + '\n'
      new_input.insert(media_line, new_media_line + '\n')
      new_input.insert(media_line, "'The new media is defined below \n")
  return new_input
Exemplo n.º 8
0
def parseGeometryKeywords(list_of_strings, unit):
    """ Given (1) a list of strings that define the geometry of a unit and (2) the
      unit number, this module will create a dictionary 'regionDict' that
      summarizes the unit geometry.
      This regionDict is then returned. """

    #  print 'Running parseGeometryKeywords'

    regionDict = {
    }  # Temporary dictionary for holding data to be added to unitGeom

    media_counter = 1  # Initialize to 1 each time a new unit is parsed
    for new_line in range(len(list_of_strings)):
        # Split the string new_line into a list of words/numbers called geomData
        geomData = string2list(list_of_strings[new_line])
        """ Check for shorthand notation, if no shorthand is used then none will be returned.
        Need an exception for the error this will cause. If shorthand found, expand it. """
        geomData = expandFIDO(geomData)
        # Now that the geometry data has been parsed and shorthand has been expanded, read the values in a dictionary
        if not geomData:  # skip if there is a blank line
            continue
        elif geomData[0] == 'cylinder':
            regionDict[int(geomData[1])] = {
                'shape': geomData[0],
                'radius': float(geomData[2])
            }
        elif geomData[0] == 'cuboid':
            regionDict[int(geomData[1])] = {
                'shape': geomData[0],
                'dimension': {
                    'x+': float(geomData[2]),
                    'x-': float(geomData[3]),
                    'y+': float(geomData[4]),
                    'y-': float(geomData[5])
                }
            }
# For 'media', we want to assign a mixtureID to a regionID. Select the regionID by whichever one is not negative.
# Search among geomData[3:] since this is where composition numbers start
        elif geomData[0] == 'media':
            for z in range(3, len(geomData)):
                j = geomData[z].find('-')
                if j == -1:
                    regionID = geomData[z]
                    break
            regionDict[int(regionID)]['mixtureID'] = int(geomData[1])
            regionDict[int(
                regionID
            )]['mediaOrder'] = media_counter  # This is needed for MCDancoff Inputs
            regionDict[int(regionID)]['densityMultiplier'] = float(geomData[2])
            media_counter += 1
            if float(geomData[2]) != 1.0:
                print 'Non-unity Density Multiplier in Unit ', unit, 'in region ', regionID
                print 'Value given is ', geomData[2]
                print 'WARNING - This is not accounted for yet when creating in Centrm Inputs '
        elif geomData[0] == 'hole':
            media_counter += 1
            print 'WARNING - Hole found in unit ', unit, '.  Nothing currently done with holes.'
        elif geomData[0] == 'boundary':
            regionDict['boundaryRegion'] = int(geomData[1])
#      unitGeom[unit] = regionDict
        elif geomData[0].find('com') != -1:
            continue  # This is just a comment
        else:
            continue
            print 'WARNING - Presently Unsupported Keyword In Unit ', unit


#      print regionDict
    return regionDict
Exemplo n.º 9
0
def fixUnitsWithArrays(new_input, unitGeom=0, arrayData=0):

    print 'Running fixUnitsWithArrays'

    if unitGeom == 0:
        unitGeom = getUnitGeom(new_input)
    if arrayData == 0:
        arrayData = getArrayData(new_input)

    start_geom = findLineNumWithComments(new_input, 'read geom')
    end_geom = findLineNumWithComments(new_input,
                                       'end geom',
                                       start_index=start_geom)
    """ Start by calculating the x and y dimensions of the array. 
        A) Find nux and nuy
        B) Make a list of units which span the x and y dimensions of the array
        C) Find the size of each of these units
          1)  Find which region is the boundary for the unit
          2) Find the dimension of that region
        D) Sum up the unit dimensions to ge the array dimension """

    # Remove any redundant spaces to make parsing simpler
    for line_num in range(start_geom, end_geom):
        new_input[line_num] = re.sub('[ ]+', ' ', new_input[line_num])

    for array_num in arrayData.keys():
        units_x = []
        units_y = []
        nux = arrayData[array_num]['nux']
        nuy = arrayData[array_num]['nuy']
        for position in range(nux):
            units_x.append(arrayData[array_num]['unitGivenLocation'][position])
        # this units_y part will only work for a cuboidal array
        for position in range(0, nux * nuy, nux):
            units_y.append(arrayData[array_num]['unitGivenLocation'][position])
        unit_size = []
        array_size_x = 0.0
        for unit in units_x:
            boundary_region = unitGeom[unit]['boundaryRegion']
            unit_size = abs(
                unitGeom[unit][boundary_region]['dimension']['x+']) + abs(
                    unitGeom[unit][boundary_region]['dimension']['x-'])
            array_size_x = array_size_x + unit_size
#    print array_size_x
        unit_size = []
        array_size_y = 0.0
        for unit in units_y:
            boundary_region = unitGeom[unit]['boundaryRegion']
            unit_size = abs(
                unitGeom[unit][boundary_region]['dimension']['y+']) + abs(
                    unitGeom[unit][boundary_region]['dimension']['y-'])
            array_size_y = array_size_y + unit_size
#    print array_size_y
        """ Now for each array:
        E) go to the unit where the array is described
        F) Read the array definition
        G) Determine which surface is being filled in the array
        H) If this surface is larger than array_size_x and array_size_y
          1) Make a new surface that has dimensions array_size_x and array_size_y
            a) If array_size_x == array_size_y
              i) Adjust the x+ and x- equally to get the correct size surface
              ii) Adjust the y+ and y- equally to get the correct size surface
            b) If array_size_x != array_size_y
              i) Adjust the x+ dimension to get the correct size surface
              ii) Adjust the y- dimension to get the correct size surface
          2) Change the array definition such that this new_surface is the one being filled
          3) Add "-" + new_suface_number to the media describing the old surface number
    """
        # This is the unit where the array is used
        unit = arrayData[array_num]['locatedInUnit']
        #    print 'The Unit we want is ', unit
        # Find the start and end of the desciption for the unit
        unit_search = re.compile(r'unit\s+(\d+)')
        search_line = start_geom
        for line_num in range(start_geom, end_geom):
            tmp_line_num = findLineNumWithComments(new_input,
                                                   'unit',
                                                   start_index=search_line)
            tmp_unit = int(
                unit_search.search(new_input[tmp_line_num]).groups()[0])
            if unit == tmp_unit:
                start_unit = tmp_line_num
                break
            else:
                search_line = tmp_line_num + 1
        end_unit = findLineNumWithComments(new_input,
                                           'boundary',
                                           start_index=start_unit)

        # Find where the array is described
        array_search = re.compile(r'array\s+(\d+)')
        for line_num in range(start_unit, end_unit):
            tmp_line_num = findLineNumWithComments(new_input,
                                                   'array',
                                                   start_index=line_num)
            possible_array = int(
                array_search.search(new_input[tmp_line_num]).groups()[0])
            if array_num == possible_array:
                array_line = tmp_line_num
                break
#    print new_input[array_line]

# Read the array information
        array_reader = re.compile(r'array([a-zA-Z0-9.\-+ ]+)place')
        tmp_string = array_reader.search(new_input[array_line]).groups()[0]
        tmp_list = string2list(tmp_string)
        # The bounding surface for the array is the one that is not negative
        for i in range(1, len(tmp_list)):
            if tmp_list[i].find('-') == -1:
                array_surf = int(tmp_list[i])


#    print 'array surf is ', array_surf

# Find the dimensions of the array surface being used
        x_plus = unitGeom[unit][array_surf]['dimension']['x+']
        x_minus = unitGeom[unit][array_surf]['dimension']['x-']
        y_plus = unitGeom[unit][array_surf]['dimension']['y+']
        y_minus = unitGeom[unit][array_surf]['dimension']['y-']
        surf_x_length = abs(x_plus - x_minus)
        surf_y_length = abs(y_plus - y_minus)

        # See if the array surface size is the same as the sum of the length of the units filling it
        if surf_x_length == array_size_x and surf_y_length == array_size_y:
            print 'Array', array_num, 'seems OK. Continuing...'
            pass
        else:
            print 'Array', array_num, ': The surface used to define the array is larger than the sum of the length of the units filling it.'
            print 'This will cause issues in KENO/MCDancoff.'
            print 'Attempting to fix the problem'
            x_diff = surf_x_length - array_size_x
            y_diff = surf_y_length - array_size_y
            if array_size_x == array_size_y:
                new_x_plus = x_plus - x_diff / 2.0
                new_x_minus = x_minus + x_diff / 2.0
                new_y_plus = y_plus - y_diff / 2.0
                new_y_minus = y_minus + y_diff / 2.0
            else:
                new_x_plus = x_plus - x_diff
                new_x_minus = x_minus
                new_y_plus = y_plus
                new_y_minus = y_minus + y_diff
            """ Start making the new surface for the array to be filled into """

            # Pick a new surface # that is not already in use
            tmp_list = unitGeom[unit].keys()
            new_surf_num = 999
            for num in range(999, 0, -1):
                if new_surf_num in tmp_list:
                    new_surf_num = new_surf_num - 1
                else:
                    break

            # Make the new surface by copying the old one and editing it's values
            shape = unitGeom[unit][array_surf]['shape']
            array_surf_line = findLineNumWithComments(new_input,
                                                      shape + ' ' +
                                                      str(array_surf),
                                                      start_index=start_unit)
            new_surf_list = string2list(new_input[array_surf_line])
            #      print new_input[array_surf_line]
            new_surf_list[1] = str(new_surf_num)
            new_surf_list[2] = str(new_x_plus)
            new_surf_list[3] = str(new_x_minus)
            new_surf_list[4] = str(new_y_plus)
            new_surf_list[5] = str(new_y_minus)
            new_surf_definition = ' '.join(new_surf_list)
            #      print new_surf_definition

            # Change the array definition to use the new surface
            new_array_list = string2list(new_input[array_line])
            # The bounding surface for the array is the one that is not negative
            for i in range(2, len(new_array_list)):
                if new_array_list[i].find('-') == -1:
                    new_array_list[i] = str(new_surf_num)
                    break
            new_array_definition = ' '.join(new_array_list)
            #      print new_array_definition

            # Write the new surface definition to the input
            new_input.insert(array_surf_line, new_surf_definition + '\n')
            new_input.insert(array_surf_line,
                             "'The new surface is defined below \n")

            # Write the new array definition to the input
            # Check if the array definition line number changed first
            if array_line > array_surf_line:
                array_line = array_line + 2
            new_input[array_line] = "'Old: " + new_input[array_line]
            new_input.insert(array_line, new_array_definition + '\n')
            new_input.insert(array_line, "'The new array is defined below \n")
            """ Now need to change the media that describes the original 
          surface number to also exclude the new surface number """
            # Find where the array is described, then append '-' + new_surf_num
            array_search = re.compile(r'array\s+(\d+)')
            for line_num in range(start_unit, end_unit):
                tmp_line_num = findLineNumWithComments(
                    new_input, 'media', start_index=tmp_line_num)
                tmp_list = string2list(new_input[tmp_line_num])
                if str(array_surf) in tmp_list[3:]:
                    media_line = tmp_line_num
                    tmp_list.append(' ' + '-' + str(new_surf_num))
                    new_media_line = ' '.join(tmp_list)
                    break
                else:
                    tmp_line_num = tmp_line_num + 1

            new_input[media_line] = "'Old: " + new_input[media_line] + '\n'
            new_input.insert(media_line, new_media_line + '\n')
            new_input.insert(media_line, "'The new media is defined below \n")
    return new_input