Ejemplo n.º 1
0
void DCFreeHedron::SetBondLengthOld(TrialMol& oldMol)
{
  for(uint i = 0; i < hed.NumBond(); ++i) {
    bondLengthOld[i] = sqrt(oldMol.OldDistSq(hed.Focus(), hed.Bonded(i)));
  }
  anchorBondOld = sqrt(oldMol.OldDistSq(hed.Focus(), hed.Prev()));
}
Ejemplo n.º 2
0
//Calculate OldMol Bond Energy &
//Calculate phi weight for nTrials using actual theta of OldMol
void DCHedron::ConstrainedAnglesOld(uint nTrials, TrialMol& oldMol,
                                    uint molIndex)
{
  IncorporateOld(oldMol, molIndex);

  for (uint b = 1; b < nBonds; ++b) {
    double stepWeight = 0.0;
    //pick "twist" angles
    for (uint i = 0; i < nTrials; ++i) {
      double angles  = data->prng.rand(M_PI * 2);
      double energies = 0.0;
      double nonbondedEng = 0.0;
      //compare to angles determined in previous iterations
      for (uint c = 0; c < b; ++c) {
        if(!data->ff.angles->AngleFixed(angleKinds[b][c])) {
          double cosTerm = cos(theta[b]) * cos(theta[c]);
          double sinTerm = sin(theta[b]) * sin(theta[c]);
          double bfcTheta = acos(sinTerm * cos(angles - phi[c])
                                 + cosTerm);
          double distSq = oldMol.AngleDist(bondLengthOld[b],
                                           bondLengthOld[c], bfcTheta);
          nonbondedEng += data->calc.IntraEnergy_1_3(distSq, bonded[b],
                          bonded[c], molIndex);

          energies += data->ff.angles->Calc(angleKinds[b][c], bfcTheta);
        } else {
          double cosTerm = cos(theta[b]) * cos(theta[c]);
          double sinTerm = sin(theta[b]) * sin(theta[c]);
          double bfcTheta = data->ff.angles->Angle(angleKinds[b][c]);
          angles = acos((cos(bfcTheta) - cosTerm) / sinTerm) + phi[c];
          double distSq = oldMol.AngleDist(bondLengthOld[b],
                                           bondLengthOld[c], bfcTheta);
          nonbondedEng += data->calc.IntraEnergy_1_3(distSq, bonded[b],
                          bonded[c], molIndex);

          energies += data->ff.angles->Calc(angleKinds[b][c],
                                            bfcTheta);
	  
	  if(abs(angles) > 2.0 * M_PI) {
	    std::cout << "Error: Cannot constrain fix angle for " <<
	      oldMol.GetKind().atomTypeNames[bonded[b]] << " " <<
	      oldMol.GetKind().atomTypeNames[focus] << " " <<
	      oldMol.GetKind().atomTypeNames[bonded[c]] << " !\n";
	    exit(EXIT_FAILURE);
	  }
        }
      }

      //calculate weights from combined energy
      double weights = exp(-1 * data->ff.beta * (energies + nonbondedEng));
      stepWeight += weights;
    }
    phiWeight[b] += stepWeight;
  }
}
Ejemplo n.º 3
0
   void DCHedron::IncorporateOld(TrialMol& oldMol)
   {
      bendEnergy = 0;
      const Forcefield& ff = data->ff;
      for (uint b = 0; b < nBonds; ++b)
      {
	 
         oldMol.OldThetaAndPhi(bonded[b], focus, theta[b], phi[b]);
         double thetaEnergy = ff.angles->Calc(angleKinds[b][b], theta[b]);
         thetaWeight[b] += exp(-ff.beta * thetaEnergy);
         bendEnergy += thetaEnergy;
	 
	 if (b!=0)
	 {
	    double phiEnergy = 0;
	    phiWeight[b] = 0;
	    for (uint c = 0; c < b; ++c)
	    {
	       double cosTerm = cos(theta[b]) * cos(theta[c]);
	       double sinTerm = sin(theta[b]) * sin(theta[c]);
	       double bfcTheta = acos(sinTerm * cos(phi[b] - phi[c]) + 
				      cosTerm);
	       phiEnergy += ff.angles->Calc(angleKinds[b][c], bfcTheta);
	    }
	    phiWeight[b] = exp(-ff.beta * phiEnergy);
	    bendEnergy += phiEnergy;
	 }
      }
   }
