Beispiel #1
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]));
   }
Beispiel #2
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]);
   }
Beispiel #3
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]));
   }
Beispiel #4
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);
   }
Beispiel #5
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);
   }
Beispiel #6
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);
   }
Beispiel #7
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

   }
Beispiel #8
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

   }