Exemplo n.º 1
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);
   }
Exemplo n.º 2
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]));
   }
Exemplo n.º 3
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);
   }
Exemplo n.º 4
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

   }