initial dummy version of fix_latte.cpp

This commit is contained in:
Steve Plimpton 2016-11-09 13:48:11 -07:00
parent a23b287a7a
commit 6f23f6535c
8 changed files with 487 additions and 3 deletions

View File

@ -0,0 +1,5 @@
# Settings that the LAMMPS build will import when this package is installed
latte_SYSINC =
latte_SYSLIB = -lgfortran
latte_SYSPATH =

View File

@ -0,0 +1,5 @@
# Settings that the LAMMPS build will import when this package library is used
latte_SYSINC =
latte_SYSLIB = -lifcore -lsvml -lompstub -limf
latte_SYSPATH = -L/opt/intel/fce/10.0.023/lib

33
lib/latte/README Normal file
View File

@ -0,0 +1,33 @@
This directory contains build settings for the LATTE library which
is required to use the LATTE package and its fix latte command in a
LAMMPS input script.
Information about the LATTE DFTB code can be found at ... The LATTE
developement effort is led by Anders Niklasson, etc at LANLS.
To download, build, and install LATTE as a library on your system,
follow these steps. We are working on scripts that will automate this
process.
Go to this web site: https://??? and download a current tarball. The
tarball you download is "latte-??.tgz", which can be unpacked in this
directory or wherever you wish:
tar xvfz latte*tgz
Note that if you unpack and build LATTE in this directory, when you
download a new LAMMPS tarball, the files you have added here will be
lost. So you likely want to build it somewhere else.
Build instructions for LATTE library ...
When you have successully built the LATTE library, you can build
LAMMPS with the LATTE package installed:
$ cd lammps/src
$ make yes-latte
$ make g++ (or whatever target you wish)
Note that the Makefile.lammps file in this directory is required to
allow the LAMMPS build to find the necessary LATTE files. You should
not normally need to edit this file.

67
src/LATTE/Install.sh Normal file
View File

@ -0,0 +1,67 @@
# 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
}
# all package files with no dependencies
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]*latte[^ \t]* //' ../Makefile.package
sed -i -e 's|^PKG_INC =[ \t]*|&-I../../lib/latte |' ../Makefile.package
sed -i -e 's|^PKG_PATH =[ \t]*|&-L../../lib/latte |' ../Makefile.package
#sed -i -e 's|^PKG_LIB =[ \t]*|&-llatte |' ../Makefile.package
sed -i -e 's|^PKG_SYSINC =[ \t]*|&$(latte_SYSINC) |' ../Makefile.package
sed -i -e 's|^PKG_SYSLIB =[ \t]*|&$(latte_SYSLIB) |' ../Makefile.package
sed -i -e 's|^PKG_SYSPATH =[ \t]*|&$(latte_SYSPATH) |' ../Makefile.package
fi
if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*latte.*$/d' ../Makefile.package.settings
# multiline form needed for BSD sed on Macs
sed -i -e '4 i \
include ..\/..\/lib\/latte\/Makefile.lammps
' ../Makefile.package.settings
fi
elif (test $1 = 0) then
if (test -e ../Makefile.package) then
sed -i -e 's/[^ \t]*latte[^ \t]* //' ../Makefile.package
fi
if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*latte.*$/d' ../Makefile.package.settings
fi
fi

28
src/LATTE/README Normal file
View File

@ -0,0 +1,28 @@
This package provides a fix latte command which is a wrapper on the
LATTE DFTB code, so that molecular dynamics can be run with LAMMPS
using density-functional tight-binding quantum forces calculated by
LATTE. More information on LATTE can be found at "web site". Its
authors are Anders Niklasson, etc at LANL.
Using this package requires the LATTE code to be downloaded and built
as a library on your system. The library can be downloaded and built
in lib/latte or elsewhere on your system, which must be done before
building LAMMPS with this package. Details of the download, build, and
install process for LATTE are given in the lib/latte/README file, and
scripts are provided to help automate the process.
Also see the LAMMPS manual for general information on building LAMMPS
with external libraries. The settings in the Makefile.lammps file in
lib/latte must be correct for LAMMPS to build correctly with this
package installed. However, the default settings should be correct in
most cases and the Makefile.lammps file usually will not need to be
changed.
Once you have successfully built LAMMPS with this package and the
LATTE library you can test it using an input file from the examples
dir:
./lmp_serial < lammps/examples/latte/in.latte
This pair style was written in collaboration with the LATTE
developers.

283
src/LATTE/fix_latte.cpp Normal file
View File

