Skip to content

Commit

Permalink
change names
Browse files Browse the repository at this point in the history
  • Loading branch information
psn417 committed Jun 26, 2024
1 parent 4840132 commit d965cfd
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 63 deletions.
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
.. _kw_dump_piston:
.. _kw_dump_shock_nemd:
.. index::
single: dump_piston (keyword in run.in)
single: dump_shock_nemd (keyword in run.in)

:attr:`dump_piston`
:attr:`dump_shock_nemd`
=====================

In shock wave piston simulations, it's often crucial to compute thermo information at different regions, both before and after the shock wave passage.

Piston simulations commonly involve millions of atoms. Dumping all the virial and velocity data for each atom can lead to excessively large output files, making data processing cumbersome. The `dump_piston` command addresses this by calculating spatial thermo information during the simulation.
Piston simulations commonly involve millions of atoms. Dumping all the virial and velocity data for each atom can lead to excessively large output files, making data processing cumbersome. The `dump_shock_nemd` command addresses this by calculating spatial thermo information during the simulation.

This feature calculates the spatial distribution of partical velocity (km/h), stress (GPa), temperature and density (g/cm3).
This feature calculates the spatial distribution of partical velocity (km/h), stress (GPa), temperature and density (g/cm3) in *x*-direction.

Syntax
------

.. code::
dump_piston direction <direction> interval <time_interval> bin_size <size of each bin>
dump_shock_nemd interval <time_interval> bin_size <size of each bin>
- The :attr:`direction` parameter specifies the shock wave direction (x, y, or z).
- The :attr:`interval` parameter sets the output interval (number of steps).
- The :attr:`bin_size` parameter, optional with a default value of 10, defines the thickness of each histogram bin, measured in Angstroms.

Expand All @@ -29,4 +28,4 @@ To output spatial thermo information every 1000 steps for a run in the x-directi

.. code::
dump_piston direction x interval 1000 bin_size 20
dump_shock_nemd interval 1000 bin_size 20
18 changes: 8 additions & 10 deletions doc/gpumd/input_parameters/ensemble_shock_nemd.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@
=========================

In a typical NEMD shock simulation, a shock wave is generated by a moving *wall*.
We can simulate the *wall* in multiple ways:
The *wall* can be simulated in multiple ways:

- :attr:`wall_piston`: A fixed layer of atoms.
- :attr:`wall_mirror`: A momentum mirror that reflects atoms.
- :attr:`wall_harmonic`: A harmonic potential that pushes atoms away. It is softer than a momentum mirror.

Any of these methods can generate a shock wave. There are other possible methods, but the above methods are usually enough.
Any of these methods can generate a shock wave. While there are other possible methods, the above methods are usually sufficient.

Please note that the shock wave propagates in the *x*-direction.
Another wall is placed on the opposite side of the cell to prevent atoms from escaping.
It is important **NOT** to use non-periodic boundary conditions in the *x*-direction, as GPUMD currently does not handle it well. A vacuum layer is automatically added on the other side of the cell.

Note that the shock wave is in x direction.
Another wall is placed at the other side of the cell to prevent atoms from escaping.
You **MUST NOT** use non-peridic boundary condition in x dirction, since currently GPUMD can not handle it well. A vacuum layer is automatically added to the other side of the cell.

We recommand to use it with the :ref:`dump_piston keyword <kw_dump_piston>`.
It is recommended to use this with the :ref:`dump_shock_nemd keyword <kw_dump_shock_nemd>` to get the spatial distribution of thermo information.

Syntax
------
Expand All @@ -29,7 +28,7 @@ The parameters are specified as follows:
ensemble wall_piston vp <vp> thickness <thickness>
- :attr:`<vp>`: Indicates the velocity of the moving piston in km/s.
- :attr:`<thickness>`: Defines the thickness of the wall in Angstroms. This keyword is optional with the default value 20.
- :attr:`<thickness>`: Defines the thickness of the wall in Angstroms. This keyword is optional with the default value of 20.

.. code-block:: rst
Expand All @@ -42,5 +41,4 @@ The parameters are specified as follows:
ensemble wall_harmonic vp <vp> k <k>
- :attr:`<vp>`: Indicates the velocity of the moving piston in km/s.
- :attr:`<k>`: Defines the strength of the harmonic wall in eV/A^2. This keyword is optional with the default value 10.

