Commit 418c734c authored by Gurecky, William's avatar Gurecky, William
Browse files

adding alternate interpolation method to get nodal powers onto the ctf grid

parent 4d4a238f
Loading
Loading
Loading
Loading
+20 −10
Original line number Diff line number Diff line
@@ -990,7 +990,7 @@ class SquareLatticeLWR_Nodal(CoreBuilder.Core):
      for i, obj in enumerate(me.model.solidObjects.values()):
         obj.power = radP[i]

   def setCorePowerShape3D(me, powerDist, wgts=None, coreStart=0.0):
   def setCorePowerShape3D(me, powerDist, wgts=None, coreStart=0.0, interp_type="nearest"):
      """
      Set a 3D power distribution for the core.
      Args:
@@ -1013,11 +1013,12 @@ class SquareLatticeLWR_Nodal(CoreBuilder.Core):
         coreStart (float): The axial location of the start of the core.  In CTF, the bottom of the
            model is zero.  If the core does not start at the bottom of the model, this must be provided
            so the power tables are correctly defined in CTF. [m]
         interp_type: str. One of "nearest" or "linear"
      """
      if len(powerDist.shape) == 3:
         me._setCorePowerShapeAsm3D(powerDist, wgts, coreStart)
         me._setCorePowerShapeAsm3D(powerDist, wgts, coreStart, interp_type)
      elif len(powerDist.shape) == 4:
         me._setCorePowerShapeNodal3D(powerDist, wgts, coreStart)
         me._setCorePowerShapeNodal3D(powerDist, wgts, coreStart, interp_type)
      else:
         raise RuntimeError("Invalid power distribution shape: %s" % str(powerDist.shape))

@@ -1031,7 +1032,7 @@ class SquareLatticeLWR_Nodal(CoreBuilder.Core):
      for i, obj in enumerate(me.model.solidObjects.values()):
         obj.power = radP[i]

   def _setCorePowerShapeAsm3D(me, powerDist, wgts=None, coreStart=0.0):
   def _setCorePowerShapeAsm3D(me, powerDist, wgts=None, coreStart=0.0, interp_type="nearest"):
      """
      Set a 3D power distribution for the core.  Each assembly can have its own
      axial power shape.
@@ -1091,7 +1092,7 @@ class SquareLatticeLWR_Nodal(CoreBuilder.Core):
                  # radial power factors are implicit in the 3d power distribution
                  obj_rod.power = avg_axpwr

   def _setCorePowerShapeNodal3D(me, powerDist, wgts=None, coreStart=0.0):
   def _setCorePowerShapeNodal3D(me, powerDist, wgts=None, coreStart=0.0, interp_type="nearest"):
      """
      Set a 3D power distribution for the core.  Each node within each assembly
      can have its own axial power shape.
@@ -1169,12 +1170,21 @@ class SquareLatticeLWR_Nodal(CoreBuilder.Core):

                  # the node_axial_power_profile is specified at z_centers
                  assert me.z_centers.size == node_axial_power_profile.size

                  if interp_type == "linear":
                     # lin interpolate to the z_bounds
                     node_axial_power_interpolant = \
                             interp1d(me.z_centers, node_axial_power_profile,
                                      kind='linear', fill_value='extrapolate')

                  # interpolate to the z_bounds
                     node_axial_power_ctf = node_axial_power_interpolant(me.z_power_grid)
                  else:
                     # alternative interp to ctf grid
                     node_axial_power_ctf = np.zeros(me.z_power_grid.size)
                     for z_lvl in range(me.z_centers.size):
                        node_axial_power_ctf[[2*z_lvl, 2*z_lvl+1]] = \
                                node_axial_power_profile[z_lvl]

                  # Normalize such that axially integrated asm nodal power is 1
                  avg_axpwr = np.max((np.trapz(node_axial_power_ctf, x=me.z_power_grid) / \
                        (np.max(me.z_power_grid) - np.min(me.z_power_grid)), 1e-12))