@ -0,0 +1,283 @@
/* ----------------------------------------------------------------------
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.
------------------------------------------------------------------------- */
#include <stdio.h>
#include <string.h>
#include "fix_latte.h"
#include "atom.h"
#include "force.h"
#include "update.h"
#include "neighbor.h"
#include "neigh_request.h"
#include "neigh_list.h"
#include "modify.h"
#include "compute.h"
#include "comm.h"
#include "error.h"
using namespace LAMMPS_NS;
using namespace FixConst;
#define INVOKED_PERATOM 8
/* ---------------------------------------------------------------------- */
FixLatte::FixLatte(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg)
{
if (narg != 4) error->all(FLERR,"Illegal fix latte command");
// store pe/atom ID used for input of Coulomb potential to LATTE
// insure it is valid for these computations
int n = strlen(arg[3]) + 1;
id_pe = new char[n];
strcpy(id_pe,arg[3]);
int ipe = modify->find_compute(id_pe);
if (ipe < 0) error->all(FLERR,"Could not find fix latte compute ID");
if (modify->compute[ipe]->peatomflag == 0)
error->all(FLERR,"Fix latte compute ID does not compute pe/atom");
// initialize LATTE with LAMMPS info about box, atoms, atom types, etc ?
// may need to be done in init() ??
// any per-atom quantities to allocate/initialize for LAMMPS?
// i.e. quantities carried with atoms across timesteps ??
}
/* ---------------------------------------------------------------------- */
FixLatte::~FixLatte()
{
delete [] id_pe;
}
/* ---------------------------------------------------------------------- */
int FixLatte::setmask()
{
int mask = 0;
mask |= INITIAL_INTEGRATE;
mask |= FINAL_INTEGRATE;
mask |= POST_FORCE;
mask |= MIN_POST_FORCE;
mask |= THERMO_ENERGY;
return mask;
}
/* ---------------------------------------------------------------------- */
void FixLatte::init()
{
// error checks
int ipe = modify->find_compute(id_pe);
if (ipe < 0) error->all(FLERR,"Could not find fix latte compute ID");
c_pe = modify->compute[ipe];
// warn if any integrate fix comes after this one
// is it actually necessary for q(n) update to come after x,v update ??
int after = 0;
int flag = 0;
for (int i = 0; i < modify->nfix; i++) {
if (strcmp(id,modify->fix[i]->id) == 0) after = 1;
else if ((modify->fmask[i] & INITIAL_INTEGRATE) && after) flag = 1;
}
if (flag && comm->me == 0)
error->warning(FLERR,"Fix latte should come after all other "
"integration fixes");
// need a full neighbor list
// perpetual list, built whenever re-neighboring occurs
int irequest = neighbor->request(this,instance_me);
neighbor->requests[irequest]->pair = 0;
neighbor->requests[irequest]->fix = 1;
neighbor->requests[irequest]->half = 0;
neighbor->requests[irequest]->full = 1;
// integrator timesteps
dtv = update->dt;
dtf = 0.5 * update->dt * force->ftm2v;
// any more LATTE initialization to do ?
}
/* ---------------------------------------------------------------------- */
void FixLatte::init_list(int id, NeighList *ptr)
{
list = ptr;
}
/* ---------------------------------------------------------------------- */
void FixLatte::setup(int vflag)
{
post_force(vflag);
}
/* ---------------------------------------------------------------------- */
void FixLatte::min_setup(int vflag)
{
// for minimize, what about charge DOFs ??
post_force(vflag);
}
/* ----------------------------------------------------------------------
integrate electronic degrees of freedom
------------------------------------------------------------------------- */
void FixLatte::initial_integrate(int vflag)
{
// what do I do here for q(n) update?
// is it the same variable as LAMMPS q, I think so
// is it an Euler update or VV update ??
/*
double dtfm;
// update v and x of atoms in group
double **x = atom->x;
double **v = atom->v;
double **f = atom->f;
double *mass = atom->mass;
int *type = atom->type;
int *mask = atom->mask;
int nlocal = atom->nlocal;
if (igroup == atom->firstgroup) nlocal = atom->nfirst;
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
dtfm = dtf / mass[type[i]];
v[i][0] += dtfm * f[i][0];
v[i][1] += dtfm * f[i][1];
v[i][2] += dtfm * f[i][2];
x[i][0] += dtv * v[i][0];
x[i][1] += dtv * v[i][1];
x[i][2] += dtv * v[i][2];
}
*/
}
/* ---------------------------------------------------------------------- */
void FixLatte::post_force(int vflag)
{
// what should cutoffs be for passing neighlist info to LATTE ??
// do cutoffs include many self image atoms for tiny periodic system ??
int i,j,ii,jj,inum,jnum;
int *ilist,*jlist,*numneigh,**firstneigh;
inum = list->inum;
ilist = list->ilist;
numneigh = list->numneigh;
firstneigh = list->firstneigh;
for (ii = 0; ii < inum; ii++) {
i = ilist[ii];
jlist = firstneigh[i];
jnum = numneigh[i];
for (jj = 0; jj < jnum; jj++) {
j = jlist[jj];
j &= NEIGHMASK;
// enforce a different cutoff than pair style?
// what are optimal cutoffs for pair/Kspace for tiny system?
// operations on I/J pairs if necessary
}
}
// invoke compute pe/atom
// wrap with clear/add and trigger pe/atom calculation every step
// Coulomb potential should just be pe[i]/q[i] ??
modify->clearstep_compute();
if (!(c_pe->invoked_flag & INVOKED_PERATOM)) {
c_pe->compute_peratom();
c_pe->invoked_flag |= INVOKED_PERATOM;
}
double *pe = c_pe->vector_atom;
modify->addstep_compute(update->ntimestep+1);
// construct H0,S,Z
// setup full Hamiltonian H(R,n)
// calculate density matrix D and charge q(n)
// calculate DFTB forces via LATTE = F(R,H0,S,Z,D,q,n)
// how to pass neighbor list and Coulomb potential to LATTE ??
// HERE is where main call to LATTE goes to get forces
// simply add the returned forces to atom->f
// how to request/get global or per-atom energy back from LATTE ??
// how to request/get global or per-atom virial back from LATTE ??
}
/* ----------------------------------------------------------------------
integrate electronic degrees of freedom
------------------------------------------------------------------------- */
void FixLatte::final_integrate()
{
// possibly nothing to do here if Euler step of q(n) ??
/*
double dtfm;
// update v of atoms in group
double **v = atom->v;
double **f = atom->f;
double *mass = atom->mass;
int *type = atom->type;
int *mask = atom->mask;
int nlocal = atom->nlocal;
if (igroup == atom->firstgroup) nlocal = atom->nfirst;
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
dtfm = dtf / mass[type[i]];
v[i][0] += dtfm * f[i][0];
v[i][1] += dtfm * f[i][1];
v[i][2] += dtfm * f[i][2];
}
*/
}
/* ---------------------------------------------------------------------- */
void FixLatte::reset_dt()
{
// will we ever auto-adjust the timestep ??
dtv = update->dt;
dtf = 0.5 * update->dt * force->ftm2v;
}
/* ---------------------------------------------------------------------- */
double FixLatte::compute_scalar()
{
// return DFTB global energy
return 0.0;
}

