Simulation of Lennard-Jones particles in contact with an ideal gas with a force capping applied in the transition zone.
Configuration for the Lennard-Jones/ideal-gas contact simulation with local force capping.
void runLennardJones_idealGas_localCap(Config& config)
{
{config.Lx, config.Lx, config.Lx},
{0_r, Config::neighborCutoff, Config::neighborCutoff});
auto atoms =
auto rho =
real_c(atoms.numLocalAtoms) / volume;
std::cout << "rho: " << rho << std::endl;
real_t maxAtomDisplacement = std::numeric_limits<real_t>::max();
idx_t rebuildCounter = 0;
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]}, 0_r, 10_r * config.sigma);
{boxCenter[0], boxCenter[1], boxCenter[2]}, 10_r * config.sigma, 15_r * config.sigma);
Kokkos::Timer timer;
meanSquareDisplacement.
reset(atoms);
auto msd = 0_r;
util::printTable(
"step",
"time",
"T",
"Ek",
"E0",
"E",
"p",
"msd",
"Nlocal",
"Nghost");
std::ofstream fStat("statistics.txt");
for (auto step = 0; step < config.nsteps; ++step)
{
maxAtomDisplacement += integrator.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,
subdomain.minGhostCorner.data(),
subdomain.maxGhostCorner.data(),
config.estimatedMaxNeighbors);
++rebuildCounter;
}
else
{
}
auto force = atoms.getForce();
Cabana::deep_copy(force, 0_r);
if (step <= config.nstepsEq)
{
lennardJonesCap.apply(atoms, verletList);
}
else
{
lennardJones.apply_if(
atoms,
verletList,
KOKKOS_LAMBDA(
const real_t x1,
return isInNoCapRegion(x1, y1, z1) || isInNoCapRegion(x2, y2, z2);
});
lennardJonesCap.apply_if(
atoms,
verletList,
KOKKOS_LAMBDA(
const real_t x1,
return isInCappingRegion(x1, y1, z1) && isInCappingRegion(x2, y2, z2);
});
}
integrator.postForceIntegrate(atoms, config.dt);
if (config.bOutput && (step % config.outputInterval == 0))
{
auto E0 = (lennardJones.getEnergy() + lennardJonesCap.getEnergy()) /
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,
atoms.numLocalAtoms,
atoms.numGhostAtoms);
fStat << step << " " << timer.seconds() << " " << T << " " << Ek << " " << E0 << " "
<< E0 + Ek << " " << p << " " << msd << " " << atoms.numLocalAtoms << " "
<< atoms.numGhostAtoms << " " << std::endl;
}
}
fStat.close();
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
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
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
void printTableSep(HEAD)
Definition PrintTable.hpp:40
data::Atoms fillDomainWithAtoms(const data::Subdomain &subdomain, const idx_t &numAtoms, const real_t &maxVelocity, const real_t &inputMass)
Helper function to provide an initial atoms ensamble.
Definition simulationSetup.cpp:22
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
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 Fluid benchmark application"};
app.add_option("-n,--nsteps", config.nsteps, "total number of simulation steps");
app.add_option("-L,--length", config.Lx, "simulation box diameter");
app.add_option("-e,--numeq", config.nstepsEq, "number of equilibration steps");
app.add_option(
"-T,--temperature",
config.temperature,
"temperature of the Langevin thermostat (negative numbers deactivate the thermostat)");
app.add_option("-o,--output", config.outputInterval, "output interval");
CLI11_PARSE(app, argc, argv);
if (config.outputInterval < 0) config.bOutput = false;
runLennardJones_idealGas_localCap(config);
return EXIT_SUCCESS;
}