Merge pull request #4519 from fxcoudert/extxyz2
Add extended XYZ dump style extxyz
This commit is contained in:
1
.github/CODEOWNERS
vendored
1
.github/CODEOWNERS
vendored
@ -71,6 +71,7 @@ src/EXTRA-COMMAND/group_ndx.* @akohlmey
|
||||
src/EXTRA-COMMAND/ndx_group.* @akohlmey
|
||||
src/EXTRA-COMPUTE/compute_stress_mop*.* @RomainVermorel
|
||||
src/EXTRA-COMPUTE/compute_born_matrix.* @Bibobu @athomps
|
||||
src/EXTRA-DUMP/dump_extxyz.* @fxcoudert
|
||||
src/EXTRA-FIX/fix_deform_pressure.* @jtclemm
|
||||
src/EXTRA-PAIR/pair_dispersion_d3.* @soniasolomoni @arthurfl
|
||||
src/EXTRA-PAIR/d3_parameters.h @soniasolomoni @arthurfl
|
||||
|
||||
@ -19,6 +19,7 @@ An alphabetic list of all LAMMPS :doc:`dump <dump>` commands.
|
||||
* :doc:`custom/gz <dump>`
|
||||
* :doc:`custom/zstd <dump>`
|
||||
* :doc:`dcd <dump>`
|
||||
* :doc:`extxyz <dump>`
|
||||
* :doc:`grid <dump>`
|
||||
* :doc:`grid/vtk <dump>`
|
||||
* :doc:`h5md <dump_h5md>`
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
.. index:: dump cfg
|
||||
.. index:: dump custom
|
||||
.. index:: dump dcd
|
||||
.. index:: dump extxyz
|
||||
.. index:: dump grid
|
||||
.. index:: dump grid/vtk
|
||||
.. index:: dump local
|
||||
@ -59,7 +60,7 @@ Syntax
|
||||
|
||||
* ID = user-assigned name for the dump
|
||||
* group-ID = ID of the group of atoms to be dumped
|
||||
* style = *atom* or *atom/adios* or *atom/gz* or *atom/zstd* or *cfg* or *cfg/gz* or *cfg/zstd* or *cfg/uef* or *custom* or *custom/gz* or *custom/zstd* or *custom/adios* or *dcd* or *grid* or *grid/vtk* or *h5md* or *image* or *local* or *local/gz* or *local/zstd* or *molfile* or *movie* or *netcdf* or *netcdf/mpiio* or *vtk* or *xtc* or *xyz* or *xyz/gz* or *xyz/zstd* or *yaml*
|
||||
* style = *atom* or *atom/adios* or *atom/gz* or *atom/zstd* or *cfg* or *cfg/gz* or *cfg/zstd* or *cfg/uef* or *custom* or *custom/gz* or *custom/zstd* or *custom/adios* or *dcd* or *extxyz* or *grid* or *grid/vtk* or *h5md* or *image* or *local* or *local/gz* or *local/zstd* or *molfile* or *movie* or *netcdf* or *netcdf/mpiio* or *vtk* or *xtc* or *xyz* or *xyz/gz* or *xyz/zstd* or *yaml*
|
||||
* N = dump on timesteps which are multiples of N
|
||||
* file = name of file to write dump info to
|
||||
* attribute1,attribute2,... = list of attributes for a particular style
|
||||
@ -77,6 +78,7 @@ Syntax
|
||||
*custom*, *custom/gz*, *custom/zstd* attributes = see below
|
||||
*custom/adios* attributes = same as *custom* attributes, discussed on :doc:`dump custom/adios <dump_adios>` page
|
||||
*dcd* attributes = none
|
||||
*extxyz* attributes = none
|
||||
*h5md* attributes = discussed on :doc:`dump h5md <dump_h5md>` page
|
||||
*grid* attributes = see below
|
||||
*grid/vtk* attributes = see below
|
||||
@ -242,28 +244,29 @@ all the processors or multiple smaller files.
|
||||
frames consistently to the same atom. This can lead to incorrect
|
||||
visualizations or results. LAMMPS will print a warning in such cases.
|
||||
|
||||
For the *atom*, *custom*, *cfg*, *grid*, and *local* styles, sorting
|
||||
is off by default. For the *dcd*, *grid/vtk*, *xtc*, *xyz*, and
|
||||
For the *atom*, *custom*, *cfg*, *grid*, and *local* styles, sorting is
|
||||
off by default. For the *dcd*, *extxyz*, *grid/vtk*, *xtc*, *xyz*, and
|
||||
*molfile* styles, sorting by atom ID or grid ID is on by default. See
|
||||
the :doc:`dump_modify <dump_modify>` page for details.
|
||||
|
||||
The *style* keyword determines what kind of data is written to the
|
||||
dump file(s) and in what format.
|
||||
|
||||
Note that *atom*, *custom*, *dcd*, *xtc*, *xyz*, and *yaml* style dump
|
||||
files can be read directly by `VMD <https://www.ks.uiuc.edu/Research/vmd>`_,
|
||||
a popular tool for visualizing and analyzing trajectories from atomic
|
||||
and molecular systems. For reading *netcdf* style dump files, the
|
||||
netcdf plugin needs to be recompiled from source using a NetCDF version
|
||||
compatible with the one used by LAMMPS. The bundled plugin binary
|
||||
uses a very old version of NetCDF that is not compatible with LAMMPS.
|
||||
Note that *atom*, *custom*, *dcd*, *extxyz*, *xtc*, *xyz*, and *yaml*
|
||||
style dump files can be read directly by `VMD
|
||||
<https://www.ks.uiuc.edu/Research/vmd>`_, a popular tool for visualizing
|
||||
and analyzing trajectories from atomic and molecular systems. For
|
||||
reading *netcdf* style dump files, the netcdf plugin needs to be
|
||||
recompiled from source using a NetCDF version compatible with the one
|
||||
used by LAMMPS. The bundled plugin binary uses a very old version of
|
||||
NetCDF that is not compatible with LAMMPS.
|
||||
|
||||
Likewise the `OVITO visualization package <https://www.ovito.org>`_,
|
||||
popular for materials modeling, can read the *atom*, *custom*,
|
||||
popular for materials modeling, can read the *atom*, *custom*, *extxyz*,
|
||||
*local*, *xtc*, *cfg*, *netcdf*, and *xyz* style atom dump files
|
||||
directly. With version 3.8 and above, OVITO can also read and
|
||||
visualize *grid* style dump files with grid cell data, including
|
||||
iso-surface images of the grid cell values.
|
||||
directly. With version 3.8 and above, OVITO can also read and visualize
|
||||
*grid* style dump files with grid cell data, including iso-surface
|
||||
images of the grid cell values.
|
||||
|
||||
Note that settings made via the :doc:`dump_modify <dump_modify>`
|
||||
command can also alter the format of individual values and content of
|
||||
@ -475,6 +478,24 @@ label). This option will help many visualization programs to guess bonds
|
||||
and colors. You can use the :doc:`dump_modify types labels <dump_modify>`
|
||||
option to replace numeric atom types with :doc:`type labels <Howto_type_labels>`.
|
||||
|
||||
.. versionadded:: TBD
|
||||
|
||||
The *extxyz* style writes XYZ files compatible with the Extended XYZ (or
|
||||
ExtXYZ) format as defined as defined in `the libAtoms specification
|
||||
<https://github.com/libAtoms/extxyz>`_. Specifically, the following
|
||||
information will be dumped:
|
||||
|
||||
* timestep
|
||||
* time, which can be disabled with :doc:`dump_modify time no <dump_modify>`
|
||||
* simulation box lattice and pbc conditions
|
||||
* atomic forces, which can be disabled with :doc:`dump_modify forces no <dump_modify>`
|
||||
* atomic velocities, which can be disabled with :doc:`dump_modify vel no <dump_modify>`
|
||||
* atomic masses, if enabled with :doc:`dump_modify mass yes <dump_modify>`
|
||||
|
||||
Dump style *extxyz* requires either that a :doc:`type label map for atoms types
|
||||
<labelmap>` is defined or :doc:`dump_modify element <dump_modify>` is used to
|
||||
set up an atom type number to atom name mapping.
|
||||
|
||||
.. versionadded:: 22Dec2022
|
||||
|
||||
The *grid/vtk* style writes VTK files for grid data on a regular
|
||||
@ -607,8 +628,8 @@ with the processor ID from :math:`0` to :math:`P-1`. For example,
|
||||
tmp.dump.% becomes tmp.dump.0, tmp.dump.1, ... tmp.dump.:math:`P-1`,
|
||||
etc. This creates smaller files and can be a fast mode of output on
|
||||
parallel machines that support parallel I/O for output. This option is
|
||||
**not** available for the *dcd*, *xtc*, *xyz*, *grid/vtk*, and *yaml*
|
||||
styles.
|
||||
**not** available for the *dcd*, *extxyz*, *xtc*, *xyz*, *grid/vtk*, and
|
||||
*yaml* styles.
|
||||
|
||||
By default, :math:`P` is the the number of processors, meaning one file per
|
||||
processor, but :math:`P` can be set to a smaller value via the *nfile* or
|
||||
@ -1017,9 +1038,9 @@ the COMPRESS package. They are only enabled if LAMMPS was built with
|
||||
that package. See the :doc:`Build package <Build_package>` page for
|
||||
more info.
|
||||
|
||||
The *xtc*, *dcd*, and *yaml* styles are part of the EXTRA-DUMP package.
|
||||
They are only enabled if LAMMPS was built with that package. See the
|
||||
:doc:`Build package <Build_package>` page for more info.
|
||||
The *dcd*, *extxyz*, *xtc*, and *yaml* styles are part of the EXTRA-DUMP
|
||||
package. They are only enabled if LAMMPS was built with that package.
|
||||
See the :doc:`Build package <Build_package>` page for more info.
|
||||
|
||||
Related commands
|
||||
""""""""""""""""
|
||||
|
||||
@ -92,6 +92,15 @@ Syntax
|
||||
|
||||
see the :doc:`dump image <dump_image>` doc page for details
|
||||
|
||||
* these keywords apply only to the extxyz dump style
|
||||
* keyword = *forces* or *mass* or *vel*
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
*forces* arg = *yes* or *no*
|
||||
*mass* arg = *yes* or *no*
|
||||
*vel* arg = *yes* or *no*
|
||||
|
||||
* these keywords apply only to the */gz* and */zstd* dump styles
|
||||
* keyword = *compression_level*
|
||||
|
||||
@ -972,9 +981,11 @@ The option defaults are
|
||||
* fileper = # of processors
|
||||
* first = no
|
||||
* flush = yes
|
||||
* forces = yes
|
||||
* format = %d and %g for each integer or floating point value
|
||||
* image = no
|
||||
* label = ENTRIES
|
||||
* mass = no
|
||||
* maxfiles = -1
|
||||
* nfile = 1
|
||||
* pad = 0
|
||||
@ -990,6 +1001,7 @@ The option defaults are
|
||||
* types = numeric
|
||||
* units = no
|
||||
* unwrap = no
|
||||
* vel = yes
|
||||
|
||||
* compression_level = 9 (gz variants)
|
||||
* compression_level = 0 (zstd variants)
|
||||
|
||||
2
src/.gitignore
vendored
2
src/.gitignore
vendored
@ -419,6 +419,8 @@
|
||||
/compute_hexorder_atom.h
|
||||
/dump_dcd.cpp
|
||||
/dump_dcd.h
|
||||
/dump_extxyz.cpp
|
||||
/dump_extxyz.h
|
||||
/fix_controller.cpp
|
||||
/fix_controller.h
|
||||
/fix_drag.cpp
|
||||
|
||||
296
src/EXTRA-DUMP/dump_extxyz.cpp
Normal file
296
src/EXTRA-DUMP/dump_extxyz.cpp
Normal file
@ -0,0 +1,296 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
LAMMPS development team: developers@lammps.org
|
||||
|
||||
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||
certain rights in this software. This software is distributed under
|
||||
the GNU General Public License.
|
||||
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "dump_extxyz.h"
|
||||
|
||||
#include "atom.h"
|
||||
#include "compute.h"
|
||||
#include "domain.h"
|
||||
#include "error.h"
|
||||
#include "label_map.h"
|
||||
#include "memory.h"
|
||||
#include "modify.h"
|
||||
#include "output.h"
|
||||
#include "thermo.h"
|
||||
#include "update.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
static constexpr int ONELINE = 512;
|
||||
static constexpr int DELTA = 1048576;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
DumpExtXYZ::DumpExtXYZ(LAMMPS *lmp, int narg, char **arg) :
|
||||
DumpXYZ(lmp, narg, arg), properties_string(nullptr)
|
||||
{
|
||||
// style specific customizable settings
|
||||
with_vel = 1;
|
||||
with_forces = 1;
|
||||
with_mass = 0;
|
||||
with_pe = 1;
|
||||
with_temp = 1;
|
||||
with_press = 0;
|
||||
|
||||
update_properties();
|
||||
|
||||
// We want simulation time by default
|
||||
time_flag = 1;
|
||||
|
||||
// dump may invoke computes
|
||||
clearstep = 1;
|
||||
|
||||
// use type labels by default if present
|
||||
if (atom->labelmapflag) {
|
||||
typenames = new char *[ntypes + 1];
|
||||
for (int itype = 1; itype <= ntypes; itype++) {
|
||||
typenames[itype] = utils::strdup(atom->lmap->typelabel[itype - 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void DumpExtXYZ::update_properties()
|
||||
{
|
||||
// How many per-atom elements we buffer
|
||||
size_one = 5 + (with_vel ? 3 : 0) + (with_forces ? 3 : 0) + (with_mass ? 1 : 0);
|
||||
|
||||
// The properties string
|
||||
delete[] properties_string;
|
||||
properties_string = utils::strdup(
|
||||
fmt::format("species:S:1:pos:R:3{}{}{}", (with_vel ? ":vel:R:3" : ""),
|
||||
(with_forces ? ":forces:R:3" : ""), (with_mass ? ":mass:R:1" : "")));
|
||||
|
||||
// The output printf-style format
|
||||
delete[] format;
|
||||
if (format_line_user)
|
||||
format = utils::strdup(fmt::format("{}\n", format_line_user));
|
||||
else {
|
||||
format = utils::strdup(fmt::format("%s %g %g %g{}{}{}\n", (with_vel ? " %g %g %g" : ""),
|
||||
(with_forces ? " %g %g %g" : ""), (with_mass ? " %g" : "")));
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void DumpExtXYZ::init_style()
|
||||
{
|
||||
if (!typenames)
|
||||
error->all(FLERR, Error::NOLASTLINE,
|
||||
"Must use either type lables or dump_modify element with dump style extxyz");
|
||||
|
||||
DumpXYZ::init_style();
|
||||
update_properties();
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
int DumpExtXYZ::modify_param(int narg, char **arg)
|
||||
{
|
||||
int rv = DumpXYZ::modify_param(narg, arg);
|
||||
if (rv > 0) return rv;
|
||||
|
||||
if (strcmp(arg[0], "vel") == 0) {
|
||||
if (narg < 2) error->all(FLERR, "Illegal dump_modify command");
|
||||
with_vel = utils::logical(FLERR, arg[1], false, lmp);
|
||||
update_properties();
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (strcmp(arg[0], "forces") == 0) {
|
||||
if (narg < 2) error->all(FLERR, "Illegal dump_modify command");
|
||||
with_forces = utils::logical(FLERR, arg[1], false, lmp);
|
||||
update_properties();
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (strcmp(arg[0], "mass") == 0) {
|
||||
if (narg < 2) error->all(FLERR, "Illegal dump_modify command");
|
||||
with_mass = utils::logical(FLERR, arg[1], false, lmp);
|
||||
update_properties();
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void DumpExtXYZ::write_header(bigint n)
|
||||
{
|
||||
if (me == 0) {
|
||||
if (!fp)
|
||||
error->one(FLERR, Error::NOLASTLINE, "Must not use 'run pre no' after creating a new dump");
|
||||
|
||||
std::string header = fmt::format("{}\nTimestep={}", n, update->ntimestep);
|
||||
if (time_flag) header += fmt::format(" Time={:.6f}", compute_time());
|
||||
header += fmt::format(" pbc=\"{} {} {}\"", domain->xperiodic ? "T" : "F",
|
||||
domain->yperiodic ? "T" : "F", domain->zperiodic ? "T" : "F");
|
||||
header +=
|
||||
fmt::format(" Lattice=\"{:g} {:g} {:g} {:g} {:g} {:g} {:g} {:g} {:g}\"", domain->xprd, 0.,
|
||||
0., domain->xy, domain->yprd, 0., domain->xz, domain->yz, domain->zprd);
|
||||
|
||||
if (output && output->thermo) {
|
||||
auto *pe = output->thermo->pe;
|
||||
if (pe) header += fmt::format(" Potential_energy={}", pe->compute_scalar());
|
||||
|
||||
auto *temp = output->thermo->temperature;
|
||||
if (temp) header += fmt::format(" Temperature={}", temp->compute_scalar());
|
||||
|
||||
auto *press = output->thermo->pressure;
|
||||
if (press) {
|
||||
press->compute_vector();
|
||||
header +=
|
||||
fmt::format(" Stress=\"{} {} {} {} {} {} {} {} {}\"", press->vector[0],
|
||||
press->vector[3], press->vector[4], press->vector[3], press->vector[1],
|
||||
press->vector[5], press->vector[4], press->vector[5], press->vector[2]);
|
||||
}
|
||||
}
|
||||
|
||||
header += fmt::format(" Properties={}", properties_string);
|
||||
utils::print(fp, header + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void DumpExtXYZ::pack(tagint *ids)
|
||||
{
|
||||
int m, n;
|
||||
|
||||
tagint *tag = atom->tag;
|
||||
int *type = atom->type;
|
||||
int *mask = atom->mask;
|
||||
double **x = atom->x;
|
||||
double **v = atom->v;
|
||||
double **f = atom->f;
|
||||
double *mass = atom->mass;
|
||||
double *rmass = atom->rmass;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
m = n = 0;
|
||||
for (int i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit) {
|
||||
buf[m++] = tag[i];
|
||||
buf[m++] = type[i];
|
||||
buf[m++] = x[i][0];
|
||||
buf[m++] = x[i][1];
|
||||
buf[m++] = x[i][2];
|
||||
if (with_vel) {
|
||||
buf[m++] = v[i][0];
|
||||
buf[m++] = v[i][1];
|
||||
buf[m++] = v[i][2];
|
||||
}
|
||||
if (with_forces) {
|
||||
buf[m++] = f[i][0];
|
||||
buf[m++] = f[i][1];
|
||||
buf[m++] = f[i][2];
|
||||
}
|
||||
if (with_mass) {
|
||||
if (rmass) {
|
||||
buf[m++] = rmass[i];
|
||||
} else {
|
||||
buf[m++] = mass[type[i]];
|
||||
}
|
||||
}
|
||||
|
||||
if (ids) ids[n++] = tag[i];
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
convert mybuf of doubles to one big formatted string in sbuf
|
||||
return -1 if strlen exceeds an int, since used as arg in MPI calls in Dump
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int DumpExtXYZ::convert_string(int n, double *mybuf)
|
||||
{
|
||||
int offset = 0;
|
||||
int m = 0;
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (offset + ONELINE > maxsbuf) {
|
||||
if ((bigint) maxsbuf + DELTA > MAXSMALLINT) return -1;
|
||||
maxsbuf += DELTA;
|
||||
memory->grow(sbuf, maxsbuf, "dump:sbuf");
|
||||
}
|
||||
|
||||
if (size_one == 5) {
|
||||
offset += snprintf(&sbuf[offset], maxsbuf - offset, format,
|
||||
typenames[static_cast<int>(mybuf[m + 1])], mybuf[m + 2], mybuf[m + 3],
|
||||
mybuf[m + 4]);
|
||||
} else if (size_one == 6) {
|
||||
offset += snprintf(&sbuf[offset], maxsbuf - offset, format,
|
||||
typenames[static_cast<int>(mybuf[m + 1])], mybuf[m + 2], mybuf[m + 3],
|
||||
mybuf[m + 4], mybuf[m + 5]);
|
||||
} else if (size_one == 8) {
|
||||
offset += snprintf(&sbuf[offset], maxsbuf - offset, format,
|
||||
typenames[static_cast<int>(mybuf[m + 1])], mybuf[m + 2], mybuf[m + 3],
|
||||
mybuf[m + 4], mybuf[m + 5], mybuf[m + 6], mybuf[m + 7]);
|
||||
} else if (size_one == 9) {
|
||||
offset += snprintf(&sbuf[offset], maxsbuf - offset, format,
|
||||
typenames[static_cast<int>(mybuf[m + 1])], mybuf[m + 2], mybuf[m + 3],
|
||||
mybuf[m + 4], mybuf[m + 5], mybuf[m + 6], mybuf[m + 7], mybuf[m + 8]);
|
||||
} else if (size_one == 11) {
|
||||
offset += snprintf(&sbuf[offset], maxsbuf - offset, format,
|
||||
typenames[static_cast<int>(mybuf[m + 1])], mybuf[m + 2], mybuf[m + 3],
|
||||
mybuf[m + 4], mybuf[m + 5], mybuf[m + 6], mybuf[m + 7], mybuf[m + 8],
|
||||
mybuf[m + 9], mybuf[m + 10]);
|
||||
} else if (size_one == 12) {
|
||||
offset += snprintf(&sbuf[offset], maxsbuf - offset, format,
|
||||
typenames[static_cast<int>(mybuf[m + 1])], mybuf[m + 2], mybuf[m + 3],
|
||||
mybuf[m + 4], mybuf[m + 5], mybuf[m + 6], mybuf[m + 7], mybuf[m + 8],
|
||||
mybuf[m + 9], mybuf[m + 10], mybuf[m + 11]);
|
||||
} else {
|
||||
error->all(FLERR, "Invalid value of size_one for dump extxyz format.");
|
||||
}
|
||||
m += size_one;
|
||||
}
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void DumpExtXYZ::write_lines(int n, double *mybuf)
|
||||
{
|
||||
int m = 0;
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (size_one == 5) {
|
||||
fprintf(fp, format, typenames[static_cast<int>(mybuf[m + 1])], mybuf[m + 2], mybuf[m + 3],
|
||||
mybuf[m + 4]);
|
||||
} else if (size_one == 6) {
|
||||
fprintf(fp, format, typenames[static_cast<int>(mybuf[m + 1])], mybuf[m + 2], mybuf[m + 3],
|
||||
mybuf[m + 4], mybuf[m + 5]);
|
||||
} else if (size_one == 8) {
|
||||
fprintf(fp, format, typenames[static_cast<int>(mybuf[m + 1])], mybuf[m + 2], mybuf[m + 3],
|
||||
mybuf[m + 4], mybuf[m + 5], mybuf[m + 6], mybuf[m + 7]);
|
||||
} else if (size_one == 9) {
|
||||
fprintf(fp, format, typenames[static_cast<int>(mybuf[m + 1])], mybuf[m + 2], mybuf[m + 3],
|
||||
mybuf[m + 4], mybuf[m + 5], mybuf[m + 6], mybuf[m + 7], mybuf[m + 8]);
|
||||
} else if (size_one == 11) {
|
||||
fprintf(fp, format, typenames[static_cast<int>(mybuf[m + 1])], mybuf[m + 2], mybuf[m + 3],
|
||||
mybuf[m + 4], mybuf[m + 5], mybuf[m + 6], mybuf[m + 7], mybuf[m + 8], mybuf[m + 9],
|
||||
mybuf[m + 10]);
|
||||
} else if (size_one == 12) {
|
||||
fprintf(fp, format, typenames[static_cast<int>(mybuf[m + 1])], mybuf[m + 2], mybuf[m + 3],
|
||||
mybuf[m + 4], mybuf[m + 5], mybuf[m + 6], mybuf[m + 7], mybuf[m + 8], mybuf[m + 9],
|
||||
mybuf[m + 10], mybuf[m + 11]);
|
||||
} else {
|
||||
error->all(FLERR, "Invalid value of size_one for dump extxyz format.");
|
||||
}
|
||||
m += size_one;
|
||||
}
|
||||
}
|
||||
50
src/EXTRA-DUMP/dump_extxyz.h
Normal file
50
src/EXTRA-DUMP/dump_extxyz.h
Normal file
@ -0,0 +1,50 @@
|
||||
/* -*- c++ -*- ----------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
LAMMPS development team: developers@lammps.org
|
||||
|
||||
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||
certain rights in this software. This software is distributed under
|
||||
the GNU General Public License.
|
||||
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef DUMP_CLASS
|
||||
// clang-format off
|
||||
DumpStyle(extxyz,DumpExtXYZ);
|
||||
// clang-format on
|
||||
#else
|
||||
|
||||
#ifndef LMP_DUMP_EXTXYZ_H
|
||||
#define LMP_DUMP_EXTXYZ_H
|
||||
|
||||
#include "dump_xyz.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
class DumpExtXYZ : public DumpXYZ {
|
||||
public:
|
||||
DumpExtXYZ(class LAMMPS *, int, char **);
|
||||
|
||||
protected:
|
||||
int with_vel;
|
||||
int with_forces;
|
||||
int with_mass;
|
||||
int with_pe;
|
||||
int with_temp;
|
||||
int with_press;
|
||||
char *properties_string;
|
||||
|
||||
void update_properties();
|
||||
void init_style() override;
|
||||
void write_header(bigint) override;
|
||||
void pack(tagint *) override;
|
||||
int convert_string(int, double *) override;
|
||||
int modify_param(int, char **) override;
|
||||
|
||||
void write_lines(int, double *) override;
|
||||
};
|
||||
} // namespace LAMMPS_NS
|
||||
#endif
|
||||
#endif
|
||||
@ -16,6 +16,7 @@
|
||||
|
||||
#include "atom.h"
|
||||
#include "error.h"
|
||||
#include "input.h"
|
||||
#include "label_map.h"
|
||||
#include "memory.h"
|
||||
#include "update.h"
|
||||
@ -32,8 +33,8 @@ static constexpr int DELTA = 1048576;
|
||||
DumpXYZ::DumpXYZ(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg),
|
||||
typenames(nullptr)
|
||||
{
|
||||
if (narg != 5) error->all(FLERR,"Illegal dump xyz command");
|
||||
if (binary || multiproc) error->all(FLERR,"Invalid dump xyz filename");
|
||||
if (narg != 5) error->all(FLERR, Error::NOPOINTER, "Illegal dump {} command", style);
|
||||
if (binary || multiproc) error->all(FLERR, 4, "Invalid dump {} filename", style);
|
||||
|
||||
size_one = 5;
|
||||
|
||||
@ -43,7 +44,6 @@ DumpXYZ::DumpXYZ(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg),
|
||||
sortcol = 0;
|
||||
|
||||
delete[] format_default;
|
||||
|
||||
format_default = utils::strdup("%s %g %g %g");
|
||||
|
||||
ntypes = atom->ntypes;
|
||||
@ -103,9 +103,16 @@ void DumpXYZ::init_style()
|
||||
|
||||
int DumpXYZ::modify_param(int narg, char **arg)
|
||||
{
|
||||
// determine argument offset, if possible
|
||||
int ioffset = 0;
|
||||
if (input->arg) {
|
||||
for (int i = 0; i < input->narg; ++i)
|
||||
if (input->arg[i] == arg[0]) ioffset = i;
|
||||
}
|
||||
|
||||
if (strcmp(arg[0],"element") == 0) {
|
||||
if (narg < ntypes+1)
|
||||
error->all(FLERR, "Dump modify element names do not match atom types");
|
||||
error->all(FLERR, ioffset, "Dump modify element names do not match number of atom types");
|
||||
|
||||
if (typenames) {
|
||||
for (int i = 1; i <= ntypes; i++)
|
||||
@ -120,11 +127,11 @@ int DumpXYZ::modify_param(int narg, char **arg)
|
||||
typenames[itype] = utils::strdup(arg[itype]);
|
||||
}
|
||||
|
||||
return ntypes+1;
|
||||
return ntypes + 1;
|
||||
}
|
||||
|
||||
if (strcmp(arg[0],"types") == 0) {
|
||||
if (narg < 2) error->all(FLERR,"Illegal dump_modify command");
|
||||
if (narg < 2) utils::missing_cmd_args(FLERR,"dump_modify types", error);
|
||||
|
||||
if (typenames) {
|
||||
for (int i = 1; i <= ntypes; i++)
|
||||
@ -138,8 +145,8 @@ int DumpXYZ::modify_param(int narg, char **arg)
|
||||
return 2;
|
||||
} else if (strcmp(arg[1],"labels") == 0) {
|
||||
if (!atom->labelmapflag)
|
||||
error->all(FLERR, "Label map must be defined when using 'types labels'");
|
||||
} else error->all(FLERR, "Illegal option for dump_modify 'types' keyword");
|
||||
error->all(FLERR, ioffset + 1, "Label map must be defined when using 'types labels'");
|
||||
} else error->all(FLERR, ioffset + 1, "Unknown option {} for dump_modify 'types' keyword", arg[1]);
|
||||
|
||||
typenames = new char*[ntypes+1];
|
||||
for (int itype = 1; itype <= ntypes; itype++) {
|
||||
@ -157,7 +164,7 @@ int DumpXYZ::modify_param(int narg, char **arg)
|
||||
void DumpXYZ::write_header(bigint n)
|
||||
{
|
||||
if (me == 0) {
|
||||
if (!fp) error->one(FLERR, "Must not use 'run pre no' after creating a new dump");
|
||||
if (!fp) error->one(FLERR, Error::NOLASTLINE, "Must not use 'run pre no' after creating a new dump");
|
||||
|
||||
auto header = fmt::format("{}\n Atoms. Timestep: {}", n, update->ntimestep);
|
||||
if (time_flag) header += fmt::format(" Time: {:.6f}", compute_time());
|
||||
|
||||
@ -43,7 +43,7 @@ class DumpXYZ : public Dump {
|
||||
typedef void (DumpXYZ::*FnPtrWrite)(int, double *);
|
||||
FnPtrWrite write_choice; // ptr to write data functions
|
||||
void write_string(int, double *);
|
||||
void write_lines(int, double *);
|
||||
virtual void write_lines(int, double *);
|
||||
};
|
||||
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
@ -23,6 +23,7 @@ namespace LAMMPS_NS {
|
||||
class LabelMap : protected Pointers {
|
||||
friend class AtomVec;
|
||||
friend class DumpCustom;
|
||||
friend class DumpExtXYZ;
|
||||
friend class DumpXYZ;
|
||||
friend class ReadData;
|
||||
|
||||
|
||||
@ -101,8 +101,8 @@ static char fmtbuf[512];
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
Thermo::Thermo(LAMMPS *_lmp, int narg, char **arg) :
|
||||
Pointers(_lmp), style(nullptr), vtype(nullptr), cache_mutex(nullptr), field2index(nullptr),
|
||||
argindex1(nullptr), argindex2(nullptr), temperature(nullptr), pressure(nullptr), pe(nullptr)
|
||||
Pointers(_lmp), style(nullptr), temperature(nullptr), pressure(nullptr), pe(nullptr),
|
||||
vtype(nullptr), cache_mutex(nullptr), field2index(nullptr), argindex1(nullptr), argindex2(nullptr)
|
||||
{
|
||||
style = utils::strdup(arg[0]);
|
||||
|
||||
|
||||
@ -21,8 +21,8 @@
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class Thermo : protected Pointers {
|
||||
friend class MinCG; // accesses compute_pe
|
||||
|
||||
friend class MinCG; // accesses compute_pe
|
||||
friend class DumpExtXYZ; // accesses compute_temp, compute_press, compute_pe
|
||||
public:
|
||||
char *style;
|
||||
int normflag; // 0 if do not normalize by atoms, 1 if normalize
|
||||
@ -57,6 +57,9 @@ class Thermo : protected Pointers {
|
||||
void set_line(int _nline) { nline = _nline; }
|
||||
void set_image_fname(const std::string &fname) { image_fname = fname; }
|
||||
|
||||
protected:
|
||||
class Compute *temperature, *pressure, *pe;
|
||||
|
||||
private:
|
||||
int nfield, nfield_initial;
|
||||
int *vtype;
|
||||
@ -104,7 +107,6 @@ class Thermo : protected Pointers {
|
||||
// Compute * = ptrs to the Compute objects
|
||||
|
||||
int index_temp, index_press_scalar, index_press_vector, index_pe;
|
||||
class Compute *temperature, *pressure, *pe;
|
||||
double press_tensor[3][3];
|
||||
|
||||
int ncompute; // # of Compute objects called by thermo
|
||||
|
||||
Reference in New Issue
Block a user