Пример #1
0
 def evaluatorTerms(self, universe, subset1, subset2, global_data):
     # The energy for subsets is defined as consisting only
     # of interactions within that subset, so the contribution
     # of an external field is zero. Therefore we just return
     # an empty list of energy terms.
     if subset1 is not None or subset2 is not None:
         return []
     # Collect the scaling_factor into an array
     scaling_factor = ParticleScalar(universe)
     for o in universe:
         for a in o.atomList():
             scaling_factor[a] = o.getAtomProperty(a, self.scaling_property)
     scaling_factor.scaleBy(self.scaling_prefactor)
     # Here we pass all the parameters to
     # the energy term code that handles energy calculations.
     return [TrilinearThreshGridTerm(universe, \
       self.grid_data['spacing'], self.grid_data['counts'], \
       self.grid_data['vals'], \
       self.strength, scaling_factor, self.grid_name, self.max_val, self.Ethresh)]
 def evaluatorTerms(self, universe, subset1, subset2, global_data):
     # The energy for subsets is defined as consisting only
     # of interactions within that subset, so the contribution
     # of an external field is zero. Therefore we just return
     # an empty list of energy terms.
     if subset1 is not None or subset2 is not None:
         return []
     # Collect the scaling_factor into an array
     scaling_factor = ParticleScalar(universe)
     for o in universe:
         for a in o.atomList():
             scaling_factor[a] = o.getAtomProperty(a, self.scaling_property)
     scaling_factor.scaleBy(self.scaling_prefactor)
     # Here we pass all the parameters to
     # the energy term code that handles energy calculations.
     return [TrilinearISqrtGridTerm(universe, \
       self.grid_data['spacing'], self.grid_data['counts'], \
       self.grid_data['vals'], \
       self.strength, scaling_factor, self.grid_name)]
Пример #3
0
  def evaluatorTerms(self, universe, subset1, subset2, global_data):
    # The energy for subsets is defined as consisting only
    # of interactions within that subset, so the contribution
    # of an external field is zero. Therefore we just return
    # an empty list of energy terms.
    if subset1 is not None or subset2 is not None:
      return []
    # Collect the scaling_factor into an array
    scaling_factor = ParticleScalar(universe)
    for o in universe:
      for a in o.atomList():
        scaling_factor[a] = o.getAtomProperty(a, self.params['scaling_property'])
    scaling_factor.scaleBy(self.params['scaling_prefactor'])

    # Here we pass all the parameters to
    # the energy term code that handles energy calculations.
    if self.params['interpolation_type']=='Trilinear':
      if self.params['energy_thresh']>0:
        if self.params['inv_power'] is not None:
          raise NotImplementedError
        else:
          from MMTK_trilinear_thresh_grid import TrilinearThreshGridTerm
          return [TrilinearThreshGridTerm(universe, \
            self.grid_data['spacing'], self.grid_data['counts'], \
            self.grid_data['vals'], self.params['strength'], scaling_factor, \
            self.params['name'], self.params['energy_thresh'])]
      elif self.params['inv_power'] is not None:
        if self.params['inv_power']==-2:
          from MMTK_trilinear_isqrt_grid import TrilinearISqrtGridTerm
          return [TrilinearISqrtGridTerm(universe, \
            self.grid_data['spacing'], self.grid_data['counts'], \
            self.grid_data['vals'], self.params['strength'], scaling_factor, \
            self.params['name'])]
        else:
          from MMTK_trilinear_transform_grid import TrilinearTransformGridTerm
          return [TrilinearTransformGridTerm(universe, \
            self.grid_data['spacing'], self.grid_data['counts'], \
            self.grid_data['vals'], self.params['strength'], scaling_factor,
            self.params['name'], self.params['inv_power'])]
      else:
        from MMTK_trilinear_grid import TrilinearGridTerm
        return [TrilinearGridTerm(universe, \
          self.grid_data['spacing'], self.grid_data['counts'], \
          self.grid_data['vals'], self.params['strength'], scaling_factor, \
          self.params['name'])]
    elif self.params['interpolation_type']=='BSpline':
      if self.params['inv_power'] is not None:
        from MMTK_BSpline_transform_grid import BSplineTransformGridTerm
        return [BSplineTransformGridTerm(universe, \
          self.grid_data['spacing'], self.grid_data['counts'], \
          self.grid_data['vals'], self.params['strength'], scaling_factor, \
          self.params['name'], self.params['inv_power'])]
      else:
        from MMTK_BSpline_grid import BSplineGridTerm
        return [BSplineGridTerm(universe, \
          self.grid_data['spacing'], self.grid_data['counts'], \
          self.grid_data['vals'], self.params['strength'], scaling_factor, \
          self.params['name'])]
    elif self.params['interpolation_type']=='CatmullRom':
      if self.params['inv_power'] is not None:
        from MMTK_CatmullRom_transform_grid import CatmullRomTransformGridTerm
        return [CatmullRomTransformGridTerm(universe, \
          self.grid_data['spacing'], self.grid_data['counts'], \
          self.grid_data['vals'], self.params['strength'], scaling_factor, \
          self.params['name'], self.params['inv_power'])]
      else:
        from MMTK_CatmullRom_grid import CatmullRomGridTerm
        return [CatmullRomGridTerm(universe, \
          self.grid_data['spacing'], self.grid_data['counts'], \
          self.grid_data['vals'], self.params['strength'], scaling_factor, \
          self.params['name'])]
    elif self.params['interpolation_type']=='Tricubic':
      raise NotImplementedError
