Equilibration run for the Lennard-Jones fluid using the Langevin thermostat as a second step towards running an AdResS simulation. The initial phase position is restored from an H5MD file that can be generated by a preceding Berendsen equilibration. The final phase position is dumped into both GRO and H5MD output files and the trajectory is stored in a separate H5MD file.
Configuration for the Lennard-Jones equilibration simulation using the Langevin thermostat.
void equilibrateLangevin(Config& config)
{
io.restore(config.fileRestoreH5MD, subdomain, atoms);
auto rho =
real_c(atoms.numLocalAtoms) / volume;
std::cout << "rho: " << rho << std::endl;
config.temperature);
Kokkos::Timer timer;
real_t maxAtomDisplacement = std::numeric_limits<real_t>::max();
idx_t rebuildCounter = 0;
if (config.bOutput)
{
"step", "wall time", "T", "p", "V", "E_kin", "E_LJ", "E_total", "Nlocal", "Nghost");
"step", "wall time", "T", "p", "V", "E_kin", "E_LJ", "E_total", "Nlocal", "Nghost");
dumpH5MD.open(config.fileOutH5MD, subdomain, atoms);
}
for (auto step = 0; step < config.nsteps; ++step)
{
maxAtomDisplacement += langevinIntegrator.preForceIntegrate(atoms, config.dt);
if (maxAtomDisplacement >= config.skin * 0.5_r)
{
maxAtomDisplacement = 0_r;
verletList.build(atoms.getPos(),
0,
atoms.numLocalAtoms,
config.neighborCutoff,
config.cell_ratio,
config.estimatedMaxNeighbors);
++rebuildCounter;
}
else
{
}
auto force = atoms.getForce();
Cabana::deep_copy(force, 0_r);
LJ.apply(atoms, verletList);
currentPressure << 2_r * (Ek - LJ.getVirial()) / (3_r * volume);
Ek /=
real_c(atoms.numLocalAtoms);
currentTemperature << (2_r / 3_r) * Ek;
langevinIntegrator.postForceIntegrate(atoms, config.dt);
if (config.bOutput && (step % config.outputInterval == 0))
{
timer.seconds(),
currentTemperature,
currentPressure,
volume,
Ek,
LJ.getEnergy() /
real_c(atoms.numLocalAtoms),
Ek + LJ.getEnergy() /
real_c(atoms.numLocalAtoms),
atoms.numLocalAtoms,
atoms.numGhostAtoms);
dumpH5MD.dumpStep(subdomain, atoms, step, config.dt);
}
}
if (config.bOutput)
{
dumpH5MD.close();
dumpH5MD.dump(config.fileOutFinalH5MD, subdomain, atoms);
atoms,
subdomain,
0,
config.resName,
config.resName,
config.typeNames,
false,
true);
}
auto time = timer.seconds();
std::cout << time << std::endl;
std::ofstream fout("ecab.perf", std::ofstream::app);
fout << cores << ", " << time << ", " << atoms.numLocalAtoms << ", " << config.nsteps
<< std::endl;
fout.close();
}
High-level interface for the application of the Lennard-Jones potential to given atoms.
Definition LennardJones.hpp:118
Integrator that updates the positions and velocities of atoms using the BAOAB Langevin dynamics algor...
Definition VelocityVerletLangevinThermostat.hpp:36
High-level interface for managing ghost atoms at the periodic boundaries.
Definition GhostLayer.hpp:33
void createGhostAtoms(data::Atoms &atoms, const data::Subdomain &subdomain)
Definition GhostLayer.hpp:44
void updateGhostAtoms(data::Atoms &atoms, const data::Subdomain &subdomain)
Definition GhostLayer.hpp:49
void exchangeRealAtoms(data::Atoms &atoms, const data::Subdomain &subdomain)
Definition GhostLayer.hpp:39
void contributeBackGhostToReal(data::Atoms &atoms)
Definition GhostLayer.hpp:56
Handles dumping trajectory data in H5MD format.
Definition DumpH5MD.hpp:41
Handles restoring trajectory data from H5MD format.
Definition RestoreH5MD.hpp:33
Calculates the exponential moving average (EMA) for values added with append.
Definition ExponentialMovingAverage.hpp:32
real_t getKineticEnergy(data::Atoms &atoms)
Definition KineticEnergy.hpp:26
DeviceAtoms Atoms
Definition Atoms.hpp:177
Save and load simulation data.
void dumpGRO(const std::string &filename, data::Atoms &atoms, const data::Subdomain &subdomain, const real_t ×tamp, const std::string &title, const std::string &resName, const std::vector< std::string > &typeNames, bool dumpGhosts, bool dumpVelocities)
format specification https://manual.gromacs.org/current/reference-manual/file-formats....
Definition DumpGRO.cpp:26
void printTableSep(HEAD)
Definition PrintTable.hpp:40
std::string getEnvironmentVariable(const std::string &variable)
Definition EnvironmentVariables.hpp:23
void printTable(HEAD head)
Definition PrintTable.hpp:27
Cabana::VerletList< Kokkos::DefaultExecutionSpace::memory_space, Cabana::HalfNeighborTag, Cabana::VerletLayout2D, Cabana::TeamOpTag > HalfVerletList
Definition datatypes.hpp:184
KOKKOS_INLINE_FUNCTION constexpr real_t real_c(T t)
Definition datatypes.hpp:114
Axis-aligned simulation box with a surrounding ghost layer.
Definition Subdomain.hpp:46
Point3D minGhostCorner
Definition Subdomain.hpp:97
Point3D maxGhostCorner
Definition Subdomain.hpp:100
real_t getVolume() const
Definition Subdomain.cpp:57
int main(int argc, char* argv[])
{
Kokkos::ScopeGuard scope_guard(argc, argv);
std::cout << "execution space: " << typeid(Kokkos::DefaultExecutionSpace).name() << std::endl;
Config config;
CLI::App app{"follow-up NVT equilibration run of Lennard-Jones fluid with Langevin thermostat"};
app.add_option("-n,--nsteps", config.nsteps, "number of simulation steps");
app.add_option("-o,--outint", config.outputInterval, "output interval");
app.add_option("-i,--inpfile", config.fileRestoreH5MD, "input file name");
app.add_option("-T,--temperature", config.temperature, "thermostat target temperature");
app.add_option("--friction", config.friction, "friction coefficient for thermostat");
app.add_option("-f,--outfile", config.fileOut, "output file name");
CLI11_PARSE(app, argc, argv);
config.fileOutH5MD = format("{0}.h5md", config.fileOut);
config.fileOutTF = format("{0}_tf.txt", config.fileOut);
config.fileOutFinalH5MD = format("{0}_final.h5md", config.fileOut);
config.fileOutFinalGRO = format("{0}_final.gro", config.fileOut);
if (config.outputInterval < 0) config.bOutput = false;
equilibrateLangevin(config);
return EXIT_SUCCESS;
}