本文整理汇总了C++中CState::andersen方法的典型用法代码示例。如果您正苦于以下问题:C++ CState::andersen方法的具体用法?C++ CState::andersen怎么用?C++ CState::andersen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CState
的用法示例。
在下文中一共展示了CState::andersen方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runApplication
void MainApplication::runApplication(int argc, char *argv[])
{
double dt, T, Tbath, tau, L;
int nSteps, thermostat, N, calculateStatistics, saveStates;
if (argc != 11)
{
cout << endl << "! Usage: 'dt nSteps T(MD) thermostat#(0,1,2) Tbath(MD) tau L(SI) N calculateStatistics saveStates'" << endl;
if (argc == 1)
{
dt = 0.005;
nSteps = 200;
T = 1.7; // to get 0.851
thermostat = 1;
Tbath = 0.851;
tau = 15;
L = 5.720;
N = 20;
calculateStatistics = 1;
saveStates = 0;
cout << endl << "! Using default of: dt = " << dt << ", nSteps = " << nSteps << ", T = " << T
<< ", thermostat# = " << thermostat << ", Tbath = " << Tbath
<< ", tau = " << tau << ", L = " << L
<< ", N = " << N << ", statistics? = " << calculateStatistics
<< ", save states? = " << saveStates << endl << endl;
} else
exit(1);
}
else if (argc == 11)
{
dt = atof(argv[1]);
nSteps = atoi(argv[2]);
T = atof(argv[3]);
thermostat = atoi(argv[4]);
Tbath = atof(argv[5]);
tau = atof(argv[6]);
L = atof(argv[7]);
N = atoi(argv[8]);
calculateStatistics = atoi(argv[9]);
saveStates = atoi(argv[10]);
}
double tt = 1.0/10;
long seed = -1;
cout << "dt : " << dt << endl;
cout << "Tbath : " << Tbath << endl;
CState state;
state = initialize(T, L, N, &seed);
CStatisticsSampler sampler(state);
sampler.initialize_pairCorrelation(200, 1);
ostringstream filename;
// state.load("./output/states/state.1000.xyz");
for (int i = 0; i < nSteps; i++)
{
if (i%50==0) cout << "n = " << i << " of " << nSteps << endl;
filename.str(string());
filename << "./output/states/state." << setfill('0') << setw(4) << i << ".xyz";
if (saveStates) state.save(filename.str(), 1, 1);
if (calculateStatistics) sampler.sample(state, 1, dt*i);
// if (i>250) sampler.pairCorrelation();
if (thermostat == 1 && calculateStatistics) state.berendsen(Tbath, sampler.T, tt);
else if (thermostat == 2) state.andersen(Tbath, tt, &seed);
state.move(dt, calculateStatistics);
}
sampler.sample(state, 1, nSteps*dt);
// filename.str(string());
// filename << "./output/states/state." << setfill('0') << setw(4) << nSteps << ".xyz";
// state.save(filename.str(), 0, 0);
// sampler.pairCorrelation_manual("./output/pairCorrelation_final.dat", 1, 200);
}