Ejemplo n.º 4
0
 void DCLinkNoDih::IncorporateOld(TrialMol& oldMol)
 {
    double dummy;
    oldMol.OldThetaAndPhi(atom, focus, theta, dummy);
    const Forcefield& ff = data->ff;
    bendEnergy = ff.angles->Calc(angleKind, theta);
    bendWeight += exp(-ff.beta * bendEnergy);
 }
Ejemplo n.º 5
0
   void DCLinkNoDih::BuildNew(TrialMol& newMol, uint molIndex)
   {
      AlignBasis(newMol);
      double* ljWeights = data->ljWeights;
      double* inter = data->inter;
	  double *real = data->real;
	  double *self = data->self;
	  double* corr = data->correction;
      uint nLJTrials = data->nLJTrialsNth;
      XYZArray& positions = data->positions;
      PRNG& prng = data->prng;

      for (uint trial = 0, count = nLJTrials; trial < count; ++trial)
      {
         double phi = prng.rand(M_PI * 2);
         positions.Set(trial, newMol.GetRectCoords(bondLength, theta, phi));

      }

      data->axes.WrapPBC(positions, newMol.GetBox());
      std::fill_n(inter, nLJTrials, 0.0);
	  std::fill_n(self, nLJTrials, 0.0);
	  std::fill_n(real, nLJTrials, 0.0);
	  std::fill_n(corr, nLJTrials, 0.0);
	  std::fill_n(ljWeights, nLJTrials, 0.0);

      data->calc.ParticleInter(inter, real, positions, atom, molIndex,
                               newMol.GetBox(), nLJTrials);
	  if(DoEwald){
		data->calc.SwapSelf(self, molIndex, atom, newMol.GetBox(), nLJTrials);
		data->calc.SwapCorrection(corr, newMol, positions, atom, newMol.GetBox(), nLJTrials);
	  }

      double stepWeight = 0.0;
      for (uint trial = 0; trial < nLJTrials; trial++)
      {
         ljWeights[trial] = exp(-1 * data->ff.beta * (inter[trial] + real[trial] + self[trial] + corr[trial]));
	 if(ljWeights[trial] < 10e-200)
	   ljWeights[trial] = 0.0;
         stepWeight += ljWeights[trial];
      }

      uint winner = prng.PickWeighted(ljWeights, nLJTrials, stepWeight);
      double WinEnergy = inter[winner]+real[winner]+self[winner]+corr[winner];
      if ( ( WinEnergy * data->ff.beta ) > (2.3*200.0) || WinEnergy * data->ff.beta < -2.303e308){
      	stepWeight = 0.0;
      	inter[winner] = 0.0;
      	real[winner] = 0.0;
      	self[winner] = 0.0;
      	corr[winner] = 0.0;
      }
      newMol.MultWeight(stepWeight * bendWeight);
      newMol.AddAtom(atom, positions[winner]);
      newMol.AddEnergy(Energy(bendEnergy, 0.0, inter[winner], real[winner], 0.0, self[winner], corr[winner]));
   }
