diff --git a/src/cltools/Benchmark.cpp b/src/cltools/Benchmark.cpp index 4b03ec95ad..829a17d4e7 100644 --- a/src/cltools/Benchmark.cpp +++ b/src/cltools/Benchmark.cpp @@ -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"); } @@ -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 cell(9); + std::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; steppositions(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