import lammps-netcdf code as USER-NC-DUMP package

This commit is contained in:
Axel Kohlmeyer 2016-10-11 23:03:18 -04:00
parent 0eb7fbf34d
commit ecb03dd2df
8 changed files with 2622 additions and 1 deletions

View File

@ -0,0 +1,19 @@
# Settings that the LAMMPS build will import when a package using the
# netCDF library is installed. This tries to automate configuration
# via the nc-config tool, which is part of the netCDF installation.
ifeq ($(shell nc-config --has-pnetcdf),no)
netcdf_SYSINC = $(shell nc-config --cflags)
netcdf_SYSLIB = $(shell nc-config --libs)
netcdf_SYSPATH =
endif
ifeq ($(shell nc-config --has-pnetcdf),yes)
netcdf_SYSINC = -DLMP_HAS_PNETCDF $(nc-config --cflags)
netcdf_SYSLIB = $(shell nc-config --libs)
netcdf_SYSPATH =
endif

View File

@ -57,7 +57,7 @@ PACKUSER = user-atc user-awpmd user-cg-cmm user-colvars \
PACKLIB = compress gpu kim kokkos meam mpiio poems python reax voronoi \
user-atc user-awpmd user-colvars user-h5md user-lb user-molfile \
user-qmmm user-quip user-vtk
user-nc-dump user-qmmm user-quip user-vtk
PACKALL = $(PACKAGE) $(PACKUSER)

View File

@ -0,0 +1,63 @@
# Install/unInstall package files in LAMMPS
# mode = 0/1/2 for uninstall/install/update
mode=$1
# enforce using portable C locale
LC_ALL=C
export LC_ALL
# arg1 = file, arg2 = file it depends on
action () {
if (test $mode = 0) then
rm -f ../$1
elif (! cmp -s $1 ../$1) then
if (test -z "$2" || test -e ../$2) then
cp $1 ..
if (test $mode = 2) then
echo " updating src/$1"
fi
fi
elif (test -n "$2") then
if (test ! -e ../$2) then
rm -f ../$1
fi
fi
}
for file in *.cpp *.h; do
action $file
done
# edit 2 Makefile.package files to include/exclude package info
if (test $1 = 1) then
if (test -e ../Makefile.package) then
sed -i -e 's/[^ \t]*netcdf[^ \t]* //g' ../Makefile.package
sed -i -e 's|^PKG_SYSINC =[ \t]*|&$(netcdf_SYSINC) |' ../Makefile.package
sed -i -e 's|^PKG_SYSLIB =[ \t]*|&$(netcdf_SYSLIB) |' ../Makefile.package
sed -i -e 's|^PKG_SYSPATH =[ \t]*|&$(netcdf_SYSPATH) |' ../Makefile.package
fi
if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*netcdf.*$/d' ../Makefile.package.settings
# multiline form needed for BSD sed on Macs
sed -i -e '4 i \
include ..\/..\/lib\/netcdf\/Makefile.lammps
' ../Makefile.package.settings
fi
elif (test $1 = 0) then
if (test -e ../Makefile.package) then
sed -i -e 's/[^ \t]*netcdf[^ \t]* //g' ../Makefile.package
fi
if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*netcdf.*$/d' ../Makefile.package.settings
fi
fi

37
src/USER-NC-DUMP/README Normal file
View File

