Production run for the Lennard-Jones fluid coupled to a tracer gas of non-interacting particles with a converged thermodynamic force obtained from a previous thermodynamic force iteration. Output is stored in GRO and H5MD files.
Configuration for the production run simulation with a converged thermodynamic force.
void productionTracer(Config& config)
{
io.restore(config.fileRestoreH5MD, initialSubdomain, atoms);
{
},
{
},
auto rho =
real_c(atoms.numLocalAtoms) / volume;
std::cout << "rho: " << rho << std::endl;
std::cout << "restoring thermodynamic force from file" << std::endl;
auto thermodynamicForce =
real_t maxAtomDisplacement = std::numeric_limits<real_t>::max();
idx_t rebuildCounter = 0;
config.r_cut, config.sigma, config.epsilon, config.r_cap);
const auto boxCenter = subdomain.getCenter();
std::cout << "x center: " << boxCenter[0] << std::endl;
std::cout << "y center: " << boxCenter[1] << std::endl;
std::cout << "z center: " << boxCenter[2] << std::endl;
{boxCenter[0], boxCenter[1], boxCenter[2]}, config.intRegionMin, config.intRegionMax);
config.thermoForceRegionMin,
config.thermoForceRegionMax);
config.temperature);
Kokkos::Timer timer;
meanSquareDisplacement.
reset(atoms);
auto msd = 0_r;
{boxCenter[0] + 10_r * config.sigma, boxCenter[1], boxCenter[2]}, {1_r, 0_r, 0_r});
int64_t flux = 0;
std::ofstream fStat("statistics.txt");
if (config.bOutput)
{
"step", "time", "T", "Ek", "E0", "E", "p", "msd", "flux", "Nlocal", "Nghost");
"step", "time", "T", "Ek", "E0", "E", "p", "msd", "flux", "Nlocal", "Nghost");
dumpH5MD.open(config.fileOutH5MD, subdomain, atoms);
}
for (auto step = 0; step < config.nsteps; ++step)
{
countingPlane.startCounting(atoms);
maxAtomDisplacement += langevinIntegrator.preForceIntegrate(atoms, config.dt);
flux += countingPlane.stopCounting(atoms);
if (maxAtomDisplacement >=
config.skin *
0.5_r)
{
maxAtomDisplacement = 0_r;
verletList.build(atoms.getPos(),
0,
atoms.numLocalAtoms,
config.neighborCutoff,
config.cell_ratio,
subdomain.minGhostCorner.data(),
subdomain.maxGhostCorner.data(),
config.estimatedMaxNeighbors);
++rebuildCounter;
}
else
{
}
auto force = atoms.getForce();
Cabana::deep_copy(force, 0_r);
thermodynamicForce.applyInterpolated_if(atoms, isInThermoForceRegion);
lennardJonesInner.apply_if(
atoms,
verletList,
KOKKOS_LAMBDA(
const real_t x1,
return (isInInnerIntRegion(x1, y1, z1) && isInInnerIntRegion(x2, y2, z2));
});
langevinIntegrator.postForceIntegrate(atoms, config.dt);
if (config.bOutput && (step % config.outputInterval == 0))
{
auto E0 = (lennardJonesInner.getEnergy()) /
real_c(atoms.numLocalAtoms);
auto T = (2_r / 3_r) * Ek;
msd = meanSquareDisplacement.
calc(atoms, subdomain) /
(
real_c(config.outputInterval) * config.dt);
meanSquareDisplacement.
reset(atoms);
timer.seconds(),
T,
Ek,
E0,
E0 + Ek,
p,
msd,
flux,
atoms.numLocalAtoms,
atoms.numGhostAtoms);
fStat << step << " " << timer.seconds() << " " << T << " " << Ek << " " << E0 << " "
<< E0 + Ek << " " << p << " " << msd << " " << flux << " "
<< atoms.numLocalAtoms << " " << atoms.numGhostAtoms << " " << std::endl;
flux = 0;
dumpH5MD.dumpStep(subdomain, atoms, step, config.dt);
}
}
if (config.bOutput)
{
dumpH5MD.close();
dumpH5MD.dump(config.fileOutFinalH5MD, subdomain, atoms);
fStat.close();
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
Counts particles that cross a defined plane between two time steps.
Definition CountingPlane.hpp:29
Calculates the mean square displacement of particles over time.
Definition MeanSquareDisplacement.hpp:31
void reset(data::Atoms &atoms)
Store current positions as a starting point.
Definition MeanSquareDisplacement.cpp:24
real_t calc(data::Atoms &atoms, const data::Subdomain &subdomain)
Compare current positions against the starting point.
Definition MeanSquareDisplacement.cpp:60
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
Predicate to check if a point is within an axis-aligned slab.
Definition IsInSymmetricSlab.hpp:26
real_t getMeanKineticEnergy(data::Atoms &atoms)
Definition KineticEnergy.hpp:44
Vector3D getSystemMomentum(data::Atoms &atoms)
Definition SystemMomentum.cpp:21
real_t getPressure(data::Atoms &atoms, const data::Subdomain &subdomain)
Definition Pressure.cpp:23
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
action::ThermodynamicForce restoreThermoForce(const std::string &filename, const data::Subdomain &subdomain, const std::vector< real_t > &targetDensities, const std::vector< real_t > &thermodynamicForceModulations, const bool enforceSymmetry, const bool usePeriodicity, const idx_t maxNumForces)
Definition RestoreThermoForce.cpp:24
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 minCorner
Definition Subdomain.hpp:86
Point3D maxCorner
Definition Subdomain.hpp:89
Point3D ghostLayerThickness
Definition Subdomain.hpp:93
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{
"Lennard-Jones tracer production simulation with converged thermodynamic force input"};
app.add_option("-n,--nsteps", config.nsteps, "number of simulation steps");
app.add_option("-d,--tstep", config.dt, "time step");
app.add_option("-o,--outint", config.outputInterval, "output interval");
app.add_option("-i,--inpfile", config.fileRestoreH5MD, "input file name");
app.add_option("-f,--outfile", config.fileOut, "output 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("--forceinp", config.fileRestoreTF, "input file for the thermodynamics force");
app.add_option("--rcap", config.r_cap, "capping radius for inner Lennard-Jones potential");
app.add_option("--intmin", config.intRegionMin, "interacting region minimum coordinate");
app.add_option("--intmax", config.intRegionMax, "interacting region maximum coordinate");
app.add_option("--thermoforcemin",
config.thermoForceRegionMin,
"thermodynamic force region minimum coordinate");
app.add_option("--thermoforcemax",
config.thermoForceRegionMax,
"thermodynamic force region maximum coordinate");
CLI11_PARSE(app, argc, argv);
config.fileOutH5MD = format("{0}.h5md", config.fileOut);
config.fileOutFinalGRO = format("{0}_final.gro", config.fileOut);
config.fileOutFinalH5MD = format("{0}_final.h5md", config.fileOut);
if (config.outputInterval < 0) config.bOutput = false;
productionTracer(config);
return EXIT_SUCCESS;
}