本文整理汇总了C++中CellList::rebuild方法的典型用法代码示例。如果您正苦于以下问题:C++ CellList::rebuild方法的具体用法?C++ CellList::rebuild怎么用?C++ CellList::rebuild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CellList
的用法示例。
在下文中一共展示了CellList::rebuild方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
fflush (stdout);
}
coms.clear ();
waters.clear ();
int nmol = natoms / numb_mol_atom;
vector<double > read_com(3, 0.);
vector<vector<double > > read_water(3);
for (int ii = 0; ii < 3; ++ii) read_water[ii].resize(3, 0.);
for (int ii = 0; ii < nmol; ++ii){
for (int dd = 0; dd < 3; ++dd){
read_com[dd] = xx[ii*numb_mol_atom][dd];
if (read_com[dd] < 0 ) read_com[dd] += box[dd][dd];
else if (read_com[dd] >= box[dd][dd]) read_com[dd] -= box[dd][dd];
}
for (int jj = 0; jj < 3; ++jj){
for (int dd = 0; dd < 3; ++dd){
read_water[jj][dd] = xx[ii*numb_mol_atom + jj][dd];
}
}
for (int dd = 0; dd < 3; ++dd){
if (read_water[0][dd] < 0 ) read_water[0][dd] += box[dd][dd];
else if (read_water[0][dd] >= box[dd][dd]) read_water[0][dd] -= box[dd][dd];
}
align_water (box, read_water);
coms.push_back (read_com);
waters.push_back (read_water);
}
vbox.x = box[0][0];
vbox.y = box[1][1];
vbox.z = box[2][2];
clist.reinit (nmolecules, vbox, cellSize);
clist.rebuild (coms);
vector<double > vect_box(3);
for (int dd = 0; dd < 3; ++dd) vect_box[dd] = box[dd][dd];
vector<vector<int > > h_list;
hba.computeBondList (h_list, clist, vect_box, waters);
// for (unsigned ii = 0; ii < h_list.size(); ++ii){
// cout << ii << " \t " << h_list[ii].size() << " \t ";
// for (unsigned jj = 0; jj < h_list[ii].size(); ++jj){
// cout << h_list[ii][jj] << " " ;
// }
// cout << endl;
// }
RingAnalysis ra;
vector<vector<vector<int > > > r_list;
ra.compute (r_list, h_list, max_ring, func_numb_threads);
vector<vector<int > > ur_list;
ra.unique_list (ur_list, r_list);
rs.mol_deposite (r_list);
rs.sys_deposite (ur_list);
rs.print_frame (fout, time);
// for (unsigned jj = 0; jj < r_list[0].size(); ++jj){
// cout << "ring " << jj << " " ;
// for (unsigned kk = 0; kk < r_list[0][jj].size(); ++kk){
// cout << r_list[0][jj][kk] << " ";
// }
// cout << endl;
// }
// for (unsigned tt = 0; tt < r_list.size(); ++tt){
// cout << " atom " << tt << endl;
// for (unsigned jj = 0; jj < r_list[tt].size(); ++jj){
// cout << "ring " << jj << " " ;
// for (unsigned kk = 0; kk < r_list[tt][jj].size(); ++kk){
// cout << r_list[tt][jj][kk] << " ";
// }
// cout << endl;
// }
// // break;
// }
// for (unsigned tt = 0; tt < ur_list.size(); ++tt){
// cout << tt << " \t " ;
// for (unsigned kk = 0; kk < ur_list[tt].size(); ++kk){
// cout << ur_list[tt][kk] << " ";
// }
// cout << endl;
// }
if (p_def_ring){
print_step (odir, step, time, ur_list);
}
if (p_mol_dist){
print_mol_dist (odir, step, time, rs.get_frame_mol_dist());
}
}
printf ("\n");
free (xx);
xdrfile_close (fp);
return 0;
}
示例2: main
//.........这里部分代码省略.........
int countread = 0;
int realcountread = 0;
XtcLoader tjl (ifile.c_str());
if (rup * 2. > tjl.getBox()[0]) {
cerr << "to large rup, set to half box size" << endl;
rup = 0.5 * tjl.getBox()[0];
}
int nmols = tjl.getNAtoms()/3;
VectorType vbox;
vbox.x = tjl.getBox()[0];
vbox.y = tjl.getBox()[1];
vbox.z = tjl.getBox()[2];
CellList clist (nmols, vbox, cellSize);
KirkwoodFactor gkr;
gkr.reinit (rup, refh, nDataBlock);
std::vector<std::vector<ValueType > > coms;
coms.resize (nmols);
std::vector<std::vector<ValueType > > dipoles;
dipoles.resize (nmols);
while (true == tjl.load()){
countread ++;
if ((countread-1) % every != 0) continue;
float time = tjl.getTime();
if (end != 0.f) {
if (time < begin - time_prec){
continue;
}
else if (time > end + time_prec) {
break;
}
}
else {
if (time < begin - time_prec) continue;
}
if ((realcountread++) % 1 == 0){
printf ("# load frame at time: %.1f ps\r", time);
fflush (stdout);
}
vector<vector<double > > frame;
tjl.getFrame (frame);
// we assume here the tip3p water
for (int ii = 0; ii < nmols; ++ii){
vector<double > moment (3, 0.);
vector<double > com (3, 0.);
double totmi = 1./(mh * 2. + mo);
for (int dd = 0; dd < 3; ++dd){
moment[dd] += frame[ii*3+0][dd] * qo;
moment[dd] += frame[ii*3+1][dd] * qh;
moment[dd] += frame[ii*3+2][dd] * qh;
// com[dd] += frame[ii*3+0][dd] * mo * totmi;
// com[dd] += frame[ii*3+1][dd] * mh * totmi;
// com[dd] += frame[ii*3+2][dd] * mh * totmi;
}
for (int dd = 0; dd < 3; ++dd){
// ValueType dx1, dx2;
// dx1 = frame[ii*3+1][dd] - frame[ii*3+0][dd];
// dx2 = frame[ii*3+2][dd] - frame[ii*3+0][dd];
// if (dx1 > 0.5 * tjl.getBox()[dd]) {dx1 -= tjl.getBox()[dd]; printf ("hit\n");}
// if (dx1 <-0.5 * tjl.getBox()[dd]) {dx1 += tjl.getBox()[dd]; printf ("hit\n");}
// if (dx2 > 0.5 * tjl.getBox()[dd]) {dx2 -= tjl.getBox()[dd]; printf ("hit\n");}
// if (dx2 <-0.5 * tjl.getBox()[dd]) {dx2 += tjl.getBox()[dd]; printf ("hit\n");}
// com[dd] = mo * totmi * frame[ii*3+0][dd] + mh * totmi * (frame[ii*3+0][dd] + dx1) + mh * totmi * (frame[ii*3+0][dd] + dx2);
com[dd] = frame[ii*3+0][dd];
if (com[dd] < 0 ) com[dd] += tjl.getBox()[dd];
else if (com[dd] >= tjl.getBox()[dd]) com[dd] -= tjl.getBox()[dd];
}
coms[ii] = com;
dipoles[ii] = moment;
}
clist.rebuild (coms);
gkr.deposit (coms, clist, dipoles, vbox);
}
printf ("\n");
gkr.calculate ();
FILE *fout = fopen (ofile.c_str(), "w");
if (fout == NULL){
std::cerr << "cannot open file " << ofile << std::endl;
exit (1);
}
for (unsigned i = 1; i < gkr.getN(); ++i){
fprintf (fout, "%f %f %e\n", (i) * refh, gkr.getAvg(i), gkr.getAvgError(i));
}
fclose (fout);
return 0;
}
示例3: main
//.........这里部分代码省略.........
int countread = 0;
while (read_xtc (fp, natoms, &step, &time, box, xx, &prec) == 0){
if (end != 0.f) {
if (time < begin - time_prec){
continue;
}
else if (time > end + time_prec) {
break;
}
}
else {
if (time < begin - time_prec) continue;
}
if (countread++ % 1 == 0){
printf ("# load frame at time: %.1f ps\r", time);
fflush (stdout);
}
coms.clear ();
if (method == std::string ("adress")){
int nmol = natoms / 4;
for (int i = 0; i < nmol; ++i){
if (xx[i*4+3][0] < 0 ) xx[i*4+3][0] += box[0][0];
else if (xx[i*4+3][0] >= box[0][0]) xx[i*4+3][0] -= box[0][0];
if (xx[i*4+3][1] < 0 ) xx[i*4+3][1] += box[1][1];
else if (xx[i*4+3][1] >= box[1][1]) xx[i*4+3][1] -= box[1][1];
if (xx[i*4+3][2] < 0 ) xx[i*4+3][2] += box[2][2];
else if (xx[i*4+3][2] >= box[2][2]) xx[i*4+3][2] -= box[2][2];
std::vector<ValueType > tmp(3);
tmp[0] = xx[i*4+3][0];
tmp[1] = xx[i*4+3][1];
tmp[2] = xx[i*4+3][2];
coms.push_back(tmp);
}
}
else if (method == std::string ("atom")){
int nmol = natoms / 3;
for (int i = 0; i < nmol; ++i){
std::vector<ValueType > com(3, 0.);
for (int dd = 0; dd < 3; ++dd){
ValueType dx1, dx2;
dx1 = xx[i*3+1][dd] - xx[i*3+0][dd];
dx2 = xx[i*3+2][dd] - xx[i*3+0][dd];
if (dx1 > 0.5 * box[dd][dd]) {dx1 -= box[dd][dd]; printf ("hit\n");}
if (dx1 <-0.5 * box[dd][dd]) {dx1 += box[dd][dd]; printf ("hit\n");}
if (dx2 > 0.5 * box[dd][dd]) {dx2 -= box[dd][dd]; printf ("hit\n");}
if (dx2 <-0.5 * box[dd][dd]) {dx2 += box[dd][dd]; printf ("hit\n");}
com[dd] = 16. * xx[i*3+0][dd] +
1. * (xx[i*3+0][dd] + dx1) +
1. * (xx[i*3+0][dd] + dx2);
com[dd] /= 18.;
if (com[dd] < 0 ) com[dd] += box[dd][dd];
else if (com[dd] >= box[dd][dd]) com[dd] -= box[dd][dd];
}
coms.push_back (com);
}
}
else if (method == std::string ("cg")){
int nmol = natoms;
for (int i = 0; i < nmol; ++i){
if (xx[i][0] < 0 ) xx[i][0] += box[0][0];
else if (xx[i][0] >= box[0][0]) xx[i][0] -= box[0][0];
if (xx[i][1] < 0 ) xx[i][1] += box[1][1];
else if (xx[i][1] >= box[1][1]) xx[i][1] -= box[1][1];
if (xx[i][2] < 0 ) xx[i][2] += box[2][2];
else if (xx[i][2] >= box[2][2]) xx[i][2] -= box[2][2];
std::vector<ValueType > tmp(3);
tmp[0] = xx[i][0];
tmp[1] = xx[i][1];
tmp[2] = xx[i][2];
coms.push_back(tmp);
}
}
clist.rebuild (coms);
myrdf.deposit (coms, vbox, clist);
}
printf ("\n");
xdrfile_close (fp);
free (xx);
myrdf.calculate();
FILE *fout = fopen (ofile.c_str(), "w");
if (fout == NULL){
std::cerr << "cannot open file " << ofile << std::endl;
exit (1);
}
fprintf (fout, "%f %f\n", 0., myrdf.getValue(0));
for (unsigned i = 1; i < myrdf.getN(); ++i){
fprintf (fout, "%f %f\n", (i) * refh, myrdf.getValue(i));
}
fclose (fout);
return 0;
}