Ejemplo n.º 6
0
void DCHedron::IncorporateOld(TrialMol& oldMol, uint molIndex)
{
  bendEnergy = 0.0;
  oneThree = 0.0;
  const Forcefield& ff = data->ff;
  for (uint b = 0; b < nBonds; ++b) {

    oldMol.OldThetaAndPhi(bonded[b], focus, theta[b], phi[b]);
    double thetaEnergy = data->ff.angles->Calc(angleKinds[b][b], theta[b]);
    double distSq = oldMol.OldDistSq(prev, bonded[b]);
    double nonbondedEn =
      data->calc.IntraEnergy_1_3(distSq, prev, bonded[b], molIndex);

    thetaWeight[b] += exp(-1 * data->ff.beta * (thetaEnergy + nonbondedEn));
    bendEnergy += thetaEnergy;
    oneThree += nonbondedEn;

    if (b != 0) {
      double phiEnergy = 0.0;
      nonbondedEn = 0.0;
      phiWeight[b] = 0.0;
      for (uint c = 0; c < b; ++c) {
        double cosTerm = cos(theta[b]) * cos(theta[c]);
        double sinTerm = sin(theta[b]) * sin(theta[c]);
        double bfcTheta = acos(sinTerm * cos(phi[b] - phi[c]) +
                               cosTerm);

        double distSq = oldMol.OldDistSq(bonded[c], bonded[b]);
        nonbondedEn +=  data->calc.IntraEnergy_1_3(distSq, bonded[c],
                        bonded[b], molIndex);

        phiEnergy += ff.angles->Calc(angleKinds[b][c], bfcTheta);

      }
      phiWeight[b] = exp(-ff.beta * (phiEnergy + nonbondedEn));
      bendEnergy += phiEnergy;
      oneThree += nonbondedEn;
    }
  }
}
Ejemplo n.º 7
0
   void DCLinkNoDih::BuildOld(TrialMol& oldMol, uint molIndex)
   {
      AlignBasis(oldMol);
      IncorporateOld(oldMol);
      double* inter = data->inter;
	  double* real = data->real;
	  double *self = data->self;
	  double* corr = data->correction;
      uint nLJTrials = data->nLJTrialsNth;
      XYZArray& positions = data->positions;
      PRNG& prng = data->prng;
      positions.Set(0, oldMol.AtomPosition(atom));
      for (uint trial = 1, count = nLJTrials; trial < count; ++trial)
      {
         double phi = prng.rand(M_PI * 2);
         positions.Set(trial, oldMol.GetRectCoords(bondLength, theta, phi));
      }

      data->axes.WrapPBC(positions, oldMol.GetBox());
      std::fill_n(inter, nLJTrials, 0.0);
	  std::fill_n(self, nLJTrials, 0.0);
	  std::fill_n(real, nLJTrials, 0.0);
	  std::fill_n(corr, nLJTrials, 0.0);
      data->calc.ParticleInter(inter, real, positions, atom, molIndex,
                               oldMol.GetBox(), nLJTrials);
	  if(DoEwald){
		data->calc.SwapSelf(self, molIndex, atom, oldMol.GetBox(), nLJTrials);
		data->calc.SwapCorrection(corr, oldMol, positions, atom, oldMol.GetBox(), nLJTrials);
	  }

      double stepWeight = 0.0;
      for (uint trial = 0; trial < nLJTrials; ++trial)
      {
         stepWeight += exp(-1 * data->ff.beta * (inter[trial] + real[trial] + self[trial] + corr[trial]) );
	 if(stepWeight < 10e-200)
	   stepWeight = 0.0;
      }
      oldMol.MultWeight(stepWeight * bendWeight);
      oldMol.ConfirmOldAtom(atom);
      oldMol.AddEnergy(Energy(bendEnergy, 0.0, inter[0], real[0], 0.0, self[0], corr[0]));
   }
