From 6f23f6535ce0768ff623b3b84b9dc99ea1dc4f2a Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Wed, 9 Nov 2016 13:48:11 -0700 Subject: [PATCH 01/41] initial dummy version of fix_latte.cpp --- lib/latte/Makefile.lammps.gfortran | 5 + lib/latte/Makefile.lammps.ifort | 5 + lib/latte/README | 33 ++++ src/LATTE/Install.sh | 67 +++++++ src/LATTE/README | 28 +++ src/LATTE/fix_latte.cpp | 283 +++++++++++++++++++++++++++++ src/LATTE/fix_latte.h | 63 +++++++ src/Makefile | 6 +- 8 files changed, 487 insertions(+), 3 deletions(-) create mode 100644 lib/latte/Makefile.lammps.gfortran create mode 100644 lib/latte/Makefile.lammps.ifort create mode 100644 lib/latte/README create mode 100644 src/LATTE/Install.sh create mode 100644 src/LATTE/README create mode 100644 src/LATTE/fix_latte.cpp create mode 100644 src/LATTE/fix_latte.h diff --git a/lib/latte/Makefile.lammps.gfortran b/lib/latte/Makefile.lammps.gfortran new file mode 100644 index 0000000000..0ad5b1ad01 --- /dev/null +++ b/lib/latte/Makefile.lammps.gfortran @@ -0,0 +1,5 @@ +# Settings that the LAMMPS build will import when this package is installed + +latte_SYSINC = +latte_SYSLIB = -lgfortran +latte_SYSPATH = diff --git a/lib/latte/Makefile.lammps.ifort b/lib/latte/Makefile.lammps.ifort new file mode 100644 index 0000000000..22b976ddc6 --- /dev/null +++ b/lib/latte/Makefile.lammps.ifort @@ -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 diff --git a/lib/latte/README b/lib/latte/README new file mode 100644 index 0000000000..423f47ac52 --- /dev/null +++ b/lib/latte/README @@ -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. diff --git a/src/LATTE/Install.sh b/src/LATTE/Install.sh new file mode 100644 index 0000000000..2fb34096c8 --- /dev/null +++ b/src/LATTE/Install.sh @@ -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 diff --git a/src/LATTE/README b/src/LATTE/README new file mode 100644 index 0000000000..e82480c865 --- /dev/null +++ b/src/LATTE/README @@ -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. diff --git a/src/LATTE/fix_latte.cpp b/src/LATTE/fix_latte.cpp new file mode 100644 index 0000000000..1ff45a869e --- /dev/null +++ b/src/LATTE/fix_latte.cpp @@ -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 +#include +#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; +} + diff --git a/src/LATTE/fix_latte.h b/src/LATTE/fix_latte.h new file mode 100644 index 0000000000..ebd738315d --- /dev/null +++ b/src/LATTE/fix_latte.h @@ -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. + +*/ diff --git a/src/Makefile b/src/Makefile index a5d0a326a4..9b64c395e9 100644 --- a/src/Makefile +++ b/src/Makefile @@ -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 From f3d6ecf07be360fb9c711ddd1b709fb66d46c3ac Mon Sep 17 00:00:00 2001 From: Christian Negre Date: Mon, 14 Nov 2016 07:58:47 -0700 Subject: [PATCH 02/41] changes for lattelib --- lib/latte/Makefile.lammps.gfortran | 23 ++++++++++++++++++++--- src/LATTE/fix_latte.cpp | 17 ++++++++++++++--- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/lib/latte/Makefile.lammps.gfortran b/lib/latte/Makefile.lammps.gfortran index 0ad5b1ad01..76913c6e5b 100644 --- a/lib/latte/Makefile.lammps.gfortran +++ b/lib/latte/Makefile.lammps.gfortran @@ -1,5 +1,22 @@ # Settings that the LAMMPS build will import when this package is installed +# Change all the flags and paths accordingly +# If using PROGRESS/BML set PROGRESS to ON +# For more information about these libraries see: +# BML: https://github.com/qmmd/bml +# PROGRESS: https://github.com/losalamos/qmd-progress +# METIS: + +latte_PATH = ${HOME}/exaalt/LATTE +progress_PATH = ${HOME}/qmd-progress +bml_PATH = ${HOME}/bml +metis_PATH = ${HOME}/Programs/metis-5.1.0 + +latte_SYSINC = -I${latte_PATH}/src -I${bml_PATH}/install/include -I${progress_PATH}/install/include +latte_SYSLIB = -fopenmp ${latte_PATH}/liblatte/latte_c_bind.o ${latte_PATH}/liblatte.a -lgfortran \ + -lm -Wl,--no-as-needed -L${MKLROOT}/lib/intel64 -lmkl_lapack95_lp64 -lmkl_gf_lp64 \ + -lmkl_gnu_thread -lmkl_core -lmkl_gnu_thread -lmkl_core -ldl -lpthread -lm + +# Uncomment the following line to use PROGRESS/BML +latte_SYSLIB += -L${progress_PATH}/install/lib -lprogress -L${bml_PATH}/install/lib -lbml -L${metis_PATH}/install -lmetis + -latte_SYSINC = -latte_SYSLIB = -lgfortran -latte_SYSPATH = diff --git a/src/LATTE/fix_latte.cpp b/src/LATTE/fix_latte.cpp index 1ff45a869e..d15ee59872 100644 --- a/src/LATTE/fix_latte.cpp +++ b/src/LATTE/fix_latte.cpp @@ -28,6 +28,10 @@ using namespace LAMMPS_NS; using namespace FixConst; + extern "C" { + void latte(int*, double*, int*, double*); + } + #define INVOKED_PERATOM 8 /* ---------------------------------------------------------------------- */ @@ -35,7 +39,7 @@ using namespace FixConst; FixLatte::FixLatte(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) { - if (narg != 4) error->all(FLERR,"Illegal fix latte command"); + if (narg != 5) 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 @@ -49,6 +53,8 @@ FixLatte::FixLatte(LAMMPS *lmp, int narg, char **arg) : if (modify->compute[ipe]->peatomflag == 0) error->all(FLERR,"Fix latte compute ID does not compute pe/atom"); +// latte(arg[4]); + // initialize LATTE with LAMMPS info about box, atoms, atom types, etc ? // may need to be done in init() ?? @@ -183,7 +189,7 @@ 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 i,j,ii,jj,inum,jnum; int *ilist,*jlist,*numneigh,**firstneigh; inum = list->inum; @@ -218,7 +224,11 @@ void FixLatte::post_force(int vflag) double *pe = c_pe->vector_atom; modify->addstep_compute(update->ntimestep+1); - +*/ + int natoms = (int) atom->natoms; + latte(&natoms,&atom->x[0][0],atom->type,&atom->f[0][0]); +// latte(&natoms,&atom->x[0][0],atom->type); + // construct H0,S,Z // setup full Hamiltonian H(R,n) // calculate density matrix D and charge q(n) @@ -281,3 +291,4 @@ double FixLatte::compute_scalar() return 0.0; } + From f040f15218d286ed74281206dff4160a732e0f75 Mon Sep 17 00:00:00 2001 From: Christian Negre Date: Mon, 14 Nov 2016 16:11:12 -0700 Subject: [PATCH 03/41] changes in latte makefile for lattelib and README --- lib/latte/Makefile.lammps.gfortran | 4 +-- lib/latte/README | 44 ++++++++++++++++++------------ 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/lib/latte/Makefile.lammps.gfortran b/lib/latte/Makefile.lammps.gfortran index 76913c6e5b..37003db31d 100644 --- a/lib/latte/Makefile.lammps.gfortran +++ b/lib/latte/Makefile.lammps.gfortran @@ -4,7 +4,7 @@ # For more information about these libraries see: # BML: https://github.com/qmmd/bml # PROGRESS: https://github.com/losalamos/qmd-progress -# METIS: +# METIS: http://glaros.dtc.umn.edu/gkhome/metis/metis/download latte_PATH = ${HOME}/exaalt/LATTE progress_PATH = ${HOME}/qmd-progress @@ -12,7 +12,7 @@ bml_PATH = ${HOME}/bml metis_PATH = ${HOME}/Programs/metis-5.1.0 latte_SYSINC = -I${latte_PATH}/src -I${bml_PATH}/install/include -I${progress_PATH}/install/include -latte_SYSLIB = -fopenmp ${latte_PATH}/liblatte/latte_c_bind.o ${latte_PATH}/liblatte.a -lgfortran \ +latte_SYSLIB = -fopenmp ${latte_PATH}/src/latte_c_bind.o ${latte_PATH}/liblatte.a -lgfortran \ -lm -Wl,--no-as-needed -L${MKLROOT}/lib/intel64 -lmkl_lapack95_lp64 -lmkl_gf_lp64 \ -lmkl_gnu_thread -lmkl_core -lmkl_gnu_thread -lmkl_core -ldl -lpthread -lm diff --git a/lib/latte/README b/lib/latte/README index 423f47ac52..3acd85095a 100644 --- a/lib/latte/README +++ b/lib/latte/README @@ -2,31 +2,41 @@ 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. +Information about the LATTE DFTB code can be found at: +https://github.com/losalamos/LATTE + +The LATTE development effort is led by Marc Cawkwell and +Anders Niklasson at Los Alamos National Laboratory. 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. +follow these steps: + +- Download or clone the LATTE source code from: + https://github.com/losalamos/LATTE. -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: +- Modify the makefile.CHOICES according to your system architecture + and compilers. + +- Set the MAKELIB flag to ON in makefile.CHOICES and finally, build the + code with the make command. -tar xvfz latte*tgz - -Note that if you unpack and build LATTE in this directory, when you +Note that if you unpack and build LATTE in this directory, if you download a new LAMMPS tarball, the files you have added here will be -lost. So you likely want to build it somewhere else. +lost. So you likely want to build it somewhere else. The recommended +place is the home directory. -Build instructions for LATTE library ... +To build LAMMPS with the LATTE library you should follow the following +instructions: -When you have successully built the LATTE library, you can build -LAMMPS with the LATTE package installed: +- makefile.lammps.* to makefile.lammps in the /lammps/lib/latte directory. -$ cd lammps/src -$ make yes-latte -$ make g++ (or whatever target you wish) +- Change the path, flags and compilers on the makefile.lammps according + to your compilers, architecture and the LATTE location. + +- Finally, you should execute the following commands: + $ 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 From fe99fc287d2f310d0bb6fc5d9e113671919283ed Mon Sep 17 00:00:00 2001 From: Christian Negre Date: Mon, 28 Nov 2016 15:29:37 -0700 Subject: [PATCH 04/41] changes in fix_latte --- lib/latte/Makefile.lammps.ifort | 25 +++++++++++++++++++++---- src/LATTE/fix_latte.cpp | 17 ++++++++++++++--- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/lib/latte/Makefile.lammps.ifort b/lib/latte/Makefile.lammps.ifort index 22b976ddc6..40637013f5 100644 --- a/lib/latte/Makefile.lammps.ifort +++ b/lib/latte/Makefile.lammps.ifort @@ -1,5 +1,22 @@ -# Settings that the LAMMPS build will import when this package library is used +# Settings that the LAMMPS build will import when this package is installed +# Change all the flags and paths accordingly +# If using PROGRESS/BML set PROGRESS to ON +# For more information about these libraries see: +# BML: https://github.com/qmmd/bml +# PROGRESS: https://github.com/losalamos/qmd-progress +# METIS: http://glaros.dtc.umn.edu/gkhome/metis/metis/download -latte_SYSINC = -latte_SYSLIB = -lifcore -lsvml -lompstub -limf -latte_SYSPATH = -L/opt/intel/fce/10.0.023/lib +latte_PATH = ${HOME}/exaalt/LATTE +progress_PATH = ${HOME}/qmd-progress +bml_PATH = ${HOME}/bml +metis_PATH = ${HOME}/Programs/metis-5.1.0 + +latte_SYSINC = -I${latte_PATH}/src -I${bml_PATH}/install/include -I${progress_PATH}/install/include +latte_SYSLIB = -openmp ${latte_PATH}/src/latte_c_bind.o ${latte_PATH}/liblatte.a \ + -lifcore -lsvml -lompstub -limf -L${MKLROOT}/lib/intel64 -lmkl_lapack95_lp64 -lmkl_intel_lp64 \ + -lmkl_intel_thread -lmkl_core -lmkl_intel_thread -lpthread -openmp -O0 \ +# Uncomment the following line to use PROGRESS/BML +latte_SYSLIB += -L${progress_PATH}/install/lib -lprogress -L${bml_PATH}/install/lib -lbml -L${metis_PATH}/install -lmetis + + +latte_SYSPATH = -L/opt/intel/composer_xe_2013_sp1.2.144/compiler/lib/intel64 diff --git a/src/LATTE/fix_latte.cpp b/src/LATTE/fix_latte.cpp index d15ee59872..60c9d5f4c2 100644 --- a/src/LATTE/fix_latte.cpp +++ b/src/LATTE/fix_latte.cpp @@ -18,6 +18,7 @@ #include "force.h" #include "update.h" #include "neighbor.h" +#include "domain.h" #include "neigh_request.h" #include "neigh_list.h" #include "modify.h" @@ -29,9 +30,9 @@ using namespace LAMMPS_NS; using namespace FixConst; extern "C" { - void latte(int*, double*, int*, double*); + void latte(int*, double*, int*, int*, double*, double*, double*, double*); } - + #define INVOKED_PERATOM 8 /* ---------------------------------------------------------------------- */ @@ -226,7 +227,17 @@ void FixLatte::post_force(int vflag) modify->addstep_compute(update->ntimestep+1); */ int natoms = (int) atom->natoms; - latte(&natoms,&atom->x[0][0],atom->type,&atom->f[0][0]); +// int* n1types -> (int) atom->ntypes; +// domain->boxlo; +// domain->boxhi; +// domain->boylo; +// domain->boyhi; +// domain->bozlo; +// domain->bozhi; +// double* lo = &domain->boxlo; + + latte(&natoms,&atom->x[0][0],atom->type,&atom->ntypes,&atom->mass[1], \ + &domain->boxlo[0],&domain->boxhi[0], &atom->f[0][0]); // latte(&natoms,&atom->x[0][0],atom->type); // construct H0,S,Z From 45b85b1686e42a8fc00471e896bbe2b67895b238 Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Thu, 1 Dec 2016 14:50:11 -0700 Subject: [PATCH 05/41] updated version of fix latte from SJP --- src/LATTE/fix_latte.cpp | 330 ++++++++++++++++++++++------------------ src/LATTE/fix_latte.h | 10 +- 2 files changed, 187 insertions(+), 153 deletions(-) diff --git a/src/LATTE/fix_latte.cpp b/src/LATTE/fix_latte.cpp index 60c9d5f4c2..c6269f4c21 100644 --- a/src/LATTE/fix_latte.cpp +++ b/src/LATTE/fix_latte.cpp @@ -11,27 +11,42 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ +// NOTES on possible future issues: +// LATTE compute and return 6-value virial tensor +// can LATTE compute per-atom energy and per-atom virial +// for minimize, what about charge DOFs +// implement charge DOF integration +// pass neighbor list to LATTE: half or full +// will we ever auto-adjust the timestep in reset_dt() +// could pass an input file to LATTE, specified in LAMMPS input script +// what units options can LAMMPS be using +// should LATTE take triclinic box from LAMMPS +// does Coulomb potential = pe[i]/q[i], is it 0 when q = 0 +// how will this work for serial/parallel LAMMPS with serial/parallel LATTE + #include #include #include "fix_latte.h" #include "atom.h" -#include "force.h" +#include "comm.h" #include "update.h" #include "neighbor.h" #include "domain.h" +#include "force.h" #include "neigh_request.h" #include "neigh_list.h" #include "modify.h" #include "compute.h" -#include "comm.h" +#include "memory.h" #include "error.h" using namespace LAMMPS_NS; using namespace FixConst; - extern "C" { - void latte(int*, double*, int*, int*, double*, double*, double*, double*); - } +extern "C" { + void latte(int *, int *, double *, int *, int *, + double *, double *, double *, double *, double *); +} #define INVOKED_PERATOM 8 @@ -40,27 +55,42 @@ using namespace FixConst; FixLatte::FixLatte(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) { - if (narg != 5) error->all(FLERR,"Illegal fix latte command"); + 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 + if (comm->nprocs != 1) + error->all(FLERR,"Fix latte currently runs only in serial"); - int n = strlen(arg[3]) + 1; - id_pe = new char[n]; - strcpy(id_pe,arg[3]); + scalar_flag = 1; + global_freq = 1; + extscalar = 1; + virial_flag = 1; - 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"); + // store ID of compute pe/atom used to generate Coulomb potential for LATTE + // NULL means LATTE will compute Coulombic potential -// latte(arg[4]); + coulomb = 0; + id_pe = NULL; - // initialize LATTE with LAMMPS info about box, atoms, atom types, etc ? - // may need to be done in init() ?? + if (strcmp(arg[3],"NULL") != 0) { + coulomb = 1; - // any per-atom quantities to allocate/initialize for LAMMPS? - // i.e. quantities carried with atoms across timesteps ?? + 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"); + } + + // initializations + + nmax = 0; + qpotential = NULL; + flatte = NULL; + + latte_energy = 0.0; } /* ---------------------------------------------------------------------- */ @@ -68,6 +98,8 @@ FixLatte::FixLatte(LAMMPS *lmp, int narg, char **arg) : FixLatte::~FixLatte() { delete [] id_pe; + memory->destroy(qpotential); + memory->destroy(flatte); } /* ---------------------------------------------------------------------- */ @@ -75,8 +107,9 @@ FixLatte::~FixLatte() int FixLatte::setmask() { int mask = 0; - mask |= INITIAL_INTEGRATE; - mask |= FINAL_INTEGRATE; + //mask |= INITIAL_INTEGRATE; + //mask |= FINAL_INTEGRATE; + mask |= PRE_REVERSE; mask |= POST_FORCE; mask |= MIN_POST_FORCE; mask |= THERMO_ENERGY; @@ -89,10 +122,34 @@ 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]; + if (domain->dimension == 2) + error->all(FLERR,"Fix latte requires 3d problem"); + if (coulomb) { + if (atom->q_flag == 0 || force->pair == NULL || force->kspace == NULL) + error->all(FLERR,"Fix latte cannot compute Coulombic potential"); + + 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]; + } + + // must be fully periodic or fully non-periodic + + if (domain->nonperiodic == 0) pbcflag = 1; + else if (!domain->xperiodic && !domain->yperiodic && !domain->zperiodic) + pbcflag = 0; + else error->all(FLERR,"Fix latte requires 3d simulation"); + + // create qpotential & flatte if needed + // for now, assume nlocal will never change + + if (coulomb && qpotential == NULL) { + memory->create(qpotential,atom->nlocal,"latte:qpotential"); + memory->create(flatte,atom->nlocal,3,"latte:flatte"); + } + + /* // warn if any integrate fix comes after this one // is it actually necessary for q(n) update to come after x,v update ?? @@ -105,8 +162,11 @@ void FixLatte::init() if (flag && comm->me == 0) error->warning(FLERR,"Fix latte should come after all other " "integration fixes"); + */ + /* // need a full neighbor list + // could we use a half list? // perpetual list, built whenever re-neighboring occurs int irequest = neighbor->request(this,instance_me); @@ -114,20 +174,14 @@ void FixLatte::init() 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; + // list = ptr; } /* ---------------------------------------------------------------------- */ @@ -141,8 +195,6 @@ void FixLatte::setup(int vflag) void FixLatte::min_setup(int vflag) { - // for minimize, what about charge DOFs ?? - post_force(vflag); } @@ -150,156 +202,130 @@ void FixLatte::min_setup(int vflag) integrate electronic degrees of freedom ------------------------------------------------------------------------- */ -void FixLatte::initial_integrate(int vflag) +void FixLatte::initial_integrate(int vflag) {} + +/* ---------------------------------------------------------------------- + store eflag, so can use it in post_force to tally per-atom energies +------------------------------------------------------------------------- */ + +void FixLatte::pre_reverse(int eflag, 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]; - } - */ + eflag_caller = eflag; } /* ---------------------------------------------------------------------- */ 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 - } - } + int eflag = eflag_caller; + if (eflag || vflag) ev_setup(eflag,vflag); + else evflag = 0; + // compute Coulombic potential = pe[i]/q[i] // 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 (coulomb) { + modify->clearstep_compute(); - if (!(c_pe->invoked_flag & INVOKED_PERATOM)) { - c_pe->compute_peratom(); - c_pe->invoked_flag |= INVOKED_PERATOM; + if (!(c_pe->invoked_flag & INVOKED_PERATOM)) { + c_pe->compute_peratom(); + c_pe->invoked_flag |= INVOKED_PERATOM; + } + + modify->addstep_compute(update->ntimestep+1); + + double *pe = c_pe->vector_atom; + double *q = atom->q; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) + if (q[i]) qpotential[i] = pe[i]/q[i]; + else qpotential[i] = 0.0; } - double *pe = c_pe->vector_atom; + // hardwire these unsupported flags for now - modify->addstep_compute(update->ntimestep+1); -*/ - int natoms = (int) atom->natoms; -// int* n1types -> (int) atom->ntypes; -// domain->boxlo; -// domain->boxhi; -// domain->boylo; -// domain->boyhi; -// domain->bozlo; -// domain->bozhi; -// double* lo = &domain->boxlo; - - latte(&natoms,&atom->x[0][0],atom->type,&atom->ntypes,&atom->mass[1], \ - &domain->boxlo[0],&domain->boxhi[0], &atom->f[0][0]); -// latte(&natoms,&atom->x[0][0],atom->type); - - // 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 ?? + int coulombflag = 0; + pe_peratom = 0; + virial_global = 0; // set via vflag_global at some point + virial_peratom = 0; + neighflag = 0; - // HERE is where main call to LATTE goes to get forces + // set flags used by LATTE - // 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 ?? + int flags[6]; + + flags[0] = pbcflag; // 1 for fully periodic, 0 for fully non-periodic + flags[1] = coulombflag; // 1 for LAMMPS computes Coulombics, 0 for LATTE + flags[2] = pe_peratom; // 1 to return per-atom energies, 0 for no + flags[3] = virial_global; // 1 to return global virial 0 for no + flags[4] = virial_peratom; // 1 to return per-atom virial, 0 for no + flags[5] = neighflag; // 1 to pass neighbor list to LATTE, 0 for no + + // setup LATTE arguments + + int natoms = atom->nlocal; + double *coords = &atom->x[0][0]; + int *type = atom->type; + int ntypes = atom->ntypes; + double *mass = &atom->mass[1]; + double *boxlo = domain->boxlo; + double *boxhi = domain->boxhi; + + double *forces; + if (coulomb) forces = &flatte[0][0]; + else forces = &atom->f[0][0]; + + // invoke LATTE + + latte(flags,&natoms,coords,type,&ntypes,mass,boxlo,boxhi, + forces,&latte_energy); + + // sum LATTE forces to LAMMPS (Coulombic) forces + + if (coulomb) { + double **f = atom->f; + int nlocal = atom->nlocal; + for (int i = 0; i < nlocal; i++) { + f[i][0] += flatte[i][0]; + f[i][1] += flatte[i][1]; + f[i][2] += flatte[i][2]; + } + } } /* ---------------------------------------------------------------------- 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::final_integrate() {} /* ---------------------------------------------------------------------- */ void FixLatte::reset_dt() { - // will we ever auto-adjust the timestep ?? - - dtv = update->dt; - dtf = 0.5 * update->dt * force->ftm2v; + //dtv = update->dt; + //dtf = 0.5 * update->dt * force->ftm2v; } -/* ---------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + DFTB energy from LATTE +------------------------------------------------------------------------- */ double FixLatte::compute_scalar() { - // return DFTB global energy - return 0.0; + return latte_energy; } +/* ---------------------------------------------------------------------- + memory usage of local arrays +------------------------------------------------------------------------- */ +double FixLatte::memory_usage() +{ + double bytes = 0.0; + if (coulomb) bytes += nmax * sizeof(double); + if (coulomb) bytes += nmax*3 * sizeof(double); + return bytes; +} diff --git a/src/LATTE/fix_latte.h b/src/LATTE/fix_latte.h index ebd738315d..d0f2fdea3e 100644 --- a/src/LATTE/fix_latte.h +++ b/src/LATTE/fix_latte.h @@ -34,14 +34,22 @@ class FixLatte : public Fix { void setup(int); void min_setup(int); void initial_integrate(int); + void pre_reverse(int, int); void post_force(int); void final_integrate(); void reset_dt(); double compute_scalar(); + double memory_usage(); protected: - double dtv,dtf; char *id_pe; + int coulomb,pbcflag,pe_peratom,virial_global,virial_peratom,neighflag; + int eflag_caller; + + int nmax; + double *qpotential; + double **flatte; + double latte_energy; class NeighList *list; class Compute *c_pe; From 5f78c2b6a50f4186d42f444984d7c5321874d262 Mon Sep 17 00:00:00 2001 From: Richard Zamora Date: Thu, 1 Dec 2016 15:14:47 -0700 Subject: [PATCH 06/41] test push --- test.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 test.txt diff --git a/test.txt b/test.txt new file mode 100644 index 0000000000..b089100527 --- /dev/null +++ b/test.txt @@ -0,0 +1 @@ +The creation of this file is for testing purposes only. From 031d4acde863f27316d90b61abdad3aa367e8895 Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Wed, 9 Nov 2016 13:48:11 -0700 Subject: [PATCH 07/41] initial dummy version of fix_latte.cpp --- lib/latte/Makefile.lammps.gfortran | 5 + lib/latte/Makefile.lammps.ifort | 5 + lib/latte/README | 33 ++++ src/LATTE/Install.sh | 67 +++++++ src/LATTE/README | 28 +++ src/LATTE/fix_latte.cpp | 283 +++++++++++++++++++++++++++++ src/LATTE/fix_latte.h | 63 +++++++ src/Makefile | 6 +- 8 files changed, 487 insertions(+), 3 deletions(-) create mode 100644 lib/latte/Makefile.lammps.gfortran create mode 100644 lib/latte/Makefile.lammps.ifort create mode 100644 lib/latte/README create mode 100644 src/LATTE/Install.sh create mode 100644 src/LATTE/README create mode 100644 src/LATTE/fix_latte.cpp create mode 100644 src/LATTE/fix_latte.h diff --git a/lib/latte/Makefile.lammps.gfortran b/lib/latte/Makefile.lammps.gfortran new file mode 100644 index 0000000000..0ad5b1ad01 --- /dev/null +++ b/lib/latte/Makefile.lammps.gfortran @@ -0,0 +1,5 @@ +# Settings that the LAMMPS build will import when this package is installed + +latte_SYSINC = +latte_SYSLIB = -lgfortran +latte_SYSPATH = diff --git a/lib/latte/Makefile.lammps.ifort b/lib/latte/Makefile.lammps.ifort new file mode 100644 index 0000000000..22b976ddc6 --- /dev/null +++ b/lib/latte/Makefile.lammps.ifort @@ -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 diff --git a/lib/latte/README b/lib/latte/README new file mode 100644 index 0000000000..423f47ac52 --- /dev/null +++ b/lib/latte/README @@ -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. diff --git a/src/LATTE/Install.sh b/src/LATTE/Install.sh new file mode 100644 index 0000000000..2fb34096c8 --- /dev/null +++ b/src/LATTE/Install.sh @@ -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 diff --git a/src/LATTE/README b/src/LATTE/README new file mode 100644 index 0000000000..e82480c865 --- /dev/null +++ b/src/LATTE/README @@ -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. diff --git a/src/LATTE/fix_latte.cpp b/src/LATTE/fix_latte.cpp new file mode 100644 index 0000000000..1ff45a869e --- /dev/null +++ b/src/LATTE/fix_latte.cpp @@ -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 +#include +#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; +} + diff --git a/src/LATTE/fix_latte.h b/src/LATTE/fix_latte.h new file mode 100644 index 0000000000..ebd738315d --- /dev/null +++ b/src/LATTE/fix_latte.h @@ -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. + +*/ diff --git a/src/Makefile b/src/Makefile index a5d0a326a4..9b64c395e9 100644 --- a/src/Makefile +++ b/src/Makefile @@ -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 From 765fe3cdfe678d9f5e089386f7150ee5a2d0eeed Mon Sep 17 00:00:00 2001 From: Christian Negre Date: Mon, 14 Nov 2016 07:58:47 -0700 Subject: [PATCH 08/41] changes for lattelib --- lib/latte/Makefile.lammps.gfortran | 23 ++++++++++++++++++++--- src/LATTE/fix_latte.cpp | 17 ++++++++++++++--- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/lib/latte/Makefile.lammps.gfortran b/lib/latte/Makefile.lammps.gfortran index 0ad5b1ad01..76913c6e5b 100644 --- a/lib/latte/Makefile.lammps.gfortran +++ b/lib/latte/Makefile.lammps.gfortran @@ -1,5 +1,22 @@ # Settings that the LAMMPS build will import when this package is installed +# Change all the flags and paths accordingly +# If using PROGRESS/BML set PROGRESS to ON +# For more information about these libraries see: +# BML: https://github.com/qmmd/bml +# PROGRESS: https://github.com/losalamos/qmd-progress +# METIS: + +latte_PATH = ${HOME}/exaalt/LATTE +progress_PATH = ${HOME}/qmd-progress +bml_PATH = ${HOME}/bml +metis_PATH = ${HOME}/Programs/metis-5.1.0 + +latte_SYSINC = -I${latte_PATH}/src -I${bml_PATH}/install/include -I${progress_PATH}/install/include +latte_SYSLIB = -fopenmp ${latte_PATH}/liblatte/latte_c_bind.o ${latte_PATH}/liblatte.a -lgfortran \ + -lm -Wl,--no-as-needed -L${MKLROOT}/lib/intel64 -lmkl_lapack95_lp64 -lmkl_gf_lp64 \ + -lmkl_gnu_thread -lmkl_core -lmkl_gnu_thread -lmkl_core -ldl -lpthread -lm + +# Uncomment the following line to use PROGRESS/BML +latte_SYSLIB += -L${progress_PATH}/install/lib -lprogress -L${bml_PATH}/install/lib -lbml -L${metis_PATH}/install -lmetis + -latte_SYSINC = -latte_SYSLIB = -lgfortran -latte_SYSPATH = diff --git a/src/LATTE/fix_latte.cpp b/src/LATTE/fix_latte.cpp index 1ff45a869e..d15ee59872 100644 --- a/src/LATTE/fix_latte.cpp +++ b/src/LATTE/fix_latte.cpp @@ -28,6 +28,10 @@ using namespace LAMMPS_NS; using namespace FixConst; + extern "C" { + void latte(int*, double*, int*, double*); + } + #define INVOKED_PERATOM 8 /* ---------------------------------------------------------------------- */ @@ -35,7 +39,7 @@ using namespace FixConst; FixLatte::FixLatte(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) { - if (narg != 4) error->all(FLERR,"Illegal fix latte command"); + if (narg != 5) 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 @@ -49,6 +53,8 @@ FixLatte::FixLatte(LAMMPS *lmp, int narg, char **arg) : if (modify->compute[ipe]->peatomflag == 0) error->all(FLERR,"Fix latte compute ID does not compute pe/atom"); +// latte(arg[4]); + // initialize LATTE with LAMMPS info about box, atoms, atom types, etc ? // may need to be done in init() ?? @@ -183,7 +189,7 @@ 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 i,j,ii,jj,inum,jnum; int *ilist,*jlist,*numneigh,**firstneigh; inum = list->inum; @@ -218,7 +224,11 @@ void FixLatte::post_force(int vflag) double *pe = c_pe->vector_atom; modify->addstep_compute(update->ntimestep+1); - +*/ + int natoms = (int) atom->natoms; + latte(&natoms,&atom->x[0][0],atom->type,&atom->f[0][0]); +// latte(&natoms,&atom->x[0][0],atom->type); + // construct H0,S,Z // setup full Hamiltonian H(R,n) // calculate density matrix D and charge q(n) @@ -281,3 +291,4 @@ double FixLatte::compute_scalar() return 0.0; } + From b912db5c73a155cc1cd1a18d4eab6111b6f908bb Mon Sep 17 00:00:00 2001 From: Christian Negre Date: Mon, 14 Nov 2016 16:11:12 -0700 Subject: [PATCH 09/41] changes in latte makefile for lattelib and README --- lib/latte/Makefile.lammps.gfortran | 4 +-- lib/latte/README | 44 ++++++++++++++++++------------ 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/lib/latte/Makefile.lammps.gfortran b/lib/latte/Makefile.lammps.gfortran index 76913c6e5b..37003db31d 100644 --- a/lib/latte/Makefile.lammps.gfortran +++ b/lib/latte/Makefile.lammps.gfortran @@ -4,7 +4,7 @@ # For more information about these libraries see: # BML: https://github.com/qmmd/bml # PROGRESS: https://github.com/losalamos/qmd-progress -# METIS: +# METIS: http://glaros.dtc.umn.edu/gkhome/metis/metis/download latte_PATH = ${HOME}/exaalt/LATTE progress_PATH = ${HOME}/qmd-progress @@ -12,7 +12,7 @@ bml_PATH = ${HOME}/bml metis_PATH = ${HOME}/Programs/metis-5.1.0 latte_SYSINC = -I${latte_PATH}/src -I${bml_PATH}/install/include -I${progress_PATH}/install/include -latte_SYSLIB = -fopenmp ${latte_PATH}/liblatte/latte_c_bind.o ${latte_PATH}/liblatte.a -lgfortran \ +latte_SYSLIB = -fopenmp ${latte_PATH}/src/latte_c_bind.o ${latte_PATH}/liblatte.a -lgfortran \ -lm -Wl,--no-as-needed -L${MKLROOT}/lib/intel64 -lmkl_lapack95_lp64 -lmkl_gf_lp64 \ -lmkl_gnu_thread -lmkl_core -lmkl_gnu_thread -lmkl_core -ldl -lpthread -lm diff --git a/lib/latte/README b/lib/latte/README index 423f47ac52..3acd85095a 100644 --- a/lib/latte/README +++ b/lib/latte/README @@ -2,31 +2,41 @@ 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. +Information about the LATTE DFTB code can be found at: +https://github.com/losalamos/LATTE + +The LATTE development effort is led by Marc Cawkwell and +Anders Niklasson at Los Alamos National Laboratory. 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. +follow these steps: + +- Download or clone the LATTE source code from: + https://github.com/losalamos/LATTE. -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: +- Modify the makefile.CHOICES according to your system architecture + and compilers. + +- Set the MAKELIB flag to ON in makefile.CHOICES and finally, build the + code with the make command. -tar xvfz latte*tgz - -Note that if you unpack and build LATTE in this directory, when you +Note that if you unpack and build LATTE in this directory, if you download a new LAMMPS tarball, the files you have added here will be -lost. So you likely want to build it somewhere else. +lost. So you likely want to build it somewhere else. The recommended +place is the home directory. -Build instructions for LATTE library ... +To build LAMMPS with the LATTE library you should follow the following +instructions: -When you have successully built the LATTE library, you can build -LAMMPS with the LATTE package installed: +- makefile.lammps.* to makefile.lammps in the /lammps/lib/latte directory. -$ cd lammps/src -$ make yes-latte -$ make g++ (or whatever target you wish) +- Change the path, flags and compilers on the makefile.lammps according + to your compilers, architecture and the LATTE location. + +- Finally, you should execute the following commands: + $ 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 From d43bd57a40d956157ce6e49bb43a86b4d1866cae Mon Sep 17 00:00:00 2001 From: Christian Negre Date: Mon, 28 Nov 2016 15:29:37 -0700 Subject: [PATCH 10/41] changes in fix_latte --- lib/latte/Makefile.lammps.ifort | 25 +++++++++++++++++++++---- src/LATTE/fix_latte.cpp | 17 ++++++++++++++--- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/lib/latte/Makefile.lammps.ifort b/lib/latte/Makefile.lammps.ifort index 22b976ddc6..40637013f5 100644 --- a/lib/latte/Makefile.lammps.ifort +++ b/lib/latte/Makefile.lammps.ifort @@ -1,5 +1,22 @@ -# Settings that the LAMMPS build will import when this package library is used +# Settings that the LAMMPS build will import when this package is installed +# Change all the flags and paths accordingly +# If using PROGRESS/BML set PROGRESS to ON +# For more information about these libraries see: +# BML: https://github.com/qmmd/bml +# PROGRESS: https://github.com/losalamos/qmd-progress +# METIS: http://glaros.dtc.umn.edu/gkhome/metis/metis/download -latte_SYSINC = -latte_SYSLIB = -lifcore -lsvml -lompstub -limf -latte_SYSPATH = -L/opt/intel/fce/10.0.023/lib +latte_PATH = ${HOME}/exaalt/LATTE +progress_PATH = ${HOME}/qmd-progress +bml_PATH = ${HOME}/bml +metis_PATH = ${HOME}/Programs/metis-5.1.0 + +latte_SYSINC = -I${latte_PATH}/src -I${bml_PATH}/install/include -I${progress_PATH}/install/include +latte_SYSLIB = -openmp ${latte_PATH}/src/latte_c_bind.o ${latte_PATH}/liblatte.a \ + -lifcore -lsvml -lompstub -limf -L${MKLROOT}/lib/intel64 -lmkl_lapack95_lp64 -lmkl_intel_lp64 \ + -lmkl_intel_thread -lmkl_core -lmkl_intel_thread -lpthread -openmp -O0 \ +# Uncomment the following line to use PROGRESS/BML +latte_SYSLIB += -L${progress_PATH}/install/lib -lprogress -L${bml_PATH}/install/lib -lbml -L${metis_PATH}/install -lmetis + + +latte_SYSPATH = -L/opt/intel/composer_xe_2013_sp1.2.144/compiler/lib/intel64 diff --git a/src/LATTE/fix_latte.cpp b/src/LATTE/fix_latte.cpp index d15ee59872..60c9d5f4c2 100644 --- a/src/LATTE/fix_latte.cpp +++ b/src/LATTE/fix_latte.cpp @@ -18,6 +18,7 @@ #include "force.h" #include "update.h" #include "neighbor.h" +#include "domain.h" #include "neigh_request.h" #include "neigh_list.h" #include "modify.h" @@ -29,9 +30,9 @@ using namespace LAMMPS_NS; using namespace FixConst; extern "C" { - void latte(int*, double*, int*, double*); + void latte(int*, double*, int*, int*, double*, double*, double*, double*); } - + #define INVOKED_PERATOM 8 /* ---------------------------------------------------------------------- */ @@ -226,7 +227,17 @@ void FixLatte::post_force(int vflag) modify->addstep_compute(update->ntimestep+1); */ int natoms = (int) atom->natoms; - latte(&natoms,&atom->x[0][0],atom->type,&atom->f[0][0]); +// int* n1types -> (int) atom->ntypes; +// domain->boxlo; +// domain->boxhi; +// domain->boylo; +// domain->boyhi; +// domain->bozlo; +// domain->bozhi; +// double* lo = &domain->boxlo; + + latte(&natoms,&atom->x[0][0],atom->type,&atom->ntypes,&atom->mass[1], \ + &domain->boxlo[0],&domain->boxhi[0], &atom->f[0][0]); // latte(&natoms,&atom->x[0][0],atom->type); // construct H0,S,Z From 16b15a636cfc1331780a6e796864110df74428d7 Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Thu, 1 Dec 2016 14:50:11 -0700 Subject: [PATCH 11/41] updated version of fix latte from SJP --- src/LATTE/fix_latte.cpp | 330 ++++++++++++++++++++++------------------ src/LATTE/fix_latte.h | 10 +- 2 files changed, 187 insertions(+), 153 deletions(-) diff --git a/src/LATTE/fix_latte.cpp b/src/LATTE/fix_latte.cpp index 60c9d5f4c2..c6269f4c21 100644 --- a/src/LATTE/fix_latte.cpp +++ b/src/LATTE/fix_latte.cpp @@ -11,27 +11,42 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ +// NOTES on possible future issues: +// LATTE compute and return 6-value virial tensor +// can LATTE compute per-atom energy and per-atom virial +// for minimize, what about charge DOFs +// implement charge DOF integration +// pass neighbor list to LATTE: half or full +// will we ever auto-adjust the timestep in reset_dt() +// could pass an input file to LATTE, specified in LAMMPS input script +// what units options can LAMMPS be using +// should LATTE take triclinic box from LAMMPS +// does Coulomb potential = pe[i]/q[i], is it 0 when q = 0 +// how will this work for serial/parallel LAMMPS with serial/parallel LATTE + #include #include #include "fix_latte.h" #include "atom.h" -#include "force.h" +#include "comm.h" #include "update.h" #include "neighbor.h" #include "domain.h" +#include "force.h" #include "neigh_request.h" #include "neigh_list.h" #include "modify.h" #include "compute.h" -#include "comm.h" +#include "memory.h" #include "error.h" using namespace LAMMPS_NS; using namespace FixConst; - extern "C" { - void latte(int*, double*, int*, int*, double*, double*, double*, double*); - } +extern "C" { + void latte(int *, int *, double *, int *, int *, + double *, double *, double *, double *, double *); +} #define INVOKED_PERATOM 8 @@ -40,27 +55,42 @@ using namespace FixConst; FixLatte::FixLatte(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) { - if (narg != 5) error->all(FLERR,"Illegal fix latte command"); + 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 + if (comm->nprocs != 1) + error->all(FLERR,"Fix latte currently runs only in serial"); - int n = strlen(arg[3]) + 1; - id_pe = new char[n]; - strcpy(id_pe,arg[3]); + scalar_flag = 1; + global_freq = 1; + extscalar = 1; + virial_flag = 1; - 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"); + // store ID of compute pe/atom used to generate Coulomb potential for LATTE + // NULL means LATTE will compute Coulombic potential -// latte(arg[4]); + coulomb = 0; + id_pe = NULL; - // initialize LATTE with LAMMPS info about box, atoms, atom types, etc ? - // may need to be done in init() ?? + if (strcmp(arg[3],"NULL") != 0) { + coulomb = 1; - // any per-atom quantities to allocate/initialize for LAMMPS? - // i.e. quantities carried with atoms across timesteps ?? + 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"); + } + + // initializations + + nmax = 0; + qpotential = NULL; + flatte = NULL; + + latte_energy = 0.0; } /* ---------------------------------------------------------------------- */ @@ -68,6 +98,8 @@ FixLatte::FixLatte(LAMMPS *lmp, int narg, char **arg) : FixLatte::~FixLatte() { delete [] id_pe; + memory->destroy(qpotential); + memory->destroy(flatte); } /* ---------------------------------------------------------------------- */ @@ -75,8 +107,9 @@ FixLatte::~FixLatte() int FixLatte::setmask() { int mask = 0; - mask |= INITIAL_INTEGRATE; - mask |= FINAL_INTEGRATE; + //mask |= INITIAL_INTEGRATE; + //mask |= FINAL_INTEGRATE; + mask |= PRE_REVERSE; mask |= POST_FORCE; mask |= MIN_POST_FORCE; mask |= THERMO_ENERGY; @@ -89,10 +122,34 @@ 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]; + if (domain->dimension == 2) + error->all(FLERR,"Fix latte requires 3d problem"); + if (coulomb) { + if (atom->q_flag == 0 || force->pair == NULL || force->kspace == NULL) + error->all(FLERR,"Fix latte cannot compute Coulombic potential"); + + 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]; + } + + // must be fully periodic or fully non-periodic + + if (domain->nonperiodic == 0) pbcflag = 1; + else if (!domain->xperiodic && !domain->yperiodic && !domain->zperiodic) + pbcflag = 0; + else error->all(FLERR,"Fix latte requires 3d simulation"); + + // create qpotential & flatte if needed + // for now, assume nlocal will never change + + if (coulomb && qpotential == NULL) { + memory->create(qpotential,atom->nlocal,"latte:qpotential"); + memory->create(flatte,atom->nlocal,3,"latte:flatte"); + } + + /* // warn if any integrate fix comes after this one // is it actually necessary for q(n) update to come after x,v update ?? @@ -105,8 +162,11 @@ void FixLatte::init() if (flag && comm->me == 0) error->warning(FLERR,"Fix latte should come after all other " "integration fixes"); + */ + /* // need a full neighbor list + // could we use a half list? // perpetual list, built whenever re-neighboring occurs int irequest = neighbor->request(this,instance_me); @@ -114,20 +174,14 @@ void FixLatte::init() 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; + // list = ptr; } /* ---------------------------------------------------------------------- */ @@ -141,8 +195,6 @@ void FixLatte::setup(int vflag) void FixLatte::min_setup(int vflag) { - // for minimize, what about charge DOFs ?? - post_force(vflag); } @@ -150,156 +202,130 @@ void FixLatte::min_setup(int vflag) integrate electronic degrees of freedom ------------------------------------------------------------------------- */ -void FixLatte::initial_integrate(int vflag) +void FixLatte::initial_integrate(int vflag) {} + +/* ---------------------------------------------------------------------- + store eflag, so can use it in post_force to tally per-atom energies +------------------------------------------------------------------------- */ + +void FixLatte::pre_reverse(int eflag, 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]; - } - */ + eflag_caller = eflag; } /* ---------------------------------------------------------------------- */ 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 - } - } + int eflag = eflag_caller; + if (eflag || vflag) ev_setup(eflag,vflag); + else evflag = 0; + // compute Coulombic potential = pe[i]/q[i] // 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 (coulomb) { + modify->clearstep_compute(); - if (!(c_pe->invoked_flag & INVOKED_PERATOM)) { - c_pe->compute_peratom(); - c_pe->invoked_flag |= INVOKED_PERATOM; + if (!(c_pe->invoked_flag & INVOKED_PERATOM)) { + c_pe->compute_peratom(); + c_pe->invoked_flag |= INVOKED_PERATOM; + } + + modify->addstep_compute(update->ntimestep+1); + + double *pe = c_pe->vector_atom; + double *q = atom->q; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) + if (q[i]) qpotential[i] = pe[i]/q[i]; + else qpotential[i] = 0.0; } - double *pe = c_pe->vector_atom; + // hardwire these unsupported flags for now - modify->addstep_compute(update->ntimestep+1); -*/ - int natoms = (int) atom->natoms; -// int* n1types -> (int) atom->ntypes; -// domain->boxlo; -// domain->boxhi; -// domain->boylo; -// domain->boyhi; -// domain->bozlo; -// domain->bozhi; -// double* lo = &domain->boxlo; - - latte(&natoms,&atom->x[0][0],atom->type,&atom->ntypes,&atom->mass[1], \ - &domain->boxlo[0],&domain->boxhi[0], &atom->f[0][0]); -// latte(&natoms,&atom->x[0][0],atom->type); - - // 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 ?? + int coulombflag = 0; + pe_peratom = 0; + virial_global = 0; // set via vflag_global at some point + virial_peratom = 0; + neighflag = 0; - // HERE is where main call to LATTE goes to get forces + // set flags used by LATTE - // 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 ?? + int flags[6]; + + flags[0] = pbcflag; // 1 for fully periodic, 0 for fully non-periodic + flags[1] = coulombflag; // 1 for LAMMPS computes Coulombics, 0 for LATTE + flags[2] = pe_peratom; // 1 to return per-atom energies, 0 for no + flags[3] = virial_global; // 1 to return global virial 0 for no + flags[4] = virial_peratom; // 1 to return per-atom virial, 0 for no + flags[5] = neighflag; // 1 to pass neighbor list to LATTE, 0 for no + + // setup LATTE arguments + + int natoms = atom->nlocal; + double *coords = &atom->x[0][0]; + int *type = atom->type; + int ntypes = atom->ntypes; + double *mass = &atom->mass[1]; + double *boxlo = domain->boxlo; + double *boxhi = domain->boxhi; + + double *forces; + if (coulomb) forces = &flatte[0][0]; + else forces = &atom->f[0][0]; + + // invoke LATTE + + latte(flags,&natoms,coords,type,&ntypes,mass,boxlo,boxhi, + forces,&latte_energy); + + // sum LATTE forces to LAMMPS (Coulombic) forces + + if (coulomb) { + double **f = atom->f; + int nlocal = atom->nlocal; + for (int i = 0; i < nlocal; i++) { + f[i][0] += flatte[i][0]; + f[i][1] += flatte[i][1]; + f[i][2] += flatte[i][2]; + } + } } /* ---------------------------------------------------------------------- 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::final_integrate() {} /* ---------------------------------------------------------------------- */ void FixLatte::reset_dt() { - // will we ever auto-adjust the timestep ?? - - dtv = update->dt; - dtf = 0.5 * update->dt * force->ftm2v; + //dtv = update->dt; + //dtf = 0.5 * update->dt * force->ftm2v; } -/* ---------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + DFTB energy from LATTE +------------------------------------------------------------------------- */ double FixLatte::compute_scalar() { - // return DFTB global energy - return 0.0; + return latte_energy; } +/* ---------------------------------------------------------------------- + memory usage of local arrays +------------------------------------------------------------------------- */ +double FixLatte::memory_usage() +{ + double bytes = 0.0; + if (coulomb) bytes += nmax * sizeof(double); + if (coulomb) bytes += nmax*3 * sizeof(double); + return bytes; +} diff --git a/src/LATTE/fix_latte.h b/src/LATTE/fix_latte.h index ebd738315d..d0f2fdea3e 100644 --- a/src/LATTE/fix_latte.h +++ b/src/LATTE/fix_latte.h @@ -34,14 +34,22 @@ class FixLatte : public Fix { void setup(int); void min_setup(int); void initial_integrate(int); + void pre_reverse(int, int); void post_force(int); void final_integrate(); void reset_dt(); double compute_scalar(); + double memory_usage(); protected: - double dtv,dtf; char *id_pe; + int coulomb,pbcflag,pe_peratom,virial_global,virial_peratom,neighflag; + int eflag_caller; + + int nmax; + double *qpotential; + double **flatte; + double latte_energy; class NeighList *list; class Compute *c_pe; From 544e23f9714f93dd06ebb2f6970e2cdfa37a7162 Mon Sep 17 00:00:00 2001 From: Richard Zamora Date: Thu, 1 Dec 2016 15:14:47 -0700 Subject: [PATCH 12/41] test push --- test.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 test.txt diff --git a/test.txt b/test.txt new file mode 100644 index 0000000000..b089100527 --- /dev/null +++ b/test.txt @@ -0,0 +1 @@ +The creation of this file is for testing purposes only. From 7eb05b33fb1d0ce909a2265dafa423f68602981c Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Wed, 9 Nov 2016 13:48:11 -0700 Subject: [PATCH 13/41] initial dummy version of fix_latte.cpp --- lib/latte/Makefile.lammps.gfortran | 5 + lib/latte/Makefile.lammps.ifort | 5 + lib/latte/README | 33 ++++ src/LATTE/Install.sh | 67 +++++++ src/LATTE/README | 28 +++ src/LATTE/fix_latte.cpp | 283 +++++++++++++++++++++++++++++ src/LATTE/fix_latte.h | 63 +++++++ src/Makefile | 6 +- 8 files changed, 487 insertions(+), 3 deletions(-) create mode 100644 lib/latte/Makefile.lammps.gfortran create mode 100644 lib/latte/Makefile.lammps.ifort create mode 100644 lib/latte/README create mode 100644 src/LATTE/Install.sh create mode 100644 src/LATTE/README create mode 100644 src/LATTE/fix_latte.cpp create mode 100644 src/LATTE/fix_latte.h diff --git a/lib/latte/Makefile.lammps.gfortran b/lib/latte/Makefile.lammps.gfortran new file mode 100644 index 0000000000..0ad5b1ad01 --- /dev/null +++ b/lib/latte/Makefile.lammps.gfortran @@ -0,0 +1,5 @@ +# Settings that the LAMMPS build will import when this package is installed + +latte_SYSINC = +latte_SYSLIB = -lgfortran +latte_SYSPATH = diff --git a/lib/latte/Makefile.lammps.ifort b/lib/latte/Makefile.lammps.ifort new file mode 100644 index 0000000000..22b976ddc6 --- /dev/null +++ b/lib/latte/Makefile.lammps.ifort @@ -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 diff --git a/lib/latte/README b/lib/latte/README new file mode 100644 index 0000000000..423f47ac52 --- /dev/null +++ b/lib/latte/README @@ -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. diff --git a/src/LATTE/Install.sh b/src/LATTE/Install.sh new file mode 100644 index 0000000000..2fb34096c8 --- /dev/null +++ b/src/LATTE/Install.sh @@ -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 diff --git a/src/LATTE/README b/src/LATTE/README new file mode 100644 index 0000000000..e82480c865 --- /dev/null +++ b/src/LATTE/README @@ -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. diff --git a/src/LATTE/fix_latte.cpp b/src/LATTE/fix_latte.cpp new file mode 100644 index 0000000000..1ff45a869e --- /dev/null +++ b/src/LATTE/fix_latte.cpp @@ -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 +#include +#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; +} + diff --git a/src/LATTE/fix_latte.h b/src/LATTE/fix_latte.h new file mode 100644 index 0000000000..ebd738315d --- /dev/null +++ b/src/LATTE/fix_latte.h @@ -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. + +*/ diff --git a/src/Makefile b/src/Makefile index a5d0a326a4..9b64c395e9 100644 --- a/src/Makefile +++ b/src/Makefile @@ -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 From e59552c2ecba489eb1c0a074208d61fb65416098 Mon Sep 17 00:00:00 2001 From: Christian Negre Date: Mon, 14 Nov 2016 07:58:47 -0700 Subject: [PATCH 14/41] changes for lattelib --- lib/latte/Makefile.lammps.gfortran | 23 ++++++++++++++++++++--- src/LATTE/fix_latte.cpp | 17 ++++++++++++++--- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/lib/latte/Makefile.lammps.gfortran b/lib/latte/Makefile.lammps.gfortran index 0ad5b1ad01..76913c6e5b 100644 --- a/lib/latte/Makefile.lammps.gfortran +++ b/lib/latte/Makefile.lammps.gfortran @@ -1,5 +1,22 @@ # Settings that the LAMMPS build will import when this package is installed +# Change all the flags and paths accordingly +# If using PROGRESS/BML set PROGRESS to ON +# For more information about these libraries see: +# BML: https://github.com/qmmd/bml +# PROGRESS: https://github.com/losalamos/qmd-progress +# METIS: + +latte_PATH = ${HOME}/exaalt/LATTE +progress_PATH = ${HOME}/qmd-progress +bml_PATH = ${HOME}/bml +metis_PATH = ${HOME}/Programs/metis-5.1.0 + +latte_SYSINC = -I${latte_PATH}/src -I${bml_PATH}/install/include -I${progress_PATH}/install/include +latte_SYSLIB = -fopenmp ${latte_PATH}/liblatte/latte_c_bind.o ${latte_PATH}/liblatte.a -lgfortran \ + -lm -Wl,--no-as-needed -L${MKLROOT}/lib/intel64 -lmkl_lapack95_lp64 -lmkl_gf_lp64 \ + -lmkl_gnu_thread -lmkl_core -lmkl_gnu_thread -lmkl_core -ldl -lpthread -lm + +# Uncomment the following line to use PROGRESS/BML +latte_SYSLIB += -L${progress_PATH}/install/lib -lprogress -L${bml_PATH}/install/lib -lbml -L${metis_PATH}/install -lmetis + -latte_SYSINC = -latte_SYSLIB = -lgfortran -latte_SYSPATH = diff --git a/src/LATTE/fix_latte.cpp b/src/LATTE/fix_latte.cpp index 1ff45a869e..d15ee59872 100644 --- a/src/LATTE/fix_latte.cpp +++ b/src/LATTE/fix_latte.cpp @@ -28,6 +28,10 @@ using namespace LAMMPS_NS; using namespace FixConst; + extern "C" { + void latte(int*, double*, int*, double*); + } + #define INVOKED_PERATOM 8 /* ---------------------------------------------------------------------- */ @@ -35,7 +39,7 @@ using namespace FixConst; FixLatte::FixLatte(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) { - if (narg != 4) error->all(FLERR,"Illegal fix latte command"); + if (narg != 5) 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 @@ -49,6 +53,8 @@ FixLatte::FixLatte(LAMMPS *lmp, int narg, char **arg) : if (modify->compute[ipe]->peatomflag == 0) error->all(FLERR,"Fix latte compute ID does not compute pe/atom"); +// latte(arg[4]); + // initialize LATTE with LAMMPS info about box, atoms, atom types, etc ? // may need to be done in init() ?? @@ -183,7 +189,7 @@ 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 i,j,ii,jj,inum,jnum; int *ilist,*jlist,*numneigh,**firstneigh; inum = list->inum; @@ -218,7 +224,11 @@ void FixLatte::post_force(int vflag) double *pe = c_pe->vector_atom; modify->addstep_compute(update->ntimestep+1); - +*/ + int natoms = (int) atom->natoms; + latte(&natoms,&atom->x[0][0],atom->type,&atom->f[0][0]); +// latte(&natoms,&atom->x[0][0],atom->type); + // construct H0,S,Z // setup full Hamiltonian H(R,n) // calculate density matrix D and charge q(n) @@ -281,3 +291,4 @@ double FixLatte::compute_scalar() return 0.0; } + From ef8d50733883c8f8c8d2014f016a2f2dbc7abc55 Mon Sep 17 00:00:00 2001 From: Christian Negre Date: Mon, 14 Nov 2016 16:11:12 -0700 Subject: [PATCH 15/41] changes in latte makefile for lattelib and README --- lib/latte/Makefile.lammps.gfortran | 4 +-- lib/latte/README | 44 ++++++++++++++++++------------ 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/lib/latte/Makefile.lammps.gfortran b/lib/latte/Makefile.lammps.gfortran index 76913c6e5b..37003db31d 100644 --- a/lib/latte/Makefile.lammps.gfortran +++ b/lib/latte/Makefile.lammps.gfortran @@ -4,7 +4,7 @@ # For more information about these libraries see: # BML: https://github.com/qmmd/bml # PROGRESS: https://github.com/losalamos/qmd-progress -# METIS: +# METIS: http://glaros.dtc.umn.edu/gkhome/metis/metis/download latte_PATH = ${HOME}/exaalt/LATTE progress_PATH = ${HOME}/qmd-progress @@ -12,7 +12,7 @@ bml_PATH = ${HOME}/bml metis_PATH = ${HOME}/Programs/metis-5.1.0 latte_SYSINC = -I${latte_PATH}/src -I${bml_PATH}/install/include -I${progress_PATH}/install/include -latte_SYSLIB = -fopenmp ${latte_PATH}/liblatte/latte_c_bind.o ${latte_PATH}/liblatte.a -lgfortran \ +latte_SYSLIB = -fopenmp ${latte_PATH}/src/latte_c_bind.o ${latte_PATH}/liblatte.a -lgfortran \ -lm -Wl,--no-as-needed -L${MKLROOT}/lib/intel64 -lmkl_lapack95_lp64 -lmkl_gf_lp64 \ -lmkl_gnu_thread -lmkl_core -lmkl_gnu_thread -lmkl_core -ldl -lpthread -lm diff --git a/lib/latte/README b/lib/latte/README index 423f47ac52..3acd85095a 100644 --- a/lib/latte/README +++ b/lib/latte/README @@ -2,31 +2,41 @@ 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. +Information about the LATTE DFTB code can be found at: +https://github.com/losalamos/LATTE + +The LATTE development effort is led by Marc Cawkwell and +Anders Niklasson at Los Alamos National Laboratory. 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. +follow these steps: + +- Download or clone the LATTE source code from: + https://github.com/losalamos/LATTE. -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: +- Modify the makefile.CHOICES according to your system architecture + and compilers. + +- Set the MAKELIB flag to ON in makefile.CHOICES and finally, build the + code with the make command. -tar xvfz latte*tgz - -Note that if you unpack and build LATTE in this directory, when you +Note that if you unpack and build LATTE in this directory, if you download a new LAMMPS tarball, the files you have added here will be -lost. So you likely want to build it somewhere else. +lost. So you likely want to build it somewhere else. The recommended +place is the home directory. -Build instructions for LATTE library ... +To build LAMMPS with the LATTE library you should follow the following +instructions: -When you have successully built the LATTE library, you can build -LAMMPS with the LATTE package installed: +- makefile.lammps.* to makefile.lammps in the /lammps/lib/latte directory. -$ cd lammps/src -$ make yes-latte -$ make g++ (or whatever target you wish) +- Change the path, flags and compilers on the makefile.lammps according + to your compilers, architecture and the LATTE location. + +- Finally, you should execute the following commands: + $ 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 From f209c8c129fee44f494a9e91042b245964e66865 Mon Sep 17 00:00:00 2001 From: Christian Negre Date: Mon, 28 Nov 2016 15:29:37 -0700 Subject: [PATCH 16/41] changes in fix_latte --- lib/latte/Makefile.lammps.ifort | 25 +++++++++++++++++++++---- src/LATTE/fix_latte.cpp | 17 ++++++++++++++--- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/lib/latte/Makefile.lammps.ifort b/lib/latte/Makefile.lammps.ifort index 22b976ddc6..40637013f5 100644 --- a/lib/latte/Makefile.lammps.ifort +++ b/lib/latte/Makefile.lammps.ifort @@ -1,5 +1,22 @@ -# Settings that the LAMMPS build will import when this package library is used +# Settings that the LAMMPS build will import when this package is installed +# Change all the flags and paths accordingly +# If using PROGRESS/BML set PROGRESS to ON +# For more information about these libraries see: +# BML: https://github.com/qmmd/bml +# PROGRESS: https://github.com/losalamos/qmd-progress +# METIS: http://glaros.dtc.umn.edu/gkhome/metis/metis/download -latte_SYSINC = -latte_SYSLIB = -lifcore -lsvml -lompstub -limf -latte_SYSPATH = -L/opt/intel/fce/10.0.023/lib +latte_PATH = ${HOME}/exaalt/LATTE +progress_PATH = ${HOME}/qmd-progress +bml_PATH = ${HOME}/bml +metis_PATH = ${HOME}/Programs/metis-5.1.0 + +latte_SYSINC = -I${latte_PATH}/src -I${bml_PATH}/install/include -I${progress_PATH}/install/include +latte_SYSLIB = -openmp ${latte_PATH}/src/latte_c_bind.o ${latte_PATH}/liblatte.a \ + -lifcore -lsvml -lompstub -limf -L${MKLROOT}/lib/intel64 -lmkl_lapack95_lp64 -lmkl_intel_lp64 \ + -lmkl_intel_thread -lmkl_core -lmkl_intel_thread -lpthread -openmp -O0 \ +# Uncomment the following line to use PROGRESS/BML +latte_SYSLIB += -L${progress_PATH}/install/lib -lprogress -L${bml_PATH}/install/lib -lbml -L${metis_PATH}/install -lmetis + + +latte_SYSPATH = -L/opt/intel/composer_xe_2013_sp1.2.144/compiler/lib/intel64 diff --git a/src/LATTE/fix_latte.cpp b/src/LATTE/fix_latte.cpp index d15ee59872..60c9d5f4c2 100644 --- a/src/LATTE/fix_latte.cpp +++ b/src/LATTE/fix_latte.cpp @@ -18,6 +18,7 @@ #include "force.h" #include "update.h" #include "neighbor.h" +#include "domain.h" #include "neigh_request.h" #include "neigh_list.h" #include "modify.h" @@ -29,9 +30,9 @@ using namespace LAMMPS_NS; using namespace FixConst; extern "C" { - void latte(int*, double*, int*, double*); + void latte(int*, double*, int*, int*, double*, double*, double*, double*); } - + #define INVOKED_PERATOM 8 /* ---------------------------------------------------------------------- */ @@ -226,7 +227,17 @@ void FixLatte::post_force(int vflag) modify->addstep_compute(update->ntimestep+1); */ int natoms = (int) atom->natoms; - latte(&natoms,&atom->x[0][0],atom->type,&atom->f[0][0]); +// int* n1types -> (int) atom->ntypes; +// domain->boxlo; +// domain->boxhi; +// domain->boylo; +// domain->boyhi; +// domain->bozlo; +// domain->bozhi; +// double* lo = &domain->boxlo; + + latte(&natoms,&atom->x[0][0],atom->type,&atom->ntypes,&atom->mass[1], \ + &domain->boxlo[0],&domain->boxhi[0], &atom->f[0][0]); // latte(&natoms,&atom->x[0][0],atom->type); // construct H0,S,Z From 07d9f9d66e19ca17a824e309f123272a26f9d3ad Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Thu, 1 Dec 2016 14:50:11 -0700 Subject: [PATCH 17/41] updated version of fix latte from SJP --- src/LATTE/fix_latte.cpp | 330 ++++++++++++++++++++++------------------ src/LATTE/fix_latte.h | 10 +- 2 files changed, 187 insertions(+), 153 deletions(-) diff --git a/src/LATTE/fix_latte.cpp b/src/LATTE/fix_latte.cpp index 60c9d5f4c2..c6269f4c21 100644 --- a/src/LATTE/fix_latte.cpp +++ b/src/LATTE/fix_latte.cpp @@ -11,27 +11,42 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ +// NOTES on possible future issues: +// LATTE compute and return 6-value virial tensor +// can LATTE compute per-atom energy and per-atom virial +// for minimize, what about charge DOFs +// implement charge DOF integration +// pass neighbor list to LATTE: half or full +// will we ever auto-adjust the timestep in reset_dt() +// could pass an input file to LATTE, specified in LAMMPS input script +// what units options can LAMMPS be using +// should LATTE take triclinic box from LAMMPS +// does Coulomb potential = pe[i]/q[i], is it 0 when q = 0 +// how will this work for serial/parallel LAMMPS with serial/parallel LATTE + #include #include #include "fix_latte.h" #include "atom.h" -#include "force.h" +#include "comm.h" #include "update.h" #include "neighbor.h" #include "domain.h" +#include "force.h" #include "neigh_request.h" #include "neigh_list.h" #include "modify.h" #include "compute.h" -#include "comm.h" +#include "memory.h" #include "error.h" using namespace LAMMPS_NS; using namespace FixConst; - extern "C" { - void latte(int*, double*, int*, int*, double*, double*, double*, double*); - } +extern "C" { + void latte(int *, int *, double *, int *, int *, + double *, double *, double *, double *, double *); +} #define INVOKED_PERATOM 8 @@ -40,27 +55,42 @@ using namespace FixConst; FixLatte::FixLatte(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) { - if (narg != 5) error->all(FLERR,"Illegal fix latte command"); + 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 + if (comm->nprocs != 1) + error->all(FLERR,"Fix latte currently runs only in serial"); - int n = strlen(arg[3]) + 1; - id_pe = new char[n]; - strcpy(id_pe,arg[3]); + scalar_flag = 1; + global_freq = 1; + extscalar = 1; + virial_flag = 1; - 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"); + // store ID of compute pe/atom used to generate Coulomb potential for LATTE + // NULL means LATTE will compute Coulombic potential -// latte(arg[4]); + coulomb = 0; + id_pe = NULL; - // initialize LATTE with LAMMPS info about box, atoms, atom types, etc ? - // may need to be done in init() ?? + if (strcmp(arg[3],"NULL") != 0) { + coulomb = 1; - // any per-atom quantities to allocate/initialize for LAMMPS? - // i.e. quantities carried with atoms across timesteps ?? + 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"); + } + + // initializations + + nmax = 0; + qpotential = NULL; + flatte = NULL; + + latte_energy = 0.0; } /* ---------------------------------------------------------------------- */ @@ -68,6 +98,8 @@ FixLatte::FixLatte(LAMMPS *lmp, int narg, char **arg) : FixLatte::~FixLatte() { delete [] id_pe; + memory->destroy(qpotential); + memory->destroy(flatte); } /* ---------------------------------------------------------------------- */ @@ -75,8 +107,9 @@ FixLatte::~FixLatte() int FixLatte::setmask() { int mask = 0; - mask |= INITIAL_INTEGRATE; - mask |= FINAL_INTEGRATE; + //mask |= INITIAL_INTEGRATE; + //mask |= FINAL_INTEGRATE; + mask |= PRE_REVERSE; mask |= POST_FORCE; mask |= MIN_POST_FORCE; mask |= THERMO_ENERGY; @@ -89,10 +122,34 @@ 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]; + if (domain->dimension == 2) + error->all(FLERR,"Fix latte requires 3d problem"); + if (coulomb) { + if (atom->q_flag == 0 || force->pair == NULL || force->kspace == NULL) + error->all(FLERR,"Fix latte cannot compute Coulombic potential"); + + 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]; + } + + // must be fully periodic or fully non-periodic + + if (domain->nonperiodic == 0) pbcflag = 1; + else if (!domain->xperiodic && !domain->yperiodic && !domain->zperiodic) + pbcflag = 0; + else error->all(FLERR,"Fix latte requires 3d simulation"); + + // create qpotential & flatte if needed + // for now, assume nlocal will never change + + if (coulomb && qpotential == NULL) { + memory->create(qpotential,atom->nlocal,"latte:qpotential"); + memory->create(flatte,atom->nlocal,3,"latte:flatte"); + } + + /* // warn if any integrate fix comes after this one // is it actually necessary for q(n) update to come after x,v update ?? @@ -105,8 +162,11 @@ void FixLatte::init() if (flag && comm->me == 0) error->warning(FLERR,"Fix latte should come after all other " "integration fixes"); + */ + /* // need a full neighbor list + // could we use a half list? // perpetual list, built whenever re-neighboring occurs int irequest = neighbor->request(this,instance_me); @@ -114,20 +174,14 @@ void FixLatte::init() 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; + // list = ptr; } /* ---------------------------------------------------------------------- */ @@ -141,8 +195,6 @@ void FixLatte::setup(int vflag) void FixLatte::min_setup(int vflag) { - // for minimize, what about charge DOFs ?? - post_force(vflag); } @@ -150,156 +202,130 @@ void FixLatte::min_setup(int vflag) integrate electronic degrees of freedom ------------------------------------------------------------------------- */ -void FixLatte::initial_integrate(int vflag) +void FixLatte::initial_integrate(int vflag) {} + +/* ---------------------------------------------------------------------- + store eflag, so can use it in post_force to tally per-atom energies +------------------------------------------------------------------------- */ + +void FixLatte::pre_reverse(int eflag, 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]; - } - */ + eflag_caller = eflag; } /* ---------------------------------------------------------------------- */ 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 - } - } + int eflag = eflag_caller; + if (eflag || vflag) ev_setup(eflag,vflag); + else evflag = 0; + // compute Coulombic potential = pe[i]/q[i] // 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 (coulomb) { + modify->clearstep_compute(); - if (!(c_pe->invoked_flag & INVOKED_PERATOM)) { - c_pe->compute_peratom(); - c_pe->invoked_flag |= INVOKED_PERATOM; + if (!(c_pe->invoked_flag & INVOKED_PERATOM)) { + c_pe->compute_peratom(); + c_pe->invoked_flag |= INVOKED_PERATOM; + } + + modify->addstep_compute(update->ntimestep+1); + + double *pe = c_pe->vector_atom; + double *q = atom->q; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) + if (q[i]) qpotential[i] = pe[i]/q[i]; + else qpotential[i] = 0.0; } - double *pe = c_pe->vector_atom; + // hardwire these unsupported flags for now - modify->addstep_compute(update->ntimestep+1); -*/ - int natoms = (int) atom->natoms; -// int* n1types -> (int) atom->ntypes; -// domain->boxlo; -// domain->boxhi; -// domain->boylo; -// domain->boyhi; -// domain->bozlo; -// domain->bozhi; -// double* lo = &domain->boxlo; - - latte(&natoms,&atom->x[0][0],atom->type,&atom->ntypes,&atom->mass[1], \ - &domain->boxlo[0],&domain->boxhi[0], &atom->f[0][0]); -// latte(&natoms,&atom->x[0][0],atom->type); - - // 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 ?? + int coulombflag = 0; + pe_peratom = 0; + virial_global = 0; // set via vflag_global at some point + virial_peratom = 0; + neighflag = 0; - // HERE is where main call to LATTE goes to get forces + // set flags used by LATTE - // 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 ?? + int flags[6]; + + flags[0] = pbcflag; // 1 for fully periodic, 0 for fully non-periodic + flags[1] = coulombflag; // 1 for LAMMPS computes Coulombics, 0 for LATTE + flags[2] = pe_peratom; // 1 to return per-atom energies, 0 for no + flags[3] = virial_global; // 1 to return global virial 0 for no + flags[4] = virial_peratom; // 1 to return per-atom virial, 0 for no + flags[5] = neighflag; // 1 to pass neighbor list to LATTE, 0 for no + + // setup LATTE arguments + + int natoms = atom->nlocal; + double *coords = &atom->x[0][0]; + int *type = atom->type; + int ntypes = atom->ntypes; + double *mass = &atom->mass[1]; + double *boxlo = domain->boxlo; + double *boxhi = domain->boxhi; + + double *forces; + if (coulomb) forces = &flatte[0][0]; + else forces = &atom->f[0][0]; + + // invoke LATTE + + latte(flags,&natoms,coords,type,&ntypes,mass,boxlo,boxhi, + forces,&latte_energy); + + // sum LATTE forces to LAMMPS (Coulombic) forces + + if (coulomb) { + double **f = atom->f; + int nlocal = atom->nlocal; + for (int i = 0; i < nlocal; i++) { + f[i][0] += flatte[i][0]; + f[i][1] += flatte[i][1]; + f[i][2] += flatte[i][2]; + } + } } /* ---------------------------------------------------------------------- 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::final_integrate() {} /* ---------------------------------------------------------------------- */ void FixLatte::reset_dt() { - // will we ever auto-adjust the timestep ?? - - dtv = update->dt; - dtf = 0.5 * update->dt * force->ftm2v; + //dtv = update->dt; + //dtf = 0.5 * update->dt * force->ftm2v; } -/* ---------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + DFTB energy from LATTE +------------------------------------------------------------------------- */ double FixLatte::compute_scalar() { - // return DFTB global energy - return 0.0; + return latte_energy; } +/* ---------------------------------------------------------------------- + memory usage of local arrays +------------------------------------------------------------------------- */ +double FixLatte::memory_usage() +{ + double bytes = 0.0; + if (coulomb) bytes += nmax * sizeof(double); + if (coulomb) bytes += nmax*3 * sizeof(double); + return bytes; +} diff --git a/src/LATTE/fix_latte.h b/src/LATTE/fix_latte.h index ebd738315d..d0f2fdea3e 100644 --- a/src/LATTE/fix_latte.h +++ b/src/LATTE/fix_latte.h @@ -34,14 +34,22 @@ class FixLatte : public Fix { void setup(int); void min_setup(int); void initial_integrate(int); + void pre_reverse(int, int); void post_force(int); void final_integrate(); void reset_dt(); double compute_scalar(); + double memory_usage(); protected: - double dtv,dtf; char *id_pe; + int coulomb,pbcflag,pe_peratom,virial_global,virial_peratom,neighflag; + int eflag_caller; + + int nmax; + double *qpotential; + double **flatte; + double latte_energy; class NeighList *list; class Compute *c_pe; From ee4d1b340b7c45ec8de2e819379b04ca03dab01f Mon Sep 17 00:00:00 2001 From: Richard Zamora Date: Thu, 1 Dec 2016 15:14:47 -0700 Subject: [PATCH 18/41] test push --- test.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 test.txt diff --git a/test.txt b/test.txt new file mode 100644 index 0000000000..b089100527 --- /dev/null +++ b/test.txt @@ -0,0 +1 @@ +The creation of this file is for testing purposes only. From a58f7631c09609bb4ab51dd1bfdabccb98c4b353 Mon Sep 17 00:00:00 2001 From: Christian Negre Date: Thu, 15 Dec 2016 10:57:02 -0700 Subject: [PATCH 19/41] fix_latte unpdated --- src/LATTE/fix_latte.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/LATTE/fix_latte.cpp b/src/LATTE/fix_latte.cpp index c6269f4c21..19a1e78603 100644 --- a/src/LATTE/fix_latte.cpp +++ b/src/LATTE/fix_latte.cpp @@ -45,7 +45,7 @@ using namespace FixConst; extern "C" { void latte(int *, int *, double *, int *, int *, - double *, double *, double *, double *, double *); + double *, double *, double *, double *, int*, double *, double *, double *); } #define INVOKED_PERATOM 8 @@ -278,9 +278,11 @@ void FixLatte::post_force(int vflag) else forces = &atom->f[0][0]; // invoke LATTE + + int maxiter = -1; latte(flags,&natoms,coords,type,&ntypes,mass,boxlo,boxhi, - forces,&latte_energy); + forces,&maxiter, &latte_energy, &atom->v[0][0],&update->dt); // sum LATTE forces to LAMMPS (Coulombic) forces From 967cdd947ef93ef6c5d63432fa865ee96e10f20d Mon Sep 17 00:00:00 2001 From: Christian Negre Date: Thu, 5 Jan 2017 15:37:01 -0700 Subject: [PATCH 20/41] cleanup --- lib/latte/Makefile.lammps.gfortran | 5 +- src/fix_latte.cpp | 338 +++++++++++++++++++++++++++++ 2 files changed, 342 insertions(+), 1 deletion(-) create mode 100644 src/fix_latte.cpp diff --git a/lib/latte/Makefile.lammps.gfortran b/lib/latte/Makefile.lammps.gfortran index 37003db31d..876cfd5772 100644 --- a/lib/latte/Makefile.lammps.gfortran +++ b/lib/latte/Makefile.lammps.gfortran @@ -6,7 +6,7 @@ # PROGRESS: https://github.com/losalamos/qmd-progress # METIS: http://glaros.dtc.umn.edu/gkhome/metis/metis/download -latte_PATH = ${HOME}/exaalt/LATTE +latte_PATH = ${HOME}/exaalt/LATTE_dev progress_PATH = ${HOME}/qmd-progress bml_PATH = ${HOME}/bml metis_PATH = ${HOME}/Programs/metis-5.1.0 @@ -16,6 +16,9 @@ latte_SYSLIB = -fopenmp ${latte_PATH}/src/latte_c_bind.o ${latte_PATH}/liblatte -lm -Wl,--no-as-needed -L${MKLROOT}/lib/intel64 -lmkl_lapack95_lp64 -lmkl_gf_lp64 \ -lmkl_gnu_thread -lmkl_core -lmkl_gnu_thread -lmkl_core -ldl -lpthread -lm +latte_SYSLIB = -fopenmp ${latte_PATH}/src/latte_c_bind.o ${latte_PATH}/liblatte.a -lgfortran \ + -llapack -lblas + # Uncomment the following line to use PROGRESS/BML latte_SYSLIB += -L${progress_PATH}/install/lib -lprogress -L${bml_PATH}/install/lib -lbml -L${metis_PATH}/install -lmetis diff --git a/src/fix_latte.cpp b/src/fix_latte.cpp new file mode 100644 index 0000000000..d7bf6eaccf --- /dev/null +++ b/src/fix_latte.cpp @@ -0,0 +1,338 @@ +/* ---------------------------------------------------------------------- + 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. +------------------------------------------------------------------------- */ + +// NOTES on possible future issues: +// LATTE compute and return 6-value virial tensor +// can LATTE compute per-atom energy and per-atom virial +// for minimize, what about charge DOFs +// implement charge DOF integration +// pass neighbor list to LATTE: half or full +// will we ever auto-adjust the timestep in reset_dt() +// could pass an input file to LATTE, specified in LAMMPS input script +// what units options can LAMMPS be using +// should LATTE take triclinic box from LAMMPS +// does Coulomb potential = pe[i]/q[i], is it 0 when q = 0 +// how will this work for serial/parallel LAMMPS with serial/parallel LATTE + +#include +#include +#include "fix_latte.h" +#include "atom.h" +#include "comm.h" +#include "update.h" +#include "neighbor.h" +#include "domain.h" +#include "force.h" +#include "neigh_request.h" +#include "neigh_list.h" +#include "modify.h" +#include "compute.h" +#include "memory.h" +#include "error.h" + +using namespace LAMMPS_NS; +using namespace FixConst; + +extern "C" { + void latte(int *, int *, double *, int *, int *, + double *, double *, double *, double *, int*, double *, double *, double*); +} + +#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"); + + if (comm->nprocs != 1) + error->all(FLERR,"Fix latte currently runs only in serial"); + + scalar_flag = 1; + global_freq = 1; + extscalar = 1; + virial_flag = 1; + + // store ID of compute pe/atom used to generate Coulomb potential for LATTE + // NULL means LATTE will compute Coulombic potential + + coulomb = 0; + id_pe = NULL; + + if (strcmp(arg[3],"NULL") != 0) { + coulomb = 1; + + 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"); + } + + // initializations + + nmax = 0; + qpotential = NULL; + flatte = NULL; + + latte_energy = 0.0; +} + +/* ---------------------------------------------------------------------- */ + +FixLatte::~FixLatte() +{ + delete [] id_pe; + memory->destroy(qpotential); + memory->destroy(flatte); +} + +/* ---------------------------------------------------------------------- */ + +int FixLatte::setmask() +{ + int mask = 0; + //mask |= INITIAL_INTEGRATE; + //mask |= FINAL_INTEGRATE; + mask |= PRE_REVERSE; + mask |= POST_FORCE; + mask |= MIN_POST_FORCE; + mask |= THERMO_ENERGY; + return mask; +} + +/* ---------------------------------------------------------------------- */ + +void FixLatte::init() +{ + // error checks + + if (domain->dimension == 2) + error->all(FLERR,"Fix latte requires 3d problem"); + + if (coulomb) { + if (atom->q_flag == 0 || force->pair == NULL || force->kspace == NULL) + error->all(FLERR,"Fix latte cannot compute Coulombic potential"); + + 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]; + } + + // must be fully periodic or fully non-periodic + + if (domain->nonperiodic == 0) pbcflag = 1; + else if (!domain->xperiodic && !domain->yperiodic && !domain->zperiodic) + pbcflag = 0; + else error->all(FLERR,"Fix latte requires 3d simulation"); + + // create qpotential & flatte if needed + // for now, assume nlocal will never change + + if (coulomb && qpotential == NULL) { + memory->create(qpotential,atom->nlocal,"latte:qpotential"); + memory->create(flatte,atom->nlocal,3,"latte:flatte"); + } + + /* + // 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 + // could we use a half 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; + */ +} + +/* ---------------------------------------------------------------------- */ + +void FixLatte::init_list(int id, NeighList *ptr) +{ + // list = ptr; +} + +/* ---------------------------------------------------------------------- */ + +void FixLatte::setup(int vflag) +{ + post_force(vflag); +} + +/* ---------------------------------------------------------------------- */ + +void FixLatte::min_setup(int vflag) +{ + post_force(vflag); +} + +/* ---------------------------------------------------------------------- + integrate electronic degrees of freedom +------------------------------------------------------------------------- */ + +void FixLatte::initial_integrate(int vflag) {} + +/* ---------------------------------------------------------------------- + store eflag, so can use it in post_force to tally per-atom energies +------------------------------------------------------------------------- */ + +void FixLatte::pre_reverse(int eflag, int vflag) +{ + eflag_caller = eflag; +} + +/* ---------------------------------------------------------------------- */ + +void FixLatte::post_force(int vflag) +{ + int eflag = eflag_caller; + if (eflag || vflag) ev_setup(eflag,vflag); + else evflag = 0; + + // compute Coulombic potential = pe[i]/q[i] + // invoke compute pe/atom + // wrap with clear/add and trigger pe/atom calculation every step + + if (coulomb) { + modify->clearstep_compute(); + + if (!(c_pe->invoked_flag & INVOKED_PERATOM)) { + c_pe->compute_peratom(); + c_pe->invoked_flag |= INVOKED_PERATOM; + } + + modify->addstep_compute(update->ntimestep+1); + + double *pe = c_pe->vector_atom; + double *q = atom->q; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) + if (q[i]) qpotential[i] = pe[i]/q[i]; + else qpotential[i] = 0.0; + } + + // hardwire these unsupported flags for now + + int coulombflag = 0; + pe_peratom = 0; + virial_global = 0; // set via vflag_global at some point + virial_peratom = 0; + neighflag = 0; + + // set flags used by LATTE + + int flags[6]; + + flags[0] = pbcflag; // 1 for fully periodic, 0 for fully non-periodic + flags[1] = coulombflag; // 1 for LAMMPS computes Coulombics, 0 for LATTE + flags[2] = pe_peratom; // 1 to return per-atom energies, 0 for no + flags[3] = virial_global; // 1 to return global virial 0 for no + flags[4] = virial_peratom; // 1 to return per-atom virial, 0 for no + flags[5] = neighflag; // 1 to pass neighbor list to LATTE, 0 for no + + // setup LATTE arguments + + int natoms = atom->nlocal; + double *coords = &atom->x[0][0]; + int *type = atom->type; + int ntypes = atom->ntypes; + double *mass = &atom->mass[1]; + double *boxlo = domain->boxlo; + double *boxhi = domain->boxhi; + + double *forces; + if (coulomb) forces = &flatte[0][0]; + else forces = &atom->f[0][0]; + + // invoke LATTE + + int maxiter = -1; + double *dt_latte = &update->dt; + double dt_latte_ang = *dt_latte * 1000.0; // Units of DT must be in Angstroms + +// latte(flags,&natoms,coords,type,&ntypes,mass,boxlo,boxhi, +// forces,&maxiter, &latte_energy, &atom->v[0][0],&update->dt); + + latte(flags,&natoms,coords,type,&ntypes,mass,boxlo,boxhi, + forces,&maxiter, &latte_energy, &atom->v[0][0], &dt_latte_ang); + + // sum LATTE forces to LAMMPS (Coulombic) forces + + if (coulomb) { + double **f = atom->f; + int nlocal = atom->nlocal; + for (int i = 0; i < nlocal; i++) { + f[i][0] += flatte[i][0]; + f[i][1] += flatte[i][1]; + f[i][2] += flatte[i][2]; + } + } +} + +/* ---------------------------------------------------------------------- + integrate electronic degrees of freedom +------------------------------------------------------------------------- */ + +void FixLatte::final_integrate() {} + +/* ---------------------------------------------------------------------- */ + +void FixLatte::reset_dt() +{ + //dtv = update->dt; + //dtf = 0.5 * update->dt * force->ftm2v; +} + +/* ---------------------------------------------------------------------- + DFTB energy from LATTE +------------------------------------------------------------------------- */ + +double FixLatte::compute_scalar() +{ + return latte_energy; +} + +/* ---------------------------------------------------------------------- + memory usage of local arrays +------------------------------------------------------------------------- */ + +double FixLatte::memory_usage() +{ + double bytes = 0.0; + if (coulomb) bytes += nmax * sizeof(double); + if (coulomb) bytes += nmax*3 * sizeof(double); + return bytes; +} From 1f6cfb1b317973ae4e7f403090f85b055b6b442e Mon Sep 17 00:00:00 2001 From: Christian Negre Date: Tue, 10 Jan 2017 10:56:31 -0700 Subject: [PATCH 21/41] Makefile.lammps.gfortran changed --- lib/latte/Makefile.lammps.gfortran | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/latte/Makefile.lammps.gfortran b/lib/latte/Makefile.lammps.gfortran index 876cfd5772..f7cfb59d76 100644 --- a/lib/latte/Makefile.lammps.gfortran +++ b/lib/latte/Makefile.lammps.gfortran @@ -6,15 +6,16 @@ # PROGRESS: https://github.com/losalamos/qmd-progress # METIS: http://glaros.dtc.umn.edu/gkhome/metis/metis/download -latte_PATH = ${HOME}/exaalt/LATTE_dev +latte_PATH = ${HOME}/latte_dev progress_PATH = ${HOME}/qmd-progress bml_PATH = ${HOME}/bml metis_PATH = ${HOME}/Programs/metis-5.1.0 latte_SYSINC = -I${latte_PATH}/src -I${bml_PATH}/install/include -I${progress_PATH}/install/include -latte_SYSLIB = -fopenmp ${latte_PATH}/src/latte_c_bind.o ${latte_PATH}/liblatte.a -lgfortran \ - -lm -Wl,--no-as-needed -L${MKLROOT}/lib/intel64 -lmkl_lapack95_lp64 -lmkl_gf_lp64 \ - -lmkl_gnu_thread -lmkl_core -lmkl_gnu_thread -lmkl_core -ldl -lpthread -lm + +#latte_SYSLIB = -fopenmp ${latte_PATH}/src/latte_c_bind.o ${latte_PATH}/liblatte.a -lgfortran \ +# -lm -Wl,--no-as-needed -L${MKLROOT}/lib/intel64 -lmkl_lapack95_lp64 -lmkl_gf_lp64 \ +# -lmkl_gnu_thread -lmkl_core -lmkl_gnu_thread -lmkl_core -ldl -lpthread -lm latte_SYSLIB = -fopenmp ${latte_PATH}/src/latte_c_bind.o ${latte_PATH}/liblatte.a -lgfortran \ -llapack -lblas From f51ddf8450a0e043a1352eb0042b485a85a61a13 Mon Sep 17 00:00:00 2001 From: Christian Negre Date: Thu, 12 Jan 2017 13:50:02 -0700 Subject: [PATCH 22/41] Makefile.lammps.gfortran --- lib/latte/Makefile.lammps.gfortran | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/latte/Makefile.lammps.gfortran b/lib/latte/Makefile.lammps.gfortran index f7cfb59d76..5ec06ed1ad 100644 --- a/lib/latte/Makefile.lammps.gfortran +++ b/lib/latte/Makefile.lammps.gfortran @@ -6,7 +6,7 @@ # PROGRESS: https://github.com/losalamos/qmd-progress # METIS: http://glaros.dtc.umn.edu/gkhome/metis/metis/download -latte_PATH = ${HOME}/latte_dev +latte_PATH = ${HOME}/LATTE_dev progress_PATH = ${HOME}/qmd-progress bml_PATH = ${HOME}/bml metis_PATH = ${HOME}/Programs/metis-5.1.0 From 6bd17be454d2b50e80a02f8941dd035dab29f43c Mon Sep 17 00:00:00 2001 From: Christian Negre Date: Thu, 12 Jan 2017 16:58:27 -0700 Subject: [PATCH 23/41] Makefile.lammps.gfortran --- lib/latte/Makefile.lammps.gfortran | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/latte/Makefile.lammps.gfortran b/lib/latte/Makefile.lammps.gfortran index 5ec06ed1ad..36ead90b41 100644 --- a/lib/latte/Makefile.lammps.gfortran +++ b/lib/latte/Makefile.lammps.gfortran @@ -20,7 +20,8 @@ latte_SYSINC = -I${latte_PATH}/src -I${bml_PATH}/install/include -I${progress_P latte_SYSLIB = -fopenmp ${latte_PATH}/src/latte_c_bind.o ${latte_PATH}/liblatte.a -lgfortran \ -llapack -lblas -# Uncomment the following line to use PROGRESS/BML +# Uncomment the following line to use PROGRESS/BML and metis. latte_SYSLIB += -L${progress_PATH}/install/lib -lprogress -L${bml_PATH}/install/lib -lbml -L${metis_PATH}/install -lmetis +#latte_SYSLIB += -L${metis_PATH}/install -lmetis From aaa7dca21bfadba2cc04c42450e09af50f58b61c Mon Sep 17 00:00:00 2001 From: Christian Negre Date: Thu, 12 Jan 2017 17:13:02 -0700 Subject: [PATCH 24/41] Makefile.lammps.gfortran --- lib/latte/Makefile.lammps.gfortran | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/latte/Makefile.lammps.gfortran b/lib/latte/Makefile.lammps.gfortran index 36ead90b41..b2876f9777 100644 --- a/lib/latte/Makefile.lammps.gfortran +++ b/lib/latte/Makefile.lammps.gfortran @@ -21,7 +21,7 @@ latte_SYSLIB = -fopenmp ${latte_PATH}/src/latte_c_bind.o ${latte_PATH}/liblatte -llapack -lblas # Uncomment the following line to use PROGRESS/BML and metis. -latte_SYSLIB += -L${progress_PATH}/install/lib -lprogress -L${bml_PATH}/install/lib -lbml -L${metis_PATH}/install -lmetis +latte_SYSLIB += -L${progress_PATH}/install/lib -lprogress -L${bml_PATH}/install/lib -lbml #latte_SYSLIB += -L${metis_PATH}/install -lmetis From 6d47cf350c52a5922e5656f038c4d99dfa40bb19 Mon Sep 17 00:00:00 2001 From: Christian Negre Date: Thu, 19 Jan 2017 15:42:09 -0700 Subject: [PATCH 25/41] Makefile for latte_dev --- lib/latte/Makefile.lammps.gfortran | 2 +- lib/latte/Makefile.lammps.gfortran.dev | 27 ++++++++++++++++++++++++++ lib/latte/Makefile.lammps.ifort | 2 +- 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 lib/latte/Makefile.lammps.gfortran.dev diff --git a/lib/latte/Makefile.lammps.gfortran b/lib/latte/Makefile.lammps.gfortran index b2876f9777..310ba74454 100644 --- a/lib/latte/Makefile.lammps.gfortran +++ b/lib/latte/Makefile.lammps.gfortran @@ -6,7 +6,7 @@ # PROGRESS: https://github.com/losalamos/qmd-progress # METIS: http://glaros.dtc.umn.edu/gkhome/metis/metis/download -latte_PATH = ${HOME}/LATTE_dev +latte_PATH = ${HOME}/LATTE progress_PATH = ${HOME}/qmd-progress bml_PATH = ${HOME}/bml metis_PATH = ${HOME}/Programs/metis-5.1.0 diff --git a/lib/latte/Makefile.lammps.gfortran.dev b/lib/latte/Makefile.lammps.gfortran.dev new file mode 100644 index 0000000000..b2876f9777 --- /dev/null +++ b/lib/latte/Makefile.lammps.gfortran.dev @@ -0,0 +1,27 @@ +# Settings that the LAMMPS build will import when this package is installed +# Change all the flags and paths accordingly +# If using PROGRESS/BML set PROGRESS to ON +# For more information about these libraries see: +# BML: https://github.com/qmmd/bml +# PROGRESS: https://github.com/losalamos/qmd-progress +# METIS: http://glaros.dtc.umn.edu/gkhome/metis/metis/download + +latte_PATH = ${HOME}/LATTE_dev +progress_PATH = ${HOME}/qmd-progress +bml_PATH = ${HOME}/bml +metis_PATH = ${HOME}/Programs/metis-5.1.0 + +latte_SYSINC = -I${latte_PATH}/src -I${bml_PATH}/install/include -I${progress_PATH}/install/include + +#latte_SYSLIB = -fopenmp ${latte_PATH}/src/latte_c_bind.o ${latte_PATH}/liblatte.a -lgfortran \ +# -lm -Wl,--no-as-needed -L${MKLROOT}/lib/intel64 -lmkl_lapack95_lp64 -lmkl_gf_lp64 \ +# -lmkl_gnu_thread -lmkl_core -lmkl_gnu_thread -lmkl_core -ldl -lpthread -lm + +latte_SYSLIB = -fopenmp ${latte_PATH}/src/latte_c_bind.o ${latte_PATH}/liblatte.a -lgfortran \ + -llapack -lblas + +# Uncomment the following line to use PROGRESS/BML and metis. +latte_SYSLIB += -L${progress_PATH}/install/lib -lprogress -L${bml_PATH}/install/lib -lbml +#latte_SYSLIB += -L${metis_PATH}/install -lmetis + + diff --git a/lib/latte/Makefile.lammps.ifort b/lib/latte/Makefile.lammps.ifort index 40637013f5..1d5c55b2fc 100644 --- a/lib/latte/Makefile.lammps.ifort +++ b/lib/latte/Makefile.lammps.ifort @@ -6,7 +6,7 @@ # PROGRESS: https://github.com/losalamos/qmd-progress # METIS: http://glaros.dtc.umn.edu/gkhome/metis/metis/download -latte_PATH = ${HOME}/exaalt/LATTE +latte_PATH = ${HOME}/LATTE progress_PATH = ${HOME}/qmd-progress bml_PATH = ${HOME}/bml metis_PATH = ${HOME}/Programs/metis-5.1.0 From 2dcbc805ba62ec2045f6a581ccc9beb115ef1a1f Mon Sep 17 00:00:00 2001 From: Christian Negre Date: Thu, 23 Feb 2017 18:20:02 -0700 Subject: [PATCH 26/41] min latte partially fixed --- examples/latte/data.sucrose_non_opt.lmp | 63 +++++++++++++++++++++++++ examples/latte/data.water | 41 ++++++++++++++++ examples/latte/in.latte.sucrose.min | 42 +++++++++++++++++ examples/latte/in.latte.water | 40 ++++++++++++++++ examples/latte/in.latte.water.min | 41 ++++++++++++++++ lib/latte/README | 4 +- src/LATTE/fix_latte.cpp | 12 ++++- src/LATTE/fix_latte.h | 1 + 8 files changed, 240 insertions(+), 4 deletions(-) create mode 100644 examples/latte/data.sucrose_non_opt.lmp create mode 100644 examples/latte/data.water create mode 100644 examples/latte/in.latte.sucrose.min create mode 100644 examples/latte/in.latte.water create mode 100644 examples/latte/in.latte.water.min diff --git a/examples/latte/data.sucrose_non_opt.lmp b/examples/latte/data.sucrose_non_opt.lmp new file mode 100644 index 0000000000..a96a19eddb --- /dev/null +++ b/examples/latte/data.sucrose_non_opt.lmp @@ -0,0 +1,63 @@ + LAMMPS Description + + 45 atoms + + 3 atom types + + 0.0000000000000000 18.917000000000002 xlo xhi + 0.0000000000000000 17.350999999999999 ylo yhi + 0.0000000000000000 15.472000000000000 zlo zhi + + Masses + + 1 15.994915008544922 + 2 12.000000000000000 + 3 1.0078250169754028 + + Atoms + + 1 1 1 0.0 11.47359 7.39174 7.26456 + 2 1 2 0.0 12.66159 8.24474 7.53356 + 3 1 3 0.0 13.49759 7.72474 7.00656 + 4 1 2 0.0 12.92859 8.18374 9.02956 + 5 1 1 0.0 13.69659 9.10274 10.46556 + 6 1 2 0.0 12.83959 10.10474 6.64056 + 7 1 3 0.0 13.24359 10.33074 7.58456 + 8 1 1 0.0 13.17359 9.67874 5.60956 + 9 1 2 0.0 11.20559 10.26374 6.86456 + 10 1 3 0.0 11.22159 11.15674 6.18156 + 11 1 1 0.0 10.78559 10.69674 8.19156 + 12 1 2 0.0 10.23459 9.20474 6.34356 + 13 1 3 0.0 9.23359 9.62574 6.11656 + 14 1 1 0.0 10.73959 8.65074 5.08856 + 15 1 2 0.0 10.18759 8.08774 7.38056 + 16 1 3 0.0 10.03259 8.49174 8.42656 + 17 1 1 0.0 9.22959 7.03374 7.08156 + 18 1 2 0.0 7.79359 7.27874 7.34356 + 19 1 1 0.0 7.44259 8.64274 6.96956 + 20 1 2 0.0 7.01059 9.43674 8.13856 + 21 1 3 0.0 5.95059 9.74974 7.96256 + 22 1 2 0.0 7.08359 8.51474 9.35656 + 23 1 3 0.0 8.19359 8.08474 9.80956 + 24 1 1 0.0 5.86059 8.56174 10.14056 + 25 1 2 0.0 7.34259 7.10674 8.80356 + 26 1 3 0.0 6.37259 6.54074 8.80556 + 27 1 1 0.0 8.32159 6.38474 9.58156 + 28 1 2 0.0 7.89859 10.67174 8.17156 + 29 1 1 0.0 6.06859 12.11474 7.59256 + 30 1 2 0.0 7.47359 7.05174 5.99256 + 31 1 1 0.0 5.66359 6.54374 6.50656 + 32 1 3 0.0 12.00659 8.11374 9.61556 + 33 1 3 0.0 13.35859 7.21774 9.30856 + 34 1 3 0.0 13.67759 8.46774 11.22956 + 35 1 3 0.0 12.44459 9.34474 5.00556 + 36 1 3 0.0 11.54859 11.18274 8.59756 + 37 1 3 0.0 11.00959 7.71574 5.30056 + 38 1 3 0.0 5.09459 8.45474 9.52056 + 39 1 3 0.0 7.92859 6.23074 10.47756 + 40 1 3 0.0 8.53259 10.62974 7.23156 + 41 1 3 0.0 8.58159 10.63874 9.05856 + 42 1 3 0.0 6.42359 13.37374 7.86056 + 43 1 3 0.0 7.58559 6.90074 4.62256 + 44 1 3 0.0 7.35159 5.27974 6.61456 + 45 1 3 0.0 5.22759 6.18974 5.69256 diff --git a/examples/latte/data.water b/examples/latte/data.water new file mode 100644 index 0000000000..1a1e4d9e0b --- /dev/null +++ b/examples/latte/data.water @@ -0,0 +1,41 @@ + LAMMPS Description + + 24 atoms + + 2 atom types + + 0.0000000000000000 6.2670000000000003 xlo xhi + 0.0000000000000000 6.2670000000000003 ylo yhi + 0.0000000000000000 6.2670000000000003 zlo zhi + + Masses + + 1 15.994915008544922 + 2 1.0078250169754028 + + Atoms + + 1 1 1 0.0 3.08800 3.70000 3.12400 + 2 1 2 0.0 4.05800 3.70000 3.12400 + 3 1 2 0.0 2.76400 3.13200 3.84100 + 4 1 1 0.0 2.47000 0.39000 1.36000 + 5 1 2 0.0 1.54000 0.37000 1.73000 + 6 1 2 0.0 2.48000 0.00000 0.44000 + 7 1 1 0.0 1.99300 0.41700 5.25000 + 8 1 2 0.0 2.39300 1.32700 5.16000 + 9 1 2 0.0 0.99300 0.49700 5.31000 + 10 1 1 0.0 2.05300 6.09700 3.48000 + 11 1 2 0.0 2.12300 5.20700 3.02000 + 12 1 2 0.0 1.11300 0.17000 3.40000 + 13 1 1 0.0 4.90000 5.37700 2.14000 + 14 1 2 0.0 5.51000 6.17700 2.18000 + 15 1 2 0.0 3.95000 5.68700 2.21000 + 16 1 1 0.0 0.92000 3.82700 0.56000 + 17 1 2 0.0 0.00000 3.54700 0.27000 + 18 1 2 0.0 1.23000 4.59700 0.00000 + 19 1 1 0.0 0.89000 2.03700 3.41000 + 20 1 2 0.0 0.72000 2.86700 2.87000 + 21 1 2 0.0 1.79000 1.66700 3.19000 + 22 1 1 0.0 4.45000 4.61700 5.43000 + 23 1 2 0.0 4.75000 3.89700 4.81000 + 24 1 2 0.0 4.06000 4.21700 6.26000 diff --git a/examples/latte/in.latte.sucrose.min b/examples/latte/in.latte.sucrose.min new file mode 100644 index 0000000000..dc0879861a --- /dev/null +++ b/examples/latte/in.latte.sucrose.min @@ -0,0 +1,42 @@ +# simple water model with LATTE + +units metal +atom_style full +atom_modify sort 0 0.0 # turn off sorting of the coordinates + +#read_data data.water +read_data data.sucrose_non_opt.lmp + +# replicate system if requested + +variable x index 1 +variable y index 1 +variable z index 1 + +variable nrep equal v_x*v_y*v_z +if "${nrep} > 1" then "replicate $x $y $z" + +# initialize system + +velocity all create 0.0 87287 loop geom + +pair_style zero 1.0 +pair_coeff * * + +neighbor 1.0 bin +neigh_modify every 1 delay 0 check yes + +timestep 0.00025 + +fix 1 all nve + +fix 2 all latte NULL +fix_modify 2 energy yes + +thermo_style custom step temp pe etotal + +# minimization + +thermo 1 +min_style cg +minimize 1.0e-9 1.0e-9 1000 1000 diff --git a/examples/latte/in.latte.water b/examples/latte/in.latte.water new file mode 100644 index 0000000000..1ab9fcaafe --- /dev/null +++ b/examples/latte/in.latte.water @@ -0,0 +1,40 @@ +# simple water model with LATTE + +units metal +atom_style full +atom_modify sort 0 0.0 # turn off sorting of the coordinates + +read_data data.water + +# replicate system if requested + +variable x index 1 +variable y index 1 +variable z index 1 + +variable nrep equal v_x*v_y*v_z +if "${nrep} > 1" then "replicate $x $y $z" + +# initialize system + +velocity all create 0.0 87287 loop geom + +pair_style zero 1.0 +pair_coeff * * + +neighbor 1.0 bin +neigh_modify every 1 delay 0 check yes + +timestep 0.00025 + +fix 1 all nve + +fix 2 all latte NULL +fix_modify 2 energy yes + +thermo_style custom step temp pe etotal + +# dynamics + +thermo 10 +run 100 diff --git a/examples/latte/in.latte.water.min b/examples/latte/in.latte.water.min new file mode 100644 index 0000000000..5bf261547a --- /dev/null +++ b/examples/latte/in.latte.water.min @@ -0,0 +1,41 @@ +# simple water model with LATTE + +units metal +atom_style full +atom_modify sort 0 0.0 # turn off sorting of the coordinates + +read_data data.water + +# replicate system if requested + +variable x index 1 +variable y index 1 +variable z index 1 + +variable nrep equal v_x*v_y*v_z +if "${nrep} > 1" then "replicate $x $y $z" + +# initialize system + +velocity all create 0.0 87287 loop geom + +pair_style zero 1.0 +pair_coeff * * + +neighbor 1.0 bin +neigh_modify every 1 delay 0 check yes + +timestep 0.00025 + +fix 1 all nve + +fix 2 all latte NULL +fix_modify 2 energy yes + +thermo_style custom step temp pe etotal + +# minimization + +thermo 1 +min_style fire +minimize 1.0e-9 1.0e-9 1000 1000 diff --git a/lib/latte/README b/lib/latte/README index 3acd85095a..4166d03166 100644 --- a/lib/latte/README +++ b/lib/latte/README @@ -20,7 +20,7 @@ follow these steps: - Set the MAKELIB flag to ON in makefile.CHOICES and finally, build the code with the make command. -Note that if you unpack and build LATTE in this directory, if you +Note that if you unpack and build LATTE in this directory and you download a new LAMMPS tarball, the files you have added here will be lost. So you likely want to build it somewhere else. The recommended place is the home directory. @@ -28,7 +28,7 @@ place is the home directory. To build LAMMPS with the LATTE library you should follow the following instructions: -- makefile.lammps.* to makefile.lammps in the /lammps/lib/latte directory. +- copy makefile.lammps.* to makefile.lammps in the /lammps/lib/latte directory. - Change the path, flags and compilers on the makefile.lammps according to your compilers, architecture and the LATTE location. diff --git a/src/LATTE/fix_latte.cpp b/src/LATTE/fix_latte.cpp index 19a1e78603..ba9804de0d 100644 --- a/src/LATTE/fix_latte.cpp +++ b/src/LATTE/fix_latte.cpp @@ -45,7 +45,8 @@ using namespace FixConst; extern "C" { void latte(int *, int *, double *, int *, int *, - double *, double *, double *, double *, int*, double *, double *, double *); + double *, double *, double *, double *, int*, + double *, double *, double *); } #define INVOKED_PERATOM 8 @@ -282,7 +283,7 @@ void FixLatte::post_force(int vflag) int maxiter = -1; latte(flags,&natoms,coords,type,&ntypes,mass,boxlo,boxhi, - forces,&maxiter, &latte_energy, &atom->v[0][0],&update->dt); + forces,&maxiter,&latte_energy,&atom->v[0][0],&update->dt); // sum LATTE forces to LAMMPS (Coulombic) forces @@ -297,6 +298,13 @@ void FixLatte::post_force(int vflag) } } +/* ---------------------------------------------------------------------- */ + +void FixLatte::min_post_force(int vflag) +{ + post_force(vflag); +} + /* ---------------------------------------------------------------------- integrate electronic degrees of freedom ------------------------------------------------------------------------- */ diff --git a/src/LATTE/fix_latte.h b/src/LATTE/fix_latte.h index d0f2fdea3e..d6b75d52f4 100644 --- a/src/LATTE/fix_latte.h +++ b/src/LATTE/fix_latte.h @@ -36,6 +36,7 @@ class FixLatte : public Fix { void initial_integrate(int); void pre_reverse(int, int); void post_force(int); + void min_post_force(int); void final_integrate(); void reset_dt(); double compute_scalar(); From 9736fb3be84597101c53d31d2c4ace5bff058b98 Mon Sep 17 00:00:00 2001 From: Christian Negre Date: Tue, 28 Feb 2017 10:40:46 -0700 Subject: [PATCH 27/41] added sucrose latte min example --- examples/latte/in.latte.sucrose.min | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/latte/in.latte.sucrose.min b/examples/latte/in.latte.sucrose.min index dc0879861a..9513af9ac6 100644 --- a/examples/latte/in.latte.sucrose.min +++ b/examples/latte/in.latte.sucrose.min @@ -4,7 +4,6 @@ units metal atom_style full atom_modify sort 0 0.0 # turn off sorting of the coordinates -#read_data data.water read_data data.sucrose_non_opt.lmp # replicate system if requested @@ -39,4 +38,6 @@ thermo_style custom step temp pe etotal thermo 1 min_style cg -minimize 1.0e-9 1.0e-9 1000 1000 +min_modify dmax 0.1 +min_modify line quadratic +minimize 1.0e-6 1.0e-6 10000 10000 From 78a8f75a8f3155c37dd18a0929317b49de9a9a68 Mon Sep 17 00:00:00 2001 From: Christian Negre Date: Wed, 1 Mar 2017 09:53:50 -0700 Subject: [PATCH 28/41] params added --- examples/latte/TBparam/bondints.nonortho | 36 ++++++++++++++++++++++++ examples/latte/TBparam/electrons.dat | 7 +++++ examples/latte/TBparam/ppots.nonortho | 12 ++++++++ 3 files changed, 55 insertions(+) create mode 100644 examples/latte/TBparam/bondints.nonortho create mode 100644 examples/latte/TBparam/electrons.dat create mode 100644 examples/latte/TBparam/ppots.nonortho diff --git a/examples/latte/TBparam/bondints.nonortho b/examples/latte/TBparam/bondints.nonortho new file mode 100644 index 0000000000..8c1eee76b5 --- /dev/null +++ b/examples/latte/TBparam/bondints.nonortho @@ -0,0 +1,36 @@ +Noints= 34 +Element1 Element2 Kind H0 B1 B2 B3 B4 B5 R1 Rcut H0 B1 B2 B3 B4 B5 R1 Rcut +N O sss -11.430028 -2.257346 -1.152844 0.000000 0.000000 1.200000 3.500000 4.000000 0.340064 -1.703613 -0.622348 0.036738 -0.040158 1.200000 3.500000 4.000000 +N O sps 11.597479 -1.382001 -0.765170 0.000000 0.000000 1.200000 3.500000 4.000000 -0.370946 -1.040947 -0.931097 0.252441 -0.115450 1.200000 3.500000 4.000000 +O N sps 12.143744 -0.822913 -0.676127 0.000000 0.000000 1.200000 3.500000 4.000000 -0.420014 -1.107918 -0.905594 0.188424 -0.088365 1.200000 3.500000 4.000000 +N O pps 9.465191 -1.082032 -0.769214 0.000000 0.000000 1.200000 3.500000 4.000000 -0.314073 0.499050 -2.914288 2.067657 -0.738439 1.200000 3.500000 4.000000 +N O ppp -4.676789 -2.171480 -0.288002 0.000000 0.000000 1.200000 3.500000 4.000000 0.223937 -1.991867 -0.537630 -0.081270 -0.004130 1.200000 3.500000 4.000000 +C O sss -14.369472 -2.077439 -0.875471 0.000000 0.000000 1.200000 3.500000 4.000000 0.375339 -1.547372 -0.642492 0.020614 -0.026699 1.200000 3.500000 4.000000 +C O sps 9.576296 -1.156217 -0.494803 0.000000 0.000000 1.200000 3.500000 4.000000 -0.373027 -0.776043 -1.019920 0.257539 -0.102838 1.200000 3.500000 4.000000 +O C sps 14.037374 -1.192632 -0.654572 0.000000 0.000000 1.200000 3.500000 4.000000 -0.458068 -1.035067 -0.937868 0.190562 -0.077841 1.200000 3.500000 4.000000 +C O pps 9.331152 -0.718120 -0.822100 0.000000 0.000000 1.200000 3.500000 4.000000 -0.322293 0.795473 -3.476601 2.589965 -0.897800 1.200000 3.500000 4.000000 +C O ppp -5.334367 -2.263939 -0.204910 0.000000 0.000000 1.200000 3.500000 4.000000 0.244570 -1.922717 -0.573671 -0.057280 -0.004108 1.200000 3.500000 4.000000 +C N sss -7.010061 -1.730597 -0.575559 0.000000 0.000000 1.500000 3.500000 4.000000 0.263438 -1.754525 -0.584215 -0.007801 -0.021729 1.500000 3.500000 4.000000 +C N sps 7.543283 -1.293768 -0.624363 0.000000 0.000000 1.500000 3.500000 4.000000 -0.326609 -1.197485 -0.807786 0.134891 -0.084373 1.500000 3.500000 4.000000 +N C sps 9.090970 -1.494255 -0.616711 0.000000 0.000000 1.500000 3.500000 4.000000 -0.337943 -1.335442 -0.769693 0.119373 -0.079493 1.500000 3.500000 4.000000 +C N pps 6.892240 -0.931920 -0.769164 0.000000 0.000000 1.500000 3.500000 4.000000 -0.350240 -0.467439 -1.849316 1.854403 -0.988471 1.500000 3.500000 4.000000 +C N ppp -2.903346 -2.149349 -0.253006 0.000000 0.000000 1.500000 3.500000 4.000000 0.158424 -2.114409 -0.582346 -0.051076 -0.006183 1.500000 3.500000 4.000000 +C C sss -9.404207 -1.363297 -0.507128 0.000000 0.000000 1.400000 3.500000 4.000000 0.346977 -1.519820 -0.570812 -0.013518 -0.015829 1.400000 3.500000 4.000000 +C C sps 8.662429 -1.047410 -0.661999 0.000000 0.000000 1.400000 3.500000 4.000000 -0.400467 -0.984048 -0.853949 0.157178 -0.073381 1.400000 3.500000 4.000000 +C C pps 6.811512 -0.552299 -0.776890 0.000000 0.000000 1.400000 3.500000 4.000000 -0.382417 0.102889 -2.786680 2.646356 -1.134320 1.400000 3.500000 4.000000 +C C ppp -3.550127 -1.925572 -0.132715 0.000000 0.000000 1.400000 3.500000 4.000000 0.214357 -1.948923 -0.578323 -0.034356 -0.007257 1.400000 3.500000 4.000000 +H C sss -9.072577 -1.393093 -0.430611 0.000000 0.000000 1.100000 3.500000 4.000000 0.416003 -1.459596 -0.654874 0.009140 -0.012658 1.100000 3.500000 4.000000 +H C sps 8.176008 -0.985177 -0.427403 0.000000 0.000000 1.100000 3.500000 4.000000 -0.495695 -0.901626 -1.007214 0.189808 -0.057087 1.100000 3.500000 4.000000 +H H sss -9.340000 -1.145903 -0.391777 0.000000 0.000000 0.750000 3.500000 4.000000 0.575007 -1.391261 -0.778831 0.080209 -0.017759 0.750000 3.500000 4.000000 +O O sss -12.737687 -1.851608 -0.666621 0.000000 0.000000 1.200000 3.500000 4.000000 0.296445 -1.911896 -0.663451 0.038054 -0.046608 1.200000 3.500000 4.000000 +O O sps 13.683050 -1.684554 -0.468349 0.000000 0.000000 1.200000 3.500000 4.000000 -0.362143 -1.285274 -0.939591 0.204641 -0.106438 1.200000 3.500000 4.000000 +O O pps 9.460772 -1.211748 -0.581016 0.000000 0.000000 1.200000 3.500000 4.000000 -0.312044 0.121814 -2.519352 1.681266 -0.644566 1.200000 3.500000 4.000000 +O O ppp -4.494595 -2.709223 -0.284124 0.000000 0.000000 1.200000 3.500000 4.000000 0.193010 -2.168462 -0.580629 -0.105104 0.004891 1.200000 3.500000 4.000000 +H O sss -12.230931 -1.808632 -0.421164 0.000000 0.000000 1.000000 3.500000 4.000000 0.404725 -1.702546 -0.707938 0.074904 -0.039922 1.000000 3.500000 4.000000 +H O sps 9.466088 -1.321262 -0.386336 0.000000 0.000000 1.000000 3.500000 4.000000 -0.447660 -0.952979 -1.163537 0.400616 -0.156965 1.000000 3.500000 4.000000 +N N sss -7.710330 -2.365312 -0.525527 0.000000 0.000000 1.500000 3.500000 4.000000 0.231654 -1.879002 -0.572765 -0.004579 -0.031106 1.500000 3.500000 4.000000 +N N sps 8.222314 -1.612118 -0.690081 0.000000 0.000000 1.500000 3.500000 4.000000 -0.305271 -1.385158 -0.751032 0.114531 -0.090839 1.500000 3.500000 4.000000 +N N pps 7.178570 -1.176467 -0.571049 0.000000 0.000000 1.500000 3.500000 4.000000 -0.324668 -0.547805 -1.638658 1.495168 -0.827868 1.500000 3.500000 4.000000 +N N ppp -2.829344 -2.408049 -0.387709 0.000000 0.000000 1.500000 3.500000 4.000000 0.142909 -2.162036 -0.571942 -0.071640 -0.004682 1.500000 3.500000 4.000000 +H N sss -12.095890 -1.519057 -0.277247 0.000000 0.000000 1.000000 3.500000 4.000000 0.446693 -1.500463 -0.657448 0.065741 -0.037004 1.000000 3.500000 4.000000 +H N sps 9.851338 -1.231616 -0.370836 0.000000 0.000000 1.000000 3.500000 4.000000 -0.501530 -0.785734 -1.123232 0.394878 -0.148501 1.000000 3.500000 4.000000 diff --git a/examples/latte/TBparam/electrons.dat b/examples/latte/TBparam/electrons.dat new file mode 100644 index 0000000000..c38fd23ce2 --- /dev/null +++ b/examples/latte/TBparam/electrons.dat @@ -0,0 +1,7 @@ +Noelem= 5 +Element basis Numel Es Ep Ed Ef Mass HubbardU Wss Wpp Wdd Wff +N sp 5.0 -18.58 -7.09 0.0 0.0 14.0067 15.93 0.0 -0.6950 0.0 0.0 +O sp 6.0 -23.96 -9.02 0.0 0.0 15.9994 12.15 0.0 -0.7577 0.0 0.0 +H s 1.0 -6.35 0.0 0.0 0.0 1.0079 12.85 -1.7937 0.0 0.0 0.0 +C sp 4.0 -13.75 -5.28 0.0 0.0 12.01 10.0 0.0 -0.621 0.0 0.0 +Ti sd 4.0 -5.5 0.0 -3.0 0.0 47.867 10.0 0.0 0.0 0.0 0.0 \ No newline at end of file diff --git a/examples/latte/TBparam/ppots.nonortho b/examples/latte/TBparam/ppots.nonortho new file mode 100644 index 0000000000..1b9b66c0a1 --- /dev/null +++ b/examples/latte/TBparam/ppots.nonortho @@ -0,0 +1,12 @@ +Nopps= 10 +Ele1 Ele2 A0 A1 A2 A3 A4 A5 A6 C R1 Rcut +N O 13.182426 20.050322 -46.806321 38.206953 -12.319656 0.000000 0.000000 0.000000 1.600000 1.700000 +C N 88.953762 10.294988 -27.706877 22.101434 -6.836438 0.000000 0.000000 0.000000 1.600000 1.700000 +C O 0.944093 30.116337 -59.608215 45.107654 -13.178839 0.000000 0.000000 0.000000 1.600000 1.700000 +C H 104.889589 3.971095 -23.823043 26.408093 -11.317522 0.000000 0.000000 0.000000 1.200000 1.300000 +C C 3.962931 24.467772 -51.156024 39.031644 -11.342979 0.000000 0.000000 0.000000 1.600000 1.700000 +H H 38.512100 3.887860 -37.769100 57.083500 -34.512200 0.000000 0.000000 0.000000 0.900000 1.000000 +N N 43.228899 15.004605 -36.621777 29.234888 -8.912743 0.000000 0.000000 0.000000 1.600000 1.700000 +N H 0.625470 28.081241 -63.414297 53.286361 -17.352234 0.000000 0.000000 0.000000 1.300000 1.400000 +O O 10.999870 19.303033 -45.747853 37.946431 -11.935755 0.000000 0.000000 0.000000 1.500000 1.600000 +O H 0.481176 33.175383 -81.158683 74.935408 -26.792315 0.000000 0.000000 0.000000 1.200000 1.300000 From 1025c25548f146c320f5ab0126dd918462b6c4bb Mon Sep 17 00:00:00 2001 From: Christian Negre Date: Wed, 1 Mar 2017 09:55:33 -0700 Subject: [PATCH 29/41] latte.in added --- examples/latte/latte.in | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 examples/latte/latte.in diff --git a/examples/latte/latte.in b/examples/latte/latte.in new file mode 100644 index 0000000000..0f834d4023 --- /dev/null +++ b/examples/latte/latte.in @@ -0,0 +1,39 @@ +LATTE INPUT FILE +================ +#This input file resumes the content of MDcontroller and TBparam/control.in +#The parser will only read it if it's present inside the running folder. +#In case this file is not present Latte will read the two files as original. +#The order of the kewords is not important in this file. +#To get a full description of these keywords please see: +## https://github.com/lanl/LATTE/blob/master/Manual/LATTE_manual.pdf + +#General controls +CONTROL{ + xControl= 1 + BASISTYPE= NONORTHO + COORDSFILE= "./coords.dat" + KBT= 0.0 + ENTROPYKIND= 1 + PPOTON= 1 + SPINON= 0 SPINTOL= 1.0e-4 + ELECTRO= 1 ELECMETH= 0 ELEC_QTOL= 1.0e-8 + MAXSCF= 450 + BREAKTOL= 1.0E-6 MINSP2ITER= 22 SP2CONV= REL + FULLQCONV= 0 QITER= 3 + QMIX= 0.25 SPINMIX= 0.25 MDMIX= 0.25 + SPARSEON= 1 THRESHOLDON= 1 NUMTHRESH= 1.0e-6 FILLINSTOP= 100 BLKSZ= 4 + MSPARSE= 1500 + RELAX= 0 RELAXTYPE= SD MAXITER= 100000 RLXFTOL= 0.0000001 + SKIN= 1.0 + CHARGE= 0 + XBO= 1 + XBODISON= 1 + XBODISORDER= 5 + KON= 0 +} + +#Controls for QMD (if using lammps MAXITER must be set to -1) +MDCONTROL{ + MAXITER= -1 +} + From 48ed963fd2f495a90f0deaa28d43f4289a3bde9e Mon Sep 17 00:00:00 2001 From: Christian Negre Date: Wed, 1 Mar 2017 12:05:00 -0700 Subject: [PATCH 30/41] latte in added --- examples/latte/latte.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/latte/latte.in b/examples/latte/latte.in index 0f834d4023..0790317a5d 100644 --- a/examples/latte/latte.in +++ b/examples/latte/latte.in @@ -19,7 +19,7 @@ CONTROL{ ELECTRO= 1 ELECMETH= 0 ELEC_QTOL= 1.0e-8 MAXSCF= 450 BREAKTOL= 1.0E-6 MINSP2ITER= 22 SP2CONV= REL - FULLQCONV= 0 QITER= 3 + FULLQCONV= 1 QITER= 3 QMIX= 0.25 SPINMIX= 0.25 MDMIX= 0.25 SPARSEON= 1 THRESHOLDON= 1 NUMTHRESH= 1.0e-6 FILLINSTOP= 100 BLKSZ= 4 MSPARSE= 1500 From 5c6b0cc85c5e6e57a7ccedfda1db39f030ed0a42 Mon Sep 17 00:00:00 2001 From: Christian Negre Date: Wed, 1 Mar 2017 16:34:20 -0700 Subject: [PATCH 31/41] removed fix_latte from src folder --- src/fix_latte.cpp | 338 ---------------------------------------------- 1 file changed, 338 deletions(-) delete mode 100644 src/fix_latte.cpp diff --git a/src/fix_latte.cpp b/src/fix_latte.cpp deleted file mode 100644 index d7bf6eaccf..0000000000 --- a/src/fix_latte.cpp +++ /dev/null @@ -1,338 +0,0 @@ -/* ---------------------------------------------------------------------- - 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. -------------------------------------------------------------------------- */ - -// NOTES on possible future issues: -// LATTE compute and return 6-value virial tensor -// can LATTE compute per-atom energy and per-atom virial -// for minimize, what about charge DOFs -// implement charge DOF integration -// pass neighbor list to LATTE: half or full -// will we ever auto-adjust the timestep in reset_dt() -// could pass an input file to LATTE, specified in LAMMPS input script -// what units options can LAMMPS be using -// should LATTE take triclinic box from LAMMPS -// does Coulomb potential = pe[i]/q[i], is it 0 when q = 0 -// how will this work for serial/parallel LAMMPS with serial/parallel LATTE - -#include -#include -#include "fix_latte.h" -#include "atom.h" -#include "comm.h" -#include "update.h" -#include "neighbor.h" -#include "domain.h" -#include "force.h" -#include "neigh_request.h" -#include "neigh_list.h" -#include "modify.h" -#include "compute.h" -#include "memory.h" -#include "error.h" - -using namespace LAMMPS_NS; -using namespace FixConst; - -extern "C" { - void latte(int *, int *, double *, int *, int *, - double *, double *, double *, double *, int*, double *, double *, double*); -} - -#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"); - - if (comm->nprocs != 1) - error->all(FLERR,"Fix latte currently runs only in serial"); - - scalar_flag = 1; - global_freq = 1; - extscalar = 1; - virial_flag = 1; - - // store ID of compute pe/atom used to generate Coulomb potential for LATTE - // NULL means LATTE will compute Coulombic potential - - coulomb = 0; - id_pe = NULL; - - if (strcmp(arg[3],"NULL") != 0) { - coulomb = 1; - - 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"); - } - - // initializations - - nmax = 0; - qpotential = NULL; - flatte = NULL; - - latte_energy = 0.0; -} - -/* ---------------------------------------------------------------------- */ - -FixLatte::~FixLatte() -{ - delete [] id_pe; - memory->destroy(qpotential); - memory->destroy(flatte); -} - -/* ---------------------------------------------------------------------- */ - -int FixLatte::setmask() -{ - int mask = 0; - //mask |= INITIAL_INTEGRATE; - //mask |= FINAL_INTEGRATE; - mask |= PRE_REVERSE; - mask |= POST_FORCE; - mask |= MIN_POST_FORCE; - mask |= THERMO_ENERGY; - return mask; -} - -/* ---------------------------------------------------------------------- */ - -void FixLatte::init() -{ - // error checks - - if (domain->dimension == 2) - error->all(FLERR,"Fix latte requires 3d problem"); - - if (coulomb) { - if (atom->q_flag == 0 || force->pair == NULL || force->kspace == NULL) - error->all(FLERR,"Fix latte cannot compute Coulombic potential"); - - 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]; - } - - // must be fully periodic or fully non-periodic - - if (domain->nonperiodic == 0) pbcflag = 1; - else if (!domain->xperiodic && !domain->yperiodic && !domain->zperiodic) - pbcflag = 0; - else error->all(FLERR,"Fix latte requires 3d simulation"); - - // create qpotential & flatte if needed - // for now, assume nlocal will never change - - if (coulomb && qpotential == NULL) { - memory->create(qpotential,atom->nlocal,"latte:qpotential"); - memory->create(flatte,atom->nlocal,3,"latte:flatte"); - } - - /* - // 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 - // could we use a half 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; - */ -} - -/* ---------------------------------------------------------------------- */ - -void FixLatte::init_list(int id, NeighList *ptr) -{ - // list = ptr; -} - -/* ---------------------------------------------------------------------- */ - -void FixLatte::setup(int vflag) -{ - post_force(vflag); -} - -/* ---------------------------------------------------------------------- */ - -void FixLatte::min_setup(int vflag) -{ - post_force(vflag); -} - -/* ---------------------------------------------------------------------- - integrate electronic degrees of freedom -------------------------------------------------------------------------- */ - -void FixLatte::initial_integrate(int vflag) {} - -/* ---------------------------------------------------------------------- - store eflag, so can use it in post_force to tally per-atom energies -------------------------------------------------------------------------- */ - -void FixLatte::pre_reverse(int eflag, int vflag) -{ - eflag_caller = eflag; -} - -/* ---------------------------------------------------------------------- */ - -void FixLatte::post_force(int vflag) -{ - int eflag = eflag_caller; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; - - // compute Coulombic potential = pe[i]/q[i] - // invoke compute pe/atom - // wrap with clear/add and trigger pe/atom calculation every step - - if (coulomb) { - modify->clearstep_compute(); - - if (!(c_pe->invoked_flag & INVOKED_PERATOM)) { - c_pe->compute_peratom(); - c_pe->invoked_flag |= INVOKED_PERATOM; - } - - modify->addstep_compute(update->ntimestep+1); - - double *pe = c_pe->vector_atom; - double *q = atom->q; - int nlocal = atom->nlocal; - - for (int i = 0; i < nlocal; i++) - if (q[i]) qpotential[i] = pe[i]/q[i]; - else qpotential[i] = 0.0; - } - - // hardwire these unsupported flags for now - - int coulombflag = 0; - pe_peratom = 0; - virial_global = 0; // set via vflag_global at some point - virial_peratom = 0; - neighflag = 0; - - // set flags used by LATTE - - int flags[6]; - - flags[0] = pbcflag; // 1 for fully periodic, 0 for fully non-periodic - flags[1] = coulombflag; // 1 for LAMMPS computes Coulombics, 0 for LATTE - flags[2] = pe_peratom; // 1 to return per-atom energies, 0 for no - flags[3] = virial_global; // 1 to return global virial 0 for no - flags[4] = virial_peratom; // 1 to return per-atom virial, 0 for no - flags[5] = neighflag; // 1 to pass neighbor list to LATTE, 0 for no - - // setup LATTE arguments - - int natoms = atom->nlocal; - double *coords = &atom->x[0][0]; - int *type = atom->type; - int ntypes = atom->ntypes; - double *mass = &atom->mass[1]; - double *boxlo = domain->boxlo; - double *boxhi = domain->boxhi; - - double *forces; - if (coulomb) forces = &flatte[0][0]; - else forces = &atom->f[0][0]; - - // invoke LATTE - - int maxiter = -1; - double *dt_latte = &update->dt; - double dt_latte_ang = *dt_latte * 1000.0; // Units of DT must be in Angstroms - -// latte(flags,&natoms,coords,type,&ntypes,mass,boxlo,boxhi, -// forces,&maxiter, &latte_energy, &atom->v[0][0],&update->dt); - - latte(flags,&natoms,coords,type,&ntypes,mass,boxlo,boxhi, - forces,&maxiter, &latte_energy, &atom->v[0][0], &dt_latte_ang); - - // sum LATTE forces to LAMMPS (Coulombic) forces - - if (coulomb) { - double **f = atom->f; - int nlocal = atom->nlocal; - for (int i = 0; i < nlocal; i++) { - f[i][0] += flatte[i][0]; - f[i][1] += flatte[i][1]; - f[i][2] += flatte[i][2]; - } - } -} - -/* ---------------------------------------------------------------------- - integrate electronic degrees of freedom -------------------------------------------------------------------------- */ - -void FixLatte::final_integrate() {} - -/* ---------------------------------------------------------------------- */ - -void FixLatte::reset_dt() -{ - //dtv = update->dt; - //dtf = 0.5 * update->dt * force->ftm2v; -} - -/* ---------------------------------------------------------------------- - DFTB energy from LATTE -------------------------------------------------------------------------- */ - -double FixLatte::compute_scalar() -{ - return latte_energy; -} - -/* ---------------------------------------------------------------------- - memory usage of local arrays -------------------------------------------------------------------------- */ - -double FixLatte::memory_usage() -{ - double bytes = 0.0; - if (coulomb) bytes += nmax * sizeof(double); - if (coulomb) bytes += nmax*3 * sizeof(double); - return bytes; -} From 3298c379821d4e8f8ce81baa45037dbc35dd7daf Mon Sep 17 00:00:00 2001 From: Christian Negre Date: Thu, 9 Mar 2017 14:30:21 -0700 Subject: [PATCH 32/41] Makefile.lammps.gfortran for latte --- lib/latte/Makefile.lammps.gfortran | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/latte/Makefile.lammps.gfortran b/lib/latte/Makefile.lammps.gfortran index 310ba74454..fa6a44869f 100644 --- a/lib/latte/Makefile.lammps.gfortran +++ b/lib/latte/Makefile.lammps.gfortran @@ -21,7 +21,7 @@ latte_SYSLIB = -fopenmp ${latte_PATH}/src/latte_c_bind.o ${latte_PATH}/liblatte -llapack -lblas # Uncomment the following line to use PROGRESS/BML and metis. -latte_SYSLIB += -L${progress_PATH}/install/lib -lprogress -L${bml_PATH}/install/lib -lbml +#latte_SYSLIB += -L${progress_PATH}/install/lib -lprogress -L${bml_PATH}/install/lib -lbml #latte_SYSLIB += -L${metis_PATH}/install -lmetis From 7ed500e8291bbbe39e38f083734ab86180648e89 Mon Sep 17 00:00:00 2001 From: Christian Negre Date: Tue, 21 Mar 2017 17:09:42 -0600 Subject: [PATCH 33/41] added virial --- src/LATTE/fix_latte.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/LATTE/fix_latte.cpp b/src/LATTE/fix_latte.cpp index ba9804de0d..43fba416e7 100644 --- a/src/LATTE/fix_latte.cpp +++ b/src/LATTE/fix_latte.cpp @@ -23,6 +23,7 @@ // should LATTE take triclinic box from LAMMPS // does Coulomb potential = pe[i]/q[i], is it 0 when q = 0 // how will this work for serial/parallel LAMMPS with serial/parallel LATTE +// NOTE: ADD checks for metal units !!!!!!!!!!!!! #include #include @@ -44,11 +45,11 @@ using namespace LAMMPS_NS; using namespace FixConst; extern "C" { - void latte(int *, int *, double *, int *, int *, - double *, double *, double *, double *, int*, - double *, double *, double *); + void latte(int *, int *, double *, int *, int *, + double *, double *, double *, double *, int*, + double *, double *, double *, double * ); } - + #define INVOKED_PERATOM 8 /* ---------------------------------------------------------------------- */ @@ -123,7 +124,7 @@ void FixLatte::init() { // error checks - if (domain->dimension == 2) + if (domain->dimension == 2) error->all(FLERR,"Fix latte requires 3d problem"); if (coulomb) { @@ -220,7 +221,8 @@ void FixLatte::post_force(int vflag) { int eflag = eflag_caller; if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = 0; + // else evflag = 0; + else evflag = eflag_global = vflag_global = eflag_atom = vflag_atom = 0; // compute Coulombic potential = pe[i]/q[i] // invoke compute pe/atom @@ -248,9 +250,9 @@ void FixLatte::post_force(int vflag) // hardwire these unsupported flags for now int coulombflag = 0; - pe_peratom = 0; - virial_global = 0; // set via vflag_global at some point - virial_peratom = 0; + // pe_peratom = 0; + // virial_global = 1; // set via vflag_global at some point + // virial_peratom = 0; neighflag = 0; // set flags used by LATTE @@ -259,9 +261,9 @@ void FixLatte::post_force(int vflag) flags[0] = pbcflag; // 1 for fully periodic, 0 for fully non-periodic flags[1] = coulombflag; // 1 for LAMMPS computes Coulombics, 0 for LATTE - flags[2] = pe_peratom; // 1 to return per-atom energies, 0 for no - flags[3] = virial_global; // 1 to return global virial 0 for no - flags[4] = virial_peratom; // 1 to return per-atom virial, 0 for no + flags[2] = eflag_atom; //pe_peratom; // 1 to return per-atom energies, 0 for no + flags[3] = vflag_global; //virial_global; // 1 to return global virial 0 for no + flags[4] = vflag_atom; //virial_peratom; // 1 to return per-atom virial, 0 for no flags[5] = neighflag; // 1 to pass neighbor list to LATTE, 0 for no // setup LATTE arguments @@ -278,12 +280,10 @@ void FixLatte::post_force(int vflag) if (coulomb) forces = &flatte[0][0]; else forces = &atom->f[0][0]; - // invoke LATTE - int maxiter = -1; latte(flags,&natoms,coords,type,&ntypes,mass,boxlo,boxhi, - forces,&maxiter,&latte_energy,&atom->v[0][0],&update->dt); + forces,&maxiter,&latte_energy,&atom->v[0][0],&update->dt,virial); // sum LATTE forces to LAMMPS (Coulombic) forces From f7bdf128eaa361b021312c0ff94b48a450e4f1b1 Mon Sep 17 00:00:00 2001 From: Christian Negre Date: Wed, 22 Mar 2017 09:35:47 -0600 Subject: [PATCH 34/41] cleaned fix latte --- src/LATTE/fix_latte.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/LATTE/fix_latte.cpp b/src/LATTE/fix_latte.cpp index 43fba416e7..77a186adb9 100644 --- a/src/LATTE/fix_latte.cpp +++ b/src/LATTE/fix_latte.cpp @@ -23,7 +23,7 @@ // should LATTE take triclinic box from LAMMPS // does Coulomb potential = pe[i]/q[i], is it 0 when q = 0 // how will this work for serial/parallel LAMMPS with serial/parallel LATTE -// NOTE: ADD checks for metal units !!!!!!!!!!!!! +// INPORTANT NOTE: ADD checks for metal units !!!!!!!!!!!!! #include #include @@ -261,9 +261,9 @@ void FixLatte::post_force(int vflag) flags[0] = pbcflag; // 1 for fully periodic, 0 for fully non-periodic flags[1] = coulombflag; // 1 for LAMMPS computes Coulombics, 0 for LATTE - flags[2] = eflag_atom; //pe_peratom; // 1 to return per-atom energies, 0 for no - flags[3] = vflag_global; //virial_global; // 1 to return global virial 0 for no - flags[4] = vflag_atom; //virial_peratom; // 1 to return per-atom virial, 0 for no + flags[2] = eflag_atom; // 1 to return per-atom energies, 0 for no + flags[3] = vflag_global; // 1 to return global virial 0 for no + flags[4] = vflag_atom; // 1 to return per-atom virial, 0 for no flags[5] = neighflag; // 1 to pass neighbor list to LATTE, 0 for no // setup LATTE arguments From 756c8995641e37a84b8407c585f948c6f233147b Mon Sep 17 00:00:00 2001 From: Richard Zamora Date: Thu, 23 Mar 2017 10:01:21 -0600 Subject: [PATCH 35/41] testing simple ci --- .gitlab-ci.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000..d5cb18c6e8 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,32 @@ +image: ubuntu:latest + +before_script: + +# Install Linux Packages: +- apt-get update +- hostname +- pwd +- export HOME=/builds/exaalt/ +- env +#- apt-get --yes --force-yes install gfortran libblas-dev liblapack-dev +#- apt-get --yes --force-yes install cmake python gcc cmake-data g++ git wget +#- apt-get --yes --force-yes install pkg-config python-numpy python3-numpy libopenmpi-dev +# +## Build LATTE: +#- cd /builds/exaalt/exaalt/LATTE/ +#- cp ./makefiles/makefile.CHOICES.gfort.lapack.lmp makefile.CHOICES +#- make +# +## Build LAMMPS: +#- cd /builds/exaalt/exaalt/lammps/lib/latte/ +#- cp Makefile.lammps.gfortran Makefile.lammps +#- cd /builds/exaalt/exaalt/lammps/src/ +#- make yes-latte +#- make yes-molecule +#- make serial +# +#script: +# +## Test LAMMPS-LATTE Example: +#- cd /builds/exaalt/exaalt/lammps/examples/latte/ +#- ../../src/lmp_serial -in in.latte.water From 8d793d4223150166213dfab308c341e11cedecce Mon Sep 17 00:00:00 2001 From: Richard Zamora Date: Thu, 23 Mar 2017 10:03:24 -0600 Subject: [PATCH 36/41] testing simple ci, attempt 2 --- .gitlab-ci.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d5cb18c6e8..97281e60eb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,13 +1,14 @@ image: ubuntu:latest -before_script: +#before_script: +script: # Install Linux Packages: -- apt-get update -- hostname -- pwd -- export HOME=/builds/exaalt/ -- env + - apt-get update + - hostname + - pwd + - export HOME=/builds/exaalt/ + - env #- apt-get --yes --force-yes install gfortran libblas-dev liblapack-dev #- apt-get --yes --force-yes install cmake python gcc cmake-data g++ git wget #- apt-get --yes --force-yes install pkg-config python-numpy python3-numpy libopenmpi-dev From e5987628577f95992a6437aca2ceea1d6a9cebf2 Mon Sep 17 00:00:00 2001 From: Richard Zamora Date: Thu, 23 Mar 2017 10:04:03 -0600 Subject: [PATCH 37/41] testing simple ci, attempt 3 --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 97281e60eb..189880eae3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,12 +3,13 @@ image: ubuntu:latest #before_script: script: -# Install Linux Packages: + # Install Linux Packages: - apt-get update - hostname - pwd - export HOME=/builds/exaalt/ - env + #- apt-get --yes --force-yes install gfortran libblas-dev liblapack-dev #- apt-get --yes --force-yes install cmake python gcc cmake-data g++ git wget #- apt-get --yes --force-yes install pkg-config python-numpy python3-numpy libopenmpi-dev From 969325bf441453ac12a2931b0f47d4aa6ea9f89f Mon Sep 17 00:00:00 2001 From: Richard Zamora Date: Thu, 23 Mar 2017 10:08:09 -0600 Subject: [PATCH 38/41] testing simple ci, attempt 4 --- .gitlab-ci.yml | 39 ++++++++------------------------------- 1 file changed, 8 insertions(+), 31 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 189880eae3..f44ffb6a70 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,34 +1,11 @@ image: ubuntu:latest -#before_script: -script: +test: + script: + # Install Linux Packages: + - apt-get update + - hostname + - pwd + - export HOME=/builds/exaalt/ + - env - # Install Linux Packages: - - apt-get update - - hostname - - pwd - - export HOME=/builds/exaalt/ - - env - -#- apt-get --yes --force-yes install gfortran libblas-dev liblapack-dev -#- apt-get --yes --force-yes install cmake python gcc cmake-data g++ git wget -#- apt-get --yes --force-yes install pkg-config python-numpy python3-numpy libopenmpi-dev -# -## Build LATTE: -#- cd /builds/exaalt/exaalt/LATTE/ -#- cp ./makefiles/makefile.CHOICES.gfort.lapack.lmp makefile.CHOICES -#- make -# -## Build LAMMPS: -#- cd /builds/exaalt/exaalt/lammps/lib/latte/ -#- cp Makefile.lammps.gfortran Makefile.lammps -#- cd /builds/exaalt/exaalt/lammps/src/ -#- make yes-latte -#- make yes-molecule -#- make serial -# -#script: -# -## Test LAMMPS-LATTE Example: -#- cd /builds/exaalt/exaalt/lammps/examples/latte/ -#- ../../src/lmp_serial -in in.latte.water From df95b2c566e8b50e67d7cbebdb92cbb9f8c6c419 Mon Sep 17 00:00:00 2001 From: Richard Zamora Date: Thu, 23 Mar 2017 22:27:42 -0600 Subject: [PATCH 39/41] testing simple ci, more complex #1 --- .gitlab-ci.yml | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f44ffb6a70..67ad4ac722 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,11 +1,36 @@ image: ubuntu:latest test: - script: + + before_script: + # Install Linux Packages: - apt-get update - hostname - - pwd - export HOME=/builds/exaalt/ - env + - apt-get --yes --force-yes install gfortran libblas-dev liblapack-dev + - apt-get --yes --force-yes install cmake python gcc cmake-data g++ git wget + - apt-get --yes --force-yes install pkg-config python-numpy python3-numpy libopenmpi-dev + + # Build LATTE: + - cd /builds/exaalt/ + - git clone https://github.com/lanl/LATTE.git + - cd LATTE + - cp ./makefiles/makefile.CHOICES.gfort.lapack.lmp makefile.CHOICES + - make + + # Build LAMMPS: + - cd /builds/exaalt/lammps/lib/latte/ + - cp Makefile.lammps.gfortran Makefile.lammps + - cd /builds/exaalt/lammps/src/ + - make yes-latte + - make yes-molecule + - make serial + + script: + + # Test LAMMPS-LATTE Example: + - cd /builds/exaalt/lammps/examples/latte/ + - ../../src/lmp_serial -in in.latte.water From 98713680ec1bd3adf1573bb0374cab87e9de31a0 Mon Sep 17 00:00:00 2001 From: Christian Negre Date: Wed, 17 May 2017 11:36:31 -0600 Subject: [PATCH 40/41] added alternative linking line for intel mkl --- lib/latte/Makefile.lammps.ifort | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/latte/Makefile.lammps.ifort b/lib/latte/Makefile.lammps.ifort index 1d5c55b2fc..af622dfbd2 100644 --- a/lib/latte/Makefile.lammps.ifort +++ b/lib/latte/Makefile.lammps.ifort @@ -15,6 +15,13 @@ latte_SYSINC = -I${latte_PATH}/src -I${bml_PATH}/install/include -I${progress_P latte_SYSLIB = -openmp ${latte_PATH}/src/latte_c_bind.o ${latte_PATH}/liblatte.a \ -lifcore -lsvml -lompstub -limf -L${MKLROOT}/lib/intel64 -lmkl_lapack95_lp64 -lmkl_intel_lp64 \ -lmkl_intel_thread -lmkl_core -lmkl_intel_thread -lpthread -openmp -O0 \ + +# Alternative linking line +#latte_SYSLIB = -qopenmp ${latte_PATH}/src/latte_c_bind.o ${latte_PATH}/liblatte.a \ +# -L${MKLROOT}/lib/intel64 -lifcore -lsvml -lifport -mkl=parallel -lpthread -qopenmp -O0 \ + +# Uncomment the following line to use PROGRESS/BML +#latte_SYSLIB += -L${progress_PATH}/install/lib -lprogress -L${bml_PATH}/install/lib -lbml -L${metis_PATH}/install -lmetis # Uncomment the following line to use PROGRESS/BML latte_SYSLIB += -L${progress_PATH}/install/lib -lprogress -L${bml_PATH}/install/lib -lbml -L${metis_PATH}/install -lmetis From 60faca2896eeecb50350d318f8237c7f54b26141 Mon Sep 17 00:00:00 2001 From: Christian Negre Date: Fri, 14 Jul 2017 10:05:38 -0600 Subject: [PATCH 41/41] added tilt factors --- src/LATTE/fix_latte.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/LATTE/fix_latte.cpp b/src/LATTE/fix_latte.cpp index 77a186adb9..a35318bc3a 100644 --- a/src/LATTE/fix_latte.cpp +++ b/src/LATTE/fix_latte.cpp @@ -46,7 +46,8 @@ using namespace FixConst; extern "C" { void latte(int *, int *, double *, int *, int *, - double *, double *, double *, double *, int*, + double *, double *, double *, double *, + double *, double *, double *, int*, double *, double *, double *, double * ); } @@ -281,8 +282,9 @@ void FixLatte::post_force(int vflag) else forces = &atom->f[0][0]; int maxiter = -1; - - latte(flags,&natoms,coords,type,&ntypes,mass,boxlo,boxhi, + + latte(flags,&natoms,coords,type,&ntypes,mass,boxlo,boxhi,&domain->xy, + &domain->xz,&domain->yz, forces,&maxiter,&latte_energy,&atom->v[0][0],&update->dt,virial); // sum LATTE forces to LAMMPS (Coulombic) forces