Пример #4
0
    def evaluatorTerms(self, universe, subset1, subset2, global_data):
        # The energy for subsets is defined as consisting only
        # of interactions within that subset, so the contribution
        # of an external field is zero. Therefore we just return
        # an empty list of energy terms.
        if subset1 is not None or subset2 is not None:
            return []
        # Collect the scaling_factor into an array
        scaling_factor = ParticleScalar(universe)
        for o in universe:
            for a in o.atomList():
                scaling_factor[a] = o.getAtomProperty(
                    a, self.params['scaling_property'])
        scaling_factor.scaleBy(self.params['scaling_prefactor'])

        # Here we pass all the parameters to
        # the energy term code that handles energy calculations.
        if self.params['interpolation_type'] == 'Trilinear':
            if self.params['energy_thresh'] > 0:
                if self.params['inv_power'] is not None:
                    raise NotImplementedError
                else:
                    from MMTK_trilinear_thresh_grid import TrilinearThreshGridTerm
                    return [TrilinearThreshGridTerm(universe, \
                      self.grid_data['spacing'], self.grid_data['counts'], \
                      self.grid_data['vals'], self.params['strength'], scaling_factor, \
                      self.params['name'], self.params['energy_thresh'])]
            elif self.params['inv_power'] is not None:
                if self.params['inv_power'] == 4:
                    from MMTK_trilinear_one_fourth_grid import TrilinearOneFourthGridTerm
                    return [TrilinearOneFourthGridTerm(universe, \
                      self.grid_data['spacing'], self.grid_data['counts'], \
                      self.grid_data['vals'], self.params['strength'], scaling_factor, \
                      self.params['name'])]
                else:
                    from MMTK_trilinear_transform_grid import TrilinearTransformGridTerm
                    return [TrilinearTransformGridTerm(universe, \
                      self.grid_data['spacing'], self.grid_data['counts'], \
                      self.grid_data['vals'], self.params['strength'], scaling_factor,
                      self.params['name'], self.params['inv_power'])]
            else:
                from MMTK_trilinear_grid import TrilinearGridTerm
                return [TrilinearGridTerm(universe, \
                  self.grid_data['spacing'], self.grid_data['counts'], \
                  self.grid_data['vals'], self.params['strength'], scaling_factor, \
                  self.params['name'])]
        elif self.params['interpolation_type'] == 'BSpline':
            if self.params['inv_power'] is not None:
                from MMTK_BSpline_transform_grid import BSplineTransformGridTerm
                return [BSplineTransformGridTerm(universe, \
                  self.grid_data['spacing'], self.grid_data['counts'], \
                  self.grid_data['vals'], self.params['strength'], scaling_factor, \
                  self.params['name'], self.params['inv_power'])]
            else:
                from MMTK_BSpline_grid import BSplineGridTerm
                return [BSplineGridTerm(universe, \
                  self.grid_data['spacing'], self.grid_data['counts'], \
                  self.grid_data['vals'], self.params['strength'], scaling_factor, \
                  self.params['name'])]
        elif self.params['interpolation_type'] == 'CatmullRom':
            if self.params['inv_power'] is not None:
                from MMTK_CatmullRom_transform_grid import CatmullRomTransformGridTerm
                return [CatmullRomTransformGridTerm(universe, \
                  self.grid_data['spacing'], self.grid_data['counts'], \
                  self.grid_data['vals'], self.params['strength'], scaling_factor, \
                  self.params['name'], self.params['inv_power'])]
            else:
                from MMTK_CatmullRom_grid import CatmullRomGridTerm
                return [CatmullRomGridTerm(universe, \
                  self.grid_data['spacing'], self.grid_data['counts'], \
                  self.grid_data['vals'], self.params['strength'], scaling_factor, \
                  self.params['name'])]
        elif self.params['interpolation_type'] == 'Tricubic':
            if self.params['inv_power'] is not None:
                from MMTK_Tricubic_transform_grid import TricubicTransformGridTerm
                return [TricubicTransformGridTerm(universe, \
                  self.grid_data['spacing'], self.grid_data['counts'], \
                  self.grid_data['vals'], self.params['strength'], scaling_factor, \
                  self.params['name'], self.params['inv_power'])]
            else:
                from MMTK_Tricubic_grid import TricubicGridTerm
                return [TricubicGridTerm(universe, \
                  self.grid_data['spacing'], self.grid_data['counts'], \
                  self.grid_data['vals'], self.params['strength'], scaling_factor, \
                  self.params['name'])]
        print self.params['interpolation_type'] + ' interpolation is unknown'
        raise NotImplementedError