@ -0,0 +1,37 @@
USER-NC-DUMP
============
This package provides the nc and (optionally) the nc/mpiio dump styles.
PACKAGE DESCRIPTION
-------------------
This is a LAMMPS (http://lammps.sandia.gov/) dump style for output into a NetCDF
database. The database format follows the AMBER NetCDF trajectory convention
(http://ambermd.org/netcdf/nctraj.xhtml), but includes extensions to this
convention. These extension are:
* A variable "cell_origin" (of dimension "frame", "cell_spatial") that contains
the bottom left corner of the simulation cell.
* Any number of additional variables corresponding to per atom scalar, vector
or tensor quantities available within LAMMPS. Tensor quantities are written in
Voigt notation. An additional dimension "Voigt" of length 6 is created for
this purpose.
* Possibility to output to an HDF5 database.
NetCDF files can be directly visualized with the following tools:
* Ovito (http://www.ovito.org/). Ovito supports the AMBER convention and all of
the above extensions.
* VMD (http://www.ks.uiuc.edu/Research/vmd/).
* AtomEye (http://www.libatoms.org/). The libAtoms version of AtomEye contains
a NetCDF reader that is not present in the standard distribution of AtomEye.
The person who created these files is Lars Pastewka at
Karlsruhe Institute of Technology (lars.pastewka@kit.edu).
Contact him directly if you have questions.
Lars Pastewka
Institute for Applied Materials (IAM)
Karlsruhe Institute of Technology (KIT)
Kaiserstraße 12, 76131 Karlsruhe
e-mail: lars.pastewka@kit.edu

1144
src/USER-NC-DUMP/dump_nc.cpp Normal file

File diff suppressed because it is too large Load Diff

141
src/USER-NC-DUMP/dump_nc.h Normal file
View File

@ -0,0 +1,141 @@
/* ======================================================================
LAMMPS NetCDF dump style
https://github.com/pastewka/lammps-netcdf
Lars Pastewka, lars.pastewka@kit.edu
Copyright (2011-2013) Fraunhofer IWM
Copyright (2014) Karlsruhe Institute of Technology
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
====================================================================== */
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
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
DumpStyle(nc,DumpNC)
#else
#ifndef LMP_DUMP_NC_H
#define LMP_DUMP_NC_H
#include "dump_custom.h"
namespace LAMMPS_NS {
const int NC_FIELD_NAME_MAX = 100;
const int DUMP_NC_MAX_DIMS = 100;
class DumpNC : public DumpCustom {
public:
DumpNC(class LAMMPS *, int, char **);
virtual ~DumpNC();
virtual void write();
private:
// per-atoms quantities (positions, velocities, etc.)
struct nc_perat_t {
int dims; // number of dimensions
int field[DUMP_NC_MAX_DIMS]; // field indices corresponding to the dim.
char name[NC_FIELD_NAME_MAX]; // field name
int var; // NetCDF variable
bool constant; // is this property per file (not per frame)
int ndumped; // number of enties written for this prop.
};
typedef void (DumpNC::*funcptr_t)(void *);
// per-frame quantities (variables, fixes or computes)
struct nc_perframe_t {
char name[NC_FIELD_NAME_MAX]; // field name
int var; // NetCDF variable
int type; // variable, fix, compute or callback
int index; // index in fix/compute list
funcptr_t compute; // compute function
int dim; // dimension
char id[NC_FIELD_NAME_MAX]; // variable id
bigint bigint_data; // actual data
double double_data; // actual data
};
int framei; // current frame index
int blocki; // current block index
int ndata; // number of data blocks to expect
bigint ntotalgr; // # of atoms
int n_perat; // # of netcdf per-atom properties
nc_perat_t *perat; // per-atom properties
int n_perframe; // # of global netcdf (not per-atom) fix props
nc_perframe_t *perframe; // global properties
bool double_precision; // write everything as double precision
bigint n_buffer; // size of buffer
int *int_buffer; // buffer for passing data to netcdf
double *double_buffer; // buffer for passing data to netcdf
int ncid;
int frame_dim;
int spatial_dim;
int Voigt_dim;
int atom_dim;
int cell_spatial_dim;
int cell_angular_dim;
int label_dim;
int spatial_var;
int cell_spatial_var;
int cell_angular_var;
int time_var;
int cell_origin_var;
int cell_lengths_var;
int cell_angles_var;
virtual void openfile();
void closefile();
virtual void write_header(bigint);
virtual void write_data(int, double *);
void write_prmtop();
virtual int modify_param(int, char **);
void ncerr(int, const char *, int);
void compute_step(void *);
void compute_elapsed(void *);
void compute_elapsed_long(void *);
};
}
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,140 @@
/* ======================================================================
LAMMPS NetCDF dump style
https://github.com/pastewka/lammps-netcdf
Lars Pastewka, lars.pastewka@kit.edu
Copyright (2011-2013) Fraunhofer IWM
Copyright (2014) Karlsruhe Institute of Technology
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
====================================================================== */
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
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.
------------------------------------------------------------------------- */
#if defined(LMP_HAS_PNETCDF)
#ifdef DUMP_CLASS
DumpStyle(nc/mpiio,DumpNCMPIIO)
#else
#ifndef LMP_DUMP_NC_MPIIO_H
#define LMP_DUMP_NC_MPIIO_H
#include "dump_custom.h"
namespace LAMMPS_NS {
const int NC_MPIIO_FIELD_NAME_MAX = 100;
const int DUMP_NC_MPIIO_MAX_DIMS = 100;
class DumpNCMPIIO : public DumpCustom {
public:
DumpNCMPIIO(class LAMMPS *, int, char **);
virtual ~DumpNCMPIIO();
virtual void write();
private:
// per-atoms quantities (positions, velocities, etc.)
struct nc_perat_t {
int dims; // number of dimensions
int field[DUMP_NC_MPIIO_MAX_DIMS]; // field indices corresponding to the dim.
char name[NC_MPIIO_FIELD_NAME_MAX]; // field name
int var; // NetCDF variable
};
typedef void (DumpNCMPIIO::*funcptr_t)(void *);
// per-frame quantities (variables, fixes or computes)
struct nc_perframe_t {
char name[NC_MPIIO_FIELD_NAME_MAX]; // field name
int var; // NetCDF variable
int type; // variable, fix, compute or callback
int index; // index in fix/compute list
funcptr_t compute; // compute function
int dim; // dimension
char id[NC_MPIIO_FIELD_NAME_MAX]; // variable id
bigint bigint_data; // actual data
double double_data; // actual data
};
int framei; // current frame index
int blocki; // current block index
int ndata; // number of data blocks to expect
bigint ntotalgr; // # of atoms
int n_perat; // # of netcdf per-atom properties
nc_perat_t *perat; // per-atom properties
int n_perframe; // # of global netcdf (not per-atom) fix props
nc_perframe_t *perframe; // global properties
bool double_precision; // write everything as double precision
bigint n_buffer; // size of buffer
int *int_buffer; // buffer for passing data to netcdf
double *double_buffer; // buffer for passing data to netcdf
int ncid;
int frame_dim;
int spatial_dim;
int Voigt_dim;
int atom_dim;
int cell_spatial_dim;
int cell_angular_dim;
int label_dim;
int spatial_var;
int cell_spatial_var;
int cell_angular_var;
int time_var;
int cell_origin_var;
int cell_lengths_var;
int cell_angles_var;
virtual void openfile();
void closefile();
void write_time_and_cell();
virtual void write_data(int, double *);
void write_prmtop();
virtual int modify_param(int, char **);
void ncerr(int, const char *, int);
void compute_step(void *);
void compute_elapsed(void *);
void compute_elapsed_long(void *);
};
}
#endif
#endif
#endif /* defined(LMP_HAS_PNETCDF) */