当前位置: 首页>>代码示例>>C++>>正文


C++ Frame::CRD方法代码示例

本文整理汇总了C++中Frame::CRD方法的典型用法代码示例。如果您正苦于以下问题:C++ Frame::CRD方法的具体用法?C++ Frame::CRD怎么用?C++ Frame::CRD使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Frame的用法示例。


在下文中一共展示了Frame::CRD方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Calculate_LJ

double Action_LIE::Calculate_LJ(Frame const& frameIn, Topology const& parmIn) const {
  double result = 0;
  // Loop over ligand atoms
  AtomMask::const_iterator mask1_end = Mask1_.end();
  AtomMask::const_iterator mask2_end = Mask2_.end();
  for (AtomMask::const_iterator maskatom1 = Mask1_.begin();
       maskatom1 != mask1_end; maskatom1++) {

    int crdidx1 = (*maskatom1) * 3; // index into coordinate array
    Vec3 atm1 = Vec3(frameIn.CRD(crdidx1));

    for (AtomMask::const_iterator maskatom2 = Mask2_.begin();
         maskatom2 != mask2_end; maskatom2++) {

      int crdidx2 = (*maskatom2) * 3; // index into coordinate array
      Vec3 atm2 = Vec3(frameIn.CRD(crdidx2));
      
      double dist2;
      // Get imaged distance
      Matrix_3x3 ucell, recip;
      switch( ImageType() ) {
        case NONORTHO:
          frameIn.BoxCrd().ToRecip(ucell, recip);
          dist2 = DIST2_ImageNonOrtho(atm1, atm2, ucell, recip);
          break;
        case ORTHO:
          dist2 = DIST2_ImageOrtho(atm1, atm2, frameIn.BoxCrd());
          break;
        default:
          dist2 = DIST2_NoImage(atm1, atm2);
      }

      if (dist2 > cut2vdw_) continue;
      // Here we add to our nonbonded (VDW) energy
      NonbondType const& LJ = parmIn.GetLJparam(*maskatom1, *maskatom2);
      double r2 = 1 / dist2;
      double r6 = r2 * r2 * r2;
      result += LJ.A() * r6 * r6 - LJ.B() * r6;
    }
  }

  return result;
}
开发者ID:jcr13,项目名称:cpptraj,代码行数:43,代码来源:Action_LIE.cpp

示例2: Calculate_Elec

double Action_LIE::Calculate_Elec(Frame const& frameIn) const {
  double result = 0;
  // Loop over ligand atoms
  AtomMask::const_iterator mask1_end = Mask1_.end();
  AtomMask::const_iterator mask2_end = Mask2_.end();
  for (AtomMask::const_iterator maskatom1 = Mask1_.begin();
       maskatom1 != mask1_end; maskatom1++) {

    int crdidx1 = (*maskatom1) * 3; // index into coordinate array
    Vec3 atm1 = Vec3(frameIn.CRD(crdidx1));

    for (AtomMask::const_iterator maskatom2 = Mask2_.begin();
         maskatom2 != mask2_end; maskatom2++) {

      int crdidx2 = (*maskatom2) * 3; // index into coordinate array
      Vec3 atm2 = Vec3(frameIn.CRD(crdidx2));
      
      double dist2;
      // Get imaged distance
      Matrix_3x3 ucell, recip;
      switch( ImageType() ) {
        case NONORTHO:
          frameIn.BoxCrd().ToRecip(ucell, recip);
          dist2 = DIST2_ImageNonOrtho(atm1, atm2, ucell, recip);
          break;
        case ORTHO:
          dist2 = DIST2_ImageOrtho(atm1, atm2, frameIn.BoxCrd());
          break;
        default:
          dist2 = DIST2_NoImage(atm1, atm2);
      }

      if (dist2 > cut2elec_) continue;
      // Here we add to our electrostatic energy
      double qiqj = atom_charge_[*maskatom1] * atom_charge_[*maskatom2];
      double shift = (1 - dist2 * onecut2_);
      result += qiqj / sqrt(dist2) * shift * shift;
    }
  }

  return result;
}
开发者ID:jcr13,项目名称:cpptraj,代码行数:42,代码来源:Action_LIE.cpp

示例3: CalcCovarianceMatrix