Ejemplo n.º 8
0
void DCHedron::GenerateAnglesOld(TrialMol& oldMol, uint molIndex,
                                 uint kind, uint nTrials, uint bType)
{
  double* nonbonded_1_3 =  data->nonbonded_1_3;
  int i;
  double distSq, thetaFix;
  bool angleFix = false;
  std::fill_n(nonbonded_1_3, nTrials, 0.0);

  if(data->ff.angles->AngleFixed(kind)) {
    angleFix = true;
    thetaFix = data->ff.angles->Angle(kind);
  }

  for (i = 0; i < nTrials; ++i) {
    if(angleFix)
      data->angles[i] = thetaFix;
    else
      data->angles[i] = data->prng.rand(M_PI);
  }

#ifdef _OPENMP
  #pragma omp parallel for default(shared) private(i, distSq)
#endif
  for (i = 0; i < nTrials; ++i) {
    data->angleEnergy[i] = data->ff.angles->Calc(kind, data->angles[i]);

    distSq = oldMol.AngleDist(anchorBondOld, bondLengthOld[bType],
                              data->angles[i]);
    nonbonded_1_3[i] =
      data->calc.IntraEnergy_1_3(distSq, prev, bonded[bType], molIndex);

    data->angleWeights[i] = exp((data->angleEnergy[i] + nonbonded_1_3[i])
                                * -data->ff.beta);
  }
}
Ejemplo n.º 9
0
   void DCFreeHedron::BuildNew(TrialMol& newMol, uint molIndex)
   {
      seed.BuildNew(newMol, molIndex);
      PRNG& prng = data->prng;
      const CalculateEnergy& calc = data->calc;
      const Forcefield& ff = data->ff;
      uint nLJTrials = data->nLJTrialsNth;
      double* ljWeights = data->ljWeights;
      double* inter = data->inter;
	  double* real = data->real;
	  double* self = data->self;
	  double* corr = data->correction;

      //get info about existing geometry
      newMol.ShiftBasis(hed.Focus());
      const XYZ center = newMol.AtomPosition(hed.Focus());
      XYZArray* positions = data->multiPositions;
      for (uint i = 0; i < hed.NumBond(); ++i)
      {
         positions[i].Set(0, newMol.RawRectCoords(hed.BondLength(i),
                                                  hed.Theta(i), hed.Phi(i)));
      }
      //add anchor atom
      positions[hed.NumBond()].Set(0, newMol.RawRectCoords(anchorBond, 0, 0));

      //counting backward to preserve prototype
      for (uint lj = nLJTrials; lj-- > 0;)
      {
         //convert chosen torsion to 3D positions
         RotationMatrix spin =
            RotationMatrix::UniformRandom(prng(), prng(), prng());
         for (uint b = 0; b < hed.NumBond() + 1; ++b)
         {
               //find positions
               positions[b].Set(lj, spin.Apply(positions[b][0]));
               positions[b].Add(lj, center);
         }
      }

      for (uint b = 0; b < hed.NumBond() + 1; ++b)
      {
         data->axes.WrapPBC(positions[b], newMol.GetBox());
      }

      std::fill_n(inter, nLJTrials, 0.0);
      std::fill_n(real, nLJTrials, 0.0);
      std::fill_n(self, nLJTrials, 0.0);
	  std::fill_n(corr, nLJTrials, 0.0);
      for (uint b = 0; b < hed.NumBond(); ++b)
      {
	 calc.ParticleInter(inter, real, positions[b], hed.Bonded(b), 
			    molIndex, newMol.GetBox(), nLJTrials);
	 if(DoEwald){
		data->calc.SwapSelf(self, molIndex, hed.Bonded(b), newMol.GetBox(), nLJTrials);
		data->calc.SwapCorrection(corr, newMol, positions[b], hed.Bonded(b), newMol.GetBox(), nLJTrials);
	 }
      }
      calc.ParticleInter(inter, real, positions[hed.NumBond()], hed.Prev(),
                         molIndex, newMol.GetBox(), nLJTrials);
	  if(DoEwald){
		  data->calc.SwapSelf(self, molIndex, hed.Prev(), newMol.GetBox(), nLJTrials);
		  data->calc.SwapCorrection(corr, newMol, positions[hed.NumBond()], hed.Prev(), newMol.GetBox(), nLJTrials);
	  }
      double stepWeight = 0;
      for (uint lj = 0; lj < nLJTrials; ++lj)
      {
         ljWeights[lj] = exp(-ff.beta * inter[lj]);
         stepWeight += ljWeights[lj];
      }
      uint winner = prng.PickWeighted(ljWeights, nLJTrials, stepWeight);
      for(uint b = 0; b < hed.NumBond(); ++b)
      {
         newMol.AddAtom(hed.Bonded(b), positions[b][winner]);
      }
      newMol.AddAtom(hed.Prev(), positions[hed.NumBond()][winner]);
      newMol.AddEnergy(Energy(hed.GetEnergy(), 0, inter[winner], real[winner], 0, self[winner], corr[winner]));
      newMol.MultWeight(hed.GetWeight());
      newMol.MultWeight(stepWeight);
   }
