Skip to content

Commit

Permalink
set up a very simple way for visualizing the benchmark trajectories
Browse files Browse the repository at this point in the history
improved the xyz output
  • Loading branch information
Iximiel committed Jul 25, 2024
1 parent 9a80702 commit ffb5511
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/cltools/Benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ void Benchmark::registerKeywords( Keywords& keys ) {
keys.add("compulsory","--maxtime","-1","maximum number of seconds (-1 means forever)");
keys.add("compulsory","--sleep","0","number of seconds of sleep, mimicking MD calculation");
keys.add("compulsory","--atom-distribution","line","the kind of possible atomic displacement at each step");
keys.add("optional","--dump-trajectory","dump the trajectory to this file");
keys.addFlag("--domain-decomposition",false,"simulate domain decomposition, implies --shuffle");
keys.addFlag("--shuffled",false,"reshuffle atoms");
}
Expand Down Expand Up @@ -663,6 +664,48 @@ int Benchmark::main(FILE* in, FILE*out,Communicator& pc) {
distribution = getAtomDistribution(atomicDistr);
log << "Using --atom-distribution=" << atomicDistr << "\n";
}

{
std::string fileToDump;
if(parse("--dump-trajectory",fileToDump)) {
log << "Saving the trajectory to \"" << fileToDump << "\" and exiting\n";
std::vector<double> cell(9);
std::vector<Vector> pos(natoms);
std::ofstream ofile(fileToDump);
bool extendedxyz=false;
if(std::getenv("PLUMED_BENCH_EXTENDED_XYZ")) {
extendedxyz=true;
} else {
log << "If you export PLUMED_BENCH_EXTENDED_XYZ, the xyz file will be in extended xyz format\n";
}
if (nf<0) {
//if the user accidentally sets infinite steps, we set it to print only one
nf=1;
}
for(int step=0; step<nf; ++step) {
auto sw=kernels[0].stopwatch.startStop("TrajectoryGeneration");
distribution->positions(pos,step,atomicGenerator);
distribution->box(cell,natoms,step,atomicGenerator);
ofile<< natoms << "\n";
if (extendedxyz) {
ofile << "Properties=species:S:1:pos:R:3 Lattice=\"";
}
ofile << cell[0] << " " << cell[1] << " " << cell[2] << " "
<< cell[3] << " " << cell[4] << " " << cell[5] << " "
<< cell[6] << " " << cell[7] << " " << cell[8] ;
if (extendedxyz) {
ofile << '"';
}
ofile<< "\n";
for(int i=0; i<natoms; ++i) {
ofile << "X\t" << pos[i]<< "\n";
}
}
ofile.close();
return 0 ;
}
}

log <<"Initializing the setup of the kernel(s)\n";
const auto initial_time=std::chrono::high_resolution_clock::now();

Expand Down

0 comments on commit ffb5511

Please sign in to comment.