- :attr:`<k>`: Defines the strength of the harmonic wall in eV/A^2. This keyword is optional with the default value of 10.
2 changes: 1 addition & 1 deletion doc/gpumd/input_parameters/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ Below you can find a listing of keywords for the ``run.in`` input file.
dump_restart
dump_thermo
dump_velocity
dump_piston
dump_shock_nemd
4 changes: 2 additions & 2 deletions src/main_gpumd/run.cu
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,8 @@ void Run::parse_one_keyword(std::vector<std::string>& tokens)
measure.dump_beads.parse(param, num_param);
} else if (strcmp(param[0], "dump_observer") == 0) {
measure.dump_observer.parse(param, num_param);
} else if (strcmp(param[0], "dump_piston") == 0) {
measure.dump_piston.parse(param, num_param);
} else if (strcmp(param[0], "dump_shock_nemd") == 0) {
measure.dump_shock_nemd.parse(param, num_param);
} else if (strcmp(param[0], "dump_dipole") == 0) {
measure.dump_dipole.parse(param, num_param);
} else if (strcmp(param[0], "dump_polarizability") == 0) {
Expand Down
40 changes: 7 additions & 33 deletions src/measure/dump_piston.cu → src/measure/dump_shock_nemd.cu
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
along with GPUMD. If not, see <http:https://www.gnu.org/licenses/>.
*/

#include "dump_piston.cuh"
#include "dump_shock_nemd.cuh"
#include <cstring>

namespace
Expand Down Expand Up @@ -139,24 +139,14 @@ void write_to_file(FILE* file, double* array, int n)

} // namespace