Ejemplo n.º 10
0
   void DCFreeHedron::BuildOld(TrialMol& oldMol, uint molIndex)
   {
      seed.BuildOld(oldMol, molIndex);
      PRNG& prng = data->prng;
      const CalculateEnergy& calc = data->calc;
      const Forcefield& ff = data->ff;
      uint nLJTrials = data->nLJTrialsNth;
      double* ljWeights = data->ljWeights;
      double* inter = data->inter;
	  double* real = data->real;
	  double* self = data->self;
	  double* corr = data->correction;

      //get info about existing geometry
      oldMol.SetBasis(hed.Focus(), hed.Prev());
      //Calculate OldMol Bond Energy &
      //Calculate phi weight for nTrials using actual theta of OldMol
      hed.ConstrainedAnglesOld(data->nAngleTrials - 1, oldMol);
      const XYZ center = oldMol.AtomPosition(hed.Focus());
      XYZArray* positions = data->multiPositions;
      double prevPhi[MAX_BONDS];
      for (uint i = 0; i < hed.NumBond(); ++i)
      {
         //get position and shift to origin
         positions[i].Set(0, oldMol.AtomPosition(hed.Bonded(i)));
         data->axes.UnwrapPBC(positions[i], 0, 1, oldMol.GetBox(), center);
         positions[i].Add(0, -center);
      }
      //add anchor atom
      positions[hed.NumBond()].Set(0, oldMol.AtomPosition(hed.Prev()));
      data->axes.UnwrapPBC(positions[hed.NumBond()], 0, 1,
			   oldMol.GetBox(), center);
      positions[hed.NumBond()].Add(0, -center);

      //counting backward to preserve prototype
      for (uint lj = nLJTrials; lj-- > 1;)
      {
         //convert chosen torsion to 3D positions
         RotationMatrix spin =
            RotationMatrix::UniformRandom(prng(), prng(), prng());
         for (uint b = 0; b < hed.NumBond() + 1; ++b)
         {
            //find positions
            positions[b].Set(lj, spin.Apply(positions[b][0]));
            positions[b].Add(lj, center);
         }
      }

      for (uint b = 0; b < hed.NumBond() + 1; ++b)
      {
         positions[b].Add(0, center);
         data->axes.WrapPBC(positions[b], oldMol.GetBox());
      }

      std::fill_n(inter, nLJTrials, 0.0);
      std::fill_n(real, nLJTrials, 0.0);
      std::fill_n(self, nLJTrials, 0.0);
	  std::fill_n(corr, nLJTrials, 0.0);
      for (uint b = 0; b < hed.NumBond(); ++b)
      {
         calc.ParticleInter(inter, real, positions[b], hed.Bonded(b),
                            molIndex, oldMol.GetBox(), nLJTrials);
		 if(DoEwald){
			 data->calc.SwapSelf(self, molIndex, hed.Bonded(b), oldMol.GetBox(), nLJTrials);
			data->calc.SwapCorrection(corr, oldMol, positions[b], hed.Bonded(b), oldMol.GetBox(), nLJTrials);
		 }
      }
      double stepWeight = 0;
      calc.ParticleInter(inter, real, positions[hed.NumBond()], hed.Prev(),
                         molIndex, oldMol.GetBox(), nLJTrials);
	  if(DoEwald){
		  data->calc.SwapSelf(self, molIndex, hed.Prev(), oldMol.GetBox(), nLJTrials);
		  data->calc.SwapCorrection(corr, oldMol, positions[hed.NumBond()], hed.Prev(), oldMol.GetBox(), nLJTrials);
	  }

      for (uint lj = 0; lj < nLJTrials; ++lj)
      {
         stepWeight += exp(-ff.beta * inter[lj]);
      }
      for(uint b = 0; b < hed.NumBond(); ++b)
      {
         oldMol.ConfirmOldAtom(hed.Bonded(b));
      }
      oldMol.ConfirmOldAtom(hed.Prev());
      oldMol.AddEnergy(Energy(hed.GetEnergy(), 0, inter[0], real[0], 0, self[0], corr[0]));
      oldMol.MultWeight(hed.GetWeight());
      oldMol.MultWeight(stepWeight);
   }