/** Calc Covariance Matrix */
void Action_Matrix::CalcCovarianceMatrix(Frame const& currentFrame) {
# ifdef _OPENMP
#ifdef NEW_MATRIX_PARA /* New matrix parallelization */
  //int idx2, atomCrd2, offset2, midx, idx1, atomCrd1, offset1;
  int idx2, midx, idx1;
  double Mj;
  if (useMask2_) { // FULL MATRIX TODO
    return;
  } else { // HALF MATRIX
    DataSet_MatrixDbl& matrix = *Mat_;
    Darray& vect1 = Mat_->V1();
    //int Ncoords = mask1_.Nselected() * 3;
    int Ncoords = (int)crd_indices_.size();
//#   pragma omp parallel private(idx2, atomCrd2, offset2, midx, idx1, atomCrd1, offset1, Mj)
#   pragma omp parallel private(idx2, midx, idx1, Mj)
    {
#   pragma omp for schedule(dynamic)
    for (idx2 = 0; idx2 < Ncoords; idx2++)
    {
      //atomCrd2 = mask1_[idx2 / 3] * 3;
      //offset2 = idx2 % 3;
      //Mj = currentFrame[atomCrd2 + offset2];
      Mj = currentFrame[ crd_indices_[idx2] ];
      vect1[idx2] += Mj;
      vect2_[idx2] += (Mj * Mj);
      midx = (idx2 * (int)matrix.Ncols() - (idx2 * (idx2-1) / 2));
      for (idx1 = idx2; idx1 < Ncoords; idx1++, midx++)
      {
        //atomCrd1 = mask1_[idx1 / 3] * 3;
        //offset1 = idx1 % 3;
        //matrix[midx] += (currentFrame[atomCrd1 + offset1] * Mj);
        matrix[midx] += (currentFrame[ crd_indices_[idx1] ] * Mj);
      }
    } // END for loop
    } // END openmp pragma
  }
#else /* Original matrix parallelization */
  int m1_idx, m2_idx;
  double Vj;
  const double* XYZi;
  const double* XYZj;
  unsigned int ny;
  DataSet_MatrixDbl::iterator mat;
  v_iterator v1, v2;
  if (useMask2_) { // FULL MATRIX
    int NX = (int)Mat_->Ncols();
    int crd_max = (int)crd_indices_.size();
#   pragma omp parallel private(m1_idx, m2_idx, XYZi, XYZj, Vj, mat, v1, v2, ny)
    {
    #pragma omp for
    for (m2_idx = 0; m2_idx < mask2_.Nselected(); m2_idx++) {
      mat = Mat_->begin() + ((m2_idx*3)*NX);
      XYZj = currentFrame.XYZ( mask2_[m2_idx] );
      for (ny = 0; ny < 3; ny++) {
        Vj = XYZj[ny];
        for (m1_idx = 0; m1_idx < mask1_.Nselected(); m1_idx++) {
          XYZi = currentFrame.XYZ( mask1_[m1_idx] );
          *(mat++) += Vj * XYZi[0];
          *(mat++) += Vj * XYZi[1];
          *(mat++) += Vj * XYZi[2];
        }
      }
    }
    // Mask1/Mask2 diagonal
    #   pragma omp for
    for (m1_idx = 0; m1_idx < crd_max; m1_idx++) {
      v1 = Mat_->v1begin() + (m1_idx * 3); // Index into vect/vect2
      v2 = vect2_.begin()  + (m1_idx * 3);
      StoreVec(v1, v2, currentFrame.CRD( crd_indices_[m1_idx] ));
    }
    } // END PARALLEL BLOCK FULL
    return;
  } else {         // HALF MATRIX
    int v_idx;
    unsigned int nx;
    double d_m2_idx;
    double TwoN = (double)( Mat_->Ncols() * 2 );
#   pragma omp parallel private(m1_idx, m2_idx, d_m2_idx, v_idx, XYZi, XYZj, Vj, mat, v1, v2, ny, nx)
    {
    #pragma omp for schedule(dynamic)
    for (m2_idx = 0; m2_idx < mask1_.Nselected(); m2_idx++) {
      v_idx = m2_idx * 3;
      d_m2_idx = (double)v_idx;
      mat = Mat_->begin() + (int)(0.5*d_m2_idx*(TwoN-d_m2_idx-1.0)+d_m2_idx);
      v1 = Mat_->v1begin() + v_idx;
      v2 = vect2_.begin() + v_idx;
      XYZj = currentFrame.XYZ( mask1_[m2_idx] );
      StoreVec(v1, v2, XYZj);
      for (ny = 0; ny < 3; ny++) {
        Vj = XYZj[ny];
        // m1_idx = m2_idx, diagonal
        for (nx = ny; nx < 3; nx++)
          *(mat++) += Vj * XYZj[nx]; // Vj * i{0,1,2}, Vj * i{1,2}, Vj * i{2}
        for (m1_idx = m2_idx+1; m1_idx < mask1_.Nselected(); m1_idx++) {
          XYZi = currentFrame.XYZ( mask1_[m1_idx] );
          *(mat++) += Vj * XYZi[0];
          *(mat++) += Vj * XYZi[1];
          *(mat++) += Vj * XYZi[2];
        }
//.........这里部分代码省略.........
开发者ID:SAMAN-64,项目名称:cpptraj,代码行数:101,代码来源:Action_Matrix.cpp


注:本文中的Frame::CRD方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。