63
src/LATTE/fix_latte.h Normal file
View File

@ -0,0 +1,63 @@
/* -*- c++ -*- ----------------------------------------------------------
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 FIX_CLASS
FixStyle(latte,FixLatte)
#else
#ifndef LMP_FIX_LATTE_H
#define LMP_FIX_LATTE_H
#include "fix.h"
namespace LAMMPS_NS {
class FixLatte : public Fix {
public:
FixLatte(class LAMMPS *, int, char **);
virtual ~FixLatte();
int setmask();
void init();
void init_list(int, class NeighList *);
void setup(int);
void min_setup(int);
void initial_integrate(int);
void post_force(int);
void final_integrate();
void reset_dt();
double compute_scalar();
protected:
double dtv,dtf;
char *id_pe;
class NeighList *list;
class Compute *c_pe;
};
}
#endif
#endif
/* ERROR/WARNING messages:
E: Illegal ... command
Self-explanatory. Check the input script syntax and compare to the
documentation for the command. You can use -echo screen as a
command-line option when running LAMMPS to see the offending line.
*/

View File

@ -44,8 +44,8 @@ endif
# Package variables
PACKAGE = asphere body class2 colloid compress coreshell dipole gpu \
granular kim \
kokkos kspace manybody mc meam misc molecule mpiio opt peri poems \
granular kim kokkos kspace latte manybody mc meam misc \
molecule mpiio opt peri poems \
python qeq reax replica rigid shock snap srd voronoi
PACKUSER = user-atc user-awpmd user-cg-cmm user-colvars \
@ -55,7 +55,7 @@ PACKUSER = user-atc user-awpmd user-cg-cmm user-colvars \
user-quip user-reaxc user-smd user-smtbq user-sph user-tally \
user-vtk
PACKLIB = compress gpu kim kokkos meam mpiio poems python reax voronoi \
PACKLIB = compress gpu kim kokkos latte meam mpiio poems python reax voronoi \
user-atc user-awpmd user-colvars user-h5md user-lb user-molfile \
user-nc-dump user-qmmm user-quip user-smd user-vtk