Ejemplo n.º 11
0
void DCHedron::ConstrainedAngles(TrialMol& newMol, uint molIndex, uint nTrials)
{
  double* angles = data->angles;
  double* energies = data->angleEnergy;
  double* weights = data->angleWeights;
  double* nonbonded_1_3 =  data->nonbonded_1_3;
  std::fill_n(nonbonded_1_3, nTrials, 0.0);
  phi[0] = 0.0;

  for (uint b = 1; b < nBonds; ++b) {
    //pick "twist" angles
    for (uint i = 0; i < nTrials; ++i) {
      angles[i] = data->prng.rand(M_PI * 2);
      energies[i] = 0.0;
      nonbonded_1_3[i] = 0.0;
    }

    //compare to angles determined in previous iterations
    for (uint c = 0; c < b; ++c) {
      double cosTerm = cos(theta[b]) * cos(theta[c]);
      double sinTerm = sin(theta[b]) * sin(theta[c]);

      for (uint i = 0; i < nTrials; ++i) {
        if(!data->ff.angles->AngleFixed(angleKinds[b][c])) {
          double bfcTheta = acos(sinTerm * cos(angles[i] - phi[c]) +
                                 cosTerm);
          double distSq = newMol.AngleDist(bondLength[b], bondLength[c],
                                           bfcTheta);
          double tempEn = data->calc.IntraEnergy_1_3(distSq, bonded[b],
                          bonded[c],
                          molIndex);

          nonbonded_1_3[i] += tempEn;
          energies[i] += data->ff.angles->Calc(angleKinds[b][c],
                                               bfcTheta);
        } else {
          double bfcTheta = data->ff.angles->Angle(angleKinds[b][c]);
          angles[i] = acos((cos(bfcTheta) - cosTerm) / sinTerm) + phi[c];
          double distSq = newMol.AngleDist(bondLength[b], bondLength[c],
                                           bfcTheta);
          double tempEn = data->calc.IntraEnergy_1_3(distSq, bonded[b],
                          bonded[c],
                          molIndex);

          nonbonded_1_3[i] += tempEn;
          energies[i] += data->ff.angles->Calc(angleKinds[b][c],
                                               bfcTheta);

	  if(abs(angles[i]) > 2.0 * M_PI) {
	    std::cout << "Error: Cannot constrain fix angle for " <<
	      newMol.GetKind().atomTypeNames[bonded[b]] << " " <<
	      newMol.GetKind().atomTypeNames[focus] << " " <<
	      newMol.GetKind().atomTypeNames[bonded[c]] << " !\n";
	    exit(EXIT_FAILURE);
	  }
        }
      }
    }

    //calculate weights from combined energy
    double stepWeight = 0.0;
    int i;
#ifdef _OPENMP
    #pragma omp parallel for default(shared) private(i) reduction(+:stepWeight)
#endif
    for (i = 0; i < nTrials; ++i) {
      weights[i] = exp(-1 * data->ff.beta * (energies[i] +
                                             nonbonded_1_3[i]));
      stepWeight += weights[i];
    }

    uint winner = data->prng.PickWeighted(weights, nTrials, stepWeight);
    phi[b] = angles[winner];
    bendEnergy += energies[winner];
    oneThree += nonbonded_1_3[winner];
    phiWeight[b] = stepWeight;
  }
}
Ejemplo n.º 12
0
 void DCLinkNoDih::AlignBasis(TrialMol& mol)
 {
    mol.SetBasis(focus, prev);
 }