Пример #5
0
  def evaluatorTerms(self, universe, subset1, subset2, global_data):
    # The energy for subsets is defined as consisting only
    # of interactions within that subset, so the contribution
    # of an external field is zero. Therefore we just return
    # an empty list of energy terms.
    if subset1 is not None or subset2 is not None:
      return []
    # Collect the scaling_factor into an array
    scaling_factor = ParticleScalar(universe)
    for o in universe:
      for a in o.atomList():
        scaling_factor[a] = o.getAtomProperty(a, self.params['scaling_property'])
    scaling_factor.scaleBy(self.params['scaling_prefactor'])

    # Here we pass all the parameters to
    # the energy term code that handles energy calculations.
    if self.params['interpolation_type']=='Trilinear':
      if self.params['energy_thresh']>0:
        if self.params['inv_power'] is not None:
          raise NotImplementedError
        else:
          from MMTK_trilinear_thresh_grid import TrilinearThreshGridTerm
          return [TrilinearThreshGridTerm(universe, \
            self.grid_data['spacing'], self.grid_data['counts'], \
            self.grid_data['vals'], self.params['strength'], scaling_factor, \
            self.params['name'], self.params['energy_thresh'])]
      elif self.params['inv_power'] is not None:
        if self.params['inv_power']==4:
#          import time
#          import os.path
#          import MMTK_trilinear_one_fourth_grid
#          trilinear_grid_path = MMTK_trilinear_one_fourth_grid.__file__
#          print """
#          in {0}
#          last modified {1}
#              """.format(trilinear_grid_path, \
#              time.ctime(os.path.getmtime(trilinear_grid_path)))
          from MMTK_trilinear_one_fourth_grid import TrilinearOneFourthGridTerm
          return [TrilinearOneFourthGridTerm(universe._spec, \
            self.grid_data['spacing'], self.grid_data['counts'], \
            self.grid_data['vals'], self.params['strength'], \
            scaling_factor.array, \
            self.params['name'])]
        else:
          from MMTK_trilinear_transform_grid import TrilinearTransformGridTerm
          return [TrilinearTransformGridTerm(universe, \
            self.grid_data['spacing'], self.grid_data['counts'], \
            self.grid_data['vals'], self.params['strength'], scaling_factor,
            self.params['name'], self.params['inv_power'])]
      else:
        # print "self.params['name']", self.params['name']
        if self.use_C:
#          import time
#          import os.path
#          import MMTK_trilinear_grid
#          trilinear_grid_path = MMTK_trilinear_grid.__file__
#          print """
#          in {0}
#          last modified {1}
#              """.format(trilinear_grid_path, \
#              time.ctime(os.path.getmtime(trilinear_grid_path)))
          from MMTK_trilinear_grid import TrilinearGridTerm
          return [TrilinearGridTerm(universe._spec, \
            self.grid_data['spacing'], self.grid_data['counts'], \
            self.grid_data['vals'], self.params['strength'], \
            scaling_factor.array, \
            self.params['name'])]
        else:
          # This is for debugging
          from MMTK_trilinear_grid_cython import TrilinearGridTerm as TrilinearGridTerm_cython
          return [TrilinearGridTerm_cython(universe, \
            self.grid_data['spacing'], self.grid_data['counts'], \
            self.grid_data['vals'], self.params['strength'], \
            scaling_factor, \
            self.params['name'])]
    elif self.params['interpolation_type']=='BSpline':
      if self.params['inv_power'] is not None:
        from MMTK_BSpline_transform_grid import BSplineTransformGridTerm
        return [BSplineTransformGridTerm(universe, \
          self.grid_data['spacing'], self.grid_data['counts'], \
          self.grid_data['vals'], self.params['strength'], scaling_factor, \
          self.params['name'], self.params['inv_power'])]
      else:
        from MMTK_BSpline_grid import BSplineGridTerm
        return [BSplineGridTerm(universe, \
          self.grid_data['spacing'], self.grid_data['counts'], \
          self.grid_data['vals'], self.params['strength'], scaling_factor, \
          self.params['name'])]
    elif self.params['interpolation_type']=='CatmullRom':
      if self.params['inv_power'] is not None:
        from MMTK_CatmullRom_transform_grid import CatmullRomTransformGridTerm
        return [CatmullRomTransformGridTerm(universe, \
          self.grid_data['spacing'], self.grid_data['counts'], \
          self.grid_data['vals'], self.params['strength'], scaling_factor, \
          self.params['name'], self.params['inv_power'])]
      else:
        from MMTK_CatmullRom_grid import CatmullRomGridTerm
        return [CatmullRomGridTerm(universe, \
          self.grid_data['spacing'], self.grid_data['counts'], \
          self.grid_data['vals'], self.params['strength'], scaling_factor, \
          self.params['name'])]
    elif self.params['interpolation_type']=='Tricubic':
      if self.params['inv_power'] is not None:
        from MMTK_Tricubic_transform_grid import TricubicTransformGridTerm
        return [TricubicTransformGridTerm(universe, \
          self.grid_data['spacing'], self.grid_data['counts'], \
          self.grid_data['vals'], self.params['strength'], scaling_factor, \
          self.params['name'], self.params['inv_power'])]
      else:
        from MMTK_Tricubic_grid import TricubicGridTerm
        return [TricubicGridTerm(universe, \
          self.grid_data['spacing'], self.grid_data['counts'], \
          self.grid_data['vals'], self.params['strength'], scaling_factor, \
          self.params['name'])]
    print self.params['interpolation_type'] + ' interpolation is unknown'
    raise NotImplementedError