本文整理汇总了C++中path::get_lam方法的典型用法代码示例。如果您正苦于以下问题:C++ path::get_lam方法的具体用法?C++ path::get_lam怎么用?C++ path::get_lam使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类path
的用法示例。
在下文中一共展示了path::get_lam方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: StagingMove
// There is bug inside stagingMove
bool pimc::StagingMove(path p, int ptcl)
{
//srand((unsigned)time(NULL));
// the length of the stage
int m = 16;
int NumTime=p.get_NumTime();
double tau=p.get_tau();
double lam=p.get_lam();
double oldbeads[m-1];
// Choose the start and end of the stage
int alpha_start = (int) NumTime*((double) rand() / (RAND_MAX)) ; //np.random.randint(0,Path.numTimeSlices)
//cout<< alpha_start<< endl;
//int alpha_start = 15;
int alpha_end = (alpha_start + m) % NumTime;
// Record the positions of the beads to be updated and store the action
for(int a=0; a<m-1; a++)
oldbeads[a] = 0;
double oldAction = 0.0;
for (int a=1; a<m; a++)
{
int slice = (alpha_start + a) % NumTime;
oldbeads[a-1] = p.beads[slice][ptcl];
oldAction += p.PotentialAction(slice);
}
// Generate new positions and accumulate the new action
double newAction = 0.0;
for (int a=1; a<m; a++)
{
int slicem1;
int slice = (alpha_start + a) % NumTime;
if( (slice-1) > 0 )
slicem1 = (slice - 1) % NumTime;
else if( (slice-1)==0)
slicem1 = 0;
else
slicem1 = ((slice - 1) % NumTime) + NumTime;
//cout << slicem1 <<endl;
double tau1 = (m-a)*tau;
//cout <<ptcl <<" " << slicem1 << " "<< slice <<endl;
double avex = (tau1*p.beads[slicem1][ptcl] + tau*p.beads[alpha_end][ptcl]) / (tau + tau1);
double sigma2 = 2.0*lam / ((1.0 / tau) + (1.0 / tau1));
p.beads[slice][ptcl] = avex + sqrt(sigma2)*((double) rand() / (RAND_MAX));
newAction += p.PotentialAction(slice);
}
// Perform the Metropolis step, if we rejct, revert the worldline
if( ((double) rand() / (RAND_MAX)) < exp(-(newAction - oldAction)) )
return true;
else
for(int a=1; a<m; a++)
{
int slice = (alpha_start + a) % NumTime;
p.beads[slice][ptcl] = oldbeads[a-1];
return false;
}
}