Ejemplo n.º 13
0
   void DCLinkNoDih::BuildNew(TrialMol& newMol, uint molIndex)
   {//printf("DC Linked No dihhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh\n");

	//  printf("DCLinkNoDeh new\n");

      AlignBasis(newMol);
      double* ljWeights = data->ljWeights;
	   double* nonbonded_1_4 = data->nonbonded_1_4;// v1

      double* inter = data->inter;
      uint nLJTrials = data->nLJTrialsNth;
      XYZArray& positions = data->positions;
      PRNG& prng = data->prng;

      for (uint trial = 0, count = nLJTrials; trial < count; ++trial)
      {
         double phi = prng.rand(M_PI * 2);
         positions.Set(trial, newMol.GetRectCoords(bondLength, theta, phi));
      }

      data->axes.WrapPBC(positions, newMol.GetBox());
      std::fill_n(inter, nLJTrials, 0);
	   std::fill_n(nonbonded_1_4, nLJTrials, 0);// v1


     // data->calc.ParticleInter(inter, positions, atom, molIndex,                         newMol.GetBox(), nLJTrials);
      
	 // data->calc.GetParticleEnergyGPU(newMol.GetBox(),  inter,positions, newMol.molLength, newMol.mOff, atom,newMol.molKindIndex);
	    data->calc.GetParticleEnergy(newMol.GetBox(),  inter,positions, newMol.molLength, newMol.mOff, atom,newMol.molKindIndex,nLJTrials);
	 /*   for (int trial = 0; trial < data->nLJTrials; ++trial)
	   {
	   printf("serial Trial %d energy=%f\n",trial,inter[trial] );
	   
	   }



	   printf("\n\n");
	 

	  for (int trial = 0; trial < data->nLJTrials; ++trial)
	   {
	   printf("GPU Trial %d energy=%f\n",trial,inter[trial] );
	   
	   }


	  printf("===================\n\n");*/

		data->calc.ParticleNonbonded_1_4(nonbonded_1_4, newMol, positions, atom,
				   newMol.GetBox(), nLJTrials);// v1

      double stepWeight = 0;
      double beta = data->ff.beta;
      for (uint trial = 0, count = nLJTrials; trial < count; ++trial)
      {
       ljWeights[trial] = exp(-data->ff.beta * (inter[trial] +
						 nonbonded_1_4[trial]));// v1

         stepWeight += ljWeights[trial];
      }

      uint winner = prng.PickWeighted(ljWeights, nLJTrials, stepWeight);
      newMol.MultWeight(stepWeight * bendWeight);
      newMol.AddAtom(atom, positions[winner]);
       newMol.AddEnergy(Energy(bendEnergy, nonbonded_1_4[winner],
			      inter[winner]));// v1

   }
Ejemplo n.º 14
0
   void DCLinkNoDih::BuildOld(TrialMol& oldMol, uint molIndex)
   {//printf("DCLinkNoDeh old\n");
      AlignBasis(oldMol);
      IncorporateOld(oldMol);
	   double* nonbonded_1_4 = data->nonbonded_1_4;// v1
      double* inter = data->inter;
      uint nLJTrials = data->nLJTrialsNth;
      XYZArray& positions = data->positions;
      PRNG& prng = data->prng;
      positions.Set(0, oldMol.AtomPosition(atom));
      for (uint trial = 1, count = nLJTrials; trial < count; ++trial)
      {
         double phi = prng.rand(M_PI * 2);
         positions.Set(trial, oldMol.GetRectCoords(bondLength, theta, phi));
      }

      data->axes.WrapPBC(positions, oldMol.GetBox());
      std::fill_n(inter, nLJTrials, 0.0);
	   std::fill_n(nonbonded_1_4, nLJTrials, 0.0);//v1

      //data->calc.ParticleInter(inter, positions, atom, molIndex,                         oldMol.GetBox(), nLJTrials);

	   //data->calc.GetParticleEnergyGPU(oldMol.GetBox(),  inter,positions, oldMol.molLength, oldMol.mOff, atom,oldMol.molKindIndex);
	    data->calc.GetParticleEnergy(oldMol.GetBox(),  inter,positions, oldMol.molLength, oldMol.mOff, atom,oldMol.molKindIndex,nLJTrials);
	      //printf("DC Linked No dihhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh\n");
	  /* for (int trial = 0; trial < data->nLJTrials; ++trial)
	   {
	   printf("serial Trial %d energy=%f\n",trial,inter[trial] );
	   
	   }



	   printf("\n\n");
	  data->calc.GetParticleEnergyGPU(oldMol.GetBox(), data->nLJTrials, inter,positions, oldMol.molLength, oldMol.mOff, atom,oldMol.molKindIndex);

	  for (int trial = 0; trial < data->nLJTrials; ++trial)
	   {
	   printf("GPU Trial %d energy=%f\n",trial,inter[trial] );
	   
	   }


	  printf("===================\n\n");*/




		data->calc.ParticleNonbonded_1_4(nonbonded_1_4, oldMol, positions, atom,
				   oldMol.GetBox(), nLJTrials);// v1

	     double stepWeight = 0;
      for (uint trial = 0, count = nLJTrials; trial < count; ++trial)
      {
        stepWeight += exp(-data->ff.beta * (inter[trial] +
					    nonbonded_1_4[trial]));//v1
      }
      oldMol.MultWeight(stepWeight * bendWeight);
      oldMol.ConfirmOldAtom(atom);
      oldMol.AddEnergy(Energy(bendEnergy, nonbonded_1_4[0], inter[0]));//v1

   }