void Dump_Piston::parse(const char** param, int num_param)
void Dump_Shock_NEMD::parse(const char** param, int num_param)
{
dump_ = true;

printf("Dump spatial histogram thermo information for piston shock wave simulation, ");
int i = 1;
while (i < num_param) {
if (strcmp(param[i], "direction") == 0) {
if (strcmp(param[i + 1], "x") == 0)
direction = 0;
else if (strcmp(param[i + 1], "y") == 0)
direction = 1;
else if (strcmp(param[i + 1], "z") == 0)
direction = 2;
else
PRINT_INPUT_ERROR("Direction should be x or y or z.");
i += 2;
} else if (strcmp(param[i], "interval") == 0) {
if (strcmp(param[i], "interval") == 0) {
if (!is_valid_int(param[i + 1], &dump_interval_))
PRINT_INPUT_ERROR("Dump interval should be an integer.");
i += 2;
Expand All @@ -168,19 +158,9 @@ void Dump_Piston::parse(const char** param, int num_param)
PRINT_INPUT_ERROR("Unknown keyword.");
}
}

if (strcmp(param[2], "x") == 0) {
direction = 0;
} else if (strcmp(param[2], "y") == 0) {
direction = 1;
} else if (strcmp(param[2], "z") == 0) {
direction = 2;
} else
PRINT_INPUT_ERROR("Direction should be x or y or z.");
printf("in %d direction.\n", direction);
}

void Dump_Piston::preprocess(Atom& atom, Box& box)
void Dump_Shock_NEMD::preprocess(Atom& atom, Box& box)
{
if (!dump_)
return;
Expand All @@ -199,12 +179,10 @@ void Dump_Piston::preprocess(Atom& atom, Box& box)
pyy_file = my_fopen("pyy_hist.txt", "w");
pzz_file = my_fopen("pzz_hist.txt", "w");
density_file = my_fopen("density_hist.txt", "w");
com_vx_file = my_fopen("com_vx_hist.txt", "w");
com_vy_file = my_fopen("com_vy_hist.txt", "w");
com_vz_file = my_fopen("com_vz_hist.txt", "w");
com_vx_file = my_fopen("vp_hist.txt", "w");
}

void Dump_Piston::process(Atom& atom, Box& box, const int step)
void Dump_Shock_NEMD::process(Atom& atom, Box& box, const int step)
{
if (!dump_ || step % dump_interval_ != 0)
return;
Expand Down Expand Up @@ -295,11 +273,9 @@ void Dump_Piston::process(Atom& atom, Box& box, const int step)
write_to_file(pzz_file, cpu_pzz.data(), bins);
write_to_file(density_file, cpu_density.data(), bins);
write_to_file(com_vx_file, cpu_com_vx.data(), bins);
write_to_file(com_vy_file, cpu_com_vy.data(), bins);
write_to_file(com_vz_file, cpu_com_vz.data(), bins);
}

void Dump_Piston::postprocess()
void Dump_Shock_NEMD::postprocess()
{
if (!dump_)
return;
Expand All @@ -310,7 +286,5 @@ void Dump_Piston::postprocess()
fclose(pzz_file);
fclose(density_file);
fclose(com_vx_file);
fclose(com_vy_file);
fclose(com_vz_file);
dump_ = false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <string>
#include <vector>

class Dump_Piston
class Dump_Shock_NEMD
{
public:
void parse(const char** param, int num_param);
Expand All @@ -36,12 +36,11 @@ private:
bool dump_ = false;
int n;
int dump_interval_ = -1;
int direction;
int direction = 0;
int bins;
double slice_vol = 1;
double avg_window = 10;
FILE *temp_file, *pxx_file, *pyy_file, *pzz_file, *density_file, *com_vx_file, *com_vy_file,
*com_vz_file;
FILE *temp_file, *pxx_file, *pyy_file, *pzz_file, *density_file, *com_vx_file;
GPU_Vector<double> gpu_temp, gpu_pxx, gpu_pyy, gpu_pzz, gpu_density, gpu_com_vx, gpu_com_vy,
gpu_com_vz, gpu_number;
std::vector<double> cpu_temp, cpu_pxx, cpu_pyy, cpu_pzz, cpu_density, cpu_com_vx, cpu_com_vy,
Expand Down
6 changes: 3 additions & 3 deletions src/measure/measure.cu
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void Measure::initialize(
dump_exyz.preprocess(number_of_atoms);
dump_beads.preprocess(number_of_atoms, atom.number_of_beads);
dump_observer.preprocess(number_of_atoms, number_of_potentials, force);
dump_piston.preprocess(atom, box);
dump_shock_nemd.preprocess(atom, box);
dump_dipole.preprocess(number_of_atoms, number_of_potentials, force);
dump_polarizability.preprocess(number_of_atoms, number_of_potentials, force);
active.preprocess(number_of_atoms, number_of_potentials, force);
Expand Down Expand Up @@ -85,7 +85,7 @@ void Measure::finalize(
dump_exyz.postprocess();
dump_beads.postprocess();
dump_observer.postprocess();
dump_piston.postprocess();
dump_shock_nemd.postprocess();
dump_dipole.postprocess();
dump_polarizability.postprocess();
active.postprocess();
Expand Down Expand Up @@ -204,7 +204,7 @@ void Measure::process(
step, temperature, box.get_volume(), hnemd.fe, atom.velocity_per_atom, atom.virial_per_atom);

lsqt.process(atom, box, step);
dump_piston.process(atom, box, step);
dump_shock_nemd.process(atom, box, step);

#ifdef USE_NETCDF
dump_netcdf.process(
Expand Down
4 changes: 2 additions & 2 deletions src/measure/measure.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
#include "dump_exyz.cuh"
#include "dump_force.cuh"
#include "dump_observer.cuh"
#include "dump_piston.cuh"
#include "dump_polarizability.cuh"
#include "dump_position.cuh"
#include "dump_restart.cuh"
#include "dump_shock_nemd.cuh"
#include "dump_thermo.cuh"
#include "dump_velocity.cuh"
#include "force/force.cuh"
Expand Down Expand Up @@ -109,7 +109,7 @@ public:
Dump_EXYZ dump_exyz;
Dump_Beads dump_beads;
Dump_Observer dump_observer;
Dump_Piston dump_piston;
Dump_Shock_NEMD dump_shock_nemd;
Dump_Dipole dump_dipole;
Dump_Polarizability dump_polarizability;
Active active;
Expand Down

0 comments on commit d965cfd

Please sign in to comment.