Ejemplo n.º 15
0
   void DCDiatomic::BuildNew(TrialMol& newMol, uint molIndex)
   {
      PRNG& prng = data->prng;
      XYZArray& positions = data->positions;
      double beta = data->ff.beta;
      uint nLJTrials = data->nLJTrialsNth;
      double* inter = data->inter;
      double* ljWeights = data->ljWeights;

      prng.FillWithRandom(positions, nLJTrials,
			  data->axes.GetAxis(newMol.GetBox()));
      data->axes.WrapPBC(positions, newMol.GetBox());
      data->calc.ParticleInter(first, positions, inter, molIndex,
			       newMol.GetBox(), nLJTrials);

      double stepWeight = 0;
      for (uint trial = 0; trial < nLJTrials; ++trial)
      {
         ljWeights[trial] = exp(-1 * beta * inter[trial]);
         stepWeight += ljWeights[trial];
      }
      uint winner = prng.PickWeighted(ljWeights, nLJTrials, stepWeight);
      newMol.MultWeight(stepWeight);
      newMol.AddEnergy(Energy(0, 0, inter[winner]));
      newMol.AddAtom(first, positions[winner]);

      prng.FillWithRandomOnSphere(positions, nLJTrials, bondLength,
				  newMol.AtomPosition(first));
      data->axes.WrapPBC(positions, newMol.GetBox());
      data->calc.ParticleInter(second, positions, inter, molIndex,
			       newMol.GetBox(), nLJTrials);

      stepWeight = 0;
      for (uint trial = 0; trial < nLJTrials; trial++)
      {
         ljWeights[trial] = exp(-1 * beta * inter[trial]);
         stepWeight += ljWeights[trial];
      }
      winner = prng.PickWeighted(ljWeights, nLJTrials, stepWeight);
      newMol.MultWeight(stepWeight);
      newMol.AddEnergy(Energy(0, 0, inter[winner]));
      newMol.AddAtom(second, positions[winner]);
   }
Ejemplo n.º 16
0
   void DCDiatomic::BuildOld(TrialMol& oldMol, uint molIndex)
   {
      PRNG& prng = data->prng;
      XYZArray& positions = data->positions;
      uint nLJTrials = data->nLJTrialsNth;
      double beta = data->ff.beta;

      prng.FillWithRandom(data->positions, nLJTrials,
			  data->axes.GetAxis(oldMol.GetBox()));
      positions.Set(0, oldMol.AtomPosition(first));

      double* inter = data->inter;
      double stepWeight = 0;
      data->axes.WrapPBC(positions, oldMol.GetBox());
      data->calc.ParticleInter(first, positions, inter, molIndex,
			       oldMol.GetBox(), nLJTrials);
      for (uint trial = 0; trial < nLJTrials; ++trial)
      {
         stepWeight += exp(-1 * beta * inter[trial]);
      }
      oldMol.MultWeight(stepWeight);
      oldMol.AddEnergy(Energy(0, 0, inter[0]));
      oldMol.ConfirmOldAtom(first);

      prng.FillWithRandomOnSphere(positions, nLJTrials, bondLength,
				  oldMol.AtomPosition(first));
      positions.Set(0, oldMol.AtomPosition(second));

      stepWeight = 0;
      data->axes.WrapPBC(positions, oldMol.GetBox());
      data->calc.ParticleInter(second, positions, inter, molIndex,
			       oldMol.GetBox(), nLJTrials);
      for (uint trial = 0; trial < nLJTrials; trial++)
      {
         stepWeight += exp(-1 * beta * inter[trial]);
      }
      oldMol.MultWeight(stepWeight);
      oldMol.AddEnergy(Energy(0, 0, inter[0]));
      oldMol.ConfirmOldAtom(second);
   }