From 3e639fe97957a9398642d63a56389f54824bd8c9 Mon Sep 17 00:00:00 2001 From: kipbarrett Date: Mon, 25 Jan 2021 16:41:35 -0600 Subject: [PATCH 01/25] Initial inclusion of rann potential --- src/activation.cpp | 44 + src/activation.h | 39 + src/activation_linear.cpp | 42 + src/activation_linear.h | 42 + src/activation_sigI.cpp | 41 + src/activation_sigI.h | 42 + src/fingerprint.cpp | 106 ++ src/fingerprint.h | 58 + src/fingerprint_bond.cpp | 912 +++++++++ src/fingerprint_bond.h | 67 + src/fingerprint_bondscreened.cpp | 946 +++++++++ src/fingerprint_bondscreened.h | 67 + src/fingerprint_bondscreenedspin.cpp | 1019 ++++++++++ src/fingerprint_bondscreenedspin.h | 67 + src/fingerprint_bondspin.cpp | 1015 ++++++++++ src/fingerprint_bondspin.h | 67 + src/fingerprint_radial.cpp | 253 +++ src/fingerprint_radial.h | 56 + src/fingerprint_radialscreened.cpp | 266 +++ src/fingerprint_radialscreened.h | 59 + src/fingerprint_radialscreenedspin.cpp | 279 +++ src/fingerprint_radialscreenedspin.h | 59 + src/fingerprint_radialspin.cpp | 265 +++ src/fingerprint_radialspin.h | 56 + src/pair_rann.cpp | 2423 ++++++++++++++++++++++++ src/pair_rann.h | 153 ++ src/style_activation.h | 2 + src/style_fingerprint.h | 8 + 28 files changed, 8453 insertions(+) create mode 100644 src/activation.cpp create mode 100644 src/activation.h create mode 100644 src/activation_linear.cpp create mode 100644 src/activation_linear.h create mode 100644 src/activation_sigI.cpp create mode 100644 src/activation_sigI.h create mode 100644 src/fingerprint.cpp create mode 100644 src/fingerprint.h create mode 100644 src/fingerprint_bond.cpp create mode 100644 src/fingerprint_bond.h create mode 100644 src/fingerprint_bondscreened.cpp create mode 100644 src/fingerprint_bondscreened.h create mode 100644 src/fingerprint_bondscreenedspin.cpp create mode 100644 src/fingerprint_bondscreenedspin.h create mode 100644 src/fingerprint_bondspin.cpp create mode 100644 src/fingerprint_bondspin.h create mode 100644 src/fingerprint_radial.cpp create mode 100644 src/fingerprint_radial.h create mode 100644 src/fingerprint_radialscreened.cpp create mode 100644 src/fingerprint_radialscreened.h create mode 100644 src/fingerprint_radialscreenedspin.cpp create mode 100644 src/fingerprint_radialscreenedspin.h create mode 100644 src/fingerprint_radialspin.cpp create mode 100644 src/fingerprint_radialspin.h create mode 100644 src/pair_rann.cpp create mode 100644 src/pair_rann.h create mode 100644 src/style_activation.h create mode 100644 src/style_fingerprint.h diff --git a/src/activation.cpp b/src/activation.cpp new file mode 100644 index 0000000000..aaa409c4b0 --- /dev/null +++ b/src/activation.cpp @@ -0,0 +1,44 @@ +/* -*- 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. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing author: Christopher Barrett (MSU) barrett@me.msstate.edu + ----------------------------------------------------------------------*/ + + +#include "activation.h" + + +using namespace LAMMPS_NS; + +Activation::Activation(PairRANN *pair) { + empty = true; + style = "empty"; +} + +Activation::~Activation(){ + +} + +//default is linear activation (no change). +double Activation::activation_function(double A){ + return A; +} + +double Activation::dactivation_function(double A){ + return 1.0; +} + +double Activation::ddactivation_function(double A){ + return 0.0; +} diff --git a/src/activation.h b/src/activation.h new file mode 100644 index 0000000000..3fba49723d --- /dev/null +++ b/src/activation.h @@ -0,0 +1,39 @@ +/* -*- 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. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing author: Christopher Barrett (MSU) barrett@me.msstate.edu + ----------------------------------------------------------------------*/ + +#ifndef ACTIVATION_H_ +#define ACTIVATION_H_ + +#include "pair_rann.h" + +namespace LAMMPS_NS { + + class Activation { + public: + Activation(class PairRANN *); + virtual ~Activation(); + virtual double activation_function(double); + virtual double dactivation_function(double); + virtual double ddactivation_function(double); + bool empty; + const char *style; + }; +} + + + +#endif /* ACTIVATION_H_ */ diff --git a/src/activation_linear.cpp b/src/activation_linear.cpp new file mode 100644 index 0000000000..2ad9594be1 --- /dev/null +++ b/src/activation_linear.cpp @@ -0,0 +1,42 @@ +/* -*- 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. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing author: Christopher Barrett (MSU) barrett@me.msstate.edu + ----------------------------------------------------------------------*/ + +#include +#include "activation_linear.h" +#include "activation.h" + + +using namespace LAMMPS_NS; + +Activation_linear::Activation_linear(PairRANN *pair) : Activation(pair){ + empty = false; + style = "linear"; +} + +double Activation_linear::activation_function(double A) +{ + return A; +} + +double Activation_linear::dactivation_function(double A) +{ + return 1.0; +} + +double Activation_linear::ddactivation_function(double){ + return 0.0; +} diff --git a/src/activation_linear.h b/src/activation_linear.h new file mode 100644 index 0000000000..ba39436f03 --- /dev/null +++ b/src/activation_linear.h @@ -0,0 +1,42 @@ +/* -*- 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. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing author: Christopher Barrett (MSU) barrett@me.msstate.edu +*/ + +#ifdef ACTIVATION_CLASS + +ActivationStyle(linear,Activation_linear) + +#else + +#ifndef ACTIVATION_LINEAR_H_ +#define ACTIVATION_LINEAR_H_ + +#include "activation.h" + +namespace LAMMPS_NS { + +class Activation_linear : public Activation { +public: + Activation_linear(class PairRANN *); + double activation_function(double); + double dactivation_function(double); + double ddactivation_function(double); +}; + +} + +#endif +#endif /* ACTIVATION_LINEAR_H_ */ diff --git a/src/activation_sigI.cpp b/src/activation_sigI.cpp new file mode 100644 index 0000000000..cdf82982da --- /dev/null +++ b/src/activation_sigI.cpp @@ -0,0 +1,41 @@ +/* -*- 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. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing author: Christopher Barrett (MSU) barrett@me.msstate.edu + ----------------------------------------------------------------------*/ + +#include +#include "activation_sigI.h" + +using namespace LAMMPS_NS; + +Activation_sigI::Activation_sigI(PairRANN *pair) : Activation(pair){ + empty = false; + style = "sigI"; +} + +double Activation_sigI::activation_function(double in){ + if (in>34)return in; + return 0.1*in + 0.9*log(exp(in) + 1); +} + +double Activation_sigI::dactivation_function(double in){ + if (in>34)return 1; + return 0.1 + 0.9/(exp(in)+1)*exp(in); +} + +double Activation_sigI::ddactivation_function(double in){ + if (in>34)return 0; + return 0.9*exp(in)/(exp(in)+1)/(exp(in)+1);; +} diff --git a/src/activation_sigI.h b/src/activation_sigI.h new file mode 100644 index 0000000000..b47433a336 --- /dev/null +++ b/src/activation_sigI.h @@ -0,0 +1,42 @@ +/* -*- 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. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing author: Christopher Barrett (MSU) barrett@me.msstate.edu +*/ + +#ifdef ACTIVATION_CLASS + +ActivationStyle(sigI,Activation_sigI) + +#else + +#ifndef ACTIVATION_SIGI_H_ +#define ACTIVATION_SIGI_H_ + +#include "activation.h" + +namespace LAMMPS_NS { + + class Activation_sigI : public Activation { + public: + Activation_sigI(class PairRANN *); + double activation_function(double); + double dactivation_function(double); + double ddactivation_function(double); + }; +} + + +#endif +#endif /* ACTIVATION_SIGI_H_ */ diff --git a/src/fingerprint.cpp b/src/fingerprint.cpp new file mode 100644 index 0000000000..cdcb5855bd --- /dev/null +++ b/src/fingerprint.cpp @@ -0,0 +1,106 @@ +/* -*- 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. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + ----------------------------------------------------------------------*/ + +#include "fingerprint.h" +#include +#include +#include +#include +#include +#include + + +using namespace LAMMPS_NS; + +Fingerprint::Fingerprint(PairRANN *pair) +{ + spin = false; + screen = false; + empty = true; + fullydefined = false; + n_body_type = 0; + style = "empty"; + this->pair = pair; +} + +Fingerprint::~Fingerprint(){ + +} + +bool Fingerprint::parse_values(char *word,char *line1){ + return false; +} + +void Fingerprint::init(int *i,int id){ + +} + +void Fingerprint::allocate(){ + +} + +void Fingerprint::compute_fingerprint(double *features,double *dfeaturesx,double *dfeaturesy,double * dfeaturesz, int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl){ + +} + +void Fingerprint::compute_fingerprint(double *features,double *dfeaturesx,double *dfeaturesy,double * dfeaturesz,double *Sik, double *dSikx, double*dSiky, double *dSikz, double *dSijkx, double *dSijky, double *dSijkz, bool *Bij, int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl){ + +} + +void Fingerprint::compute_fingerprint(double *features,double *dfeaturesx,double *dfeaturesy,double * dfeaturesz,double *sx, double *sy, double *sz, int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl){ + +} + +void Fingerprint::compute_fingerprint(double *features,double *dfeaturesx,double *dfeaturesy,double * dfeaturesz,double *sx, double *sy, double *sz, double *Sik, double *dSikx, double*dSiky, double *dSikz, double *dSijkx, double *dSijky, double *dSijkz, bool *Bij, int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl){ + +} + +void Fingerprint::write_values(FILE *fid){ + +} + +int Fingerprint::get_length(){ + return 0; +} + +//Smooth cutoff, goes from 1 to zero over the interval rc-dr to rc. Same as MEAM uses. Used by generateradialtable and generatexpcuttable. +double Fingerprint::cutofffunction(double r,double rc, double dr){ + double out; + if (r < (rc -dr))out=1; + else if (r>rc)out=0; + else { + out = pow(1-pow(1-(rc-r)/dr,4.0),2.0); + } + return out; +} + +void Fingerprint::generate_rinvssqrttable(){ + int buf = 5; + int m; + double r1; + double cutmax = pair->cutmax; + int res = pair->res; + rinvsqrttable = new double[res+buf]; + for (m=0;m<(res+buf);m++){ + r1 = cutmax*cutmax*(double)(m)/(double)(res); + rinvsqrttable[m] = 1/sqrt(r1); + } +} + + + + diff --git a/src/fingerprint.h b/src/fingerprint.h new file mode 100644 index 0000000000..1bef4c0ab8 --- /dev/null +++ b/src/fingerprint.h @@ -0,0 +1,58 @@ +/* -*- 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. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing author: Christopher Barrett (MSU) barrett@me.msstate.edu + ----------------------------------------------------------------------*/ + +#ifndef FINGERPRINT_H_ +#define FINGERPRINT_H_ + +#include "pair_rann.h" + +namespace LAMMPS_NS { + + class Fingerprint { + public: + Fingerprint(PairRANN *); + virtual ~Fingerprint(); + virtual bool parse_values(char*,char*); + virtual void write_values(FILE *); + virtual void init(int*,int); + virtual void allocate(); + void init_screen(int); + virtual void compute_fingerprint(double*,double*,double*,double*,int,int,double*,double*,double*,int*,int,int*);//no screen,no spin + virtual void compute_fingerprint(double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,bool*,int,int,double*,double*,double*,int*,int,int*);//screen + virtual void compute_fingerprint(double*,double*,double*,double*,double*,double*,double*,int,int,double*,double*,double*,int*,int,int*);//spin + virtual void compute_fingerprint(double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,bool*,int,int,double*,double*,double*,int*,int,int*);//spin,screen + virtual int get_length(); + virtual double cutofffunction(double,double, double); + virtual void generate_rinvssqrttable(); + bool spin; + bool screen; + int n_body_type;//i-j vs. i-j-k vs. i-j-k-l, etc. + bool empty; + bool fullydefined; + int startingneuron; + int id;//based on ordering of fingerprints listed for i-j in potential file + const char *style; + int* atomtypes; + double *rinvsqrttable; + double rc; + PairRANN *pair; + }; + +} + + +#endif /* FINGERPRINT_H_ */ diff --git a/src/fingerprint_bond.cpp b/src/fingerprint_bond.cpp new file mode 100644 index 0000000000..7fdece310c --- /dev/null +++ b/src/fingerprint_bond.cpp @@ -0,0 +1,912 @@ +/* -*- 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. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@cavs.msstate.edu + ----------------------------------------------------------------------*/ + + +#include "fingerprint_bond.h" +#include "fingerprint.h" +#include +#include +#include +#include +#include +#include + +using namespace LAMMPS_NS; + +Fingerprint_bond::Fingerprint_bond(PairRANN *pair) : Fingerprint(pair) +{ + n_body_type = 3; + dr = 0; + re = 0; + rc = 0; + alpha_k = new double [1]; + alpha_k[0] = -1; + k = 0; + m = 0; + id = -1; + style = "bond"; + atomtypes = new int [n_body_type]; + empty = true; + pair->allscreen = false; +} + +Fingerprint_bond::~Fingerprint_bond(){ + delete [] alpha_k; + delete [] atomtypes; + delete [] expcuttable; + delete [] dfctable; + for (int i=0;i<(m*(m+1))>>1;i++){ + delete [] coeff[i]; + delete [] coeffx[i]; + delete [] coeffy[i]; + delete [] coeffz[i]; + delete [] Mf[i]; + } + delete [] coeff; + delete [] coeffx; + delete [] coeffy; + delete [] coeffz; + delete [] Mf; + delete [] rinvsqrttable; +} + +bool Fingerprint_bond::parse_values(char * constant, char * line1){ + char **words=new char *[MAXLINE]; + int nwords,l; + nwords=0; + words[nwords++] = strtok(line1,": ,\t\n"); + while ((words[nwords++] = strtok(NULL,": ,\t\n"))) continue; + nwords -= 1; + if (strcmp(constant,"re")==0){ + re = strtod(words[0],NULL); + } + else if (strcmp(constant,"rc")==0){ + rc = strtod(words[0],NULL); + } + else if (strcmp(constant,"alphak")==0){ + delete [] alpha_k; + alpha_k = new double [nwords]; + for (l=0;lerrorf("Undefined value for bond power"); + delete [] words; + if (re!=0.0 && rc!=0.0 && alpha_k[0]!=-1 && dr!=0.0 && m!=0 && k!=0)return true; + return false; +} + +void Fingerprint_bond::write_values(FILE *fid){ + int i; + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:re:\n",style,id); + fprintf(fid,"%f\n",re); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:rc:\n",style,id); + fprintf(fid,"%f\n",rc); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:alphak:\n",style,id); + for (i=0;ielementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:dr:\n",style,id); + fprintf(fid,"%f\n",dr); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:k:\n",style,id); + fprintf(fid,"%d\n",k); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:m:\n",style,id); + fprintf(fid,"%d\n",m); +} + +void Fingerprint_bond::init(int *i,int id){ + for (int j=0;jk = 0; + alpha_k = new double [1]; + alpha_k[0]=-1; + empty = false; + this->id = id; +} + +//number of neurons defined by this fingerprint +int Fingerprint_bond::get_length(){ + return m*k; +} + +void Fingerprint_bond::allocate(){ + generate_exp_cut_table(); + generate_coefficients(); + generate_rinvssqrttable(); +} + +//Generate table of complex functions for quick reference during compute. Used by do3bodyfeatureset_singleneighborloop and do3bodyfeatureset_doubleneighborloop. +void Fingerprint_bond::generate_exp_cut_table(){ + int m,n; + double r1; + int buf = 5; + int res = pair->res; + double cutmax = pair->cutmax; + expcuttable = new double [(res+buf)*(this->k)]; + dfctable = new double [res+buf]; + for (m=0;m<(res+buf);m++){ + r1 = cutmax*cutmax*(double)(m)/(double)(res); + for (n=0;n<(this->k);n++){ + expcuttable[n+m*(this->k)] = exp(-alpha_k[n]/re*sqrt(r1))*cutofffunction(sqrt(r1),rc,dr); + } + if (sqrt(r1)>=rc || sqrt(r1) <= (rc-dr)){ + dfctable[m]=0; + } + else{ + dfctable[m]=-8*pow(1-(rc-sqrt(r1))/dr,3)/dr/(1-pow(1-(rc-sqrt(r1))/dr,4)); + } + } +} + +//Generate table of complex functions for quick reference during compute. Used by do3bodyfeatureset_singleneighborloop. +void Fingerprint_bond::generate_coefficients(){ //calculates multinomial coefficient for each term + int p,mb,mc; + int n,p1,i1; + mb = this->m; + mc=(mb*(mb+1))>>1; + coeff = new int *[mc]; + coeffx = new int *[mc]; + coeffy = new int *[mc]; + coeffz = new int *[mc]; + for (p=0;pm+1]; + for (p=0;pm+1;p++){ + M[p]=0; + } + for (p1=0;p1sims[sid]; + ilist = sim->ilist; + numneigh = sim->numneigh; + i = ilist[ii]; +// jnum = numneigh[i]; + //select the more efficient algorithm for this particular potential and environment. + if (jnum*2>(m+1)*m*20){ + do3bodyfeatureset_singleneighborloop(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,sid,xn,yn,zn,tn,jnum,jl); + } + else{ + do3bodyfeatureset_doubleneighborloop(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,sid,xn,yn,zn,tn,jnum,jl); + + } +} + +//Called by do3bodyfeatureset. Algorithm for high neighbor numbers and small series of bond angle powers +void Fingerprint_bond::do3bodyfeatureset_singleneighborloop(double * features,double * dfeaturesx,double *dfeaturesy,double *dfeaturesz,int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl){ + int i,j,jj,itype,jtype,kk,m,n,mcount,a,a1,a2,ai; + double xtmp,ytmp,ztmp,delx,dely,delz,rsq; + int *ilist,*jlist,*numneigh,**firstneigh; + int count=0; + PairRANN::Simulation *sim = &pair->sims[sid]; +// double **x = sim->x; + int *type = sim->type; + double cutmax = pair->cutmax; + int res = pair->res; + double cutinv2 = 1/cutmax/cutmax; + ilist = sim->ilist; +// numneigh = sim->numneigh; +// firstneigh = sim->firstneigh; + int nelements=pair->nelements; + i = ilist[ii]; + itype = pair->map[type[i]]; + int f = pair->net[itype].dimensions[0]; +// xtmp = x[i][0]; +// ytmp = x[i][1]; +// ztmp = x[i][2]; +// jlist = firstneigh[i]; +// jnum = numneigh[i]; + double expr[jnum][this->k+12]; + int p = this->k; + int countmb=((this->m)*(this->m+1))>>1; + // calculate interpolation expr, rinvs and dfc, for each neighbor + for (jj = 0; jj < jnum; jj++) { +// j = jlist[jj]; +// j &= NEIGHMASK; +// jtype = pair->map[type[j]]; + jtype = tn[jj]; + if (atomtypes[1] != nelements && atomtypes[1] != jtype && atomtypes[2] != nelements && atomtypes[2] != jtype){ + expr[jj][0]=0; + continue; + } +// delx = xtmp - x[j][0]; +// dely = ytmp - x[j][1]; +// delz = ztmp - x[j][2]; + delx = xn[jj]; + dely = yn[jj]; + delz = zn[jj]; + rsq = delx*delx + dely*dely + delz*delz; + if (rsq>rc*rc){ + expr[jj][0]=0; + continue; + } + double r1 = (rsq*((double)res)*cutinv2); + int m1 = (int)r1; + r1 = r1-trunc(r1); + double *p0 = &expcuttable[(m1-1)*this->k]; + double *p1 = &expcuttable[m1*this->k]; + double *p2 = &expcuttable[(m1+1)*this->k]; + double *p3 = &expcuttable[(m1+2)*this->k]; + for (kk=0;kkk;kk++){ + expr[jj][kk] = p1[kk]+0.5*r1*(p2[kk]-p0[kk]+r1*(2.0*p0[kk]-5.0*p1[kk]+4.0*p2[kk]-p3[kk]+r1*(3.0*(p1[kk]-p2[kk])+p3[kk]-p0[kk]))); + } + double* q = &dfctable[m1-1]; + double* ri = &rinvsqrttable[m1-1]; + double dfc = q[1] + 0.5 * r1*(q[2] - q[0] + r1*(2.0*q[0] - 5.0*q[1] + 4.0*q[2] - q[3] + r1*(3.0*(q[1] - q[2]) + q[3] - q[0]))); + double rinvs = ri[1] + 0.5 * r1*(ri[2] - ri[0] + r1*(2.0*ri[0] - 5.0*ri[1] + 4.0*ri[2] - ri[3] + r1*(3.0*(ri[1] - ri[2]) + ri[3] - ri[0]))); + + expr[jj][p]=delx*rinvs; + expr[jj][p+1]=dely*rinvs; + expr[jj][p+2]=delz*rinvs; + //Hack to avoid nan when x y or z component of radial vector is exactly 0. Shouldn't affect accuracy. + if (expr[jj][p]*expr[jj][p]<0.000000000001){ + expr[jj][p] = 0.000001; + } + if (expr[jj][p+1]*expr[jj][p+1]<0.000000000001){ + expr[jj][p+1] = 0.000001; + } + if (expr[jj][p+2]*expr[jj][p+2]<0.000000000001){ + expr[jj][p+2] = 0.000001; + } + expr[jj][p+3] = -dfc*expr[jj][p]; + expr[jj][p+4] = rinvs/expr[jj][p]; + expr[jj][p+5] = rinvs*expr[jj][p]; + expr[jj][p+6] = -dfc*expr[jj][p+1]; + expr[jj][p+7] = rinvs/expr[jj][p+1]; + expr[jj][p+8] = rinvs*expr[jj][p+1]; + expr[jj][p+9] = -dfc*expr[jj][p+2]; + expr[jj][p+10] = rinvs/expr[jj][p+2]; + expr[jj][p+11] = rinvs*expr[jj][p+2]; + } + + int kb = this->k; + int mb = this->m; + count = startingneuron; + double Bb[mb]; + double dBbx; + double dBby; + double dBbz; +// double dBbx1[mb]; +// double dBby1[mb]; +// double dBbz1[mb]; + double yprod; + for (mcount=0;mcountcoeffx[mcount]; + int *coeffy = this->coeffy[mcount]; + int *coeffz = this->coeffz[mcount]; + int *coeff = this->coeff[mcount]; + a = mb+1; + for (a1=0;a1map[type[j]]; + jtype = tn[jj]; + if (atomtypes[1] != nelements && atomtypes[1] != jtype){ + continue; + } + double yprod = expr[jj][ai]; + double *y4 = &expr[jj][p]; + for (a2=0;a2map[type[j]]; + jtype = tn[jj]; + if (atomtypes[2] != nelements && atomtypes[2] != jtype){ + continue; + } + double yprod = expr[jj][ai]; + double *y4 = &expr[jj][p]; + for (a2=0;a2map[type[j]]; + jtype = tn[jj]; + if (atomtypes[2] != nelements && atomtypes[2] != jtype){ + continue; + } + double *y3 = &expr[jj][p+3]; + double *y4 = &expr[jj][p]; + ai = n; + yprod = expr[jj][ai]; + for (a2=0;a2map[type[j]]; + jtype = tn[jj]; + if (atomtypes[1] != nelements && atomtypes[1] != jtype){ + continue; + } + double *y3 = &expr[jj][p+3]; + double *y4 = &expr[jj][p]; + ai = n; + yprod = expr[jj][ai]; + for (a2=0;a2map[type[j]]; + jtype = tn[jj]; + if (atomtypes[1] != nelements && atomtypes[1] != jtype){ + continue; + } + double *y3 = &expr[jj][p+3]; + double *y4 = &expr[jj][p]; + ai = n; + yprod = expr[jj][ai]; + for (a2=0;a2sims[sid]; + double **x = sim->x; + int *type = sim->type; + int nelements = pair->nelements; + int res = pair->res; + double cutmax = pair->cutmax; + double cutinv2 = 1/cutmax/cutmax; + ilist = sim->ilist; +// numneigh = sim->numneigh; +// firstneigh = sim->firstneigh; + i = ilist[ii]; + itype = pair->map[type[i]]; + int f = pair->net[itype].dimensions[0]; +// xtmp = x[i][0]; +// ytmp = x[i][1]; +// ztmp = x[i][2]; +// jlist = firstneigh[i]; +// jnum = numneigh[i]; + double expr[jnum][this->k]; + double y[jnum][3]; + double ri[jnum]; + double dfc[jnum]; + int kb = this->k; + int mb = this->m; + double c41[this->k]; + double c51[this->k]; + double c61[this->k]; + double ct[this->k]; + for (jj = 0; jj < jnum; jj++) { +// j = jlist[jj]; +// j &= NEIGHMASK; +// jtype = pair->map[type[j]]; + jtype = tn[jj]; + if (jtypes != nelements && jtypes != jtype && ktypes != nelements && ktypes != jtype){ + expr[jj][0]=0; + continue; + } +// delx = xtmp - x[j][0]; +// dely = ytmp - x[j][1]; +// delz = ztmp - x[j][2]; + delx = xn[jj]; + dely = yn[jj]; + delz = zn[jj]; + rsq = delx*delx + dely*dely + delz*delz; + if (rsq>rc*rc){ + expr[jj][0]=0; + continue; + } + double r1 = (rsq*((double)res)*cutinv2); + int m1 = (int)r1; + if (!(m1>=1 && m1 <= res))pair->errorf("Neighbor list is invalid.");//usually results from nan somewhere. + r1 = r1-trunc(r1); + double *p0 = &expcuttable[(m1-1)*this->k]; + double *p1 = &expcuttable[m1*this->k]; + double *p2 = &expcuttable[(m1+1)*this->k]; + double *p3 = &expcuttable[(m1+2)*this->k]; + for (kk=0;kkk;kk++){ + expr[jj][kk] = p1[kk]+0.5*r1*(p2[kk]-p0[kk]+r1*(2.0*p0[kk]-5.0*p1[kk]+4.0*p2[kk]-p3[kk]+r1*(3.0*(p1[kk]-p2[kk])+p3[kk]-p0[kk]))); + } + double* q = &dfctable[m1-1]; + double* r2 = &rinvsqrttable[m1-1]; + dfc[jj] = q[1] + 0.5 * r1*(q[2] - q[0] + r1*(2.0*q[0] - 5.0*q[1] + 4.0*q[2] - q[3] + r1*(3.0*(q[1] - q[2]) + q[3] - q[0]))); + ri[jj] = r2[1] + 0.5 * r1*(r2[2] - r2[0] + r1*(2.0*r2[0] - 5.0*r2[1] + 4.0*r2[2] - r2[3] + r1*(3.0*(r2[1] - r2[2]) + r2[3] - r2[0]))); + y[jj][0]=delx*ri[jj]; + y[jj][1]=dely*ri[jj]; + y[jj][2]=delz*ri[jj]; + } +// if (i==5){ +// for (jj=0;jjmap[type[j]]; + jtype = tn[jj]; + if (jtypes != nelements && jtypes != jtype){ + continue; + } + for (n = 0;nk;n++){ + ct[n] = 2*alpha_k[n]/re; + c41[n]=(-ct[n]+2*dfc[jj])*y[jj][0]; + c51[n]=(-ct[n]+2*dfc[jj])*y[jj][1]; + c61[n]= (-ct[n]+2*dfc[jj])*y[jj][2]; + } + if (jtypes==ktypes){ + for (kk=jj+1;kk< jnum; kk++){ + if (expr[kk][0]==0)continue; +// int k1 = jlist[kk]; +// k1 &= NEIGHMASK; +// ktype = pair->map[type[k1]]; + ktype = tn[kk]; + if (ktypes != nelements && ktypes != ktype){ + continue; + } + count = startingneuron; + double dot = (y[jj][0]*y[kk][0]+y[jj][1]*y[kk][1]+y[jj][2]*y[kk][2]); + double c1 = 2*ri[jj]*(y[kk][0]-dot*y[jj][0]); + double c2 = 2*ri[jj]*(y[kk][1]-dot*y[jj][1]); + double c3 = 2*ri[jj]*(y[kk][2]-dot*y[jj][2]); + double c10 = 2*ri[kk]*(y[jj][0]-dot*y[kk][0]); + double c11 = 2*ri[kk]*(y[jj][1]-dot*y[kk][1]); + double c12 = 2*ri[kk]*(y[jj][2]-dot*y[kk][2]); +// double c1 = 2*ri[jj]*y[kk][0]*(1-y[jj][0]*y[jj][0]); +// double c2 = 2*ri[jj]*y[kk][1]*(1-y[jj][1]*y[jj][1]); +// double c3 = 2*ri[jj]*y[kk][2]*(1-y[jj][2]*y[jj][2]); +// double c10 = 2*ri[kk]*y[jj][0]*(1-y[kk][0]*y[kk][0]); +// double c11 = 2*ri[kk]*y[jj][1]*(1-y[kk][1]*y[kk][1]); +// double c12 = 2*ri[kk]*y[jj][2]*(1-y[kk][2]*y[kk][2]); + for (n=0;nmap[type[k1]]; + ktype = tn[kk]; + if (ktypes != nelements && ktypes != ktype){ + continue; + } + count = startingneuron; + double dot = (y[jj][0]*y[kk][0]+y[jj][1]*y[kk][1]+y[jj][2]*y[kk][2]); + double c1 = ri[jj]*(y[kk][0]-dot*y[jj][0]); + double c2 = ri[jj]*(y[kk][1]-dot*y[jj][1]); + double c3 = ri[jj]*(y[kk][2]-dot*y[jj][2]); + double c10 = ri[kk]*(y[jj][0]-dot*y[kk][0]); + double c11 = ri[kk]*(y[jj][1]-dot*y[kk][1]); + double c12 = ri[kk]*(y[jj][2]-dot*y[kk][2]); +// double c1 = 2*ri[jj]*y[kk][0]*(1-y[jj][0]*y[jj][0]); +// double c2 = 2*ri[jj]*y[kk][1]*(1-y[jj][1]*y[jj][1]); +// double c3 = 2*ri[jj]*y[kk][2]*(1-y[jj][2]*y[jj][2]); +// double c10 = 2*ri[kk]*y[jj][0]*(1-y[kk][0]*y[kk][0]); +// double c11 = 2*ri[kk]*y[jj][1]*(1-y[kk][1]*y[kk][1]); +// double c12 = 2*ri[kk]*y[jj][2]*(1-y[kk][2]*y[kk][2]); + for (n=0;n +#include +#include +#include +#include +#include + +using namespace LAMMPS_NS; + +Fingerprint_bondscreened::Fingerprint_bondscreened(PairRANN *pair) : Fingerprint(pair) +{ + n_body_type = 3; + dr = 0; + re = 0; + rc = 0; + alpha_k = new double [1]; + alpha_k[0] = -1; + k = 0; + m = 0; + id = -1; + style = "bondscreened"; + atomtypes = new int [n_body_type]; + empty = true; + pair->doscreen = true; + screen = true; +} + +Fingerprint_bondscreened::~Fingerprint_bondscreened(){ + delete [] alpha_k; + delete [] atomtypes; + delete [] expcuttable; + delete [] dfctable; + for (int i=0;i<(m*(m+1))>>1;i++){ + delete [] coeff[i]; + delete [] coeffx[i]; + delete [] coeffy[i]; + delete [] coeffz[i]; + delete [] Mf[i]; + } + delete [] coeff; + delete [] coeffx; + delete [] coeffy; + delete [] coeffz; + delete [] Mf; + delete [] rinvsqrttable; +} + +bool Fingerprint_bondscreened::parse_values(char * constant, char * line1){ + char **words=new char *[MAXLINE]; + int nwords,l; + nwords=0; + words[nwords++] = strtok(line1,": ,\t\n"); + while ((words[nwords++] = strtok(NULL,": ,\t\n"))) continue; + nwords -= 1; + if (strcmp(constant,"re")==0){ + re = strtod(words[0],NULL); + } + else if (strcmp(constant,"rc")==0){ + rc = strtod(words[0],NULL); + } + else if (strcmp(constant,"alphak")==0){ + delete [] alpha_k; + alpha_k = new double [nwords]; + for (l=0;lerrorf("Undefined value for bond power"); + delete [] words; + if (re!=0.0 && rc!=0.0 && alpha_k[0]!=-1 && dr!=0.0 && m!=0 && k!=0)return true; + return false; +} + +void Fingerprint_bondscreened::write_values(FILE *fid){ + int i; + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:re:\n",style,id); + fprintf(fid,"%f\n",re); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:rc:\n",style,id); + fprintf(fid,"%f\n",rc); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:alphak:\n",style,id); + for (i=0;ielementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:dr:\n",style,id); + fprintf(fid,"%f\n",dr); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:k:\n",style,id); + fprintf(fid,"%d\n",k); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:m:\n",style,id); + fprintf(fid,"%d\n",m); +} + +void Fingerprint_bondscreened::init(int *i,int id){ + for (int j=0;jk = 0; + alpha_k = new double [1]; + alpha_k[0]=-1; + empty = false; + this->id = id; +} + +//number of neurons defined by this fingerprint +int Fingerprint_bondscreened::get_length(){ + return m*k; +} + +void Fingerprint_bondscreened::allocate(){ + generate_exp_cut_table(); + generate_coefficients(); + generate_rinvssqrttable(); +} + +//Generate table of complex functions for quick reference during compute. Used by do3bodyfeatureset_singleneighborloop and do3bodyfeatureset_doubleneighborloop. +void Fingerprint_bondscreened::generate_exp_cut_table(){ + int m,n; + double r1; + int buf = 5; + int res = pair->res; + double cutmax = pair->cutmax; + expcuttable = new double [(res+buf)*(this->k)]; + dfctable = new double [res+buf]; + for (m=0;m<(res+buf);m++){ + r1 = cutmax*cutmax*(double)(m)/(double)(res); + for (n=0;n<(this->k);n++){ + expcuttable[n+m*(this->k)] = exp(-alpha_k[n]/re*sqrt(r1))*cutofffunction(sqrt(r1),rc,dr); + } + if (sqrt(r1)>=rc || sqrt(r1) <= (rc-dr)){ + dfctable[m]=0; + } + else{ + dfctable[m]=-8*pow(1-(rc-sqrt(r1))/dr,3)/dr/(1-pow(1-(rc-sqrt(r1))/dr,4)); + } + } +} + + +//Generate table of complex functions for quick reference during compute. Used by do3bodyfeatureset_singleneighborloop. +void Fingerprint_bondscreened::generate_coefficients(){ //calculates multinomial coefficient for each term + int p,mb,mc; + int n,p1,i1; + mb = this->m; + mc=(mb*(mb+1))>>1; + coeff = new int *[mc]; + coeffx = new int *[mc]; + coeffy = new int *[mc]; + coeffz = new int *[mc]; + for (p=0;pm+1]; + for (p=0;pm+1;p++){ + M[p]=0; + } + for (p1=0;p1sims[sid]; +// ilist = sim->ilist; +// numneigh = sim->numneigh; +// i = ilist[ii]; +// jnum = numneigh[i]; + //select the more efficient algorithm for this particular potential and environment. + if (jnum*2>(m+1)*m*20){ + do3bodyfeatureset_singleneighborloop(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,sid,xn,yn,zn,tn,jnum,jl); + } + else{ + do3bodyfeatureset_doubleneighborloop(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,sid,xn,yn,zn,tn,jnum,jl); + + } +} + +//Called by do3bodyfeatureset. Algorithm for high neighbor numbers and small series of bond angle powers +void Fingerprint_bondscreened::do3bodyfeatureset_singleneighborloop(double * features,double * dfeaturesx,double *dfeaturesy,double *dfeaturesz,double *Sik, double *dSikx, double*dSiky, double *dSikz, double *dSijkx, double *dSijky, double *dSijkz, bool *Bij,int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl){ + int i,j,jj,itype,jtype,kk,m,n,mcount,a,a1,a2,ai; + double xtmp,ytmp,ztmp,delx,dely,delz,rsq; + int *ilist,*jlist,*numneigh,**firstneigh; + int count=0; + PairRANN::Simulation *sim = &pair->sims[sid]; +// double **x = sim->x; + //double **f = atom->f; + int *type = sim->type; + double cutmax = pair->cutmax; + int res = pair->res; + double cutinv2 = 1/cutmax/cutmax; + ilist = sim->ilist; +// numneigh = sim->numneigh; +// firstneigh = sim->firstneigh; + int nelements=pair->nelements; + i = ilist[ii]; + itype = pair->map[type[i]]; + int f = pair->net[itype].dimensions[0]; +// xtmp = x[i][0]; +// ytmp = x[i][1]; +// ztmp = x[i][2]; +// jlist = firstneigh[i]; +// jnum = numneigh[i]; + double expr[jnum][this->k+12]; + int p = this->k; + int countmb=((this->m)*(this->m+1))>>1; + // calculate interpolation expr, rinvs and dfc, for each neighbor + for (jj = 0; jj < jnum; jj++) { + if (Bij[jj]==false){continue;} +// j = jlist[jj]; +// j &= NEIGHMASK; +// jtype = pair->map[type[j]]; + jtype = tn[jj]; + if (atomtypes[1] != nelements && atomtypes[1] != jtype && atomtypes[2] != nelements && atomtypes[2] != jtype){ + expr[jj][0]=0; + continue; + } +// delx = xtmp - x[j][0]; +// dely = ytmp - x[j][1]; +// delz = ztmp - x[j][2]; + delx=xn[jj]; + dely=yn[jj]; + delz=zn[jj]; + rsq = delx*delx + dely*dely + delz*delz; + if (rsq>rc*rc){ + expr[jj][0]=0; + continue; + } + double r1 = (rsq*((double)res)*cutinv2); + int m1 = (int)r1; + r1 = r1-trunc(r1); + double *p0 = &expcuttable[(m1-1)*this->k]; + double *p1 = &expcuttable[m1*this->k]; + double *p2 = &expcuttable[(m1+1)*this->k]; + double *p3 = &expcuttable[(m1+2)*this->k]; + for (kk=0;kkk;kk++){ + expr[jj][kk] = p1[kk]+0.5*r1*(p2[kk]-p0[kk]+r1*(2.0*p0[kk]-5.0*p1[kk]+4.0*p2[kk]-p3[kk]+r1*(3.0*(p1[kk]-p2[kk])+p3[kk]-p0[kk]))); + expr[jj][kk] *= Sik[jj]; + } + double* q = &dfctable[m1-1]; + double* ri = &rinvsqrttable[m1-1]; + double dfc = q[1] + 0.5 * r1*(q[2] - q[0] + r1*(2.0*q[0] - 5.0*q[1] + 4.0*q[2] - q[3] + r1*(3.0*(q[1] - q[2]) + q[3] - q[0]))); + double rinvs = ri[1] + 0.5 * r1*(ri[2] - ri[0] + r1*(2.0*ri[0] - 5.0*ri[1] + 4.0*ri[2] - ri[3] + r1*(3.0*(ri[1] - ri[2]) + ri[3] - ri[0]))); + + expr[jj][p]=delx*rinvs; + expr[jj][p+1]=dely*rinvs; + expr[jj][p+2]=delz*rinvs; + //Hack to avoid nan when x y or z component of radial vector is exactly 0. Shouldn't affect accuracy. + if (expr[jj][p]*expr[jj][p]<0.000000000001){ + expr[jj][p] = 0.000001; + } + if (expr[jj][p+1]*expr[jj][p+1]<0.000000000001){ + expr[jj][p+1] = 0.000001; + } + if (expr[jj][p+2]*expr[jj][p+2]<0.000000000001){ + expr[jj][p+2] = 0.000001; + } + expr[jj][p+3] = -dfc*expr[jj][p]-dSikx[jj]; + expr[jj][p+4] = rinvs/expr[jj][p]; + expr[jj][p+5] = rinvs*expr[jj][p]; + expr[jj][p+6] = -dfc*expr[jj][p+1]-dSiky[jj]; + expr[jj][p+7] = rinvs/expr[jj][p+1]; + expr[jj][p+8] = rinvs*expr[jj][p+1]; + expr[jj][p+9] = -dfc*expr[jj][p+2]-dSikz[jj]; + expr[jj][p+10] = rinvs/expr[jj][p+2]; + expr[jj][p+11] = rinvs*expr[jj][p+2]; + } + + int kb = this->k; + int mb = this->m; +// int ind = kb+mb*kb; + count = startingneuron; + double Bb[mb]; + double dBbx; + double dBby; + double dBbz; + double dBbx1[mb]; + double dBby1[mb]; + double dBbz1[mb]; + double yprod; + for (mcount=0;mcountcoeffx[mcount]; + int *coeffy = this->coeffy[mcount]; + int *coeffz = this->coeffz[mcount]; + int *coeff = this->coeff[mcount]; + a = mb+1; + for (a1=0;a1map[type[j]]; + jtype = tn[jj]; + if (atomtypes[1] != nelements && atomtypes[1] != jtype){ + continue; + } + double yprod = expr[jj][ai]; + double *y4 = &expr[jj][p]; + for (a2=0;a2map[type[j]]; + jtype = tn[jj]; + if (atomtypes[2] != nelements && atomtypes[2] != jtype){ + continue; + } + double yprod = expr[jj][ai]; + double *y4 = &expr[jj][p]; + for (a2=0;a2map[type[j]]; + jtype = tn[jj]; + if (atomtypes[2] != nelements && atomtypes[2] != jtype){ + continue; + } + double *y3 = &expr[jj][p+3]; + double *y4 = &expr[jj][p]; + ai = n; + yprod = expr[jj][ai]; + for (a2=0;a2map[type[j]]; + jtype = tn[jj]; + if (atomtypes[1] != nelements && atomtypes[1] != jtype){ + continue; + } + double *y3 = &expr[jj][p+3]; + double *y4 = &expr[jj][p]; + ai = n; + yprod = expr[jj][ai]; + for (a2=0;a2map[type[j]]; + jtype = tn[jj]; + if (atomtypes[1] != nelements && atomtypes[1] != jtype){ + continue; + } + double *y3 = &expr[jj][p+3]; + double *y4 = &expr[jj][p]; + ai = n; + yprod = expr[jj][ai]; + for (a2=0;a2sims[sid]; +// double **x = sim->x; + int *type = sim->type; + int nelements = pair->nelements; + int res = pair->res; + double cutmax = pair->cutmax; + double cutinv2 = 1/cutmax/cutmax; + ilist = sim->ilist; +// numneigh = sim->numneigh; +// firstneigh = sim->firstneigh; + i = ilist[ii]; + itype = pair->map[type[i]]; + int f = pair->net[itype].dimensions[0]; +// xtmp = x[i][0]; +// ytmp = x[i][1]; +// ztmp = x[i][2]; +// jlist = firstneigh[i]; +// jnum = numneigh[i]; + double expr[jnum][this->k]; + double y[jnum][3]; + double ri[jnum]; + double dfc[jnum]; + int kb = this->k; + int mb = this->m; + double Bijk[kb][mb]; + double c41[this->k]; + double c51[this->k]; + double c61[this->k]; + double ct[this->k]; + for (jj = 0; jj < jnum; jj++) { + if (Bij[jj]==false){continue;} +// j = jlist[jj]; +// j &= NEIGHMASK; +// jtype = pair->map[type[j]]; + jtype = tn[jj]; + if (jtypes != nelements && jtypes != jtype && ktypes != nelements && ktypes != jtype){ + expr[jj][0]=0; + continue; + } +// delx = xtmp - x[j][0]; +// dely = ytmp - x[j][1]; +// delz = ztmp - x[j][2]; + delx = xn[jj]; + dely = yn[jj]; + delz = zn[jj]; + rsq = delx*delx + dely*dely + delz*delz; + if (rsq>rc*rc){ + expr[jj][0]=0; + continue; + } + double r1 = (rsq*((double)res)*cutinv2); + int m1 = (int)r1; + if (!(m1>=1 && m1 <= res))pair->errorf("Neighbor list is invalid.");//usually results from nan somewhere. + r1 = r1-trunc(r1); + double *p0 = &expcuttable[(m1-1)*this->k]; + double *p1 = &expcuttable[m1*this->k]; + double *p2 = &expcuttable[(m1+1)*this->k]; + double *p3 = &expcuttable[(m1+2)*this->k]; + for (kk=0;kkk;kk++){ + expr[jj][kk] = p1[kk]+0.5*r1*(p2[kk]-p0[kk]+r1*(2.0*p0[kk]-5.0*p1[kk]+4.0*p2[kk]-p3[kk]+r1*(3.0*(p1[kk]-p2[kk])+p3[kk]-p0[kk]))); + expr[jj][kk] *= Sik[jj]; + } + double* q = &dfctable[m1-1]; + double* r2 = &rinvsqrttable[m1-1]; + dfc[jj] = q[1] + 0.5 * r1*(q[2] - q[0] + r1*(2.0*q[0] - 5.0*q[1] + 4.0*q[2] - q[3] + r1*(3.0*(q[1] - q[2]) + q[3] - q[0]))); + ri[jj] = r2[1] + 0.5 * r1*(r2[2] - r2[0] + r1*(2.0*r2[0] - 5.0*r2[1] + 4.0*r2[2] - r2[3] + r1*(3.0*(r2[1] - r2[2]) + r2[3] - r2[0]))); + y[jj][0]=delx*ri[jj]; + y[jj][1]=dely*ri[jj]; + y[jj][2]=delz*ri[jj]; + } + for (jj = 0; jj < jnum; jj++) { + if (Bij[jj]==false){continue;} + if (expr[jj][0]==0)continue; +// j = jlist[jj]; +// j &= NEIGHMASK; +// jtype = pair->map[type[j]]; + jtype =tn[jj]; + if (jtypes != nelements && jtypes != jtype){ + continue; + } + for (n = 0;nk;n++){ + ct[n] = alpha_k[n]/re; + c41[n]=(-ct[n]+dfc[jj])*y[jj][0]+dSikx[jj]; + c51[n]=(-ct[n]+dfc[jj])*y[jj][1]+dSiky[jj]; + c61[n]=(-ct[n]+dfc[jj])*y[jj][2]+dSikz[jj]; + } + for (n=0;nmap[type[k1]]; + ktype = tn[kk]; + if (ktypes != nelements && ktypes != ktype){ + continue; + } + count = startingneuron; + double dot = (y[jj][0]*y[kk][0]+y[jj][1]*y[kk][1]+y[jj][2]*y[kk][2]); + double c1 = ri[jj]*(y[kk][0]-dot*y[jj][0]); + double c2 = ri[jj]*(y[kk][1]-dot*y[jj][1]); + double c3 = ri[jj]*(y[kk][2]-dot*y[jj][2]); + double c10 = ri[kk]*(y[jj][0]-dot*y[kk][0]); + double c11 = ri[kk]*(y[jj][1]-dot*y[kk][1]); + double c12 = ri[kk]*(y[jj][2]-dot*y[kk][2]); + for (n=0;nSik[kk]*pair->Sik[jj]; +// double c4 = c41[n]+4*pair->dSikx[kk]; +// double c5 = c51[n]+4*pair->dSiky[kk]; +// double c6 = c61[n]+4*pair->dSikz[kk]; +// //m=0 +// features[count]+=dot1; +// Bijk[n][0]+=dot1; +// dfeaturesx[jj*f+count]+=dot1*c4; +// dfeaturesy[jj*f+count]+=dot1*c5; +// dfeaturesz[jj*f+count]+=dot1*c6; +// c4*=dot; +// c5*=dot; +// c6*=dot; +// count++; +// for (m=1;mmap[type[k1]]; + ktype = tn[kk]; + if (ktypes != nelements && ktypes != ktype){ + continue; + } + count = startingneuron; + for (n=0;nBij[kk]==false){continue;} +// if (expr[kk][0]==0)continue; +// int k1 = jlist[kk]; +// k1 &= NEIGHMASK; +// ktype = pair->map[type[k1]]; +// if (ktypes != nelements && ktypes != ktype){ +// continue; +// } +// count = startingneuron; +// double dot = (y[jj][0]*y[kk][0]+y[jj][1]*y[kk][1]+y[jj][2]*y[kk][2]); +// double c1 = ri[jj]*(y[kk][0]-dot*y[jj][0]); +// double c2 = ri[jj]*(y[kk][1]-dot*y[jj][1]); +// double c3 = ri[jj]*(y[kk][2]-dot*y[jj][2]); +// double c10 = ri[kk]*(y[jj][0]-dot*y[kk][0]); +// double c11 = ri[kk]*(y[jj][1]-dot*y[kk][1]); +// double c12 = ri[kk]*(y[jj][2]-dot*y[kk][2]); +// for (n=0;nSik[kk]*pair->Sik[jj]; +// double c4 = c41[n]/2; +// double c5 = c51[n]/2; +// double c6 = c61[n]/2; +// double ct2 = -ct[n]/2+dfc[kk]; +// double c42 = ct2*y[kk][0]+pair->dSikx[kk]; +// double c52 = ct2*y[kk][1]+pair->dSiky[kk]; +// double c62 = ct2*y[kk][2]+pair->dSikz[kk]; +// //m=0 +// features[count]+=dot1; +// dfeaturesx[jj*f+count]+=dot1*c4; +// dfeaturesy[jj*f+count]+=dot1*c5; +// dfeaturesz[jj*f+count]+=dot1*c6; +// dfeaturesx[kk*f+count]+=dot1*c42; +// dfeaturesy[kk*f+count]+=dot1*c52; +// dfeaturesz[kk*f+count]+=dot1*c62; +// c4*=dot; +// c5*=dot; +// c6*=dot; +// c42*=dot; +// c52*=dot; +// c62*=dot; +// count++; +// for (m=1;m +#include +#include +#include +#include +#include + +using namespace LAMMPS_NS; + +Fingerprint_bondscreenedspin::Fingerprint_bondscreenedspin(PairRANN *pair) : Fingerprint(pair) +{ + n_body_type = 3; + dr = 0; + re = 0; + rc = 0; + alpha_k = new double [1]; + alpha_k[0] = -1; + k = 0; + m = 0; + id = -1; + style = "bondscreenedspin"; + atomtypes = new int [n_body_type]; + empty = true; + pair->doscreen = true; + screen = true; + pair->dospin = true; + spin = true; +} + +Fingerprint_bondscreenedspin::~Fingerprint_bondscreenedspin(){ + delete [] alpha_k; + delete [] atomtypes; + delete [] expcuttable; + delete [] dfctable; + for (int i=0;i<(m*(m+1))>>1;i++){ + delete [] coeff[i]; + delete [] coeffx[i]; + delete [] coeffy[i]; + delete [] coeffz[i]; + delete [] Mf[i]; + } + delete [] coeff; + delete [] coeffx; + delete [] coeffy; + delete [] coeffz; + delete [] Mf; + delete [] rinvsqrttable; +} + +bool Fingerprint_bondscreenedspin::parse_values(char * constant, char * line1){ + char **words=new char *[MAXLINE]; + int nwords,l; + nwords=0; + words[nwords++] = strtok(line1,": ,\t\n"); + while ((words[nwords++] = strtok(NULL,": ,\t\n"))) continue; + nwords -= 1; + if (strcmp(constant,"re")==0){ + re = strtod(words[0],NULL); + } + else if (strcmp(constant,"rc")==0){ + rc = strtod(words[0],NULL); + } + else if (strcmp(constant,"alphak")==0){ + delete [] alpha_k; + alpha_k = new double [nwords]; + for (l=0;lerrorf("Undefined value for bond power"); + delete [] words; + if (re!=0.0 && rc!=0.0 && alpha_k[0]!=-1 && dr!=0.0 && m!=0 && k!=0)return true; + return false; +} + +void Fingerprint_bondscreenedspin::write_values(FILE *fid){ + int i; + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:re:\n",style,id); + fprintf(fid,"%f\n",re); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:rc:\n",style,id); + fprintf(fid,"%f\n",rc); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:alphak:\n",style,id); + for (i=0;ielementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:dr:\n",style,id); + fprintf(fid,"%f\n",dr); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:k:\n",style,id); + fprintf(fid,"%d\n",k); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:m:\n",style,id); + fprintf(fid,"%d\n",m); +} + +void Fingerprint_bondscreenedspin::init(int *i,int id){ + for (int j=0;jk = 0; + alpha_k = new double [1]; + alpha_k[0]=-1; + empty = false; + this->id = id; +} + +//number of neurons defined by this fingerprint +int Fingerprint_bondscreenedspin::get_length(){ + return m*k; +} + +void Fingerprint_bondscreenedspin::allocate(){ + generate_exp_cut_table(); + generate_coefficients(); + generate_rinvssqrttable(); +} + +//Generate table of complex functions for quick reference during compute. Used by do3bodyfeatureset_singleneighborloop and do3bodyfeatureset_doubleneighborloop. +void Fingerprint_bondscreenedspin::generate_exp_cut_table(){ + int m,n; + double r1; + int buf = 5; + int res = pair->res; + double cutmax = pair->cutmax; + expcuttable = new double [(res+buf)*(this->k)]; + dfctable = new double [res+buf]; + for (m=0;m<(res+buf);m++){ + r1 = cutmax*cutmax*(double)(m)/(double)(res); + for (n=0;n<(this->k);n++){ + expcuttable[n+m*(this->k)] = exp(-alpha_k[n]/re*sqrt(r1))*cutofffunction(sqrt(r1),rc,dr); + } + if (sqrt(r1)>=rc || sqrt(r1) <= (rc-dr)){ + dfctable[m]=0; + } + else{ + dfctable[m]=-8*pow(1-(rc-sqrt(r1))/dr,3)/dr/(1-pow(1-(rc-sqrt(r1))/dr,4)); + } + } +} + + +//Generate table of complex functions for quick reference during compute. Used by do3bodyfeatureset_singleneighborloop. +void Fingerprint_bondscreenedspin::generate_coefficients(){ //calculates multinomial coefficient for each term + int p,mb,mc; + int n,p1,i1; + mb = this->m; + mc=(mb*(mb+1))>>1; + coeff = new int *[mc]; + coeffx = new int *[mc]; + coeffy = new int *[mc]; + coeffz = new int *[mc]; + for (p=0;pm+1]; + for (p=0;pm+1;p++){ + M[p]=0; + } + for (p1=0;p1sims[sid]; +// ilist = sim->ilist; +// numneigh = sim->numneigh; +// i = ilist[ii]; +// jnum = numneigh[i]; + //select the more efficient algorithm for this particular potential and environment. + if (jnum*2>(m+1)*m*20){ + do3bodyfeatureset_singleneighborloop(features,dfeaturesx,dfeaturesy,dfeaturesz,dspinx,dspiny,dspinz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,sid,xn,yn,zn,tn,jnum,jl); + } + else{ + do3bodyfeatureset_doubleneighborloop(features,dfeaturesx,dfeaturesy,dfeaturesz,dspinx,dspiny,dspinz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,sid,xn,yn,zn,tn,jnum,jl); + + } +} + +//Called by do3bodyfeatureset. Algorithm for high neighbor numbers and small series of bond angle powers +void Fingerprint_bondscreenedspin::do3bodyfeatureset_singleneighborloop(double * features,double * dfeaturesx,double *dfeaturesy,double *dfeaturesz, double *dspinx, double *dspiny, double *dspinz,double *Sik, double *dSikx, double*dSiky, double *dSikz, double *dSijkx, double *dSijky, double *dSijkz, bool *Bij, int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl){ + int i,j,jj,itype,jtype,kk,m,n,mcount,a,a1,a2,ai; + double xtmp,ytmp,ztmp,delx,dely,delz,rsq; + int *ilist,*jlist,*numneigh,**firstneigh; + int count=0; + PairRANN::Simulation *sim = &pair->sims[sid]; +// double **x = sim->x; + //double **f = atom->f; + int *type = sim->type; + double cutmax = pair->cutmax; + int res = pair->res; + double cutinv2 = 1/cutmax/cutmax; + ilist = sim->ilist; +// numneigh = sim->numneigh; +// firstneigh = sim->firstneigh; + int nelements=pair->nelements; + i = ilist[ii]; + itype = pair->map[type[i]]; + int f = pair->net[itype].dimensions[0]; +// xtmp = x[i][0]; +// ytmp = x[i][1]; +// ztmp = x[i][2]; +// jlist = firstneigh[i]; +// jnum = numneigh[i]; + double expr[jnum][this->k+12]; + int p = this->k; + int countmb=((this->m)*(this->m+1))>>1; + double *si = sim->s[i]; + // calculate interpolation expr, rinvs and dfc, for each neighbor + for (jj = 0; jj < jnum; jj++) { + if (Bij[jj]==false){continue;} +// j = jlist[jj]; +// j &= NEIGHMASK; +// jtype = pair->map[type[j]]; + jtype = tn[jj]; + if (atomtypes[1] != nelements && atomtypes[1] != jtype && atomtypes[2] != nelements && atomtypes[2] != jtype){ + expr[jj][0]=0; + continue; + } +// delx = xtmp - x[j][0]; +// dely = ytmp - x[j][1]; +// delz = ztmp - x[j][2]; + delx=xn[jj]; + dely=yn[jj]; + delz=zn[jj]; + rsq = delx*delx + dely*dely + delz*delz; + if (rsq>rc*rc){ + expr[jj][0]=0; + continue; + } + double r1 = (rsq*((double)res)*cutinv2); + int m1 = (int)r1; + r1 = r1-trunc(r1); + double *p0 = &expcuttable[(m1-1)*this->k]; + double *p1 = &expcuttable[m1*this->k]; + double *p2 = &expcuttable[(m1+1)*this->k]; + double *p3 = &expcuttable[(m1+2)*this->k]; + for (kk=0;kkk;kk++){ + expr[jj][kk] = p1[kk]+0.5*r1*(p2[kk]-p0[kk]+r1*(2.0*p0[kk]-5.0*p1[kk]+4.0*p2[kk]-p3[kk]+r1*(3.0*(p1[kk]-p2[kk])+p3[kk]-p0[kk]))); + expr[jj][kk] *= Sik[jj]; + } + double* q = &dfctable[m1-1]; + double* ri = &rinvsqrttable[m1-1]; + double dfc = q[1] + 0.5 * r1*(q[2] - q[0] + r1*(2.0*q[0] - 5.0*q[1] + 4.0*q[2] - q[3] + r1*(3.0*(q[1] - q[2]) + q[3] - q[0]))); + double rinvs = ri[1] + 0.5 * r1*(ri[2] - ri[0] + r1*(2.0*ri[0] - 5.0*ri[1] + 4.0*ri[2] - ri[3] + r1*(3.0*(ri[1] - ri[2]) + ri[3] - ri[0]))); + + expr[jj][p]=delx*rinvs; + expr[jj][p+1]=dely*rinvs; + expr[jj][p+2]=delz*rinvs; + //Hack to avoid nan when x y or z component of radial vector is exactly 0. Shouldn't affect accuracy. + if (expr[jj][p]*expr[jj][p]<0.000000000001){ + expr[jj][p] = 0.000001; + } + if (expr[jj][p+1]*expr[jj][p+1]<0.000000000001){ + expr[jj][p+1] = 0.000001; + } + if (expr[jj][p+2]*expr[jj][p+2]<0.000000000001){ + expr[jj][p+2] = 0.000001; + } + expr[jj][p+3] = -dfc*expr[jj][p]-dSikx[jj]; + expr[jj][p+4] = rinvs/expr[jj][p]; + expr[jj][p+5] = rinvs*expr[jj][p]; + expr[jj][p+6] = -dfc*expr[jj][p+1]-dSiky[jj]; + expr[jj][p+7] = rinvs/expr[jj][p+1]; + expr[jj][p+8] = rinvs*expr[jj][p+1]; + expr[jj][p+9] = -dfc*expr[jj][p+2]-dSikz[jj]; + expr[jj][p+10] = rinvs/expr[jj][p+2]; + expr[jj][p+11] = rinvs*expr[jj][p+2]; + } + + int kb = this->k; + int mb = this->m; +// int ind = kb+mb*kb; + count = startingneuron; + double Bb[mb]; + double Bbs[mb]; + double dBbx; + double dBby; + double dBbz; +// double dBbx1[mb]; +// double dBby1[mb]; +// double dBbz1[mb]; + double yprod; + for (mcount=0;mcountcoeffx[mcount]; + int *coeffy = this->coeffy[mcount]; + int *coeffz = this->coeffz[mcount]; + int *coeff = this->coeff[mcount]; + a = mb+1; + for (a1=0;a1map[type[j]]; + jtype = tn[jj]; + if (atomtypes[1] != nelements && atomtypes[1] != jtype){ + continue; + } + j = jl[jj]; + double *sj = sim->s[j]; + double sp = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; + double yprod = expr[jj][ai]; + double *y4 = &expr[jj][p]; + for (a2=0;a2map[type[j]]; + jtype = tn[jj]; + if (atomtypes[2] != nelements && atomtypes[2] != jtype){ + continue; + } + j = jl[jj]; + double *sj = sim->s[j]; + double sp = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; + double yprod = expr[jj][ai]; + double *y4 = &expr[jj][p]; + for (a2=0;a2map[type[j]]; + jtype = tn[jj]; + if (atomtypes[2] != nelements && atomtypes[2] != jtype){ + continue; + } + j = jl[jj]; + double *sj = sim->s[j]; + double sp = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; + double *y3 = &expr[jj][p+3]; + double *y4 = &expr[jj][p]; + ai = n; + yprod = expr[jj][ai]; + for (a2=0;a2map[type[j]]; + jtype = tn[jj]; + if (atomtypes[1] != nelements && atomtypes[1] != jtype){ + continue; + } + j = jl[jj]; + double *sj = sim->s[j]; + double sp = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; + double *y3 = &expr[jj][p+3]; + double *y4 = &expr[jj][p]; + ai = n; + yprod = expr[jj][ai]; + for (a2=0;a2map[type[j]]; + jtype = tn[jj]; + if (atomtypes[1] != nelements && atomtypes[1] != jtype){ + continue; + } + j = jl[jj]; + double *sj = sim->s[j]; + double sp = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; + double *y3 = &expr[jj][p+3]; + double *y4 = &expr[jj][p]; + ai = n; + yprod = expr[jj][ai]; + for (a2=0;a2sims[sid]; +// double **x = sim->x; + int *type = sim->type; + int nelements = pair->nelements; + int res = pair->res; + double cutmax = pair->cutmax; + double cutinv2 = 1/cutmax/cutmax; + ilist = sim->ilist; +// numneigh = sim->numneigh; +// firstneigh = sim->firstneigh; + i = ilist[ii]; + itype = pair->map[type[i]]; + int f = pair->net[itype].dimensions[0]; +// xtmp = x[i][0]; +// ytmp = x[i][1]; +// ztmp = x[i][2]; +// jlist = firstneigh[i]; +// jnum = numneigh[i]; + double expr[jnum][this->k]; + double y[jnum][3]; + double ri[jnum]; + double dfc[jnum]; + int kb = this->k; + int mb = this->m; + double Bijk[kb][mb]; + double c41[this->k]; + double c51[this->k]; + double c61[this->k]; + double ct[this->k]; + double *si = sim->s[i]; + for (jj = 0; jj < jnum; jj++) { + if (Bij[jj]==false){continue;} +// j = jlist[jj]; +// j &= NEIGHMASK; +// jtype = pair->map[type[j]]; + jtype = tn[jj]; + if (jtypes != nelements && jtypes != jtype && ktypes != nelements && ktypes != jtype){ + expr[jj][0]=0; + continue; + } +// delx = xtmp - x[j][0]; +// dely = ytmp - x[j][1]; +// delz = ztmp - x[j][2]; + delx = xn[jj]; + dely = yn[jj]; + delz = zn[jj]; + rsq = delx*delx + dely*dely + delz*delz; + if (rsq>rc*rc){ + expr[jj][0]=0; + continue; + } + double r1 = (rsq*((double)res)*cutinv2); + int m1 = (int)r1; + if (!(m1>=1 && m1 <= res))pair->errorf("Neighbor list is invalid.");//usually results from nan somewhere. + r1 = r1-trunc(r1); + double *p0 = &expcuttable[(m1-1)*this->k]; + double *p1 = &expcuttable[m1*this->k]; + double *p2 = &expcuttable[(m1+1)*this->k]; + double *p3 = &expcuttable[(m1+2)*this->k]; + for (kk=0;kkk;kk++){ + expr[jj][kk] = p1[kk]+0.5*r1*(p2[kk]-p0[kk]+r1*(2.0*p0[kk]-5.0*p1[kk]+4.0*p2[kk]-p3[kk]+r1*(3.0*(p1[kk]-p2[kk])+p3[kk]-p0[kk]))); + expr[jj][kk] *= Sik[jj]; + } + double* q = &dfctable[m1-1]; + double* r2 = &rinvsqrttable[m1-1]; + dfc[jj] = q[1] + 0.5 * r1*(q[2] - q[0] + r1*(2.0*q[0] - 5.0*q[1] + 4.0*q[2] - q[3] + r1*(3.0*(q[1] - q[2]) + q[3] - q[0]))); + ri[jj] = r2[1] + 0.5 * r1*(r2[2] - r2[0] + r1*(2.0*r2[0] - 5.0*r2[1] + 4.0*r2[2] - r2[3] + r1*(3.0*(r2[1] - r2[2]) + r2[3] - r2[0]))); + y[jj][0]=delx*ri[jj]; + y[jj][1]=dely*ri[jj]; + y[jj][2]=delz*ri[jj]; + } + for (jj = 0; jj < jnum; jj++) { + if (Bij[jj]==false){continue;} + if (expr[jj][0]==0)continue; +// j = jlist[jj]; +// j &= NEIGHMASK; +// jtype = pair->map[type[j]]; + jtype =tn[jj]; + if (jtypes != nelements && jtypes != jtype){ + continue; + } + j = jl[jj]; + double *sj = sim->s[j]; + double spj = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; + for (n = 0;nk;n++){ + ct[n] = alpha_k[n]/re; + c41[n]=(-ct[n]+dfc[jj])*y[jj][0]+dSikx[jj]; + c51[n]=(-ct[n]+dfc[jj])*y[jj][1]+dSiky[jj]; + c61[n]=(-ct[n]+dfc[jj])*y[jj][2]+dSikz[jj]; + } + for (n=0;nmap[type[k1]]; + ktype = tn[kk]; + if (ktypes != nelements && ktypes != ktype){ + continue; + } + j = jl[kk]; + double *sk = sim->s[j]; + double spk = si[0]*sk[0]+si[1]*sk[1]+si[2]*sk[2]; + count = startingneuron; + double dot = (y[jj][0]*y[kk][0]+y[jj][1]*y[kk][1]+y[jj][2]*y[kk][2]); + double c1 = ri[jj]*(y[kk][0]-dot*y[jj][0]); + double c2 = ri[jj]*(y[kk][1]-dot*y[jj][1]); + double c3 = ri[jj]*(y[kk][2]-dot*y[jj][2]); + double c10 = ri[kk]*(y[jj][0]-dot*y[kk][0]); + double c11 = ri[kk]*(y[jj][1]-dot*y[kk][1]); + double c12 = ri[kk]*(y[jj][2]-dot*y[kk][2]); + for (n=0;nSik[kk]*pair->Sik[jj]; +// double c4 = c41[n]+4*pair->dSikx[kk]; +// double c5 = c51[n]+4*pair->dSiky[kk]; +// double c6 = c61[n]+4*pair->dSikz[kk]; +// //m=0 +// features[count]+=dot1; +// Bijk[n][0]+=dot1; +// dfeaturesx[jj*f+count]+=dot1*c4; +// dfeaturesy[jj*f+count]+=dot1*c5; +// dfeaturesz[jj*f+count]+=dot1*c6; +// c4*=dot; +// c5*=dot; +// c6*=dot; +// count++; +// for (m=1;mmap[type[k1]]; + ktype = tn[kk]; + if (ktypes != nelements && ktypes != ktype){ + continue; + } + count = startingneuron; + for (n=0;nBij[kk]==false){continue;} +// if (expr[kk][0]==0)continue; +// int k1 = jlist[kk]; +// k1 &= NEIGHMASK; +// ktype = pair->map[type[k1]]; +// if (ktypes != nelements && ktypes != ktype){ +// continue; +// } +// count = startingneuron; +// double dot = (y[jj][0]*y[kk][0]+y[jj][1]*y[kk][1]+y[jj][2]*y[kk][2]); +// double c1 = ri[jj]*(y[kk][0]-dot*y[jj][0]); +// double c2 = ri[jj]*(y[kk][1]-dot*y[jj][1]); +// double c3 = ri[jj]*(y[kk][2]-dot*y[jj][2]); +// double c10 = ri[kk]*(y[jj][0]-dot*y[kk][0]); +// double c11 = ri[kk]*(y[jj][1]-dot*y[kk][1]); +// double c12 = ri[kk]*(y[jj][2]-dot*y[kk][2]); +// for (n=0;nSik[kk]*pair->Sik[jj]; +// double c4 = c41[n]/2; +// double c5 = c51[n]/2; +// double c6 = c61[n]/2; +// double ct2 = -ct[n]/2+dfc[kk]; +// double c42 = ct2*y[kk][0]+pair->dSikx[kk]; +// double c52 = ct2*y[kk][1]+pair->dSiky[kk]; +// double c62 = ct2*y[kk][2]+pair->dSikz[kk]; +// //m=0 +// features[count]+=dot1; +// dfeaturesx[jj*f+count]+=dot1*c4; +// dfeaturesy[jj*f+count]+=dot1*c5; +// dfeaturesz[jj*f+count]+=dot1*c6; +// dfeaturesx[kk*f+count]+=dot1*c42; +// dfeaturesy[kk*f+count]+=dot1*c52; +// dfeaturesz[kk*f+count]+=dot1*c62; +// c4*=dot; +// c5*=dot; +// c6*=dot; +// c42*=dot; +// c52*=dot; +// c62*=dot; +// count++; +// for (m=1;m +#include +#include +#include +#include +#include + +using namespace LAMMPS_NS; + +Fingerprint_bondspin::Fingerprint_bondspin(PairRANN *pair) : Fingerprint(pair) +{ + n_body_type = 3; + dr = 0; + re = 0; + rc = 0; + alpha_k = new double [1]; + alpha_k[0] = -1; + k = 0; + m = 0; + id = -1; + style = "bondspin"; + atomtypes = new int [n_body_type]; + empty = true; + pair->allscreen = false; + pair->dospin = true; + spin = true; +} + +Fingerprint_bondspin::~Fingerprint_bondspin(){ + delete [] alpha_k; + delete [] atomtypes; + delete [] expcuttable; + delete [] dfctable; + for (int i=0;i<(m*(m+1))>>1;i++){ + delete [] coeff[i]; + delete [] coeffx[i]; + delete [] coeffy[i]; + delete [] coeffz[i]; + delete [] Mf[i]; + } + delete [] coeff; + delete [] coeffx; + delete [] coeffy; + delete [] coeffz; + delete [] Mf; + delete [] rinvsqrttable; +} + +bool Fingerprint_bondspin::parse_values(char * constant, char * line1){ + char **words=new char *[MAXLINE]; + int nwords,l; + nwords=0; + words[nwords++] = strtok(line1,": ,\t\n"); + while ((words[nwords++] = strtok(NULL,": ,\t\n"))) continue; + nwords -= 1; + if (strcmp(constant,"re")==0){ + re = strtod(words[0],NULL); + } + else if (strcmp(constant,"rc")==0){ + rc = strtod(words[0],NULL); + } + else if (strcmp(constant,"alphak")==0){ + delete [] alpha_k; + alpha_k = new double [nwords]; + for (l=0;lerrorf("Undefined value for bond power"); + delete [] words; + if (re!=0.0 && rc!=0.0 && alpha_k[0]!=-1 && dr!=0.0 && m!=0 && k!=0)return true; + return false; +} + +void Fingerprint_bondspin::write_values(FILE *fid){ + int i; + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:re:\n",style,id); + fprintf(fid,"%f\n",re); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:rc:\n",style,id); + fprintf(fid,"%f\n",rc); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:alphak:\n",style,id); + for (i=0;ielementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:dr:\n",style,id); + fprintf(fid,"%f\n",dr); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:k:\n",style,id); + fprintf(fid,"%d\n",k); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:m:\n",style,id); + fprintf(fid,"%d\n",m); +} + +void Fingerprint_bondspin::init(int *i,int id){ + for (int j=0;jk = 0; + alpha_k = new double [1]; + alpha_k[0]=-1; + empty = false; + this->id = id; +} + +//number of neurons defined by this fingerprint +int Fingerprint_bondspin::get_length(){ + return m*k; +} + +void Fingerprint_bondspin::allocate(){ + generate_exp_cut_table(); + generate_coefficients(); + generate_rinvssqrttable(); +} + +//Generate table of complex functions for quick reference during compute. Used by do3bodyfeatureset_singleneighborloop and do3bodyfeatureset_doubleneighborloop. +void Fingerprint_bondspin::generate_exp_cut_table(){ + int m,n; + double r1; + int buf = 5; + int res = pair->res; + double cutmax = pair->cutmax; + expcuttable = new double [(res+buf)*(this->k)]; + dfctable = new double [res+buf]; + for (m=0;m<(res+buf);m++){ + r1 = cutmax*cutmax*(double)(m)/(double)(res); + for (n=0;n<(this->k);n++){ + expcuttable[n+m*(this->k)] = exp(-alpha_k[n]/re*sqrt(r1))*cutofffunction(sqrt(r1),rc,dr); + } + if (sqrt(r1)>=rc || sqrt(r1) <= (rc-dr)){ + dfctable[m]=0; + } + else{ + dfctable[m]=-8*pow(1-(rc-sqrt(r1))/dr,3)/dr/(1-pow(1-(rc-sqrt(r1))/dr,4)); + } + } +} + +//Generate table of complex functions for quick reference during compute. Used by do3bodyfeatureset_singleneighborloop. +void Fingerprint_bondspin::generate_coefficients(){ //calculates multinomial coefficient for each term + int p,mb,mc; + int n,p1,i1; + mb = this->m; + mc=(mb*(mb+1))>>1; + coeff = new int *[mc]; + coeffx = new int *[mc]; + coeffy = new int *[mc]; + coeffz = new int *[mc]; + for (p=0;pm+1]; + for (p=0;pm+1;p++){ + M[p]=0; + } + for (p1=0;p1sims[sid]; + ilist = sim->ilist; + numneigh = sim->numneigh; + i = ilist[ii]; +// jnum = numneigh[i]; + //select the more efficient algorithm for this particular potential and environment. + + if (jnum*2>(m+1)*m*20){ + do3bodyfeatureset_singleneighborloop(features,dfeaturesx,dfeaturesy,dfeaturesz,dspinx,dspiny,dspinz,ii,sid,xn,yn,zn,tn,jnum,jl); + } + else{ + do3bodyfeatureset_doubleneighborloop(features,dfeaturesx,dfeaturesy,dfeaturesz,dspinx,dspiny,dspinz,ii,sid,xn,yn,zn,tn,jnum,jl); + } +} + +//Called by do3bodyfeatureset. Algorithm for high neighbor numbers and small series of bond angle powers +void Fingerprint_bondspin::do3bodyfeatureset_singleneighborloop(double * features,double * dfeaturesx,double *dfeaturesy,double *dfeaturesz,double * dspinx,double *dspiny,double *dspinz,int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl){ + int i,j,jj,itype,jtype,kk,m,n,mcount,a,a1,a2,ai; + double xtmp,ytmp,ztmp,delx,dely,delz,rsq; + int *ilist,*jlist,*numneigh,**firstneigh; + int count=0; + PairRANN::Simulation *sim = &pair->sims[sid]; +// double **x = sim->x; + int *type = sim->type; + double cutmax = pair->cutmax; + int res = pair->res; + double cutinv2 = 1/cutmax/cutmax; + ilist = sim->ilist; +// numneigh = sim->numneigh; +// firstneigh = sim->firstneigh; + int nelements=pair->nelements; + i = ilist[ii]; + itype = pair->map[type[i]]; + int f = pair->net[itype].dimensions[0]; +// xtmp = x[i][0]; +// ytmp = x[i][1]; +// ztmp = x[i][2]; +// jlist = firstneigh[i]; +// jnum = numneigh[i]; + double expr[jnum][this->k+12]; + int p = this->k; + int countmb=((this->m)*(this->m+1))>>1; + double *si = sim->s[i]; + // calculate interpolation expr, rinvs and dfc, for each neighbor + for (jj = 0; jj < jnum; jj++) { +// j = jlist[jj]; +// j &= NEIGHMASK; +// jtype = pair->map[type[j]]; + jtype = tn[jj]; + if (atomtypes[1] != nelements && atomtypes[1] != jtype && atomtypes[2] != nelements && atomtypes[2] != jtype){ + expr[jj][0]=0; + continue; + } +// delx = xtmp - x[j][0]; +// dely = ytmp - x[j][1]; +// delz = ztmp - x[j][2]; + delx = xn[jj]; + dely = yn[jj]; + delz = zn[jj]; + rsq = delx*delx + dely*dely + delz*delz; + if (rsq>rc*rc){ + expr[jj][0]=0; + continue; + } + double r1 = (rsq*((double)res)*cutinv2); + int m1 = (int)r1; + r1 = r1-trunc(r1); + double *p0 = &expcuttable[(m1-1)*this->k]; + double *p1 = &expcuttable[m1*this->k]; + double *p2 = &expcuttable[(m1+1)*this->k]; + double *p3 = &expcuttable[(m1+2)*this->k]; + for (kk=0;kkk;kk++){ + expr[jj][kk] = p1[kk]+0.5*r1*(p2[kk]-p0[kk]+r1*(2.0*p0[kk]-5.0*p1[kk]+4.0*p2[kk]-p3[kk]+r1*(3.0*(p1[kk]-p2[kk])+p3[kk]-p0[kk]))); + } + double* q = &dfctable[m1-1]; + double* ri = &rinvsqrttable[m1-1]; + double dfc = q[1] + 0.5 * r1*(q[2] - q[0] + r1*(2.0*q[0] - 5.0*q[1] + 4.0*q[2] - q[3] + r1*(3.0*(q[1] - q[2]) + q[3] - q[0]))); + double rinvs = ri[1] + 0.5 * r1*(ri[2] - ri[0] + r1*(2.0*ri[0] - 5.0*ri[1] + 4.0*ri[2] - ri[3] + r1*(3.0*(ri[1] - ri[2]) + ri[3] - ri[0]))); + + expr[jj][p]=delx*rinvs; + expr[jj][p+1]=dely*rinvs; + expr[jj][p+2]=delz*rinvs; + //Hack to avoid nan when x y or z component of radial vector is exactly 0. Shouldn't affect accuracy. + if (expr[jj][p]*expr[jj][p]<0.000000000001){ + expr[jj][p] = 0.000001; + } + if (expr[jj][p+1]*expr[jj][p+1]<0.000000000001){ + expr[jj][p+1] = 0.000001; + } + if (expr[jj][p+2]*expr[jj][p+2]<0.000000000001){ + expr[jj][p+2] = 0.000001; + } + expr[jj][p+3] = -dfc*expr[jj][p]; + expr[jj][p+4] = rinvs/expr[jj][p]; + expr[jj][p+5] = rinvs*expr[jj][p]; + expr[jj][p+6] = -dfc*expr[jj][p+1]; + expr[jj][p+7] = rinvs/expr[jj][p+1]; + expr[jj][p+8] = rinvs*expr[jj][p+1]; + expr[jj][p+9] = -dfc*expr[jj][p+2]; + expr[jj][p+10] = rinvs/expr[jj][p+2]; + expr[jj][p+11] = rinvs*expr[jj][p+2]; + } + + int kb = this->k; + int mb = this->m; + count = startingneuron; + double Bb[mb]; + double Bbs[mb]; + double dBbx; + double dBby; + double dBbz; +// double dBbx1[mb]; +// double dBby1[mb]; +// double dBbz1[mb]; + double yprod; + for (mcount=0;mcountcoeffx[mcount]; + int *coeffy = this->coeffy[mcount]; + int *coeffz = this->coeffz[mcount]; + int *coeff = this->coeff[mcount]; + a = mb+1; + for (a1=0;a1map[type[j]]; + jtype = tn[jj]; + if (atomtypes[1] != nelements && atomtypes[1] != jtype){ + continue; + } + j = jl[jj]; + double *sj = sim->s[j]; + double sp = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; + double yprod = expr[jj][ai]; + double *y4 = &expr[jj][p]; + for (a2=0;a2map[type[j]]; + jtype = tn[jj]; + if (atomtypes[2] != nelements && atomtypes[2] != jtype){ + continue; + } + j = jl[jj]; + double *sj = sim->s[j]; + double sp = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; + double yprod = expr[jj][ai]; + double *y4 = &expr[jj][p]; + for (a2=0;a2map[type[j]]; + jtype = tn[jj]; + if (atomtypes[2] != nelements && atomtypes[2] != jtype){ + continue; + } + j = jl[jj]; + double *sj = sim->s[j]; + double sp = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; + double *y3 = &expr[jj][p+3]; + double *y4 = &expr[jj][p]; + ai = n; + yprod = expr[jj][ai]; + for (a2=0;a2map[type[j]]; + jtype = tn[jj]; + if (atomtypes[1] != nelements && atomtypes[1] != jtype){ + continue; + } + j = jl[jj]; + double *sj = sim->s[j]; + double sp = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; + double *y3 = &expr[jj][p+3]; + double *y4 = &expr[jj][p]; + ai = n; + yprod = expr[jj][ai]; + for (a2=0;a2map[type[j]]; + jtype = tn[jj]; + if (atomtypes[1] != nelements && atomtypes[1] != jtype){ + continue; + } + j = jl[jj]; + double *sj = sim->s[j]; + double sp = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; + double *y3 = &expr[jj][p+3]; + double *y4 = &expr[jj][p]; + ai = n; + yprod = expr[jj][ai]; + for (a2=0;a2sims[sid]; + double **x = sim->x; + int *type = sim->type; + int nelements = pair->nelements; + int res = pair->res; + double cutmax = pair->cutmax; + double cutinv2 = 1/cutmax/cutmax; + ilist = sim->ilist; +// numneigh = sim->numneigh; +// firstneigh = sim->firstneigh; + i = ilist[ii]; + itype = pair->map[type[i]]; + int f = pair->net[itype].dimensions[0]; +// xtmp = x[i][0]; +// ytmp = x[i][1]; +// ztmp = x[i][2]; +// jlist = firstneigh[i]; +// jnum = numneigh[i]; + double expr[jnum][this->k]; + double y[jnum][3]; + double ri[jnum]; + double dfc[jnum]; + int kb = this->k; + int mb = this->m; + double c41[this->k]; + double c51[this->k]; + double c61[this->k]; + double ct[this->k]; + double *si = sim->s[i]; + for (jj = 0; jj < jnum; jj++) { +// j = jlist[jj]; +// j &= NEIGHMASK; +// jtype = pair->map[type[j]]; + jtype = tn[jj]; + if (jtypes != nelements && jtypes != jtype && ktypes != nelements && ktypes != jtype){ + expr[jj][0]=0; + continue; + } +// delx = xtmp - x[j][0]; +// dely = ytmp - x[j][1]; +// delz = ztmp - x[j][2]; + delx = xn[jj]; + dely = yn[jj]; + delz = zn[jj]; + rsq = delx*delx + dely*dely + delz*delz; + if (rsq>rc*rc){ + expr[jj][0]=0; + continue; + } +// j = jl[jj]; +// double *sj = sim->s[j]; +// double sp = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; + double r1 = (rsq*((double)res)*cutinv2); + int m1 = (int)r1; + if (!(m1>=1 && m1 <= res))pair->errorf("Neighbor list is invalid.");//usually results from nan somewhere. + r1 = r1-trunc(r1); + double *p0 = &expcuttable[(m1-1)*this->k]; + double *p1 = &expcuttable[m1*this->k]; + double *p2 = &expcuttable[(m1+1)*this->k]; + double *p3 = &expcuttable[(m1+2)*this->k]; + for (kk=0;kkk;kk++){ + expr[jj][kk] = p1[kk]+0.5*r1*(p2[kk]-p0[kk]+r1*(2.0*p0[kk]-5.0*p1[kk]+4.0*p2[kk]-p3[kk]+r1*(3.0*(p1[kk]-p2[kk])+p3[kk]-p0[kk]))); +// expr[jj][kk]*= sp; + } + double* q = &dfctable[m1-1]; + double* r2 = &rinvsqrttable[m1-1]; + dfc[jj] = q[1] + 0.5 * r1*(q[2] - q[0] + r1*(2.0*q[0] - 5.0*q[1] + 4.0*q[2] - q[3] + r1*(3.0*(q[1] - q[2]) + q[3] - q[0]))); + ri[jj] = r2[1] + 0.5 * r1*(r2[2] - r2[0] + r1*(2.0*r2[0] - 5.0*r2[1] + 4.0*r2[2] - r2[3] + r1*(3.0*(r2[1] - r2[2]) + r2[3] - r2[0]))); + y[jj][0]=delx*ri[jj]; + y[jj][1]=dely*ri[jj]; + y[jj][2]=delz*ri[jj]; + } +// if (i==5){ +// for (jj=0;jjmap[type[j]]; + jtype = tn[jj]; + if (jtypes != nelements && jtypes != jtype){ + continue; + } + j = jl[jj]; + double *sj = sim->s[j]; + double spj = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; + for (n = 0;nk;n++){ + ct[n] = 2*alpha_k[n]/re; + c41[n]=(-ct[n]+2*dfc[jj])*y[jj][0]; + c51[n]=(-ct[n]+2*dfc[jj])*y[jj][1]; + c61[n]= (-ct[n]+2*dfc[jj])*y[jj][2]; + } + if (jtypes==ktypes){ + for (kk=jj+1;kk< jnum; kk++){ + if (expr[kk][0]==0)continue; +// int k1 = jlist[kk]; +// k1 &= NEIGHMASK; +// ktype = pair->map[type[k1]]; + ktype = tn[kk]; + if (ktypes != nelements && ktypes != ktype){ + continue; + } + j = jl[kk]; + double *sk = sim->s[j]; + double spk = si[0]*sk[0]+si[1]*sk[1]+si[2]*sk[2]; + count = startingneuron; + double dot = (y[jj][0]*y[kk][0]+y[jj][1]*y[kk][1]+y[jj][2]*y[kk][2]); + double c1 = 2*ri[jj]*(y[kk][0]-dot*y[jj][0]); + double c2 = 2*ri[jj]*(y[kk][1]-dot*y[jj][1]); + double c3 = 2*ri[jj]*(y[kk][2]-dot*y[jj][2]); + double c10 = 2*ri[kk]*(y[jj][0]-dot*y[kk][0]); + double c11 = 2*ri[kk]*(y[jj][1]-dot*y[kk][1]); + double c12 = 2*ri[kk]*(y[jj][2]-dot*y[kk][2]); +// double c1 = 2*ri[jj]*y[kk][0]*(1-y[jj][0]*y[jj][0]); +// double c2 = 2*ri[jj]*y[kk][1]*(1-y[jj][1]*y[jj][1]); +// double c3 = 2*ri[jj]*y[kk][2]*(1-y[jj][2]*y[jj][2]); +// double c10 = 2*ri[kk]*y[jj][0]*(1-y[kk][0]*y[kk][0]); +// double c11 = 2*ri[kk]*y[jj][1]*(1-y[kk][1]*y[kk][1]); +// double c12 = 2*ri[kk]*y[jj][2]*(1-y[kk][2]*y[kk][2]); + for (n=0;nmap[type[k1]]; + ktype = tn[kk]; + if (ktypes != nelements && ktypes != ktype){ + continue; + } + j = jl[kk]; + double *sk = sim->s[j]; + double spk = si[0]*sk[0]+si[1]*sk[1]+si[2]*sk[2]; + count = startingneuron; + double dot = (y[jj][0]*y[kk][0]+y[jj][1]*y[kk][1]+y[jj][2]*y[kk][2]); + double c1 = ri[jj]*(y[kk][0]-dot*y[jj][0]); + double c2 = ri[jj]*(y[kk][1]-dot*y[jj][1]); + double c3 = ri[jj]*(y[kk][2]-dot*y[jj][2]); + double c10 = ri[kk]*(y[jj][0]-dot*y[kk][0]); + double c11 = ri[kk]*(y[jj][1]-dot*y[kk][1]); + double c12 = ri[kk]*(y[jj][2]-dot*y[kk][2]); +// double c1 = 2*ri[jj]*y[kk][0]*(1-y[jj][0]*y[jj][0]); +// double c2 = 2*ri[jj]*y[kk][1]*(1-y[jj][1]*y[jj][1]); +// double c3 = 2*ri[jj]*y[kk][2]*(1-y[jj][2]*y[jj][2]); +// double c10 = 2*ri[kk]*y[jj][0]*(1-y[kk][0]*y[kk][0]); +// double c11 = 2*ri[kk]*y[jj][1]*(1-y[kk][1]*y[kk][1]); +// double c12 = 2*ri[kk]*y[jj][2]*(1-y[kk][2]*y[kk][2]); + for (n=0;n +#include +#include +#include +#include +#include + + +using namespace LAMMPS_NS; + +Fingerprint_radial::Fingerprint_radial(PairRANN *pair) : Fingerprint(pair) +{ + n_body_type = 2; + dr = 0; + re = 0; + rc = 0; + alpha = new double [1]; + alpha[0] = -1; + n = 0; + o = 0; + id = -1; + style = "radial"; + atomtypes = new int [n_body_type]; + empty = true; + fullydefined = false; + pair->allscreen = false; +} + +Fingerprint_radial::~Fingerprint_radial() +{ + delete [] atomtypes; + delete [] radialtable; + delete [] alpha; + delete [] dfctable; + delete [] rinvsqrttable; +} + +bool Fingerprint_radial::parse_values(char* constant,char * line1){ + int l; + char **words=new char *[MAXLINE]; + int nwords; + nwords=0; + words[nwords++] = strtok(line1,": ,\t\n"); + while ((words[nwords++] = strtok(NULL,": ,\t\n"))) continue; + nwords -= 1; + if (strcmp(constant,"re")==0){ + re = strtod(line1,NULL); + } + else if (strcmp(constant,"rc")==0){ + rc = strtod(line1,NULL); + } + else if (strcmp(constant,"alpha")==0){ + delete [] alpha; + alpha = new double [nwords]; + for (l=0;lerrorf("Undefined value for radial power"); + //code will run with default o=0 if o is never specified. All other values must be defined in potential file. + delete [] words; + if (re!=0 && rc!=0 && alpha!=0 && dr!=0 && n!=0)return true; + return false; +} + +void Fingerprint_radial::write_values(FILE *fid){ + int i; + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:re:\n",style,id); + fprintf(fid,"%f\n",re); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:rc:\n",style,id); + fprintf(fid,"%f\n",rc); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:alpha:\n",style,id); + for (i=0;i<(n-o+1);i++){ + fprintf(fid,"%f ",alpha[i]); + } + fprintf(fid,"\n"); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:dr:\n",style,id); + fprintf(fid,"%f\n",dr); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:o:\n",style,id); + fprintf(fid,"%d\n",o); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:n:\n",style,id); + fprintf(fid,"%d\n",n); +} + +//called after fingerprint is fully defined and tables can be computed. +void Fingerprint_radial::allocate() +{ + int k,m; + double r1; + int buf = 5; + int res = pair->res; + double cutmax = pair->cutmax; + radialtable = new double [(res+buf)*get_length()]; + dfctable = new double [res+buf]; + for (k=0;k<(res+buf);k++){ + r1 = cutmax*cutmax*(double)(k)/(double)(res); + for (m=0;m<=(n-o);m++){ + radialtable[k*(n-o+1)+m]=pow(sqrt(r1)/re,m+o)*exp(-alpha[m]*sqrt(r1)/re)*cutofffunction(sqrt(r1),rc,dr); + } + if (sqrt(r1)>=rc || sqrt(r1) <= (rc-dr)){ + dfctable[k]=0; + } + else{ + dfctable[k]=-8*pow(1-(rc-sqrt(r1))/dr,3)/dr/(1-pow(1-(rc-sqrt(r1))/dr,4)); + } + } + generate_rinvssqrttable(); +} + +//called after fingerprint is declared for i-j type, but before its parameters are read. +void Fingerprint_radial::init(int *i,int id) +{ + empty = false; + for (int j=0;jid = id; +} + +void Fingerprint_radial::compute_fingerprint(double * features,double * dfeaturesx,double *dfeaturesy,double *dfeaturesz,int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl) +{ + int nelements = pair->nelements; + int res = pair->res; + int i,j,jj,itype,jtype,l; + double xtmp,ytmp,ztmp,delx,dely,delz,rsq; + int *ilist,*jlist,*numneigh,**firstneigh; + // + PairRANN::Simulation *sim = &pair->sims[sid]; + int count=0; +// double **x = sim->x; + int *type = sim->type; + ilist = sim->ilist; + double cutmax = pair->cutmax; + i = ilist[ii]; + itype = pair->map[type[i]]; + int f = pair->net[itype].dimensions[0]; + double cutinv2 = 1/cutmax/cutmax; +// numneigh = sim->numneigh; +// firstneigh = sim->firstneigh; +// xtmp = x[i][0]; +// ytmp = x[i][1]; +// ztmp = x[i][2]; +// jlist = firstneigh[i]; +// jnum = numneigh[i]; + //loop over neighbors + for (jj = 0; jj < jnum; jj++) { +// j = jlist[jj]; +// j &= NEIGHMASK; +// jtype = pair->map[type[j]]; + jtype =tn[jj]; + if (this->atomtypes[1] != nelements && this->atomtypes[1] != jtype)continue; +// delx = xtmp - x[j][0]; +// dely = ytmp - x[j][1]; +// delz = ztmp - x[j][2]; + delx = xn[jj]; + dely = yn[jj]; + delz = zn[jj]; + rsq = delx*delx + dely*dely + delz*delz; + if (rsq > rc*rc)continue; + count = startingneuron; + double r1 = (rsq*((double)res)*cutinv2); + int m1 = (int)r1; + if (m1>res || m1<1){pair->errorf("invalid neighbor radius!");} + if (radialtable[m1]==0){continue;} + //cubic interpolation from tables + double *p1 = &radialtable[m1*(n-o+1)]; + double *p2 = &radialtable[(m1+1)*(n-o+1)]; + double *p3 = &radialtable[(m1+2)*(n-o+1)]; + double *p0 = &radialtable[(m1-1)*(n-o+1)]; + double *q = &dfctable[m1-1]; + double *rinvs = &rinvsqrttable[m1-1]; + r1 = r1-trunc(r1); + double dfc = q[1] + 0.5 * r1*(q[2] - q[0] + r1*(2.0*q[0] - 5.0*q[1] + 4.0*q[2] - q[3] + r1*(3.0*(q[1] - q[2]) + q[3] - q[0]))); + double ri = rinvs[1] + 0.5 * r1*(rinvs[2] - rinvs[0] + r1*(2.0*rinvs[0] - 5.0*rinvs[1] + 4.0*rinvs[2] - rinvs[3] + r1*(3.0*(rinvs[1] - rinvs[2]) + rinvs[3] - rinvs[0]))); + for (l=0;l<=(n-o);l++){ + double rt = p1[l]+0.5*r1*(p2[l]-p0[l]+r1*(2.0*p0[l]-5.0*p1[l]+4.0*p2[l]-p3[l]+r1*(3.0*(p1[l]-p2[l])+p3[l]-p0[l]))); + features[count]+=rt; + rt *= (l+o)/rsq+(-alpha[l]/re+dfc)*ri; + //update neighbor's features + dfeaturesx[jj*f+count]+=rt*delx; + dfeaturesy[jj*f+count]+=rt*dely; + dfeaturesz[jj*f+count]+=rt*delz; + //update atom's features + dfeaturesx[jnum*f+count]-=rt*delx; + dfeaturesy[jnum*f+count]-=rt*dely; + dfeaturesz[jnum*f+count]-=rt*delz; + count++; + } + } + +} + +int Fingerprint_radial::get_length() +{ + return n-o+1; +} diff --git a/src/fingerprint_radial.h b/src/fingerprint_radial.h new file mode 100644 index 0000000000..e828aa2c41 --- /dev/null +++ b/src/fingerprint_radial.h @@ -0,0 +1,56 @@ +/* -*- 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. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing author: Christopher Barrett (MSU) barrett@me.msstate.edu + ----------------------------------------------------------------------*/ + +#ifdef FINGERPRINT_CLASS + +FingerprintStyle(radial,Fingerprint_radial) + +#else + +#ifndef FINGERPRINT_RADIAL_H_ +#define FINGERPRINT_RADIAL_H_ + +#include "fingerprint.h" + +namespace LAMMPS_NS { + +class Fingerprint_radial : public Fingerprint { + public: + Fingerprint_radial(PairRANN *); + ~Fingerprint_radial(); + bool parse_values(char*,char*); + void write_values(FILE *); + void init(int*,int); + void allocate(); + void compute_fingerprint(double*,double*,double*,double*,int,int,double*,double*,double*,int*,int,int*); + int get_length(); + + double *radialtable; + double *dfctable; + double dr; + double *alpha; + double re; + int n;//highest term + int o;//lowest term + +}; + + +} + +#endif +#endif /* FINGERPRINT_RADIAL_H_ */ diff --git a/src/fingerprint_radialscreened.cpp b/src/fingerprint_radialscreened.cpp new file mode 100644 index 0000000000..003c7abbc3 --- /dev/null +++ b/src/fingerprint_radialscreened.cpp @@ -0,0 +1,266 @@ +/* -*- 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. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing author: Christopher Barrett (MSU) barrett@me.msstate.edu + ----------------------------------------------------------------------*/ + + +#include "fingerprint_radialscreened.h" +#include +#include +#include +#include +#include +#include + + +using namespace LAMMPS_NS; + +Fingerprint_radialscreened::Fingerprint_radialscreened(PairRANN *pair) : Fingerprint(pair) +{ + n_body_type = 2; + dr = 0; + re = 0; + rc = 0; + alpha = new double [1]; + alpha[0] = -1; + n = 0; + o = 0; + id = -1; + style = "radialscreened"; + atomtypes = new int [n_body_type]; + empty = true; + fullydefined = false; + pair->doscreen = true; + screen = true; +} + +Fingerprint_radialscreened::~Fingerprint_radialscreened() +{ + delete [] atomtypes; + delete [] radialtable; + delete [] alpha; + delete [] dfctable; + delete [] rinvsqrttable; +} + +bool Fingerprint_radialscreened::parse_values(char* constant,char * line1){ + int l; + char **words=new char *[MAXLINE]; + int nwords; + nwords=0; + words[nwords++] = strtok(line1,": ,\t\n"); + while ((words[nwords++] = strtok(NULL,": ,\t\n"))) continue; + nwords -= 1; + if (strcmp(constant,"re")==0){ + re = strtod(line1,NULL); + } + else if (strcmp(constant,"rc")==0){ + rc = strtod(line1,NULL); + } + else if (strcmp(constant,"alpha")==0){ + delete [] alpha; + alpha = new double [nwords]; + for (l=0;lerrorf("Undefined value for radial power"); + //code will run with default o=0 if o is never specified. All other values must be defined in potential file. + delete [] words; + if (re!=0 && rc!=0 && alpha!=0 && dr!=0 && n!=0)return true; + return false; +} + +void Fingerprint_radialscreened::write_values(FILE *fid){ + int i; + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:re:\n",style,id); + fprintf(fid,"%f\n",re); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:rc:\n",style,id); + fprintf(fid,"%f\n",rc); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:alpha:\n",style,id); + for (i=0;i<(n-o+1);i++){ + fprintf(fid,"%f ",alpha[i]); + } + fprintf(fid,"\n"); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:dr:\n",style,id); + fprintf(fid,"%f\n",dr); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:o:\n",style,id); + fprintf(fid,"%d\n",o); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:n:\n",style,id); + fprintf(fid,"%d\n",n); +} + +//called after fingerprint is fully defined and tables can be computed. +void Fingerprint_radialscreened::allocate() +{ + int k,m; + double r1; + int buf = 5; + int res = pair->res; + double cutmax = pair->cutmax; + radialtable = new double [(res+buf)*get_length()]; + dfctable = new double [res+buf]; + for (k=0;k<(res+buf);k++){ + r1 = cutmax*cutmax*(double)(k)/(double)(res); + for (m=0;m<=(n-o);m++){ + radialtable[k*(n-o+1)+m]=pow(sqrt(r1)/re,m+o)*exp(-alpha[m]*sqrt(r1)/re)*cutofffunction(sqrt(r1),rc,dr); + } + if (sqrt(r1)>=rc || sqrt(r1) <= (rc-dr)){ + dfctable[k]=0; + } + else{ + dfctable[k]=-8*pow(1-(rc-sqrt(r1))/dr,3)/dr/(1-pow(1-(rc-sqrt(r1))/dr,4)); + } + } + generate_rinvssqrttable(); +} + +//called after fingerprint is declared for i-j type, but before its parameters are read. +void Fingerprint_radialscreened::init(int *i,int id) +{ + empty = false; + for (int j=0;jid = id; +} + +void Fingerprint_radialscreened::compute_fingerprint(double * features,double * dfeaturesx,double *dfeaturesy,double *dfeaturesz,double *Sik, double *dSikx, double*dSiky, double *dSikz, double *dSijkx, double *dSijky, double *dSijkz, bool *Bij,int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl) +{ + int nelements = pair->nelements; + int res = pair->res; + int i,j,jj,itype,jtype,l,kk; + double xtmp,ytmp,ztmp,delx,dely,delz,rsq; + int *ilist,*jlist,*numneigh,**firstneigh; + // + PairRANN::Simulation *sim = &pair->sims[sid]; + int count=0; + double **x = sim->x; + int *type = sim->type; + ilist = sim->ilist; + double cutmax = pair->cutmax; + i = ilist[ii]; + itype = pair->map[type[i]]; + int f = pair->net[itype].dimensions[0]; + double cutinv2 = 1/cutmax/cutmax; +// numneigh = sim->numneigh; +// firstneigh = sim->firstneigh; +// xtmp = x[i][0]; +// ytmp = x[i][1]; +// ztmp = x[i][2]; +// jlist = firstneigh[i]; +// jnum = numneigh[i]; + //loop over neighbors + for (jj = 0; jj < jnum; jj++) { + if (Bij[jj]==false){continue;} +// j = jlist[jj]; +// j &= NEIGHMASK; +// jtype = pair->map[type[j]]; + jtype = tn[jj]; + if (this->atomtypes[1] != nelements && this->atomtypes[1] != jtype)continue; +// delx = xtmp - x[j][0]; +// dely = ytmp - x[j][1]; +// delz = ztmp - x[j][2]; + delx = xn[jj]; + dely = yn[jj]; + delz = zn[jj]; + rsq = delx*delx + dely*dely + delz*delz; + if (rsq > rc*rc)continue; + count = startingneuron; + double r1 = (rsq*((double)res)*cutinv2); + int m1 = (int)r1; + if (m1>res || m1<1){pair->errorf("invalid neighbor radius!");} + if (radialtable[m1]==0){continue;} + //cubic interpolation from tables + double *p1 = &radialtable[m1*(n-o+1)]; + double *p2 = &radialtable[(m1+1)*(n-o+1)]; + double *p3 = &radialtable[(m1+2)*(n-o+1)]; + double *p0 = &radialtable[(m1-1)*(n-o+1)]; + double *q = &dfctable[m1-1]; + double *rinvs = &rinvsqrttable[m1-1]; + r1 = r1-trunc(r1); + double dfc = q[1] + 0.5 * r1*(q[2] - q[0] + r1*(2.0*q[0] - 5.0*q[1] + 4.0*q[2] - q[3] + r1*(3.0*(q[1] - q[2]) + q[3] - q[0]))); + double ri = rinvs[1] + 0.5 * r1*(rinvs[2] - rinvs[0] + r1*(2.0*rinvs[0] - 5.0*rinvs[1] + 4.0*rinvs[2] - rinvs[3] + r1*(3.0*(rinvs[1] - rinvs[2]) + rinvs[3] - rinvs[0]))); + for (l=0;l<=(n-o);l++){ + double rt = Sik[jj]*(p1[l]+0.5*r1*(p2[l]-p0[l]+r1*(2.0*p0[l]-5.0*p1[l]+4.0*p2[l]-p3[l]+r1*(3.0*(p1[l]-p2[l])+p3[l]-p0[l])))); + features[count]+=rt; + double rt1 = rt*((l+o)/rsq+(-alpha[l]/re+dfc)*ri); + //update neighbor's features + dfeaturesx[jj*f+count]+=rt1*delx+rt*dSikx[jj]; + dfeaturesy[jj*f+count]+=rt1*dely+rt*dSiky[jj]; + dfeaturesz[jj*f+count]+=rt1*delz+rt*dSikz[jj]; + for (kk=0;kk +#include +#include +#include +#include +#include + + +using namespace LAMMPS_NS; + +Fingerprint_radialscreenedspin::Fingerprint_radialscreenedspin(PairRANN *pair) : Fingerprint(pair) +{ + n_body_type = 2; + dr = 0; + re = 0; + rc = 0; + alpha = new double [1]; + alpha[0] = -1; + n = 0; + o = 0; + id = -1; + style = "radialscreenedspin"; + atomtypes = new int [n_body_type]; + empty = true; + fullydefined = false; + pair->doscreen = true; + screen = true; + pair->dospin = true; + spin = true; +} + +Fingerprint_radialscreenedspin::~Fingerprint_radialscreenedspin() +{ + delete [] atomtypes; + delete [] radialtable; + delete [] alpha; + delete [] dfctable; + delete [] rinvsqrttable; +} + +bool Fingerprint_radialscreenedspin::parse_values(char* constant,char * line1){ + int l; + char **words=new char *[MAXLINE]; + int nwords; + nwords=0; + words[nwords++] = strtok(line1,": ,\t\n"); + while ((words[nwords++] = strtok(NULL,": ,\t\n"))) continue; + nwords -= 1; + if (strcmp(constant,"re")==0){ + re = strtod(line1,NULL); + } + else if (strcmp(constant,"rc")==0){ + rc = strtod(line1,NULL); + } + else if (strcmp(constant,"alpha")==0){ + delete [] alpha; + alpha = new double [nwords]; + for (l=0;lerrorf("Undefined value for radial power"); + //code will run with default o=0 if o is never specified. All other values must be defined in potential file. + delete [] words; + if (re!=0 && rc!=0 && alpha!=0 && dr!=0 && n!=0)return true; + return false; +} + +void Fingerprint_radialscreenedspin::write_values(FILE *fid){ + int i; + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:re:\n",style,id); + fprintf(fid,"%f\n",re); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:rc:\n",style,id); + fprintf(fid,"%f\n",rc); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:alpha:\n",style,id); + for (i=0;i<(n-o+1);i++){ + fprintf(fid,"%f ",alpha[i]); + } + fprintf(fid,"\n"); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:dr:\n",style,id); + fprintf(fid,"%f\n",dr); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:o:\n",style,id); + fprintf(fid,"%d\n",o); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:n:\n",style,id); + fprintf(fid,"%d\n",n); +} + +//called after fingerprint is fully defined and tables can be computed. +void Fingerprint_radialscreenedspin::allocate() +{ + int k,m; + double r1; + int buf = 5; + int res = pair->res; + double cutmax = pair->cutmax; + radialtable = new double [(res+buf)*get_length()]; + dfctable = new double [res+buf]; + for (k=0;k<(res+buf);k++){ + r1 = cutmax*cutmax*(double)(k)/(double)(res); + for (m=0;m<=(n-o);m++){ + radialtable[k*(n-o+1)+m]=pow(sqrt(r1)/re,m+o)*exp(-alpha[m]*sqrt(r1)/re)*cutofffunction(sqrt(r1),rc,dr); + } + if (sqrt(r1)>=rc || sqrt(r1) <= (rc-dr)){ + dfctable[k]=0; + } + else{ + dfctable[k]=-8*pow(1-(rc-sqrt(r1))/dr,3)/dr/(1-pow(1-(rc-sqrt(r1))/dr,4)); + } + } + generate_rinvssqrttable(); +} + +//called after fingerprint is declared for i-j type, but before its parameters are read. +void Fingerprint_radialscreenedspin::init(int *i,int id) +{ + empty = false; + for (int j=0;jid = id; +} + +void Fingerprint_radialscreenedspin::compute_fingerprint(double * features,double * dfeaturesx,double *dfeaturesy,double *dfeaturesz,double * dspinx,double *dspiny,double *dspinz,double *Sik, double *dSikx, double*dSiky, double *dSikz, double *dSijkx, double *dSijky, double *dSijkz, bool *Bij,int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl) +{ + int nelements = pair->nelements; + int res = pair->res; + int i,j,jj,itype,jtype,l,kk; + double xtmp,ytmp,ztmp,delx,dely,delz,rsq; + int *ilist,*jlist,*numneigh,**firstneigh; + // + PairRANN::Simulation *sim = &pair->sims[sid]; + int count=0; + double **x = sim->x; + int *type = sim->type; + ilist = sim->ilist; + double cutmax = pair->cutmax; + i = ilist[ii]; + itype = pair->map[type[i]]; + int f = pair->net[itype].dimensions[0]; + double cutinv2 = 1/cutmax/cutmax; + double *si = sim->s[i]; +// numneigh = sim->numneigh; +// firstneigh = sim->firstneigh; +// xtmp = x[i][0]; +// ytmp = x[i][1]; +// ztmp = x[i][2]; +// jlist = firstneigh[i]; +// jnum = numneigh[i]; + //loop over neighbors + for (jj = 0; jj < jnum; jj++) { + if (Bij[jj]==false){continue;} +// j = jlist[jj]; +// j &= NEIGHMASK; +// jtype = pair->map[type[j]]; + jtype = tn[jj]; + if (this->atomtypes[1] != nelements && this->atomtypes[1] != jtype)continue; +// delx = xtmp - x[j][0]; +// dely = ytmp - x[j][1]; +// delz = ztmp - x[j][2]; + delx = xn[jj]; + dely = yn[jj]; + delz = zn[jj]; + rsq = delx*delx + dely*dely + delz*delz; + if (rsq > rc*rc)continue; + count = startingneuron; + double r1 = (rsq*((double)res)*cutinv2); + int m1 = (int)r1; + if (m1>res || m1<1){pair->errorf("invalid neighbor radius!");} + if (radialtable[m1]==0){continue;} + j=jl[jj]; + double *sj = sim->s[j]; + double sp = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; + //cubic interpolation from tables + double *p1 = &radialtable[m1*(n-o+1)]; + double *p2 = &radialtable[(m1+1)*(n-o+1)]; + double *p3 = &radialtable[(m1+2)*(n-o+1)]; + double *p0 = &radialtable[(m1-1)*(n-o+1)]; + double *q = &dfctable[m1-1]; + double *rinvs = &rinvsqrttable[m1-1]; + r1 = r1-trunc(r1); + double dfc = q[1] + 0.5 * r1*(q[2] - q[0] + r1*(2.0*q[0] - 5.0*q[1] + 4.0*q[2] - q[3] + r1*(3.0*(q[1] - q[2]) + q[3] - q[0]))); + double ri = rinvs[1] + 0.5 * r1*(rinvs[2] - rinvs[0] + r1*(2.0*rinvs[0] - 5.0*rinvs[1] + 4.0*rinvs[2] - rinvs[3] + r1*(3.0*(rinvs[1] - rinvs[2]) + rinvs[3] - rinvs[0]))); + for (l=0;l<=(n-o);l++){ + double rt = Sik[jj]*(p1[l]+0.5*r1*(p2[l]-p0[l]+r1*(2.0*p0[l]-5.0*p1[l]+4.0*p2[l]-p3[l]+r1*(3.0*(p1[l]-p2[l])+p3[l]-p0[l])))); + //update neighbor's features + dspinx[jj*f+count]+=rt*si[0]; + dspiny[jj*f+count]+=rt*si[1]; + dspinz[jj*f+count]+=rt*si[2]; + dspinx[jnum*f+count]+=rt*sj[0]; + dspiny[jnum*f+count]+=rt*sj[1]; + dspinz[jnum*f+count]+=rt*sj[2]; + rt *= sp; + features[count]+=rt; + double rt1 = rt*((l+o)/rsq+(-alpha[l]/re+dfc)*ri); + dfeaturesx[jj*f+count]+=rt1*delx+rt*dSikx[jj]; + dfeaturesy[jj*f+count]+=rt1*dely+rt*dSiky[jj]; + dfeaturesz[jj*f+count]+=rt1*delz+rt*dSikz[jj]; + for (kk=0;kk +#include +#include +#include +#include +#include + + +using namespace LAMMPS_NS; + +Fingerprint_radialspin::Fingerprint_radialspin(PairRANN *pair) : Fingerprint(pair) +{ + n_body_type = 2; + dr = 0; + re = 0; + rc = 0; + alpha = new double [1]; + alpha[0] = -1; + n = 0; + o = 0; + id = -1; + style = "radialspin"; + atomtypes = new int [n_body_type]; + empty = true; + fullydefined = false; + pair->allscreen = false; + pair->dospin = true; + spin = true; +} + +Fingerprint_radialspin::~Fingerprint_radialspin() +{ + delete [] atomtypes; + delete [] radialtable; + delete [] alpha; + delete [] dfctable; + delete [] rinvsqrttable; +} + +bool Fingerprint_radialspin::parse_values(char* constant,char * line1){ + int l; + char **words=new char *[MAXLINE]; + int nwords; + nwords=0; + words[nwords++] = strtok(line1,": ,\t\n"); + while ((words[nwords++] = strtok(NULL,": ,\t\n"))) continue; + nwords -= 1; + if (strcmp(constant,"re")==0){ + re = strtod(line1,NULL); + } + else if (strcmp(constant,"rc")==0){ + rc = strtod(line1,NULL); + } + else if (strcmp(constant,"alpha")==0){ + delete [] alpha; + alpha = new double [nwords]; + for (l=0;lerrorf("Undefined value for radial power"); + //code will run with default o=0 if o is never specified. All other values must be defined in potential file. + delete [] words; + if (re!=0 && rc!=0 && alpha!=0 && dr!=0 && n!=0)return true; + return false; +} + +void Fingerprint_radialspin::write_values(FILE *fid){ + int i; + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:re:\n",style,id); + fprintf(fid,"%f\n",re); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:rc:\n",style,id); + fprintf(fid,"%f\n",rc); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:alpha:\n",style,id); + for (i=0;i<(n-o+1);i++){ + fprintf(fid,"%f ",alpha[i]); + } + fprintf(fid,"\n"); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:dr:\n",style,id); + fprintf(fid,"%f\n",dr); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:o:\n",style,id); + fprintf(fid,"%d\n",o); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:n:\n",style,id); + fprintf(fid,"%d\n",n); +} + +//called after fingerprint is fully defined and tables can be computed. +void Fingerprint_radialspin::allocate() +{ + int k,m; + double r1; + int buf = 5; + int res = pair->res; + double cutmax = pair->cutmax; + radialtable = new double [(res+buf)*get_length()]; + dfctable = new double [res+buf]; + for (k=0;k<(res+buf);k++){ + r1 = cutmax*cutmax*(double)(k)/(double)(res); + for (m=0;m<=(n-o);m++){ + radialtable[k*(n-o+1)+m]=pow(sqrt(r1)/re,m+o)*exp(-alpha[m]*sqrt(r1)/re)*cutofffunction(sqrt(r1),rc,dr); + } + if (sqrt(r1)>=rc || sqrt(r1) <= (rc-dr)){ + dfctable[k]=0; + } + else{ + dfctable[k]=-8*pow(1-(rc-sqrt(r1))/dr,3)/dr/(1-pow(1-(rc-sqrt(r1))/dr,4)); + } + } + generate_rinvssqrttable(); +} + +//called after fingerprint is declared for i-j type, but before its parameters are read. +void Fingerprint_radialspin::init(int *i,int id) +{ + empty = false; + for (int j=0;jid = id; +} + +void Fingerprint_radialspin::compute_fingerprint(double * features,double * dfeaturesx,double *dfeaturesy,double *dfeaturesz,double * dspinx,double *dspiny,double *dspinz,int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl) +{ + int nelements = pair->nelements; + int res = pair->res; + int i,j,jj,itype,jtype,l; + double xtmp,ytmp,ztmp,delx,dely,delz,rsq; + int *ilist,*jlist,*numneigh,**firstneigh; + // + PairRANN::Simulation *sim = &pair->sims[sid]; + int count=0; +// double **x = sim->x; + int *type = sim->type; + ilist = sim->ilist; + double cutmax = pair->cutmax; + i = ilist[ii]; + itype = pair->map[type[i]]; + int f = pair->net[itype].dimensions[0]; + double cutinv2 = 1/cutmax/cutmax; + double *si = sim->s[i]; +// numneigh = sim->numneigh; + firstneigh = sim->firstneigh; +// xtmp = x[i][0]; +// ytmp = x[i][1]; +// ztmp = x[i][2]; + jlist = firstneigh[i]; +// jnum = numneigh[i]; + //loop over neighbors + for (jj = 0; jj < jnum; jj++) { + j = jl[jj]; + // jtype = pair->map[type[j]]; + jtype =tn[jj]; + if (this->atomtypes[1] != nelements && this->atomtypes[1] != jtype)continue; + // delx = xtmp - x[j][0]; + // dely = ytmp - x[j][1]; + // delz = ztmp - x[j][2]; + delx = xn[jj]; + dely = yn[jj]; + delz = zn[jj]; + rsq = delx*delx + dely*dely + delz*delz; + if (rsq > rc*rc)continue; + count = startingneuron; + double r1 = (rsq*((double)res)*cutinv2); + int m1 = (int)r1; + if (m1>res || m1<1){pair->errorf("invalid neighbor radius!");} + if (radialtable[m1]==0){continue;} + double *sj = sim->s[j]; + double sp = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; + //cubic interpolation from tables + double *p1 = &radialtable[m1*(n-o+1)]; + double *p2 = &radialtable[(m1+1)*(n-o+1)]; + double *p3 = &radialtable[(m1+2)*(n-o+1)]; + double *p0 = &radialtable[(m1-1)*(n-o+1)]; + double *q = &dfctable[m1-1]; + double *rinvs = &rinvsqrttable[m1-1]; + r1 = r1-trunc(r1); + double dfc = q[1] + 0.5 * r1*(q[2] - q[0] + r1*(2.0*q[0] - 5.0*q[1] + 4.0*q[2] - q[3] + r1*(3.0*(q[1] - q[2]) + q[3] - q[0]))); + double ri = rinvs[1] + 0.5 * r1*(rinvs[2] - rinvs[0] + r1*(2.0*rinvs[0] - 5.0*rinvs[1] + 4.0*rinvs[2] - rinvs[3] + r1*(3.0*(rinvs[1] - rinvs[2]) + rinvs[3] - rinvs[0]))); + for (l=0;l<=(n-o);l++){ + double rt = p1[l]+0.5*r1*(p2[l]-p0[l]+r1*(2.0*p0[l]-5.0*p1[l]+4.0*p2[l]-p3[l]+r1*(3.0*(p1[l]-p2[l])+p3[l]-p0[l]))); + dspinx[jj*f+count]+=rt*si[0]; + dspiny[jj*f+count]+=rt*si[1]; + dspinz[jj*f+count]+=rt*si[2]; + dspinx[jnum*f+count]+=rt*sj[0]; + dspiny[jnum*f+count]+=rt*sj[1]; + dspinz[jnum*f+count]+=rt*sj[2]; + rt *= sp; + features[count]+=rt; + rt *= (l+o)/rsq+(-alpha[l]/re+dfc)*ri; + //update neighbor's features + dfeaturesx[jj*f+count]+=rt*delx; + dfeaturesy[jj*f+count]+=rt*dely; + dfeaturesz[jj*f+count]+=rt*delz; + //update atom's features + dfeaturesx[jnum*f+count]-=rt*delx; + dfeaturesy[jnum*f+count]-=rt*dely; + dfeaturesz[jnum*f+count]-=rt*delz; + count++; + } + } + +} + +int Fingerprint_radialspin::get_length() +{ + return n-o+1; +} diff --git a/src/fingerprint_radialspin.h b/src/fingerprint_radialspin.h new file mode 100644 index 0000000000..c42b904d61 --- /dev/null +++ b/src/fingerprint_radialspin.h @@ -0,0 +1,56 @@ +/* -*- 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. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing author: Christopher Barrett (MSU) barrett@me.msstate.edu + ----------------------------------------------------------------------*/ + +#ifdef FINGERPRINT_CLASS + +FingerprintStyle(radialspin,Fingerprint_radialspin) + +#else + +#ifndef FINGERPRINT_RADIALspin_H_ +#define FINGERPRINT_RADIALspin_H_ + +#include "fingerprint.h" + +namespace LAMMPS_NS { + +class Fingerprint_radialspin : public Fingerprint { + public: + Fingerprint_radialspin(PairRANN *); + ~Fingerprint_radialspin(); + bool parse_values(char*,char*); + void write_values(FILE *); + void init(int*,int); + void allocate(); + void compute_fingerprint(double*,double*,double*,double*,double*,double*,double*,int,int,double*,double*,double*,int*,int,int*); + int get_length(); + + double *radialtable; + double *dfctable; + double dr; + double *alpha; + double re; + int n;//highest term + int o;//lowest term + +}; + + +} + +#endif +#endif /* FINGERPRINT_RADIAL_H_ */ diff --git a/src/pair_rann.cpp b/src/pair_rann.cpp new file mode 100644 index 0000000000..84333d7710 --- /dev/null +++ b/src/pair_rann.cpp @@ -0,0 +1,2423 @@ +/* -*- 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. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@cavs.msstate.edu + ----------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include +#include "atom.h" +#include "style_fingerprint.h" +#include "style_activation.h" +#include "force.h" +#include "comm.h" +#include "memory.h" +#include "neighbor.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "memory.h" +#include "error.h" +#include "update.h" +#include "pair_rann.h" + + + +using namespace LAMMPS_NS; + +PairRANN::PairRANN(LAMMPS *lmp) : Pair(lmp) +{ + single_enable = 0; + restartinfo = 0; + one_coeff = 1; + manybody_flag = 1; + + allocated = 0; + + nelements = -1; + elements = NULL; + mass = NULL; + + // set comm size needed by this Pair + // comm unused for now. + + comm_forward = 38; + comm_reverse = 30; + res = 10000; + cutmax = 0; + //at least one of the following will change during fingerprint definition: + doscreen = false; + allscreen = true; + dospin = false; + + fingerprint_map = new FingerprintCreatorMap(); + + #define FINGERPRINT_CLASS + #define FingerprintStyle(key,Class) \ + (*fingerprint_map)[#key] = &fingerprint_creator; + #include "style_fingerprint.h" + #undef FingerprintStyle + #undef FINGERPRINT_CLASS + + activation_map = new ActivationCreatorMap(); + + #define ACTIVATION_CLASS + #define ActivationStyle(key,Class) \ + (*activation_map)[#key] = &activation_creator; + #include "style_activation.h" + #undef ActivationStyle + #undef ACTIVATION_CLASS +} + +PairRANN::~PairRANN() +{ + //clear memory + delete [] mass; + for (int i=0;i0){ + for (int j=0;j0){ + delete [] fingerprints[i]; + delete [] activation[i]; + } + } + delete [] fingerprints; + delete [] activation; + delete [] fingerprintcount; + delete [] fingerprintperelement; + delete [] fingerprintlength; + delete [] screening_min; + delete [] screening_max; +} + + + +void PairRANN::allocate(char **elementword) +{ + int i,j,k,l,n; + n = atom->ntypes; + memory->create(setflag,n+1,n+1,"pair:setflag"); + memory->create(cutsq,n+1,n+1,"pair:cutsq"); + cutmax = 0; + nelementsp=nelements+1; + //initialize arrays + elements = new char *[nelements]; + elementsp = new char *[nelementsp];//elements + 'all' + mass = new double[nelements]; + net = new NNarchitecture[nelementsp]; + weightdefined = new bool*[nelementsp]; + biasdefined = new bool *[nelementsp]; + activation = new Activation**[nelementsp]; + fingerprints = new Fingerprint**[nelementsp]; + fingerprintlength = new int[nelementsp]; + fingerprintperelement = new int [nelementsp]; + fingerprintcount = new int[nelementsp]; + screening_min = new double [nelements*nelements*nelements]; + screening_max = new double [nelements*nelements*nelements]; + for (i=0;i 0) error->all(FLERR,"Illegal pair_style command"); +} + +void PairRANN::coeff(int narg, char **arg) +{ + int i,j; + map = new int [atom->ntypes+1]; + + + if (narg != 3 + atom->ntypes) + error->all(FLERR,"Incorrect args for pair coefficients"); + + + if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) + error->all(FLERR,"Incorrect args for pair coefficients"); + nelements = -1; + read_file(arg[2]); + + // read args that map atom types to elements in potential file + // map[i] = which element the Ith atom type is, -1 if NULL + + for (i = 3; i < narg; i++) { + if (strcmp(arg[i],"NULL") == 0) { + map[i-2] = -1; + continue; + } + for (j = 0; j < nelements; j++) + { + if (strcmp(arg[i],elements[j]) == 0) break; + } + if (j < nelements) map[i-2] = j; + else error->all(FLERR,"No matching element in NN potential file"); + } + // clear setflag since coeff() called once with I,J = * * + + int n = atom->ntypes; + for (i = 1; i <= n; i++) + for (j = i; j <= n; j++) + setflag[i][j] = 0; + + // set setflag i,j for type pairs where both are mapped to elements + // set mass of atom type if i = j + + int count = 0; + for (i = 1; i <= n; i++) { + for (j = i; j <= n; j++) { + if (map[i] >= 0 && map[j] >= 0) { + setflag[i][j] = 1; + if (i == j) atom->set_mass(FLERR,i,mass[map[i]]); + count++; + } + } + } + if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); + for (i=0;iallocate(); + } + } + allocated=1; +} + +void PairRANN::read_file(char *filename) +{ + FILE *fp; + int eof = 0,i,j,k,l; + int n,nwords; + char line [MAXLINE],line1[MAXLINE]; + + char *ptr; + bool comment; + char str[128]; + fp = force->open_potential(filename); + if (fp == NULL) { + sprintf(str,"Cannot open NN potential file %s",filename); + error->one(FLERR,str); + } + while (eof == 0){ + ptr = fgets(line,MAXLINE,fp); + if (ptr == NULL) { + if (check_potential()) {//looks to see if everything needed appears to be defined + error->one(FLERR,"Invalid syntax in potential file, values are inconsistent or missing"); + } + else{ + update_stack_size(); + fclose(fp); + eof = 1; + break; + } + } + else n = strlen(line) + 1; + // strip comment, skip line if blank + if ((ptr = strchr(line,'#'))) *ptr = '\0'; + nwords = count_words(line); + char **words = new char* [strlen(line)]; + if (nwords == 0) continue; + comment = true; + while (comment==true){ + ptr = fgets(line1,MAXLINE,fp); + if (ptr==NULL)error->one(FLERR,"Unexpected end of file"); + if ((ptr = strchr(line1,'#'))) *ptr = '\0'; + nwords = count_words(line1); + if (nwords == 0) continue; + comment = false; + } + nwords = 0; + words[nwords++] = strtok(line,": ,\t_\n"); + while ((words[nwords++] = strtok(NULL,": ,\t_\n"))) continue; + if (strcmp(words[0],"atomtypes")==0)read_atom_types(words,line1); + else if (strcmp(words[0],"mass")==0)read_mass(words,line1); + else if (strcmp(words[0],"fingerprintsperelement")==0)read_fpe(words,line1); + else if (strcmp(words[0],"fingerprints")==0)read_fingerprints(words,nwords-1,line1); + else if (strcmp(words[0],"fingerprintconstants")==0)read_fingerprint_constants(words,nwords-1,line1); + else if (strcmp(words[0],"networklayers")==0)read_network_layers(words,line1); + else if (strcmp(words[0],"layersize")==0)read_layer_size(words,line1); + else if (strcmp(words[0],"weight")==0)read_weight(words,line1,fp); + else if (strcmp(words[0],"bias")==0)read_bias(words,line1,fp); + else if (strcmp(words[0],"activationfunctions")==0)read_activation_functions(words,line1); + else if (strcmp(words[0],"calibrationparameters")==0)continue;//information on how the network was trained + else if (strcmp(words[0],"screening")==0)read_screening(words,nwords-1,line1); + else error->one(FLERR,"Could not understand file syntax: unknown keyword"); + delete [] words; + } +} + +void PairRANN::read_atom_types(char **words,char * line1){ + int nwords = 0; + int t = count_words(line1)+1; + char **elementword = new char *[t]; + elementword[nwords++] = strtok(line1," ,\t:_\n"); + while ((elementword[nwords++] = strtok(NULL," ,\t:_\n"))) continue; + if (nwords < 1) errorf("Incorrect syntax for atom types"); + elementword[nwords-1] = new char [strlen("all")+1]; + char elt [] = "all"; + strcpy(elementword[nwords-1],elt); + nelements = nwords-1; + allocate(elementword); +} + +void PairRANN::read_mass(char **words,char * line1){ + if (nelements == -1)error->one(FLERR,"atom types must be defined before mass in potential file."); + int nwords = 0,i; + for (i=0;ione(FLERR,"mass element not found in atom types."); +} + +void PairRANN::read_fpe(char **words,char * line1){ + int i,j; + if (nelements == -1)error->one(FLERR,"atom types must be defined before fingerprints per element in potential file."); + for (i=0;ione(FLERR,"fingerprint-per-element element not found in atom types"); +} + +void PairRANN::read_fingerprints(char **words,int nwords,char * line1){ + int nwords1=0,i,j,k,l,m,i1; + bool found; + char str[MAXLINE]; + char **words1 = new char * [count_words(line1)+1]; + words1[nwords1++] = strtok(line1," ,\t:_\n"); + while ((words1[nwords1++] = strtok(NULL," ,\t:_\n"))) continue; + nwords1 -= 1; + if (nelements == -1)error->one(FLERR,"atom types must be defined before fingerprints in potential file."); + int atomtypes[nwords-1]; + for (i=1;ione(FLERR,"fingerprint element not found in atom types");} + } + i = atomtypes[0]; + k = 0; + if (fingerprintperelement[i]==-1){error->one(FLERR,"fingerprint per element must be defined before fingerprints");} + while (kn_body_type); + std::cout<n_body_type!=nwords-1){error->one(FLERR,"invalid fingerprint for element combination");} + k++; + fingerprints[i][i1]->init(atomtypes,strtol(words1[k++],NULL,10)); + fingerprintcount[i]++; + } + delete [] words1; +} + + +void PairRANN::read_fingerprint_constants(char **words,int nwords,char * line1){ + int i,j,k,l,m,i1; + bool found; + char str [128]; + if (nelements == -1)error->one(FLERR,"atom types must be defined before fingerprints in potential file."); + int n_body_type = nwords-4; + int atomtypes[n_body_type]; + for (i=1;i<=n_body_type;i++){ + found = false; + for (j=0;jone(FLERR,"fingerprint element not found in atom types");} + } + i = atomtypes[0]; + found = false; + for (k=0;kempty){continue;} + if (n_body_type!=fingerprints[i][k]->n_body_type){continue;} + for (j=0;jatomtypes[j]!=atomtypes[j]){break;} + if (j==n_body_type-1){ + if (strcmp(words[nwords-3],fingerprints[i][k]->style)==0 && strtol(words[nwords-2],NULL,10)==fingerprints[i][k]->id){ + found=true; + i1 = k; + break; + } + } + } + if (found){break;} + } + if (!found){error->one(FLERR,"cannot define constants for unknown fingerprint");} + fingerprints[i][i1]->fullydefined=fingerprints[i][i1]->parse_values(words[nwords-1],line1); +} + +void PairRANN::read_network_layers(char **words,char *line1){ + int i,j; + if (nelements == -1)error->one(FLERR,"atom types must be defined before network layers in potential file."); + for (i=0;ione(FLERR,"invalid number of network layers"); + delete [] net[i].dimensions; + net[i].dimensions = new int [net[i].layers]; + weightdefined[i] = new bool [net[i].layers]; + biasdefined[i] = new bool [net[i].layers]; + net[i].Weights = new double * [net[i].layers-1]; + net[i].Biases = new double * [net[i].layers-1]; + for (j=0;jone(FLERR,"network layers element not found in atom types"); +} + +void PairRANN::read_layer_size(char **words,char* line1){ + int i; + for (i=0;ione(FLERR,"networklayers for each atom type must be defined before the corresponding layer sizes."); + int j = strtol(words[2],NULL,10); + if (j>=net[i].layers || j<0){errorf("invalid layer in layer size definition");}; + net[i].dimensions[j]= strtol(line1,NULL,10); +// net[i].Weights[j] = new double [1]; +// net[i].Weights[j][0]=0; +// net[i].Biases[j] = new double [1]; +// net[i].Biases[j][0] = 0; + return; + } + } + error->one(FLERR,"layer size element not found in atom types"); +} + +void PairRANN::read_weight(char **words,char* line1,FILE* fp){ + int i,j,k,l,nwords; + char *ptr; + char **words1; + for (l=0;lone(FLERR,"networklayers must be defined before weights."); + i=strtol(words[2],NULL,10); + if (i>=net[l].layers || i<0)error->one(FLERR,"invalid weight layer"); + if (net[l].dimensions[i]==0 || net[l].dimensions[i+1]==0) error->one(FLERR,"network layer sizes must be defined before corresponding weight"); +// delete [] net[l].Weights[i]; + net[l].Weights[i] = new double [net[l].dimensions[i]*net[l].dimensions[i+1]]; + weightdefined[l][i] = true; + int n = count_words(line1)+1; + words1 = new char* [n]; + nwords=0; + words1[nwords++] = strtok(line1," ,\t:_\n"); + while ((words1[nwords++] = strtok(NULL," ,\t:_\n"))) continue; + nwords -= 1; + if (nwords != net[l].dimensions[i])error->one(FLERR,"invalid weights per line"); + for (k=0;kone(FLERR,"invalid weights per line"); + for (k=0;kone(FLERR,"weight element not found in atom types"); +} + +void PairRANN::read_bias(char **words,char* line1,FILE* fp){ + int i,j,l,nwords; + char *ptr; + for (l=0;lone(FLERR,"networklayers must be defined before biases."); + i=strtol(words[2],NULL,10); + if (i>=net[l].layers || i<0)error->one(FLERR,"invalid bias layer"); + if (net[l].dimensions[i]==0) error->one(FLERR,"network layer sizes must be defined before corresponding bias"); +// delete [] net[l].Biases[i]; + biasdefined[l][i] = true; + net[l].Biases[i] = new double [net[l].dimensions[i+1]]; + words[0] = strtok(line1," ,\t:_\n"); + net[l].Biases[i][0] = strtod(words[0],NULL); + for (j=1;jone(FLERR,"bias element not found in atom types"); +} + +void PairRANN::read_activation_functions(char** words,char * line1){ + int i,j,l,nwords; + int *ptr; + for (l=0;lone(FLERR,"networklayers must be defined before activation functions."); + i = strtol(words[2],NULL,10); + if (i>=net[l].layers || i<0)error->one(FLERR,"invalid activation layer"); + nwords=0; + words[nwords++] = strtok(line1," ,\t:_\n"); + delete activation[l][i]; + activation[l][i]=create_activation(line1); + return; + } + } + error->one(FLERR,"activation function element not found in atom types"); +} + +void PairRANN::read_screening(char** words,int nwords,char *line1){ + int i,j,k; + bool found; +// char str[MAXLINE]; +// sprintf(str,"%d\n",nwords); +// for (i=0;inet[i].maxlayer)net[i].maxlayer = net[i].dimensions[j]; + } + if (net[i].dimensions[net[i].layers-1]!=1)return true;//output layer must have single neuron (the energy) + for (j=0;jempty)return true;//undefined activations + for (k=0;kfullydefined==false)return true; + fingerprints[i][j]->startingneuron = fingerprintlength[i]; + fingerprintlength[i] +=fingerprints[i][j]->get_length(); + if (fingerprints[i][j]->rc>cutmax){cutmax = fingerprints[i][j]->rc;} + } + if (net[i].dimensions[0]!=fingerprintlength[i])return true; + } + return false;//everything looks good +} + +void PairRANN::compute(int eflag, int vflag) +{ + //perform force/energy computation_ + if (dospin){ + if (strcmp(update->unit_style,"metal") != 0) + error->all(FLERR,"Spin pair styles require metal units"); + if (!atom->sp_flag) + error->all(FLERR,"Spin pair styles requires atom/spin style"); + } + if (eflag || vflag) ev_setup(eflag,vflag); + else evflag = vflag_fdotr = vflag_atom = 0; + int ii,i,j; + int nn = 0; + sims = new Simulation[1]; + sims->inum = listfull->inum; + sims->ilist=listfull->ilist; + sims->id = listfull->ilist; + sims->type = atom->type; + sims->x = atom->x; + sims->numneigh = listfull->numneigh; + sims->firstneigh = listfull->firstneigh; + if (dospin){ + sims->s = atom->sp; + } + int itype,f,jnum,len; + if (eflag || vflag) ev_setup(eflag,vflag); + else evflag = vflag_fdotr = eflag_global = eflag_atom = 0; + if (eflag_global){eng_vdwl=0;eng_coul=0;} + double energy=0; + double **force = atom->f; + double **fm = atom->fm; + double **virial = vatom; + char str[MAXLINE]; + //loop over atoms + for (ii=0;iiinum;ii++){ + i = sims->ilist[ii]; + itype = map[sims->type[i]]; + f = net[itype].dimensions[0]; + jnum = sims->numneigh[i]; + double xn[jnum]; + double yn[jnum]; + double zn[jnum]; + int tn[jnum]; + int jl[jnum]; + cull_neighbor_list(xn,yn,zn,tn,&jnum,jl,i,0); + double features [f]; + double dfeaturesx[f*jnum]; + double dfeaturesy[f*jnum]; + double dfeaturesz[f*jnum]; + for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + itype = nelements; + //do fingerprints for type "all" + len = fingerprintperelement[itype]; + for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + clock_t t3 = clock(); + //run fingerprints through network + if (dospin){ + propagateforwardspin(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,&energy,force,fm,virial,ii,jnum,jl); + } + else { + propagateforward(features,dfeaturesx,dfeaturesy,dfeaturesz,&energy,force,virial,ii,jnum,jl); + } + //testdfeatures(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii); + clock_t t4 = clock(); + double ts = (double) (t2-t1) / CLOCKS_PER_SEC * 1000.0; + double tf = (double) (t3-t2) / CLOCKS_PER_SEC * 1000.0; + double tp = (double) (t4-t3) / CLOCKS_PER_SEC * 1000.0; + sprintf(str,"screen time: %f, fingerprint time: %f, propagation time: %f\n",ts,tf,tp); +// std::cout<cutmax*cutmax){ + continue; + } + xn[count]=delx; + yn[count]=dely; + zn[count]=delz; + tn[count]=jtype; + jl[count]=j; + count++; + } + jnum[0]=count+1; +} + +void PairRANN::screen_neighbor_list(double *xn,double *yn, double *zn,int *tn, int* jnum,int *jl,int i,int sn,bool *Bij,double *Sik, double *dSikx, double*dSiky, double *dSikz, double *dSijkx, double *dSijky, double *dSijkz){ + double xnc[jnum[0]],ync[jnum[0]],znc[jnum[0]]; + double Sikc[jnum[0]]; + double dSikxc[jnum[0]]; + double dSikyc[jnum[0]]; + double dSikzc[jnum[0]]; + double dSijkxc[jnum[0]][jnum[0]]; + double dSijkyc[jnum[0]][jnum[0]]; + double dSijkzc[jnum[0]][jnum[0]]; + int jj,kk,count,count1,tnc[jnum[0]],jlc[jnum[0]]; + count = 0; + for (jj=0;jjtype; + inum = sims->inum; + ilist = sims->ilist; + int f = net[itype].dimensions[0]; + double cutinv2 = 1/cutmax/cutmax; + i = sims->ilist[ii]; + numneigh = sims->numneigh; + firstneigh = sims->firstneigh; + jlist = firstneigh[i]; + itype = map[sims->type[i]]; + f = net[itype].dimensions[0]; + jnum = sims->numneigh[i]; + double xn[jnum]; + double yn[jnum]; + double zn[jnum]; + int tn[jnum]; + int jl[jnum]; + double features1x [f]; + double features2x [f]; + double features1y [f]; + double features2y [f]; + double features1z [f]; + double features2z [f]; + double features1sx [f]; + double features2sx [f]; + double features1sy [f]; + double features2sy [f]; + double features1sz [f]; + double features2sz [f]; + double dfeaturesx1[f*jnum]; + double dfeaturesy1[f*jnum]; + double dfeaturesz1[f*jnum]; + double dspinx1[f*jnum]; + double dspiny1[f*jnum]; + double dspinz1[f*jnum]; + double dfxtest[f*jnum]; + double dfytest[f*jnum]; + double dfztest[f*jnum]; + double dfstestx[f*jnum]; + double dfstesty[f*jnum]; + double dfstestz[f*jnum]; + for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features1x,dfeaturesx1,dfeaturesy1,dfeaturesz1,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features1x,dfeaturesx1,dfeaturesy1,dfeaturesz1,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features1x,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features1x,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + xn[jj] = xn[jj]-2*del; + if (doscreen){ + screen(Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,0,xn,yn,zn,tn,jnum-1); + } + for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features2x,dfeaturesx1,dfeaturesy1,dfeaturesz1,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features2x,dfeaturesx1,dfeaturesy1,dfeaturesz1,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features2x,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features2x,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + for (k=0;kspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features1y,dfeaturesx1,dfeaturesy1,dfeaturesz1,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features1y,dfeaturesx1,dfeaturesy1,dfeaturesz1,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features1y,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features1y,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + yn[jj] = yn[jj]-2*del; + if (doscreen){ + screen(Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,0,xn,yn,zn,tn,jnum-1); + } + for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features2y,dfeaturesx1,dfeaturesy1,dfeaturesz1,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features2y,dfeaturesx1,dfeaturesy1,dfeaturesz1,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features2y,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features2y,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + for (k=0;kspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features1z,dfeaturesx1,dfeaturesy1,dfeaturesz1,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features1z,dfeaturesx1,dfeaturesy1,dfeaturesz1,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features1z,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features1z,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + zn[jj] = zn[jj]-2*del; + if (doscreen){ + screen(Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,0,xn,yn,zn,tn,jnum-1); + } + for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features2z,dfeaturesx1,dfeaturesy1,dfeaturesz1,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features2z,dfeaturesx1,dfeaturesy1,dfeaturesz1,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features2z,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features2z,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + for (k=0;ks[jj1][0]+=del; + for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features1sx,dfeaturesx1,dfeaturesy1,dfeaturesz1,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features1sx,dfeaturesx1,dfeaturesy1,dfeaturesz1,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features1sx,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features1sx,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + sims->s[jj1][0]-=2*del; + for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features2sx,dfeaturesx1,dfeaturesy1,dfeaturesz1,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features2sx,dfeaturesx1,dfeaturesy1,dfeaturesz1,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features2sx,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features2sx,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + for (k=0;ks[jj1][0]+=del; + sims->s[jj1][1]+=del; + for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features1sy,dfeaturesx1,dfeaturesy1,dfeaturesz1,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features1sy,dfeaturesx1,dfeaturesy1,dfeaturesz1,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features1sy,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features1sy,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + sims->s[jj1][1]-=2*del; + for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features2sy,dfeaturesx1,dfeaturesy1,dfeaturesz1,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features2sy,dfeaturesx1,dfeaturesy1,dfeaturesz1,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features2sy,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features2sy,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + for (k=0;ks[jj1][1]+=del; + sims->s[jj1][2]+=del; + for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features1sz,dfeaturesx1,dfeaturesy1,dfeaturesz1,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features1sz,dfeaturesx1,dfeaturesy1,dfeaturesz1,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features1sz,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features1sz,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + sims->s[jj1][2]-=2*del; + for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features2sz,dfeaturesx1,dfeaturesy1,dfeaturesz1,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features2sz,dfeaturesx1,dfeaturesy1,dfeaturesz1,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features2sz,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features2sz,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + for (k=0;ks[jj1][2]+=del; + for (k=0;kone(FLERR,"terminate"); + } +} + +void PairRANN::testdenergy(){ + double **force = atom->f; + double **fm = atom->fm; + double del = 0.00002; + int ii,i,j; + int nn = 0; + double ex1,ex2,ey1,ey2,ez1,ez2,esx1,esx2,esy1,esy2,esz1,esz2; + ex1=ex2=ey1=ey2=ez1=ez2=esx1=esx2=esy1=esy2=esz1=esz2=0.0; + double **force1 = new double *[listfull->maxatom]; + double **fm1 = new double *[listfull->maxatom]; + double **force1n = new double *[listfull->maxatom]; + double **fm1n = new double *[listfull->maxatom]; + for (i=0;imaxatom;i++){ + force1[i]=new double [3]; + fm1[i] = new double [3]; + force1n[i]=new double [3]; + fm1n[i] = new double [3]; + } + for (int n=0;ninum;n++){ + int itype,f,jnum,len; + double **virial = vatom; + char str[MAXLINE]; + eng_vdwl=0; + //loop over atoms + sims->x[n][0]+=del; + for (ii=0;iiinum;ii++){ + i = sims->ilist[ii]; + itype = map[sims->type[i]]; + f = net[itype].dimensions[0]; + jnum = sims->numneigh[i]; + double xn[jnum]; + double yn[jnum]; + double zn[jnum]; + int tn[jnum]; + int jl[jnum]; + cull_neighbor_list(xn,yn,zn,tn,&jnum,jl,i,0); + double features [f]; + double dfeaturesx[f*jnum]; + double dfeaturesy[f*jnum]; + double dfeaturesz[f*jnum]; + for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + itype = nelements; + //do fingerprints for type "all" + len = fingerprintperelement[itype]; + for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + //run fingerprints through network + if (dospin){ + propagateforwardspin(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,&ex1,force1,fm1,virial,ii,jnum,jl); + } + else { + propagateforward(features,dfeaturesx,dfeaturesy,dfeaturesz,&ex1,force1,virial,ii,jnum,jl); + } + ex1=eng_vdwl; + } + eng_vdwl=0; + //loop over atoms + sims->x[n][0]-=2*del; + for (ii=0;iiinum;ii++){ + i = sims->ilist[ii]; + itype = map[sims->type[i]]; + f = net[itype].dimensions[0]; + jnum = sims->numneigh[i]; + double xn[jnum]; + double yn[jnum]; + double zn[jnum]; + int tn[jnum]; + int jl[jnum]; + cull_neighbor_list(xn,yn,zn,tn,&jnum,jl,i,0); + double features [f]; + double dfeaturesx[f*jnum]; + double dfeaturesy[f*jnum]; + double dfeaturesz[f*jnum]; + for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + itype = nelements; + //do fingerprints for type "all" + len = fingerprintperelement[itype]; + for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + //run fingerprints through network + if (dospin){ + propagateforwardspin(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,&ex2,force1,fm1,virial,ii,jnum,jl); + } + else { + propagateforward(features,dfeaturesx,dfeaturesy,dfeaturesz,&ex2,force1,virial,ii,jnum,jl); + } + ex2=eng_vdwl; + } + force1n[n][0]=(ex1-ex2)/2/del; + eng_vdwl=0; + //loop over atoms + sims->x[n][0]+=del; + sims->x[n][1]+=del; + for (ii=0;iiinum;ii++){ + i = sims->ilist[ii]; + itype = map[sims->type[i]]; + f = net[itype].dimensions[0]; + jnum = sims->numneigh[i]; + double xn[jnum]; + double yn[jnum]; + double zn[jnum]; + int tn[jnum]; + int jl[jnum]; + cull_neighbor_list(xn,yn,zn,tn,&jnum,jl,i,0); + double features [f]; + double dfeaturesx[f*jnum]; + double dfeaturesy[f*jnum]; + double dfeaturesz[f*jnum]; + for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + itype = nelements; + //do fingerprints for type "all" + len = fingerprintperelement[itype]; + for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + //run fingerprints through network + if (dospin){ + propagateforwardspin(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,&ey1,force1,fm1,virial,ii,jnum,jl); + } + else { + propagateforward(features,dfeaturesx,dfeaturesy,dfeaturesz,&ey1,force1,virial,ii,jnum,jl); + } + ey1=eng_vdwl; + } + eng_vdwl=0; + //loop over atoms + sims->x[n][1]-=2*del; + for (ii=0;iiinum;ii++){ + i = sims->ilist[ii]; + itype = map[sims->type[i]]; + f = net[itype].dimensions[0]; + jnum = sims->numneigh[i]; + double xn[jnum]; + double yn[jnum]; + double zn[jnum]; + int tn[jnum]; + int jl[jnum]; + cull_neighbor_list(xn,yn,zn,tn,&jnum,jl,i,0); + double features [f]; + double dfeaturesx[f*jnum]; + double dfeaturesy[f*jnum]; + double dfeaturesz[f*jnum]; + for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + itype = nelements; + //do fingerprints for type "all" + len = fingerprintperelement[itype]; + for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + //run fingerprints through network + if (dospin){ + propagateforwardspin(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,&ey2,force1,fm1,virial,ii,jnum,jl); + } + else { + propagateforward(features,dfeaturesx,dfeaturesy,dfeaturesz,&ey2,force1,virial,ii,jnum,jl); + } + ey2=eng_vdwl; + } + eng_vdwl=0; + force1n[n][1]=(ey1-ey2)/2/del; + //loop over atoms + sims->x[n][1]+=del; + sims->x[n][2]+=del; + for (ii=0;iiinum;ii++){ + i = sims->ilist[ii]; + itype = map[sims->type[i]]; + f = net[itype].dimensions[0]; + jnum = sims->numneigh[i]; + double xn[jnum]; + double yn[jnum]; + double zn[jnum]; + int tn[jnum]; + int jl[jnum]; + cull_neighbor_list(xn,yn,zn,tn,&jnum,jl,i,0); + double features [f]; + double dfeaturesx[f*jnum]; + double dfeaturesy[f*jnum]; + double dfeaturesz[f*jnum]; + for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + itype = nelements; + //do fingerprints for type "all" + len = fingerprintperelement[itype]; + for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + //run fingerprints through network + if (dospin){ + propagateforwardspin(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,&ez1,force1,fm1,virial,ii,jnum,jl); + } + else { + propagateforward(features,dfeaturesx,dfeaturesy,dfeaturesz,&ez1,force1,virial,ii,jnum,jl); + } + ez1=eng_vdwl; + } + eng_vdwl=0; + //loop over atoms + sims->x[n][2]-=2*del; + for (ii=0;iiinum;ii++){ + i = sims->ilist[ii]; + itype = map[sims->type[i]]; + f = net[itype].dimensions[0]; + jnum = sims->numneigh[i]; + double xn[jnum]; + double yn[jnum]; + double zn[jnum]; + int tn[jnum]; + int jl[jnum]; + cull_neighbor_list(xn,yn,zn,tn,&jnum,jl,i,0); + double features [f]; + double dfeaturesx[f*jnum]; + double dfeaturesy[f*jnum]; + double dfeaturesz[f*jnum]; + for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + itype = nelements; + //do fingerprints for type "all" + len = fingerprintperelement[itype]; + for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + //run fingerprints through network + if (dospin){ + propagateforwardspin(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,&ez2,force1,fm1,virial,ii,jnum,jl); + } + else { + propagateforward(features,dfeaturesx,dfeaturesy,dfeaturesz,&ez2,force1,virial,ii,jnum,jl); + } + ez2=eng_vdwl; + } + eng_vdwl=0; + sims->x[n][2]+=del; + force1n[n][2]=(ez1-ez2)/2/del; + + //loop over atoms + sims->s[n][0]+=del; + for (ii=0;iiinum;ii++){ + i = sims->ilist[ii]; + itype = map[sims->type[i]]; + f = net[itype].dimensions[0]; + jnum = sims->numneigh[i]; + double xn[jnum]; + double yn[jnum]; + double zn[jnum]; + int tn[jnum]; + int jl[jnum]; + cull_neighbor_list(xn,yn,zn,tn,&jnum,jl,i,0); + double features [f]; + double dfeaturesx[f*jnum]; + double dfeaturesy[f*jnum]; + double dfeaturesz[f*jnum]; + for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + itype = nelements; + //do fingerprints for type "all" + len = fingerprintperelement[itype]; + for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + //run fingerprints through network + if (dospin){ + propagateforwardspin(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,&esx1,force1,fm1,virial,ii,jnum,jl); + } + else { + propagateforward(features,dfeaturesx,dfeaturesy,dfeaturesz,&esx1,force1,virial,ii,jnum,jl); + } + esx1=eng_vdwl; + } + eng_vdwl=0; + //loop over atoms + sims->s[n][0]-=2*del; + for (ii=0;iiinum;ii++){ + i = sims->ilist[ii]; + itype = map[sims->type[i]]; + f = net[itype].dimensions[0]; + jnum = sims->numneigh[i]; + double xn[jnum]; + double yn[jnum]; + double zn[jnum]; + int tn[jnum]; + int jl[jnum]; + cull_neighbor_list(xn,yn,zn,tn,&jnum,jl,i,0); + double features [f]; + double dfeaturesx[f*jnum]; + double dfeaturesy[f*jnum]; + double dfeaturesz[f*jnum]; + for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + itype = nelements; + //do fingerprints for type "all" + len = fingerprintperelement[itype]; + for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + //run fingerprints through network + if (dospin){ + propagateforwardspin(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,&esx2,force1,fm1,virial,ii,jnum,jl); + } + else { + propagateforward(features,dfeaturesx,dfeaturesy,dfeaturesz,&esx2,force1,virial,ii,jnum,jl); + } + esx2=eng_vdwl; + } + eng_vdwl=0; + fm1n[n][0]=(esx1-esx2)/2/del; + //loop over atoms + sims->s[n][0]+=del; + sims->s[n][1]+=del; + for (ii=0;iiinum;ii++){ + i = sims->ilist[ii]; + itype = map[sims->type[i]]; + f = net[itype].dimensions[0]; + jnum = sims->numneigh[i]; + double xn[jnum]; + double yn[jnum]; + double zn[jnum]; + int tn[jnum]; + int jl[jnum]; + cull_neighbor_list(xn,yn,zn,tn,&jnum,jl,i,0); + double features [f]; + double dfeaturesx[f*jnum]; + double dfeaturesy[f*jnum]; + double dfeaturesz[f*jnum]; + for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + itype = nelements; + //do fingerprints for type "all" + len = fingerprintperelement[itype]; + for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + //run fingerprints through network + if (dospin){ + propagateforwardspin(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,&esy1,force1,fm1,virial,ii,jnum,jl); + } + else { + propagateforward(features,dfeaturesx,dfeaturesy,dfeaturesz,&esy1,force1,virial,ii,jnum,jl); + } + esy1=eng_vdwl; + } + eng_vdwl=0; + //loop over atoms + sims->s[n][1]-=2*del; + for (ii=0;iiinum;ii++){ + i = sims->ilist[ii]; + itype = map[sims->type[i]]; + f = net[itype].dimensions[0]; + jnum = sims->numneigh[i]; + double xn[jnum]; + double yn[jnum]; + double zn[jnum]; + int tn[jnum]; + int jl[jnum]; + cull_neighbor_list(xn,yn,zn,tn,&jnum,jl,i,0); + double features [f]; + double dfeaturesx[f*jnum]; + double dfeaturesy[f*jnum]; + double dfeaturesz[f*jnum]; + for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + itype = nelements; + //do fingerprints for type "all" + len = fingerprintperelement[itype]; + for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + //run fingerprints through network + if (dospin){ + propagateforwardspin(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,&esy2,force1,fm1,virial,ii,jnum,jl); + } + else { + propagateforward(features,dfeaturesx,dfeaturesy,dfeaturesz,&esy2,force1,virial,ii,jnum,jl); + } + esy2=eng_vdwl; + } + eng_vdwl=0; + fm1n[n][1]=(esy1-esy2)/2/del; + //loop over atoms + sims->x[n][1]+=del; + sims->x[n][2]+=del; + for (ii=0;iiinum;ii++){ + i = sims->ilist[ii]; + itype = map[sims->type[i]]; + f = net[itype].dimensions[0]; + jnum = sims->numneigh[i]; + double xn[jnum]; + double yn[jnum]; + double zn[jnum]; + int tn[jnum]; + int jl[jnum]; + cull_neighbor_list(xn,yn,zn,tn,&jnum,jl,i,0); + double features [f]; + double dfeaturesx[f*jnum]; + double dfeaturesy[f*jnum]; + double dfeaturesz[f*jnum]; + for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + itype = nelements; + //do fingerprints for type "all" + len = fingerprintperelement[itype]; + for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + //run fingerprints through network + if (dospin){ + propagateforwardspin(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,&esz1,force1,fm1,virial,ii,jnum,jl); + } + else { + propagateforward(features,dfeaturesx,dfeaturesy,dfeaturesz,&esz1,force1,virial,ii,jnum,jl); + } + esz1=eng_vdwl; + } + eng_vdwl=0; + //loop over atoms + sims->s[n][2]-=2*del; + for (ii=0;iiinum;ii++){ + i = sims->ilist[ii]; + itype = map[sims->type[i]]; + f = net[itype].dimensions[0]; + jnum = sims->numneigh[i]; + double xn[jnum]; + double yn[jnum]; + double zn[jnum]; + int tn[jnum]; + int jl[jnum]; + cull_neighbor_list(xn,yn,zn,tn,&jnum,jl,i,0); + double features [f]; + double dfeaturesx[f*jnum]; + double dfeaturesy[f*jnum]; + double dfeaturesz[f*jnum]; + for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + itype = nelements; + //do fingerprints for type "all" + len = fingerprintperelement[itype]; + for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + //run fingerprints through network + if (dospin){ + propagateforwardspin(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,&esz2,force1,fm1,virial,ii,jnum,jl); + } + else { + propagateforward(features,dfeaturesx,dfeaturesy,dfeaturesz,&esz2,force1,virial,ii,jnum,jl); + } + esz2=eng_vdwl; + } + eng_vdwl=0; + sims->s[n][2]+=del; + fm1n[n][2]=(esz1-esz2)/2/del; + sprintf(str,"atom: %d fx: %f fxn: %f fy: %f fyn: %f fz: %f fzn: %f fmx: %f fmxn: %f fmy: %f fmyn: %f fmz: %f fmzn: %f\n",n,force[n][0],force1n[n][0],force[n][1],force1n[n][1],force[n][2],force1n[n][2],fm[n][0],fm1n[n][0],fm[n][1],fm1n[n][1],fm[n][2],fm1n[n][2]); + std::cout<x; + double xtmp,ytmp,ztmp,delx,dely,delz,rij,delx2,dely2,delz2,rik,delx3,dely3,delz3,rjk; + i = sim->ilist[ii]; + itype = map[sim->type[i]]; +// jnum = sim->numneigh[i]; +// jlist = sim->firstneigh[i]; +// xtmp = x[i][0]; +// ytmp = x[i][1]; +// ztmp = x[i][2]; + for (int jj=0;jjtype[k]]; + ktype = tn[kk]; +// delx2 = xtmp - x[k][0]; +// dely2 = ytmp - x[k][1]; +// delz2 = ztmp - x[k][2]; + delx2 = xn[kk]; + dely2 = yn[kk]; + delz2 = zn[kk]; + rik = delx2*delx2+dely2*dely2+delz2*delz2; + if (rik>cutmax*cutmax){ + Bij[kk]= false; + continue; + } + for (jj=0;jjtype[j]]; +// delx = xtmp - x[j][0]; +// dely = ytmp - x[j][1]; +// delz = ztmp - x[j][2]; + jtype = tn[jj]; + delx = xn[jj]; + dely = yn[jj]; + delz = zn[jj]; + rij = delx*delx+dely*dely+delz*delz; + if (rij>cutmax*cutmax){ + Bij[jj] = false; + continue; + } +// delx3 = x[j][0]-x[k][0]; +// dely3 = x[j][1]-x[k][1]; +// delz3 = x[j][2]-x[k][2]; + delx3 = delx2-delx; + dely3 = dely2-dely; + delz3 = delz2-delz; + rjk = delx3*delx3+dely3*dely3+delz3*delz3; + if (rik+rjk<=rij){continue;}//bond angle > 90 degrees + if (rik+rij<=rjk){continue;}//bond angle > 90 degrees + double Cmax = screening_max[itype*nelements*nelements+jtype*nelements+ktype]; + double Cmin = screening_min[itype*nelements*nelements+jtype*nelements+ktype]; + double temp1 = rij-rik+rjk; + Cn = temp1*temp1-4*rij*rjk; + //Cn = (rij-rik+rjk)*(rij-rik+rjk)-4*rij*rjk; + temp1 = rij-rjk; + Cd = temp1*temp1-rik*rik; + //Cd = (rij-rjk)*(rij-rjk)-rik*rik; + Cijk = Cn/Cd; + //Cijk = 1+2*(rik*rij+rik*rjk-rik*rik)/(rik*rik-(rij-rjk)*(rij-rjk)); + C = (Cijk-Cmin)/(Cmax-Cmin); + if (C>=1){continue;} + else if (C<=0){ + Bij[kk]=false; + break; + } + dC = Cmax-Cmin; + dC *= dC; + dC *= dC; + temp1 = 1-C; + temp1 *= temp1; + temp1 *= temp1; + Sijk = 1-temp1; + Sijk *= Sijk; + Dij = 4*rik*(Cn+4*rjk*(rij+rik-rjk))/Cd/Cd; + Dik = -4*(rij*Cn+rjk*Cn+8*rij*rik*rjk)/Cd/Cd; + Djk = 4*rik*(Cn+4*rij*(rik-rij+rjk))/Cd/Cd; + temp1 = Cijk-Cmax; + double temp2 = temp1*temp1; + dfc = 8*temp1*temp2/(temp2*temp2-dC); + Sik[kk] *= Sijk; + dSijkx[kk*jnum+jj] = dfc*(delx*Dij-delx3*Djk); + dSikx[kk] += dfc*(delx2*Dik+delx3*Djk); + dSijky[kk*jnum+jj] = dfc*(dely*Dij-dely3*Djk); + dSiky[kk] += dfc*(dely2*Dik+dely3*Djk); + dSijkz[kk*jnum+jj] = dfc*(delz*Dij-delz3*Djk); + dSikz[kk] += dfc*(delz2*Dik+delz3*Djk); + } + } +} + + +//Called by getproperties. Propagate features and dfeatures through network. Updates force and energy +void PairRANN::propagateforward(double *features,double *dfeaturesx,double *dfeaturesy,double *dfeaturesz, double * energy,double **force,double **virial, int ii,int jnum,int *jl){ + int i,j,k,jj,j1,itype,i1; + int *ilist,*numneigh; + ilist = listfull->ilist; + int inum = listfull->inum; + int *type = atom->type; + i1=ilist[ii]; + itype = map[type[i1]]; + NNarchitecture net1 = net[itype]; +// numneigh = listfull->numneigh; +// jnum = numneigh[ilist[ii]]+1;//extra value on the end of the array is the self term. +// firstneigh = listfull->firstneigh; +// jlist = firstneigh[i1]; + int L = net1.layers-1; + double layer[net1.maxlayer]; + double sum[net1.maxlayer]; + double sum1[net1.maxlayer]; + double dlayerx[jnum][net1.maxlayer]; + double dlayersumx[jnum][net1.maxlayer]; + double dlayery[jnum][net1.maxlayer]; + double dlayersumy[jnum][net1.maxlayer]; + double dlayerz[jnum][net1.maxlayer]; + double dlayersumz[jnum][net1.maxlayer]; + //energy output with forces from analytical derivatives + double dsum1; + int f = net1.dimensions[0]; + for (i=0;idactivation_function(sum[j]); + sum[j] = activation[itype][i]->activation_function(sum[j]); + if (i==L-1){ + energy[j] = sum[j]; + if (eflag_atom)eatom[i1]=sum[j]; + if (eflag_global){eng_vdwl +=sum[j];} + } + //force propagation + for (jj=0;jjilist; + int inum = listfull->inum; + int *type = atom->type; + i1=ilist[ii]; + itype = map[type[i1]]; + NNarchitecture net1 = net[itype]; +// numneigh = listfull->numneigh; +// jnum = numneigh[ilist[ii]]+1;//extra value on the end of the array is the self term. +// firstneigh = listfull->firstneigh; +// jlist = firstneigh[i1]; + int L = net1.layers-1; + double layer[net1.maxlayer]; + double sum[net1.maxlayer]; + double sum1[net1.maxlayer]; + double dlayerx[jnum][net1.maxlayer]; + double dlayersumx[jnum][net1.maxlayer]; + double dlayery[jnum][net1.maxlayer]; + double dlayersumy[jnum][net1.maxlayer]; + double dlayerz[jnum][net1.maxlayer]; + double dlayersumz[jnum][net1.maxlayer]; + double dsx[jnum][net1.maxlayer]; + double dssumx[jnum][net1.maxlayer]; + double dsy[jnum][net1.maxlayer]; + double dssumy[jnum][net1.maxlayer]; + double dsz[jnum][net1.maxlayer]; + double dssumz[jnum][net1.maxlayer]; + //energy output with forces from analytical derivatives + double dsum1; + int f = net1.dimensions[0]; + for (i=0;idactivation_function(sum[j]); + sum[j] = activation[itype][i]->activation_function(sum[j]); + if (i==L-1){ + energy[j] = sum[j]; + if (eflag_atom)eatom[i1]=sum[j]; + if (eflag_global){eng_vdwl +=sum[j];} + } + //force propagation + for (jj=0;jjrequest(this,instance_me); + neighbor->requests[irequest_full]->id = 1; + neighbor->requests[irequest_full]->half = 0; + neighbor->requests[irequest_full]->full = 1; +} + + +/* ---------------------------------------------------------------------- + init for one type pair i,j and corresponding j,i +------------------------------------------------------------------------- */ + +double PairRANN::init_one(int i, int j) +{ + return cutmax; +} + +void PairRANN::errorf(char * message){ + this->error->all(FLERR,message); +} + +template +Fingerprint *PairRANN::fingerprint_creator(PairRANN* pair) +{ + return new T(pair); +} + +Fingerprint *PairRANN::create_fingerprint(const char *style) +{ + if (fingerprint_map->find(style) != fingerprint_map->end()) { + FingerprintCreator fingerprint_creator = (*fingerprint_map)[style]; + return fingerprint_creator(this); + } + char str[128]; + sprintf(str,"Unknown fingerprint style %s",style); + error->all(FLERR,str); + return NULL; +} + +template +Activation *PairRANN::activation_creator(PairRANN* pair) +{ + return new T(pair); +} + +Activation *PairRANN::create_activation(const char *style) +{ + if (activation_map->find(style) != activation_map->end()) { + ActivationCreator activation_creator = (*activation_map)[style]; + return activation_creator(this); + } + char str[128]; + sprintf(str,"Unknown activation style %s",style); + error->all(FLERR,str); + return NULL; +} + diff --git a/src/pair_rann.h b/src/pair_rann.h new file mode 100644 index 0000000000..d2746954d2 --- /dev/null +++ b/src/pair_rann.h @@ -0,0 +1,153 @@ +/* -*- 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. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@cavs.msstate.edu + ----------------------------------------------------------------------*/ + + +#ifdef PAIR_CLASS + +PairStyle(rann,PairRANN) + +#else + +#ifndef LMP_PAIR_RANN +#define LMP_PAIR_RANN + +#define MAXLINE 4096 + +#include "neigh_list.h" +#include "pair.h" +#include +#include +#include +#include + +namespace LAMMPS_NS { + +class PairRANN : public Pair { + public: + + //inherited functions + PairRANN(class LAMMPS *); + ~PairRANN(); + void compute(int, int); + void settings(int, char **); + void coeff(int, char **); + void init_style(); + double init_one(int, int); + void init_list(int , NeighList *); + void errorf(char*); + int count_words(char *); + //black magic for modular fingerprints and activations + class Activation ***activation; + class Fingerprint ***fingerprints; + typedef Fingerprint *(*FingerprintCreator)(PairRANN *); + typedef Activation *(*ActivationCreator)(PairRANN *); + typedef std::map FingerprintCreatorMap; + typedef std::map ActivationCreatorMap; + FingerprintCreatorMap *fingerprint_map; + ActivationCreatorMap *activation_map; + Fingerprint * create_fingerprint(const char *); + Activation * create_activation(const char *); + + //global variables + int nelements; // # of elements (distinct from LAMMPS atom types since multiple atom types can be mapped to one element) + int nelementsp; // nelements+1 + char **elements; // names of elements + char **elementsp; // names of elements with "all" appended as the last "element" + double *mass; // mass of each element + double cutmax; // max radial distance for neighbor lists + int *map; // mapping from atom types to elements + int *fingerprintcount; // static variable used in initialization + int *fingerprintlength; // # of input neurons defined by fingerprints of each element. + int *fingerprintperelement; // # of fingerprints for each element + bool doscreen;//screening is calculated if any defined fingerprint uses it + bool allscreen;//all fingerprints use screening so screened neighbors can be completely ignored + bool dospin; + int res;//Resolution of function tables for cubic interpolation. + int memguess; +// double *Sik,*dSikx,*dSiky,*dSikz,*dSijkx,*dSijky,*dSijkz; +// bool *Bij; + double *screening_min; + double *screening_max; + bool **weightdefined; + bool **biasdefined; + + struct Simulation{ + int *id; + bool forces; + bool spins; + double **x; + double **f; + double **s; + double box[3][3]; + double origin[3]; + double **features; + double **dfx; + double **dfy; + double **dfz; + double **dsx; + double **dsy; + double **dsz; + int *ilist,*numneigh,**firstneigh,*type,inum,gnum; + }; + Simulation *sims; + + struct NNarchitecture{ + int layers; + int *dimensions;//vector of length layers with entries for neurons per layer + double **Weights; + double **Biases; + int *activations;//unused + int maxlayer;//longest layer (for memory allocation) + }; + NNarchitecture *net;//array of networks, 1 for each element. + + private: + template static Fingerprint *fingerprint_creator(PairRANN *); + template static Activation *activation_creator(PairRANN *); + //new functions + void allocate(char **);//called after reading element list, but before reading the rest of the potential + void read_file(char *);//read potential file + void read_atom_types(char **,char *); + void read_mass(char **,char *); + void read_fpe(char**,char *);//fingerprints per element. Count total fingerprints defined for each 1st element in element combinations + void read_fingerprints(char **,int,char *); + void read_fingerprint_constants(char **,int,char *); + void read_network_layers(char**,char*);//include input and output layer (hidden layers + 2) + void read_layer_size(char**,char*); + void read_weight(char**,char*,FILE*);//weights should be formatted as properly shaped matrices + void read_bias(char**,char*,FILE*);//biases should be formatted as properly shaped vectors + void read_activation_functions(char**,char*); + void read_screening(char**,int, char*); + bool check_potential();//after finishing reading potential file + void propagateforward(double *,double *,double *,double *,double *,double **,double **,int,int,int*);//called by compute to get force and energy + void propagateforwardspin(double *,double *,double *,double *,double *,double *,double *,double *,double **,double **,double**,int,int,int*);//called by compute to get force and energy + void screen(double*,double*,double*,double*,double*,double*,double*,bool*,int,int,double*,double*,double*,int *,int); + void testdfeatures(double *,double *, double *, double *,double *,double *, double *,int); + void testdenergy(); + void cull_neighbor_list(double *,double *,double *,int *,int *,int *,int,int); + void screen_neighbor_list(double *,double *,double *,int *,int *,int *,int,int,bool*,double*,double*,double*,double*,double*,double*,double*); + void update_stack_size(); +}; + +} + +#endif +#endif + + + diff --git a/src/style_activation.h b/src/style_activation.h new file mode 100644 index 0000000000..4cdd4ff031 --- /dev/null +++ b/src/style_activation.h @@ -0,0 +1,2 @@ +#include "activation_linear.h" +#include "activation_sigI.h" diff --git a/src/style_fingerprint.h b/src/style_fingerprint.h new file mode 100644 index 0000000000..2647d31274 --- /dev/null +++ b/src/style_fingerprint.h @@ -0,0 +1,8 @@ +#include "fingerprint_bond.h" +#include "fingerprint_bondscreened.h" +#include "fingerprint_bondscreenedspin.h" +#include "fingerprint_bondspin.h" +#include "fingerprint_radial.h" +#include "fingerprint_radialscreened.h" +#include "fingerprint_radialscreenedspin.h" +#include "fingerprint_radialspin.h" From ec82a4602d2dcf0a03deecca2cc5d437a8c081a1 Mon Sep 17 00:00:00 2001 From: kipbarrett Date: Fri, 29 Jan 2021 17:08:24 -0600 Subject: [PATCH 02/25] should be all ready --- doc/src/pair_rann.rst | 393 +++++++++++++++++++++++++++++++++++++++ potentials/Mg.rann | 91 +++++++++ potentials/MgAl.rann | 420 ++++++++++++++++++++++++++++++++++++++++++ potentials/Ti.rann | 125 +++++++++++++ potentials/Zn.rann | 124 +++++++++++++ potentials/Zr.rann | 124 +++++++++++++ 6 files changed, 1277 insertions(+) create mode 100644 doc/src/pair_rann.rst create mode 100644 potentials/Mg.rann create mode 100644 potentials/MgAl.rann create mode 100644 potentials/Ti.rann create mode 100644 potentials/Zn.rann create mode 100644 potentials/Zr.rann diff --git a/doc/src/pair_rann.rst b/doc/src/pair_rann.rst new file mode 100644 index 0000000000..72f1768364 --- /dev/null +++ b/doc/src/pair_rann.rst @@ -0,0 +1,393 @@ +.. index:: pair_style rann + +pair_style rann command +======================= + +Syntax +"""""" + +.. code-block:: LAMMPS + + pair_style rann + pair_coeff file Type1_element Type2_element Type3_element... + +Examples +"""""""" + +.. code-block:: LAMMPS + + pair_style rann + pair_coeff ** Mg.rann Mg + pair_coeff ** MgAlalloy.rann Mg Mg Al Mg + +Description +""""""""""" + +Style *rann* computes pairwise interactions for a variety of materials +using rapid atomistic neural network (RANN) potentials (:ref:`Dickel ` , :ref:`Nitol `). +Neural network potentials work by first generating a series of symmetry functions +i.e. structural fingerprints from the neighbor list and then using these values +as the input layer of a neural network. There is a single output neuron in the +final layer which is the energy. Atomic forces are found by analytical +derivatives computed via backpropagation. For alloy systems, each element has a unique +network. + +Potential file syntax +""""""""""""""""""""" + +The RANN potential is defined by a single text file which contains all the fitting parameters for the alloy system. +The potential file also defines the active fingerprints, network architecture, activation functions, etc. +The potential file is divided into several sections which are identified by one of the following keywords: + +* atomtypes + +* mass + +* fingerprintsperelement + +* fingerprints + +* fingerprintconstants + +* screening (optional) + +* networklayers + +* layersize + +* weight + +* bias + +* activationfunctions + +* calibrationparameters (ignored) + +# is treated as a comment marker, similar to LAMMPS input scripts. Sections are not required to follow a rigid +ordering, but do require previous definition of prerequisite information. E.g., fingerprintconstants for a +particular fingerprint must follow the fingerprints definition; layersize for a particular layer must follow +the declaration of network layers. + +*atomtypes* are defined as follows using element keywords separated by spaces. + +.. code-block:: + + atomtypes: + Fe Mg Al etc. + +*mass* must be specified for each element keyword as follows: + +.. code-block:: + + mass:Mg: + 24.305 + mass:Fe: + 55.847 + mass:Al: + 26.982 + +*fingerprintsperelement* specifies how many fingerprints are active for computing the energy of a given atom. +This number must be specified for each element keyword. Active elements for each fingerprint depend upon the +type of the central atom and the neighboring atoms. Pairwise fingerprints may be defined for a Mg atom based +exclusively on its Al neighbors, for example. Bond fingerprints may use two neighborlists of different +element types. In computing fingerprintsperelement from all defined fingerprints, only the fingerprints +defined for atoms of a particular element should be considered, regardless of the elements used in its +neighbor list. In the following code, for example, some fingerprints may compute pairwise fingerprints summing +contributions about Fe atoms based on a neighbor list of exclusively Al atoms, but if there are no fingerprints +summing contributions of all neighbors about a central Al atom, then fingerprintsperelement of Al is zero: + +.. code-block:: + + fingerprintsperelement:Mg: + 5 + fingerprintsperelement:Fe: + 2 + fingerprintsperelement:Al: + 0 + +*fingerprints* specifies the active fingerprints for a certain element combination. Pair fingerprints are +specified for two elements, while bond fingerprints are specified for three elements. Only one fingerprints +header should be used for an individual combination of elements. The ordering of the fingerprints in the +network input layer is determined by the order of element combinations specified by subsequent *fingerprints* +lines, and the order of the fingerprints defined for each element combination. Multiple fingerprints of the same style or +different ones may be specified. If the same style and element combination is used for multiple fingerprints, +they should have different id numbers. The first element specifies the atoms for which this fingerprint is +computed while the other(s) specify which atoms to use in the neighbor lists for the computation. Switching +the second and third element type in bond fingerprints has no effect on the computation: + +.. code-block:: + + fingerprints:Mg_Mg: + radial_0 radialscreened_0 radial_1 + fingerprints:Mg_Al_Fe: + bond_0 bondspin_0 + fingerprints:Mg_Al: + radial_0 radialscreened_0 + +The following fingerprint styles are currently defined. See the :ref:`formulation section ` below for their definitions: + +* radial + +* radialscreened + +* radialspin + +* radialscreenedspin + +* bond + +* bondscreened + +* bondspin + +* bondscreenedspin + +*fingerprintconstants* specifies the metaparameters for a defined fingerprint. For all radial styles, re, rc, +alpha, dr, o, and n must be specified. re should usually be the stable interatomic distance, rc is the cutoff +radius, dr is the cutoff smoothing distance, o is the lowest radial power term (which may be negative), and n +is the highest power term. The total length of the fingerprint vector is (n-o+1). alpha is a list of decay parameters +used for exponential decay of radial contributions. It may be set proportionally to the bulk modulus similarly +to MEAM potentials, but other values may provided better fitting in special cases. Bond style fingerprints require +specification of re, rc, alphak, dr, k, and m. Here m is the power of the bond cosines and k is the number of +decay parameters. Cosine powers go from 0 to m-1 and are each computed for all values of alphak. Thus the total +length of the fingerprint vector is m*k. + +.. code-block:: + + fingerprintconstants:Mg_Mg:radialscreened_0:re: + 3.193592 + fingerprintconstants:Mg_Mg:radialscreened_0:rc: + 6.000000 + fingerprintconstants:Mg_Mg:radialscreened_0:alpha: + 5.520000 5.520000 5.520000 5.520000 5.520000 + fingerprintconstants:Mg_Mg:radialscreened_0:dr: + 2.806408 + fingerprintconstants:Mg_Mg:radialscreened_0:o: + -1 + fingerprintconstants:Mg_Mg:radialscreened_0:n: + 3 + +*screening* specifies the Cmax and Cmin values used in the screening fingerprints. Neighbors' contribution to the +fingerprint are ommitted if they are blocked by a closer neighbor, and reduced if they are partially blocked. +Larger values of Cmin correspond to neighbors being blocked more easily. Cmax cannot be greater than 3, and +Cmin cannot be greater than Cmax or less than zero. Screening may be ommitted in which case the default values +Cmax = 2.8, Cmin = 0.8 are used. Since screening is a bond computation, it is specified separately for each +combination of three elements in which the latter two may be interchanged with no effect. + +.. code-block:: + + screening:Mg_Mg_Mg:Cmax: + 2.700000 + screening:Mg_Mg_Mg:Cmin: + 0.400000 + +*networklayers* species the size of the neural network for each atom. It counts both the input and output layer +and so is 2+hiddenlayers. + +.. code-block:: + + networklayers:Mg: + 3 + +*layersize* specifies the length of each layer, including the input layer and output layer. The input layer is +layer 0. The size of the input layer size must match the summed length of all the fingerprints for that element, +and the output layer size must be 1: + +.. code-block:: + + layersize:Mg:0: + 14 + layersize:Mg:1: + 20 + layersize:Mg:2: + 1 + +*weight* specifies the weight for a given element and layer. Weight cannot be specified for the output layer. +The weight of layer i is a mxn matrix where m is the layer size of i and n is the layer size of i+1: + +.. code-block:: + + weight:Mg:0: + w11 w12 w13 ... + w21 w22 w23 ... + ... + +*bias* specifies the bias for a given element and layer. Bias cannot be specified for the output layer. +The bias of layer i is a nx1 vector where n is the layer size of i+1: + +.. code-block:: + + bias:Mg:0: + b1 + b2 + b3 + ... + +*activationfunctions* specifies the activation function for a given element and layer. Activation functions +cannot be specified for the output layer: + +.. code-block:: + + activationfunctions:Mg:0: + sigI + activationfunctions:Mg:1: + linear + +The following activation styles are currently specified. See the :ref:`formulation section ` below for their definitions. + +* sigI + +* linear + +*calibrationparameters* specifies a number of parameters used to calibrate the potential. These are ignored +by LAMMPS. + +Formulation +""""""""""" + +In the RANN formulation, the total energy of a system of atoms +is given by: + +.. math:: + + E = \sum_{\alpha} E^{\alpha}\\\\ + E^{\alpha} = {}^{N}\!A^{\alpha}\\\\ + {}^{n+1}\!A_i^{\alpha} = {}^{n}\!F\left({}^{n}\!W_{ij}{\;}^{n}\!A_j^{\alpha}+{}^{n}\!B_i\right)\\\\ + {}^{0}\!A_i^{\alpha} = \left[\begin{array} S{}^1\!S\!f^\alpha\\ {}^2\!S\!f^\alpha \\...\\\end{array}\right] + +Here :math:`E^\alpha` is the energy of atom :math:`\alpha`, :math:`{}^n\!F()`, :math:`{}^n\!W_{ij}` and :math:`{}^n\!B_i` are +the activation function, weight matrix and bias vector of the n-th layer respectively. The +inputs to the first layer are a collection of structural fingerprints which are collected and reshaped into a single long vector. +The individual fingerprints may be defined in any order and have various shapes and sizes. Multiple fingerprints of the same +type and varying parameters may also be defined in the input layer. + +Eight types of structural fingerprints are currently defined. In the following, :math:`\beta` and :math:`\gamma` span the +full neighborlist of atom :math:`\alpha`. :math:`\delta_i` are decay metaparameters, and :math:`r_e` is a metaparameter +roughly proportional to the first neighbor distance. :math:`r_c` and :math:`dr` are the neighbor cutoff distance and +cutoff smoothing distance respectively. :math:`S^{\alpha\beta}` is the MEAM screening function +:ref:`(Baskes) `, :math:`s_i^\alpha` and :math:`s_i^\beta` are the atom spin vectors :ref:`(Tranchida) `. +:math:`r^{\alpha\beta}` is the distance from atom :math:`\alpha` to atom :math:`\beta`, and :math:`\theta^{\alpha\beta\gamma}` +is the bond angle: + +.. math :: + + cos\left(\theta^{\alpha\beta\gamma}\right)=\frac{\mathbf{r}^{\alpha\beta} \cdot \mathbf{r}^{\alpha\gamma}}{r^{\alpha\beta}r^{\alpha\gamma}} + +:math:`S^{\alpha\beta}` is defined as :ref:`(Baskes) `: + +.. math:: + + X^{\gamma\beta} = \left(\frac{r^{\gamma\beta}}{r^{\alpha\beta}}\right)^2\\ + \\ + X^{\alpha\gamma} = \left(\frac{r^{\alpha\gamma}}{r^{\alpha\beta}}\right)^2\\ + \\ + C = \frac{2\left(X^{\alpha\gamma}+X^{\gamma\beta}\right)-\left(X^{\alpha\gamma}-X^{\gamma\beta}\right)^2-1}{1-\left(X^{\alpha\gamma}-X^{\gamma\beta}\right)^2}\\ + \\ + f_c(x) = \left[\begin{array} 11 \; x \geq 1\\ \left(1-\left(1-x\right)^4\right)^2 \; 0 Date: Fri, 29 Jan 2021 17:09:40 -0600 Subject: [PATCH 03/25] maybe the last one --- doc/src/Commands_pair.rst | 1 + doc/src/pair_rann.rst | 4 +- doc/src/pair_style.rst | 1 + potentials/Mg.rann | 91 -- src/activation.cpp | 17 +- src/activation.h | 17 +- src/activation_linear.cpp | 20 +- src/activation_linear.h | 18 +- src/activation_sigI.cpp | 17 +- src/activation_sigI.h | 19 +- src/fingerprint.cpp | 21 +- src/fingerprint.h | 18 +- src/fingerprint_bond.cpp | 23 +- src/fingerprint_bond.h | 17 +- src/fingerprint_bondscreened.cpp | 22 +- src/fingerprint_bondscreened.h | 16 +- src/fingerprint_bondscreenedspin.cpp | 24 +- src/fingerprint_bondscreenedspin.h | 16 +- src/fingerprint_bondspin.cpp | 24 +- src/fingerprint_bondspin.h | 16 +- src/fingerprint_radial.cpp | 24 +- src/fingerprint_radial.h | 16 +- src/fingerprint_radialscreened.cpp | 23 +- src/fingerprint_radialscreened.h | 16 +- src/fingerprint_radialscreenedspin.cpp | 24 +- src/fingerprint_radialscreenedspin.h | 16 +- src/fingerprint_radialspin.cpp | 24 +- src/fingerprint_radialspin.h | 17 +- src/pair_rann.cpp | 1354 ++---------------------- src/pair_rann.h | 40 +- 30 files changed, 471 insertions(+), 1485 deletions(-) delete mode 100644 potentials/Mg.rann diff --git a/doc/src/Commands_pair.rst b/doc/src/Commands_pair.rst index 2ca0e88729..8d28bb7bb6 100644 --- a/doc/src/Commands_pair.rst +++ b/doc/src/Commands_pair.rst @@ -221,6 +221,7 @@ OPT. * :doc:`polymorphic ` * :doc:`python ` * :doc:`quip ` + * :doc:`rann ` * :doc:`reax/c (ko) ` * :doc:`rebo (io) ` * :doc:`resquared (go) ` diff --git a/doc/src/pair_rann.rst b/doc/src/pair_rann.rst index 72f1768364..af9b90de14 100644 --- a/doc/src/pair_rann.rst +++ b/doc/src/pair_rann.rst @@ -253,7 +253,7 @@ is given by: E = \sum_{\alpha} E^{\alpha}\\\\ E^{\alpha} = {}^{N}\!A^{\alpha}\\\\ {}^{n+1}\!A_i^{\alpha} = {}^{n}\!F\left({}^{n}\!W_{ij}{\;}^{n}\!A_j^{\alpha}+{}^{n}\!B_i\right)\\\\ - {}^{0}\!A_i^{\alpha} = \left[\begin{array} S{}^1\!S\!f^\alpha\\ {}^2\!S\!f^\alpha \\...\\\end{array}\right] + {}^{0}\!A_i^{\alpha} = \left[\begin{array}{c} {}^1\!S\!f^\alpha\\ {}^2\!S\!f^\alpha \\...\\\end{array}\right] Here :math:`E^\alpha` is the energy of atom :math:`\alpha`, :math:`{}^n\!F()`, :math:`{}^n\!W_{ij}` and :math:`{}^n\!B_i` are the activation function, weight matrix and bias vector of the n-th layer respectively. The @@ -283,7 +283,7 @@ is the bond angle: \\ C = \frac{2\left(X^{\alpha\gamma}+X^{\gamma\beta}\right)-\left(X^{\alpha\gamma}-X^{\gamma\beta}\right)^2-1}{1-\left(X^{\alpha\gamma}-X^{\gamma\beta}\right)^2}\\ \\ - f_c(x) = \left[\begin{array} 11 \; x \geq 1\\ \left(1-\left(1-x\right)^4\right)^2 \; 0` - polymorphic 3-body potential * :doc:`python ` - * :doc:`quip ` - +* :doc:`rann ` - * :doc:`reax/c ` - ReaxFF potential in C * :doc:`rebo ` - second generation REBO potential of Brenner * :doc:`resquared ` - Everaers RE-Squared ellipsoidal potential diff --git a/potentials/Mg.rann b/potentials/Mg.rann deleted file mode 100644 index 23ce143f2e..0000000000 --- a/potentials/Mg.rann +++ /dev/null @@ -1,91 +0,0 @@ -# Neural Network Potential file created by MATLAB -atomtypes: -Mg -mass:Mg: -24.305 -fingerprints:Mg_Mg: - radialpower_0 -fingerprints:Mg_Mg_Mg: - bondpower_0 -fingerprintconstants:Mg_Mg:radialpower_0:re: -3.1936 -fingerprintconstants:Mg_Mg:radialpower_0:rc: -6 -fingerprintconstants:Mg_Mg:radialpower_0:dr: -2.8064 -fingerprintconstants:Mg_Mg:radialpower_0:n: -3 -fingerprintconstants:Mg_Mg:radialpower_0:o: --1 -fingerprintconstants:Mg_Mg:radialpower_0:alpha: -5.52 5.52 5.52 5.52 5.52 -fingerprintconstants:Mg_Mg_Mg:bondpower_0:re: -3.1936 -fingerprintconstants:Mg_Mg_Mg:bondpower_0:rc: -6 -fingerprintconstants:Mg_Mg_Mg:bondpower_0:dr: -2.8064 -fingerprintconstants:Mg_Mg_Mg:bondpower_0:m: -8 -fingerprintconstants:Mg_Mg_Mg:bondpower_0:alphak: -1 2 6 9 -fingerprintconstants:Mg_Mg_Mg:bondpower_0:k: -4 -networklayers:Mg: -3 -layersize:Mg:0: -37 -layersize:Mg:1: -20 -layersize:Mg:2: -1 -weight:Mg:0: - -2.854926896534886 1.551245978744016 -5.299486715905226 1.303032393066583 -3.927350992087088 0.806210218127504 -1.428595777065406 -0.168066964538803 -0.728351260519369 -0.157450640068210 5.491434639296052 1.080334461269439 -2.130535923458539 -1.156477049555650 -2.051010848588853 -0.782611130585220 -4.606523573915344 -2.387644217672982 -5.576794096713175 -3.318269168403370 -6.292539058097229 18.703592187192875 -2.381590380244950 2.799241528343801 -2.407391034332221 4.405517388343755 -9.491423045727968 8.229571895198635 2.527344035625121 -0.067244382960372 0.170484581466223 1.282379910053745 0.065724915799647 1.113377435138116 -0.573535002947138 1.560506886857219 -0.876475786409630 - -6.905795192470435 -7.464851024478298 -4.212312565059744 0.177224177577384 11.273321377353385 -0.210487659926669 -5.819374791289330 -2.033417952209441 -4.401498131844281 -2.128151337900873 -0.904360930561321 -3.305494550705017 -4.616231916010149 3.912909136253442 2.947676302989125 -2.342485904191098 -2.629380811311687 -6.884618057641441 -3.228814118217041 -13.703094807969595 -1.300216807828401 -2.261830509920602 0.027689516537923 -0.754770352048472 0.265831744444728 -0.578713086630345 1.235859586468241 -0.909393391144123 -0.130377276389241 0.005769129836449 -0.018101530784263 -0.153698562663844 -0.004256306458426 -0.129488729063532 0.071417563698228 -0.180101367188990 0.106998530785552 - 2.027368852731460 -2.234930329773146 8.824228524281670 1.704698789800998 -1.155837352063270 0.376652391418795 0.858355152247836 1.377681586792678 0.436289641520560 0.853917175552360 0.690614213233795 1.376492364541512 -2.015997328530133 1.369574870403928 0.055844805801055 0.783591606187434 0.404005434930766 1.206961052573969 -1.999327862233608 1.826075255464499 0.627227543558058 -17.260093530489559 -0.015436687195038 -5.792743983495749 1.941452350663885 -4.516251976247205 9.635327821970479 -7.154962635508413 -1.132501265775309 0.045219076986031 -0.144961660279011 -1.214358002605798 -0.035176354978761 -1.023461588111742 0.562378377829011 -1.423056677559738 0.843325995738792 - 1.208244516420682 -1.131840612824115 5.602916209454777 5.377189872565848 -8.289510961581353 -0.757639317978607 1.630815069114324 -0.339900851719867 0.082235533040557 0.540557520027109 -5.105403160100436 -1.014334786095929 2.143454227839968 0.951897441739667 0.979668365102507 3.548633747321196 8.841902370955873 1.763504926468970 3.512417602344678 1.382917514597444 5.555534077563014 -1.659972257416550 -2.351658713764479 -4.038187560819433 -0.088959774258771 -0.970180329948655 1.946111437202853 -0.300645322288457 1.144144327361578 -0.013167226701211 -0.002692066926437 -0.162155013181752 0.022921711089007 -0.104820739882106 0.094406387979159 -0.133404958291914 0.125683026190237 - 2.100928316978550 -5.183998527665579 -8.480879276100829 9.460380106942930 -5.201669626403725 0.962206904548074 -2.984661666784377 0.261183571650286 -3.848501149625126 -0.239707114702959 -8.596129999470033 0.521757831428229 -6.520209233371624 2.323033278087488 -0.265454776689194 1.523127304519969 -1.082726125483242 1.511022780061617 1.205965597804440 0.024474495360653 -3.483786353690174 14.171770758936283 -3.851702757605302 -1.798585833589429 4.049824434318227 0.069456670984154 -4.253485775805993 4.540282728384077 14.367909979660597 -0.197918108438600 0.311690000226778 1.819217692267907 0.210328518613983 1.580666788134497 -0.708099957875404 2.228865452878142 -1.144252642918932 - 1.262532693758904 0.350623829895615 -8.699901753422376 -3.085638499190991 6.389397372073611 1.179750651699251 -2.593445903455847 1.952325298053385 6.595055699523514 2.135194104048645 5.528706413590786 1.560624920794900 2.422460296183040 1.304225846779401 -7.241934606696978 1.636390257791887 -1.736384466347888 1.467247357487496 -2.853047935848705 0.759339373628147 -3.654077760246829 11.754664182440964 0.130595433294996 4.052940796844539 -1.224415821949852 3.148873042113080 -6.429982902218374 4.900113261521697 0.823458021034089 -0.029774951115797 0.098876543510691 0.819211676255803 0.024553459350792 0.690424769720306 -0.378293809056988 0.959647124562582 -0.567667252848028 - 1.077951213052746 -1.212884120455442 4.466696029681781 1.126522701233764 -0.824485886270087 0.746066586200740 0.237846800839545 2.412691828237975 0.265670197068234 2.547960690375329 0.251089808230521 2.789866425802990 -1.386565169169989 3.188365508353491 0.012788207345652 1.411569880351537 0.187923650084155 0.897708422676008 -1.186063481186897 1.817579144493965 0.005486752244332 -8.791529216651448 -0.007914899179980 -2.954460648767480 0.990232144780852 -2.303180614487853 4.914297841774428 -3.649557839866476 -0.577624553073888 0.023071421508466 -0.073933351726003 -0.619347250688672 -0.017940452989678 -0.521986222874665 0.286824650670929 -0.725787973584357 0.430113661483229 - 1.477170160541443 -1.649652581439826 6.213432897237716 1.400569462034309 -1.011276402537009 1.187897469736217 0.453209851000615 0.871685199158680 0.459321320291843 1.847312220269744 0.575610035134335 1.736036062978334 -1.860153349971864 2.116310742565068 0.031994029982359 0.458180992521830 0.264483774017290 1.209179594569965 -1.541309826350069 2.085021603546824 0.201598271251571 -12.106547394711939 -0.010869556896233 -4.065906834057119 1.362668952258048 -3.169692616907158 6.762715300426427 -5.022207983262414 -0.794878825801757 0.031744704425550 -0.101742280431958 -0.852305421462378 -0.024688589050509 -0.718323459269597 0.394709266338209 -0.998782081426093 0.591894259734427 - 3.433524389012201 -17.461788286235350 10.477660623704468 -5.777816863260376 1.914103672722578 0.018096330553880 -0.058070001804858 -0.070387239997111 0.173183121485576 -0.045144096781169 -0.171378715111243 0.095905929991461 0.071086574391139 -0.115350907959316 0.256550435439909 0.433809735763484 -0.863025644960901 0.488223534834578 1.213451867057584 -0.873878466713472 -0.796742757392603 -13.714272857908089 7.342980962765325 64.411093528170881 10.387772034565234 -18.536427206282116 36.869062803091644 -26.192181909491545 -76.230119220113451 -13.489960390399707 0.696638838828117 -13.112785864355953 -2.884037632878795 -10.509259276761314 -0.367453998594681 -12.268265660772627 0.697571815289684 - -0.127608387430088 0.115300949266899 -0.437150971619888 -0.133383966308027 0.121497970782513 -0.588669819740072 0.025758224769098 -0.952554844198443 -0.053640314558928 -0.365454037935086 0.129308125986025 -0.108538052032897 0.419666410719713 -0.626154283498825 -0.000249078140046 -0.147478260516556 -0.027032875858370 0.027866916754600 0.118178617778006 0.057943800212654 0.006595878355105 0.872180305198599 0.000779633398631 0.293574525283819 -0.098431741706998 0.228849445048682 -0.488441508114544 0.362715745551437 0.057399641976603 -0.002293960641186 0.007348131388532 0.061556392948764 0.001783028792910 0.051879800695321 -0.028507370794972 0.072135539589032 -0.042748769934250 - 6.381829674277219 -9.048190600698000 6.288111643495736 12.859689000600714 -7.950284963331926 -0.970019501268750 2.974296325271271 -0.265518710035594 3.942466510230380 0.269993334517349 8.414210339742439 -0.503624461184050 6.702627400542080 -2.230387593186117 0.250866190943356 -1.468229492221626 0.247068384710592 -1.396879607519626 0.665239379557282 -0.918952145927020 1.429461700682165 -15.803218589855202 -3.880476592562245 -11.877864843053574 7.432265722744073 -7.799320747356560 12.522656664504245 -7.918155443300065 12.404212000235528 -0.119232499915167 0.059383452319659 -0.294483753163383 0.149136663588460 -0.200756253322839 0.270808659593346 -0.248080700766084 0.323670903595105 - -0.174630851219475 0.043280581679653 -0.446460924331736 -0.178544685668711 0.036242615491561 -0.524739832236012 -0.066055003483814 -0.137301477746459 -0.260937722788983 -0.433701744197567 -0.202915786397843 -0.164266056105498 0.067411395038662 -0.937156750357017 -0.011279189601853 -0.020004506355464 -0.062554491544235 0.022590523114614 0.005757221221309 0.030386324941044 -0.142473382537104 0.774225371167432 0.000586551446714 0.260475983526433 -0.087519136219707 0.203162145763299 -0.433956694209711 0.322113054560167 0.050871468441467 -0.002036664806940 0.006526429550767 0.054676879236815 0.001583202407854 0.046082022464924 -0.025321978370274 0.064074051139615 -0.037971760564235 - 1.804009863208751 -1.996305019395112 7.740036521789937 1.588277242818513 -1.127917261976985 0.701006047346957 0.557741638403578 1.156565391221981 0.431154676709536 0.267492331905443 0.627850709462984 1.265970301880936 -1.494924752456795 1.939364476480926 0.046524941140489 0.934668819229131 0.342634065807298 0.391343475176609 -1.821750622749297 1.674946697561555 0.434698378479914 -15.135870610005762 -0.013558976481435 -5.081347218787830 1.703032625264342 -3.961512412227682 8.451989917310183 -6.276405372141420 -0.993423100238103 0.039669224673654 -0.127157904945782 -1.065214383909233 -0.030856015692956 -0.897763264572354 0.493308941368786 -1.248281399355681 0.739751462439964 - 1.307888003990277 -1.470165596889384 5.467224874622317 1.289881274307584 -0.938892247073344 1.331752505949844 0.537151376396538 -0.075378173532199 0.266500990656396 1.863487506524708 0.466975119525905 1.205289348036037 -1.557599888898875 1.648789441886696 0.024422842314144 1.193230614379106 0.231572766233420 0.892139401518918 -1.400371331161769 2.065766931528078 0.108468715937517 -10.742037993381615 -0.009655857775515 -3.608709961236443 1.209493294888381 -2.813266719855085 6.002491329081101 -4.457627644815942 -0.705526065191486 0.028177864002805 -0.090305007412531 -0.756494222655155 -0.021913204159751 -0.637573756175409 0.350338429089144 -0.886504900913266 0.525357052259401 - 1.558386094279491 -1.738794171282809 6.591215786058525 1.446257102140766 -1.030297257597810 0.865702182464186 0.712435361441494 1.443935746150295 0.443054428290101 1.415008392625009 0.490563331892227 0.721770756564936 -1.843974805913214 1.447665543613017 0.035872549918664 -0.166709499936668 0.283150849026334 1.068709451145629 -1.615148679265154 1.807215711113644 0.254016524992397 -12.873904534676676 -0.011552521483852 -4.323339814739654 1.448978628076924 -3.370447786810358 7.191077754521811 -5.340218997908830 -0.845225465359211 0.033754412034381 -0.108187186030265 -0.906294955878763 -0.026252522971385 -0.763825881404720 0.419712224908423 -1.062050230892440 0.629387965766975 - 0.902089419117165 0.368911320289205 -8.669057127373151 -2.858394823981106 6.876026844124112 0.449359543436865 3.212232877709710 2.301343293089906 -4.918023478422725 1.779808514019082 0.075997852285900 1.213908548868051 6.340631437124236 1.806639880874012 10.667794428429600 2.826887737164946 4.877448002936416 2.649500563815019 7.025883314722370 0.314429155946167 5.646355364868669 12.148758934398504 0.126774988579089 4.171148179432463 -1.268266698902179 3.240121622890479 -6.635394495266157 5.059976550931194 0.854046514711456 -0.030497259634990 0.101782937425919 0.845882737638225 0.025146523997290 0.712861326998738 -0.390781339641258 0.990877629774033 -0.586319907462099 - -6.854080311751575 -3.366413846641228 -13.072799595088947 -1.947514492844213 13.713838929601375 -0.019406446538777 8.473917855409606 1.004610551903908 9.093996565522684 3.207103662168222 3.901439651670244 2.983318187189680 -2.524579939084030 3.252784494652512 2.950876646744284 3.372023470643452 -0.464237673645948 3.755696203886226 3.808960469764337 2.339907193946746 5.146170730857166 17.834156726071658 0.035731510216900 6.005254664256362 -1.999420765454485 4.690139638769533 -9.977721762987899 7.426200989135139 1.184394487193257 -0.046748770059314 0.150461492361159 1.259105030698577 0.036602097122206 1.061204719522792 -0.582916554758782 1.475480676393535 -0.874188624044419 - -0.091871803641423 0.155712039736981 -1.736705516334532 -3.235473587990033 -7.662082879932669 0.592839860436439 -7.068870826737258 -0.399637343479208 -6.149104660398526 -2.063383569534510 7.873997147178776 -3.605791816207420 20.150381452293846 -3.351880740983101 -0.863899319401915 -4.018547645815094 -0.784923284019245 -4.442513682373789 0.250780859062035 -5.184517276334443 0.558648923127730 1.885233769145124 0.001521615587180 0.634399323585855 -0.213531910461594 0.494460218427058 -1.058719613823579 0.784528439330135 0.124197877420478 -0.004983773553378 0.015924450492573 0.133399802571537 0.003863441417922 0.112429943824441 -0.061782783107639 0.156329122431333 -0.092647205069654 - 0.482137277570261 0.655431110773911 0.092243100481870 0.244841673165367 0.207743962910201 -0.645933694930810 -0.982792443155817 -0.909615692956593 0.313478029717837 -0.555365598226454 4.163468659783327 -0.412159823135017 6.862260499419868 -3.302281380717564 1.482065536636173 -2.407385962358501 1.098207258186840 -1.807106215233626 1.383175114366523 -1.461187579432369 1.404195771393285 0.800616887078038 0.003684546162640 0.269069405372722 -0.087549656335027 0.209484975310045 -0.442918898899253 0.331272282874469 0.053885366476729 -0.002067807910823 0.006698932859304 0.056045887718202 0.001629610981992 0.047234045216482 -0.025947665446354 0.065674182157580 -0.038913439761760 - 12.149148826917946 4.657579636724005 1.764736473860053 0.870668138244216 6.223017368077887 -1.046145904487804 0.953308100141891 -1.978615490874998 -3.417207462372495 -2.506835762341485 -3.697370786082169 -0.450785302259934 -3.125213455592869 -1.637693139214092 -1.348769649727682 -1.994082907081566 2.283115627163778 -2.635964849784550 -3.318422800479618 -3.639669251682635 -0.145614294451353 -1.483837070228372 0.212891384076277 -0.324023869431791 0.362382513657968 -0.276474277638942 1.166715100587859 -0.608385924126500 -0.008353550840676 0.006659952284272 -0.013796269604796 -0.130275245160746 -0.002411584088968 -0.109852596493500 0.062271293211841 -0.153386893869237 0.092727416429870 -bias:Mg:0: - -5.812840455195256 - 15.010638582099496 - 29.624659288791705 - 6.089482003604780 - -20.183942564953359 - -19.131750622870765 - 25.425690046060971 - 27.624111929794111 - 0.740297410586282 - -4.844537022087861 - 20.211971127789965 - -3.950026427133535 - 28.926886494246766 - 25.304822365917076 - 27.383284316546206 - -14.878350779530585 - -13.726815004417979 - 0.300936029014161 - -1.610552372672948 - 17.876279610284211 -weight:Mg:1: - 8.393525190816597 -9.799005074799757 -7.735480085336927 -8.104124576752014 12.240026012539039 5.213425998776577 -3.945232488424331 -5.429176982828405 -99.914578185849578 3.921063641589451 -12.243519026057772 3.482819561249847 -6.785425943665748 -4.818862897620001 -5.773098229238692 5.383347312306200 8.019798211775075 8.499369933136281 3.569846715528147 -8.397559798533649 -bias:Mg:1: -1713.7664607023298 -activationfunctions:Mg:0: -sigI -activationfunctions:Mg:1: -linear diff --git a/src/activation.cpp b/src/activation.cpp index aaa409c4b0..5286eb4730 100644 --- a/src/activation.cpp +++ b/src/activation.cpp @@ -10,10 +10,23 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ - /* ---------------------------------------------------------------------- - Contributing author: Christopher Barrett (MSU) barrett@me.msstate.edu + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” + +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ #include "activation.h" diff --git a/src/activation.h b/src/activation.h index 3fba49723d..0188f80bff 100644 --- a/src/activation.h +++ b/src/activation.h @@ -10,10 +10,23 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ - /* ---------------------------------------------------------------------- - Contributing author: Christopher Barrett (MSU) barrett@me.msstate.edu + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” + +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ #ifndef ACTIVATION_H_ #define ACTIVATION_H_ diff --git a/src/activation_linear.cpp b/src/activation_linear.cpp index 2ad9594be1..ddb9ae54c9 100644 --- a/src/activation_linear.cpp +++ b/src/activation_linear.cpp @@ -10,14 +10,26 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ - /* ---------------------------------------------------------------------- - Contributing author: Christopher Barrett (MSU) barrett@me.msstate.edu + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” + +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ -#include #include "activation_linear.h" -#include "activation.h" + using namespace LAMMPS_NS; diff --git a/src/activation_linear.h b/src/activation_linear.h index ba39436f03..2ea0f55729 100644 --- a/src/activation_linear.h +++ b/src/activation_linear.h @@ -10,11 +10,23 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ - /* ---------------------------------------------------------------------- - Contributing author: Christopher Barrett (MSU) barrett@me.msstate.edu -*/ + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu + ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ #ifdef ACTIVATION_CLASS ActivationStyle(linear,Activation_linear) diff --git a/src/activation_sigI.cpp b/src/activation_sigI.cpp index cdf82982da..b14f1c503d 100644 --- a/src/activation_sigI.cpp +++ b/src/activation_sigI.cpp @@ -10,12 +10,23 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ - /* ---------------------------------------------------------------------- - Contributing author: Christopher Barrett (MSU) barrett@me.msstate.edu + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” -#include +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ #include "activation_sigI.h" using namespace LAMMPS_NS; diff --git a/src/activation_sigI.h b/src/activation_sigI.h index b47433a336..404af35cfd 100644 --- a/src/activation_sigI.h +++ b/src/activation_sigI.h @@ -10,10 +10,23 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ - /* ---------------------------------------------------------------------- - Contributing author: Christopher Barrett (MSU) barrett@me.msstate.edu -*/ + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu + ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” + +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ #ifdef ACTIVATION_CLASS diff --git a/src/fingerprint.cpp b/src/fingerprint.cpp index cdcb5855bd..89786b632a 100644 --- a/src/fingerprint.cpp +++ b/src/fingerprint.cpp @@ -10,18 +10,25 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ - /* ---------------------------------------------------------------------- Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” + +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ #include "fingerprint.h" -#include -#include -#include -#include -#include -#include using namespace LAMMPS_NS; diff --git a/src/fingerprint.h b/src/fingerprint.h index 1bef4c0ab8..35645742f4 100644 --- a/src/fingerprint.h +++ b/src/fingerprint.h @@ -10,10 +10,24 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ - /* ---------------------------------------------------------------------- - Contributing author: Christopher Barrett (MSU) barrett@me.msstate.edu + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” + +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + +----------------*/ #ifndef FINGERPRINT_H_ #define FINGERPRINT_H_ diff --git a/src/fingerprint_bond.cpp b/src/fingerprint_bond.cpp index 7fdece310c..1f8630ccb2 100644 --- a/src/fingerprint_bond.cpp +++ b/src/fingerprint_bond.cpp @@ -10,21 +10,26 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ - /* ---------------------------------------------------------------------- Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu - Doyl Dickel (MSU) doyl@cavs.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ #include "fingerprint_bond.h" -#include "fingerprint.h" -#include -#include -#include -#include -#include -#include + using namespace LAMMPS_NS; diff --git a/src/fingerprint_bond.h b/src/fingerprint_bond.h index 1d07d34f3b..42d5cb03c6 100644 --- a/src/fingerprint_bond.h +++ b/src/fingerprint_bond.h @@ -10,10 +10,23 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ - /* ---------------------------------------------------------------------- - Contributing author: Christopher Barrett (MSU) barrett@me.msstate.edu + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” + +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ #ifdef FINGERPRINT_CLASS diff --git a/src/fingerprint_bondscreened.cpp b/src/fingerprint_bondscreened.cpp index 54659581a7..c573f6aedb 100644 --- a/src/fingerprint_bondscreened.cpp +++ b/src/fingerprint_bondscreened.cpp @@ -10,21 +10,25 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ - /* ---------------------------------------------------------------------- Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu - Doyl Dickel (MSU) doyl@cavs.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ #include "fingerprint_bondscreened.h" -#include "fingerprint.h" -#include -#include -#include -#include -#include -#include using namespace LAMMPS_NS; diff --git a/src/fingerprint_bondscreened.h b/src/fingerprint_bondscreened.h index 912cd1f84f..945e1615fc 100644 --- a/src/fingerprint_bondscreened.h +++ b/src/fingerprint_bondscreened.h @@ -10,11 +10,23 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ - /* ---------------------------------------------------------------------- - Contributing author: Christopher Barrett (MSU) barrett@me.msstate.edu + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ #ifdef FINGERPRINT_CLASS FingerprintStyle(bondscreened,Fingerprint_bondscreened) diff --git a/src/fingerprint_bondscreenedspin.cpp b/src/fingerprint_bondscreenedspin.cpp index cf1812b700..ce7e7c9e51 100644 --- a/src/fingerprint_bondscreenedspin.cpp +++ b/src/fingerprint_bondscreenedspin.cpp @@ -10,21 +10,25 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ - /* ---------------------------------------------------------------------- Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu - Doyl Dickel (MSU) doyl@cavs.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” - +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ #include "fingerprint_bondscreenedspin.h" -#include "fingerprint.h" -#include -#include -#include -#include -#include -#include + using namespace LAMMPS_NS; diff --git a/src/fingerprint_bondscreenedspin.h b/src/fingerprint_bondscreenedspin.h index 8a081305ff..e560c16ddb 100644 --- a/src/fingerprint_bondscreenedspin.h +++ b/src/fingerprint_bondscreenedspin.h @@ -10,11 +10,23 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ - /* ---------------------------------------------------------------------- - Contributing author: Christopher Barrett (MSU) barrett@me.msstate.edu + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ #ifdef FINGERPRINT_CLASS FingerprintStyle(bondscreenedspin,Fingerprint_bondscreenedspin) diff --git a/src/fingerprint_bondspin.cpp b/src/fingerprint_bondspin.cpp index 69e214c77a..78a0bdd815 100644 --- a/src/fingerprint_bondspin.cpp +++ b/src/fingerprint_bondspin.cpp @@ -10,21 +10,25 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ - /* ---------------------------------------------------------------------- Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu - Doyl Dickel (MSU) doyl@cavs.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” - +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ #include "fingerprint_bondspin.h" -#include "fingerprint.h" -#include -#include -#include -#include -#include -#include + using namespace LAMMPS_NS; diff --git a/src/fingerprint_bondspin.h b/src/fingerprint_bondspin.h index 5190af7107..56c540b508 100644 --- a/src/fingerprint_bondspin.h +++ b/src/fingerprint_bondspin.h @@ -10,11 +10,23 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ - /* ---------------------------------------------------------------------- - Contributing author: Christopher Barrett (MSU) barrett@me.msstate.edu + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ #ifdef FINGERPRINT_CLASS FingerprintStyle(bondspin,Fingerprint_bondspin) diff --git a/src/fingerprint_radial.cpp b/src/fingerprint_radial.cpp index f42dfc8cef..71dbcd9ad8 100644 --- a/src/fingerprint_radial.cpp +++ b/src/fingerprint_radial.cpp @@ -10,20 +10,26 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ - /* ---------------------------------------------------------------------- - Contributing author: Christopher Barrett (MSU) barrett@me.msstate.edu + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ #include "fingerprint_radial.h" -#include "fingerprint.h" -#include -#include -#include -#include -#include -#include + using namespace LAMMPS_NS; diff --git a/src/fingerprint_radial.h b/src/fingerprint_radial.h index e828aa2c41..aeb1c2eca3 100644 --- a/src/fingerprint_radial.h +++ b/src/fingerprint_radial.h @@ -10,11 +10,23 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ - /* ---------------------------------------------------------------------- - Contributing author: Christopher Barrett (MSU) barrett@me.msstate.edu + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ #ifdef FINGERPRINT_CLASS FingerprintStyle(radial,Fingerprint_radial) diff --git a/src/fingerprint_radialscreened.cpp b/src/fingerprint_radialscreened.cpp index 003c7abbc3..3101ca0ab0 100644 --- a/src/fingerprint_radialscreened.cpp +++ b/src/fingerprint_radialscreened.cpp @@ -10,19 +10,26 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ - /* ---------------------------------------------------------------------- - Contributing author: Christopher Barrett (MSU) barrett@me.msstate.edu + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ #include "fingerprint_radialscreened.h" -#include -#include -#include -#include -#include -#include + using namespace LAMMPS_NS; diff --git a/src/fingerprint_radialscreened.h b/src/fingerprint_radialscreened.h index 1a2cc518ab..7f9b729222 100644 --- a/src/fingerprint_radialscreened.h +++ b/src/fingerprint_radialscreened.h @@ -10,11 +10,23 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ - /* ---------------------------------------------------------------------- - Contributing author: Christopher Barrett (MSU) barrett@me.msstate.edu + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ #ifdef FINGERPRINT_CLASS FingerprintStyle(radialscreened,Fingerprint_radialscreened) diff --git a/src/fingerprint_radialscreenedspin.cpp b/src/fingerprint_radialscreenedspin.cpp index 906715109c..48ad061489 100644 --- a/src/fingerprint_radialscreenedspin.cpp +++ b/src/fingerprint_radialscreenedspin.cpp @@ -10,19 +10,25 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ - /* ---------------------------------------------------------------------- - Contributing author: Christopher Barrett (MSU) barrett@me.msstate.edu + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” - +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ #include "fingerprint_radialscreenedspin.h" -#include -#include -#include -#include -#include -#include + using namespace LAMMPS_NS; diff --git a/src/fingerprint_radialscreenedspin.h b/src/fingerprint_radialscreenedspin.h index f5a835111d..76c4eae50a 100644 --- a/src/fingerprint_radialscreenedspin.h +++ b/src/fingerprint_radialscreenedspin.h @@ -10,11 +10,23 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ - /* ---------------------------------------------------------------------- - Contributing author: Christopher Barrett (MSU) barrett@me.msstate.edu + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ #ifdef FINGERPRINT_CLASS FingerprintStyle(radialscreenedspin,Fingerprint_radialscreenedspin) diff --git a/src/fingerprint_radialspin.cpp b/src/fingerprint_radialspin.cpp index 36b74488b6..67ff6982c5 100644 --- a/src/fingerprint_radialspin.cpp +++ b/src/fingerprint_radialspin.cpp @@ -10,21 +10,25 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ - /* ---------------------------------------------------------------------- - Contributing author: Christopher Barrett (MSU) barrett@me.msstate.edu + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” - +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ #include "fingerprint_radialspin.h" -#include "fingerprint.h" -#include -#include -#include -#include -#include -#include using namespace LAMMPS_NS; diff --git a/src/fingerprint_radialspin.h b/src/fingerprint_radialspin.h index c42b904d61..428c0e74e4 100644 --- a/src/fingerprint_radialspin.h +++ b/src/fingerprint_radialspin.h @@ -10,10 +10,23 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ - /* ---------------------------------------------------------------------- - Contributing author: Christopher Barrett (MSU) barrett@me.msstate.edu + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” + +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ #ifdef FINGERPRINT_CLASS diff --git a/src/pair_rann.cpp b/src/pair_rann.cpp index 84333d7710..3507c931dc 100644 --- a/src/pair_rann.cpp +++ b/src/pair_rann.cpp @@ -10,36 +10,42 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ - /* ---------------------------------------------------------------------- Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu - Doyl Dickel (MSU) doyl@cavs.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” + +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ -#include -#include -#include -#include -#include -#include -#include "atom.h" #include "style_fingerprint.h" #include "style_activation.h" -#include "force.h" -#include "comm.h" -#include "memory.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "neigh_request.h" -#include "memory.h" -#include "error.h" -#include "update.h" + #include "pair_rann.h" - - using namespace LAMMPS_NS; +static const char cite_user_rann_package[] = + "USER-RANN package:\n\n" + "@Article{Nitol2021,\n" + " author = {Nitol, Mashroor S and Dickel, Doyl E and Barrett, Christopher D},\n" + " title = {Artificial neural network potential for pure zinc},\n" + " journal = {Computational Materials Science},\n" + " year = 2021,\n" + " volume = 188,\n" + " pages = {110207}\n" + "}\n\n"; + PairRANN::PairRANN(LAMMPS *lmp) : Pair(lmp) { single_enable = 0; @@ -241,44 +247,43 @@ void PairRANN::read_file(char *filename) FILE *fp; int eof = 0,i,j,k,l; int n,nwords; - char line [MAXLINE],line1[MAXLINE]; - + int longline = 4096; + char line [longline],line1[longline]; char *ptr; bool comment; char str[128]; - fp = force->open_potential(filename); + fp = utils::open_potential(filename,lmp,nullptr); if (fp == NULL) { - sprintf(str,"Cannot open NN potential file %s",filename); + sprintf(str,"Cannot open rann potential file %s",filename); error->one(FLERR,str); } while (eof == 0){ - ptr = fgets(line,MAXLINE,fp); + ptr = fgets(line,longline,fp); if (ptr == NULL) { if (check_potential()) {//looks to see if everything needed appears to be defined error->one(FLERR,"Invalid syntax in potential file, values are inconsistent or missing"); } else{ - update_stack_size(); fclose(fp); eof = 1; break; } } else n = strlen(line) + 1; - // strip comment, skip line if blank - if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = count_words(line); - char **words = new char* [strlen(line)]; - if (nwords == 0) continue; + if ((ptr = strchr(line,'#'))) *ptr = '\0';//strip comments from end of lines + if (count_words(line)==0){continue;}//skip comment line comment = true; while (comment==true){ - ptr = fgets(line1,MAXLINE,fp); - if (ptr==NULL)error->one(FLERR,"Unexpected end of file"); + ptr = fgets(line1,longline,fp); + if (ptr==NULL)errorf("Unexpected end of parameter file (keyword given with no value)"); if ((ptr = strchr(line1,'#'))) *ptr = '\0'; nwords = count_words(line1); if (nwords == 0) continue; comment = false; } + line1[strlen(line1)-1] = '\0';//replace \n with \0 + nwords = count_words(line); + char **words=new char *[nwords+1]; nwords = 0; words[nwords++] = strtok(line,": ,\t_\n"); while ((words[nwords++] = strtok(NULL,": ,\t_\n"))) continue; @@ -369,8 +374,6 @@ void PairRANN::read_fingerprints(char **words,int nwords,char * line1){ i1 = fingerprintcount[i]; delete fingerprints[i][i1]; fingerprints[i][i1] = create_fingerprint(words1[k]); - sprintf(str,"%d %d\n",nwords-1,fingerprints[i][i1]->n_body_type); - std::cout<n_body_type!=nwords-1){error->one(FLERR,"invalid fingerprint for element combination");} k++; fingerprints[i][i1]->init(atomtypes,strtol(words1[k++],NULL,10)); @@ -425,15 +428,17 @@ void PairRANN::read_network_layers(char **words,char *line1){ for (i=0;ione(FLERR,"invalid number of network layers"); + if (net[i].layers < 1)errorf("invalid number of network layers"); delete [] net[i].dimensions; - net[i].dimensions = new int [net[i].layers]; weightdefined[i] = new bool [net[i].layers]; biasdefined[i] = new bool [net[i].layers]; + net[i].dimensions = new int [net[i].layers]; net[i].Weights = new double * [net[i].layers-1]; net[i].Biases = new double * [net[i].layers-1]; + net[i].activations = new int [net[i].layers-1]; for (j=0;jone(FLERR,"networklayers for each atom type must be defined before the corresponding layer sizes."); int j = strtol(words[2],NULL,10); - if (j>=net[i].layers || j<0){errorf("invalid layer in layer size definition");}; + if (j>=net[i].layers || j<0){error->one(FLERR,"invalid layer in layer size definition");}; net[i].dimensions[j]= strtol(line1,NULL,10); -// net[i].Weights[j] = new double [1]; -// net[i].Weights[j][0]=0; -// net[i].Biases[j] = new double [1]; -// net[i].Biases[j][0] = 0; return; } } - error->one(FLERR,"layer size element not found in atom types"); + errorf("layer size element not found in atom types"); } void PairRANN::read_weight(char **words,char* line1,FILE* fp){ int i,j,k,l,nwords; char *ptr; + int longline = 4096; char **words1; for (l=0;lone(FLERR,"networklayers must be defined before weights."); + if (net[l].layers==0)errorf("networklayers must be defined before weights."); i=strtol(words[2],NULL,10); if (i>=net[l].layers || i<0)error->one(FLERR,"invalid weight layer"); - if (net[l].dimensions[i]==0 || net[l].dimensions[i+1]==0) error->one(FLERR,"network layer sizes must be defined before corresponding weight"); -// delete [] net[l].Weights[i]; + if (net[l].dimensions[i]==0 || net[l].dimensions[i+1]==0) errorf("network layer sizes must be defined before corresponding weight"); net[l].Weights[i] = new double [net[l].dimensions[i]*net[l].dimensions[i+1]]; weightdefined[l][i] = true; int n = count_words(line1)+1; @@ -489,7 +490,8 @@ void PairRANN::read_weight(char **words,char* line1,FILE* fp){ net[l].Weights[i][k] = strtod(words1[k],NULL); } for (j=1;jone(FLERR,"weight element not found in atom types"); + errorf("weight element not found in atom types"); } void PairRANN::read_bias(char **words,char* line1,FILE* fp){ @@ -552,13 +554,6 @@ void PairRANN::read_activation_functions(char** words,char * line1){ void PairRANN::read_screening(char** words,int nwords,char *line1){ int i,j,k; bool found; -// char str[MAXLINE]; -// sprintf(str,"%d\n",nwords); -// for (i=0;itype[i]]; f = net[itype].dimensions[0]; jnum = sims->numneigh[i]; - double xn[jnum]; - double yn[jnum]; - double zn[jnum]; - int tn[jnum]; - int jl[jnum]; + double *xn = new double[jnum]; + double *yn = new double[jnum]; + double *zn = new double[jnum]; + int *tn = new int[jnum]; + int *jl = new int[jnum]; cull_neighbor_list(xn,yn,zn,tn,&jnum,jl,i,0); double features [f]; - double dfeaturesx[f*jnum]; - double dfeaturesy[f*jnum]; - double dfeaturesz[f*jnum]; + double *dfeaturesx = new double[f*jnum]; + double *dfeaturesy = new double[f*jnum]; + double *dfeaturesz = new double[f*jnum]; for (j=0;jspin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); } - clock_t t3 = clock(); //run fingerprints through network if (dospin){ propagateforwardspin(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,&energy,force,fm,virial,ii,jnum,jl); @@ -733,15 +725,26 @@ void PairRANN::compute(int eflag, int vflag) else { propagateforward(features,dfeaturesx,dfeaturesy,dfeaturesz,&energy,force,virial,ii,jnum,jl); } - //testdfeatures(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii); - clock_t t4 = clock(); - double ts = (double) (t2-t1) / CLOCKS_PER_SEC * 1000.0; - double tf = (double) (t3-t2) / CLOCKS_PER_SEC * 1000.0; - double tp = (double) (t4-t3) / CLOCKS_PER_SEC * 1000.0; - sprintf(str,"screen time: %f, fingerprint time: %f, propagation time: %f\n",ts,tf,tp); -// std::cout<type; - inum = sims->inum; - ilist = sims->ilist; - int f = net[itype].dimensions[0]; - double cutinv2 = 1/cutmax/cutmax; - i = sims->ilist[ii]; - numneigh = sims->numneigh; - firstneigh = sims->firstneigh; - jlist = firstneigh[i]; - itype = map[sims->type[i]]; - f = net[itype].dimensions[0]; - jnum = sims->numneigh[i]; - double xn[jnum]; - double yn[jnum]; - double zn[jnum]; - int tn[jnum]; - int jl[jnum]; - double features1x [f]; - double features2x [f]; - double features1y [f]; - double features2y [f]; - double features1z [f]; - double features2z [f]; - double features1sx [f]; - double features2sx [f]; - double features1sy [f]; - double features2sy [f]; - double features1sz [f]; - double features2sz [f]; - double dfeaturesx1[f*jnum]; - double dfeaturesy1[f*jnum]; - double dfeaturesz1[f*jnum]; - double dspinx1[f*jnum]; - double dspiny1[f*jnum]; - double dspinz1[f*jnum]; - double dfxtest[f*jnum]; - double dfytest[f*jnum]; - double dfztest[f*jnum]; - double dfstestx[f*jnum]; - double dfstesty[f*jnum]; - double dfstestz[f*jnum]; - for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features1x,dfeaturesx1,dfeaturesy1,dfeaturesz1,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features1x,dfeaturesx1,dfeaturesy1,dfeaturesz1,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features1x,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features1x,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - } - xn[jj] = xn[jj]-2*del; - if (doscreen){ - screen(Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,0,xn,yn,zn,tn,jnum-1); - } - for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features2x,dfeaturesx1,dfeaturesy1,dfeaturesz1,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features2x,dfeaturesx1,dfeaturesy1,dfeaturesz1,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features2x,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features2x,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - } - for (k=0;kspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features1y,dfeaturesx1,dfeaturesy1,dfeaturesz1,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features1y,dfeaturesx1,dfeaturesy1,dfeaturesz1,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features1y,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features1y,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - } - yn[jj] = yn[jj]-2*del; - if (doscreen){ - screen(Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,0,xn,yn,zn,tn,jnum-1); - } - for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features2y,dfeaturesx1,dfeaturesy1,dfeaturesz1,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features2y,dfeaturesx1,dfeaturesy1,dfeaturesz1,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features2y,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features2y,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - } - for (k=0;kspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features1z,dfeaturesx1,dfeaturesy1,dfeaturesz1,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features1z,dfeaturesx1,dfeaturesy1,dfeaturesz1,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features1z,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features1z,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - } - zn[jj] = zn[jj]-2*del; - if (doscreen){ - screen(Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,0,xn,yn,zn,tn,jnum-1); - } - for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features2z,dfeaturesx1,dfeaturesy1,dfeaturesz1,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features2z,dfeaturesx1,dfeaturesy1,dfeaturesz1,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features2z,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features2z,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - } - for (k=0;ks[jj1][0]+=del; - for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features1sx,dfeaturesx1,dfeaturesy1,dfeaturesz1,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features1sx,dfeaturesx1,dfeaturesy1,dfeaturesz1,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features1sx,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features1sx,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - } - sims->s[jj1][0]-=2*del; - for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features2sx,dfeaturesx1,dfeaturesy1,dfeaturesz1,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features2sx,dfeaturesx1,dfeaturesy1,dfeaturesz1,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features2sx,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features2sx,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - } - for (k=0;ks[jj1][0]+=del; - sims->s[jj1][1]+=del; - for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features1sy,dfeaturesx1,dfeaturesy1,dfeaturesz1,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features1sy,dfeaturesx1,dfeaturesy1,dfeaturesz1,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features1sy,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features1sy,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - } - sims->s[jj1][1]-=2*del; - for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features2sy,dfeaturesx1,dfeaturesy1,dfeaturesz1,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features2sy,dfeaturesx1,dfeaturesy1,dfeaturesz1,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features2sy,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features2sy,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - } - for (k=0;ks[jj1][1]+=del; - sims->s[jj1][2]+=del; - for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features1sz,dfeaturesx1,dfeaturesy1,dfeaturesz1,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features1sz,dfeaturesx1,dfeaturesy1,dfeaturesz1,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features1sz,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features1sz,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - } - sims->s[jj1][2]-=2*del; - for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features2sz,dfeaturesx1,dfeaturesy1,dfeaturesz1,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features2sz,dfeaturesx1,dfeaturesy1,dfeaturesz1,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features2sz,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features2sz,dfeaturesx1,dfeaturesy1,dfeaturesz1,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - } - for (k=0;ks[jj1][2]+=del; - for (k=0;kone(FLERR,"terminate"); - } -} - -void PairRANN::testdenergy(){ - double **force = atom->f; - double **fm = atom->fm; - double del = 0.00002; - int ii,i,j; - int nn = 0; - double ex1,ex2,ey1,ey2,ez1,ez2,esx1,esx2,esy1,esy2,esz1,esz2; - ex1=ex2=ey1=ey2=ez1=ez2=esx1=esx2=esy1=esy2=esz1=esz2=0.0; - double **force1 = new double *[listfull->maxatom]; - double **fm1 = new double *[listfull->maxatom]; - double **force1n = new double *[listfull->maxatom]; - double **fm1n = new double *[listfull->maxatom]; - for (i=0;imaxatom;i++){ - force1[i]=new double [3]; - fm1[i] = new double [3]; - force1n[i]=new double [3]; - fm1n[i] = new double [3]; - } - for (int n=0;ninum;n++){ - int itype,f,jnum,len; - double **virial = vatom; - char str[MAXLINE]; - eng_vdwl=0; - //loop over atoms - sims->x[n][0]+=del; - for (ii=0;iiinum;ii++){ - i = sims->ilist[ii]; - itype = map[sims->type[i]]; - f = net[itype].dimensions[0]; - jnum = sims->numneigh[i]; - double xn[jnum]; - double yn[jnum]; - double zn[jnum]; - int tn[jnum]; - int jl[jnum]; - cull_neighbor_list(xn,yn,zn,tn,&jnum,jl,i,0); - double features [f]; - double dfeaturesx[f*jnum]; - double dfeaturesy[f*jnum]; - double dfeaturesz[f*jnum]; - for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - } - itype = nelements; - //do fingerprints for type "all" - len = fingerprintperelement[itype]; - for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - } - //run fingerprints through network - if (dospin){ - propagateforwardspin(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,&ex1,force1,fm1,virial,ii,jnum,jl); - } - else { - propagateforward(features,dfeaturesx,dfeaturesy,dfeaturesz,&ex1,force1,virial,ii,jnum,jl); - } - ex1=eng_vdwl; - } - eng_vdwl=0; - //loop over atoms - sims->x[n][0]-=2*del; - for (ii=0;iiinum;ii++){ - i = sims->ilist[ii]; - itype = map[sims->type[i]]; - f = net[itype].dimensions[0]; - jnum = sims->numneigh[i]; - double xn[jnum]; - double yn[jnum]; - double zn[jnum]; - int tn[jnum]; - int jl[jnum]; - cull_neighbor_list(xn,yn,zn,tn,&jnum,jl,i,0); - double features [f]; - double dfeaturesx[f*jnum]; - double dfeaturesy[f*jnum]; - double dfeaturesz[f*jnum]; - for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - } - itype = nelements; - //do fingerprints for type "all" - len = fingerprintperelement[itype]; - for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - } - //run fingerprints through network - if (dospin){ - propagateforwardspin(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,&ex2,force1,fm1,virial,ii,jnum,jl); - } - else { - propagateforward(features,dfeaturesx,dfeaturesy,dfeaturesz,&ex2,force1,virial,ii,jnum,jl); - } - ex2=eng_vdwl; - } - force1n[n][0]=(ex1-ex2)/2/del; - eng_vdwl=0; - //loop over atoms - sims->x[n][0]+=del; - sims->x[n][1]+=del; - for (ii=0;iiinum;ii++){ - i = sims->ilist[ii]; - itype = map[sims->type[i]]; - f = net[itype].dimensions[0]; - jnum = sims->numneigh[i]; - double xn[jnum]; - double yn[jnum]; - double zn[jnum]; - int tn[jnum]; - int jl[jnum]; - cull_neighbor_list(xn,yn,zn,tn,&jnum,jl,i,0); - double features [f]; - double dfeaturesx[f*jnum]; - double dfeaturesy[f*jnum]; - double dfeaturesz[f*jnum]; - for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - } - itype = nelements; - //do fingerprints for type "all" - len = fingerprintperelement[itype]; - for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - } - //run fingerprints through network - if (dospin){ - propagateforwardspin(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,&ey1,force1,fm1,virial,ii,jnum,jl); - } - else { - propagateforward(features,dfeaturesx,dfeaturesy,dfeaturesz,&ey1,force1,virial,ii,jnum,jl); - } - ey1=eng_vdwl; - } - eng_vdwl=0; - //loop over atoms - sims->x[n][1]-=2*del; - for (ii=0;iiinum;ii++){ - i = sims->ilist[ii]; - itype = map[sims->type[i]]; - f = net[itype].dimensions[0]; - jnum = sims->numneigh[i]; - double xn[jnum]; - double yn[jnum]; - double zn[jnum]; - int tn[jnum]; - int jl[jnum]; - cull_neighbor_list(xn,yn,zn,tn,&jnum,jl,i,0); - double features [f]; - double dfeaturesx[f*jnum]; - double dfeaturesy[f*jnum]; - double dfeaturesz[f*jnum]; - for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - } - itype = nelements; - //do fingerprints for type "all" - len = fingerprintperelement[itype]; - for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - } - //run fingerprints through network - if (dospin){ - propagateforwardspin(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,&ey2,force1,fm1,virial,ii,jnum,jl); - } - else { - propagateforward(features,dfeaturesx,dfeaturesy,dfeaturesz,&ey2,force1,virial,ii,jnum,jl); - } - ey2=eng_vdwl; - } - eng_vdwl=0; - force1n[n][1]=(ey1-ey2)/2/del; - //loop over atoms - sims->x[n][1]+=del; - sims->x[n][2]+=del; - for (ii=0;iiinum;ii++){ - i = sims->ilist[ii]; - itype = map[sims->type[i]]; - f = net[itype].dimensions[0]; - jnum = sims->numneigh[i]; - double xn[jnum]; - double yn[jnum]; - double zn[jnum]; - int tn[jnum]; - int jl[jnum]; - cull_neighbor_list(xn,yn,zn,tn,&jnum,jl,i,0); - double features [f]; - double dfeaturesx[f*jnum]; - double dfeaturesy[f*jnum]; - double dfeaturesz[f*jnum]; - for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - } - itype = nelements; - //do fingerprints for type "all" - len = fingerprintperelement[itype]; - for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - } - //run fingerprints through network - if (dospin){ - propagateforwardspin(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,&ez1,force1,fm1,virial,ii,jnum,jl); - } - else { - propagateforward(features,dfeaturesx,dfeaturesy,dfeaturesz,&ez1,force1,virial,ii,jnum,jl); - } - ez1=eng_vdwl; - } - eng_vdwl=0; - //loop over atoms - sims->x[n][2]-=2*del; - for (ii=0;iiinum;ii++){ - i = sims->ilist[ii]; - itype = map[sims->type[i]]; - f = net[itype].dimensions[0]; - jnum = sims->numneigh[i]; - double xn[jnum]; - double yn[jnum]; - double zn[jnum]; - int tn[jnum]; - int jl[jnum]; - cull_neighbor_list(xn,yn,zn,tn,&jnum,jl,i,0); - double features [f]; - double dfeaturesx[f*jnum]; - double dfeaturesy[f*jnum]; - double dfeaturesz[f*jnum]; - for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - } - itype = nelements; - //do fingerprints for type "all" - len = fingerprintperelement[itype]; - for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - } - //run fingerprints through network - if (dospin){ - propagateforwardspin(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,&ez2,force1,fm1,virial,ii,jnum,jl); - } - else { - propagateforward(features,dfeaturesx,dfeaturesy,dfeaturesz,&ez2,force1,virial,ii,jnum,jl); - } - ez2=eng_vdwl; - } - eng_vdwl=0; - sims->x[n][2]+=del; - force1n[n][2]=(ez1-ez2)/2/del; - - //loop over atoms - sims->s[n][0]+=del; - for (ii=0;iiinum;ii++){ - i = sims->ilist[ii]; - itype = map[sims->type[i]]; - f = net[itype].dimensions[0]; - jnum = sims->numneigh[i]; - double xn[jnum]; - double yn[jnum]; - double zn[jnum]; - int tn[jnum]; - int jl[jnum]; - cull_neighbor_list(xn,yn,zn,tn,&jnum,jl,i,0); - double features [f]; - double dfeaturesx[f*jnum]; - double dfeaturesy[f*jnum]; - double dfeaturesz[f*jnum]; - for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - } - itype = nelements; - //do fingerprints for type "all" - len = fingerprintperelement[itype]; - for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - } - //run fingerprints through network - if (dospin){ - propagateforwardspin(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,&esx1,force1,fm1,virial,ii,jnum,jl); - } - else { - propagateforward(features,dfeaturesx,dfeaturesy,dfeaturesz,&esx1,force1,virial,ii,jnum,jl); - } - esx1=eng_vdwl; - } - eng_vdwl=0; - //loop over atoms - sims->s[n][0]-=2*del; - for (ii=0;iiinum;ii++){ - i = sims->ilist[ii]; - itype = map[sims->type[i]]; - f = net[itype].dimensions[0]; - jnum = sims->numneigh[i]; - double xn[jnum]; - double yn[jnum]; - double zn[jnum]; - int tn[jnum]; - int jl[jnum]; - cull_neighbor_list(xn,yn,zn,tn,&jnum,jl,i,0); - double features [f]; - double dfeaturesx[f*jnum]; - double dfeaturesy[f*jnum]; - double dfeaturesz[f*jnum]; - for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - } - itype = nelements; - //do fingerprints for type "all" - len = fingerprintperelement[itype]; - for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - } - //run fingerprints through network - if (dospin){ - propagateforwardspin(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,&esx2,force1,fm1,virial,ii,jnum,jl); - } - else { - propagateforward(features,dfeaturesx,dfeaturesy,dfeaturesz,&esx2,force1,virial,ii,jnum,jl); - } - esx2=eng_vdwl; - } - eng_vdwl=0; - fm1n[n][0]=(esx1-esx2)/2/del; - //loop over atoms - sims->s[n][0]+=del; - sims->s[n][1]+=del; - for (ii=0;iiinum;ii++){ - i = sims->ilist[ii]; - itype = map[sims->type[i]]; - f = net[itype].dimensions[0]; - jnum = sims->numneigh[i]; - double xn[jnum]; - double yn[jnum]; - double zn[jnum]; - int tn[jnum]; - int jl[jnum]; - cull_neighbor_list(xn,yn,zn,tn,&jnum,jl,i,0); - double features [f]; - double dfeaturesx[f*jnum]; - double dfeaturesy[f*jnum]; - double dfeaturesz[f*jnum]; - for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - } - itype = nelements; - //do fingerprints for type "all" - len = fingerprintperelement[itype]; - for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - } - //run fingerprints through network - if (dospin){ - propagateforwardspin(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,&esy1,force1,fm1,virial,ii,jnum,jl); - } - else { - propagateforward(features,dfeaturesx,dfeaturesy,dfeaturesz,&esy1,force1,virial,ii,jnum,jl); - } - esy1=eng_vdwl; - } - eng_vdwl=0; - //loop over atoms - sims->s[n][1]-=2*del; - for (ii=0;iiinum;ii++){ - i = sims->ilist[ii]; - itype = map[sims->type[i]]; - f = net[itype].dimensions[0]; - jnum = sims->numneigh[i]; - double xn[jnum]; - double yn[jnum]; - double zn[jnum]; - int tn[jnum]; - int jl[jnum]; - cull_neighbor_list(xn,yn,zn,tn,&jnum,jl,i,0); - double features [f]; - double dfeaturesx[f*jnum]; - double dfeaturesy[f*jnum]; - double dfeaturesz[f*jnum]; - for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - } - itype = nelements; - //do fingerprints for type "all" - len = fingerprintperelement[itype]; - for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - } - //run fingerprints through network - if (dospin){ - propagateforwardspin(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,&esy2,force1,fm1,virial,ii,jnum,jl); - } - else { - propagateforward(features,dfeaturesx,dfeaturesy,dfeaturesz,&esy2,force1,virial,ii,jnum,jl); - } - esy2=eng_vdwl; - } - eng_vdwl=0; - fm1n[n][1]=(esy1-esy2)/2/del; - //loop over atoms - sims->x[n][1]+=del; - sims->x[n][2]+=del; - for (ii=0;iiinum;ii++){ - i = sims->ilist[ii]; - itype = map[sims->type[i]]; - f = net[itype].dimensions[0]; - jnum = sims->numneigh[i]; - double xn[jnum]; - double yn[jnum]; - double zn[jnum]; - int tn[jnum]; - int jl[jnum]; - cull_neighbor_list(xn,yn,zn,tn,&jnum,jl,i,0); - double features [f]; - double dfeaturesx[f*jnum]; - double dfeaturesy[f*jnum]; - double dfeaturesz[f*jnum]; - for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - } - itype = nelements; - //do fingerprints for type "all" - len = fingerprintperelement[itype]; - for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - } - //run fingerprints through network - if (dospin){ - propagateforwardspin(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,&esz1,force1,fm1,virial,ii,jnum,jl); - } - else { - propagateforward(features,dfeaturesx,dfeaturesy,dfeaturesz,&esz1,force1,virial,ii,jnum,jl); - } - esz1=eng_vdwl; - } - eng_vdwl=0; - //loop over atoms - sims->s[n][2]-=2*del; - for (ii=0;iiinum;ii++){ - i = sims->ilist[ii]; - itype = map[sims->type[i]]; - f = net[itype].dimensions[0]; - jnum = sims->numneigh[i]; - double xn[jnum]; - double yn[jnum]; - double zn[jnum]; - int tn[jnum]; - int jl[jnum]; - cull_neighbor_list(xn,yn,zn,tn,&jnum,jl,i,0); - double features [f]; - double dfeaturesx[f*jnum]; - double dfeaturesy[f*jnum]; - double dfeaturesz[f*jnum]; - for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - } - itype = nelements; - //do fingerprints for type "all" - len = fingerprintperelement[itype]; - for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - } - //run fingerprints through network - if (dospin){ - propagateforwardspin(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,&esz2,force1,fm1,virial,ii,jnum,jl); - } - else { - propagateforward(features,dfeaturesx,dfeaturesy,dfeaturesz,&esz2,force1,virial,ii,jnum,jl); - } - esz2=eng_vdwl; - } - eng_vdwl=0; - sims->s[n][2]+=del; - fm1n[n][2]=(esz1-esz2)/2/del; - sprintf(str,"atom: %d fx: %f fxn: %f fy: %f fyn: %f fz: %f fzn: %f fmx: %f fmxn: %f fmy: %f fmyn: %f fmz: %f fmzn: %f\n",n,force[n][0],force1n[n][0],force[n][1],force1n[n][1],force[n][2],force1n[n][2],fm[n][0],fm1n[n][0],fm[n][1],fm1n[n][1],fm[n][2],fm1n[n][2]); - std::cout<error->all(FLERR,message); } diff --git a/src/pair_rann.h b/src/pair_rann.h index d2746954d2..1358c67fb0 100644 --- a/src/pair_rann.h +++ b/src/pair_rann.h @@ -10,12 +10,23 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ - /* ---------------------------------------------------------------------- Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu - Doyl Dickel (MSU) doyl@cavs.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ #ifdef PAIR_CLASS @@ -26,14 +37,26 @@ PairStyle(rann,PairRANN) #ifndef LMP_PAIR_RANN #define LMP_PAIR_RANN -#define MAXLINE 4096 +#define MAXLINE 1024 +#include +#include +#include +#include +#include +#include "atom.h" +#include "force.h" +#include "comm.h" +#include "memory.h" +#include "neighbor.h" #include "neigh_list.h" +#include "neigh_request.h" +#include "memory.h" +#include "error.h" +#include "update.h" #include "pair.h" #include -#include #include -#include namespace LAMMPS_NS { @@ -49,7 +72,7 @@ class PairRANN : public Pair { void init_style(); double init_one(int, int); void init_list(int , NeighList *); - void errorf(char*); + void errorf(const char*); int count_words(char *); //black magic for modular fingerprints and activations class Activation ***activation; @@ -79,8 +102,6 @@ class PairRANN : public Pair { bool dospin; int res;//Resolution of function tables for cubic interpolation. int memguess; -// double *Sik,*dSikx,*dSiky,*dSikz,*dSijkx,*dSijky,*dSijkz; -// bool *Bij; double *screening_min; double *screening_max; bool **weightdefined; @@ -137,11 +158,8 @@ class PairRANN : public Pair { void propagateforward(double *,double *,double *,double *,double *,double **,double **,int,int,int*);//called by compute to get force and energy void propagateforwardspin(double *,double *,double *,double *,double *,double *,double *,double *,double **,double **,double**,int,int,int*);//called by compute to get force and energy void screen(double*,double*,double*,double*,double*,double*,double*,bool*,int,int,double*,double*,double*,int *,int); - void testdfeatures(double *,double *, double *, double *,double *,double *, double *,int); - void testdenergy(); void cull_neighbor_list(double *,double *,double *,int *,int *,int *,int,int); void screen_neighbor_list(double *,double *,double *,int *,int *,int *,int,int,bool*,double*,double*,double*,double*,double*,double*,double*); - void update_stack_size(); }; } From 417e92bc2db164283e13fe068dbd9d7ea23d9e3a Mon Sep 17 00:00:00 2001 From: kipbarrett Date: Thu, 11 Feb 2021 08:43:04 -0600 Subject: [PATCH 04/25] Axels requested revisions --- cmake/CMakeLists.txt | 2 +- src/Makefile | 2 +- src/USER-RANN/pair_rann.cpp | 1261 +++++++++++++++++ src/USER-RANN/pair_rann.h | 174 +++ src/USER-RANN/rann_activation.h | 73 + src/USER-RANN/rann_activation_linear.h | 77 + src/USER-RANN/rann_activation_sig_i.h | 77 + src/USER-RANN/rann_fingerprint.cpp | 116 ++ src/USER-RANN/rann_fingerprint.h | 72 + src/USER-RANN/rann_fingerprint_bond.cpp | 808 +++++++++++ src/USER-RANN/rann_fingerprint_bond.h | 80 ++ .../rann_fingerprint_bondscreened.cpp | 762 ++++++++++ src/USER-RANN/rann_fingerprint_bondscreened.h | 80 ++ .../rann_fingerprint_bondscreenedspin.cpp | 814 +++++++++++ .../rann_fingerprint_bondscreenedspin.h | 80 ++ src/USER-RANN/rann_fingerprint_bondspin.cpp | 887 ++++++++++++ src/USER-RANN/rann_fingerprint_bondspin.h | 79 ++ src/USER-RANN/rann_fingerprint_radial.cpp | 239 ++++ src/USER-RANN/rann_fingerprint_radial.h | 70 + .../rann_fingerprint_radialscreened.cpp | 253 ++++ .../rann_fingerprint_radialscreened.h | 72 + .../rann_fingerprint_radialscreenedspin.cpp | 264 ++++ .../rann_fingerprint_radialscreenedspin.h | 72 + src/USER-RANN/rann_fingerprint_radialspin.cpp | 252 ++++ src/USER-RANN/rann_fingerprint_radialspin.h | 69 + src/USER-RANN/rann_list_activation.h | 2 + src/USER-RANN/rann_list_fingerprint.h | 8 + 27 files changed, 6743 insertions(+), 2 deletions(-) create mode 100644 src/USER-RANN/pair_rann.cpp create mode 100644 src/USER-RANN/pair_rann.h create mode 100644 src/USER-RANN/rann_activation.h create mode 100644 src/USER-RANN/rann_activation_linear.h create mode 100644 src/USER-RANN/rann_activation_sig_i.h create mode 100644 src/USER-RANN/rann_fingerprint.cpp create mode 100644 src/USER-RANN/rann_fingerprint.h create mode 100644 src/USER-RANN/rann_fingerprint_bond.cpp create mode 100644 src/USER-RANN/rann_fingerprint_bond.h create mode 100644 src/USER-RANN/rann_fingerprint_bondscreened.cpp create mode 100644 src/USER-RANN/rann_fingerprint_bondscreened.h create mode 100644 src/USER-RANN/rann_fingerprint_bondscreenedspin.cpp create mode 100644 src/USER-RANN/rann_fingerprint_bondscreenedspin.h create mode 100644 src/USER-RANN/rann_fingerprint_bondspin.cpp create mode 100644 src/USER-RANN/rann_fingerprint_bondspin.h create mode 100644 src/USER-RANN/rann_fingerprint_radial.cpp create mode 100644 src/USER-RANN/rann_fingerprint_radial.h create mode 100644 src/USER-RANN/rann_fingerprint_radialscreened.cpp create mode 100644 src/USER-RANN/rann_fingerprint_radialscreened.h create mode 100644 src/USER-RANN/rann_fingerprint_radialscreenedspin.cpp create mode 100644 src/USER-RANN/rann_fingerprint_radialscreenedspin.h create mode 100644 src/USER-RANN/rann_fingerprint_radialspin.cpp create mode 100644 src/USER-RANN/rann_fingerprint_radialspin.h create mode 100644 src/USER-RANN/rann_list_activation.h create mode 100644 src/USER-RANN/rann_list_fingerprint.h diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index c29fba5957..b125556c73 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -110,7 +110,7 @@ set(STANDARD_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS DIPOLE USER-ATC USER-AWPMD USER-BOCS USER-CGDNA USER-MESODPD USER-CGSDK USER-COLVARS USER-DIFFRACTION USER-DPD USER-DRUDE USER-EFF USER-FEP USER-H5MD USER-LB USER-MANIFOLD USER-MEAMC USER-MESONT USER-MGPT USER-MISC USER-MOFFF USER-MOLFILE - USER-NETCDF USER-PHONON USER-PLUMED USER-PTM USER-QTB USER-REACTION + USER-NETCDF USER-PHONON USER-PLUMED USER-PTM USER-QTB USER-RANN USER-REACTION USER-REAXC USER-SCAFACOS USER-SDPD USER-SMD USER-SMTBQ USER-SPH USER-TALLY USER-UEF USER-VTK USER-QUIP USER-QMMM USER-YAFF USER-ADIOS) set(SUFFIX_PACKAGES CORESHELL USER-OMP KOKKOS OPT USER-INTEL GPU) diff --git a/src/Makefile b/src/Makefile index 7a5e1aa728..f77e127264 100644 --- a/src/Makefile +++ b/src/Makefile @@ -56,7 +56,7 @@ PACKUSER = user-adios user-atc user-awpmd user-bocs user-cgdna user-cgsdk user-c user-intel user-lb user-manifold user-meamc user-mesodpd user-mesont \ user-mgpt user-misc user-mofff user-molfile \ user-netcdf user-omp user-phonon user-plumed user-ptm user-qmmm \ - user-qtb user-quip user-reaction user-reaxc user-scafacos user-smd user-smtbq \ + user-qtb user-quip user-rann user-reaction user-reaxc user-scafacos user-smd user-smtbq \ user-sdpd user-sph user-tally user-uef user-vtk user-yaff PACKLIB = compress gpu kim kokkos latte message mpiio mscg poems \ diff --git a/src/USER-RANN/pair_rann.cpp b/src/USER-RANN/pair_rann.cpp new file mode 100644 index 0000000000..3207b76934 --- /dev/null +++ b/src/USER-RANN/pair_rann.cpp @@ -0,0 +1,1261 @@ +/* -*- 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. +------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu + ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” + +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ +#define MAXLINE 1024 +#include "pair_rann.h" +#include "rann_list_activation.h" +#include "rann_list_fingerprint.h" +#include "tokenizer.h" +#include +#include +#include +#include +#include "atom.h" +#include "force.h" +#include "comm.h" +#include "memory.h" +#include "neigh_request.h" +#include "memory.h" +#include "error.h" +#include "update.h" +#include "math_special.h" + +using namespace LAMMPS_NS; + +static const char cite_user_rann_package[] = + "USER-RANN package:\n\n" + "@Article{Nitol2021,\n" + " author = {Nitol, Mashroor S and Dickel, Doyl E and Barrett, Christopher D},\n" + " title = {Artificial neural network potential for pure zinc},\n" + " journal = {Computational Materials Science},\n" + " year = 2021,\n" + " volume = 188,\n" + " pages = {110207}\n" + "}\n\n"; + + +PairRANN::PairRANN(LAMMPS *lmp) : Pair(lmp) +{ + single_enable = 0; + restartinfo = 0; + one_coeff = 1; + manybody_flag = 1; + allocated = 0; + nelements = -1; + elements = NULL; + mass = NULL; + + // set comm size needed by this Pair + // comm unused for now. + + comm_forward = 38; + comm_reverse = 30; + res = 10000; + cutmax = 0; + //at least one of the following will change during fingerprint definition: + doscreen = false; + allscreen = true; + + dospin = false; + fingerprint_map = new FingerprintCreatorMap(); + #define FINGERPRINT_CLASS + #define FingerprintStyle(key,Class) \ + (*fingerprint_map)[#key] = &fingerprint_creator; + + #include "rann_list_fingerprint.h" + #undef FingerprintStyle + #undef FINGERPRINT_CLASS + activation_map = new ActivationCreatorMap(); + #define ACTIVATION_CLASS + #define ActivationStyle(key,Class) \ + (*activation_map)[#key] = &activation_creator; + + #include "rann_list_activation.h" + #undef ActivationStyle + #undef ACTIVATION_CLASS +} + +PairRANN::~PairRANN() +{ + //clear memory + delete [] mass; + for (int i=0;i0) { + for (int j=0;j0) { + delete [] fingerprints[i]; + delete [] activation[i]; + } + } + delete [] fingerprints; + delete [] activation; + delete [] fingerprintcount; + delete [] fingerprintperelement; + delete [] fingerprintlength; + delete [] screening_min; + delete [] screening_max; + memory->destroy(xn); + memory->destroy(yn); + memory->destroy(zn); + memory->destroy(tn); + memory->destroy(jl); + memory->destroy(features); + memory->destroy(dfeaturesx); + memory->destroy(dfeaturesy); + memory->destroy(dfeaturesz); + memory->destroy(layer); + memory->destroy(sum); + memory->destroy(sum1); + memory->destroy(dlayerx); + memory->destroy(dlayery); + memory->destroy(dlayerz); + memory->destroy(dlayersumx); + memory->destroy(dlayersumy); + memory->destroy(dlayersumz); + if (doscreen) { + memory->destroy(Sik); + memory->destroy(Bij); + memory->destroy(dSikx); + memory->destroy(dSiky); + memory->destroy(dSikz); + memory->destroy(dSijkx); + memory->destroy(dSijky); + memory->destroy(dSijkz); + memory->destroy(dSijkxc); + memory->destroy(dSijkyc); + memory->destroy(dSijkzc); + } + if (dospin) { + memory->destroy(sx); + memory->destroy(sy); + memory->destroy(sz); + memory->destroy(dlayerx); + memory->destroy(dlayery); + memory->destroy(dlayerz); + memory->destroy(dlayersumx); + memory->destroy(dlayersumy); + memory->destroy(dlayersumz); + } +} + + + +void PairRANN::allocate(std::vector elementwords) +{ + int i,j,k,l,n; + n = atom->ntypes; + memory->create(setflag,n+1,n+1,"pair:setflag"); + memory->create(cutsq,n+1,n+1,"pair:cutsq"); + cutmax = 0; + nmax1 = 100; + nmax2 = 20; + fmax = 0; + fnmax = 0; + nelementsp=nelements+1; + //initialize arrays + elements = new char *[nelements]; + elementsp = new char *[nelementsp];//elements + 'all' + mass = new double[nelements]; + net = new NNarchitecture[nelementsp]; + weightdefined = new bool*[nelementsp]; + biasdefined = new bool *[nelementsp]; + activation = new RANN::Activation**[nelementsp]; + fingerprints = new RANN::Fingerprint**[nelementsp]; + fingerprintlength = new int[nelementsp]; + fingerprintperelement = new int [nelementsp]; + fingerprintcount = new int[nelementsp]; + screening_min = new double [nelements*nelements*nelements]; + screening_max = new double [nelements*nelements*nelements]; + for (i=0;i 0) error->one(FLERR,"Illegal pair_style command"); +} + +void PairRANN::coeff(int narg, char **arg) +{ + int i,j; + map = new int [atom->ntypes+1]; + if (narg != 3 + atom->ntypes) error->one(FLERR,"Incorrect args for pair coefficients"); + if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) error->one(FLERR,"Incorrect args for pair coefficients"); + nelements = -1; + read_file(arg[2]); + // read args that map atom types to elements in potential file + // map[i] = which element the Ith atom type is, -1 if NULL + for (i = 3; i < narg; i++) { + if (strcmp(arg[i],"NULL") == 0) { + map[i-2] = -1; + continue; + } + for (j = 0; j < nelements; j++) { + if (strcmp(arg[i],elements[j]) == 0) break; + } + if (j < nelements) map[i-2] = j; + else error->one(FLERR,"No matching element in NN potential file"); + } + // clear setflag since coeff() called once with I,J = * * + int n = atom->ntypes; + for (i = 1; i <= n; i++) { + for (j = i; j <= n; j++) { + setflag[i][j] = 0; + } + } + // set setflag i,j for type pairs where both are mapped to elements + // set mass of atom type if i = j + int count = 0; + for (i = 1; i <= n; i++) { + for (j = i; j <= n; j++) { + if (map[i] >= 0 && map[j] >= 0) { + setflag[i][j] = 1; + if (i == j) atom->set_mass(FLERR,i,mass[map[i]]); + count++; + } + } + } + if (count == 0) error->one(FLERR,"Incorrect args for pair coefficients"); + for (i=0;iallocate(); + } + } + allocated=1; +} + +void PairRANN::read_file(char *filename) +{ + FILE *fp; + int eof = 0,i,j,k,l; + int n,nwords; + std::string line,line1; + int longline = 4096; + char linetemp[longline]; + char *ptr; + bool comment; + char str[128]; + std::vector linev,line1v; + fp = utils::open_potential(filename,lmp,nullptr); + if (fp == nullptr) {error->one(FLERR,"Cannot open RANN potential file");} + ptr=fgets(linetemp,longline,fp); + strip_comments(linetemp,fp); + line=linetemp; + while (eof == 0) { + ptr=fgets(linetemp,longline,fp); + if (ptr == NULL) { + if (check_potential()) { + error->one(FLERR,"Invalid syntax in potential file, values are inconsistent or missing"); + } + else { + eof = 1; + break; + } + } + strip_comments(linetemp,fp); + line1=linetemp; + Tokenizer values = Tokenizer(line,": ,\t_\n"); + Tokenizer values1 = Tokenizer(line1,": ,\t_\n"); + linev = values.as_vector(); + line1v = values1.as_vector(); + if (linev[0].compare("atomtypes")==0)read_atom_types(linev,line1v); + else if (linev[0].compare("mass")==0)read_mass(linev,line1v); + else if (linev[0].compare("fingerprintsperelement")==0)read_fpe(linev,line1v); + else if (linev[0].compare("fingerprints")==0)read_fingerprints(linev,line1v); + else if (linev[0].compare("fingerprintconstants")==0)read_fingerprint_constants(linev,line1v); + else if (linev[0].compare("networklayers")==0)read_network_layers(linev,line1v); + else if (linev[0].compare("layersize")==0)read_layer_size(linev,line1v); + else if (linev[0].compare("weight")==0)read_weight(linev,line1v,fp); + else if (linev[0].compare("bias")==0)read_bias(linev,line1v,fp); + else if (linev[0].compare("activationfunctions")==0)read_activation_functions(linev,line1v); + else if (linev[0].compare("calibrationparameters")==0)continue;//information on how the network was trained + else if (linev[0].compare("screening")==0)read_screening(linev,line1v); + else error->one(FLERR,"Could not understand file syntax: unknown keyword"); + ptr=fgets(linetemp,longline,fp); + strip_comments(linetemp,fp); + if (ptr == NULL) { + if (check_potential()) { + error->one(FLERR,"Invalid syntax in potential file, values are inconsistent or missing"); + } + else { + eof = 1; + break; + } + } + line=linetemp; + } +} + +void PairRANN::strip_comments(char * line,FILE* fp) { + char *ptr; + bool comment; + utils::trim_comment(line); + if (strlen(line)==0) { + comment = true; + while (comment==true) { + ptr = fgets(line,4096,fp); + if (ptr==NULL) error->one(FLERR,"Unexpected end of RANN file"); + utils::trim_comment(line); + if (strlen(line) == 0) continue; + comment = false; + } + } +} + +void PairRANN::read_atom_types(std::vector line,std::vector line1) { + int nwords = line1.size(); + if (nwords < 1) error->one(FLERR,"Incorrect syntax for atom types"); + nelements = nwords; + line1.resize(nwords+1); + line1[nwords] = "all"; + allocate(line1); +} + +void PairRANN::read_mass(std::vector line,std::vector line1) { + if (nelements == -1)error->one(FLERR,"atom types must be defined before mass in potential file."); + int nwords = 0,i; + for (i=0;ione(FLERR,"mass element not found in atom types."); +} + +void PairRANN::read_fpe(std::vector line,std::vector line1) { + int i,j; + if (nelements == -1)error->one(FLERR,"atom types must be defined before fingerprints per element in potential file."); + for (i=0;ione(FLERR,"fingerprint-per-element element not found in atom types"); +} + +void PairRANN::read_fingerprints(std::vector line,std::vector line1) { + int nwords1,nwords,i,j,k,l,m,i1; + bool found; + char str[MAXLINE]; + nwords1 = line1.size(); + nwords = line.size(); + if (nelements == -1)error->one(FLERR,"atom types must be defined before fingerprints in potential file."); + int atomtypes[nwords-1]; + for (i=1;ione(FLERR,"fingerprint element not found in atom types");} + } + i = atomtypes[0]; + k = 0; + if (fingerprintperelement[i]==-1) {error->one(FLERR,"fingerprint per element must be defined before fingerprints");} + while (kn_body_type!=nwords-1) {error->one(FLERR,"invalid fingerprint for element combination");} + k++; + fingerprints[i][i1]->init(atomtypes,strtol(line1[k++].c_str(),NULL,10)); + fingerprintcount[i]++; + } +} + + +void PairRANN::read_fingerprint_constants(std::vector line,std::vector line1) { + int i,j,k,l,m,i1; + bool found; + char str [128]; + int nwords = line.size(); + if (nelements == -1)error->one(FLERR,"atom types must be defined before fingerprints in potential file."); + int n_body_type = nwords-4; + int atomtypes[n_body_type]; + for (i=1;i<=n_body_type;i++) { + found = false; + for (j=0;jone(FLERR,"fingerprint element not found in atom types");} + } + i = atomtypes[0]; + found = false; + for (k=0;kempty) {continue;} + if (n_body_type!=fingerprints[i][k]->n_body_type) {continue;} + for (j=0;jatomtypes[j]!=atomtypes[j]) {break;} + if (j==n_body_type-1) { + if (line[nwords-3].compare(fingerprints[i][k]->style)==0 && strtol(line[nwords-2].c_str(),NULL,10)==fingerprints[i][k]->id) { + found=true; + i1 = k; + break; + } + } + } + if (found) {break;} + } + if (!found) {error->one(FLERR,"cannot define constants for unknown fingerprint");} + fingerprints[i][i1]->fullydefined=fingerprints[i][i1]->parse_values(line[nwords-1],line1); +} + +void PairRANN::read_network_layers(std::vector line,std::vector line1) { + int i,j; + if (nelements == -1)error->one(FLERR,"atom types must be defined before network layers in potential file."); + for (i=0;ione(FLERR,"invalid number of network layers"); + delete [] net[i].dimensions; + weightdefined[i] = new bool [net[i].layers]; + biasdefined[i] = new bool [net[i].layers]; + net[i].dimensions = new int [net[i].layers]; + net[i].Weights = new double * [net[i].layers-1]; + net[i].Biases = new double * [net[i].layers-1]; + net[i].activations = new int [net[i].layers-1]; + for (j=0;jone(FLERR,"network layers element not found in atom types"); +} + +void PairRANN::read_layer_size(std::vector line,std::vector line1) { + int i; + for (i=0;ione(FLERR,"networklayers for each atom type must be defined before the corresponding layer sizes."); + int j = strtol(line[2].c_str(),NULL,10); + if (j>=net[i].layers || j<0) {error->one(FLERR,"invalid layer in layer size definition");}; + net[i].dimensions[j]= strtol(line1[0].c_str(),NULL,10); + return; + } + } + error->one(FLERR,"layer size element not found in atom types"); +} + +void PairRANN::read_weight(std::vector line,std::vector line1,FILE* fp) { + int i,j,k,l,nwords; + char *ptr; + int longline = 4096; + char linetemp [longline]; + for (l=0;lone(FLERR,"networklayers must be defined before weights."); + i=strtol(line[2].c_str(),NULL,10); + if (i>=net[l].layers || i<0)error->one(FLERR,"invalid weight layer"); + if (net[l].dimensions[i]==0 || net[l].dimensions[i+1]==0) error->one(FLERR,"network layer sizes must be defined before corresponding weight"); + net[l].Weights[i] = new double [net[l].dimensions[i]*net[l].dimensions[i+1]]; + weightdefined[l][i] = true; + nwords = line1.size(); + if (nwords != net[l].dimensions[i])error->one(FLERR,"invalid weights per line"); + for (k=0;kone(FLERR,"unexpected end of potential file!"); + nwords = line1.size(); + if (nwords != net[l].dimensions[i])error->one(FLERR,"invalid weights per line"); + for (k=0;kone(FLERR,"weight element not found in atom types"); +} + +void PairRANN::read_bias(std::vector line,std::vector line1,FILE* fp) { + int i,j,l,nwords; + char *ptr; + char linetemp[MAXLINE]; + for (l=0;lone(FLERR,"networklayers must be defined before biases."); + i=strtol(line[2].c_str(),NULL,10); + if (i>=net[l].layers || i<0)error->one(FLERR,"invalid bias layer"); + if (net[l].dimensions[i]==0) error->one(FLERR,"network layer sizes must be defined before corresponding bias"); + biasdefined[l][i] = true; + net[l].Biases[i] = new double [net[l].dimensions[i+1]]; + net[l].Biases[i][0] = strtod(line1[0].c_str(),NULL); + for (j=1;jone(FLERR,"bias element not found in atom types"); +} + +void PairRANN::read_activation_functions(std::vector line,std::vector line1) { + int i,j,l,nwords; + int *ptr; + for (l=0;lone(FLERR,"networklayers must be defined before activation functions."); + i = strtol(line[2].c_str(),NULL,10); + if (i>=net[l].layers || i<0)error->one(FLERR,"invalid activation layer"); + delete activation[l][i]; + activation[l][i]=create_activation(line1[0].c_str()); + return; + } + } + error->one(FLERR,"activation function element not found in atom types"); +} + +void PairRANN::read_screening(std::vector line,std::vector line1) { + int i,j,k; + bool found; + int nwords = line.size(); + if (nelements == -1)error->one(FLERR,"atom types must be defined before fingerprints in potential file."); + if (nwords!=5)error->one(FLERR,"invalid screening command"); + int n_body_type = 3; + int atomtypes[n_body_type]; + for (i=1;i<=n_body_type;i++) { + found = false; + for (j=0;jone(FLERR,"fingerprint element not found in atom types");} + } + i = atomtypes[0]; + j = atomtypes[1]; + k = atomtypes[2]; + int index = i*nelements*nelements+j*nelements+k; + int index1 = i*nelements*nelements+k*nelements+j; + if (line[4].compare("Cmin")==0) { + screening_min[index] = strtod(line1[0].c_str(),NULL); + screening_min[index1] = screening_min[index]; + } + else if (line[4].compare("Cmax")==0) { + screening_max[index] = strtod(line1[0].c_str(),NULL); + screening_max[index1] = screening_max[index]; + } + else error->one(FLERR,"unrecognized screening keyword"); +} + +//Called after finishing reading the potential file to make sure it is complete. True is bad. +//also does the rest of the memory allocation. +bool PairRANN::check_potential() { + int i,j,k,l; + if (nelements==-1) {return true;} + for (i=0;i<=nelements;i++) { + if (inet[i].maxlayer)net[i].maxlayer = net[i].dimensions[j]; + } + if (net[i].maxlayer>fnmax) {fnmax = net[i].maxlayer;} + if (net[i].dimensions[net[i].layers-1]!=1)return true;//output layer must have single neuron (the energy) + if (net[i].dimensions[0]>fmax)fmax=net[i].dimensions[0]; + for (j=0;jempty)return true;//undefined activations + for (k=0;kfullydefined==false)return true; + fingerprints[i][j]->startingneuron = fingerprintlength[i]; + fingerprintlength[i] +=fingerprints[i][j]->get_length(); + if (fingerprints[i][j]->rc>cutmax) {cutmax = fingerprints[i][j]->rc;} + } + if (net[i].dimensions[0]!=fingerprintlength[i])return true; + } + memory->create(xn,nmax1,"pair:xn"); + memory->create(yn,nmax1,"pair:yn"); + memory->create(zn,nmax1,"pair:zn"); + memory->create(tn,nmax1,"pair:tn"); + memory->create(jl,nmax1,"pair:jl"); + memory->create(features,fmax,"pair:features"); + memory->create(dfeaturesx,fmax*nmax2,"pair:dfeaturesx"); + memory->create(dfeaturesy,fmax*nmax2,"pair:dfeaturesy"); + memory->create(dfeaturesz,fmax*nmax2,"pair:dfeaturesz"); + memory->create(layer,fnmax,"pair:layer"); + memory->create(sum,fnmax,"pair:sum"); + memory->create(sum1,fnmax,"pair:sum1"); + memory->create(dlayerx,nmax2,fnmax,"pair:dlayerx"); + memory->create(dlayery,nmax2,fnmax,"pair:dlayery"); + memory->create(dlayerz,nmax2,fnmax,"pair:dlayerz"); + memory->create(dlayersumx,nmax2,fnmax,"pair:dlayersumx"); + memory->create(dlayersumy,nmax2,fnmax,"pair:dlayersumy"); + memory->create(dlayersumz,nmax2,fnmax,"pair:dlayersumz"); + if (doscreen) { + memory->create(Sik,nmax2,"pair:Sik"); + memory->create(Bij,nmax2,"pair:Bij"); + memory->create(dSikx,nmax2,"pair:dSikx"); + memory->create(dSiky,nmax2,"pair:dSiky"); + memory->create(dSikz,nmax2,"pair:dSikz"); + memory->create(dSijkx,nmax2*nmax2,"pair:dSijkx"); + memory->create(dSijky,nmax2*nmax2,"pair:dSijky"); + memory->create(dSijkz,nmax2*nmax2,"pair:dSijkz"); + memory->create(dSijkxc,nmax2,nmax2,"pair:dSijkxc"); + memory->create(dSijkyc,nmax2,nmax2,"pair:dSijkyc"); + memory->create(dSijkzc,nmax2,nmax2,"pair:dSijkzc"); + } + if (dospin) { + memory->create(sx,fmax*nmax2,"pair:sx"); + memory->create(sy,fmax*nmax2,"pair:sy"); + memory->create(sz,fmax*nmax2,"pair:sz"); + memory->create(dlayerx,nmax2,fnmax,"pair:dsx"); + memory->create(dlayery,nmax2,fnmax,"pair:dsy"); + memory->create(dlayerz,nmax2,fnmax,"pair:dsz"); + memory->create(dlayersumx,nmax2,fnmax,"pair:dssumx"); + memory->create(dlayersumy,nmax2,fnmax,"pair:dssumy"); + memory->create(dlayersumz,nmax2,fnmax,"pair:dssumz"); + } + return false;//everything looks good +} + +void PairRANN::compute(int eflag, int vflag) +{ + //perform force/energy computation_ + if (dospin) { + if (strcmp(update->unit_style,"metal") != 0) + error->one(FLERR,"Spin pair styles require metal units"); + if (!atom->sp_flag) + error->one(FLERR,"Spin pair styles requires atom/spin style"); + } + if (eflag || vflag) ev_setup(eflag,vflag); + else evflag = vflag_fdotr = vflag_atom = 0; + int ii,i,j; + int nn = 0; + sims = new Simulation[1]; + sims->inum = listfull->inum; + sims->ilist=listfull->ilist; + sims->id = listfull->ilist; + sims->type = atom->type; + sims->x = atom->x; + sims->numneigh = listfull->numneigh; + sims->firstneigh = listfull->firstneigh; + if (dospin) { + sims->s = atom->sp; + } + int itype,f,jnum,len; + if (eflag || vflag) ev_setup(eflag,vflag); + else evflag = vflag_fdotr = eflag_global = eflag_atom = 0; + if (eflag_global) {eng_vdwl=0;eng_coul=0;} + double energy=0; + double **force = atom->f; + double **fm = atom->fm; + double **virial = vatom; + //loop over atoms + for (ii=0;iiinum;ii++) { + i = sims->ilist[ii]; + itype = map[sims->type[i]]; + f = net[itype].dimensions[0]; + jnum = sims->numneigh[i]; + if (jnum>nmax1) { + nmax1 = jnum; + memory->grow(xn,nmax1,"pair:xn"); + memory->grow(yn,nmax1,"pair:yn"); + memory->grow(zn,nmax1,"pair:zn"); + memory->grow(tn,nmax1,"pair:tn"); + memory->grow(jl,nmax1,"pair:jl"); + } + cull_neighbor_list(&jnum,i,0); + if (jnum>nmax2) { + nmax2=jnum; + memory->grow(dfeaturesx,fmax*nmax2,"pair:dfeaturesx"); + memory->grow(dfeaturesy,fmax*nmax2,"pair:dfeaturesy"); + memory->grow(dfeaturesz,fmax*nmax2,"pair:dfeaturesz"); + memory->grow(layer,fnmax,"pair:layer"); + memory->grow(sum,fnmax,"pair:sum"); + memory->grow(sum1,fnmax,"pair:sum1"); + memory->grow(dlayerx,nmax2,fnmax,"pair:dlayerx"); + memory->grow(dlayery,nmax2,fnmax,"pair:dlayery"); + memory->grow(dlayerz,nmax2,fnmax,"pair:dlayerz"); + memory->grow(dlayersumx,nmax2,fnmax,"pair:dlayersumx"); + memory->grow(dlayersumy,nmax2,fnmax,"pair:dlayersumy"); + memory->grow(dlayersumz,nmax2,fnmax,"pair:dlayersumz"); + if (doscreen) { + memory->grow(Sik,nmax2,"pair:Sik"); + memory->grow(Bij,nmax2,"pair:Bij"); + memory->grow(dSikx,nmax2,"pair:dSikx"); + memory->grow(dSiky,nmax2,"pair:dSiky"); + memory->grow(dSikz,nmax2,"pair:dSikz"); + memory->grow(dSijkx,nmax2*nmax2,"pair:dSijkx"); + memory->grow(dSijky,nmax2*nmax2,"pair:dSijky"); + memory->grow(dSijkz,nmax2*nmax2,"pair:dSijkz"); + memory->destroy(dSijkxc); + memory->destroy(dSijkyc); + memory->destroy(dSijkzc); + memory->create(dSijkxc,nmax2,nmax2,"pair:dSijkxc"); + memory->create(dSijkyc,nmax2,nmax2,"pair:dSijkyc"); + memory->create(dSijkzc,nmax2,nmax2,"pair:dSijkzc"); + } + if (dospin) { + memory->grow(sx,fmax*nmax2,"pair:sx"); + memory->grow(sy,fmax*nmax2,"pair:sy"); + memory->grow(sz,fmax*nmax2,"pair:sz"); + memory->grow(dsx,nmax2,fnmax,"pair:dsx"); + memory->grow(dsy,nmax2,fnmax,"pair:dsy"); + memory->grow(dsz,nmax2,fnmax,"pair:dsz"); + memory->grow(dssumx,nmax2,fnmax,"pair:dssumx"); + memory->grow(dssumy,nmax2,fnmax,"pair:dssumy"); + memory->grow(dssumz,nmax2,fnmax,"pair:dssumz"); + } + } + for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + itype = nelements; + //do fingerprints for type "all" + len = fingerprintperelement[itype]; + for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); + else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); + } + //run fingerprints through network + if (dospin) { + propagateforwardspin(&energy,force,fm,virial,ii,jnum); + } + else { + propagateforward(&energy,force,virial,ii,jnum); + } + } + if (vflag_fdotr) virial_fdotr_compute(); +} + +void PairRANN::cull_neighbor_list(int* jnum,int i,int sn) { + int *jlist,j,count,jj,*type,jtype; + double xtmp,ytmp,ztmp,delx,dely,delz,rsq; + double **x = sims[sn].x; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + type = sims[sn].type; + jlist = sims[sn].firstneigh[i]; + count = 0; + for (jj=0;jjcutmax*cutmax) { + continue; + } + xn[count]=delx; + yn[count]=dely; + zn[count]=delz; + tn[count]=jtype; + jl[count]=j; + count++; + } + jnum[0]=count+1; +} + +void PairRANN::screen_neighbor_list(int *jnum, int i,int sn) { + int jj,kk,count,count1; + count = 0; + for (jj=0;jjilist[ii]; + itype = map[sim->type[i]]; + for (int jj=0;jjcutmax*cutmax) { + Bij[kk]= false; + continue; + } + for (jj=0;jjcutmax*cutmax) { + Bij[jj] = false; + continue; + } + delx3 = delx2-delx; + dely3 = dely2-dely; + delz3 = delz2-delz; + rjk = delx3*delx3+dely3*dely3+delz3*delz3; + if (rik+rjk<=rij) {continue;}//bond angle > 90 degrees + if (rik+rij<=rjk) {continue;}//bond angle > 90 degrees + double Cmax = screening_max[itype*nelements*nelements+jtype*nelements+ktype]; + double Cmin = screening_min[itype*nelements*nelements+jtype*nelements+ktype]; + double temp1 = rij-rik+rjk; + Cn = temp1*temp1-4*rij*rjk; + //a few expanded computations provided for clarity: + //Cn = (rij-rik+rjk)*(rij-rik+rjk)-4*rij*rjk; + //Cd = (rij-rjk)*(rij-rjk)-rik*rik; + //Cijk = 1+2*(rik*rij+rik*rjk-rik*rik)/(rik*rik-(rij-rjk)*(rij-rjk)); + temp1 = rij-rjk; + Cd = temp1*temp1-rik*rik; + Cijk = Cn/Cd; + C = (Cijk-Cmin)/(Cmax-Cmin); + if (C>=1) {continue;} + else if (C<=0) { + Bij[kk]=false; + break; + } + dC = Cmax-Cmin; + dC *= dC; + dC *= dC; + temp1 = 1-C; + temp1 *= temp1; + temp1 *= temp1; + Sijk = 1-temp1; + Sijk *= Sijk; + Dij = 4*rik*(Cn+4*rjk*(rij+rik-rjk))/Cd/Cd; + Dik = -4*(rij*Cn+rjk*Cn+8*rij*rik*rjk)/Cd/Cd; + Djk = 4*rik*(Cn+4*rij*(rik-rij+rjk))/Cd/Cd; + temp1 = Cijk-Cmax; + double temp2 = temp1*temp1; + dfc = 8*temp1*temp2/(temp2*temp2-dC); + Sik[kk] *= Sijk; + dSijkx[kk*jnum+jj] = dfc*(delx*Dij-delx3*Djk); + dSikx[kk] += dfc*(delx2*Dik+delx3*Djk); + dSijky[kk*jnum+jj] = dfc*(dely*Dij-dely3*Djk); + dSiky[kk] += dfc*(dely2*Dik+dely3*Djk); + dSijkz[kk*jnum+jj] = dfc*(delz*Dij-delz3*Djk); + dSikz[kk] += dfc*(delz2*Dik+delz3*Djk); + } + } +} + + +//Called by getproperties. Propagate features and dfeatures through network. Updates force and energy +void PairRANN::propagateforward(double * energy,double **force,double **virial, int ii,int jnum) { + int i,j,k,jj,j1,itype,i1; + int *ilist,*numneigh; + ilist = listfull->ilist; + int inum = listfull->inum; + int *type = atom->type; + i1=ilist[ii]; + itype = map[type[i1]]; + NNarchitecture net1 = net[itype]; + int L = net1.layers-1; + //energy output with forces from analytical derivatives + double dsum1; + int f = net1.dimensions[0]; + for (i=0;idactivation_function(sum[j]); + sum[j] = activation[itype][i]->activation_function(sum[j]); + if (i==L-1) { + energy[j] = sum[j]; + if (eflag_atom)eatom[i1]=sum[j]; + if (eflag_global) {eng_vdwl +=sum[j];} + } + //force propagation + for (jj=0;jjilist; + int inum = listfull->inum; + int *type = atom->type; + i1=ilist[ii]; + itype = map[type[i1]]; + NNarchitecture net1 = net[itype]; + int L = net1.layers-1; + //energy output with forces from analytical derivatives + double dsum1; + int f = net1.dimensions[0]; + for (i=0;idactivation_function(sum[j]); + sum[j] = activation[itype][i]->activation_function(sum[j]); + if (i==L-1) { + energy[j] = sum[j]; + if (eflag_atom)eatom[i1]=sum[j]; + if (eflag_global) {eng_vdwl +=sum[j];} + } + //force propagation + for (jj=0;jjrequest(this,instance_me); + neighbor->requests[irequest_full]->id = 1; + neighbor->requests[irequest_full]->half = 0; + neighbor->requests[irequest_full]->full = 1; +} + + +/* ---------------------------------------------------------------------- + init for one type pair i,j and corresponding j,i +------------------------------------------------------------------------- */ + +double PairRANN::init_one(int i, int j) +{ + return cutmax; +} + +void PairRANN::errorf(const char *file, int line, const char * message) { + error->one(file,line,message); +} + +int PairRANN::factorial(int n) { + return round(MathSpecial::factorial(n)); +} + +template +RANN::Fingerprint *PairRANN::fingerprint_creator(PairRANN* pair) +{ + return new T(pair); +} + +RANN::Fingerprint *PairRANN::create_fingerprint(const char *style) +{ + if (fingerprint_map->find(style) != fingerprint_map->end()) { + FingerprintCreator fingerprint_creator = (*fingerprint_map)[style]; + return fingerprint_creator(this); + } + char str[128]; + sprintf(str,"Unknown fingerprint style %s",style); + error->one(FLERR,str); + return NULL; +} + +template +RANN::Activation *PairRANN::activation_creator(PairRANN* pair) +{ + return new T(pair); +} + +RANN::Activation *PairRANN::create_activation(const char *style) +{ + if (activation_map->find(style) != activation_map->end()) { + ActivationCreator activation_creator = (*activation_map)[style]; + return activation_creator(this); + } + char str[128]; + sprintf(str,"Unknown activation style %s",style); + error->one(FLERR,str); + return NULL; +} + diff --git a/src/USER-RANN/pair_rann.h b/src/USER-RANN/pair_rann.h new file mode 100644 index 0000000000..9f1dbe9212 --- /dev/null +++ b/src/USER-RANN/pair_rann.h @@ -0,0 +1,174 @@ +/* -*- 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. +------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu + ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” + +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ + +#ifdef PAIR_CLASS + +PairStyle(rann,PairRANN) + +#else + +#ifndef LMP_PAIR_RANN +#define LMP_PAIR_RANN + + +#include "neighbor.h" +#include "neigh_list.h" +#include "pair.h" +#include + + +namespace LAMMPS_NS { + + namespace RANN { + //forward declarations + class Activation; + class Fingerprint; + } + + class PairRANN : public Pair { + public: + //inherited functions + PairRANN(class LAMMPS *); + ~PairRANN(); + void compute(int, int); + void settings(int, char **); + void coeff(int, char **); + void init_style(); + double init_one(int, int); + void init_list(int , NeighList *); + void errorf(const char*,int,const char*); + int factorial(int); + //black magic for modular fingerprints and activations + class RANN::Activation ***activation; + class RANN::Fingerprint ***fingerprints; + typedef RANN::Fingerprint *(*FingerprintCreator)(PairRANN *); + typedef RANN::Activation *(*ActivationCreator)(PairRANN *); + typedef std::map FingerprintCreatorMap; + typedef std::map ActivationCreatorMap; + FingerprintCreatorMap *fingerprint_map; + ActivationCreatorMap *activation_map; + RANN::Fingerprint * create_fingerprint(const char *); + RANN::Activation * create_activation(const char *); + + //global variables + int nelements; // # of elements (distinct from LAMMPS atom types since multiple atom types can be mapped to one element) + int nelementsp; // nelements+1 + char **elements; // names of elements + char **elementsp; // names of elements with "all" appended as the last "element" + double *mass; // mass of each element + double cutmax; // max radial distance for neighbor lists + int *map; // mapping from atom types to elements + int *fingerprintcount; // static variable used in initialization + int *fingerprintlength; // # of input neurons defined by fingerprints of each element. + int *fingerprintperelement; // # of fingerprints for each element + bool doscreen;//screening is calculated if any defined fingerprint uses it + bool allscreen;//all fingerprints use screening so screened neighbors can be completely ignored + bool dospin; + int res;//Resolution of function tables for cubic interpolation. + int memguess; + double *screening_min; + double *screening_max; + bool **weightdefined; + bool **biasdefined; + int nmax1; + int nmax2; + int fmax; + int fnmax; + //memory actively written to during each compute: + double *xn,*yn,*zn,*Sik,*dSikx,*dSiky,*dSikz,*dSijkx,*dSijky,*dSijkz,*sx,*sy,*sz,**dSijkxc,**dSijkyc,**dSijkzc,*dfeaturesx,*dfeaturesy,*dfeaturesz,*features; + double *layer,*sum,*sum1,**dlayerx,**dlayery,**dlayerz,**dlayersumx,**dlayersumy,**dlayersumz; + double **dsx,**dsy,**dsz,**dssumx,**dssumy,**dssumz; + int *tn,*jl; + bool *Bij; + + struct Simulation{ + int *id; + bool forces; + bool spins; + double **x; + double **f; + double **s; + double box[3][3]; + double origin[3]; + double **features; + double **dfx; + double **dfy; + double **dfz; + double **dsx; + double **dsy; + double **dsz; + int *ilist,*numneigh,**firstneigh,*type,inum,gnum; + }; + + struct NNarchitecture{ + int layers; + int *dimensions;//vector of length layers with entries for neurons per layer + double **Weights; + double **Biases; + int *activations;//unused + int maxlayer;//longest layer (for memory allocation) + }; + + Simulation *sims; + NNarchitecture *net;//array of networks, 1 for each element. + + private: + template static RANN::Fingerprint *fingerprint_creator(PairRANN *); + template static RANN::Activation *activation_creator(PairRANN *); + //new functions + void allocate(std::vector);//called after reading element list, but before reading the rest of the potential + void read_file(char *);//read potential file + void strip_comments(char *,FILE *fp); + void read_atom_types(std::vector,std::vector); + void read_mass(std::vector,std::vector); + void read_fpe(std::vector,std::vector);//fingerprints per element. Count total fingerprints defined for each 1st element in element combinations + void read_fingerprints(std::vector,std::vector); + void read_fingerprint_constants(std::vector,std::vector); + void read_network_layers(std::vector,std::vector);//include input and output layer (hidden layers + 2) + void read_layer_size(std::vector,std::vector); + void read_weight(std::vector,std::vector,FILE*);//weights should be formatted as properly shaped matrices + void read_bias(std::vector,std::vector,FILE*);//biases should be formatted as properly shaped vectors + void read_activation_functions(std::vector,std::vector); + void read_screening(std::vector,std::vector); + bool check_potential();//after finishing reading potential file + void propagateforward(double *,double **,double **,int,int);//called by compute to get force and energy + void propagateforwardspin(double *,double **,double **,double**,int,int);//called by compute to get force and energy + void screen(int,int,int); + void cull_neighbor_list(int *,int,int); + void screen_neighbor_list(int *,int,int); + }; + +} + +#endif +#endif + + + diff --git a/src/USER-RANN/rann_activation.h b/src/USER-RANN/rann_activation.h new file mode 100644 index 0000000000..d8d2940228 --- /dev/null +++ b/src/USER-RANN/rann_activation.h @@ -0,0 +1,73 @@ +/* -*- 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. +------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu + ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” + +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ + +#ifndef LMP_RANN_ACTIVATION_H +#define LMP_RANN_ACTIVATION_H + + +namespace LAMMPS_NS { + namespace RANN { + class Activation { + public: + Activation(class PairRANN *); + virtual ~Activation(); + virtual double activation_function(double); + virtual double dactivation_function(double); + virtual double ddactivation_function(double); + bool empty; + const char *style; + }; + + Activation::Activation(PairRANN *_pair) { + empty = true; + style = "empty"; + } + + Activation::~Activation() { + + } + + //default is linear activation (no change). + double Activation::activation_function(double A) { + return A; + } + + double Activation::dactivation_function(double A) { + return 1.0; + } + + double Activation::ddactivation_function(double A) { + return 0.0; + } + } +} + + +#endif /* RANN_ACTIVATION_H_ */ diff --git a/src/USER-RANN/rann_activation_linear.h b/src/USER-RANN/rann_activation_linear.h new file mode 100644 index 0000000000..812c570d3a --- /dev/null +++ b/src/USER-RANN/rann_activation_linear.h @@ -0,0 +1,77 @@ + +/* -*- 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. +------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu + ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” + +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ +#ifdef ACTIVATION_CLASS + +ActivationStyle(linear,Activation_linear) + +#else + +#ifndef LMP_RANN_ACTIVATION_LINEAR_H +#define LMP_RANN_ACTIVATION_LINEAR_H + +#include "rann_activation.h" + +namespace LAMMPS_NS { + namespace RANN { + + class Activation_linear : public Activation { + public: + Activation_linear(class PairRANN *); + double activation_function(double); + double dactivation_function(double); + double ddactivation_function(double); + }; + + Activation_linear::Activation_linear(PairRANN *_pair) : Activation(_pair) { + empty = false; + style = "linear"; + } + + double Activation_linear::activation_function(double A) + { + return A; + } + + double Activation_linear::dactivation_function(double A) + { + return 1.0; + } + + double Activation_linear::ddactivation_function(double) { + return 0.0; + } + + + } +} + +#endif +#endif /* ACTIVATION_LINEAR_H_ */ diff --git a/src/USER-RANN/rann_activation_sig_i.h b/src/USER-RANN/rann_activation_sig_i.h new file mode 100644 index 0000000000..9ca9c55d3d --- /dev/null +++ b/src/USER-RANN/rann_activation_sig_i.h @@ -0,0 +1,77 @@ +/* -*- 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. +------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu + ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” + +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ + +#ifdef ACTIVATION_CLASS + +ActivationStyle(sigI,Activation_sigI) + +#else + +#ifndef LMP_RANN_ACTIVATION_SIGI_H +#define LMP_RANN_ACTIVATION_SIGI_H + +#include "rann_activation.h" + +namespace LAMMPS_NS { + namespace RANN { + + class Activation_sigI : public Activation { + public: + Activation_sigI(class PairRANN *); + double activation_function(double); + double dactivation_function(double); + double ddactivation_function(double); + }; + + Activation_sigI::Activation_sigI(PairRANN *_pair) : Activation(_pair) { + empty = false; + style = "sigI"; + } + + double Activation_sigI::activation_function(double in) { + if (in>34)return in; + return 0.1*in + 0.9*log(exp(in) + 1); + } + + double Activation_sigI::dactivation_function(double in) { + if (in>34)return 1; + return 0.1 + 0.9/(exp(in)+1)*exp(in); + } + + double Activation_sigI::ddactivation_function(double in) { + if (in>34)return 0; + return 0.9*exp(in)/(exp(in)+1)/(exp(in)+1);; + } + + } +} + +#endif +#endif /* ACTIVATION_SIGI_H_ */ diff --git a/src/USER-RANN/rann_fingerprint.cpp b/src/USER-RANN/rann_fingerprint.cpp new file mode 100644 index 0000000000..f0bf62ed62 --- /dev/null +++ b/src/USER-RANN/rann_fingerprint.cpp @@ -0,0 +1,116 @@ +/* -*- 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. +------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu + ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” + +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ + +#include "rann_fingerprint.h" + +using namespace LAMMPS_NS::RANN; + +Fingerprint::Fingerprint(PairRANN *_pair) +{ + spin = false; + screen = false; + empty = true; + fullydefined = false; + n_body_type = 0; + style = "empty"; + pair = _pair; +} + +Fingerprint::~Fingerprint() { + +} + +bool Fingerprint::parse_values(std::string line,std::vector line1) { + return false; +} + +void Fingerprint::init(int *i,int id) { + +} + +void Fingerprint::allocate() { + +} + +void Fingerprint::compute_fingerprint(double *features,double *dfeaturesx,double *dfeaturesy,double * dfeaturesz, int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl) { + +} + +void Fingerprint::compute_fingerprint(double *features,double *dfeaturesx,double *dfeaturesy,double * dfeaturesz,double *Sik, double *dSikx, double*dSiky, double *dSikz, double *dSijkx, double *dSijky, double *dSijkz, bool *Bij, int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl) { + +} + +void Fingerprint::compute_fingerprint(double *features,double *dfeaturesx,double *dfeaturesy,double * dfeaturesz,double *sx, double *sy, double *sz, int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl) { + +} + +void Fingerprint::compute_fingerprint(double *features,double *dfeaturesx,double *dfeaturesy,double * dfeaturesz,double *sx, double *sy, double *sz, double *Sik, double *dSikx, double*dSiky, double *dSikz, double *dSijkx, double *dSijky, double *dSijkz, bool *Bij, int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl) { + +} + +void Fingerprint::write_values(FILE *fid) { + +} + +int Fingerprint::get_length() { + return 0; +} + +//Smooth cutoff, goes from 1 to zero over the interval rc-dr to rc. Same as MEAM uses. Used by generateradialtable and generatexpcuttable. +double Fingerprint::cutofffunction(double r,double rc, double dr) { + double out; + if (r < (rc -dr))out=1; + else if (r>rc)out=0; + else { + out = 1-(rc-r)/dr; + out *= out; + out *= out; + out = 1-out; + out *= out; + } + return out; +} + +void Fingerprint::generate_rinvssqrttable() { + int buf = 5; + int m; + double r1; + double cutmax = pair->cutmax; + int res = pair->res; + rinvsqrttable = new double[res+buf]; + for (m=0;m<(res+buf);m++) { + r1 = cutmax*cutmax*(double)(m)/(double)(res); + rinvsqrttable[m] = 1/sqrt(r1); + } +} + + + + diff --git a/src/USER-RANN/rann_fingerprint.h b/src/USER-RANN/rann_fingerprint.h new file mode 100644 index 0000000000..8b777ce398 --- /dev/null +++ b/src/USER-RANN/rann_fingerprint.h @@ -0,0 +1,72 @@ +/* -*- 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. +------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu + ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” + +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + +----------------*/ + +#ifndef LMP_RANN_FINGERPRINT_H +#define LMP_RANN_FINGERPRINT_H + +#include "pair_rann.h" + +namespace LAMMPS_NS { + namespace RANN { + class Fingerprint { + public: + Fingerprint(PairRANN *); + virtual ~Fingerprint(); + virtual bool parse_values(std::string,std::vector); + virtual void write_values(FILE *); + virtual void init(int*,int); + virtual void allocate(); + void init_screen(int); + virtual void compute_fingerprint(double*,double*,double*,double*,int,int,double*,double*,double*,int*,int,int*);//no screen,no spin + virtual void compute_fingerprint(double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,bool*,int,int,double*,double*,double*,int*,int,int*);//screen + virtual void compute_fingerprint(double*,double*,double*,double*,double*,double*,double*,int,int,double*,double*,double*,int*,int,int*);//spin + virtual void compute_fingerprint(double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,bool*,int,int,double*,double*,double*,int*,int,int*);//spin,screen + virtual int get_length(); + virtual double cutofffunction(double,double, double); + virtual void generate_rinvssqrttable(); + bool spin; + bool screen; + int n_body_type;//i-j vs. i-j-k vs. i-j-k-l, etc. + bool empty; + bool fullydefined; + int startingneuron; + int id;//based on ordering of fingerprints listed for i-j in potential file + const char *style; + int* atomtypes; + double *rinvsqrttable; + double rc; + PairRANN *pair; + }; + } +} + + +#endif /* RANN_FINGERPRINT_H_ */ diff --git a/src/USER-RANN/rann_fingerprint_bond.cpp b/src/USER-RANN/rann_fingerprint_bond.cpp new file mode 100644 index 0000000000..672cea718d --- /dev/null +++ b/src/USER-RANN/rann_fingerprint_bond.cpp @@ -0,0 +1,808 @@ +/* -*- 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. +------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu + ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” + +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ + +#include "rann_fingerprint_bond.h" + + +using namespace LAMMPS_NS::RANN; + +Fingerprint_bond::Fingerprint_bond(PairRANN *_pair) : Fingerprint(_pair) +{ + n_body_type = 3; + dr = 0; + re = 0; + rc = 0; + alpha_k = new double [1]; + alpha_k[0] = -1; + kmax = 0; + mlength = 0; + id = -1; + style = "bond"; + atomtypes = new int [n_body_type]; + empty = true; + _pair->allscreen = false; +} + +Fingerprint_bond::~Fingerprint_bond() { + delete [] alpha_k; + delete [] atomtypes; + delete [] expcuttable; + delete [] dfctable; + for (int i=0;i<(mlength*(mlength+1))>>1;i++) { + delete [] coeff[i]; + delete [] coeffx[i]; + delete [] coeffy[i]; + delete [] coeffz[i]; + delete [] Mf[i]; + } + delete [] coeff; + delete [] coeffx; + delete [] coeffy; + delete [] coeffz; + delete [] Mf; + delete [] rinvsqrttable; +} + +bool Fingerprint_bond::parse_values(std::string constant,std::vector line1) { + int nwords,l; + nwords=line1.size(); + if (constant.compare("re")==0) { + re = strtod(line1[0].c_str(),NULL); + } + else if (constant.compare("rc")==0) { + rc = strtod(line1[0].c_str(),NULL); + } + else if (constant.compare("alphak")==0) { + delete [] alpha_k; + alpha_k = new double [nwords]; + for (l=0;lerrorf(FLERR,"Undefined value for bond power"); + if (re!=0.0 && rc!=0.0 && alpha_k[0]!=-1 && dr!=0.0 && mlength!=0 && kmax!=0)return true; + return false; +} + +void Fingerprint_bond::write_values(FILE *fid) { + int i; + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:re:\n",style,id); + fprintf(fid,"%f\n",re); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:rc:\n",style,id); + fprintf(fid,"%f\n",rc); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:alphak:\n",style,id); + for (i=0;ielementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:dr:\n",style,id); + fprintf(fid,"%f\n",dr); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:k:\n",style,id); + fprintf(fid,"%d\n",kmax); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:m:\n",style,id); + fprintf(fid,"%d\n",mlength); +} + +void Fingerprint_bond::init(int *i,int _id) { + for (int j=0;jres; + double cutmax = pair->cutmax; + expcuttable = new double [(res+buf)*(kmax)]; + dfctable = new double [res+buf]; + for (m=0;m<(res+buf);m++) { + r1 = cutmax*cutmax*(double)(m)/(double)(res); + for (n=0;n<(kmax);n++) { + expcuttable[n+m*(kmax)] = exp(-alpha_k[n]/re*sqrt(r1))*cutofffunction(sqrt(r1),rc,dr); + } + if (sqrt(r1)>=rc || sqrt(r1) <= (rc-dr)) { + dfctable[m]=0; + } + else{ + dfctable[m]=-8*pow(1-(rc-sqrt(r1))/dr,3)/dr/(1-pow(1-(rc-sqrt(r1))/dr,4)); + } + } +} + +//Generate table of complex functions for quick reference during compute. Used by do3bodyfeatureset_singleneighborloop. +void Fingerprint_bond::generate_coefficients() { //calculates multinomial coefficient for each term + int p,mb,mc; + int n,p1,i1; + mb = mlength; + mc=(mb*(mb+1))>>1; + coeff = new int *[mc]; + coeffx = new int *[mc]; + coeffy = new int *[mc]; + coeffz = new int *[mc]; + for (p=0;pfactorial(p)/pair->factorial(coeffx[p1][p])/pair->factorial(coeffy[p1][p])/pair->factorial(coeffz[p1][p]); + } + } +} + + +//Called by getproperties. Gets 3-body features and dfeatures +void Fingerprint_bond::compute_fingerprint(double * features,double * dfeaturesx,double *dfeaturesy,double *dfeaturesz, int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl) { + int i; + int *ilist,*numneigh; + PairRANN::Simulation *sim = &pair->sims[sid]; + ilist = sim->ilist; + numneigh = sim->numneigh; + i = ilist[ii]; + //select the more efficient algorithm for this particular potential and environment. + if (jnum*2>(mlength+1)*mlength*20) { + do3bodyfeatureset_singleneighborloop(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,sid,xn,yn,zn,tn,jnum,jl); + } + else{ + do3bodyfeatureset_doubleneighborloop(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,sid,xn,yn,zn,tn,jnum,jl); + + } +} + +//Called by do3bodyfeatureset. Algorithm for high neighbor numbers and small series of bond angle powers +void Fingerprint_bond::do3bodyfeatureset_singleneighborloop(double * features,double * dfeaturesx,double *dfeaturesy,double *dfeaturesz,int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl) { + int i,j,jj,itype,jtype,kk,m,n,mcount,a,a1,a2,ai; + double xtmp,ytmp,ztmp,delx,dely,delz,rsq; + int *ilist,*jlist,*numneigh,**firstneigh; + int count=0; + PairRANN::Simulation *sim = &pair->sims[sid]; + int *type = sim->type; + double cutmax = pair->cutmax; + int res = pair->res; + double cutinv2 = 1/cutmax/cutmax; + ilist = sim->ilist; + int nelements=pair->nelements; + i = ilist[ii]; + itype = pair->map[type[i]]; + int f = pair->net[itype].dimensions[0]; + double expr[jnum][kmax+12]; + int p = kmax; + int countmb=((mlength)*(mlength+1))>>1; + // calculate interpolation expr, rinvs and dfc, for each neighbor + for (jj = 0; jj < jnum; jj++) { + jtype = tn[jj]; + if (atomtypes[1] != nelements && atomtypes[1] != jtype && atomtypes[2] != nelements && atomtypes[2] != jtype) { + expr[jj][0]=0; + continue; + } + delx = xn[jj]; + dely = yn[jj]; + delz = zn[jj]; + rsq = delx*delx + dely*dely + delz*delz; + if (rsq>rc*rc) { + expr[jj][0]=0; + continue; + } + double r1 = (rsq*((double)res)*cutinv2); + int m1 = (int)r1; + r1 = r1-trunc(r1); + double *p0 = &expcuttable[(m1-1)*kmax]; + double *p1 = &expcuttable[m1*kmax]; + double *p2 = &expcuttable[(m1+1)*kmax]; + double *p3 = &expcuttable[(m1+2)*kmax]; + for (kk=0;kksims[sid]; + double **x = sim->x; + int *type = sim->type; + int nelements = pair->nelements; + int res = pair->res; + double cutmax = pair->cutmax; + double cutinv2 = 1/cutmax/cutmax; + ilist = sim->ilist; + i = ilist[ii]; + itype = pair->map[type[i]]; + int f = pair->net[itype].dimensions[0]; + double expr[jnum][kmax]; + double y[jnum][3]; + double ri[jnum]; + double dfc[jnum]; + int kb = kmax; + int mb = mlength; + double c41[kmax]; + double c51[kmax]; + double c61[kmax]; + double ct[kmax]; + for (jj = 0; jj < jnum; jj++) { + jtype = tn[jj]; + if (jtypes != nelements && jtypes != jtype && ktypes != nelements && ktypes != jtype) { + expr[jj][0]=0; + continue; + } + delx = xn[jj]; + dely = yn[jj]; + delz = zn[jj]; + rsq = delx*delx + dely*dely + delz*delz; + if (rsq>rc*rc) { + expr[jj][0]=0; + continue; + } + double r1 = (rsq*((double)res)*cutinv2); + int m1 = (int)r1; + if (!(m1>=1 && m1 <= res))pair->errorf(FLERR,"Neighbor list is invalid.");//usually results from nan somewhere. + r1 = r1-trunc(r1); + double *p0 = &expcuttable[(m1-1)*kmax]; + double *p1 = &expcuttable[m1*kmax]; + double *p2 = &expcuttable[(m1+1)*kmax]; + double *p3 = &expcuttable[(m1+2)*kmax]; + for (kk=0;kk); + void write_values(FILE *); + void init(int*,int); + void allocate(); + void compute_fingerprint(double*,double*,double*,double*,int,int,double *,double *,double *,int *,int,int *); + void do3bodyfeatureset_doubleneighborloop(double *,double *,double *,double *,int,int,double *,double *,double *,int *,int,int *); + void do3bodyfeatureset_singleneighborloop(double *,double *,double *,double *,int,int,double *,double *,double *,int *,int,int *); + void generate_exp_cut_table(); + void generate_coefficients(); + int get_length(); + + double *expcuttable; + double *dfctable; + double dr; + double *alpha_k; + double re; + int **coeff; + int **coeffx; + int **coeffy; + int **coeffz; + int kmax; + int mlength; + int **Mf; + + }; + + } +} + + +#endif +#endif /* FINGERPRINT_BOND_H_ */ diff --git a/src/USER-RANN/rann_fingerprint_bondscreened.cpp b/src/USER-RANN/rann_fingerprint_bondscreened.cpp new file mode 100644 index 0000000000..5a9a9b7a4c --- /dev/null +++ b/src/USER-RANN/rann_fingerprint_bondscreened.cpp @@ -0,0 +1,762 @@ +/* -*- 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. +------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu + ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” + +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ + +#include "rann_fingerprint_bondscreened.h" + +using namespace LAMMPS_NS::RANN; + +Fingerprint_bondscreened::Fingerprint_bondscreened(PairRANN *_pair) : Fingerprint(_pair) +{ + n_body_type = 3; + dr = 0; + re = 0; + rc = 0; + alpha_k = new double [1]; + alpha_k[0] = -1; + kmax = 0; + mlength = 0; + id = -1; + style = "bondscreened"; + atomtypes = new int [n_body_type]; + empty = true; + _pair->doscreen = true; + screen = true; +} + +Fingerprint_bondscreened::~Fingerprint_bondscreened() { + delete [] alpha_k; + delete [] atomtypes; + delete [] expcuttable; + delete [] dfctable; + for (int i=0;i<(mlength*(mlength+1))>>1;i++) { + delete [] coeff[i]; + delete [] coeffx[i]; + delete [] coeffy[i]; + delete [] coeffz[i]; + delete [] Mf[i]; + } + delete [] coeff; + delete [] coeffx; + delete [] coeffy; + delete [] coeffz; + delete [] Mf; + delete [] rinvsqrttable; +} + +bool Fingerprint_bondscreened::parse_values(std::string constant,std::vector line1) { + int nwords,l; + nwords=line1.size(); + if (constant.compare("re")==0) { + re = strtod(line1[0].c_str(),NULL); + } + else if (constant.compare("rc")==0) { + rc = strtod(line1[0].c_str(),NULL); + } + else if (constant.compare("alphak")==0) { + delete [] alpha_k; + alpha_k = new double [nwords]; + for (l=0;lerrorf(FLERR,"Undefined value for bond power"); + if (re!=0.0 && rc!=0.0 && alpha_k[0]!=-1 && dr!=0.0 && mlength!=0 && kmax!=0)return true; + return false; +} + +void Fingerprint_bondscreened::write_values(FILE *fid) { + int i; + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:re:\n",style,id); + fprintf(fid,"%f\n",re); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:rc:\n",style,id); + fprintf(fid,"%f\n",rc); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:alphak:\n",style,id); + for (i=0;ielementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:dr:\n",style,id); + fprintf(fid,"%f\n",dr); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:k:\n",style,id); + fprintf(fid,"%d\n",kmax); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:m:\n",style,id); + fprintf(fid,"%d\n",mlength); +} + +void Fingerprint_bondscreened::init(int *i,int _id) { + for (int j=0;jres; + double cutmax = pair->cutmax; + expcuttable = new double [(res+buf)*(kmax)]; + dfctable = new double [res+buf]; + for (m=0;m<(res+buf);m++) { + r1 = cutmax*cutmax*(double)(m)/(double)(res); + for (n=0;n<(kmax);n++) { + expcuttable[n+m*(kmax)] = exp(-alpha_k[n]/re*sqrt(r1))*cutofffunction(sqrt(r1),rc,dr); + } + if (sqrt(r1)>=rc || sqrt(r1) <= (rc-dr)) { + dfctable[m]=0; + } + else{ + dfctable[m]=-8*pow(1-(rc-sqrt(r1))/dr,3)/dr/(1-pow(1-(rc-sqrt(r1))/dr,4)); + } + } +} + + +//Generate table of complex functions for quick reference during compute. Used by do3bodyfeatureset_singleneighborloop. +void Fingerprint_bondscreened::generate_coefficients() { //calculates multinomial coefficient for each term + int p,mb,mc; + int n,p1,i1; + mb = mlength; + mc=(mb*(mb+1))>>1; + coeff = new int *[mc]; + coeffx = new int *[mc]; + coeffy = new int *[mc]; + coeffz = new int *[mc]; + for (p=0;pfactorial(p)/pair->factorial(coeffx[p1][p])/pair->factorial(coeffy[p1][p])/pair->factorial(coeffz[p1][p]); + } + } +} + + +//Called by getproperties. Gets 3-body features and dfeatures +void Fingerprint_bondscreened::compute_fingerprint(double * features,double * dfeaturesx,double *dfeaturesy,double *dfeaturesz,double *Sik, double *dSikx, double*dSiky, double *dSikz, double *dSijkx, double *dSijky, double *dSijkz, bool *Bij, int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl) { + int i; + //select the more efficient algorithm for this particular potential and environment. + if (jnum*2>(mlength+1)*mlength*20) { + do3bodyfeatureset_singleneighborloop(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,sid,xn,yn,zn,tn,jnum,jl); + } + else{ + do3bodyfeatureset_doubleneighborloop(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,sid,xn,yn,zn,tn,jnum,jl); + + } +} + +//Called by do3bodyfeatureset. Algorithm for high neighbor numbers and small series of bond angle powers +void Fingerprint_bondscreened::do3bodyfeatureset_singleneighborloop(double * features,double * dfeaturesx,double *dfeaturesy,double *dfeaturesz,double *Sik, double *dSikx, double*dSiky, double *dSikz, double *dSijkx, double *dSijky, double *dSijkz, bool *Bij,int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl) { + int i,j,jj,itype,jtype,kk,m,n,mcount,a,a1,a2,ai; + double xtmp,ytmp,ztmp,delx,dely,delz,rsq; + int *ilist,*jlist,*numneigh,**firstneigh; + int count=0; + PairRANN::Simulation *sim = &pair->sims[sid]; + int *type = sim->type; + double cutmax = pair->cutmax; + int res = pair->res; + double cutinv2 = 1/cutmax/cutmax; + ilist = sim->ilist; + int nelements=pair->nelements; + i = ilist[ii]; + itype = pair->map[type[i]]; + int f = pair->net[itype].dimensions[0]; + double expr[jnum][kmax+12]; + int p = kmax; + int countmb=((mlength)*(mlength+1))>>1; + // calculate interpolation expr, rinvs and dfc, for each neighbor + for (jj = 0; jj < jnum; jj++) { + if (Bij[jj]==false) {continue;} + jtype = tn[jj]; + if (atomtypes[1] != nelements && atomtypes[1] != jtype && atomtypes[2] != nelements && atomtypes[2] != jtype) { + expr[jj][0]=0; + continue; + } + delx=xn[jj]; + dely=yn[jj]; + delz=zn[jj]; + rsq = delx*delx + dely*dely + delz*delz; + if (rsq>rc*rc) { + expr[jj][0]=0; + continue; + } + double r1 = (rsq*((double)res)*cutinv2); + int m1 = (int)r1; + r1 = r1-trunc(r1); + double *p0 = &expcuttable[(m1-1)*kmax]; + double *p1 = &expcuttable[m1*kmax]; + double *p2 = &expcuttable[(m1+1)*kmax]; + double *p3 = &expcuttable[(m1+2)*kmax]; + for (kk=0;kksims[sid]; + int *type = sim->type; + int nelements = pair->nelements; + int res = pair->res; + double cutmax = pair->cutmax; + double cutinv2 = 1/cutmax/cutmax; + ilist = sim->ilist; + i = ilist[ii]; + itype = pair->map[type[i]]; + int f = pair->net[itype].dimensions[0]; + double expr[jnum][kmax]; + double y[jnum][3]; + double ri[jnum]; + double dfc[jnum]; + int kb = kmax; + int mb = mlength; + double Bijk[kb][mb]; + double c41[kmax]; + double c51[kmax]; + double c61[kmax]; + double ct[kmax]; + for (jj = 0; jj < jnum; jj++) { + if (Bij[jj]==false) {continue;} + jtype = tn[jj]; + if (jtypes != nelements && jtypes != jtype && ktypes != nelements && ktypes != jtype) { + expr[jj][0]=0; + continue; + } + delx = xn[jj]; + dely = yn[jj]; + delz = zn[jj]; + rsq = delx*delx + dely*dely + delz*delz; + if (rsq>rc*rc) { + expr[jj][0]=0; + continue; + } + double r1 = (rsq*((double)res)*cutinv2); + int m1 = (int)r1; + if (!(m1>=1 && m1 <= res))pair->errorf(FLERR,"Neighbor list is invalid.");//usually results from nan somewhere. + r1 = r1-trunc(r1); + double *p0 = &expcuttable[(m1-1)*kmax]; + double *p1 = &expcuttable[m1*kmax]; + double *p2 = &expcuttable[(m1+1)*kmax]; + double *p3 = &expcuttable[(m1+2)*kmax]; + for (kk=0;kk); + void write_values(FILE *); + void init(int*,int); + void allocate(); + void compute_fingerprint(double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,bool*,int,int,double*,double*,double*,int*,int,int*); + void do3bodyfeatureset_doubleneighborloop(double *,double *,double *,double *,double*,double*,double*,double*,double*,double*,double*,bool*,int,int,double*,double*,double*,int*,int,int*); + void do3bodyfeatureset_singleneighborloop(double *,double *,double *,double *,double*,double*,double*,double*,double*,double*,double*,bool*,int,int,double*,double*,double*,int*,int,int*); + void generate_exp_cut_table(); + void generate_coefficients(); + int get_length(); + + double *expcuttable; + double *dfctable; + double dr; + double *alpha_k; + double re; + int **coeff; + int **coeffx; + int **coeffy; + int **coeffz; + int kmax; + int mlength; + int **Mf; + + }; + } + +} + + +#endif +#endif /* FINGERPRINT_BOND_H_ */ diff --git a/src/USER-RANN/rann_fingerprint_bondscreenedspin.cpp b/src/USER-RANN/rann_fingerprint_bondscreenedspin.cpp new file mode 100644 index 0000000000..f41dde883d --- /dev/null +++ b/src/USER-RANN/rann_fingerprint_bondscreenedspin.cpp @@ -0,0 +1,814 @@ +/* -*- 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. +------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu + ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” + +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ +#include "rann_fingerprint_bondscreenedspin.h" + + +using namespace LAMMPS_NS::RANN; + +Fingerprint_bondscreenedspin::Fingerprint_bondscreenedspin(PairRANN *_pair) : Fingerprint(_pair) +{ + n_body_type = 3; + dr = 0; + re = 0; + rc = 0; + alpha_k = new double [1]; + alpha_k[0] = -1; + kmax = 0; + mlength = 0; + id = -1; + style = "bondscreenedspin"; + atomtypes = new int [n_body_type]; + empty = true; + _pair->doscreen = true; + screen = true; + _pair->dospin = true; + spin = true; +} + +Fingerprint_bondscreenedspin::~Fingerprint_bondscreenedspin() { + delete [] alpha_k; + delete [] atomtypes; + delete [] expcuttable; + delete [] dfctable; + for (int i=0;i<(mlength*(mlength+1))>>1;i++) { + delete [] coeff[i]; + delete [] coeffx[i]; + delete [] coeffy[i]; + delete [] coeffz[i]; + delete [] Mf[i]; + } + delete [] coeff; + delete [] coeffx; + delete [] coeffy; + delete [] coeffz; + delete [] Mf; + delete [] rinvsqrttable; +} + +bool Fingerprint_bondscreenedspin::parse_values(std::string constant,std::vector line1) { + int nwords,l; + nwords=line1.size(); + if (constant.compare("re")==0) { + re = strtod(line1[0].c_str(),NULL); + } + else if (constant.compare("rc")==0) { + rc = strtod(line1[0].c_str(),NULL); + } + else if (constant.compare("alphak")==0) { + delete [] alpha_k; + alpha_k = new double [nwords]; + for (l=0;lerrorf(FLERR,"Undefined value for bond power"); + if (re!=0.0 && rc!=0.0 && alpha_k[0]!=-1 && dr!=0.0 && mlength!=0 && kmax!=0)return true; + return false; +} + +void Fingerprint_bondscreenedspin::write_values(FILE *fid) { + int i; + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:re:\n",style,id); + fprintf(fid,"%f\n",re); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:rc:\n",style,id); + fprintf(fid,"%f\n",rc); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:alphak:\n",style,id); + for (i=0;ielementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:dr:\n",style,id); + fprintf(fid,"%f\n",dr); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:k:\n",style,id); + fprintf(fid,"%d\n",kmax); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:m:\n",style,id); + fprintf(fid,"%d\n",mlength); +} + +void Fingerprint_bondscreenedspin::init(int *i,int _id) { + for (int j=0;jres; + double cutmax = pair->cutmax; + expcuttable = new double [(res+buf)*(kmax)]; + dfctable = new double [res+buf]; + for (m=0;m<(res+buf);m++) { + r1 = cutmax*cutmax*(double)(m)/(double)(res); + for (n=0;n<(kmax);n++) { + expcuttable[n+m*(kmax)] = exp(-alpha_k[n]/re*sqrt(r1))*cutofffunction(sqrt(r1),rc,dr); + } + if (sqrt(r1)>=rc || sqrt(r1) <= (rc-dr)) { + dfctable[m]=0; + } + else{ + dfctable[m]=-8*pow(1-(rc-sqrt(r1))/dr,3)/dr/(1-pow(1-(rc-sqrt(r1))/dr,4)); + } + } +} + + +//Generate table of complex functions for quick reference during compute. Used by do3bodyfeatureset_singleneighborloop. +void Fingerprint_bondscreenedspin::generate_coefficients() { //calculates multinomial coefficient for each term + int p,mb,mc; + int n,p1,i1; + mb = mlength; + mc=(mb*(mb+1))>>1; + coeff = new int *[mc]; + coeffx = new int *[mc]; + coeffy = new int *[mc]; + coeffz = new int *[mc]; + for (p=0;pfactorial(p)/pair->factorial(coeffx[p1][p])/pair->factorial(coeffy[p1][p])/pair->factorial(coeffz[p1][p]); + } + } +} + + +//Called by getproperties. Gets 3-body features and dfeatures +void Fingerprint_bondscreenedspin::compute_fingerprint(double * features,double * dfeaturesx,double *dfeaturesy,double *dfeaturesz, double *dspinx, double *dspiny, double *dspinz,double *Sik, double *dSikx, double*dSiky, double *dSikz, double *dSijkx, double *dSijky, double *dSijkz, bool *Bij, int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl) { + int i; + //select the more efficient algorithm for this particular potential and environment. + if (jnum*2>(mlength+1)*mlength*20) { + do3bodyfeatureset_singleneighborloop(features,dfeaturesx,dfeaturesy,dfeaturesz,dspinx,dspiny,dspinz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,sid,xn,yn,zn,tn,jnum,jl); + } + else{ + do3bodyfeatureset_doubleneighborloop(features,dfeaturesx,dfeaturesy,dfeaturesz,dspinx,dspiny,dspinz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,sid,xn,yn,zn,tn,jnum,jl); + + } +} + +//Called by do3bodyfeatureset. Algorithm for high neighbor numbers and small series of bond angle powers +void Fingerprint_bondscreenedspin::do3bodyfeatureset_singleneighborloop(double * features,double * dfeaturesx,double *dfeaturesy,double *dfeaturesz, double *dspinx, double *dspiny, double *dspinz,double *Sik, double *dSikx, double*dSiky, double *dSikz, double *dSijkx, double *dSijky, double *dSijkz, bool *Bij, int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl) { + int i,j,jj,itype,jtype,kk,m,n,mcount,a,a1,a2,ai; + double xtmp,ytmp,ztmp,delx,dely,delz,rsq; + int *ilist,*jlist,*numneigh,**firstneigh; + int count=0; + PairRANN::Simulation *sim = &pair->sims[sid]; + int *type = sim->type; + double cutmax = pair->cutmax; + int res = pair->res; + double cutinv2 = 1/cutmax/cutmax; + ilist = sim->ilist; + int nelements=pair->nelements; + i = ilist[ii]; + itype = pair->map[type[i]]; + int f = pair->net[itype].dimensions[0]; + double expr[jnum][kmax+12]; + int p = kmax; + int countmb=((mlength)*(mlength+1))>>1; + double *si = sim->s[i]; + // calculate interpolation expr, rinvs and dfc, for each neighbor + for (jj = 0; jj < jnum; jj++) { + if (Bij[jj]==false) {continue;} + jtype = tn[jj]; + if (atomtypes[1] != nelements && atomtypes[1] != jtype && atomtypes[2] != nelements && atomtypes[2] != jtype) { + expr[jj][0]=0; + continue; + } + delx=xn[jj]; + dely=yn[jj]; + delz=zn[jj]; + rsq = delx*delx + dely*dely + delz*delz; + if (rsq>rc*rc) { + expr[jj][0]=0; + continue; + } + double r1 = (rsq*((double)res)*cutinv2); + int m1 = (int)r1; + r1 = r1-trunc(r1); + double *p0 = &expcuttable[(m1-1)*kmax]; + double *p1 = &expcuttable[m1*kmax]; + double *p2 = &expcuttable[(m1+1)*kmax]; + double *p3 = &expcuttable[(m1+2)*kmax]; + for (kk=0;kks[j]; + double sp = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; + double yprod = expr[jj][ai]; + double *y4 = &expr[jj][p]; + for (a2=0;a2s[j]; + double sp = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; + double yprod = expr[jj][ai]; + double *y4 = &expr[jj][p]; + for (a2=0;a2s[j]; + double sp = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; + double *y3 = &expr[jj][p+3]; + double *y4 = &expr[jj][p]; + ai = n; + yprod = expr[jj][ai]; + for (a2=0;a2s[j]; + double sp = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; + double *y3 = &expr[jj][p+3]; + double *y4 = &expr[jj][p]; + ai = n; + yprod = expr[jj][ai]; + for (a2=0;a2s[j]; + double sp = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; + double *y3 = &expr[jj][p+3]; + double *y4 = &expr[jj][p]; + ai = n; + yprod = expr[jj][ai]; + for (a2=0;a2sims[sid]; + int *type = sim->type; + int nelements = pair->nelements; + int res = pair->res; + double cutmax = pair->cutmax; + double cutinv2 = 1/cutmax/cutmax; + ilist = sim->ilist; + i = ilist[ii]; + itype = pair->map[type[i]]; + int f = pair->net[itype].dimensions[0]; + double expr[jnum][kmax]; + double y[jnum][3]; + double ri[jnum]; + double dfc[jnum]; + int kb = kmax; + int mb = mlength; + double Bijk[kb][mb]; + double c41[kmax]; + double c51[kmax]; + double c61[kmax]; + double ct[kmax]; + double *si = sim->s[i]; + for (jj = 0; jj < jnum; jj++) { + if (Bij[jj]==false) {continue;} + jtype = tn[jj]; + if (jtypes != nelements && jtypes != jtype && ktypes != nelements && ktypes != jtype) { + expr[jj][0]=0; + continue; + } + delx = xn[jj]; + dely = yn[jj]; + delz = zn[jj]; + rsq = delx*delx + dely*dely + delz*delz; + if (rsq>rc*rc) { + expr[jj][0]=0; + continue; + } + double r1 = (rsq*((double)res)*cutinv2); + int m1 = (int)r1; + if (!(m1>=1 && m1 <= res))pair->errorf(FLERR,"Neighbor list is invalid.");//usually results from nan somewhere. + r1 = r1-trunc(r1); + double *p0 = &expcuttable[(m1-1)*kmax]; + double *p1 = &expcuttable[m1*kmax]; + double *p2 = &expcuttable[(m1+1)*kmax]; + double *p3 = &expcuttable[(m1+2)*kmax]; + for (kk=0;kks[j]; + double spj = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; + for (n = 0;ns[j]; + double spk = si[0]*sk[0]+si[1]*sk[1]+si[2]*sk[2]; + count = startingneuron; + double dot = (y[jj][0]*y[kk][0]+y[jj][1]*y[kk][1]+y[jj][2]*y[kk][2]); + double c1 = ri[jj]*(y[kk][0]-dot*y[jj][0]); + double c2 = ri[jj]*(y[kk][1]-dot*y[jj][1]); + double c3 = ri[jj]*(y[kk][2]-dot*y[jj][2]); + double c10 = ri[kk]*(y[jj][0]-dot*y[kk][0]); + double c11 = ri[kk]*(y[jj][1]-dot*y[kk][1]); + double c12 = ri[kk]*(y[jj][2]-dot*y[kk][2]); + for (n=0;n); + void write_values(FILE *); + void init(int*,int); + void allocate(); + void compute_fingerprint(double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,bool*,int,int,double*,double*,double*,int*,int,int*); + void do3bodyfeatureset_doubleneighborloop(double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,bool*,int,int,double*,double*,double*,int*,int,int *); + void do3bodyfeatureset_singleneighborloop(double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,bool*,int,int,double*,double*,double*,int*,int,int*); + void generate_exp_cut_table(); + void generate_coefficients(); + int get_length(); + + double *expcuttable; + double *dfctable; + double dr; + double *alpha_k; + double re; + int **coeff; + int **coeffx; + int **coeffy; + int **coeffz; + int kmax; + int mlength; + int **Mf; + + }; + + } +} + + +#endif +#endif /* FINGERPRINT_BOND_H_ */ diff --git a/src/USER-RANN/rann_fingerprint_bondspin.cpp b/src/USER-RANN/rann_fingerprint_bondspin.cpp new file mode 100644 index 0000000000..6aadbada86 --- /dev/null +++ b/src/USER-RANN/rann_fingerprint_bondspin.cpp @@ -0,0 +1,887 @@ +/* -*- 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. +------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu + ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” + +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ +#include "rann_fingerprint_bondspin.h" + + +using namespace LAMMPS_NS::RANN; + +Fingerprint_bondspin::Fingerprint_bondspin(PairRANN *_pair) : Fingerprint(_pair) +{ + n_body_type = 3; + dr = 0; + re = 0; + rc = 0; + alpha_k = new double [1]; + alpha_k[0] = -1; + kmax = 0; + mlength = 0; + id = -1; + style = "bondspin"; + atomtypes = new int [n_body_type]; + empty = true; + _pair->allscreen = false; + _pair->dospin = true; + spin = true; +} + +Fingerprint_bondspin::~Fingerprint_bondspin() { + delete [] alpha_k; + delete [] atomtypes; + delete [] expcuttable; + delete [] dfctable; + for (int i=0;i<(mlength*(mlength+1))>>1;i++) { + delete [] coeff[i]; + delete [] coeffx[i]; + delete [] coeffy[i]; + delete [] coeffz[i]; + delete [] Mf[i]; + } + delete [] coeff; + delete [] coeffx; + delete [] coeffy; + delete [] coeffz; + delete [] Mf; + delete [] rinvsqrttable; +} + +bool Fingerprint_bondspin::parse_values(std::string constant,std::vector line1) { + int nwords,l; + nwords=line1.size(); + if (constant.compare("re")==0) { + re = strtod(line1[0].c_str(),NULL); + } + else if (constant.compare("rc")==0) { + rc = strtod(line1[0].c_str(),NULL); + } + else if (constant.compare("alphak")==0) { + delete [] alpha_k; + alpha_k = new double [nwords]; + for (l=0;lerrorf(FLERR,"Undefined value for bond power"); + if (re!=0.0 && rc!=0.0 && alpha_k[0]!=-1 && dr!=0.0 && mlength!=0 && kmax!=0)return true; + return false; +} + +void Fingerprint_bondspin::write_values(FILE *fid) { + int i; + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:re:\n",style,id); + fprintf(fid,"%f\n",re); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:rc:\n",style,id); + fprintf(fid,"%f\n",rc); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:alphak:\n",style,id); + for (i=0;ielementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:dr:\n",style,id); + fprintf(fid,"%f\n",dr); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:k:\n",style,id); + fprintf(fid,"%d\n",kmax); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:m:\n",style,id); + fprintf(fid,"%d\n",mlength); +} + +void Fingerprint_bondspin::init(int *i,int _id) { + for (int j=0;jres; + double cutmax = pair->cutmax; + expcuttable = new double [(res+buf)*(kmax)]; + dfctable = new double [res+buf]; + for (m=0;m<(res+buf);m++) { + r1 = cutmax*cutmax*(double)(m)/(double)(res); + for (n=0;n<(kmax);n++) { + expcuttable[n+m*(kmax)] = exp(-alpha_k[n]/re*sqrt(r1))*cutofffunction(sqrt(r1),rc,dr); + } + if (sqrt(r1)>=rc || sqrt(r1) <= (rc-dr)) { + dfctable[m]=0; + } + else{ + dfctable[m]=-8*pow(1-(rc-sqrt(r1))/dr,3)/dr/(1-pow(1-(rc-sqrt(r1))/dr,4)); + } + } +} + +//Generate table of complex functions for quick reference during compute. Used by do3bodyfeatureset_singleneighborloop. +void Fingerprint_bondspin::generate_coefficients() { //calculates multinomial coefficient for each term + int p,mb,mc; + int n,p1,i1; + mb = mlength; + mc=(mb*(mb+1))>>1; + coeff = new int *[mc]; + coeffx = new int *[mc]; + coeffy = new int *[mc]; + coeffz = new int *[mc]; + for (p=0;pfactorial(p)/pair->factorial(coeffx[p1][p])/pair->factorial(coeffy[p1][p])/pair->factorial(coeffz[p1][p]); + } + } +} + + +//Called by getproperties. Gets 3-body features and dfeatures +void Fingerprint_bondspin::compute_fingerprint(double * features,double * dfeaturesx,double *dfeaturesy,double *dfeaturesz,double * dspinx,double *dspiny,double *dspinz,int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl) { + int i; + int *ilist,*numneigh; + PairRANN::Simulation *sim = &pair->sims[sid]; + ilist = sim->ilist; + numneigh = sim->numneigh; + i = ilist[ii]; + //select the more efficient algorithm for this particular potential and environment. + if (jnum*2>(mlength+1)*mlength*20) { + do3bodyfeatureset_singleneighborloop(features,dfeaturesx,dfeaturesy,dfeaturesz,dspinx,dspiny,dspinz,ii,sid,xn,yn,zn,tn,jnum,jl); + } + else{ + do3bodyfeatureset_doubleneighborloop(features,dfeaturesx,dfeaturesy,dfeaturesz,dspinx,dspiny,dspinz,ii,sid,xn,yn,zn,tn,jnum,jl); + } +} + +//Called by do3bodyfeatureset. Algorithm for high neighbor numbers and small series of bond angle powers +void Fingerprint_bondspin::do3bodyfeatureset_singleneighborloop(double * features,double * dfeaturesx,double *dfeaturesy,double *dfeaturesz,double * dspinx,double *dspiny,double *dspinz,int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl) { + int i,j,jj,itype,jtype,kk,m,n,mcount,a,a1,a2,ai; + double xtmp,ytmp,ztmp,delx,dely,delz,rsq; + int *ilist,*jlist,*numneigh,**firstneigh; + int count=0; + PairRANN::Simulation *sim = &pair->sims[sid]; + int *type = sim->type; + double cutmax = pair->cutmax; + int res = pair->res; + double cutinv2 = 1/cutmax/cutmax; + ilist = sim->ilist; + int nelements=pair->nelements; + i = ilist[ii]; + itype = pair->map[type[i]]; + int f = pair->net[itype].dimensions[0]; + double expr[jnum][kmax+12]; + int p = kmax; + int countmb=((mlength)*(mlength+1))>>1; + double *si = sim->s[i]; + // calculate interpolation expr, rinvs and dfc, for each neighbor + for (jj = 0; jj < jnum; jj++) { + jtype = tn[jj]; + if (atomtypes[1] != nelements && atomtypes[1] != jtype && atomtypes[2] != nelements && atomtypes[2] != jtype) { + expr[jj][0]=0; + continue; + } + delx = xn[jj]; + dely = yn[jj]; + delz = zn[jj]; + rsq = delx*delx + dely*dely + delz*delz; + if (rsq>rc*rc) { + expr[jj][0]=0; + continue; + } + double r1 = (rsq*((double)res)*cutinv2); + int m1 = (int)r1; + r1 = r1-trunc(r1); + double *p0 = &expcuttable[(m1-1)*kmax]; + double *p1 = &expcuttable[m1*kmax]; + double *p2 = &expcuttable[(m1+1)*kmax]; + double *p3 = &expcuttable[(m1+2)*kmax]; + for (kk=0;kks[j]; + double sp = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; + double yprod = expr[jj][ai]; + double *y4 = &expr[jj][p]; + for (a2=0;a2s[j]; + double sp = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; + double yprod = expr[jj][ai]; + double *y4 = &expr[jj][p]; + for (a2=0;a2s[j]; + double sp = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; + double *y3 = &expr[jj][p+3]; + double *y4 = &expr[jj][p]; + ai = n; + yprod = expr[jj][ai]; + for (a2=0;a2s[j]; + double sp = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; + double *y3 = &expr[jj][p+3]; + double *y4 = &expr[jj][p]; + ai = n; + yprod = expr[jj][ai]; + for (a2=0;a2s[j]; + double sp = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; + double *y3 = &expr[jj][p+3]; + double *y4 = &expr[jj][p]; + ai = n; + yprod = expr[jj][ai]; + for (a2=0;a2sims[sid]; + double **x = sim->x; + int *type = sim->type; + int nelements = pair->nelements; + int res = pair->res; + double cutmax = pair->cutmax; + double cutinv2 = 1/cutmax/cutmax; + ilist = sim->ilist; + i = ilist[ii]; + itype = pair->map[type[i]]; + int f = pair->net[itype].dimensions[0]; + double expr[jnum][kmax]; + double y[jnum][3]; + double ri[jnum]; + double dfc[jnum]; + int kb = kmax; + int mb = mlength; + double c41[kmax]; + double c51[kmax]; + double c61[kmax]; + double ct[kmax]; + double *si = sim->s[i]; + for (jj = 0; jj < jnum; jj++) { + jtype = tn[jj]; + if (jtypes != nelements && jtypes != jtype && ktypes != nelements && ktypes != jtype) { + expr[jj][0]=0; + continue; + } + delx = xn[jj]; + dely = yn[jj]; + delz = zn[jj]; + rsq = delx*delx + dely*dely + delz*delz; + if (rsq>rc*rc) { + expr[jj][0]=0; + continue; + } + double r1 = (rsq*((double)res)*cutinv2); + int m1 = (int)r1; + if (!(m1>=1 && m1 <= res))pair->errorf(FLERR,"Neighbor list is invalid.");//usually results from nan somewhere. + r1 = r1-trunc(r1); + double *p0 = &expcuttable[(m1-1)*kmax]; + double *p1 = &expcuttable[m1*kmax]; + double *p2 = &expcuttable[(m1+1)*kmax]; + double *p3 = &expcuttable[(m1+2)*kmax]; + for (kk=0;kks[j]; + double spj = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; + for (n = 0;ns[j]; + double spk = si[0]*sk[0]+si[1]*sk[1]+si[2]*sk[2]; + count = startingneuron; + double dot = (y[jj][0]*y[kk][0]+y[jj][1]*y[kk][1]+y[jj][2]*y[kk][2]); + double c1 = 2*ri[jj]*(y[kk][0]-dot*y[jj][0]); + double c2 = 2*ri[jj]*(y[kk][1]-dot*y[jj][1]); + double c3 = 2*ri[jj]*(y[kk][2]-dot*y[jj][2]); + double c10 = 2*ri[kk]*(y[jj][0]-dot*y[kk][0]); + double c11 = 2*ri[kk]*(y[jj][1]-dot*y[kk][1]); + double c12 = 2*ri[kk]*(y[jj][2]-dot*y[kk][2]); + for (n=0;ns[j]; + double spk = si[0]*sk[0]+si[1]*sk[1]+si[2]*sk[2]; + count = startingneuron; + double dot = (y[jj][0]*y[kk][0]+y[jj][1]*y[kk][1]+y[jj][2]*y[kk][2]); + double c1 = ri[jj]*(y[kk][0]-dot*y[jj][0]); + double c2 = ri[jj]*(y[kk][1]-dot*y[jj][1]); + double c3 = ri[jj]*(y[kk][2]-dot*y[jj][2]); + double c10 = ri[kk]*(y[jj][0]-dot*y[kk][0]); + double c11 = ri[kk]*(y[jj][1]-dot*y[kk][1]); + double c12 = ri[kk]*(y[jj][2]-dot*y[kk][2]); + for (n=0;n); + void write_values(FILE *); + void init(int*,int); + void allocate(); + virtual void compute_fingerprint(double*,double*,double*,double*,double*,double*,double*,int,int,double*,double*,double*,int*,int,int*);//spin + void do3bodyfeatureset_doubleneighborloop(double*,double*,double*,double*,double*,double*,double*,int,int,double*,double*,double*,int*,int,int*); + void do3bodyfeatureset_singleneighborloop(double*,double*,double*,double*,double*,double*,double*,int,int,double*,double*,double*,int*,int,int*); + void generate_exp_cut_table(); + void generate_coefficients(); + int get_length(); + + double *expcuttable; + double *dfctable; + double dr; + double *alpha_k; + double re; + int **coeff; + int **coeffx; + int **coeffy; + int **coeffz; + int kmax; + int mlength; + int **Mf; + + }; + + } +} + + +#endif +#endif /* FINGERPRINT_BOND_H_ */ diff --git a/src/USER-RANN/rann_fingerprint_radial.cpp b/src/USER-RANN/rann_fingerprint_radial.cpp new file mode 100644 index 0000000000..5df13aa094 --- /dev/null +++ b/src/USER-RANN/rann_fingerprint_radial.cpp @@ -0,0 +1,239 @@ +/* -*- 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. +------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu + ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” + +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ + +#include "rann_fingerprint_radial.h" + + + +using namespace LAMMPS_NS::RANN; + +Fingerprint_radial::Fingerprint_radial(PairRANN *_pair) : Fingerprint(_pair) +{ + n_body_type = 2; + dr = 0; + re = 0; + rc = 0; + alpha = new double [1]; + alpha[0] = -1; + nmax = 0; + omin = 0; + id = -1; + style = "radial"; + atomtypes = new int [n_body_type]; + empty = true; + fullydefined = false; + _pair->allscreen = false; +} + +Fingerprint_radial::~Fingerprint_radial() +{ + delete [] atomtypes; + delete [] radialtable; + delete [] alpha; + delete [] dfctable; + delete [] rinvsqrttable; +} + +bool Fingerprint_radial::parse_values(std::string constant,std::vector line1) { + int l; + int nwords=line1.size(); + if (constant.compare("re")==0) { + re = strtod(line1[0].c_str(),NULL); + } + else if (constant.compare("rc")==0) { + rc = strtod(line1[0].c_str(),NULL); + } + else if (constant.compare("alpha")==0) { + delete [] alpha; + alpha = new double [nwords]; + for (l=0;lerrorf(FLERR,"Undefined value for radial power"); + //code will run with default o=0 if o is never specified. All other values must be defined in potential file. + if (re!=0 && rc!=0 && alpha!=0 && dr!=0 && nmax!=0)return true; + return false; +} + +void Fingerprint_radial::write_values(FILE *fid) { + int i; + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:re:\n",style,id); + fprintf(fid,"%f\n",re); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:rc:\n",style,id); + fprintf(fid,"%f\n",rc); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:alpha:\n",style,id); + for (i=0;i<(nmax-omin+1);i++) { + fprintf(fid,"%f ",alpha[i]); + } + fprintf(fid,"\n"); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:dr:\n",style,id); + fprintf(fid,"%f\n",dr); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:o:\n",style,id); + fprintf(fid,"%d\n",omin); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:n:\n",style,id); + fprintf(fid,"%d\n",nmax); +} + +//called after fingerprint is fully defined and tables can be computed. +void Fingerprint_radial::allocate() +{ + int k,m; + double r1; + int buf = 5; + int res = pair->res; + double cutmax = pair->cutmax; + radialtable = new double [(res+buf)*get_length()]; + dfctable = new double [res+buf]; + for (k=0;k<(res+buf);k++) { + r1 = cutmax*cutmax*(double)(k)/(double)(res); + for (m=0;m<=(nmax-omin);m++) { + radialtable[k*(nmax-omin+1)+m]=pow(sqrt(r1)/re,m+omin)*exp(-alpha[m]*sqrt(r1)/re)*cutofffunction(sqrt(r1),rc,dr); + } + if (sqrt(r1)>=rc || sqrt(r1) <= (rc-dr)) { + dfctable[k]=0; + } + else{ + dfctable[k]=-8*pow(1-(rc-sqrt(r1))/dr,3)/dr/(1-pow(1-(rc-sqrt(r1))/dr,4)); + } + } + generate_rinvssqrttable(); +} + +//called after fingerprint is declared for i-j type, but before its parameters are read. +void Fingerprint_radial::init(int *i,int _id) +{ + empty = false; + for (int j=0;jnelements; + int res = pair->res; + int i,j,jj,itype,jtype,l; + double xtmp,ytmp,ztmp,delx,dely,delz,rsq; + int *ilist,*jlist,*numneigh,**firstneigh; + // + PairRANN::Simulation *sim = &pair->sims[sid]; + int count=0; +// double **x = sim->x; + int *type = sim->type; + ilist = sim->ilist; + double cutmax = pair->cutmax; + i = ilist[ii]; + itype = pair->map[type[i]]; + int f = pair->net[itype].dimensions[0]; + double cutinv2 = 1/cutmax/cutmax; + //loop over neighbors + for (jj = 0; jj < jnum; jj++) { + jtype =tn[jj]; + if (atomtypes[1] != nelements && atomtypes[1] != jtype)continue; + delx = xn[jj]; + dely = yn[jj]; + delz = zn[jj]; + rsq = delx*delx + dely*dely + delz*delz; + if (rsq > rc*rc)continue; + count = startingneuron; + double r1 = (rsq*((double)res)*cutinv2); + int m1 = (int)r1; + if (m1>res || m1<1) {pair->errorf(FLERR,"invalid neighbor radius!");} + if (radialtable[m1]==0) {continue;} + //cubic interpolation from tables + double *p1 = &radialtable[m1*(nmax-omin+1)]; + double *p2 = &radialtable[(m1+1)*(nmax-omin+1)]; + double *p3 = &radialtable[(m1+2)*(nmax-omin+1)]; + double *p0 = &radialtable[(m1-1)*(nmax-omin+1)]; + double *q = &dfctable[m1-1]; + double *rinvs = &rinvsqrttable[m1-1]; + r1 = r1-trunc(r1); + double dfc = q[1] + 0.5 * r1*(q[2] - q[0] + r1*(2.0*q[0] - 5.0*q[1] + 4.0*q[2] - q[3] + r1*(3.0*(q[1] - q[2]) + q[3] - q[0]))); + double ri = rinvs[1] + 0.5 * r1*(rinvs[2] - rinvs[0] + r1*(2.0*rinvs[0] - 5.0*rinvs[1] + 4.0*rinvs[2] - rinvs[3] + r1*(3.0*(rinvs[1] - rinvs[2]) + rinvs[3] - rinvs[0]))); + for (l=0;l<=(nmax-omin);l++) { + double rt = p1[l]+0.5*r1*(p2[l]-p0[l]+r1*(2.0*p0[l]-5.0*p1[l]+4.0*p2[l]-p3[l]+r1*(3.0*(p1[l]-p2[l])+p3[l]-p0[l]))); + features[count]+=rt; + rt *= (l+omin)/rsq+(-alpha[l]/re+dfc)*ri; + //update neighbor's features + dfeaturesx[jj*f+count]+=rt*delx; + dfeaturesy[jj*f+count]+=rt*dely; + dfeaturesz[jj*f+count]+=rt*delz; + //update atom's features + dfeaturesx[jnum*f+count]-=rt*delx; + dfeaturesy[jnum*f+count]-=rt*dely; + dfeaturesz[jnum*f+count]-=rt*delz; + count++; + } + } +} + +int Fingerprint_radial::get_length() +{ + return nmax-omin+1; +} diff --git a/src/USER-RANN/rann_fingerprint_radial.h b/src/USER-RANN/rann_fingerprint_radial.h new file mode 100644 index 0000000000..5f9876f493 --- /dev/null +++ b/src/USER-RANN/rann_fingerprint_radial.h @@ -0,0 +1,70 @@ + +/* -*- 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. +------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu + ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” + +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ +#ifdef FINGERPRINT_CLASS + +FingerprintStyle(radial,Fingerprint_radial) + +#else + +#ifndef LMP_RANN_FINGERPRINT_RADIAL_H +#define LMP_RANN_FINGERPRINT_RADIAL_H + +#include "rann_fingerprint.h" + +namespace LAMMPS_NS { + namespace RANN { + + class Fingerprint_radial : public Fingerprint { + public: + Fingerprint_radial(PairRANN *); + ~Fingerprint_radial(); + bool parse_values(std::string,std::vector); + void write_values(FILE *); + void init(int*,int); + void allocate(); + void compute_fingerprint(double*,double*,double*,double*,int,int,double*,double*,double*,int*,int,int*); + int get_length(); + + double *radialtable; + double *dfctable; + double dr; + double *alpha; + double re; + int nmax;//highest term + int omin;//lowest term + + }; + + } +} + +#endif +#endif /* FINGERPRINT_RADIAL_H_ */ diff --git a/src/USER-RANN/rann_fingerprint_radialscreened.cpp b/src/USER-RANN/rann_fingerprint_radialscreened.cpp new file mode 100644 index 0000000000..79333a4e3a --- /dev/null +++ b/src/USER-RANN/rann_fingerprint_radialscreened.cpp @@ -0,0 +1,253 @@ +/* -*- 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. +------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu + ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” + +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ + +#include "rann_fingerprint_radialscreened.h" + + + +using namespace LAMMPS_NS::RANN; + +Fingerprint_radialscreened::Fingerprint_radialscreened(PairRANN *_pair) : Fingerprint(_pair) +{ + n_body_type = 2; + dr = 0; + re = 0; + rc = 0; + alpha = new double [1]; + alpha[0] = -1; + nmax = 0; + omin = 0; + id = -1; + style = "radialscreened"; + atomtypes = new int [n_body_type]; + empty = true; + fullydefined = false; + _pair->doscreen = true; + screen = true; +} + +Fingerprint_radialscreened::~Fingerprint_radialscreened() +{ + delete [] atomtypes; + delete [] radialtable; + delete [] alpha; + delete [] dfctable; + delete [] rinvsqrttable; +} + +bool Fingerprint_radialscreened::parse_values(std::string constant,std::vector line1) { + int l; + int nwords=line1.size(); + if (constant.compare("re")==0) { + re = strtod(line1[0].c_str(),NULL); + } + else if (constant.compare("rc")==0) { + rc = strtod(line1[0].c_str(),NULL); + } + else if (constant.compare("alpha")==0) { + delete [] alpha; + alpha = new double [nwords]; + for (l=0;lerrorf(FLERR,"Undefined value for radial power"); + //code will run with default o=0 if o is never specified. All other values must be defined in potential file. + if (re!=0 && rc!=0 && alpha!=0 && dr!=0 && nmax!=0)return true; + return false; +} + +void Fingerprint_radialscreened::write_values(FILE *fid) { + int i; + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:re:\n",style,id); + fprintf(fid,"%f\n",re); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:rc:\n",style,id); + fprintf(fid,"%f\n",rc); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:alpha:\n",style,id); + for (i=0;i<(nmax-omin+1);i++) { + fprintf(fid,"%f ",alpha[i]); + } + fprintf(fid,"\n"); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:dr:\n",style,id); + fprintf(fid,"%f\n",dr); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:o:\n",style,id); + fprintf(fid,"%d\n",omin); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:n:\n",style,id); + fprintf(fid,"%d\n",nmax); +} + +//called after fingerprint is fully defined and tables can be computed. +void Fingerprint_radialscreened::allocate() +{ + int k,m; + double r1; + int buf = 5; + int res = pair->res; + double cutmax = pair->cutmax; + radialtable = new double [(res+buf)*get_length()]; + dfctable = new double [res+buf]; + for (k=0;k<(res+buf);k++) { + r1 = cutmax*cutmax*(double)(k)/(double)(res); + for (m=0;m<=(nmax-omin);m++) { + radialtable[k*(nmax-omin+1)+m]=pow(sqrt(r1)/re,m+omin)*exp(-alpha[m]*sqrt(r1)/re)*cutofffunction(sqrt(r1),rc,dr); + } + if (sqrt(r1)>=rc || sqrt(r1) <= (rc-dr)) { + dfctable[k]=0; + } + else{ + dfctable[k]=-8*pow(1-(rc-sqrt(r1))/dr,3)/dr/(1-pow(1-(rc-sqrt(r1))/dr,4)); + } + } + generate_rinvssqrttable(); +} + +//called after fingerprint is declared for i-j type, but before its parameters are read. +void Fingerprint_radialscreened::init(int *i,int _id) +{ + empty = false; + for (int j=0;jnelements; + int res = pair->res; + int i,j,jj,itype,jtype,l,kk; + double xtmp,ytmp,ztmp,delx,dely,delz,rsq; + int *ilist,*jlist,*numneigh,**firstneigh; + // + PairRANN::Simulation *sim = &pair->sims[sid]; + int count=0; + double **x = sim->x; + int *type = sim->type; + ilist = sim->ilist; + double cutmax = pair->cutmax; + i = ilist[ii]; + itype = pair->map[type[i]]; + int f = pair->net[itype].dimensions[0]; + double cutinv2 = 1/cutmax/cutmax; + //loop over neighbors + for (jj = 0; jj < jnum; jj++) { + if (Bij[jj]==false) {continue;} + jtype = tn[jj]; + if (atomtypes[1] != nelements && atomtypes[1] != jtype)continue; + delx = xn[jj]; + dely = yn[jj]; + delz = zn[jj]; + rsq = delx*delx + dely*dely + delz*delz; + if (rsq > rc*rc)continue; + count = startingneuron; + double r1 = (rsq*((double)res)*cutinv2); + int m1 = (int)r1; + if (m1>res || m1<1) {pair->errorf(FLERR,"invalid neighbor radius!");} + if (radialtable[m1]==0) {continue;} + //cubic interpolation from tables + double *p1 = &radialtable[m1*(nmax-omin+1)]; + double *p2 = &radialtable[(m1+1)*(nmax-omin+1)]; + double *p3 = &radialtable[(m1+2)*(nmax-omin+1)]; + double *p0 = &radialtable[(m1-1)*(nmax-omin+1)]; + double *q = &dfctable[m1-1]; + double *rinvs = &rinvsqrttable[m1-1]; + r1 = r1-trunc(r1); + double dfc = q[1] + 0.5 * r1*(q[2] - q[0] + r1*(2.0*q[0] - 5.0*q[1] + 4.0*q[2] - q[3] + r1*(3.0*(q[1] - q[2]) + q[3] - q[0]))); + double ri = rinvs[1] + 0.5 * r1*(rinvs[2] - rinvs[0] + r1*(2.0*rinvs[0] - 5.0*rinvs[1] + 4.0*rinvs[2] - rinvs[3] + r1*(3.0*(rinvs[1] - rinvs[2]) + rinvs[3] - rinvs[0]))); + for (l=0;l<=(nmax-omin);l++) { + double rt = Sik[jj]*(p1[l]+0.5*r1*(p2[l]-p0[l]+r1*(2.0*p0[l]-5.0*p1[l]+4.0*p2[l]-p3[l]+r1*(3.0*(p1[l]-p2[l])+p3[l]-p0[l])))); + features[count]+=rt; + double rt1 = rt*((l+omin)/rsq+(-alpha[l]/re+dfc)*ri); + //update neighbor's features + dfeaturesx[jj*f+count]+=rt1*delx+rt*dSikx[jj]; + dfeaturesy[jj*f+count]+=rt1*dely+rt*dSiky[jj]; + dfeaturesz[jj*f+count]+=rt1*delz+rt*dSikz[jj]; + for (kk=0;kk); + void write_values(FILE *); + void init(int*,int); + void allocate(); + void compute_fingerprint(double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,bool*,int,int,double*,double*,double*,int*,int,int*); + int get_length(); + + double *radialtable; + double *dfctable; + double dr; + double *alpha; + double re; + int nmax;//highest term + int omin;//lowest term + + }; +} + +} + +#endif + + + +#endif /* FINGERPRINT_RADIALSCREENED_H_ */ diff --git a/src/USER-RANN/rann_fingerprint_radialscreenedspin.cpp b/src/USER-RANN/rann_fingerprint_radialscreenedspin.cpp new file mode 100644 index 0000000000..f594e92077 --- /dev/null +++ b/src/USER-RANN/rann_fingerprint_radialscreenedspin.cpp @@ -0,0 +1,264 @@ +/* -*- 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. +------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu + ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” + +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ +#include "rann_fingerprint_radialscreenedspin.h" + + + +using namespace LAMMPS_NS::RANN; + +Fingerprint_radialscreenedspin::Fingerprint_radialscreenedspin(PairRANN *_pair) : Fingerprint(_pair) +{ + n_body_type = 2; + dr = 0; + re = 0; + rc = 0; + alpha = new double [1]; + alpha[0] = -1; + nmax = 0; + omin = 0; + id = -1; + style = "radialscreenedspin"; + atomtypes = new int [n_body_type]; + empty = true; + fullydefined = false; + _pair->doscreen = true; + screen = true; + _pair->dospin = true; + spin = true; +} + +Fingerprint_radialscreenedspin::~Fingerprint_radialscreenedspin() +{ + delete [] atomtypes; + delete [] radialtable; + delete [] alpha; + delete [] dfctable; + delete [] rinvsqrttable; +} + +bool Fingerprint_radialscreenedspin::parse_values(std::string constant,std::vector line1) { + int l; + int nwords=line1.size(); + if (constant.compare("re")==0) { + re = strtod(line1[0].c_str(),NULL); + } + else if (constant.compare("rc")==0) { + rc = strtod(line1[0].c_str(),NULL); + } + else if (constant.compare("alpha")==0) { + delete [] alpha; + alpha = new double [nwords]; + for (l=0;lerrorf(FLERR,"Undefined value for radial power"); + //code will run with default o=0 if o is never specified. All other values must be defined in potential file. + if (re!=0 && rc!=0 && alpha!=0 && dr!=0 && nmax!=0)return true; + return false; +} + +void Fingerprint_radialscreenedspin::write_values(FILE *fid) { + int i; + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:re:\n",style,id); + fprintf(fid,"%f\n",re); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:rc:\n",style,id); + fprintf(fid,"%f\n",rc); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:alpha:\n",style,id); + for (i=0;i<(nmax-omin+1);i++) { + fprintf(fid,"%f ",alpha[i]); + } + fprintf(fid,"\n"); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:dr:\n",style,id); + fprintf(fid,"%f\n",dr); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:o:\n",style,id); + fprintf(fid,"%d\n",omin); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:n:\n",style,id); + fprintf(fid,"%d\n",nmax); +} + +//called after fingerprint is fully defined and tables can be computed. +void Fingerprint_radialscreenedspin::allocate() +{ + int k,m; + double r1; + int buf = 5; + int res = pair->res; + double cutmax = pair->cutmax; + radialtable = new double [(res+buf)*get_length()]; + dfctable = new double [res+buf]; + for (k=0;k<(res+buf);k++) { + r1 = cutmax*cutmax*(double)(k)/(double)(res); + for (m=0;m<=(nmax-omin);m++) { + radialtable[k*(nmax-omin+1)+m]=pow(sqrt(r1)/re,m+omin)*exp(-alpha[m]*sqrt(r1)/re)*cutofffunction(sqrt(r1),rc,dr); + } + if (sqrt(r1)>=rc || sqrt(r1) <= (rc-dr)) { + dfctable[k]=0; + } + else{ + dfctable[k]=-8*pow(1-(rc-sqrt(r1))/dr,3)/dr/(1-pow(1-(rc-sqrt(r1))/dr,4)); + } + } + generate_rinvssqrttable(); +} + +//called after fingerprint is declared for i-j type, but before its parameters are read. +void Fingerprint_radialscreenedspin::init(int *i,int _id) +{ + empty = false; + for (int j=0;jnelements; + int res = pair->res; + int i,j,jj,itype,jtype,l,kk; + double xtmp,ytmp,ztmp,delx,dely,delz,rsq; + int *ilist,*jlist,*numneigh,**firstneigh; + PairRANN::Simulation *sim = &pair->sims[sid]; + int count=0; + double **x = sim->x; + int *type = sim->type; + ilist = sim->ilist; + double cutmax = pair->cutmax; + i = ilist[ii]; + itype = pair->map[type[i]]; + int f = pair->net[itype].dimensions[0]; + double cutinv2 = 1/cutmax/cutmax; + double *si = sim->s[i]; + //loop over neighbors + for (jj = 0; jj < jnum; jj++) { + if (Bij[jj]==false) {continue;} + jtype = tn[jj]; + if (atomtypes[1] != nelements && atomtypes[1] != jtype)continue; + delx = xn[jj]; + dely = yn[jj]; + delz = zn[jj]; + rsq = delx*delx + dely*dely + delz*delz; + if (rsq > rc*rc)continue; + count = startingneuron; + double r1 = (rsq*((double)res)*cutinv2); + int m1 = (int)r1; + if (m1>res || m1<1) {pair->errorf(FLERR,"invalid neighbor radius!");} + if (radialtable[m1]==0) {continue;} + j=jl[jj]; + double *sj = sim->s[j]; + double sp = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; + //cubic interpolation from tables + double *p1 = &radialtable[m1*(nmax-omin+1)]; + double *p2 = &radialtable[(m1+1)*(nmax-omin+1)]; + double *p3 = &radialtable[(m1+2)*(nmax-omin+1)]; + double *p0 = &radialtable[(m1-1)*(nmax-omin+1)]; + double *q = &dfctable[m1-1]; + double *rinvs = &rinvsqrttable[m1-1]; + r1 = r1-trunc(r1); + double dfc = q[1] + 0.5 * r1*(q[2] - q[0] + r1*(2.0*q[0] - 5.0*q[1] + 4.0*q[2] - q[3] + r1*(3.0*(q[1] - q[2]) + q[3] - q[0]))); + double ri = rinvs[1] + 0.5 * r1*(rinvs[2] - rinvs[0] + r1*(2.0*rinvs[0] - 5.0*rinvs[1] + 4.0*rinvs[2] - rinvs[3] + r1*(3.0*(rinvs[1] - rinvs[2]) + rinvs[3] - rinvs[0]))); + for (l=0;l<=(nmax-omin);l++) { + double rt = Sik[jj]*(p1[l]+0.5*r1*(p2[l]-p0[l]+r1*(2.0*p0[l]-5.0*p1[l]+4.0*p2[l]-p3[l]+r1*(3.0*(p1[l]-p2[l])+p3[l]-p0[l])))); + //update neighbor's features + dspinx[jj*f+count]+=rt*si[0]; + dspiny[jj*f+count]+=rt*si[1]; + dspinz[jj*f+count]+=rt*si[2]; + dspinx[jnum*f+count]+=rt*sj[0]; + dspiny[jnum*f+count]+=rt*sj[1]; + dspinz[jnum*f+count]+=rt*sj[2]; + rt *= sp; + features[count]+=rt; + double rt1 = rt*((l+omin)/rsq+(-alpha[l]/re+dfc)*ri); + dfeaturesx[jj*f+count]+=rt1*delx+rt*dSikx[jj]; + dfeaturesy[jj*f+count]+=rt1*dely+rt*dSiky[jj]; + dfeaturesz[jj*f+count]+=rt1*delz+rt*dSikz[jj]; + for (kk=0;kk); + void write_values(FILE *); + void init(int*,int); + void allocate(); + virtual void compute_fingerprint(double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,bool*,int,int,double*,double*,double*,int*,int,int*);//spin,screen + int get_length(); + + double *radialtable; + double *dfctable; + double dr; + double *alpha; + double re; + int nmax;//highest term + int omin;//lowest term + + }; + } + +} + +#endif + + + +#endif /* FINGERPRINT_RADIALSCREENED_H_ */ diff --git a/src/USER-RANN/rann_fingerprint_radialspin.cpp b/src/USER-RANN/rann_fingerprint_radialspin.cpp new file mode 100644 index 0000000000..9d61fc08ed --- /dev/null +++ b/src/USER-RANN/rann_fingerprint_radialspin.cpp @@ -0,0 +1,252 @@ +/* -*- 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. +------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu + ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” + +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ +#include "rann_fingerprint_radialspin.h" + + + +using namespace LAMMPS_NS::RANN; + +Fingerprint_radialspin::Fingerprint_radialspin(PairRANN *_pair) : Fingerprint(_pair) +{ + n_body_type = 2; + dr = 0; + re = 0; + rc = 0; + alpha = new double [1]; + alpha[0] = -1; + nmax = 0; + omin = 0; + id = -1; + style = "radialspin"; + atomtypes = new int [n_body_type]; + empty = true; + fullydefined = false; + _pair->allscreen = false; + _pair->dospin = true; + spin = true; +} + +Fingerprint_radialspin::~Fingerprint_radialspin() +{ + delete [] atomtypes; + delete [] radialtable; + delete [] alpha; + delete [] dfctable; + delete [] rinvsqrttable; +} + +bool Fingerprint_radialspin::parse_values(std::string constant,std::vector line1) { + int l; + int nwords=line1.size(); + if (constant.compare("re")==0) { + re = strtod(line1[0].c_str(),NULL); + } + else if (constant.compare("rc")==0) { + rc = strtod(line1[0].c_str(),NULL); + } + else if (constant.compare("alpha")==0) { + delete [] alpha; + alpha = new double [nwords]; + for (l=0;lerrorf(FLERR,"Undefined value for radial power"); + //code will run with default o=0 if o is never specified. All other values must be defined in potential file. + if (re!=0 && rc!=0 && alpha!=0 && dr!=0 && nmax!=0)return true; + return false; +} + +void Fingerprint_radialspin::write_values(FILE *fid) { + int i; + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:re:\n",style,id); + fprintf(fid,"%f\n",re); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:rc:\n",style,id); + fprintf(fid,"%f\n",rc); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:alpha:\n",style,id); + for (i=0;i<(nmax-omin+1);i++) { + fprintf(fid,"%f ",alpha[i]); + } + fprintf(fid,"\n"); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:dr:\n",style,id); + fprintf(fid,"%f\n",dr); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:o:\n",style,id); + fprintf(fid,"%d\n",omin); + fprintf(fid,"fingerprintconstants:"); + fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); + for (i=1;ielementsp[atomtypes[i]]); + } + fprintf(fid,":%s_%d:n:\n",style,id); + fprintf(fid,"%d\n",nmax); +} + +//called after fingerprint is fully defined and tables can be computed. +void Fingerprint_radialspin::allocate() +{ + int k,m; + double r1; + int buf = 5; + int res = pair->res; + double cutmax = pair->cutmax; + radialtable = new double [(res+buf)*get_length()]; + dfctable = new double [res+buf]; + for (k=0;k<(res+buf);k++) { + r1 = cutmax*cutmax*(double)(k)/(double)(res); + for (m=0;m<=(nmax-omin);m++) { + radialtable[k*(nmax-omin+1)+m]=pow(sqrt(r1)/re,m+omin)*exp(-alpha[m]*sqrt(r1)/re)*cutofffunction(sqrt(r1),rc,dr); + } + if (sqrt(r1)>=rc || sqrt(r1) <= (rc-dr)) { + dfctable[k]=0; + } + else{ + dfctable[k]=-8*pow(1-(rc-sqrt(r1))/dr,3)/dr/(1-pow(1-(rc-sqrt(r1))/dr,4)); + } + } + generate_rinvssqrttable(); +} + +//called after fingerprint is declared for i-j type, but before its parameters are read. +void Fingerprint_radialspin::init(int *i,int _id) +{ + empty = false; + for (int j=0;jnelements; + int res = pair->res; + int i,j,jj,itype,jtype,l; + double xtmp,ytmp,ztmp,delx,dely,delz,rsq; + int *ilist,*jlist,*numneigh,**firstneigh; + // + PairRANN::Simulation *sim = &pair->sims[sid]; + int count=0; + int *type = sim->type; + ilist = sim->ilist; + double cutmax = pair->cutmax; + i = ilist[ii]; + itype = pair->map[type[i]]; + int f = pair->net[itype].dimensions[0]; + double cutinv2 = 1/cutmax/cutmax; + double *si = sim->s[i]; + firstneigh = sim->firstneigh; + jlist = firstneigh[i]; + //loop over neighbors + for (jj = 0; jj < jnum; jj++) { + j = jl[jj]; + jtype =tn[jj]; + if (atomtypes[1] != nelements && atomtypes[1] != jtype)continue; + delx = xn[jj]; + dely = yn[jj]; + delz = zn[jj]; + rsq = delx*delx + dely*dely + delz*delz; + if (rsq > rc*rc)continue; + count = startingneuron; + double r1 = (rsq*((double)res)*cutinv2); + int m1 = (int)r1; + if (m1>res || m1<1) {pair->errorf(FLERR,"invalid neighbor radius!");} + if (radialtable[m1]==0) {continue;} + double *sj = sim->s[j]; + double sp = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; + //cubic interpolation from tables + double *p1 = &radialtable[m1*(nmax-omin+1)]; + double *p2 = &radialtable[(m1+1)*(nmax-omin+1)]; + double *p3 = &radialtable[(m1+2)*(nmax-omin+1)]; + double *p0 = &radialtable[(m1-1)*(nmax-omin+1)]; + double *q = &dfctable[m1-1]; + double *rinvs = &rinvsqrttable[m1-1]; + r1 = r1-trunc(r1); + double dfc = q[1] + 0.5 * r1*(q[2] - q[0] + r1*(2.0*q[0] - 5.0*q[1] + 4.0*q[2] - q[3] + r1*(3.0*(q[1] - q[2]) + q[3] - q[0]))); + double ri = rinvs[1] + 0.5 * r1*(rinvs[2] - rinvs[0] + r1*(2.0*rinvs[0] - 5.0*rinvs[1] + 4.0*rinvs[2] - rinvs[3] + r1*(3.0*(rinvs[1] - rinvs[2]) + rinvs[3] - rinvs[0]))); + for (l=0;l<=(nmax-omin);l++) { + double rt = p1[l]+0.5*r1*(p2[l]-p0[l]+r1*(2.0*p0[l]-5.0*p1[l]+4.0*p2[l]-p3[l]+r1*(3.0*(p1[l]-p2[l])+p3[l]-p0[l]))); + dspinx[jj*f+count]+=rt*si[0]; + dspiny[jj*f+count]+=rt*si[1]; + dspinz[jj*f+count]+=rt*si[2]; + dspinx[jnum*f+count]+=rt*sj[0]; + dspiny[jnum*f+count]+=rt*sj[1]; + dspinz[jnum*f+count]+=rt*sj[2]; + rt *= sp; + features[count]+=rt; + rt *= (l+omin)/rsq+(-alpha[l]/re+dfc)*ri; + //update neighbor's features + dfeaturesx[jj*f+count]+=rt*delx; + dfeaturesy[jj*f+count]+=rt*dely; + dfeaturesz[jj*f+count]+=rt*delz; + //update atom's features + dfeaturesx[jnum*f+count]-=rt*delx; + dfeaturesy[jnum*f+count]-=rt*dely; + dfeaturesz[jnum*f+count]-=rt*delz; + count++; + } + } +} + +int Fingerprint_radialspin::get_length() +{ + return nmax-omin+1; +} diff --git a/src/USER-RANN/rann_fingerprint_radialspin.h b/src/USER-RANN/rann_fingerprint_radialspin.h new file mode 100644 index 0000000000..6abddd910d --- /dev/null +++ b/src/USER-RANN/rann_fingerprint_radialspin.h @@ -0,0 +1,69 @@ +/* -*- 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. +------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu + Doyl Dickel (MSU) doyl@me.msstate.edu + ----------------------------------------------------------------------*/ +/* +“The research described and the resulting data presented herein, unless +otherwise noted, was funded under PE 0602784A, Project T53 "Military +Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, +managed by the U.S. Army Combat Capabilities Development Command (CCDC) and +the Engineer Research and Development Center (ERDC). The work described in +this document was conducted at CAVS, MSU. Permission was granted by ERDC +to publish this information. Any opinions, findings and conclusions or +recommendations expressed in this material are those of the author(s) and +do not necessarily reflect the views of the United States Army.​” + +DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 + */ + +#ifdef FINGERPRINT_CLASS + +FingerprintStyle(radialspin,Fingerprint_radialspin) + +#else + +#ifndef LMP_RANN_FINGERPRINT_RADIALSPIN_H +#define LMP_RANN_FINGERPRINT_RADIALSPIN_H + +#include "rann_fingerprint.h" + +namespace LAMMPS_NS { + namespace RANN { + class Fingerprint_radialspin : public Fingerprint { + public: + Fingerprint_radialspin(PairRANN *); + ~Fingerprint_radialspin(); + bool parse_values(std::string,std::vector); + void write_values(FILE *); + void init(int*,int); + void allocate(); + void compute_fingerprint(double*,double*,double*,double*,double*,double*,double*,int,int,double*,double*,double*,int*,int,int*); + int get_length(); + + double *radialtable; + double *dfctable; + double dr; + double *alpha; + double re; + int nmax;//highest term + int omin;//lowest term + + }; + } + +} + +#endif +#endif /* FINGERPRINT_RADIAL_H_ */ diff --git a/src/USER-RANN/rann_list_activation.h b/src/USER-RANN/rann_list_activation.h new file mode 100644 index 0000000000..a140b92c65 --- /dev/null +++ b/src/USER-RANN/rann_list_activation.h @@ -0,0 +1,2 @@ +#include "rann_activation_linear.h" +#include "rann_activation_sig_i.h" diff --git a/src/USER-RANN/rann_list_fingerprint.h b/src/USER-RANN/rann_list_fingerprint.h new file mode 100644 index 0000000000..005c7f1b04 --- /dev/null +++ b/src/USER-RANN/rann_list_fingerprint.h @@ -0,0 +1,8 @@ +#include "rann_fingerprint_bond.h" +#include "rann_fingerprint_bondscreened.h" +#include "rann_fingerprint_bondscreenedspin.h" +#include "rann_fingerprint_bondspin.h" +#include "rann_fingerprint_radial.h" +#include "rann_fingerprint_radialscreened.h" +#include "rann_fingerprint_radialscreenedspin.h" +#include "rann_fingerprint_radialspin.h" From f165fdb61deac367ea8a81dd3e9a67a3c3caea94 Mon Sep 17 00:00:00 2001 From: kipbarrett Date: Thu, 11 Feb 2021 08:48:00 -0600 Subject: [PATCH 05/25] remove all files from src that are in src/USER-RANN --- src/activation.cpp | 57 -- src/activation.h | 52 - src/activation_linear.cpp | 54 - src/activation_linear.h | 54 - src/activation_sigI.cpp | 52 - src/activation_sigI.h | 55 -- src/fingerprint.cpp | 113 --- src/fingerprint.h | 72 -- src/fingerprint_bond.cpp | 917 ----------------- src/fingerprint_bond.h | 80 -- src/fingerprint_bondscreened.cpp | 950 ------------------ src/fingerprint_bondscreened.h | 79 -- src/fingerprint_bondscreenedspin.cpp | 1023 ------------------- src/fingerprint_bondscreenedspin.h | 79 -- src/fingerprint_bondspin.cpp | 1019 ------------------- src/fingerprint_bondspin.h | 79 -- src/fingerprint_radial.cpp | 259 ----- src/fingerprint_radial.h | 68 -- src/fingerprint_radialscreened.cpp | 273 ------ src/fingerprint_radialscreened.h | 71 -- src/fingerprint_radialscreenedspin.cpp | 285 ------ src/fingerprint_radialscreenedspin.h | 71 -- src/fingerprint_radialspin.cpp | 269 ----- src/fingerprint_radialspin.h | 69 -- src/pair_rann.cpp | 1247 ------------------------ src/pair_rann.h | 171 ---- 26 files changed, 7518 deletions(-) delete mode 100644 src/activation.cpp delete mode 100644 src/activation.h delete mode 100644 src/activation_linear.cpp delete mode 100644 src/activation_linear.h delete mode 100644 src/activation_sigI.cpp delete mode 100644 src/activation_sigI.h delete mode 100644 src/fingerprint.cpp delete mode 100644 src/fingerprint.h delete mode 100644 src/fingerprint_bond.cpp delete mode 100644 src/fingerprint_bond.h delete mode 100644 src/fingerprint_bondscreened.cpp delete mode 100644 src/fingerprint_bondscreened.h delete mode 100644 src/fingerprint_bondscreenedspin.cpp delete mode 100644 src/fingerprint_bondscreenedspin.h delete mode 100644 src/fingerprint_bondspin.cpp delete mode 100644 src/fingerprint_bondspin.h delete mode 100644 src/fingerprint_radial.cpp delete mode 100644 src/fingerprint_radial.h delete mode 100644 src/fingerprint_radialscreened.cpp delete mode 100644 src/fingerprint_radialscreened.h delete mode 100644 src/fingerprint_radialscreenedspin.cpp delete mode 100644 src/fingerprint_radialscreenedspin.h delete mode 100644 src/fingerprint_radialspin.cpp delete mode 100644 src/fingerprint_radialspin.h delete mode 100644 src/pair_rann.cpp delete mode 100644 src/pair_rann.h diff --git a/src/activation.cpp b/src/activation.cpp deleted file mode 100644 index 5286eb4730..0000000000 --- a/src/activation.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- 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. -------------------------------------------------------------------------- */ -/* ---------------------------------------------------------------------- - Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu - Doyl Dickel (MSU) doyl@me.msstate.edu - ----------------------------------------------------------------------*/ -/* -“The research described and the resulting data presented herein, unless -otherwise noted, was funded under PE 0602784A, Project T53 "Military -Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, -managed by the U.S. Army Combat Capabilities Development Command (CCDC) and -the Engineer Research and Development Center (ERDC). The work described in -this document was conducted at CAVS, MSU. Permission was granted by ERDC -to publish this information. Any opinions, findings and conclusions or -recommendations expressed in this material are those of the author(s) and -do not necessarily reflect the views of the United States Army.​” - -DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 - */ - - -#include "activation.h" - - -using namespace LAMMPS_NS; - -Activation::Activation(PairRANN *pair) { - empty = true; - style = "empty"; -} - -Activation::~Activation(){ - -} - -//default is linear activation (no change). -double Activation::activation_function(double A){ - return A; -} - -double Activation::dactivation_function(double A){ - return 1.0; -} - -double Activation::ddactivation_function(double A){ - return 0.0; -} diff --git a/src/activation.h b/src/activation.h deleted file mode 100644 index 0188f80bff..0000000000 --- a/src/activation.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- 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. -------------------------------------------------------------------------- */ -/* ---------------------------------------------------------------------- - Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu - Doyl Dickel (MSU) doyl@me.msstate.edu - ----------------------------------------------------------------------*/ -/* -“The research described and the resulting data presented herein, unless -otherwise noted, was funded under PE 0602784A, Project T53 "Military -Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, -managed by the U.S. Army Combat Capabilities Development Command (CCDC) and -the Engineer Research and Development Center (ERDC). The work described in -this document was conducted at CAVS, MSU. Permission was granted by ERDC -to publish this information. Any opinions, findings and conclusions or -recommendations expressed in this material are those of the author(s) and -do not necessarily reflect the views of the United States Army.​” - -DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 - */ - -#ifndef ACTIVATION_H_ -#define ACTIVATION_H_ - -#include "pair_rann.h" - -namespace LAMMPS_NS { - - class Activation { - public: - Activation(class PairRANN *); - virtual ~Activation(); - virtual double activation_function(double); - virtual double dactivation_function(double); - virtual double ddactivation_function(double); - bool empty; - const char *style; - }; -} - - - -#endif /* ACTIVATION_H_ */ diff --git a/src/activation_linear.cpp b/src/activation_linear.cpp deleted file mode 100644 index ddb9ae54c9..0000000000 --- a/src/activation_linear.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- 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. -------------------------------------------------------------------------- */ -/* ---------------------------------------------------------------------- - Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu - Doyl Dickel (MSU) doyl@me.msstate.edu - ----------------------------------------------------------------------*/ -/* -“The research described and the resulting data presented herein, unless -otherwise noted, was funded under PE 0602784A, Project T53 "Military -Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, -managed by the U.S. Army Combat Capabilities Development Command (CCDC) and -the Engineer Research and Development Center (ERDC). The work described in -this document was conducted at CAVS, MSU. Permission was granted by ERDC -to publish this information. Any opinions, findings and conclusions or -recommendations expressed in this material are those of the author(s) and -do not necessarily reflect the views of the United States Army.​” - -DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 - */ - -#include "activation_linear.h" - - - -using namespace LAMMPS_NS; - -Activation_linear::Activation_linear(PairRANN *pair) : Activation(pair){ - empty = false; - style = "linear"; -} - -double Activation_linear::activation_function(double A) -{ - return A; -} - -double Activation_linear::dactivation_function(double A) -{ - return 1.0; -} - -double Activation_linear::ddactivation_function(double){ - return 0.0; -} diff --git a/src/activation_linear.h b/src/activation_linear.h deleted file mode 100644 index 2ea0f55729..0000000000 --- a/src/activation_linear.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- 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. -------------------------------------------------------------------------- */ -/* ---------------------------------------------------------------------- - Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu - Doyl Dickel (MSU) doyl@me.msstate.edu - ----------------------------------------------------------------------*/ -/* -“The research described and the resulting data presented herein, unless -otherwise noted, was funded under PE 0602784A, Project T53 "Military -Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, -managed by the U.S. Army Combat Capabilities Development Command (CCDC) and -the Engineer Research and Development Center (ERDC). The work described in -this document was conducted at CAVS, MSU. Permission was granted by ERDC -to publish this information. Any opinions, findings and conclusions or -recommendations expressed in this material are those of the author(s) and -do not necessarily reflect the views of the United States Army.​” - -DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 - */ -#ifdef ACTIVATION_CLASS - -ActivationStyle(linear,Activation_linear) - -#else - -#ifndef ACTIVATION_LINEAR_H_ -#define ACTIVATION_LINEAR_H_ - -#include "activation.h" - -namespace LAMMPS_NS { - -class Activation_linear : public Activation { -public: - Activation_linear(class PairRANN *); - double activation_function(double); - double dactivation_function(double); - double ddactivation_function(double); -}; - -} - -#endif -#endif /* ACTIVATION_LINEAR_H_ */ diff --git a/src/activation_sigI.cpp b/src/activation_sigI.cpp deleted file mode 100644 index b14f1c503d..0000000000 --- a/src/activation_sigI.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- 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. -------------------------------------------------------------------------- */ -/* ---------------------------------------------------------------------- - Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu - Doyl Dickel (MSU) doyl@me.msstate.edu - ----------------------------------------------------------------------*/ -/* -“The research described and the resulting data presented herein, unless -otherwise noted, was funded under PE 0602784A, Project T53 "Military -Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, -managed by the U.S. Army Combat Capabilities Development Command (CCDC) and -the Engineer Research and Development Center (ERDC). The work described in -this document was conducted at CAVS, MSU. Permission was granted by ERDC -to publish this information. Any opinions, findings and conclusions or -recommendations expressed in this material are those of the author(s) and -do not necessarily reflect the views of the United States Army.​” - -DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 - */ -#include "activation_sigI.h" - -using namespace LAMMPS_NS; - -Activation_sigI::Activation_sigI(PairRANN *pair) : Activation(pair){ - empty = false; - style = "sigI"; -} - -double Activation_sigI::activation_function(double in){ - if (in>34)return in; - return 0.1*in + 0.9*log(exp(in) + 1); -} - -double Activation_sigI::dactivation_function(double in){ - if (in>34)return 1; - return 0.1 + 0.9/(exp(in)+1)*exp(in); -} - -double Activation_sigI::ddactivation_function(double in){ - if (in>34)return 0; - return 0.9*exp(in)/(exp(in)+1)/(exp(in)+1);; -} diff --git a/src/activation_sigI.h b/src/activation_sigI.h deleted file mode 100644 index 404af35cfd..0000000000 --- a/src/activation_sigI.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- 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. -------------------------------------------------------------------------- */ -/* ---------------------------------------------------------------------- - Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu - Doyl Dickel (MSU) doyl@me.msstate.edu - ----------------------------------------------------------------------*/ -/* -“The research described and the resulting data presented herein, unless -otherwise noted, was funded under PE 0602784A, Project T53 "Military -Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, -managed by the U.S. Army Combat Capabilities Development Command (CCDC) and -the Engineer Research and Development Center (ERDC). The work described in -this document was conducted at CAVS, MSU. Permission was granted by ERDC -to publish this information. Any opinions, findings and conclusions or -recommendations expressed in this material are those of the author(s) and -do not necessarily reflect the views of the United States Army.​” - -DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 - */ - -#ifdef ACTIVATION_CLASS - -ActivationStyle(sigI,Activation_sigI) - -#else - -#ifndef ACTIVATION_SIGI_H_ -#define ACTIVATION_SIGI_H_ - -#include "activation.h" - -namespace LAMMPS_NS { - - class Activation_sigI : public Activation { - public: - Activation_sigI(class PairRANN *); - double activation_function(double); - double dactivation_function(double); - double ddactivation_function(double); - }; -} - - -#endif -#endif /* ACTIVATION_SIGI_H_ */ diff --git a/src/fingerprint.cpp b/src/fingerprint.cpp deleted file mode 100644 index 89786b632a..0000000000 --- a/src/fingerprint.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/* -*- 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. -------------------------------------------------------------------------- */ -/* ---------------------------------------------------------------------- - Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu - Doyl Dickel (MSU) doyl@me.msstate.edu - ----------------------------------------------------------------------*/ -/* -“The research described and the resulting data presented herein, unless -otherwise noted, was funded under PE 0602784A, Project T53 "Military -Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, -managed by the U.S. Army Combat Capabilities Development Command (CCDC) and -the Engineer Research and Development Center (ERDC). The work described in -this document was conducted at CAVS, MSU. Permission was granted by ERDC -to publish this information. Any opinions, findings and conclusions or -recommendations expressed in this material are those of the author(s) and -do not necessarily reflect the views of the United States Army.​” - -DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 - */ - -#include "fingerprint.h" - - -using namespace LAMMPS_NS; - -Fingerprint::Fingerprint(PairRANN *pair) -{ - spin = false; - screen = false; - empty = true; - fullydefined = false; - n_body_type = 0; - style = "empty"; - this->pair = pair; -} - -Fingerprint::~Fingerprint(){ - -} - -bool Fingerprint::parse_values(char *word,char *line1){ - return false; -} - -void Fingerprint::init(int *i,int id){ - -} - -void Fingerprint::allocate(){ - -} - -void Fingerprint::compute_fingerprint(double *features,double *dfeaturesx,double *dfeaturesy,double * dfeaturesz, int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl){ - -} - -void Fingerprint::compute_fingerprint(double *features,double *dfeaturesx,double *dfeaturesy,double * dfeaturesz,double *Sik, double *dSikx, double*dSiky, double *dSikz, double *dSijkx, double *dSijky, double *dSijkz, bool *Bij, int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl){ - -} - -void Fingerprint::compute_fingerprint(double *features,double *dfeaturesx,double *dfeaturesy,double * dfeaturesz,double *sx, double *sy, double *sz, int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl){ - -} - -void Fingerprint::compute_fingerprint(double *features,double *dfeaturesx,double *dfeaturesy,double * dfeaturesz,double *sx, double *sy, double *sz, double *Sik, double *dSikx, double*dSiky, double *dSikz, double *dSijkx, double *dSijky, double *dSijkz, bool *Bij, int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl){ - -} - -void Fingerprint::write_values(FILE *fid){ - -} - -int Fingerprint::get_length(){ - return 0; -} - -//Smooth cutoff, goes from 1 to zero over the interval rc-dr to rc. Same as MEAM uses. Used by generateradialtable and generatexpcuttable. -double Fingerprint::cutofffunction(double r,double rc, double dr){ - double out; - if (r < (rc -dr))out=1; - else if (r>rc)out=0; - else { - out = pow(1-pow(1-(rc-r)/dr,4.0),2.0); - } - return out; -} - -void Fingerprint::generate_rinvssqrttable(){ - int buf = 5; - int m; - double r1; - double cutmax = pair->cutmax; - int res = pair->res; - rinvsqrttable = new double[res+buf]; - for (m=0;m<(res+buf);m++){ - r1 = cutmax*cutmax*(double)(m)/(double)(res); - rinvsqrttable[m] = 1/sqrt(r1); - } -} - - - - diff --git a/src/fingerprint.h b/src/fingerprint.h deleted file mode 100644 index 35645742f4..0000000000 --- a/src/fingerprint.h +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- 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. -------------------------------------------------------------------------- */ -/* ---------------------------------------------------------------------- - Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu - Doyl Dickel (MSU) doyl@me.msstate.edu - ----------------------------------------------------------------------*/ -/* -“The research described and the resulting data presented herein, unless -otherwise noted, was funded under PE 0602784A, Project T53 "Military -Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, -managed by the U.S. Army Combat Capabilities Development Command (CCDC) and -the Engineer Research and Development Center (ERDC). The work described in -this document was conducted at CAVS, MSU. Permission was granted by ERDC -to publish this information. Any opinions, findings and conclusions or -recommendations expressed in this material are those of the author(s) and -do not necessarily reflect the views of the United States Army.​” - -DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 - -----------------*/ - -#ifndef FINGERPRINT_H_ -#define FINGERPRINT_H_ - -#include "pair_rann.h" - -namespace LAMMPS_NS { - - class Fingerprint { - public: - Fingerprint(PairRANN *); - virtual ~Fingerprint(); - virtual bool parse_values(char*,char*); - virtual void write_values(FILE *); - virtual void init(int*,int); - virtual void allocate(); - void init_screen(int); - virtual void compute_fingerprint(double*,double*,double*,double*,int,int,double*,double*,double*,int*,int,int*);//no screen,no spin - virtual void compute_fingerprint(double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,bool*,int,int,double*,double*,double*,int*,int,int*);//screen - virtual void compute_fingerprint(double*,double*,double*,double*,double*,double*,double*,int,int,double*,double*,double*,int*,int,int*);//spin - virtual void compute_fingerprint(double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,bool*,int,int,double*,double*,double*,int*,int,int*);//spin,screen - virtual int get_length(); - virtual double cutofffunction(double,double, double); - virtual void generate_rinvssqrttable(); - bool spin; - bool screen; - int n_body_type;//i-j vs. i-j-k vs. i-j-k-l, etc. - bool empty; - bool fullydefined; - int startingneuron; - int id;//based on ordering of fingerprints listed for i-j in potential file - const char *style; - int* atomtypes; - double *rinvsqrttable; - double rc; - PairRANN *pair; - }; - -} - - -#endif /* FINGERPRINT_H_ */ diff --git a/src/fingerprint_bond.cpp b/src/fingerprint_bond.cpp deleted file mode 100644 index 1f8630ccb2..0000000000 --- a/src/fingerprint_bond.cpp +++ /dev/null @@ -1,917 +0,0 @@ -/* -*- 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. -------------------------------------------------------------------------- */ -/* ---------------------------------------------------------------------- - Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu - Doyl Dickel (MSU) doyl@me.msstate.edu - ----------------------------------------------------------------------*/ -/* -“The research described and the resulting data presented herein, unless -otherwise noted, was funded under PE 0602784A, Project T53 "Military -Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, -managed by the U.S. Army Combat Capabilities Development Command (CCDC) and -the Engineer Research and Development Center (ERDC). The work described in -this document was conducted at CAVS, MSU. Permission was granted by ERDC -to publish this information. Any opinions, findings and conclusions or -recommendations expressed in this material are those of the author(s) and -do not necessarily reflect the views of the United States Army.​” - -DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 - */ - -#include "fingerprint_bond.h" - - -using namespace LAMMPS_NS; - -Fingerprint_bond::Fingerprint_bond(PairRANN *pair) : Fingerprint(pair) -{ - n_body_type = 3; - dr = 0; - re = 0; - rc = 0; - alpha_k = new double [1]; - alpha_k[0] = -1; - k = 0; - m = 0; - id = -1; - style = "bond"; - atomtypes = new int [n_body_type]; - empty = true; - pair->allscreen = false; -} - -Fingerprint_bond::~Fingerprint_bond(){ - delete [] alpha_k; - delete [] atomtypes; - delete [] expcuttable; - delete [] dfctable; - for (int i=0;i<(m*(m+1))>>1;i++){ - delete [] coeff[i]; - delete [] coeffx[i]; - delete [] coeffy[i]; - delete [] coeffz[i]; - delete [] Mf[i]; - } - delete [] coeff; - delete [] coeffx; - delete [] coeffy; - delete [] coeffz; - delete [] Mf; - delete [] rinvsqrttable; -} - -bool Fingerprint_bond::parse_values(char * constant, char * line1){ - char **words=new char *[MAXLINE]; - int nwords,l; - nwords=0; - words[nwords++] = strtok(line1,": ,\t\n"); - while ((words[nwords++] = strtok(NULL,": ,\t\n"))) continue; - nwords -= 1; - if (strcmp(constant,"re")==0){ - re = strtod(words[0],NULL); - } - else if (strcmp(constant,"rc")==0){ - rc = strtod(words[0],NULL); - } - else if (strcmp(constant,"alphak")==0){ - delete [] alpha_k; - alpha_k = new double [nwords]; - for (l=0;lerrorf("Undefined value for bond power"); - delete [] words; - if (re!=0.0 && rc!=0.0 && alpha_k[0]!=-1 && dr!=0.0 && m!=0 && k!=0)return true; - return false; -} - -void Fingerprint_bond::write_values(FILE *fid){ - int i; - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:re:\n",style,id); - fprintf(fid,"%f\n",re); - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:rc:\n",style,id); - fprintf(fid,"%f\n",rc); - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:alphak:\n",style,id); - for (i=0;ielementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:dr:\n",style,id); - fprintf(fid,"%f\n",dr); - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:k:\n",style,id); - fprintf(fid,"%d\n",k); - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:m:\n",style,id); - fprintf(fid,"%d\n",m); -} - -void Fingerprint_bond::init(int *i,int id){ - for (int j=0;jk = 0; - alpha_k = new double [1]; - alpha_k[0]=-1; - empty = false; - this->id = id; -} - -//number of neurons defined by this fingerprint -int Fingerprint_bond::get_length(){ - return m*k; -} - -void Fingerprint_bond::allocate(){ - generate_exp_cut_table(); - generate_coefficients(); - generate_rinvssqrttable(); -} - -//Generate table of complex functions for quick reference during compute. Used by do3bodyfeatureset_singleneighborloop and do3bodyfeatureset_doubleneighborloop. -void Fingerprint_bond::generate_exp_cut_table(){ - int m,n; - double r1; - int buf = 5; - int res = pair->res; - double cutmax = pair->cutmax; - expcuttable = new double [(res+buf)*(this->k)]; - dfctable = new double [res+buf]; - for (m=0;m<(res+buf);m++){ - r1 = cutmax*cutmax*(double)(m)/(double)(res); - for (n=0;n<(this->k);n++){ - expcuttable[n+m*(this->k)] = exp(-alpha_k[n]/re*sqrt(r1))*cutofffunction(sqrt(r1),rc,dr); - } - if (sqrt(r1)>=rc || sqrt(r1) <= (rc-dr)){ - dfctable[m]=0; - } - else{ - dfctable[m]=-8*pow(1-(rc-sqrt(r1))/dr,3)/dr/(1-pow(1-(rc-sqrt(r1))/dr,4)); - } - } -} - -//Generate table of complex functions for quick reference during compute. Used by do3bodyfeatureset_singleneighborloop. -void Fingerprint_bond::generate_coefficients(){ //calculates multinomial coefficient for each term - int p,mb,mc; - int n,p1,i1; - mb = this->m; - mc=(mb*(mb+1))>>1; - coeff = new int *[mc]; - coeffx = new int *[mc]; - coeffy = new int *[mc]; - coeffz = new int *[mc]; - for (p=0;pm+1]; - for (p=0;pm+1;p++){ - M[p]=0; - } - for (p1=0;p1sims[sid]; - ilist = sim->ilist; - numneigh = sim->numneigh; - i = ilist[ii]; -// jnum = numneigh[i]; - //select the more efficient algorithm for this particular potential and environment. - if (jnum*2>(m+1)*m*20){ - do3bodyfeatureset_singleneighborloop(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,sid,xn,yn,zn,tn,jnum,jl); - } - else{ - do3bodyfeatureset_doubleneighborloop(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,sid,xn,yn,zn,tn,jnum,jl); - - } -} - -//Called by do3bodyfeatureset. Algorithm for high neighbor numbers and small series of bond angle powers -void Fingerprint_bond::do3bodyfeatureset_singleneighborloop(double * features,double * dfeaturesx,double *dfeaturesy,double *dfeaturesz,int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl){ - int i,j,jj,itype,jtype,kk,m,n,mcount,a,a1,a2,ai; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *ilist,*jlist,*numneigh,**firstneigh; - int count=0; - PairRANN::Simulation *sim = &pair->sims[sid]; -// double **x = sim->x; - int *type = sim->type; - double cutmax = pair->cutmax; - int res = pair->res; - double cutinv2 = 1/cutmax/cutmax; - ilist = sim->ilist; -// numneigh = sim->numneigh; -// firstneigh = sim->firstneigh; - int nelements=pair->nelements; - i = ilist[ii]; - itype = pair->map[type[i]]; - int f = pair->net[itype].dimensions[0]; -// xtmp = x[i][0]; -// ytmp = x[i][1]; -// ztmp = x[i][2]; -// jlist = firstneigh[i]; -// jnum = numneigh[i]; - double expr[jnum][this->k+12]; - int p = this->k; - int countmb=((this->m)*(this->m+1))>>1; - // calculate interpolation expr, rinvs and dfc, for each neighbor - for (jj = 0; jj < jnum; jj++) { -// j = jlist[jj]; -// j &= NEIGHMASK; -// jtype = pair->map[type[j]]; - jtype = tn[jj]; - if (atomtypes[1] != nelements && atomtypes[1] != jtype && atomtypes[2] != nelements && atomtypes[2] != jtype){ - expr[jj][0]=0; - continue; - } -// delx = xtmp - x[j][0]; -// dely = ytmp - x[j][1]; -// delz = ztmp - x[j][2]; - delx = xn[jj]; - dely = yn[jj]; - delz = zn[jj]; - rsq = delx*delx + dely*dely + delz*delz; - if (rsq>rc*rc){ - expr[jj][0]=0; - continue; - } - double r1 = (rsq*((double)res)*cutinv2); - int m1 = (int)r1; - r1 = r1-trunc(r1); - double *p0 = &expcuttable[(m1-1)*this->k]; - double *p1 = &expcuttable[m1*this->k]; - double *p2 = &expcuttable[(m1+1)*this->k]; - double *p3 = &expcuttable[(m1+2)*this->k]; - for (kk=0;kkk;kk++){ - expr[jj][kk] = p1[kk]+0.5*r1*(p2[kk]-p0[kk]+r1*(2.0*p0[kk]-5.0*p1[kk]+4.0*p2[kk]-p3[kk]+r1*(3.0*(p1[kk]-p2[kk])+p3[kk]-p0[kk]))); - } - double* q = &dfctable[m1-1]; - double* ri = &rinvsqrttable[m1-1]; - double dfc = q[1] + 0.5 * r1*(q[2] - q[0] + r1*(2.0*q[0] - 5.0*q[1] + 4.0*q[2] - q[3] + r1*(3.0*(q[1] - q[2]) + q[3] - q[0]))); - double rinvs = ri[1] + 0.5 * r1*(ri[2] - ri[0] + r1*(2.0*ri[0] - 5.0*ri[1] + 4.0*ri[2] - ri[3] + r1*(3.0*(ri[1] - ri[2]) + ri[3] - ri[0]))); - - expr[jj][p]=delx*rinvs; - expr[jj][p+1]=dely*rinvs; - expr[jj][p+2]=delz*rinvs; - //Hack to avoid nan when x y or z component of radial vector is exactly 0. Shouldn't affect accuracy. - if (expr[jj][p]*expr[jj][p]<0.000000000001){ - expr[jj][p] = 0.000001; - } - if (expr[jj][p+1]*expr[jj][p+1]<0.000000000001){ - expr[jj][p+1] = 0.000001; - } - if (expr[jj][p+2]*expr[jj][p+2]<0.000000000001){ - expr[jj][p+2] = 0.000001; - } - expr[jj][p+3] = -dfc*expr[jj][p]; - expr[jj][p+4] = rinvs/expr[jj][p]; - expr[jj][p+5] = rinvs*expr[jj][p]; - expr[jj][p+6] = -dfc*expr[jj][p+1]; - expr[jj][p+7] = rinvs/expr[jj][p+1]; - expr[jj][p+8] = rinvs*expr[jj][p+1]; - expr[jj][p+9] = -dfc*expr[jj][p+2]; - expr[jj][p+10] = rinvs/expr[jj][p+2]; - expr[jj][p+11] = rinvs*expr[jj][p+2]; - } - - int kb = this->k; - int mb = this->m; - count = startingneuron; - double Bb[mb]; - double dBbx; - double dBby; - double dBbz; -// double dBbx1[mb]; -// double dBby1[mb]; -// double dBbz1[mb]; - double yprod; - for (mcount=0;mcountcoeffx[mcount]; - int *coeffy = this->coeffy[mcount]; - int *coeffz = this->coeffz[mcount]; - int *coeff = this->coeff[mcount]; - a = mb+1; - for (a1=0;a1map[type[j]]; - jtype = tn[jj]; - if (atomtypes[1] != nelements && atomtypes[1] != jtype){ - continue; - } - double yprod = expr[jj][ai]; - double *y4 = &expr[jj][p]; - for (a2=0;a2map[type[j]]; - jtype = tn[jj]; - if (atomtypes[2] != nelements && atomtypes[2] != jtype){ - continue; - } - double yprod = expr[jj][ai]; - double *y4 = &expr[jj][p]; - for (a2=0;a2map[type[j]]; - jtype = tn[jj]; - if (atomtypes[2] != nelements && atomtypes[2] != jtype){ - continue; - } - double *y3 = &expr[jj][p+3]; - double *y4 = &expr[jj][p]; - ai = n; - yprod = expr[jj][ai]; - for (a2=0;a2map[type[j]]; - jtype = tn[jj]; - if (atomtypes[1] != nelements && atomtypes[1] != jtype){ - continue; - } - double *y3 = &expr[jj][p+3]; - double *y4 = &expr[jj][p]; - ai = n; - yprod = expr[jj][ai]; - for (a2=0;a2map[type[j]]; - jtype = tn[jj]; - if (atomtypes[1] != nelements && atomtypes[1] != jtype){ - continue; - } - double *y3 = &expr[jj][p+3]; - double *y4 = &expr[jj][p]; - ai = n; - yprod = expr[jj][ai]; - for (a2=0;a2sims[sid]; - double **x = sim->x; - int *type = sim->type; - int nelements = pair->nelements; - int res = pair->res; - double cutmax = pair->cutmax; - double cutinv2 = 1/cutmax/cutmax; - ilist = sim->ilist; -// numneigh = sim->numneigh; -// firstneigh = sim->firstneigh; - i = ilist[ii]; - itype = pair->map[type[i]]; - int f = pair->net[itype].dimensions[0]; -// xtmp = x[i][0]; -// ytmp = x[i][1]; -// ztmp = x[i][2]; -// jlist = firstneigh[i]; -// jnum = numneigh[i]; - double expr[jnum][this->k]; - double y[jnum][3]; - double ri[jnum]; - double dfc[jnum]; - int kb = this->k; - int mb = this->m; - double c41[this->k]; - double c51[this->k]; - double c61[this->k]; - double ct[this->k]; - for (jj = 0; jj < jnum; jj++) { -// j = jlist[jj]; -// j &= NEIGHMASK; -// jtype = pair->map[type[j]]; - jtype = tn[jj]; - if (jtypes != nelements && jtypes != jtype && ktypes != nelements && ktypes != jtype){ - expr[jj][0]=0; - continue; - } -// delx = xtmp - x[j][0]; -// dely = ytmp - x[j][1]; -// delz = ztmp - x[j][2]; - delx = xn[jj]; - dely = yn[jj]; - delz = zn[jj]; - rsq = delx*delx + dely*dely + delz*delz; - if (rsq>rc*rc){ - expr[jj][0]=0; - continue; - } - double r1 = (rsq*((double)res)*cutinv2); - int m1 = (int)r1; - if (!(m1>=1 && m1 <= res))pair->errorf("Neighbor list is invalid.");//usually results from nan somewhere. - r1 = r1-trunc(r1); - double *p0 = &expcuttable[(m1-1)*this->k]; - double *p1 = &expcuttable[m1*this->k]; - double *p2 = &expcuttable[(m1+1)*this->k]; - double *p3 = &expcuttable[(m1+2)*this->k]; - for (kk=0;kkk;kk++){ - expr[jj][kk] = p1[kk]+0.5*r1*(p2[kk]-p0[kk]+r1*(2.0*p0[kk]-5.0*p1[kk]+4.0*p2[kk]-p3[kk]+r1*(3.0*(p1[kk]-p2[kk])+p3[kk]-p0[kk]))); - } - double* q = &dfctable[m1-1]; - double* r2 = &rinvsqrttable[m1-1]; - dfc[jj] = q[1] + 0.5 * r1*(q[2] - q[0] + r1*(2.0*q[0] - 5.0*q[1] + 4.0*q[2] - q[3] + r1*(3.0*(q[1] - q[2]) + q[3] - q[0]))); - ri[jj] = r2[1] + 0.5 * r1*(r2[2] - r2[0] + r1*(2.0*r2[0] - 5.0*r2[1] + 4.0*r2[2] - r2[3] + r1*(3.0*(r2[1] - r2[2]) + r2[3] - r2[0]))); - y[jj][0]=delx*ri[jj]; - y[jj][1]=dely*ri[jj]; - y[jj][2]=delz*ri[jj]; - } -// if (i==5){ -// for (jj=0;jjmap[type[j]]; - jtype = tn[jj]; - if (jtypes != nelements && jtypes != jtype){ - continue; - } - for (n = 0;nk;n++){ - ct[n] = 2*alpha_k[n]/re; - c41[n]=(-ct[n]+2*dfc[jj])*y[jj][0]; - c51[n]=(-ct[n]+2*dfc[jj])*y[jj][1]; - c61[n]= (-ct[n]+2*dfc[jj])*y[jj][2]; - } - if (jtypes==ktypes){ - for (kk=jj+1;kk< jnum; kk++){ - if (expr[kk][0]==0)continue; -// int k1 = jlist[kk]; -// k1 &= NEIGHMASK; -// ktype = pair->map[type[k1]]; - ktype = tn[kk]; - if (ktypes != nelements && ktypes != ktype){ - continue; - } - count = startingneuron; - double dot = (y[jj][0]*y[kk][0]+y[jj][1]*y[kk][1]+y[jj][2]*y[kk][2]); - double c1 = 2*ri[jj]*(y[kk][0]-dot*y[jj][0]); - double c2 = 2*ri[jj]*(y[kk][1]-dot*y[jj][1]); - double c3 = 2*ri[jj]*(y[kk][2]-dot*y[jj][2]); - double c10 = 2*ri[kk]*(y[jj][0]-dot*y[kk][0]); - double c11 = 2*ri[kk]*(y[jj][1]-dot*y[kk][1]); - double c12 = 2*ri[kk]*(y[jj][2]-dot*y[kk][2]); -// double c1 = 2*ri[jj]*y[kk][0]*(1-y[jj][0]*y[jj][0]); -// double c2 = 2*ri[jj]*y[kk][1]*(1-y[jj][1]*y[jj][1]); -// double c3 = 2*ri[jj]*y[kk][2]*(1-y[jj][2]*y[jj][2]); -// double c10 = 2*ri[kk]*y[jj][0]*(1-y[kk][0]*y[kk][0]); -// double c11 = 2*ri[kk]*y[jj][1]*(1-y[kk][1]*y[kk][1]); -// double c12 = 2*ri[kk]*y[jj][2]*(1-y[kk][2]*y[kk][2]); - for (n=0;nmap[type[k1]]; - ktype = tn[kk]; - if (ktypes != nelements && ktypes != ktype){ - continue; - } - count = startingneuron; - double dot = (y[jj][0]*y[kk][0]+y[jj][1]*y[kk][1]+y[jj][2]*y[kk][2]); - double c1 = ri[jj]*(y[kk][0]-dot*y[jj][0]); - double c2 = ri[jj]*(y[kk][1]-dot*y[jj][1]); - double c3 = ri[jj]*(y[kk][2]-dot*y[jj][2]); - double c10 = ri[kk]*(y[jj][0]-dot*y[kk][0]); - double c11 = ri[kk]*(y[jj][1]-dot*y[kk][1]); - double c12 = ri[kk]*(y[jj][2]-dot*y[kk][2]); -// double c1 = 2*ri[jj]*y[kk][0]*(1-y[jj][0]*y[jj][0]); -// double c2 = 2*ri[jj]*y[kk][1]*(1-y[jj][1]*y[jj][1]); -// double c3 = 2*ri[jj]*y[kk][2]*(1-y[jj][2]*y[jj][2]); -// double c10 = 2*ri[kk]*y[jj][0]*(1-y[kk][0]*y[kk][0]); -// double c11 = 2*ri[kk]*y[jj][1]*(1-y[kk][1]*y[kk][1]); -// double c12 = 2*ri[kk]*y[jj][2]*(1-y[kk][2]*y[kk][2]); - for (n=0;ndoscreen = true; - screen = true; -} - -Fingerprint_bondscreened::~Fingerprint_bondscreened(){ - delete [] alpha_k; - delete [] atomtypes; - delete [] expcuttable; - delete [] dfctable; - for (int i=0;i<(m*(m+1))>>1;i++){ - delete [] coeff[i]; - delete [] coeffx[i]; - delete [] coeffy[i]; - delete [] coeffz[i]; - delete [] Mf[i]; - } - delete [] coeff; - delete [] coeffx; - delete [] coeffy; - delete [] coeffz; - delete [] Mf; - delete [] rinvsqrttable; -} - -bool Fingerprint_bondscreened::parse_values(char * constant, char * line1){ - char **words=new char *[MAXLINE]; - int nwords,l; - nwords=0; - words[nwords++] = strtok(line1,": ,\t\n"); - while ((words[nwords++] = strtok(NULL,": ,\t\n"))) continue; - nwords -= 1; - if (strcmp(constant,"re")==0){ - re = strtod(words[0],NULL); - } - else if (strcmp(constant,"rc")==0){ - rc = strtod(words[0],NULL); - } - else if (strcmp(constant,"alphak")==0){ - delete [] alpha_k; - alpha_k = new double [nwords]; - for (l=0;lerrorf("Undefined value for bond power"); - delete [] words; - if (re!=0.0 && rc!=0.0 && alpha_k[0]!=-1 && dr!=0.0 && m!=0 && k!=0)return true; - return false; -} - -void Fingerprint_bondscreened::write_values(FILE *fid){ - int i; - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:re:\n",style,id); - fprintf(fid,"%f\n",re); - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:rc:\n",style,id); - fprintf(fid,"%f\n",rc); - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:alphak:\n",style,id); - for (i=0;ielementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:dr:\n",style,id); - fprintf(fid,"%f\n",dr); - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:k:\n",style,id); - fprintf(fid,"%d\n",k); - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:m:\n",style,id); - fprintf(fid,"%d\n",m); -} - -void Fingerprint_bondscreened::init(int *i,int id){ - for (int j=0;jk = 0; - alpha_k = new double [1]; - alpha_k[0]=-1; - empty = false; - this->id = id; -} - -//number of neurons defined by this fingerprint -int Fingerprint_bondscreened::get_length(){ - return m*k; -} - -void Fingerprint_bondscreened::allocate(){ - generate_exp_cut_table(); - generate_coefficients(); - generate_rinvssqrttable(); -} - -//Generate table of complex functions for quick reference during compute. Used by do3bodyfeatureset_singleneighborloop and do3bodyfeatureset_doubleneighborloop. -void Fingerprint_bondscreened::generate_exp_cut_table(){ - int m,n; - double r1; - int buf = 5; - int res = pair->res; - double cutmax = pair->cutmax; - expcuttable = new double [(res+buf)*(this->k)]; - dfctable = new double [res+buf]; - for (m=0;m<(res+buf);m++){ - r1 = cutmax*cutmax*(double)(m)/(double)(res); - for (n=0;n<(this->k);n++){ - expcuttable[n+m*(this->k)] = exp(-alpha_k[n]/re*sqrt(r1))*cutofffunction(sqrt(r1),rc,dr); - } - if (sqrt(r1)>=rc || sqrt(r1) <= (rc-dr)){ - dfctable[m]=0; - } - else{ - dfctable[m]=-8*pow(1-(rc-sqrt(r1))/dr,3)/dr/(1-pow(1-(rc-sqrt(r1))/dr,4)); - } - } -} - - -//Generate table of complex functions for quick reference during compute. Used by do3bodyfeatureset_singleneighborloop. -void Fingerprint_bondscreened::generate_coefficients(){ //calculates multinomial coefficient for each term - int p,mb,mc; - int n,p1,i1; - mb = this->m; - mc=(mb*(mb+1))>>1; - coeff = new int *[mc]; - coeffx = new int *[mc]; - coeffy = new int *[mc]; - coeffz = new int *[mc]; - for (p=0;pm+1]; - for (p=0;pm+1;p++){ - M[p]=0; - } - for (p1=0;p1sims[sid]; -// ilist = sim->ilist; -// numneigh = sim->numneigh; -// i = ilist[ii]; -// jnum = numneigh[i]; - //select the more efficient algorithm for this particular potential and environment. - if (jnum*2>(m+1)*m*20){ - do3bodyfeatureset_singleneighborloop(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,sid,xn,yn,zn,tn,jnum,jl); - } - else{ - do3bodyfeatureset_doubleneighborloop(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,sid,xn,yn,zn,tn,jnum,jl); - - } -} - -//Called by do3bodyfeatureset. Algorithm for high neighbor numbers and small series of bond angle powers -void Fingerprint_bondscreened::do3bodyfeatureset_singleneighborloop(double * features,double * dfeaturesx,double *dfeaturesy,double *dfeaturesz,double *Sik, double *dSikx, double*dSiky, double *dSikz, double *dSijkx, double *dSijky, double *dSijkz, bool *Bij,int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl){ - int i,j,jj,itype,jtype,kk,m,n,mcount,a,a1,a2,ai; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *ilist,*jlist,*numneigh,**firstneigh; - int count=0; - PairRANN::Simulation *sim = &pair->sims[sid]; -// double **x = sim->x; - //double **f = atom->f; - int *type = sim->type; - double cutmax = pair->cutmax; - int res = pair->res; - double cutinv2 = 1/cutmax/cutmax; - ilist = sim->ilist; -// numneigh = sim->numneigh; -// firstneigh = sim->firstneigh; - int nelements=pair->nelements; - i = ilist[ii]; - itype = pair->map[type[i]]; - int f = pair->net[itype].dimensions[0]; -// xtmp = x[i][0]; -// ytmp = x[i][1]; -// ztmp = x[i][2]; -// jlist = firstneigh[i]; -// jnum = numneigh[i]; - double expr[jnum][this->k+12]; - int p = this->k; - int countmb=((this->m)*(this->m+1))>>1; - // calculate interpolation expr, rinvs and dfc, for each neighbor - for (jj = 0; jj < jnum; jj++) { - if (Bij[jj]==false){continue;} -// j = jlist[jj]; -// j &= NEIGHMASK; -// jtype = pair->map[type[j]]; - jtype = tn[jj]; - if (atomtypes[1] != nelements && atomtypes[1] != jtype && atomtypes[2] != nelements && atomtypes[2] != jtype){ - expr[jj][0]=0; - continue; - } -// delx = xtmp - x[j][0]; -// dely = ytmp - x[j][1]; -// delz = ztmp - x[j][2]; - delx=xn[jj]; - dely=yn[jj]; - delz=zn[jj]; - rsq = delx*delx + dely*dely + delz*delz; - if (rsq>rc*rc){ - expr[jj][0]=0; - continue; - } - double r1 = (rsq*((double)res)*cutinv2); - int m1 = (int)r1; - r1 = r1-trunc(r1); - double *p0 = &expcuttable[(m1-1)*this->k]; - double *p1 = &expcuttable[m1*this->k]; - double *p2 = &expcuttable[(m1+1)*this->k]; - double *p3 = &expcuttable[(m1+2)*this->k]; - for (kk=0;kkk;kk++){ - expr[jj][kk] = p1[kk]+0.5*r1*(p2[kk]-p0[kk]+r1*(2.0*p0[kk]-5.0*p1[kk]+4.0*p2[kk]-p3[kk]+r1*(3.0*(p1[kk]-p2[kk])+p3[kk]-p0[kk]))); - expr[jj][kk] *= Sik[jj]; - } - double* q = &dfctable[m1-1]; - double* ri = &rinvsqrttable[m1-1]; - double dfc = q[1] + 0.5 * r1*(q[2] - q[0] + r1*(2.0*q[0] - 5.0*q[1] + 4.0*q[2] - q[3] + r1*(3.0*(q[1] - q[2]) + q[3] - q[0]))); - double rinvs = ri[1] + 0.5 * r1*(ri[2] - ri[0] + r1*(2.0*ri[0] - 5.0*ri[1] + 4.0*ri[2] - ri[3] + r1*(3.0*(ri[1] - ri[2]) + ri[3] - ri[0]))); - - expr[jj][p]=delx*rinvs; - expr[jj][p+1]=dely*rinvs; - expr[jj][p+2]=delz*rinvs; - //Hack to avoid nan when x y or z component of radial vector is exactly 0. Shouldn't affect accuracy. - if (expr[jj][p]*expr[jj][p]<0.000000000001){ - expr[jj][p] = 0.000001; - } - if (expr[jj][p+1]*expr[jj][p+1]<0.000000000001){ - expr[jj][p+1] = 0.000001; - } - if (expr[jj][p+2]*expr[jj][p+2]<0.000000000001){ - expr[jj][p+2] = 0.000001; - } - expr[jj][p+3] = -dfc*expr[jj][p]-dSikx[jj]; - expr[jj][p+4] = rinvs/expr[jj][p]; - expr[jj][p+5] = rinvs*expr[jj][p]; - expr[jj][p+6] = -dfc*expr[jj][p+1]-dSiky[jj]; - expr[jj][p+7] = rinvs/expr[jj][p+1]; - expr[jj][p+8] = rinvs*expr[jj][p+1]; - expr[jj][p+9] = -dfc*expr[jj][p+2]-dSikz[jj]; - expr[jj][p+10] = rinvs/expr[jj][p+2]; - expr[jj][p+11] = rinvs*expr[jj][p+2]; - } - - int kb = this->k; - int mb = this->m; -// int ind = kb+mb*kb; - count = startingneuron; - double Bb[mb]; - double dBbx; - double dBby; - double dBbz; - double dBbx1[mb]; - double dBby1[mb]; - double dBbz1[mb]; - double yprod; - for (mcount=0;mcountcoeffx[mcount]; - int *coeffy = this->coeffy[mcount]; - int *coeffz = this->coeffz[mcount]; - int *coeff = this->coeff[mcount]; - a = mb+1; - for (a1=0;a1map[type[j]]; - jtype = tn[jj]; - if (atomtypes[1] != nelements && atomtypes[1] != jtype){ - continue; - } - double yprod = expr[jj][ai]; - double *y4 = &expr[jj][p]; - for (a2=0;a2map[type[j]]; - jtype = tn[jj]; - if (atomtypes[2] != nelements && atomtypes[2] != jtype){ - continue; - } - double yprod = expr[jj][ai]; - double *y4 = &expr[jj][p]; - for (a2=0;a2map[type[j]]; - jtype = tn[jj]; - if (atomtypes[2] != nelements && atomtypes[2] != jtype){ - continue; - } - double *y3 = &expr[jj][p+3]; - double *y4 = &expr[jj][p]; - ai = n; - yprod = expr[jj][ai]; - for (a2=0;a2map[type[j]]; - jtype = tn[jj]; - if (atomtypes[1] != nelements && atomtypes[1] != jtype){ - continue; - } - double *y3 = &expr[jj][p+3]; - double *y4 = &expr[jj][p]; - ai = n; - yprod = expr[jj][ai]; - for (a2=0;a2map[type[j]]; - jtype = tn[jj]; - if (atomtypes[1] != nelements && atomtypes[1] != jtype){ - continue; - } - double *y3 = &expr[jj][p+3]; - double *y4 = &expr[jj][p]; - ai = n; - yprod = expr[jj][ai]; - for (a2=0;a2sims[sid]; -// double **x = sim->x; - int *type = sim->type; - int nelements = pair->nelements; - int res = pair->res; - double cutmax = pair->cutmax; - double cutinv2 = 1/cutmax/cutmax; - ilist = sim->ilist; -// numneigh = sim->numneigh; -// firstneigh = sim->firstneigh; - i = ilist[ii]; - itype = pair->map[type[i]]; - int f = pair->net[itype].dimensions[0]; -// xtmp = x[i][0]; -// ytmp = x[i][1]; -// ztmp = x[i][2]; -// jlist = firstneigh[i]; -// jnum = numneigh[i]; - double expr[jnum][this->k]; - double y[jnum][3]; - double ri[jnum]; - double dfc[jnum]; - int kb = this->k; - int mb = this->m; - double Bijk[kb][mb]; - double c41[this->k]; - double c51[this->k]; - double c61[this->k]; - double ct[this->k]; - for (jj = 0; jj < jnum; jj++) { - if (Bij[jj]==false){continue;} -// j = jlist[jj]; -// j &= NEIGHMASK; -// jtype = pair->map[type[j]]; - jtype = tn[jj]; - if (jtypes != nelements && jtypes != jtype && ktypes != nelements && ktypes != jtype){ - expr[jj][0]=0; - continue; - } -// delx = xtmp - x[j][0]; -// dely = ytmp - x[j][1]; -// delz = ztmp - x[j][2]; - delx = xn[jj]; - dely = yn[jj]; - delz = zn[jj]; - rsq = delx*delx + dely*dely + delz*delz; - if (rsq>rc*rc){ - expr[jj][0]=0; - continue; - } - double r1 = (rsq*((double)res)*cutinv2); - int m1 = (int)r1; - if (!(m1>=1 && m1 <= res))pair->errorf("Neighbor list is invalid.");//usually results from nan somewhere. - r1 = r1-trunc(r1); - double *p0 = &expcuttable[(m1-1)*this->k]; - double *p1 = &expcuttable[m1*this->k]; - double *p2 = &expcuttable[(m1+1)*this->k]; - double *p3 = &expcuttable[(m1+2)*this->k]; - for (kk=0;kkk;kk++){ - expr[jj][kk] = p1[kk]+0.5*r1*(p2[kk]-p0[kk]+r1*(2.0*p0[kk]-5.0*p1[kk]+4.0*p2[kk]-p3[kk]+r1*(3.0*(p1[kk]-p2[kk])+p3[kk]-p0[kk]))); - expr[jj][kk] *= Sik[jj]; - } - double* q = &dfctable[m1-1]; - double* r2 = &rinvsqrttable[m1-1]; - dfc[jj] = q[1] + 0.5 * r1*(q[2] - q[0] + r1*(2.0*q[0] - 5.0*q[1] + 4.0*q[2] - q[3] + r1*(3.0*(q[1] - q[2]) + q[3] - q[0]))); - ri[jj] = r2[1] + 0.5 * r1*(r2[2] - r2[0] + r1*(2.0*r2[0] - 5.0*r2[1] + 4.0*r2[2] - r2[3] + r1*(3.0*(r2[1] - r2[2]) + r2[3] - r2[0]))); - y[jj][0]=delx*ri[jj]; - y[jj][1]=dely*ri[jj]; - y[jj][2]=delz*ri[jj]; - } - for (jj = 0; jj < jnum; jj++) { - if (Bij[jj]==false){continue;} - if (expr[jj][0]==0)continue; -// j = jlist[jj]; -// j &= NEIGHMASK; -// jtype = pair->map[type[j]]; - jtype =tn[jj]; - if (jtypes != nelements && jtypes != jtype){ - continue; - } - for (n = 0;nk;n++){ - ct[n] = alpha_k[n]/re; - c41[n]=(-ct[n]+dfc[jj])*y[jj][0]+dSikx[jj]; - c51[n]=(-ct[n]+dfc[jj])*y[jj][1]+dSiky[jj]; - c61[n]=(-ct[n]+dfc[jj])*y[jj][2]+dSikz[jj]; - } - for (n=0;nmap[type[k1]]; - ktype = tn[kk]; - if (ktypes != nelements && ktypes != ktype){ - continue; - } - count = startingneuron; - double dot = (y[jj][0]*y[kk][0]+y[jj][1]*y[kk][1]+y[jj][2]*y[kk][2]); - double c1 = ri[jj]*(y[kk][0]-dot*y[jj][0]); - double c2 = ri[jj]*(y[kk][1]-dot*y[jj][1]); - double c3 = ri[jj]*(y[kk][2]-dot*y[jj][2]); - double c10 = ri[kk]*(y[jj][0]-dot*y[kk][0]); - double c11 = ri[kk]*(y[jj][1]-dot*y[kk][1]); - double c12 = ri[kk]*(y[jj][2]-dot*y[kk][2]); - for (n=0;nSik[kk]*pair->Sik[jj]; -// double c4 = c41[n]+4*pair->dSikx[kk]; -// double c5 = c51[n]+4*pair->dSiky[kk]; -// double c6 = c61[n]+4*pair->dSikz[kk]; -// //m=0 -// features[count]+=dot1; -// Bijk[n][0]+=dot1; -// dfeaturesx[jj*f+count]+=dot1*c4; -// dfeaturesy[jj*f+count]+=dot1*c5; -// dfeaturesz[jj*f+count]+=dot1*c6; -// c4*=dot; -// c5*=dot; -// c6*=dot; -// count++; -// for (m=1;mmap[type[k1]]; - ktype = tn[kk]; - if (ktypes != nelements && ktypes != ktype){ - continue; - } - count = startingneuron; - for (n=0;nBij[kk]==false){continue;} -// if (expr[kk][0]==0)continue; -// int k1 = jlist[kk]; -// k1 &= NEIGHMASK; -// ktype = pair->map[type[k1]]; -// if (ktypes != nelements && ktypes != ktype){ -// continue; -// } -// count = startingneuron; -// double dot = (y[jj][0]*y[kk][0]+y[jj][1]*y[kk][1]+y[jj][2]*y[kk][2]); -// double c1 = ri[jj]*(y[kk][0]-dot*y[jj][0]); -// double c2 = ri[jj]*(y[kk][1]-dot*y[jj][1]); -// double c3 = ri[jj]*(y[kk][2]-dot*y[jj][2]); -// double c10 = ri[kk]*(y[jj][0]-dot*y[kk][0]); -// double c11 = ri[kk]*(y[jj][1]-dot*y[kk][1]); -// double c12 = ri[kk]*(y[jj][2]-dot*y[kk][2]); -// for (n=0;nSik[kk]*pair->Sik[jj]; -// double c4 = c41[n]/2; -// double c5 = c51[n]/2; -// double c6 = c61[n]/2; -// double ct2 = -ct[n]/2+dfc[kk]; -// double c42 = ct2*y[kk][0]+pair->dSikx[kk]; -// double c52 = ct2*y[kk][1]+pair->dSiky[kk]; -// double c62 = ct2*y[kk][2]+pair->dSikz[kk]; -// //m=0 -// features[count]+=dot1; -// dfeaturesx[jj*f+count]+=dot1*c4; -// dfeaturesy[jj*f+count]+=dot1*c5; -// dfeaturesz[jj*f+count]+=dot1*c6; -// dfeaturesx[kk*f+count]+=dot1*c42; -// dfeaturesy[kk*f+count]+=dot1*c52; -// dfeaturesz[kk*f+count]+=dot1*c62; -// c4*=dot; -// c5*=dot; -// c6*=dot; -// c42*=dot; -// c52*=dot; -// c62*=dot; -// count++; -// for (m=1;mdoscreen = true; - screen = true; - pair->dospin = true; - spin = true; -} - -Fingerprint_bondscreenedspin::~Fingerprint_bondscreenedspin(){ - delete [] alpha_k; - delete [] atomtypes; - delete [] expcuttable; - delete [] dfctable; - for (int i=0;i<(m*(m+1))>>1;i++){ - delete [] coeff[i]; - delete [] coeffx[i]; - delete [] coeffy[i]; - delete [] coeffz[i]; - delete [] Mf[i]; - } - delete [] coeff; - delete [] coeffx; - delete [] coeffy; - delete [] coeffz; - delete [] Mf; - delete [] rinvsqrttable; -} - -bool Fingerprint_bondscreenedspin::parse_values(char * constant, char * line1){ - char **words=new char *[MAXLINE]; - int nwords,l; - nwords=0; - words[nwords++] = strtok(line1,": ,\t\n"); - while ((words[nwords++] = strtok(NULL,": ,\t\n"))) continue; - nwords -= 1; - if (strcmp(constant,"re")==0){ - re = strtod(words[0],NULL); - } - else if (strcmp(constant,"rc")==0){ - rc = strtod(words[0],NULL); - } - else if (strcmp(constant,"alphak")==0){ - delete [] alpha_k; - alpha_k = new double [nwords]; - for (l=0;lerrorf("Undefined value for bond power"); - delete [] words; - if (re!=0.0 && rc!=0.0 && alpha_k[0]!=-1 && dr!=0.0 && m!=0 && k!=0)return true; - return false; -} - -void Fingerprint_bondscreenedspin::write_values(FILE *fid){ - int i; - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:re:\n",style,id); - fprintf(fid,"%f\n",re); - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:rc:\n",style,id); - fprintf(fid,"%f\n",rc); - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:alphak:\n",style,id); - for (i=0;ielementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:dr:\n",style,id); - fprintf(fid,"%f\n",dr); - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:k:\n",style,id); - fprintf(fid,"%d\n",k); - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:m:\n",style,id); - fprintf(fid,"%d\n",m); -} - -void Fingerprint_bondscreenedspin::init(int *i,int id){ - for (int j=0;jk = 0; - alpha_k = new double [1]; - alpha_k[0]=-1; - empty = false; - this->id = id; -} - -//number of neurons defined by this fingerprint -int Fingerprint_bondscreenedspin::get_length(){ - return m*k; -} - -void Fingerprint_bondscreenedspin::allocate(){ - generate_exp_cut_table(); - generate_coefficients(); - generate_rinvssqrttable(); -} - -//Generate table of complex functions for quick reference during compute. Used by do3bodyfeatureset_singleneighborloop and do3bodyfeatureset_doubleneighborloop. -void Fingerprint_bondscreenedspin::generate_exp_cut_table(){ - int m,n; - double r1; - int buf = 5; - int res = pair->res; - double cutmax = pair->cutmax; - expcuttable = new double [(res+buf)*(this->k)]; - dfctable = new double [res+buf]; - for (m=0;m<(res+buf);m++){ - r1 = cutmax*cutmax*(double)(m)/(double)(res); - for (n=0;n<(this->k);n++){ - expcuttable[n+m*(this->k)] = exp(-alpha_k[n]/re*sqrt(r1))*cutofffunction(sqrt(r1),rc,dr); - } - if (sqrt(r1)>=rc || sqrt(r1) <= (rc-dr)){ - dfctable[m]=0; - } - else{ - dfctable[m]=-8*pow(1-(rc-sqrt(r1))/dr,3)/dr/(1-pow(1-(rc-sqrt(r1))/dr,4)); - } - } -} - - -//Generate table of complex functions for quick reference during compute. Used by do3bodyfeatureset_singleneighborloop. -void Fingerprint_bondscreenedspin::generate_coefficients(){ //calculates multinomial coefficient for each term - int p,mb,mc; - int n,p1,i1; - mb = this->m; - mc=(mb*(mb+1))>>1; - coeff = new int *[mc]; - coeffx = new int *[mc]; - coeffy = new int *[mc]; - coeffz = new int *[mc]; - for (p=0;pm+1]; - for (p=0;pm+1;p++){ - M[p]=0; - } - for (p1=0;p1sims[sid]; -// ilist = sim->ilist; -// numneigh = sim->numneigh; -// i = ilist[ii]; -// jnum = numneigh[i]; - //select the more efficient algorithm for this particular potential and environment. - if (jnum*2>(m+1)*m*20){ - do3bodyfeatureset_singleneighborloop(features,dfeaturesx,dfeaturesy,dfeaturesz,dspinx,dspiny,dspinz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,sid,xn,yn,zn,tn,jnum,jl); - } - else{ - do3bodyfeatureset_doubleneighborloop(features,dfeaturesx,dfeaturesy,dfeaturesz,dspinx,dspiny,dspinz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,sid,xn,yn,zn,tn,jnum,jl); - - } -} - -//Called by do3bodyfeatureset. Algorithm for high neighbor numbers and small series of bond angle powers -void Fingerprint_bondscreenedspin::do3bodyfeatureset_singleneighborloop(double * features,double * dfeaturesx,double *dfeaturesy,double *dfeaturesz, double *dspinx, double *dspiny, double *dspinz,double *Sik, double *dSikx, double*dSiky, double *dSikz, double *dSijkx, double *dSijky, double *dSijkz, bool *Bij, int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl){ - int i,j,jj,itype,jtype,kk,m,n,mcount,a,a1,a2,ai; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *ilist,*jlist,*numneigh,**firstneigh; - int count=0; - PairRANN::Simulation *sim = &pair->sims[sid]; -// double **x = sim->x; - //double **f = atom->f; - int *type = sim->type; - double cutmax = pair->cutmax; - int res = pair->res; - double cutinv2 = 1/cutmax/cutmax; - ilist = sim->ilist; -// numneigh = sim->numneigh; -// firstneigh = sim->firstneigh; - int nelements=pair->nelements; - i = ilist[ii]; - itype = pair->map[type[i]]; - int f = pair->net[itype].dimensions[0]; -// xtmp = x[i][0]; -// ytmp = x[i][1]; -// ztmp = x[i][2]; -// jlist = firstneigh[i]; -// jnum = numneigh[i]; - double expr[jnum][this->k+12]; - int p = this->k; - int countmb=((this->m)*(this->m+1))>>1; - double *si = sim->s[i]; - // calculate interpolation expr, rinvs and dfc, for each neighbor - for (jj = 0; jj < jnum; jj++) { - if (Bij[jj]==false){continue;} -// j = jlist[jj]; -// j &= NEIGHMASK; -// jtype = pair->map[type[j]]; - jtype = tn[jj]; - if (atomtypes[1] != nelements && atomtypes[1] != jtype && atomtypes[2] != nelements && atomtypes[2] != jtype){ - expr[jj][0]=0; - continue; - } -// delx = xtmp - x[j][0]; -// dely = ytmp - x[j][1]; -// delz = ztmp - x[j][2]; - delx=xn[jj]; - dely=yn[jj]; - delz=zn[jj]; - rsq = delx*delx + dely*dely + delz*delz; - if (rsq>rc*rc){ - expr[jj][0]=0; - continue; - } - double r1 = (rsq*((double)res)*cutinv2); - int m1 = (int)r1; - r1 = r1-trunc(r1); - double *p0 = &expcuttable[(m1-1)*this->k]; - double *p1 = &expcuttable[m1*this->k]; - double *p2 = &expcuttable[(m1+1)*this->k]; - double *p3 = &expcuttable[(m1+2)*this->k]; - for (kk=0;kkk;kk++){ - expr[jj][kk] = p1[kk]+0.5*r1*(p2[kk]-p0[kk]+r1*(2.0*p0[kk]-5.0*p1[kk]+4.0*p2[kk]-p3[kk]+r1*(3.0*(p1[kk]-p2[kk])+p3[kk]-p0[kk]))); - expr[jj][kk] *= Sik[jj]; - } - double* q = &dfctable[m1-1]; - double* ri = &rinvsqrttable[m1-1]; - double dfc = q[1] + 0.5 * r1*(q[2] - q[0] + r1*(2.0*q[0] - 5.0*q[1] + 4.0*q[2] - q[3] + r1*(3.0*(q[1] - q[2]) + q[3] - q[0]))); - double rinvs = ri[1] + 0.5 * r1*(ri[2] - ri[0] + r1*(2.0*ri[0] - 5.0*ri[1] + 4.0*ri[2] - ri[3] + r1*(3.0*(ri[1] - ri[2]) + ri[3] - ri[0]))); - - expr[jj][p]=delx*rinvs; - expr[jj][p+1]=dely*rinvs; - expr[jj][p+2]=delz*rinvs; - //Hack to avoid nan when x y or z component of radial vector is exactly 0. Shouldn't affect accuracy. - if (expr[jj][p]*expr[jj][p]<0.000000000001){ - expr[jj][p] = 0.000001; - } - if (expr[jj][p+1]*expr[jj][p+1]<0.000000000001){ - expr[jj][p+1] = 0.000001; - } - if (expr[jj][p+2]*expr[jj][p+2]<0.000000000001){ - expr[jj][p+2] = 0.000001; - } - expr[jj][p+3] = -dfc*expr[jj][p]-dSikx[jj]; - expr[jj][p+4] = rinvs/expr[jj][p]; - expr[jj][p+5] = rinvs*expr[jj][p]; - expr[jj][p+6] = -dfc*expr[jj][p+1]-dSiky[jj]; - expr[jj][p+7] = rinvs/expr[jj][p+1]; - expr[jj][p+8] = rinvs*expr[jj][p+1]; - expr[jj][p+9] = -dfc*expr[jj][p+2]-dSikz[jj]; - expr[jj][p+10] = rinvs/expr[jj][p+2]; - expr[jj][p+11] = rinvs*expr[jj][p+2]; - } - - int kb = this->k; - int mb = this->m; -// int ind = kb+mb*kb; - count = startingneuron; - double Bb[mb]; - double Bbs[mb]; - double dBbx; - double dBby; - double dBbz; -// double dBbx1[mb]; -// double dBby1[mb]; -// double dBbz1[mb]; - double yprod; - for (mcount=0;mcountcoeffx[mcount]; - int *coeffy = this->coeffy[mcount]; - int *coeffz = this->coeffz[mcount]; - int *coeff = this->coeff[mcount]; - a = mb+1; - for (a1=0;a1map[type[j]]; - jtype = tn[jj]; - if (atomtypes[1] != nelements && atomtypes[1] != jtype){ - continue; - } - j = jl[jj]; - double *sj = sim->s[j]; - double sp = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; - double yprod = expr[jj][ai]; - double *y4 = &expr[jj][p]; - for (a2=0;a2map[type[j]]; - jtype = tn[jj]; - if (atomtypes[2] != nelements && atomtypes[2] != jtype){ - continue; - } - j = jl[jj]; - double *sj = sim->s[j]; - double sp = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; - double yprod = expr[jj][ai]; - double *y4 = &expr[jj][p]; - for (a2=0;a2map[type[j]]; - jtype = tn[jj]; - if (atomtypes[2] != nelements && atomtypes[2] != jtype){ - continue; - } - j = jl[jj]; - double *sj = sim->s[j]; - double sp = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; - double *y3 = &expr[jj][p+3]; - double *y4 = &expr[jj][p]; - ai = n; - yprod = expr[jj][ai]; - for (a2=0;a2map[type[j]]; - jtype = tn[jj]; - if (atomtypes[1] != nelements && atomtypes[1] != jtype){ - continue; - } - j = jl[jj]; - double *sj = sim->s[j]; - double sp = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; - double *y3 = &expr[jj][p+3]; - double *y4 = &expr[jj][p]; - ai = n; - yprod = expr[jj][ai]; - for (a2=0;a2map[type[j]]; - jtype = tn[jj]; - if (atomtypes[1] != nelements && atomtypes[1] != jtype){ - continue; - } - j = jl[jj]; - double *sj = sim->s[j]; - double sp = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; - double *y3 = &expr[jj][p+3]; - double *y4 = &expr[jj][p]; - ai = n; - yprod = expr[jj][ai]; - for (a2=0;a2sims[sid]; -// double **x = sim->x; - int *type = sim->type; - int nelements = pair->nelements; - int res = pair->res; - double cutmax = pair->cutmax; - double cutinv2 = 1/cutmax/cutmax; - ilist = sim->ilist; -// numneigh = sim->numneigh; -// firstneigh = sim->firstneigh; - i = ilist[ii]; - itype = pair->map[type[i]]; - int f = pair->net[itype].dimensions[0]; -// xtmp = x[i][0]; -// ytmp = x[i][1]; -// ztmp = x[i][2]; -// jlist = firstneigh[i]; -// jnum = numneigh[i]; - double expr[jnum][this->k]; - double y[jnum][3]; - double ri[jnum]; - double dfc[jnum]; - int kb = this->k; - int mb = this->m; - double Bijk[kb][mb]; - double c41[this->k]; - double c51[this->k]; - double c61[this->k]; - double ct[this->k]; - double *si = sim->s[i]; - for (jj = 0; jj < jnum; jj++) { - if (Bij[jj]==false){continue;} -// j = jlist[jj]; -// j &= NEIGHMASK; -// jtype = pair->map[type[j]]; - jtype = tn[jj]; - if (jtypes != nelements && jtypes != jtype && ktypes != nelements && ktypes != jtype){ - expr[jj][0]=0; - continue; - } -// delx = xtmp - x[j][0]; -// dely = ytmp - x[j][1]; -// delz = ztmp - x[j][2]; - delx = xn[jj]; - dely = yn[jj]; - delz = zn[jj]; - rsq = delx*delx + dely*dely + delz*delz; - if (rsq>rc*rc){ - expr[jj][0]=0; - continue; - } - double r1 = (rsq*((double)res)*cutinv2); - int m1 = (int)r1; - if (!(m1>=1 && m1 <= res))pair->errorf("Neighbor list is invalid.");//usually results from nan somewhere. - r1 = r1-trunc(r1); - double *p0 = &expcuttable[(m1-1)*this->k]; - double *p1 = &expcuttable[m1*this->k]; - double *p2 = &expcuttable[(m1+1)*this->k]; - double *p3 = &expcuttable[(m1+2)*this->k]; - for (kk=0;kkk;kk++){ - expr[jj][kk] = p1[kk]+0.5*r1*(p2[kk]-p0[kk]+r1*(2.0*p0[kk]-5.0*p1[kk]+4.0*p2[kk]-p3[kk]+r1*(3.0*(p1[kk]-p2[kk])+p3[kk]-p0[kk]))); - expr[jj][kk] *= Sik[jj]; - } - double* q = &dfctable[m1-1]; - double* r2 = &rinvsqrttable[m1-1]; - dfc[jj] = q[1] + 0.5 * r1*(q[2] - q[0] + r1*(2.0*q[0] - 5.0*q[1] + 4.0*q[2] - q[3] + r1*(3.0*(q[1] - q[2]) + q[3] - q[0]))); - ri[jj] = r2[1] + 0.5 * r1*(r2[2] - r2[0] + r1*(2.0*r2[0] - 5.0*r2[1] + 4.0*r2[2] - r2[3] + r1*(3.0*(r2[1] - r2[2]) + r2[3] - r2[0]))); - y[jj][0]=delx*ri[jj]; - y[jj][1]=dely*ri[jj]; - y[jj][2]=delz*ri[jj]; - } - for (jj = 0; jj < jnum; jj++) { - if (Bij[jj]==false){continue;} - if (expr[jj][0]==0)continue; -// j = jlist[jj]; -// j &= NEIGHMASK; -// jtype = pair->map[type[j]]; - jtype =tn[jj]; - if (jtypes != nelements && jtypes != jtype){ - continue; - } - j = jl[jj]; - double *sj = sim->s[j]; - double spj = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; - for (n = 0;nk;n++){ - ct[n] = alpha_k[n]/re; - c41[n]=(-ct[n]+dfc[jj])*y[jj][0]+dSikx[jj]; - c51[n]=(-ct[n]+dfc[jj])*y[jj][1]+dSiky[jj]; - c61[n]=(-ct[n]+dfc[jj])*y[jj][2]+dSikz[jj]; - } - for (n=0;nmap[type[k1]]; - ktype = tn[kk]; - if (ktypes != nelements && ktypes != ktype){ - continue; - } - j = jl[kk]; - double *sk = sim->s[j]; - double spk = si[0]*sk[0]+si[1]*sk[1]+si[2]*sk[2]; - count = startingneuron; - double dot = (y[jj][0]*y[kk][0]+y[jj][1]*y[kk][1]+y[jj][2]*y[kk][2]); - double c1 = ri[jj]*(y[kk][0]-dot*y[jj][0]); - double c2 = ri[jj]*(y[kk][1]-dot*y[jj][1]); - double c3 = ri[jj]*(y[kk][2]-dot*y[jj][2]); - double c10 = ri[kk]*(y[jj][0]-dot*y[kk][0]); - double c11 = ri[kk]*(y[jj][1]-dot*y[kk][1]); - double c12 = ri[kk]*(y[jj][2]-dot*y[kk][2]); - for (n=0;nSik[kk]*pair->Sik[jj]; -// double c4 = c41[n]+4*pair->dSikx[kk]; -// double c5 = c51[n]+4*pair->dSiky[kk]; -// double c6 = c61[n]+4*pair->dSikz[kk]; -// //m=0 -// features[count]+=dot1; -// Bijk[n][0]+=dot1; -// dfeaturesx[jj*f+count]+=dot1*c4; -// dfeaturesy[jj*f+count]+=dot1*c5; -// dfeaturesz[jj*f+count]+=dot1*c6; -// c4*=dot; -// c5*=dot; -// c6*=dot; -// count++; -// for (m=1;mmap[type[k1]]; - ktype = tn[kk]; - if (ktypes != nelements && ktypes != ktype){ - continue; - } - count = startingneuron; - for (n=0;nBij[kk]==false){continue;} -// if (expr[kk][0]==0)continue; -// int k1 = jlist[kk]; -// k1 &= NEIGHMASK; -// ktype = pair->map[type[k1]]; -// if (ktypes != nelements && ktypes != ktype){ -// continue; -// } -// count = startingneuron; -// double dot = (y[jj][0]*y[kk][0]+y[jj][1]*y[kk][1]+y[jj][2]*y[kk][2]); -// double c1 = ri[jj]*(y[kk][0]-dot*y[jj][0]); -// double c2 = ri[jj]*(y[kk][1]-dot*y[jj][1]); -// double c3 = ri[jj]*(y[kk][2]-dot*y[jj][2]); -// double c10 = ri[kk]*(y[jj][0]-dot*y[kk][0]); -// double c11 = ri[kk]*(y[jj][1]-dot*y[kk][1]); -// double c12 = ri[kk]*(y[jj][2]-dot*y[kk][2]); -// for (n=0;nSik[kk]*pair->Sik[jj]; -// double c4 = c41[n]/2; -// double c5 = c51[n]/2; -// double c6 = c61[n]/2; -// double ct2 = -ct[n]/2+dfc[kk]; -// double c42 = ct2*y[kk][0]+pair->dSikx[kk]; -// double c52 = ct2*y[kk][1]+pair->dSiky[kk]; -// double c62 = ct2*y[kk][2]+pair->dSikz[kk]; -// //m=0 -// features[count]+=dot1; -// dfeaturesx[jj*f+count]+=dot1*c4; -// dfeaturesy[jj*f+count]+=dot1*c5; -// dfeaturesz[jj*f+count]+=dot1*c6; -// dfeaturesx[kk*f+count]+=dot1*c42; -// dfeaturesy[kk*f+count]+=dot1*c52; -// dfeaturesz[kk*f+count]+=dot1*c62; -// c4*=dot; -// c5*=dot; -// c6*=dot; -// c42*=dot; -// c52*=dot; -// c62*=dot; -// count++; -// for (m=1;mallscreen = false; - pair->dospin = true; - spin = true; -} - -Fingerprint_bondspin::~Fingerprint_bondspin(){ - delete [] alpha_k; - delete [] atomtypes; - delete [] expcuttable; - delete [] dfctable; - for (int i=0;i<(m*(m+1))>>1;i++){ - delete [] coeff[i]; - delete [] coeffx[i]; - delete [] coeffy[i]; - delete [] coeffz[i]; - delete [] Mf[i]; - } - delete [] coeff; - delete [] coeffx; - delete [] coeffy; - delete [] coeffz; - delete [] Mf; - delete [] rinvsqrttable; -} - -bool Fingerprint_bondspin::parse_values(char * constant, char * line1){ - char **words=new char *[MAXLINE]; - int nwords,l; - nwords=0; - words[nwords++] = strtok(line1,": ,\t\n"); - while ((words[nwords++] = strtok(NULL,": ,\t\n"))) continue; - nwords -= 1; - if (strcmp(constant,"re")==0){ - re = strtod(words[0],NULL); - } - else if (strcmp(constant,"rc")==0){ - rc = strtod(words[0],NULL); - } - else if (strcmp(constant,"alphak")==0){ - delete [] alpha_k; - alpha_k = new double [nwords]; - for (l=0;lerrorf("Undefined value for bond power"); - delete [] words; - if (re!=0.0 && rc!=0.0 && alpha_k[0]!=-1 && dr!=0.0 && m!=0 && k!=0)return true; - return false; -} - -void Fingerprint_bondspin::write_values(FILE *fid){ - int i; - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:re:\n",style,id); - fprintf(fid,"%f\n",re); - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:rc:\n",style,id); - fprintf(fid,"%f\n",rc); - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:alphak:\n",style,id); - for (i=0;ielementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:dr:\n",style,id); - fprintf(fid,"%f\n",dr); - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:k:\n",style,id); - fprintf(fid,"%d\n",k); - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:m:\n",style,id); - fprintf(fid,"%d\n",m); -} - -void Fingerprint_bondspin::init(int *i,int id){ - for (int j=0;jk = 0; - alpha_k = new double [1]; - alpha_k[0]=-1; - empty = false; - this->id = id; -} - -//number of neurons defined by this fingerprint -int Fingerprint_bondspin::get_length(){ - return m*k; -} - -void Fingerprint_bondspin::allocate(){ - generate_exp_cut_table(); - generate_coefficients(); - generate_rinvssqrttable(); -} - -//Generate table of complex functions for quick reference during compute. Used by do3bodyfeatureset_singleneighborloop and do3bodyfeatureset_doubleneighborloop. -void Fingerprint_bondspin::generate_exp_cut_table(){ - int m,n; - double r1; - int buf = 5; - int res = pair->res; - double cutmax = pair->cutmax; - expcuttable = new double [(res+buf)*(this->k)]; - dfctable = new double [res+buf]; - for (m=0;m<(res+buf);m++){ - r1 = cutmax*cutmax*(double)(m)/(double)(res); - for (n=0;n<(this->k);n++){ - expcuttable[n+m*(this->k)] = exp(-alpha_k[n]/re*sqrt(r1))*cutofffunction(sqrt(r1),rc,dr); - } - if (sqrt(r1)>=rc || sqrt(r1) <= (rc-dr)){ - dfctable[m]=0; - } - else{ - dfctable[m]=-8*pow(1-(rc-sqrt(r1))/dr,3)/dr/(1-pow(1-(rc-sqrt(r1))/dr,4)); - } - } -} - -//Generate table of complex functions for quick reference during compute. Used by do3bodyfeatureset_singleneighborloop. -void Fingerprint_bondspin::generate_coefficients(){ //calculates multinomial coefficient for each term - int p,mb,mc; - int n,p1,i1; - mb = this->m; - mc=(mb*(mb+1))>>1; - coeff = new int *[mc]; - coeffx = new int *[mc]; - coeffy = new int *[mc]; - coeffz = new int *[mc]; - for (p=0;pm+1]; - for (p=0;pm+1;p++){ - M[p]=0; - } - for (p1=0;p1sims[sid]; - ilist = sim->ilist; - numneigh = sim->numneigh; - i = ilist[ii]; -// jnum = numneigh[i]; - //select the more efficient algorithm for this particular potential and environment. - - if (jnum*2>(m+1)*m*20){ - do3bodyfeatureset_singleneighborloop(features,dfeaturesx,dfeaturesy,dfeaturesz,dspinx,dspiny,dspinz,ii,sid,xn,yn,zn,tn,jnum,jl); - } - else{ - do3bodyfeatureset_doubleneighborloop(features,dfeaturesx,dfeaturesy,dfeaturesz,dspinx,dspiny,dspinz,ii,sid,xn,yn,zn,tn,jnum,jl); - } -} - -//Called by do3bodyfeatureset. Algorithm for high neighbor numbers and small series of bond angle powers -void Fingerprint_bondspin::do3bodyfeatureset_singleneighborloop(double * features,double * dfeaturesx,double *dfeaturesy,double *dfeaturesz,double * dspinx,double *dspiny,double *dspinz,int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl){ - int i,j,jj,itype,jtype,kk,m,n,mcount,a,a1,a2,ai; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *ilist,*jlist,*numneigh,**firstneigh; - int count=0; - PairRANN::Simulation *sim = &pair->sims[sid]; -// double **x = sim->x; - int *type = sim->type; - double cutmax = pair->cutmax; - int res = pair->res; - double cutinv2 = 1/cutmax/cutmax; - ilist = sim->ilist; -// numneigh = sim->numneigh; -// firstneigh = sim->firstneigh; - int nelements=pair->nelements; - i = ilist[ii]; - itype = pair->map[type[i]]; - int f = pair->net[itype].dimensions[0]; -// xtmp = x[i][0]; -// ytmp = x[i][1]; -// ztmp = x[i][2]; -// jlist = firstneigh[i]; -// jnum = numneigh[i]; - double expr[jnum][this->k+12]; - int p = this->k; - int countmb=((this->m)*(this->m+1))>>1; - double *si = sim->s[i]; - // calculate interpolation expr, rinvs and dfc, for each neighbor - for (jj = 0; jj < jnum; jj++) { -// j = jlist[jj]; -// j &= NEIGHMASK; -// jtype = pair->map[type[j]]; - jtype = tn[jj]; - if (atomtypes[1] != nelements && atomtypes[1] != jtype && atomtypes[2] != nelements && atomtypes[2] != jtype){ - expr[jj][0]=0; - continue; - } -// delx = xtmp - x[j][0]; -// dely = ytmp - x[j][1]; -// delz = ztmp - x[j][2]; - delx = xn[jj]; - dely = yn[jj]; - delz = zn[jj]; - rsq = delx*delx + dely*dely + delz*delz; - if (rsq>rc*rc){ - expr[jj][0]=0; - continue; - } - double r1 = (rsq*((double)res)*cutinv2); - int m1 = (int)r1; - r1 = r1-trunc(r1); - double *p0 = &expcuttable[(m1-1)*this->k]; - double *p1 = &expcuttable[m1*this->k]; - double *p2 = &expcuttable[(m1+1)*this->k]; - double *p3 = &expcuttable[(m1+2)*this->k]; - for (kk=0;kkk;kk++){ - expr[jj][kk] = p1[kk]+0.5*r1*(p2[kk]-p0[kk]+r1*(2.0*p0[kk]-5.0*p1[kk]+4.0*p2[kk]-p3[kk]+r1*(3.0*(p1[kk]-p2[kk])+p3[kk]-p0[kk]))); - } - double* q = &dfctable[m1-1]; - double* ri = &rinvsqrttable[m1-1]; - double dfc = q[1] + 0.5 * r1*(q[2] - q[0] + r1*(2.0*q[0] - 5.0*q[1] + 4.0*q[2] - q[3] + r1*(3.0*(q[1] - q[2]) + q[3] - q[0]))); - double rinvs = ri[1] + 0.5 * r1*(ri[2] - ri[0] + r1*(2.0*ri[0] - 5.0*ri[1] + 4.0*ri[2] - ri[3] + r1*(3.0*(ri[1] - ri[2]) + ri[3] - ri[0]))); - - expr[jj][p]=delx*rinvs; - expr[jj][p+1]=dely*rinvs; - expr[jj][p+2]=delz*rinvs; - //Hack to avoid nan when x y or z component of radial vector is exactly 0. Shouldn't affect accuracy. - if (expr[jj][p]*expr[jj][p]<0.000000000001){ - expr[jj][p] = 0.000001; - } - if (expr[jj][p+1]*expr[jj][p+1]<0.000000000001){ - expr[jj][p+1] = 0.000001; - } - if (expr[jj][p+2]*expr[jj][p+2]<0.000000000001){ - expr[jj][p+2] = 0.000001; - } - expr[jj][p+3] = -dfc*expr[jj][p]; - expr[jj][p+4] = rinvs/expr[jj][p]; - expr[jj][p+5] = rinvs*expr[jj][p]; - expr[jj][p+6] = -dfc*expr[jj][p+1]; - expr[jj][p+7] = rinvs/expr[jj][p+1]; - expr[jj][p+8] = rinvs*expr[jj][p+1]; - expr[jj][p+9] = -dfc*expr[jj][p+2]; - expr[jj][p+10] = rinvs/expr[jj][p+2]; - expr[jj][p+11] = rinvs*expr[jj][p+2]; - } - - int kb = this->k; - int mb = this->m; - count = startingneuron; - double Bb[mb]; - double Bbs[mb]; - double dBbx; - double dBby; - double dBbz; -// double dBbx1[mb]; -// double dBby1[mb]; -// double dBbz1[mb]; - double yprod; - for (mcount=0;mcountcoeffx[mcount]; - int *coeffy = this->coeffy[mcount]; - int *coeffz = this->coeffz[mcount]; - int *coeff = this->coeff[mcount]; - a = mb+1; - for (a1=0;a1map[type[j]]; - jtype = tn[jj]; - if (atomtypes[1] != nelements && atomtypes[1] != jtype){ - continue; - } - j = jl[jj]; - double *sj = sim->s[j]; - double sp = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; - double yprod = expr[jj][ai]; - double *y4 = &expr[jj][p]; - for (a2=0;a2map[type[j]]; - jtype = tn[jj]; - if (atomtypes[2] != nelements && atomtypes[2] != jtype){ - continue; - } - j = jl[jj]; - double *sj = sim->s[j]; - double sp = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; - double yprod = expr[jj][ai]; - double *y4 = &expr[jj][p]; - for (a2=0;a2map[type[j]]; - jtype = tn[jj]; - if (atomtypes[2] != nelements && atomtypes[2] != jtype){ - continue; - } - j = jl[jj]; - double *sj = sim->s[j]; - double sp = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; - double *y3 = &expr[jj][p+3]; - double *y4 = &expr[jj][p]; - ai = n; - yprod = expr[jj][ai]; - for (a2=0;a2map[type[j]]; - jtype = tn[jj]; - if (atomtypes[1] != nelements && atomtypes[1] != jtype){ - continue; - } - j = jl[jj]; - double *sj = sim->s[j]; - double sp = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; - double *y3 = &expr[jj][p+3]; - double *y4 = &expr[jj][p]; - ai = n; - yprod = expr[jj][ai]; - for (a2=0;a2map[type[j]]; - jtype = tn[jj]; - if (atomtypes[1] != nelements && atomtypes[1] != jtype){ - continue; - } - j = jl[jj]; - double *sj = sim->s[j]; - double sp = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; - double *y3 = &expr[jj][p+3]; - double *y4 = &expr[jj][p]; - ai = n; - yprod = expr[jj][ai]; - for (a2=0;a2sims[sid]; - double **x = sim->x; - int *type = sim->type; - int nelements = pair->nelements; - int res = pair->res; - double cutmax = pair->cutmax; - double cutinv2 = 1/cutmax/cutmax; - ilist = sim->ilist; -// numneigh = sim->numneigh; -// firstneigh = sim->firstneigh; - i = ilist[ii]; - itype = pair->map[type[i]]; - int f = pair->net[itype].dimensions[0]; -// xtmp = x[i][0]; -// ytmp = x[i][1]; -// ztmp = x[i][2]; -// jlist = firstneigh[i]; -// jnum = numneigh[i]; - double expr[jnum][this->k]; - double y[jnum][3]; - double ri[jnum]; - double dfc[jnum]; - int kb = this->k; - int mb = this->m; - double c41[this->k]; - double c51[this->k]; - double c61[this->k]; - double ct[this->k]; - double *si = sim->s[i]; - for (jj = 0; jj < jnum; jj++) { -// j = jlist[jj]; -// j &= NEIGHMASK; -// jtype = pair->map[type[j]]; - jtype = tn[jj]; - if (jtypes != nelements && jtypes != jtype && ktypes != nelements && ktypes != jtype){ - expr[jj][0]=0; - continue; - } -// delx = xtmp - x[j][0]; -// dely = ytmp - x[j][1]; -// delz = ztmp - x[j][2]; - delx = xn[jj]; - dely = yn[jj]; - delz = zn[jj]; - rsq = delx*delx + dely*dely + delz*delz; - if (rsq>rc*rc){ - expr[jj][0]=0; - continue; - } -// j = jl[jj]; -// double *sj = sim->s[j]; -// double sp = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; - double r1 = (rsq*((double)res)*cutinv2); - int m1 = (int)r1; - if (!(m1>=1 && m1 <= res))pair->errorf("Neighbor list is invalid.");//usually results from nan somewhere. - r1 = r1-trunc(r1); - double *p0 = &expcuttable[(m1-1)*this->k]; - double *p1 = &expcuttable[m1*this->k]; - double *p2 = &expcuttable[(m1+1)*this->k]; - double *p3 = &expcuttable[(m1+2)*this->k]; - for (kk=0;kkk;kk++){ - expr[jj][kk] = p1[kk]+0.5*r1*(p2[kk]-p0[kk]+r1*(2.0*p0[kk]-5.0*p1[kk]+4.0*p2[kk]-p3[kk]+r1*(3.0*(p1[kk]-p2[kk])+p3[kk]-p0[kk]))); -// expr[jj][kk]*= sp; - } - double* q = &dfctable[m1-1]; - double* r2 = &rinvsqrttable[m1-1]; - dfc[jj] = q[1] + 0.5 * r1*(q[2] - q[0] + r1*(2.0*q[0] - 5.0*q[1] + 4.0*q[2] - q[3] + r1*(3.0*(q[1] - q[2]) + q[3] - q[0]))); - ri[jj] = r2[1] + 0.5 * r1*(r2[2] - r2[0] + r1*(2.0*r2[0] - 5.0*r2[1] + 4.0*r2[2] - r2[3] + r1*(3.0*(r2[1] - r2[2]) + r2[3] - r2[0]))); - y[jj][0]=delx*ri[jj]; - y[jj][1]=dely*ri[jj]; - y[jj][2]=delz*ri[jj]; - } -// if (i==5){ -// for (jj=0;jjmap[type[j]]; - jtype = tn[jj]; - if (jtypes != nelements && jtypes != jtype){ - continue; - } - j = jl[jj]; - double *sj = sim->s[j]; - double spj = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; - for (n = 0;nk;n++){ - ct[n] = 2*alpha_k[n]/re; - c41[n]=(-ct[n]+2*dfc[jj])*y[jj][0]; - c51[n]=(-ct[n]+2*dfc[jj])*y[jj][1]; - c61[n]= (-ct[n]+2*dfc[jj])*y[jj][2]; - } - if (jtypes==ktypes){ - for (kk=jj+1;kk< jnum; kk++){ - if (expr[kk][0]==0)continue; -// int k1 = jlist[kk]; -// k1 &= NEIGHMASK; -// ktype = pair->map[type[k1]]; - ktype = tn[kk]; - if (ktypes != nelements && ktypes != ktype){ - continue; - } - j = jl[kk]; - double *sk = sim->s[j]; - double spk = si[0]*sk[0]+si[1]*sk[1]+si[2]*sk[2]; - count = startingneuron; - double dot = (y[jj][0]*y[kk][0]+y[jj][1]*y[kk][1]+y[jj][2]*y[kk][2]); - double c1 = 2*ri[jj]*(y[kk][0]-dot*y[jj][0]); - double c2 = 2*ri[jj]*(y[kk][1]-dot*y[jj][1]); - double c3 = 2*ri[jj]*(y[kk][2]-dot*y[jj][2]); - double c10 = 2*ri[kk]*(y[jj][0]-dot*y[kk][0]); - double c11 = 2*ri[kk]*(y[jj][1]-dot*y[kk][1]); - double c12 = 2*ri[kk]*(y[jj][2]-dot*y[kk][2]); -// double c1 = 2*ri[jj]*y[kk][0]*(1-y[jj][0]*y[jj][0]); -// double c2 = 2*ri[jj]*y[kk][1]*(1-y[jj][1]*y[jj][1]); -// double c3 = 2*ri[jj]*y[kk][2]*(1-y[jj][2]*y[jj][2]); -// double c10 = 2*ri[kk]*y[jj][0]*(1-y[kk][0]*y[kk][0]); -// double c11 = 2*ri[kk]*y[jj][1]*(1-y[kk][1]*y[kk][1]); -// double c12 = 2*ri[kk]*y[jj][2]*(1-y[kk][2]*y[kk][2]); - for (n=0;nmap[type[k1]]; - ktype = tn[kk]; - if (ktypes != nelements && ktypes != ktype){ - continue; - } - j = jl[kk]; - double *sk = sim->s[j]; - double spk = si[0]*sk[0]+si[1]*sk[1]+si[2]*sk[2]; - count = startingneuron; - double dot = (y[jj][0]*y[kk][0]+y[jj][1]*y[kk][1]+y[jj][2]*y[kk][2]); - double c1 = ri[jj]*(y[kk][0]-dot*y[jj][0]); - double c2 = ri[jj]*(y[kk][1]-dot*y[jj][1]); - double c3 = ri[jj]*(y[kk][2]-dot*y[jj][2]); - double c10 = ri[kk]*(y[jj][0]-dot*y[kk][0]); - double c11 = ri[kk]*(y[jj][1]-dot*y[kk][1]); - double c12 = ri[kk]*(y[jj][2]-dot*y[kk][2]); -// double c1 = 2*ri[jj]*y[kk][0]*(1-y[jj][0]*y[jj][0]); -// double c2 = 2*ri[jj]*y[kk][1]*(1-y[jj][1]*y[jj][1]); -// double c3 = 2*ri[jj]*y[kk][2]*(1-y[jj][2]*y[jj][2]); -// double c10 = 2*ri[kk]*y[jj][0]*(1-y[kk][0]*y[kk][0]); -// double c11 = 2*ri[kk]*y[jj][1]*(1-y[kk][1]*y[kk][1]); -// double c12 = 2*ri[kk]*y[jj][2]*(1-y[kk][2]*y[kk][2]); - for (n=0;nallscreen = false; -} - -Fingerprint_radial::~Fingerprint_radial() -{ - delete [] atomtypes; - delete [] radialtable; - delete [] alpha; - delete [] dfctable; - delete [] rinvsqrttable; -} - -bool Fingerprint_radial::parse_values(char* constant,char * line1){ - int l; - char **words=new char *[MAXLINE]; - int nwords; - nwords=0; - words[nwords++] = strtok(line1,": ,\t\n"); - while ((words[nwords++] = strtok(NULL,": ,\t\n"))) continue; - nwords -= 1; - if (strcmp(constant,"re")==0){ - re = strtod(line1,NULL); - } - else if (strcmp(constant,"rc")==0){ - rc = strtod(line1,NULL); - } - else if (strcmp(constant,"alpha")==0){ - delete [] alpha; - alpha = new double [nwords]; - for (l=0;lerrorf("Undefined value for radial power"); - //code will run with default o=0 if o is never specified. All other values must be defined in potential file. - delete [] words; - if (re!=0 && rc!=0 && alpha!=0 && dr!=0 && n!=0)return true; - return false; -} - -void Fingerprint_radial::write_values(FILE *fid){ - int i; - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:re:\n",style,id); - fprintf(fid,"%f\n",re); - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:rc:\n",style,id); - fprintf(fid,"%f\n",rc); - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:alpha:\n",style,id); - for (i=0;i<(n-o+1);i++){ - fprintf(fid,"%f ",alpha[i]); - } - fprintf(fid,"\n"); - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:dr:\n",style,id); - fprintf(fid,"%f\n",dr); - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:o:\n",style,id); - fprintf(fid,"%d\n",o); - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:n:\n",style,id); - fprintf(fid,"%d\n",n); -} - -//called after fingerprint is fully defined and tables can be computed. -void Fingerprint_radial::allocate() -{ - int k,m; - double r1; - int buf = 5; - int res = pair->res; - double cutmax = pair->cutmax; - radialtable = new double [(res+buf)*get_length()]; - dfctable = new double [res+buf]; - for (k=0;k<(res+buf);k++){ - r1 = cutmax*cutmax*(double)(k)/(double)(res); - for (m=0;m<=(n-o);m++){ - radialtable[k*(n-o+1)+m]=pow(sqrt(r1)/re,m+o)*exp(-alpha[m]*sqrt(r1)/re)*cutofffunction(sqrt(r1),rc,dr); - } - if (sqrt(r1)>=rc || sqrt(r1) <= (rc-dr)){ - dfctable[k]=0; - } - else{ - dfctable[k]=-8*pow(1-(rc-sqrt(r1))/dr,3)/dr/(1-pow(1-(rc-sqrt(r1))/dr,4)); - } - } - generate_rinvssqrttable(); -} - -//called after fingerprint is declared for i-j type, but before its parameters are read. -void Fingerprint_radial::init(int *i,int id) -{ - empty = false; - for (int j=0;jid = id; -} - -void Fingerprint_radial::compute_fingerprint(double * features,double * dfeaturesx,double *dfeaturesy,double *dfeaturesz,int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl) -{ - int nelements = pair->nelements; - int res = pair->res; - int i,j,jj,itype,jtype,l; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *ilist,*jlist,*numneigh,**firstneigh; - // - PairRANN::Simulation *sim = &pair->sims[sid]; - int count=0; -// double **x = sim->x; - int *type = sim->type; - ilist = sim->ilist; - double cutmax = pair->cutmax; - i = ilist[ii]; - itype = pair->map[type[i]]; - int f = pair->net[itype].dimensions[0]; - double cutinv2 = 1/cutmax/cutmax; -// numneigh = sim->numneigh; -// firstneigh = sim->firstneigh; -// xtmp = x[i][0]; -// ytmp = x[i][1]; -// ztmp = x[i][2]; -// jlist = firstneigh[i]; -// jnum = numneigh[i]; - //loop over neighbors - for (jj = 0; jj < jnum; jj++) { -// j = jlist[jj]; -// j &= NEIGHMASK; -// jtype = pair->map[type[j]]; - jtype =tn[jj]; - if (this->atomtypes[1] != nelements && this->atomtypes[1] != jtype)continue; -// delx = xtmp - x[j][0]; -// dely = ytmp - x[j][1]; -// delz = ztmp - x[j][2]; - delx = xn[jj]; - dely = yn[jj]; - delz = zn[jj]; - rsq = delx*delx + dely*dely + delz*delz; - if (rsq > rc*rc)continue; - count = startingneuron; - double r1 = (rsq*((double)res)*cutinv2); - int m1 = (int)r1; - if (m1>res || m1<1){pair->errorf("invalid neighbor radius!");} - if (radialtable[m1]==0){continue;} - //cubic interpolation from tables - double *p1 = &radialtable[m1*(n-o+1)]; - double *p2 = &radialtable[(m1+1)*(n-o+1)]; - double *p3 = &radialtable[(m1+2)*(n-o+1)]; - double *p0 = &radialtable[(m1-1)*(n-o+1)]; - double *q = &dfctable[m1-1]; - double *rinvs = &rinvsqrttable[m1-1]; - r1 = r1-trunc(r1); - double dfc = q[1] + 0.5 * r1*(q[2] - q[0] + r1*(2.0*q[0] - 5.0*q[1] + 4.0*q[2] - q[3] + r1*(3.0*(q[1] - q[2]) + q[3] - q[0]))); - double ri = rinvs[1] + 0.5 * r1*(rinvs[2] - rinvs[0] + r1*(2.0*rinvs[0] - 5.0*rinvs[1] + 4.0*rinvs[2] - rinvs[3] + r1*(3.0*(rinvs[1] - rinvs[2]) + rinvs[3] - rinvs[0]))); - for (l=0;l<=(n-o);l++){ - double rt = p1[l]+0.5*r1*(p2[l]-p0[l]+r1*(2.0*p0[l]-5.0*p1[l]+4.0*p2[l]-p3[l]+r1*(3.0*(p1[l]-p2[l])+p3[l]-p0[l]))); - features[count]+=rt; - rt *= (l+o)/rsq+(-alpha[l]/re+dfc)*ri; - //update neighbor's features - dfeaturesx[jj*f+count]+=rt*delx; - dfeaturesy[jj*f+count]+=rt*dely; - dfeaturesz[jj*f+count]+=rt*delz; - //update atom's features - dfeaturesx[jnum*f+count]-=rt*delx; - dfeaturesy[jnum*f+count]-=rt*dely; - dfeaturesz[jnum*f+count]-=rt*delz; - count++; - } - } - -} - -int Fingerprint_radial::get_length() -{ - return n-o+1; -} diff --git a/src/fingerprint_radial.h b/src/fingerprint_radial.h deleted file mode 100644 index aeb1c2eca3..0000000000 --- a/src/fingerprint_radial.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- 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. -------------------------------------------------------------------------- */ -/* ---------------------------------------------------------------------- - Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu - Doyl Dickel (MSU) doyl@me.msstate.edu - ----------------------------------------------------------------------*/ -/* -“The research described and the resulting data presented herein, unless -otherwise noted, was funded under PE 0602784A, Project T53 "Military -Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, -managed by the U.S. Army Combat Capabilities Development Command (CCDC) and -the Engineer Research and Development Center (ERDC). The work described in -this document was conducted at CAVS, MSU. Permission was granted by ERDC -to publish this information. Any opinions, findings and conclusions or -recommendations expressed in this material are those of the author(s) and -do not necessarily reflect the views of the United States Army.​” - -DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 - */ -#ifdef FINGERPRINT_CLASS - -FingerprintStyle(radial,Fingerprint_radial) - -#else - -#ifndef FINGERPRINT_RADIAL_H_ -#define FINGERPRINT_RADIAL_H_ - -#include "fingerprint.h" - -namespace LAMMPS_NS { - -class Fingerprint_radial : public Fingerprint { - public: - Fingerprint_radial(PairRANN *); - ~Fingerprint_radial(); - bool parse_values(char*,char*); - void write_values(FILE *); - void init(int*,int); - void allocate(); - void compute_fingerprint(double*,double*,double*,double*,int,int,double*,double*,double*,int*,int,int*); - int get_length(); - - double *radialtable; - double *dfctable; - double dr; - double *alpha; - double re; - int n;//highest term - int o;//lowest term - -}; - - -} - -#endif -#endif /* FINGERPRINT_RADIAL_H_ */ diff --git a/src/fingerprint_radialscreened.cpp b/src/fingerprint_radialscreened.cpp deleted file mode 100644 index 3101ca0ab0..0000000000 --- a/src/fingerprint_radialscreened.cpp +++ /dev/null @@ -1,273 +0,0 @@ -/* -*- 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. -------------------------------------------------------------------------- */ -/* ---------------------------------------------------------------------- - Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu - Doyl Dickel (MSU) doyl@me.msstate.edu - ----------------------------------------------------------------------*/ -/* -“The research described and the resulting data presented herein, unless -otherwise noted, was funded under PE 0602784A, Project T53 "Military -Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, -managed by the U.S. Army Combat Capabilities Development Command (CCDC) and -the Engineer Research and Development Center (ERDC). The work described in -this document was conducted at CAVS, MSU. Permission was granted by ERDC -to publish this information. Any opinions, findings and conclusions or -recommendations expressed in this material are those of the author(s) and -do not necessarily reflect the views of the United States Army.​” - -DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 - */ - -#include "fingerprint_radialscreened.h" - - - -using namespace LAMMPS_NS; - -Fingerprint_radialscreened::Fingerprint_radialscreened(PairRANN *pair) : Fingerprint(pair) -{ - n_body_type = 2; - dr = 0; - re = 0; - rc = 0; - alpha = new double [1]; - alpha[0] = -1; - n = 0; - o = 0; - id = -1; - style = "radialscreened"; - atomtypes = new int [n_body_type]; - empty = true; - fullydefined = false; - pair->doscreen = true; - screen = true; -} - -Fingerprint_radialscreened::~Fingerprint_radialscreened() -{ - delete [] atomtypes; - delete [] radialtable; - delete [] alpha; - delete [] dfctable; - delete [] rinvsqrttable; -} - -bool Fingerprint_radialscreened::parse_values(char* constant,char * line1){ - int l; - char **words=new char *[MAXLINE]; - int nwords; - nwords=0; - words[nwords++] = strtok(line1,": ,\t\n"); - while ((words[nwords++] = strtok(NULL,": ,\t\n"))) continue; - nwords -= 1; - if (strcmp(constant,"re")==0){ - re = strtod(line1,NULL); - } - else if (strcmp(constant,"rc")==0){ - rc = strtod(line1,NULL); - } - else if (strcmp(constant,"alpha")==0){ - delete [] alpha; - alpha = new double [nwords]; - for (l=0;lerrorf("Undefined value for radial power"); - //code will run with default o=0 if o is never specified. All other values must be defined in potential file. - delete [] words; - if (re!=0 && rc!=0 && alpha!=0 && dr!=0 && n!=0)return true; - return false; -} - -void Fingerprint_radialscreened::write_values(FILE *fid){ - int i; - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:re:\n",style,id); - fprintf(fid,"%f\n",re); - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:rc:\n",style,id); - fprintf(fid,"%f\n",rc); - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:alpha:\n",style,id); - for (i=0;i<(n-o+1);i++){ - fprintf(fid,"%f ",alpha[i]); - } - fprintf(fid,"\n"); - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:dr:\n",style,id); - fprintf(fid,"%f\n",dr); - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:o:\n",style,id); - fprintf(fid,"%d\n",o); - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:n:\n",style,id); - fprintf(fid,"%d\n",n); -} - -//called after fingerprint is fully defined and tables can be computed. -void Fingerprint_radialscreened::allocate() -{ - int k,m; - double r1; - int buf = 5; - int res = pair->res; - double cutmax = pair->cutmax; - radialtable = new double [(res+buf)*get_length()]; - dfctable = new double [res+buf]; - for (k=0;k<(res+buf);k++){ - r1 = cutmax*cutmax*(double)(k)/(double)(res); - for (m=0;m<=(n-o);m++){ - radialtable[k*(n-o+1)+m]=pow(sqrt(r1)/re,m+o)*exp(-alpha[m]*sqrt(r1)/re)*cutofffunction(sqrt(r1),rc,dr); - } - if (sqrt(r1)>=rc || sqrt(r1) <= (rc-dr)){ - dfctable[k]=0; - } - else{ - dfctable[k]=-8*pow(1-(rc-sqrt(r1))/dr,3)/dr/(1-pow(1-(rc-sqrt(r1))/dr,4)); - } - } - generate_rinvssqrttable(); -} - -//called after fingerprint is declared for i-j type, but before its parameters are read. -void Fingerprint_radialscreened::init(int *i,int id) -{ - empty = false; - for (int j=0;jid = id; -} - -void Fingerprint_radialscreened::compute_fingerprint(double * features,double * dfeaturesx,double *dfeaturesy,double *dfeaturesz,double *Sik, double *dSikx, double*dSiky, double *dSikz, double *dSijkx, double *dSijky, double *dSijkz, bool *Bij,int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl) -{ - int nelements = pair->nelements; - int res = pair->res; - int i,j,jj,itype,jtype,l,kk; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *ilist,*jlist,*numneigh,**firstneigh; - // - PairRANN::Simulation *sim = &pair->sims[sid]; - int count=0; - double **x = sim->x; - int *type = sim->type; - ilist = sim->ilist; - double cutmax = pair->cutmax; - i = ilist[ii]; - itype = pair->map[type[i]]; - int f = pair->net[itype].dimensions[0]; - double cutinv2 = 1/cutmax/cutmax; -// numneigh = sim->numneigh; -// firstneigh = sim->firstneigh; -// xtmp = x[i][0]; -// ytmp = x[i][1]; -// ztmp = x[i][2]; -// jlist = firstneigh[i]; -// jnum = numneigh[i]; - //loop over neighbors - for (jj = 0; jj < jnum; jj++) { - if (Bij[jj]==false){continue;} -// j = jlist[jj]; -// j &= NEIGHMASK; -// jtype = pair->map[type[j]]; - jtype = tn[jj]; - if (this->atomtypes[1] != nelements && this->atomtypes[1] != jtype)continue; -// delx = xtmp - x[j][0]; -// dely = ytmp - x[j][1]; -// delz = ztmp - x[j][2]; - delx = xn[jj]; - dely = yn[jj]; - delz = zn[jj]; - rsq = delx*delx + dely*dely + delz*delz; - if (rsq > rc*rc)continue; - count = startingneuron; - double r1 = (rsq*((double)res)*cutinv2); - int m1 = (int)r1; - if (m1>res || m1<1){pair->errorf("invalid neighbor radius!");} - if (radialtable[m1]==0){continue;} - //cubic interpolation from tables - double *p1 = &radialtable[m1*(n-o+1)]; - double *p2 = &radialtable[(m1+1)*(n-o+1)]; - double *p3 = &radialtable[(m1+2)*(n-o+1)]; - double *p0 = &radialtable[(m1-1)*(n-o+1)]; - double *q = &dfctable[m1-1]; - double *rinvs = &rinvsqrttable[m1-1]; - r1 = r1-trunc(r1); - double dfc = q[1] + 0.5 * r1*(q[2] - q[0] + r1*(2.0*q[0] - 5.0*q[1] + 4.0*q[2] - q[3] + r1*(3.0*(q[1] - q[2]) + q[3] - q[0]))); - double ri = rinvs[1] + 0.5 * r1*(rinvs[2] - rinvs[0] + r1*(2.0*rinvs[0] - 5.0*rinvs[1] + 4.0*rinvs[2] - rinvs[3] + r1*(3.0*(rinvs[1] - rinvs[2]) + rinvs[3] - rinvs[0]))); - for (l=0;l<=(n-o);l++){ - double rt = Sik[jj]*(p1[l]+0.5*r1*(p2[l]-p0[l]+r1*(2.0*p0[l]-5.0*p1[l]+4.0*p2[l]-p3[l]+r1*(3.0*(p1[l]-p2[l])+p3[l]-p0[l])))); - features[count]+=rt; - double rt1 = rt*((l+o)/rsq+(-alpha[l]/re+dfc)*ri); - //update neighbor's features - dfeaturesx[jj*f+count]+=rt1*delx+rt*dSikx[jj]; - dfeaturesy[jj*f+count]+=rt1*dely+rt*dSiky[jj]; - dfeaturesz[jj*f+count]+=rt1*delz+rt*dSikz[jj]; - for (kk=0;kkdoscreen = true; - screen = true; - pair->dospin = true; - spin = true; -} - -Fingerprint_radialscreenedspin::~Fingerprint_radialscreenedspin() -{ - delete [] atomtypes; - delete [] radialtable; - delete [] alpha; - delete [] dfctable; - delete [] rinvsqrttable; -} - -bool Fingerprint_radialscreenedspin::parse_values(char* constant,char * line1){ - int l; - char **words=new char *[MAXLINE]; - int nwords; - nwords=0; - words[nwords++] = strtok(line1,": ,\t\n"); - while ((words[nwords++] = strtok(NULL,": ,\t\n"))) continue; - nwords -= 1; - if (strcmp(constant,"re")==0){ - re = strtod(line1,NULL); - } - else if (strcmp(constant,"rc")==0){ - rc = strtod(line1,NULL); - } - else if (strcmp(constant,"alpha")==0){ - delete [] alpha; - alpha = new double [nwords]; - for (l=0;lerrorf("Undefined value for radial power"); - //code will run with default o=0 if o is never specified. All other values must be defined in potential file. - delete [] words; - if (re!=0 && rc!=0 && alpha!=0 && dr!=0 && n!=0)return true; - return false; -} - -void Fingerprint_radialscreenedspin::write_values(FILE *fid){ - int i; - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:re:\n",style,id); - fprintf(fid,"%f\n",re); - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:rc:\n",style,id); - fprintf(fid,"%f\n",rc); - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:alpha:\n",style,id); - for (i=0;i<(n-o+1);i++){ - fprintf(fid,"%f ",alpha[i]); - } - fprintf(fid,"\n"); - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:dr:\n",style,id); - fprintf(fid,"%f\n",dr); - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:o:\n",style,id); - fprintf(fid,"%d\n",o); - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:n:\n",style,id); - fprintf(fid,"%d\n",n); -} - -//called after fingerprint is fully defined and tables can be computed. -void Fingerprint_radialscreenedspin::allocate() -{ - int k,m; - double r1; - int buf = 5; - int res = pair->res; - double cutmax = pair->cutmax; - radialtable = new double [(res+buf)*get_length()]; - dfctable = new double [res+buf]; - for (k=0;k<(res+buf);k++){ - r1 = cutmax*cutmax*(double)(k)/(double)(res); - for (m=0;m<=(n-o);m++){ - radialtable[k*(n-o+1)+m]=pow(sqrt(r1)/re,m+o)*exp(-alpha[m]*sqrt(r1)/re)*cutofffunction(sqrt(r1),rc,dr); - } - if (sqrt(r1)>=rc || sqrt(r1) <= (rc-dr)){ - dfctable[k]=0; - } - else{ - dfctable[k]=-8*pow(1-(rc-sqrt(r1))/dr,3)/dr/(1-pow(1-(rc-sqrt(r1))/dr,4)); - } - } - generate_rinvssqrttable(); -} - -//called after fingerprint is declared for i-j type, but before its parameters are read. -void Fingerprint_radialscreenedspin::init(int *i,int id) -{ - empty = false; - for (int j=0;jid = id; -} - -void Fingerprint_radialscreenedspin::compute_fingerprint(double * features,double * dfeaturesx,double *dfeaturesy,double *dfeaturesz,double * dspinx,double *dspiny,double *dspinz,double *Sik, double *dSikx, double*dSiky, double *dSikz, double *dSijkx, double *dSijky, double *dSijkz, bool *Bij,int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl) -{ - int nelements = pair->nelements; - int res = pair->res; - int i,j,jj,itype,jtype,l,kk; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *ilist,*jlist,*numneigh,**firstneigh; - // - PairRANN::Simulation *sim = &pair->sims[sid]; - int count=0; - double **x = sim->x; - int *type = sim->type; - ilist = sim->ilist; - double cutmax = pair->cutmax; - i = ilist[ii]; - itype = pair->map[type[i]]; - int f = pair->net[itype].dimensions[0]; - double cutinv2 = 1/cutmax/cutmax; - double *si = sim->s[i]; -// numneigh = sim->numneigh; -// firstneigh = sim->firstneigh; -// xtmp = x[i][0]; -// ytmp = x[i][1]; -// ztmp = x[i][2]; -// jlist = firstneigh[i]; -// jnum = numneigh[i]; - //loop over neighbors - for (jj = 0; jj < jnum; jj++) { - if (Bij[jj]==false){continue;} -// j = jlist[jj]; -// j &= NEIGHMASK; -// jtype = pair->map[type[j]]; - jtype = tn[jj]; - if (this->atomtypes[1] != nelements && this->atomtypes[1] != jtype)continue; -// delx = xtmp - x[j][0]; -// dely = ytmp - x[j][1]; -// delz = ztmp - x[j][2]; - delx = xn[jj]; - dely = yn[jj]; - delz = zn[jj]; - rsq = delx*delx + dely*dely + delz*delz; - if (rsq > rc*rc)continue; - count = startingneuron; - double r1 = (rsq*((double)res)*cutinv2); - int m1 = (int)r1; - if (m1>res || m1<1){pair->errorf("invalid neighbor radius!");} - if (radialtable[m1]==0){continue;} - j=jl[jj]; - double *sj = sim->s[j]; - double sp = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; - //cubic interpolation from tables - double *p1 = &radialtable[m1*(n-o+1)]; - double *p2 = &radialtable[(m1+1)*(n-o+1)]; - double *p3 = &radialtable[(m1+2)*(n-o+1)]; - double *p0 = &radialtable[(m1-1)*(n-o+1)]; - double *q = &dfctable[m1-1]; - double *rinvs = &rinvsqrttable[m1-1]; - r1 = r1-trunc(r1); - double dfc = q[1] + 0.5 * r1*(q[2] - q[0] + r1*(2.0*q[0] - 5.0*q[1] + 4.0*q[2] - q[3] + r1*(3.0*(q[1] - q[2]) + q[3] - q[0]))); - double ri = rinvs[1] + 0.5 * r1*(rinvs[2] - rinvs[0] + r1*(2.0*rinvs[0] - 5.0*rinvs[1] + 4.0*rinvs[2] - rinvs[3] + r1*(3.0*(rinvs[1] - rinvs[2]) + rinvs[3] - rinvs[0]))); - for (l=0;l<=(n-o);l++){ - double rt = Sik[jj]*(p1[l]+0.5*r1*(p2[l]-p0[l]+r1*(2.0*p0[l]-5.0*p1[l]+4.0*p2[l]-p3[l]+r1*(3.0*(p1[l]-p2[l])+p3[l]-p0[l])))); - //update neighbor's features - dspinx[jj*f+count]+=rt*si[0]; - dspiny[jj*f+count]+=rt*si[1]; - dspinz[jj*f+count]+=rt*si[2]; - dspinx[jnum*f+count]+=rt*sj[0]; - dspiny[jnum*f+count]+=rt*sj[1]; - dspinz[jnum*f+count]+=rt*sj[2]; - rt *= sp; - features[count]+=rt; - double rt1 = rt*((l+o)/rsq+(-alpha[l]/re+dfc)*ri); - dfeaturesx[jj*f+count]+=rt1*delx+rt*dSikx[jj]; - dfeaturesy[jj*f+count]+=rt1*dely+rt*dSiky[jj]; - dfeaturesz[jj*f+count]+=rt1*delz+rt*dSikz[jj]; - for (kk=0;kkallscreen = false; - pair->dospin = true; - spin = true; -} - -Fingerprint_radialspin::~Fingerprint_radialspin() -{ - delete [] atomtypes; - delete [] radialtable; - delete [] alpha; - delete [] dfctable; - delete [] rinvsqrttable; -} - -bool Fingerprint_radialspin::parse_values(char* constant,char * line1){ - int l; - char **words=new char *[MAXLINE]; - int nwords; - nwords=0; - words[nwords++] = strtok(line1,": ,\t\n"); - while ((words[nwords++] = strtok(NULL,": ,\t\n"))) continue; - nwords -= 1; - if (strcmp(constant,"re")==0){ - re = strtod(line1,NULL); - } - else if (strcmp(constant,"rc")==0){ - rc = strtod(line1,NULL); - } - else if (strcmp(constant,"alpha")==0){ - delete [] alpha; - alpha = new double [nwords]; - for (l=0;lerrorf("Undefined value for radial power"); - //code will run with default o=0 if o is never specified. All other values must be defined in potential file. - delete [] words; - if (re!=0 && rc!=0 && alpha!=0 && dr!=0 && n!=0)return true; - return false; -} - -void Fingerprint_radialspin::write_values(FILE *fid){ - int i; - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:re:\n",style,id); - fprintf(fid,"%f\n",re); - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:rc:\n",style,id); - fprintf(fid,"%f\n",rc); - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:alpha:\n",style,id); - for (i=0;i<(n-o+1);i++){ - fprintf(fid,"%f ",alpha[i]); - } - fprintf(fid,"\n"); - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:dr:\n",style,id); - fprintf(fid,"%f\n",dr); - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:o:\n",style,id); - fprintf(fid,"%d\n",o); - fprintf(fid,"fingerprintconstants:"); - fprintf(fid,"%s",pair->elementsp[atomtypes[0]]); - for (i=1;ielementsp[atomtypes[i]]); - } - fprintf(fid,":%s_%d:n:\n",style,id); - fprintf(fid,"%d\n",n); -} - -//called after fingerprint is fully defined and tables can be computed. -void Fingerprint_radialspin::allocate() -{ - int k,m; - double r1; - int buf = 5; - int res = pair->res; - double cutmax = pair->cutmax; - radialtable = new double [(res+buf)*get_length()]; - dfctable = new double [res+buf]; - for (k=0;k<(res+buf);k++){ - r1 = cutmax*cutmax*(double)(k)/(double)(res); - for (m=0;m<=(n-o);m++){ - radialtable[k*(n-o+1)+m]=pow(sqrt(r1)/re,m+o)*exp(-alpha[m]*sqrt(r1)/re)*cutofffunction(sqrt(r1),rc,dr); - } - if (sqrt(r1)>=rc || sqrt(r1) <= (rc-dr)){ - dfctable[k]=0; - } - else{ - dfctable[k]=-8*pow(1-(rc-sqrt(r1))/dr,3)/dr/(1-pow(1-(rc-sqrt(r1))/dr,4)); - } - } - generate_rinvssqrttable(); -} - -//called after fingerprint is declared for i-j type, but before its parameters are read. -void Fingerprint_radialspin::init(int *i,int id) -{ - empty = false; - for (int j=0;jid = id; -} - -void Fingerprint_radialspin::compute_fingerprint(double * features,double * dfeaturesx,double *dfeaturesy,double *dfeaturesz,double * dspinx,double *dspiny,double *dspinz,int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl) -{ - int nelements = pair->nelements; - int res = pair->res; - int i,j,jj,itype,jtype,l; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *ilist,*jlist,*numneigh,**firstneigh; - // - PairRANN::Simulation *sim = &pair->sims[sid]; - int count=0; -// double **x = sim->x; - int *type = sim->type; - ilist = sim->ilist; - double cutmax = pair->cutmax; - i = ilist[ii]; - itype = pair->map[type[i]]; - int f = pair->net[itype].dimensions[0]; - double cutinv2 = 1/cutmax/cutmax; - double *si = sim->s[i]; -// numneigh = sim->numneigh; - firstneigh = sim->firstneigh; -// xtmp = x[i][0]; -// ytmp = x[i][1]; -// ztmp = x[i][2]; - jlist = firstneigh[i]; -// jnum = numneigh[i]; - //loop over neighbors - for (jj = 0; jj < jnum; jj++) { - j = jl[jj]; - // jtype = pair->map[type[j]]; - jtype =tn[jj]; - if (this->atomtypes[1] != nelements && this->atomtypes[1] != jtype)continue; - // delx = xtmp - x[j][0]; - // dely = ytmp - x[j][1]; - // delz = ztmp - x[j][2]; - delx = xn[jj]; - dely = yn[jj]; - delz = zn[jj]; - rsq = delx*delx + dely*dely + delz*delz; - if (rsq > rc*rc)continue; - count = startingneuron; - double r1 = (rsq*((double)res)*cutinv2); - int m1 = (int)r1; - if (m1>res || m1<1){pair->errorf("invalid neighbor radius!");} - if (radialtable[m1]==0){continue;} - double *sj = sim->s[j]; - double sp = si[0]*sj[0]+si[1]*sj[1]+si[2]*sj[2]; - //cubic interpolation from tables - double *p1 = &radialtable[m1*(n-o+1)]; - double *p2 = &radialtable[(m1+1)*(n-o+1)]; - double *p3 = &radialtable[(m1+2)*(n-o+1)]; - double *p0 = &radialtable[(m1-1)*(n-o+1)]; - double *q = &dfctable[m1-1]; - double *rinvs = &rinvsqrttable[m1-1]; - r1 = r1-trunc(r1); - double dfc = q[1] + 0.5 * r1*(q[2] - q[0] + r1*(2.0*q[0] - 5.0*q[1] + 4.0*q[2] - q[3] + r1*(3.0*(q[1] - q[2]) + q[3] - q[0]))); - double ri = rinvs[1] + 0.5 * r1*(rinvs[2] - rinvs[0] + r1*(2.0*rinvs[0] - 5.0*rinvs[1] + 4.0*rinvs[2] - rinvs[3] + r1*(3.0*(rinvs[1] - rinvs[2]) + rinvs[3] - rinvs[0]))); - for (l=0;l<=(n-o);l++){ - double rt = p1[l]+0.5*r1*(p2[l]-p0[l]+r1*(2.0*p0[l]-5.0*p1[l]+4.0*p2[l]-p3[l]+r1*(3.0*(p1[l]-p2[l])+p3[l]-p0[l]))); - dspinx[jj*f+count]+=rt*si[0]; - dspiny[jj*f+count]+=rt*si[1]; - dspinz[jj*f+count]+=rt*si[2]; - dspinx[jnum*f+count]+=rt*sj[0]; - dspiny[jnum*f+count]+=rt*sj[1]; - dspinz[jnum*f+count]+=rt*sj[2]; - rt *= sp; - features[count]+=rt; - rt *= (l+o)/rsq+(-alpha[l]/re+dfc)*ri; - //update neighbor's features - dfeaturesx[jj*f+count]+=rt*delx; - dfeaturesy[jj*f+count]+=rt*dely; - dfeaturesz[jj*f+count]+=rt*delz; - //update atom's features - dfeaturesx[jnum*f+count]-=rt*delx; - dfeaturesy[jnum*f+count]-=rt*dely; - dfeaturesz[jnum*f+count]-=rt*delz; - count++; - } - } - -} - -int Fingerprint_radialspin::get_length() -{ - return n-o+1; -} diff --git a/src/fingerprint_radialspin.h b/src/fingerprint_radialspin.h deleted file mode 100644 index 428c0e74e4..0000000000 --- a/src/fingerprint_radialspin.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- 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. -------------------------------------------------------------------------- */ -/* ---------------------------------------------------------------------- - Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu - Doyl Dickel (MSU) doyl@me.msstate.edu - ----------------------------------------------------------------------*/ -/* -“The research described and the resulting data presented herein, unless -otherwise noted, was funded under PE 0602784A, Project T53 "Military -Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, -managed by the U.S. Army Combat Capabilities Development Command (CCDC) and -the Engineer Research and Development Center (ERDC). The work described in -this document was conducted at CAVS, MSU. Permission was granted by ERDC -to publish this information. Any opinions, findings and conclusions or -recommendations expressed in this material are those of the author(s) and -do not necessarily reflect the views of the United States Army.​” - -DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 - */ - -#ifdef FINGERPRINT_CLASS - -FingerprintStyle(radialspin,Fingerprint_radialspin) - -#else - -#ifndef FINGERPRINT_RADIALspin_H_ -#define FINGERPRINT_RADIALspin_H_ - -#include "fingerprint.h" - -namespace LAMMPS_NS { - -class Fingerprint_radialspin : public Fingerprint { - public: - Fingerprint_radialspin(PairRANN *); - ~Fingerprint_radialspin(); - bool parse_values(char*,char*); - void write_values(FILE *); - void init(int*,int); - void allocate(); - void compute_fingerprint(double*,double*,double*,double*,double*,double*,double*,int,int,double*,double*,double*,int*,int,int*); - int get_length(); - - double *radialtable; - double *dfctable; - double dr; - double *alpha; - double re; - int n;//highest term - int o;//lowest term - -}; - - -} - -#endif -#endif /* FINGERPRINT_RADIAL_H_ */ diff --git a/src/pair_rann.cpp b/src/pair_rann.cpp deleted file mode 100644 index 3507c931dc..0000000000 --- a/src/pair_rann.cpp +++ /dev/null @@ -1,1247 +0,0 @@ -/* -*- 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. -------------------------------------------------------------------------- */ -/* ---------------------------------------------------------------------- - Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu - Doyl Dickel (MSU) doyl@me.msstate.edu - ----------------------------------------------------------------------*/ -/* -“The research described and the resulting data presented herein, unless -otherwise noted, was funded under PE 0602784A, Project T53 "Military -Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, -managed by the U.S. Army Combat Capabilities Development Command (CCDC) and -the Engineer Research and Development Center (ERDC). The work described in -this document was conducted at CAVS, MSU. Permission was granted by ERDC -to publish this information. Any opinions, findings and conclusions or -recommendations expressed in this material are those of the author(s) and -do not necessarily reflect the views of the United States Army.​” - -DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 - */ - -#include "style_fingerprint.h" -#include "style_activation.h" - -#include "pair_rann.h" - -using namespace LAMMPS_NS; - -static const char cite_user_rann_package[] = - "USER-RANN package:\n\n" - "@Article{Nitol2021,\n" - " author = {Nitol, Mashroor S and Dickel, Doyl E and Barrett, Christopher D},\n" - " title = {Artificial neural network potential for pure zinc},\n" - " journal = {Computational Materials Science},\n" - " year = 2021,\n" - " volume = 188,\n" - " pages = {110207}\n" - "}\n\n"; - -PairRANN::PairRANN(LAMMPS *lmp) : Pair(lmp) -{ - single_enable = 0; - restartinfo = 0; - one_coeff = 1; - manybody_flag = 1; - - allocated = 0; - - nelements = -1; - elements = NULL; - mass = NULL; - - // set comm size needed by this Pair - // comm unused for now. - - comm_forward = 38; - comm_reverse = 30; - res = 10000; - cutmax = 0; - //at least one of the following will change during fingerprint definition: - doscreen = false; - allscreen = true; - dospin = false; - - fingerprint_map = new FingerprintCreatorMap(); - - #define FINGERPRINT_CLASS - #define FingerprintStyle(key,Class) \ - (*fingerprint_map)[#key] = &fingerprint_creator; - #include "style_fingerprint.h" - #undef FingerprintStyle - #undef FINGERPRINT_CLASS - - activation_map = new ActivationCreatorMap(); - - #define ACTIVATION_CLASS - #define ActivationStyle(key,Class) \ - (*activation_map)[#key] = &activation_creator; - #include "style_activation.h" - #undef ActivationStyle - #undef ACTIVATION_CLASS -} - -PairRANN::~PairRANN() -{ - //clear memory - delete [] mass; - for (int i=0;i0){ - for (int j=0;j0){ - delete [] fingerprints[i]; - delete [] activation[i]; - } - } - delete [] fingerprints; - delete [] activation; - delete [] fingerprintcount; - delete [] fingerprintperelement; - delete [] fingerprintlength; - delete [] screening_min; - delete [] screening_max; -} - - - -void PairRANN::allocate(char **elementword) -{ - int i,j,k,l,n; - n = atom->ntypes; - memory->create(setflag,n+1,n+1,"pair:setflag"); - memory->create(cutsq,n+1,n+1,"pair:cutsq"); - cutmax = 0; - nelementsp=nelements+1; - //initialize arrays - elements = new char *[nelements]; - elementsp = new char *[nelementsp];//elements + 'all' - mass = new double[nelements]; - net = new NNarchitecture[nelementsp]; - weightdefined = new bool*[nelementsp]; - biasdefined = new bool *[nelementsp]; - activation = new Activation**[nelementsp]; - fingerprints = new Fingerprint**[nelementsp]; - fingerprintlength = new int[nelementsp]; - fingerprintperelement = new int [nelementsp]; - fingerprintcount = new int[nelementsp]; - screening_min = new double [nelements*nelements*nelements]; - screening_max = new double [nelements*nelements*nelements]; - for (i=0;i 0) error->all(FLERR,"Illegal pair_style command"); -} - -void PairRANN::coeff(int narg, char **arg) -{ - int i,j; - map = new int [atom->ntypes+1]; - - - if (narg != 3 + atom->ntypes) - error->all(FLERR,"Incorrect args for pair coefficients"); - - - if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) - error->all(FLERR,"Incorrect args for pair coefficients"); - nelements = -1; - read_file(arg[2]); - - // read args that map atom types to elements in potential file - // map[i] = which element the Ith atom type is, -1 if NULL - - for (i = 3; i < narg; i++) { - if (strcmp(arg[i],"NULL") == 0) { - map[i-2] = -1; - continue; - } - for (j = 0; j < nelements; j++) - { - if (strcmp(arg[i],elements[j]) == 0) break; - } - if (j < nelements) map[i-2] = j; - else error->all(FLERR,"No matching element in NN potential file"); - } - // clear setflag since coeff() called once with I,J = * * - - int n = atom->ntypes; - for (i = 1; i <= n; i++) - for (j = i; j <= n; j++) - setflag[i][j] = 0; - - // set setflag i,j for type pairs where both are mapped to elements - // set mass of atom type if i = j - - int count = 0; - for (i = 1; i <= n; i++) { - for (j = i; j <= n; j++) { - if (map[i] >= 0 && map[j] >= 0) { - setflag[i][j] = 1; - if (i == j) atom->set_mass(FLERR,i,mass[map[i]]); - count++; - } - } - } - if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); - for (i=0;iallocate(); - } - } - allocated=1; -} - -void PairRANN::read_file(char *filename) -{ - FILE *fp; - int eof = 0,i,j,k,l; - int n,nwords; - int longline = 4096; - char line [longline],line1[longline]; - char *ptr; - bool comment; - char str[128]; - fp = utils::open_potential(filename,lmp,nullptr); - if (fp == NULL) { - sprintf(str,"Cannot open rann potential file %s",filename); - error->one(FLERR,str); - } - while (eof == 0){ - ptr = fgets(line,longline,fp); - if (ptr == NULL) { - if (check_potential()) {//looks to see if everything needed appears to be defined - error->one(FLERR,"Invalid syntax in potential file, values are inconsistent or missing"); - } - else{ - fclose(fp); - eof = 1; - break; - } - } - else n = strlen(line) + 1; - if ((ptr = strchr(line,'#'))) *ptr = '\0';//strip comments from end of lines - if (count_words(line)==0){continue;}//skip comment line - comment = true; - while (comment==true){ - ptr = fgets(line1,longline,fp); - if (ptr==NULL)errorf("Unexpected end of parameter file (keyword given with no value)"); - if ((ptr = strchr(line1,'#'))) *ptr = '\0'; - nwords = count_words(line1); - if (nwords == 0) continue; - comment = false; - } - line1[strlen(line1)-1] = '\0';//replace \n with \0 - nwords = count_words(line); - char **words=new char *[nwords+1]; - nwords = 0; - words[nwords++] = strtok(line,": ,\t_\n"); - while ((words[nwords++] = strtok(NULL,": ,\t_\n"))) continue; - if (strcmp(words[0],"atomtypes")==0)read_atom_types(words,line1); - else if (strcmp(words[0],"mass")==0)read_mass(words,line1); - else if (strcmp(words[0],"fingerprintsperelement")==0)read_fpe(words,line1); - else if (strcmp(words[0],"fingerprints")==0)read_fingerprints(words,nwords-1,line1); - else if (strcmp(words[0],"fingerprintconstants")==0)read_fingerprint_constants(words,nwords-1,line1); - else if (strcmp(words[0],"networklayers")==0)read_network_layers(words,line1); - else if (strcmp(words[0],"layersize")==0)read_layer_size(words,line1); - else if (strcmp(words[0],"weight")==0)read_weight(words,line1,fp); - else if (strcmp(words[0],"bias")==0)read_bias(words,line1,fp); - else if (strcmp(words[0],"activationfunctions")==0)read_activation_functions(words,line1); - else if (strcmp(words[0],"calibrationparameters")==0)continue;//information on how the network was trained - else if (strcmp(words[0],"screening")==0)read_screening(words,nwords-1,line1); - else error->one(FLERR,"Could not understand file syntax: unknown keyword"); - delete [] words; - } -} - -void PairRANN::read_atom_types(char **words,char * line1){ - int nwords = 0; - int t = count_words(line1)+1; - char **elementword = new char *[t]; - elementword[nwords++] = strtok(line1," ,\t:_\n"); - while ((elementword[nwords++] = strtok(NULL," ,\t:_\n"))) continue; - if (nwords < 1) errorf("Incorrect syntax for atom types"); - elementword[nwords-1] = new char [strlen("all")+1]; - char elt [] = "all"; - strcpy(elementword[nwords-1],elt); - nelements = nwords-1; - allocate(elementword); -} - -void PairRANN::read_mass(char **words,char * line1){ - if (nelements == -1)error->one(FLERR,"atom types must be defined before mass in potential file."); - int nwords = 0,i; - for (i=0;ione(FLERR,"mass element not found in atom types."); -} - -void PairRANN::read_fpe(char **words,char * line1){ - int i,j; - if (nelements == -1)error->one(FLERR,"atom types must be defined before fingerprints per element in potential file."); - for (i=0;ione(FLERR,"fingerprint-per-element element not found in atom types"); -} - -void PairRANN::read_fingerprints(char **words,int nwords,char * line1){ - int nwords1=0,i,j,k,l,m,i1; - bool found; - char str[MAXLINE]; - char **words1 = new char * [count_words(line1)+1]; - words1[nwords1++] = strtok(line1," ,\t:_\n"); - while ((words1[nwords1++] = strtok(NULL," ,\t:_\n"))) continue; - nwords1 -= 1; - if (nelements == -1)error->one(FLERR,"atom types must be defined before fingerprints in potential file."); - int atomtypes[nwords-1]; - for (i=1;ione(FLERR,"fingerprint element not found in atom types");} - } - i = atomtypes[0]; - k = 0; - if (fingerprintperelement[i]==-1){error->one(FLERR,"fingerprint per element must be defined before fingerprints");} - while (kn_body_type!=nwords-1){error->one(FLERR,"invalid fingerprint for element combination");} - k++; - fingerprints[i][i1]->init(atomtypes,strtol(words1[k++],NULL,10)); - fingerprintcount[i]++; - } - delete [] words1; -} - - -void PairRANN::read_fingerprint_constants(char **words,int nwords,char * line1){ - int i,j,k,l,m,i1; - bool found; - char str [128]; - if (nelements == -1)error->one(FLERR,"atom types must be defined before fingerprints in potential file."); - int n_body_type = nwords-4; - int atomtypes[n_body_type]; - for (i=1;i<=n_body_type;i++){ - found = false; - for (j=0;jone(FLERR,"fingerprint element not found in atom types");} - } - i = atomtypes[0]; - found = false; - for (k=0;kempty){continue;} - if (n_body_type!=fingerprints[i][k]->n_body_type){continue;} - for (j=0;jatomtypes[j]!=atomtypes[j]){break;} - if (j==n_body_type-1){ - if (strcmp(words[nwords-3],fingerprints[i][k]->style)==0 && strtol(words[nwords-2],NULL,10)==fingerprints[i][k]->id){ - found=true; - i1 = k; - break; - } - } - } - if (found){break;} - } - if (!found){error->one(FLERR,"cannot define constants for unknown fingerprint");} - fingerprints[i][i1]->fullydefined=fingerprints[i][i1]->parse_values(words[nwords-1],line1); -} - -void PairRANN::read_network_layers(char **words,char *line1){ - int i,j; - if (nelements == -1)error->one(FLERR,"atom types must be defined before network layers in potential file."); - for (i=0;ione(FLERR,"network layers element not found in atom types"); -} - -void PairRANN::read_layer_size(char **words,char* line1){ - int i; - for (i=0;ione(FLERR,"networklayers for each atom type must be defined before the corresponding layer sizes."); - int j = strtol(words[2],NULL,10); - if (j>=net[i].layers || j<0){error->one(FLERR,"invalid layer in layer size definition");}; - net[i].dimensions[j]= strtol(line1,NULL,10); - return; - } - } - errorf("layer size element not found in atom types"); -} - -void PairRANN::read_weight(char **words,char* line1,FILE* fp){ - int i,j,k,l,nwords; - char *ptr; - int longline = 4096; - char **words1; - for (l=0;l=net[l].layers || i<0)error->one(FLERR,"invalid weight layer"); - if (net[l].dimensions[i]==0 || net[l].dimensions[i+1]==0) errorf("network layer sizes must be defined before corresponding weight"); - net[l].Weights[i] = new double [net[l].dimensions[i]*net[l].dimensions[i+1]]; - weightdefined[l][i] = true; - int n = count_words(line1)+1; - words1 = new char* [n]; - nwords=0; - words1[nwords++] = strtok(line1," ,\t:_\n"); - while ((words1[nwords++] = strtok(NULL," ,\t:_\n"))) continue; - nwords -= 1; - if (nwords != net[l].dimensions[i])error->one(FLERR,"invalid weights per line"); - for (k=0;kone(FLERR,"invalid weights per line"); - for (k=0;kone(FLERR,"networklayers must be defined before biases."); - i=strtol(words[2],NULL,10); - if (i>=net[l].layers || i<0)error->one(FLERR,"invalid bias layer"); - if (net[l].dimensions[i]==0) error->one(FLERR,"network layer sizes must be defined before corresponding bias"); -// delete [] net[l].Biases[i]; - biasdefined[l][i] = true; - net[l].Biases[i] = new double [net[l].dimensions[i+1]]; - words[0] = strtok(line1," ,\t:_\n"); - net[l].Biases[i][0] = strtod(words[0],NULL); - for (j=1;jone(FLERR,"bias element not found in atom types"); -} - -void PairRANN::read_activation_functions(char** words,char * line1){ - int i,j,l,nwords; - int *ptr; - for (l=0;lone(FLERR,"networklayers must be defined before activation functions."); - i = strtol(words[2],NULL,10); - if (i>=net[l].layers || i<0)error->one(FLERR,"invalid activation layer"); - nwords=0; - words[nwords++] = strtok(line1," ,\t:_\n"); - delete activation[l][i]; - activation[l][i]=create_activation(line1); - return; - } - } - error->one(FLERR,"activation function element not found in atom types"); -} - -void PairRANN::read_screening(char** words,int nwords,char *line1){ - int i,j,k; - bool found; - if (nelements == -1)errorf("atom types must be defined before fingerprints in potential file."); - if (nwords!=5)errorf("invalid screening command"); - int n_body_type = 3; - int atomtypes[n_body_type]; - for (i=1;i<=n_body_type;i++){ - found = false; - for (j=0;jnet[i].maxlayer)net[i].maxlayer = net[i].dimensions[j]; - } - if (net[i].dimensions[net[i].layers-1]!=1)return true;//output layer must have single neuron (the energy) - for (j=0;jempty)return true;//undefined activations - for (k=0;kfullydefined==false)return true; - fingerprints[i][j]->startingneuron = fingerprintlength[i]; - fingerprintlength[i] +=fingerprints[i][j]->get_length(); - if (fingerprints[i][j]->rc>cutmax){cutmax = fingerprints[i][j]->rc;} - } - if (net[i].dimensions[0]!=fingerprintlength[i])return true; - } - return false;//everything looks good -} - -void PairRANN::compute(int eflag, int vflag) -{ - //perform force/energy computation_ - if (dospin){ - if (strcmp(update->unit_style,"metal") != 0) - error->all(FLERR,"Spin pair styles require metal units"); - if (!atom->sp_flag) - error->all(FLERR,"Spin pair styles requires atom/spin style"); - } - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = vflag_atom = 0; - int ii,i,j; - int nn = 0; - sims = new Simulation[1]; - sims->inum = listfull->inum; - sims->ilist=listfull->ilist; - sims->id = listfull->ilist; - sims->type = atom->type; - sims->x = atom->x; - sims->numneigh = listfull->numneigh; - sims->firstneigh = listfull->firstneigh; - if (dospin){ - sims->s = atom->sp; - } - int itype,f,jnum,len; - if (eflag || vflag) ev_setup(eflag,vflag); - else evflag = vflag_fdotr = eflag_global = eflag_atom = 0; - if (eflag_global){eng_vdwl=0;eng_coul=0;} - double energy=0; - double **force = atom->f; - double **fm = atom->fm; - double **virial = vatom; - char str[MAXLINE]; - //loop over atoms - for (ii=0;iiinum;ii++){ - i = sims->ilist[ii]; - itype = map[sims->type[i]]; - f = net[itype].dimensions[0]; - jnum = sims->numneigh[i]; - double *xn = new double[jnum]; - double *yn = new double[jnum]; - double *zn = new double[jnum]; - int *tn = new int[jnum]; - int *jl = new int[jnum]; - cull_neighbor_list(xn,yn,zn,tn,&jnum,jl,i,0); - double features [f]; - double *dfeaturesx = new double[f*jnum]; - double *dfeaturesy = new double[f*jnum]; - double *dfeaturesz = new double[f*jnum]; - for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - } - itype = nelements; - //do fingerprints for type "all" - len = fingerprintperelement[itype]; - for (j=0;jspin==false && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==false && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==false)fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,ii,nn,xn,yn,zn,tn,jnum-1,jl); - else if (fingerprints[itype][j]->spin==true && fingerprints[itype][j]->screen==true) fingerprints[itype][j]->compute_fingerprint(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,Sik,dSikx,dSiky,dSikz,dSijkx,dSijky,dSijkz,Bij,ii,nn,xn,yn,zn,tn,jnum-1,jl); - } - //run fingerprints through network - if (dospin){ - propagateforwardspin(features,dfeaturesx,dfeaturesy,dfeaturesz,sx,sy,sz,&energy,force,fm,virial,ii,jnum,jl); - } - else { - propagateforward(features,dfeaturesx,dfeaturesy,dfeaturesz,&energy,force,virial,ii,jnum,jl); - } - delete [] xn; - delete [] yn; - delete [] zn; - delete [] tn; - delete [] jl; - delete [] dfeaturesx; - delete [] dfeaturesy; - delete [] dfeaturesz; - delete [] Sik; - delete [] dSikx; - delete [] dSiky; - delete [] dSikz; - delete [] dSijkx; - delete [] dSijky; - delete [] dSijkz; - delete [] Bij; - delete [] sx; - delete [] sy; - delete [] sz; - } - if (vflag_fdotr) virial_fdotr_compute(); -} - -void PairRANN::cull_neighbor_list(double *xn,double *yn, double *zn,int *tn, int* jnum,int *jl,int i,int sn){ - int *jlist,j,count,jj,*type,jtype; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - double **x = sims[sn].x; - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - type = sims[sn].type; - jlist = sims[sn].firstneigh[i]; - count = 0; - for (jj=0;jjcutmax*cutmax){ - continue; - } - xn[count]=delx; - yn[count]=dely; - zn[count]=delz; - tn[count]=jtype; - jl[count]=j; - count++; - } - jnum[0]=count+1; -} - -void PairRANN::screen_neighbor_list(double *xn,double *yn, double *zn,int *tn, int* jnum,int *jl,int i,int sn,bool *Bij,double *Sik, double *dSikx, double*dSiky, double *dSikz, double *dSijkx, double *dSijky, double *dSijkz){ - double xnc[jnum[0]],ync[jnum[0]],znc[jnum[0]]; - double Sikc[jnum[0]]; - double dSikxc[jnum[0]]; - double dSikyc[jnum[0]]; - double dSikzc[jnum[0]]; - double dSijkxc[jnum[0]][jnum[0]]; - double dSijkyc[jnum[0]][jnum[0]]; - double dSijkzc[jnum[0]][jnum[0]]; - int jj,kk,count,count1,tnc[jnum[0]],jlc[jnum[0]]; - count = 0; - for (jj=0;jjx; - double xtmp,ytmp,ztmp,delx,dely,delz,rij,delx2,dely2,delz2,rik,delx3,dely3,delz3,rjk; - i = sim->ilist[ii]; - itype = map[sim->type[i]]; -// jnum = sim->numneigh[i]; -// jlist = sim->firstneigh[i]; -// xtmp = x[i][0]; -// ytmp = x[i][1]; -// ztmp = x[i][2]; - for (int jj=0;jjtype[k]]; - ktype = tn[kk]; -// delx2 = xtmp - x[k][0]; -// dely2 = ytmp - x[k][1]; -// delz2 = ztmp - x[k][2]; - delx2 = xn[kk]; - dely2 = yn[kk]; - delz2 = zn[kk]; - rik = delx2*delx2+dely2*dely2+delz2*delz2; - if (rik>cutmax*cutmax){ - Bij[kk]= false; - continue; - } - for (jj=0;jjtype[j]]; -// delx = xtmp - x[j][0]; -// dely = ytmp - x[j][1]; -// delz = ztmp - x[j][2]; - jtype = tn[jj]; - delx = xn[jj]; - dely = yn[jj]; - delz = zn[jj]; - rij = delx*delx+dely*dely+delz*delz; - if (rij>cutmax*cutmax){ - Bij[jj] = false; - continue; - } -// delx3 = x[j][0]-x[k][0]; -// dely3 = x[j][1]-x[k][1]; -// delz3 = x[j][2]-x[k][2]; - delx3 = delx2-delx; - dely3 = dely2-dely; - delz3 = delz2-delz; - rjk = delx3*delx3+dely3*dely3+delz3*delz3; - if (rik+rjk<=rij){continue;}//bond angle > 90 degrees - if (rik+rij<=rjk){continue;}//bond angle > 90 degrees - double Cmax = screening_max[itype*nelements*nelements+jtype*nelements+ktype]; - double Cmin = screening_min[itype*nelements*nelements+jtype*nelements+ktype]; - double temp1 = rij-rik+rjk; - Cn = temp1*temp1-4*rij*rjk; - //Cn = (rij-rik+rjk)*(rij-rik+rjk)-4*rij*rjk; - temp1 = rij-rjk; - Cd = temp1*temp1-rik*rik; - //Cd = (rij-rjk)*(rij-rjk)-rik*rik; - Cijk = Cn/Cd; - //Cijk = 1+2*(rik*rij+rik*rjk-rik*rik)/(rik*rik-(rij-rjk)*(rij-rjk)); - C = (Cijk-Cmin)/(Cmax-Cmin); - if (C>=1){continue;} - else if (C<=0){ - Bij[kk]=false; - break; - } - dC = Cmax-Cmin; - dC *= dC; - dC *= dC; - temp1 = 1-C; - temp1 *= temp1; - temp1 *= temp1; - Sijk = 1-temp1; - Sijk *= Sijk; - Dij = 4*rik*(Cn+4*rjk*(rij+rik-rjk))/Cd/Cd; - Dik = -4*(rij*Cn+rjk*Cn+8*rij*rik*rjk)/Cd/Cd; - Djk = 4*rik*(Cn+4*rij*(rik-rij+rjk))/Cd/Cd; - temp1 = Cijk-Cmax; - double temp2 = temp1*temp1; - dfc = 8*temp1*temp2/(temp2*temp2-dC); - Sik[kk] *= Sijk; - dSijkx[kk*jnum+jj] = dfc*(delx*Dij-delx3*Djk); - dSikx[kk] += dfc*(delx2*Dik+delx3*Djk); - dSijky[kk*jnum+jj] = dfc*(dely*Dij-dely3*Djk); - dSiky[kk] += dfc*(dely2*Dik+dely3*Djk); - dSijkz[kk*jnum+jj] = dfc*(delz*Dij-delz3*Djk); - dSikz[kk] += dfc*(delz2*Dik+delz3*Djk); - } - } -} - - -//Called by getproperties. Propagate features and dfeatures through network. Updates force and energy -void PairRANN::propagateforward(double *features,double *dfeaturesx,double *dfeaturesy,double *dfeaturesz, double * energy,double **force,double **virial, int ii,int jnum,int *jl){ - int i,j,k,jj,j1,itype,i1; - int *ilist,*numneigh; - ilist = listfull->ilist; - int inum = listfull->inum; - int *type = atom->type; - i1=ilist[ii]; - itype = map[type[i1]]; - NNarchitecture net1 = net[itype]; -// numneigh = listfull->numneigh; -// jnum = numneigh[ilist[ii]]+1;//extra value on the end of the array is the self term. -// firstneigh = listfull->firstneigh; -// jlist = firstneigh[i1]; - int L = net1.layers-1; - double layer[net1.maxlayer]; - double sum[net1.maxlayer]; - double sum1[net1.maxlayer]; - double dlayerx[jnum][net1.maxlayer]; - double dlayersumx[jnum][net1.maxlayer]; - double dlayery[jnum][net1.maxlayer]; - double dlayersumy[jnum][net1.maxlayer]; - double dlayerz[jnum][net1.maxlayer]; - double dlayersumz[jnum][net1.maxlayer]; - //energy output with forces from analytical derivatives - double dsum1; - int f = net1.dimensions[0]; - for (i=0;idactivation_function(sum[j]); - sum[j] = activation[itype][i]->activation_function(sum[j]); - if (i==L-1){ - energy[j] = sum[j]; - if (eflag_atom)eatom[i1]=sum[j]; - if (eflag_global){eng_vdwl +=sum[j];} - } - //force propagation - for (jj=0;jjilist; - int inum = listfull->inum; - int *type = atom->type; - i1=ilist[ii]; - itype = map[type[i1]]; - NNarchitecture net1 = net[itype]; -// numneigh = listfull->numneigh; -// jnum = numneigh[ilist[ii]]+1;//extra value on the end of the array is the self term. -// firstneigh = listfull->firstneigh; -// jlist = firstneigh[i1]; - int L = net1.layers-1; - double layer[net1.maxlayer]; - double sum[net1.maxlayer]; - double sum1[net1.maxlayer]; - double dlayerx[jnum][net1.maxlayer]; - double dlayersumx[jnum][net1.maxlayer]; - double dlayery[jnum][net1.maxlayer]; - double dlayersumy[jnum][net1.maxlayer]; - double dlayerz[jnum][net1.maxlayer]; - double dlayersumz[jnum][net1.maxlayer]; - double dsx[jnum][net1.maxlayer]; - double dssumx[jnum][net1.maxlayer]; - double dsy[jnum][net1.maxlayer]; - double dssumy[jnum][net1.maxlayer]; - double dsz[jnum][net1.maxlayer]; - double dssumz[jnum][net1.maxlayer]; - //energy output with forces from analytical derivatives - double dsum1; - int f = net1.dimensions[0]; - for (i=0;idactivation_function(sum[j]); - sum[j] = activation[itype][i]->activation_function(sum[j]); - if (i==L-1){ - energy[j] = sum[j]; - if (eflag_atom)eatom[i1]=sum[j]; - if (eflag_global){eng_vdwl +=sum[j];} - } - //force propagation - for (jj=0;jjrequest(this,instance_me); - neighbor->requests[irequest_full]->id = 1; - neighbor->requests[irequest_full]->half = 0; - neighbor->requests[irequest_full]->full = 1; -} - - -/* ---------------------------------------------------------------------- - init for one type pair i,j and corresponding j,i -------------------------------------------------------------------------- */ - -double PairRANN::init_one(int i, int j) -{ - return cutmax; -} - -void PairRANN::errorf(const char * message){ - this->error->all(FLERR,message); -} - -template -Fingerprint *PairRANN::fingerprint_creator(PairRANN* pair) -{ - return new T(pair); -} - -Fingerprint *PairRANN::create_fingerprint(const char *style) -{ - if (fingerprint_map->find(style) != fingerprint_map->end()) { - FingerprintCreator fingerprint_creator = (*fingerprint_map)[style]; - return fingerprint_creator(this); - } - char str[128]; - sprintf(str,"Unknown fingerprint style %s",style); - error->all(FLERR,str); - return NULL; -} - -template -Activation *PairRANN::activation_creator(PairRANN* pair) -{ - return new T(pair); -} - -Activation *PairRANN::create_activation(const char *style) -{ - if (activation_map->find(style) != activation_map->end()) { - ActivationCreator activation_creator = (*activation_map)[style]; - return activation_creator(this); - } - char str[128]; - sprintf(str,"Unknown activation style %s",style); - error->all(FLERR,str); - return NULL; -} - diff --git a/src/pair_rann.h b/src/pair_rann.h deleted file mode 100644 index 1358c67fb0..0000000000 --- a/src/pair_rann.h +++ /dev/null @@ -1,171 +0,0 @@ -/* -*- 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. -------------------------------------------------------------------------- */ -/* ---------------------------------------------------------------------- - Contributing authors: Christopher Barrett (MSU) barrett@me.msstate.edu - Doyl Dickel (MSU) doyl@me.msstate.edu - ----------------------------------------------------------------------*/ -/* -“The research described and the resulting data presented herein, unless -otherwise noted, was funded under PE 0602784A, Project T53 "Military -Engineering Applied Research", Task 002 under Contract No. W56HZV-17-C-0095, -managed by the U.S. Army Combat Capabilities Development Command (CCDC) and -the Engineer Research and Development Center (ERDC). The work described in -this document was conducted at CAVS, MSU. Permission was granted by ERDC -to publish this information. Any opinions, findings and conclusions or -recommendations expressed in this material are those of the author(s) and -do not necessarily reflect the views of the United States Army.​” - -DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 - */ - -#ifdef PAIR_CLASS - -PairStyle(rann,PairRANN) - -#else - -#ifndef LMP_PAIR_RANN -#define LMP_PAIR_RANN - -#define MAXLINE 1024 - -#include -#include -#include -#include -#include -#include "atom.h" -#include "force.h" -#include "comm.h" -#include "memory.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "neigh_request.h" -#include "memory.h" -#include "error.h" -#include "update.h" -#include "pair.h" -#include -#include - -namespace LAMMPS_NS { - -class PairRANN : public Pair { - public: - - //inherited functions - PairRANN(class LAMMPS *); - ~PairRANN(); - void compute(int, int); - void settings(int, char **); - void coeff(int, char **); - void init_style(); - double init_one(int, int); - void init_list(int , NeighList *); - void errorf(const char*); - int count_words(char *); - //black magic for modular fingerprints and activations - class Activation ***activation; - class Fingerprint ***fingerprints; - typedef Fingerprint *(*FingerprintCreator)(PairRANN *); - typedef Activation *(*ActivationCreator)(PairRANN *); - typedef std::map FingerprintCreatorMap; - typedef std::map ActivationCreatorMap; - FingerprintCreatorMap *fingerprint_map; - ActivationCreatorMap *activation_map; - Fingerprint * create_fingerprint(const char *); - Activation * create_activation(const char *); - - //global variables - int nelements; // # of elements (distinct from LAMMPS atom types since multiple atom types can be mapped to one element) - int nelementsp; // nelements+1 - char **elements; // names of elements - char **elementsp; // names of elements with "all" appended as the last "element" - double *mass; // mass of each element - double cutmax; // max radial distance for neighbor lists - int *map; // mapping from atom types to elements - int *fingerprintcount; // static variable used in initialization - int *fingerprintlength; // # of input neurons defined by fingerprints of each element. - int *fingerprintperelement; // # of fingerprints for each element - bool doscreen;//screening is calculated if any defined fingerprint uses it - bool allscreen;//all fingerprints use screening so screened neighbors can be completely ignored - bool dospin; - int res;//Resolution of function tables for cubic interpolation. - int memguess; - double *screening_min; - double *screening_max; - bool **weightdefined; - bool **biasdefined; - - struct Simulation{ - int *id; - bool forces; - bool spins; - double **x; - double **f; - double **s; - double box[3][3]; - double origin[3]; - double **features; - double **dfx; - double **dfy; - double **dfz; - double **dsx; - double **dsy; - double **dsz; - int *ilist,*numneigh,**firstneigh,*type,inum,gnum; - }; - Simulation *sims; - - struct NNarchitecture{ - int layers; - int *dimensions;//vector of length layers with entries for neurons per layer - double **Weights; - double **Biases; - int *activations;//unused - int maxlayer;//longest layer (for memory allocation) - }; - NNarchitecture *net;//array of networks, 1 for each element. - - private: - template static Fingerprint *fingerprint_creator(PairRANN *); - template static Activation *activation_creator(PairRANN *); - //new functions - void allocate(char **);//called after reading element list, but before reading the rest of the potential - void read_file(char *);//read potential file - void read_atom_types(char **,char *); - void read_mass(char **,char *); - void read_fpe(char**,char *);//fingerprints per element. Count total fingerprints defined for each 1st element in element combinations - void read_fingerprints(char **,int,char *); - void read_fingerprint_constants(char **,int,char *); - void read_network_layers(char**,char*);//include input and output layer (hidden layers + 2) - void read_layer_size(char**,char*); - void read_weight(char**,char*,FILE*);//weights should be formatted as properly shaped matrices - void read_bias(char**,char*,FILE*);//biases should be formatted as properly shaped vectors - void read_activation_functions(char**,char*); - void read_screening(char**,int, char*); - bool check_potential();//after finishing reading potential file - void propagateforward(double *,double *,double *,double *,double *,double **,double **,int,int,int*);//called by compute to get force and energy - void propagateforwardspin(double *,double *,double *,double *,double *,double *,double *,double *,double **,double **,double**,int,int,int*);//called by compute to get force and energy - void screen(double*,double*,double*,double*,double*,double*,double*,bool*,int,int,double*,double*,double*,int *,int); - void cull_neighbor_list(double *,double *,double *,int *,int *,int *,int,int); - void screen_neighbor_list(double *,double *,double *,int *,int *,int *,int,int,bool*,double*,double*,double*,double*,double*,double*,double*); -}; - -} - -#endif -#endif - - - From 8dee6cee8d0535de6ea897554d2c115d13c3a756 Mon Sep 17 00:00:00 2001 From: kipbarrett Date: Thu, 11 Feb 2021 09:25:42 -0600 Subject: [PATCH 06/25] remove style files from src --- src/style_activation.h | 2 -- src/style_fingerprint.h | 8 -------- 2 files changed, 10 deletions(-) delete mode 100644 src/style_activation.h delete mode 100644 src/style_fingerprint.h diff --git a/src/style_activation.h b/src/style_activation.h deleted file mode 100644 index 4cdd4ff031..0000000000 --- a/src/style_activation.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "activation_linear.h" -#include "activation_sigI.h" diff --git a/src/style_fingerprint.h b/src/style_fingerprint.h deleted file mode 100644 index 2647d31274..0000000000 --- a/src/style_fingerprint.h +++ /dev/null @@ -1,8 +0,0 @@ -#include "fingerprint_bond.h" -#include "fingerprint_bondscreened.h" -#include "fingerprint_bondscreenedspin.h" -#include "fingerprint_bondspin.h" -#include "fingerprint_radial.h" -#include "fingerprint_radialscreened.h" -#include "fingerprint_radialscreenedspin.h" -#include "fingerprint_radialspin.h" From b5e1851e5da47f0dc1ab57cf16c7aec357491f2b Mon Sep 17 00:00:00 2001 From: kipbarrett Date: Fri, 5 Mar 2021 16:47:13 -0600 Subject: [PATCH 07/25] removed factory creation --- src/USER-RANN/rann_list_activation.h | 2 -- src/USER-RANN/rann_list_fingerprint.h | 8 -------- 2 files changed, 10 deletions(-) delete mode 100644 src/USER-RANN/rann_list_activation.h delete mode 100644 src/USER-RANN/rann_list_fingerprint.h diff --git a/src/USER-RANN/rann_list_activation.h b/src/USER-RANN/rann_list_activation.h deleted file mode 100644 index a140b92c65..0000000000 --- a/src/USER-RANN/rann_list_activation.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "rann_activation_linear.h" -#include "rann_activation_sig_i.h" diff --git a/src/USER-RANN/rann_list_fingerprint.h b/src/USER-RANN/rann_list_fingerprint.h deleted file mode 100644 index 005c7f1b04..0000000000 --- a/src/USER-RANN/rann_list_fingerprint.h +++ /dev/null @@ -1,8 +0,0 @@ -#include "rann_fingerprint_bond.h" -#include "rann_fingerprint_bondscreened.h" -#include "rann_fingerprint_bondscreenedspin.h" -#include "rann_fingerprint_bondspin.h" -#include "rann_fingerprint_radial.h" -#include "rann_fingerprint_radialscreened.h" -#include "rann_fingerprint_radialscreenedspin.h" -#include "rann_fingerprint_radialspin.h" From 02021eb3302654c0851e5c5250575a1e5ddbc768 Mon Sep 17 00:00:00 2001 From: kipbarrett Date: Fri, 5 Mar 2021 16:49:04 -0600 Subject: [PATCH 08/25] removed factory creation --- src/USER-RANN/pair_rann.cpp | 274 +++++++++++++++++++----------------- src/USER-RANN/pair_rann.h | 90 ++++++------ 2 files changed, 186 insertions(+), 178 deletions(-) diff --git a/src/USER-RANN/pair_rann.cpp b/src/USER-RANN/pair_rann.cpp index 3207b76934..0dcf3740a6 100644 --- a/src/USER-RANN/pair_rann.cpp +++ b/src/USER-RANN/pair_rann.cpp @@ -29,8 +29,6 @@ DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 */ #define MAXLINE 1024 #include "pair_rann.h" -#include "rann_list_activation.h" -#include "rann_list_fingerprint.h" #include "tokenizer.h" #include #include @@ -45,6 +43,17 @@ DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 #include "error.h" #include "update.h" #include "math_special.h" +#include "rann_fingerprint_bond.h" +#include "rann_fingerprint_bondscreened.h" +#include "rann_fingerprint_bondscreenedspin.h" +#include "rann_fingerprint_bondspin.h" +#include "rann_fingerprint_radial.h" +#include "rann_fingerprint_radialscreened.h" +#include "rann_fingerprint_radialscreenedspin.h" +#include "rann_fingerprint_radialspin.h" +#include "rann_activation_linear.h" +#include "rann_activation_sig_i.h" + using namespace LAMMPS_NS; @@ -83,22 +92,7 @@ PairRANN::PairRANN(LAMMPS *lmp) : Pair(lmp) allscreen = true; dospin = false; - fingerprint_map = new FingerprintCreatorMap(); - #define FINGERPRINT_CLASS - #define FingerprintStyle(key,Class) \ - (*fingerprint_map)[#key] = &fingerprint_creator; - #include "rann_list_fingerprint.h" - #undef FingerprintStyle - #undef FINGERPRINT_CLASS - activation_map = new ActivationCreatorMap(); - #define ACTIVATION_CLASS - #define ActivationStyle(key,Class) \ - (*activation_map)[#key] = &activation_creator; - - #include "rann_list_activation.h" - #undef ActivationStyle - #undef ACTIVATION_CLASS } PairRANN::~PairRANN() @@ -181,7 +175,7 @@ PairRANN::~PairRANN() -void PairRANN::allocate(std::vector elementwords) +void PairRANN::allocate(const std::vector elementwords) { int i,j,k,l,n; n = atom->ntypes; @@ -295,7 +289,9 @@ void PairRANN::read_file(char *filename) int n,nwords; std::string line,line1; int longline = 4096; + int linenum; char linetemp[longline]; + std::string strtemp; char *ptr; bool comment; char str[128]; @@ -303,10 +299,17 @@ void PairRANN::read_file(char *filename) fp = utils::open_potential(filename,lmp,nullptr); if (fp == nullptr) {error->one(FLERR,"Cannot open RANN potential file");} ptr=fgets(linetemp,longline,fp); - strip_comments(linetemp,fp); - line=linetemp; + linenum++; + strtemp=utils::trim_comment(linetemp); + while (strtemp.empty()) { + ptr=fgets(linetemp,longline,fp); + strtemp=utils::trim_comment(linetemp); + linenum++; + } + line=strtemp; while (eof == 0) { ptr=fgets(linetemp,longline,fp); + linenum++; if (ptr == NULL) { if (check_potential()) { error->one(FLERR,"Invalid syntax in potential file, values are inconsistent or missing"); @@ -316,27 +319,38 @@ void PairRANN::read_file(char *filename) break; } } - strip_comments(linetemp,fp); + strtemp=utils::trim_comment(linetemp); + while (strtemp.empty()) { + ptr=fgets(linetemp,longline,fp); + strtemp=utils::trim_comment(linetemp); + linenum++; + } line1=linetemp; Tokenizer values = Tokenizer(line,": ,\t_\n"); Tokenizer values1 = Tokenizer(line1,": ,\t_\n"); linev = values.as_vector(); line1v = values1.as_vector(); - if (linev[0].compare("atomtypes")==0)read_atom_types(linev,line1v); - else if (linev[0].compare("mass")==0)read_mass(linev,line1v); - else if (linev[0].compare("fingerprintsperelement")==0)read_fpe(linev,line1v); - else if (linev[0].compare("fingerprints")==0)read_fingerprints(linev,line1v); - else if (linev[0].compare("fingerprintconstants")==0)read_fingerprint_constants(linev,line1v); - else if (linev[0].compare("networklayers")==0)read_network_layers(linev,line1v); - else if (linev[0].compare("layersize")==0)read_layer_size(linev,line1v); - else if (linev[0].compare("weight")==0)read_weight(linev,line1v,fp); - else if (linev[0].compare("bias")==0)read_bias(linev,line1v,fp); - else if (linev[0].compare("activationfunctions")==0)read_activation_functions(linev,line1v); - else if (linev[0].compare("calibrationparameters")==0)continue;//information on how the network was trained - else if (linev[0].compare("screening")==0)read_screening(linev,line1v); + if (linev[0]=="atomtypes") read_atom_types(linev,line1v,filename,linenum); + else if (linev[0]=="mass") read_mass(linev,line1v,filename,linenum); + else if (linev[0]=="fingerprintsperelement") read_fpe(linev,line1v,filename,linenum); + else if (linev[0]=="fingerprints") read_fingerprints(linev,line1v,filename,linenum); + else if (linev[0]=="fingerprintconstants") read_fingerprint_constants(linev,line1v,filename,linenum); + else if (linev[0]=="networklayers") read_network_layers(linev,line1v,filename,linenum); + else if (linev[0]=="layersize") read_layer_size(linev,line1v,filename,linenum); + else if (linev[0]=="weight") read_weight(linev,line1v,fp,filename,&linenum); + else if (linev[0]=="bias") read_bias(linev,line1v,fp,filename,&linenum); + else if (linev[0]=="activationfunctions") read_activation_functions(linev,line1v,filename,linenum); + else if (linev[0]=="screening") read_screening(linev,line1v,filename,linenum); + else if (linev[0]=="calibrationparameters") continue;//information on how the network was trained else error->one(FLERR,"Could not understand file syntax: unknown keyword"); ptr=fgets(linetemp,longline,fp); - strip_comments(linetemp,fp); + linenum++; + strtemp=utils::trim_comment(linetemp); + while (strtemp.empty()) { + ptr=fgets(linetemp,longline,fp); + strtemp=utils::trim_comment(linetemp); + linenum++; + } if (ptr == NULL) { if (check_potential()) { error->one(FLERR,"Invalid syntax in potential file, values are inconsistent or missing"); @@ -350,49 +364,32 @@ void PairRANN::read_file(char *filename) } } -void PairRANN::strip_comments(char * line,FILE* fp) { - char *ptr; - bool comment; - utils::trim_comment(line); - if (strlen(line)==0) { - comment = true; - while (comment==true) { - ptr = fgets(line,4096,fp); - if (ptr==NULL) error->one(FLERR,"Unexpected end of RANN file"); - utils::trim_comment(line); - if (strlen(line) == 0) continue; - comment = false; - } - } -} - -void PairRANN::read_atom_types(std::vector line,std::vector line1) { +void PairRANN::read_atom_types(std::vector line,std::vector line1,char *filename,int linenum) { int nwords = line1.size(); - if (nwords < 1) error->one(FLERR,"Incorrect syntax for atom types"); + if (nwords < 1) error->one(filename,linenum,"Incorrect syntax for atom types"); nelements = nwords; - line1.resize(nwords+1); - line1[nwords] = "all"; + line1.push_back("all"); allocate(line1); } -void PairRANN::read_mass(std::vector line,std::vector line1) { - if (nelements == -1)error->one(FLERR,"atom types must be defined before mass in potential file."); +void PairRANN::read_mass(std::vector line,std::vector line1,char *filename,int linenum) { + if (nelements == -1)error->one(filename,linenum-1,"atom types must be defined before mass in potential file."); int nwords = 0,i; for (i=0;ione(FLERR,"mass element not found in atom types."); + error->one(filename,linenum-1,"mass element not found in atom types."); } -void PairRANN::read_fpe(std::vector line,std::vector line1) { +void PairRANN::read_fpe(std::vector line,std::vector line1,char *filename,int linenum) { int i,j; - if (nelements == -1)error->one(FLERR,"atom types must be defined before fingerprints per element in potential file."); + if (nelements == -1)error->one(filename,linenum-1,"atom types must be defined before fingerprints per element in potential file."); for (i=0;i line,std::vector l return; } } - error->one(FLERR,"fingerprint-per-element element not found in atom types"); + error->one(filename,linenum-1,"fingerprint-per-element element not found in atom types"); } -void PairRANN::read_fingerprints(std::vector line,std::vector line1) { +void PairRANN::read_fingerprints(std::vector line,std::vector line1,char *filename,int linenum) { int nwords1,nwords,i,j,k,l,m,i1; bool found; char str[MAXLINE]; nwords1 = line1.size(); nwords = line.size(); - if (nelements == -1)error->one(FLERR,"atom types must be defined before fingerprints in potential file."); + if (nelements == -1)error->one(filename,linenum-1,"atom types must be defined before fingerprints in potential file."); int atomtypes[nwords-1]; for (i=1;i line,std::vectorone(FLERR,"fingerprint element not found in atom types");} + if (!found) {error->one(filename,linenum-1,"fingerprint element not found in atom types");} } i = atomtypes[0]; k = 0; - if (fingerprintperelement[i]==-1) {error->one(FLERR,"fingerprint per element must be defined before fingerprints");} + if (fingerprintperelement[i]==-1) {error->one(filename,linenum-1,"fingerprint per element must be defined before fingerprints");} while (k=fingerprintperelement[i]) {error->one(filename,linenum,"more fingerprints defined than fingerprint per element");} delete fingerprints[i][i1]; fingerprints[i][i1] = create_fingerprint(line1[k].c_str()); - if (fingerprints[i][i1]->n_body_type!=nwords-1) {error->one(FLERR,"invalid fingerprint for element combination");} + if (fingerprints[i][i1]->n_body_type!=nwords-1) {error->one(filename,linenum,"invalid fingerprint for element combination");} k++; - fingerprints[i][i1]->init(atomtypes,strtol(line1[k++].c_str(),NULL,10)); + fingerprints[i][i1]->init(atomtypes,utils::inumeric(filename,linenum,line1[k++].c_str(),1,lmp)); fingerprintcount[i]++; } } - -void PairRANN::read_fingerprint_constants(std::vector line,std::vector line1) { +void PairRANN::read_fingerprint_constants(std::vector line,std::vector line1,char *filename,int linenum) { int i,j,k,l,m,i1; bool found; char str [128]; int nwords = line.size(); - if (nelements == -1)error->one(FLERR,"atom types must be defined before fingerprints in potential file."); + if (nelements == -1)error->one(filename,linenum-1,"atom types must be defined before fingerprints in potential file."); int n_body_type = nwords-4; int atomtypes[n_body_type]; for (i=1;i<=n_body_type;i++) { @@ -454,7 +451,7 @@ void PairRANN::read_fingerprint_constants(std::vector line,std::vec break; } } - if (!found) {error->one(FLERR,"fingerprint element not found in atom types");} + if (!found) {error->one(filename,linenum-1,"fingerprint element not found in atom types");} } i = atomtypes[0]; found = false; @@ -464,7 +461,7 @@ void PairRANN::read_fingerprint_constants(std::vector line,std::vec for (j=0;jatomtypes[j]!=atomtypes[j]) {break;} if (j==n_body_type-1) { - if (line[nwords-3].compare(fingerprints[i][k]->style)==0 && strtol(line[nwords-2].c_str(),NULL,10)==fingerprints[i][k]->id) { + if (line[nwords-3].compare(fingerprints[i][k]->style)==0 && utils::inumeric(filename,linenum,line[nwords-2].c_str(),1,lmp)==fingerprints[i][k]->id) { found=true; i1 = k; break; @@ -473,17 +470,17 @@ void PairRANN::read_fingerprint_constants(std::vector line,std::vec } if (found) {break;} } - if (!found) {error->one(FLERR,"cannot define constants for unknown fingerprint");} + if (!found) {error->one(filename,linenum-1,"cannot define constants for unknown fingerprint");} fingerprints[i][i1]->fullydefined=fingerprints[i][i1]->parse_values(line[nwords-1],line1); } -void PairRANN::read_network_layers(std::vector line,std::vector line1) { +void PairRANN::read_network_layers(std::vector line,std::vector line1,char *filename,int linenum) { int i,j; - if (nelements == -1)error->one(FLERR,"atom types must be defined before network layers in potential file."); + if (nelements == -1)error->one(filename,linenum-1,"atom types must be defined before network layers in potential file."); for (i=0;ione(FLERR,"invalid number of network layers"); + net[i].layers = utils::inumeric(filename,linenum,line1[0].c_str(),1,lmp); + if (net[i].layers < 1)error->one(filename,linenum,"invalid number of network layers"); delete [] net[i].dimensions; weightdefined[i] = new bool [net[i].layers]; biasdefined[i] = new bool [net[i].layers]; @@ -504,105 +501,107 @@ void PairRANN::read_network_layers(std::vector line,std::vectorone(FLERR,"network layers element not found in atom types"); + error->one(filename,linenum-1,"network layers element not found in atom types"); } -void PairRANN::read_layer_size(std::vector line,std::vector line1) { +void PairRANN::read_layer_size(std::vector line,std::vector line1,char *filename,int linenum) { int i; for (i=0;ione(FLERR,"networklayers for each atom type must be defined before the corresponding layer sizes."); - int j = strtol(line[2].c_str(),NULL,10); - if (j>=net[i].layers || j<0) {error->one(FLERR,"invalid layer in layer size definition");}; - net[i].dimensions[j]= strtol(line1[0].c_str(),NULL,10); + if (net[i].layers==0)error->one(filename,linenum-1,"networklayers for each atom type must be defined before the corresponding layer sizes."); + int j = utils::inumeric(filename,linenum,line[2].c_str(),1,lmp); + if (j>=net[i].layers || j<0) {error->one(filename,linenum,"invalid layer in layer size definition");}; + net[i].dimensions[j]= utils::inumeric(filename,linenum,line1[0].c_str(),1,lmp); return; } } - error->one(FLERR,"layer size element not found in atom types"); + error->one(filename,linenum-1,"layer size element not found in atom types"); } -void PairRANN::read_weight(std::vector line,std::vector line1,FILE* fp) { +void PairRANN::read_weight(std::vector line,std::vector line1,FILE* fp,char *filename,int *linenum) { int i,j,k,l,nwords; char *ptr; int longline = 4096; char linetemp [longline]; for (l=0;lone(FLERR,"networklayers must be defined before weights."); - i=strtol(line[2].c_str(),NULL,10); - if (i>=net[l].layers || i<0)error->one(FLERR,"invalid weight layer"); - if (net[l].dimensions[i]==0 || net[l].dimensions[i+1]==0) error->one(FLERR,"network layer sizes must be defined before corresponding weight"); + if (net[l].layers==0)error->one(filename,*linenum-1,"networklayers must be defined before weights."); + i=utils::inumeric(filename,*linenum,line[2].c_str(),1,lmp); + if (i>=net[l].layers || i<0)error->one(filename,*linenum-1,"invalid weight layer"); + if (net[l].dimensions[i]==0 || net[l].dimensions[i+1]==0) error->one(filename,*linenum-1,"network layer sizes must be defined before corresponding weight"); net[l].Weights[i] = new double [net[l].dimensions[i]*net[l].dimensions[i+1]]; weightdefined[l][i] = true; nwords = line1.size(); - if (nwords != net[l].dimensions[i])error->one(FLERR,"invalid weights per line"); + if (nwords != net[l].dimensions[i])error->one(filename,*linenum,"invalid weights per line"); for (k=0;kone(FLERR,"unexpected end of potential file!"); + if (ptr==NULL)error->one(filename,*linenum,"unexpected end of potential file!"); nwords = line1.size(); - if (nwords != net[l].dimensions[i])error->one(FLERR,"invalid weights per line"); + if (nwords != net[l].dimensions[i])error->one(filename,*linenum,"invalid weights per line"); for (k=0;kone(FLERR,"weight element not found in atom types"); + error->one(filename,*linenum-1,"weight element not found in atom types"); } -void PairRANN::read_bias(std::vector line,std::vector line1,FILE* fp) { +void PairRANN::read_bias(std::vector line,std::vector line1,FILE* fp,char *filename,int *linenum) { int i,j,l,nwords; char *ptr; char linetemp[MAXLINE]; for (l=0;lone(FLERR,"networklayers must be defined before biases."); - i=strtol(line[2].c_str(),NULL,10); - if (i>=net[l].layers || i<0)error->one(FLERR,"invalid bias layer"); - if (net[l].dimensions[i]==0) error->one(FLERR,"network layer sizes must be defined before corresponding bias"); + if (net[l].layers==0)error->one(filename,*linenum-1,"networklayers must be defined before biases."); + i=utils::inumeric(filename,*linenum,line[2].c_str(),1,lmp); + if (i>=net[l].layers || i<0)error->one(filename,*linenum-1,"invalid bias layer"); + if (net[l].dimensions[i]==0) error->one(filename,*linenum-1,"network layer sizes must be defined before corresponding bias"); biasdefined[l][i] = true; net[l].Biases[i] = new double [net[l].dimensions[i+1]]; - net[l].Biases[i][0] = strtod(line1[0].c_str(),NULL); + net[l].Biases[i][0] = utils::numeric(filename,*linenum,line1[0].c_str(),1,lmp); for (j=1;jone(FLERR,"bias element not found in atom types"); + error->one(filename,*linenum-1,"bias element not found in atom types"); } -void PairRANN::read_activation_functions(std::vector line,std::vector line1) { +void PairRANN::read_activation_functions(std::vector line,std::vector line1,char *filename,int linenum) { int i,j,l,nwords; int *ptr; for (l=0;lone(FLERR,"networklayers must be defined before activation functions."); + if (net[l].layers==0)error->one(filename,linenum-1,"networklayers must be defined before activation functions."); i = strtol(line[2].c_str(),NULL,10); - if (i>=net[l].layers || i<0)error->one(FLERR,"invalid activation layer"); + if (i>=net[l].layers || i<0)error->one(filename,linenum-1,"invalid activation layer"); delete activation[l][i]; activation[l][i]=create_activation(line1[0].c_str()); return; } } - error->one(FLERR,"activation function element not found in atom types"); + error->one(filename,linenum-1,"activation function element not found in atom types"); } -void PairRANN::read_screening(std::vector line,std::vector line1) { +void PairRANN::read_screening(std::vector line,std::vector line1,char *filename,int linenum) { int i,j,k; bool found; int nwords = line.size(); - if (nelements == -1)error->one(FLERR,"atom types must be defined before fingerprints in potential file."); - if (nwords!=5)error->one(FLERR,"invalid screening command"); + if (nelements == -1)error->one(filename,linenum-1,"atom types must be defined before fingerprints in potential file."); + if (nwords!=5)error->one(filename,linenum-1,"invalid screening command"); int n_body_type = 3; int atomtypes[n_body_type]; for (i=1;i<=n_body_type;i++) { @@ -614,7 +613,7 @@ void PairRANN::read_screening(std::vector line,std::vectorone(FLERR,"fingerprint element not found in atom types");} + if (!found) {error->one(filename,linenum-1,"fingerprint element not found in atom types");} } i = atomtypes[0]; j = atomtypes[1]; @@ -622,14 +621,14 @@ void PairRANN::read_screening(std::vector line,std::vectorone(FLERR,"unrecognized screening keyword"); + else error->one(filename,linenum-1,"unrecognized screening keyword"); } //Called after finishing reading the potential file to make sure it is complete. True is bad. @@ -1223,17 +1222,31 @@ int PairRANN::factorial(int n) { return round(MathSpecial::factorial(n)); } -template -RANN::Fingerprint *PairRANN::fingerprint_creator(PairRANN* pair) -{ - return new T(pair); -} - RANN::Fingerprint *PairRANN::create_fingerprint(const char *style) { - if (fingerprint_map->find(style) != fingerprint_map->end()) { - FingerprintCreator fingerprint_creator = (*fingerprint_map)[style]; - return fingerprint_creator(this); + if (strcmp(style,"radial")==0) { + return new RANN::Fingerprint_radial(this); + } + else if (strcmp(style,"radialscreened")==0) { + return new RANN::Fingerprint_radialscreened(this); + } + else if (strcmp(style,"radialscreenedspin")==0) { + return new RANN::Fingerprint_radialscreenedspin(this); + } + else if (strcmp(style,"radialspin")==0) { + return new RANN::Fingerprint_radialspin(this); + } + else if (strcmp(style,"bond")==0) { + return new RANN::Fingerprint_bond(this); + } + else if (strcmp(style,"bondscreened")==0) { + return new RANN::Fingerprint_bondscreened(this); + } + else if (strcmp(style,"bondscreenedspin")==0) { + return new RANN::Fingerprint_bondscreenedspin(this); + } + else if (strcmp(style,"bondspin")==0) { + return new RANN::Fingerprint_bondspin(this); } char str[128]; sprintf(str,"Unknown fingerprint style %s",style); @@ -1241,17 +1254,14 @@ RANN::Fingerprint *PairRANN::create_fingerprint(const char *style) return NULL; } -template -RANN::Activation *PairRANN::activation_creator(PairRANN* pair) -{ - return new T(pair); -} RANN::Activation *PairRANN::create_activation(const char *style) { - if (activation_map->find(style) != activation_map->end()) { - ActivationCreator activation_creator = (*activation_map)[style]; - return activation_creator(this); + if (strcmp(style,"linear")==0) { + return new RANN::Activation_linear(this); + } + else if (strcmp(style,"sigI")==0) { + return new RANN::Activation_sigI(this); } char str[128]; sprintf(str,"Unknown activation style %s",style); diff --git a/src/USER-RANN/pair_rann.h b/src/USER-RANN/pair_rann.h index 9f1dbe9212..a50a46f8a2 100644 --- a/src/USER-RANN/pair_rann.h +++ b/src/USER-RANN/pair_rann.h @@ -41,7 +41,6 @@ PairStyle(rann,PairRANN) #include "neighbor.h" #include "neigh_list.h" #include "pair.h" -#include namespace LAMMPS_NS { @@ -65,15 +64,13 @@ namespace LAMMPS_NS { void init_list(int , NeighList *); void errorf(const char*,int,const char*); int factorial(int); - //black magic for modular fingerprints and activations - class RANN::Activation ***activation; - class RANN::Fingerprint ***fingerprints; - typedef RANN::Fingerprint *(*FingerprintCreator)(PairRANN *); - typedef RANN::Activation *(*ActivationCreator)(PairRANN *); - typedef std::map FingerprintCreatorMap; - typedef std::map ActivationCreatorMap; - FingerprintCreatorMap *fingerprint_map; - ActivationCreatorMap *activation_map; + +// typedef RANN::Fingerprint *(*FingerprintCreator)(PairRANN *); +// typedef RANN::Activation *(*ActivationCreator)(PairRANN *); +// typedef std::map FingerprintCreatorMap; +// typedef std::map ActivationCreatorMap; +// FingerprintCreatorMap *fingerprint_map; +// ActivationCreatorMap *activation_map; RANN::Fingerprint * create_fingerprint(const char *); RANN::Activation * create_activation(const char *); @@ -110,53 +107,54 @@ namespace LAMMPS_NS { struct Simulation{ int *id; - bool forces; - bool spins; - double **x; - double **f; - double **s; - double box[3][3]; - double origin[3]; - double **features; - double **dfx; - double **dfy; - double **dfz; - double **dsx; - double **dsy; - double **dsz; - int *ilist,*numneigh,**firstneigh,*type,inum,gnum; + bool forces; + bool spins; + double **x; + double **f; + double **s; + double box[3][3]; + double origin[3]; + double **features; + double **dfx; + double **dfy; + double **dfz; + double **dsx; + double **dsy; + double **dsz; + int *ilist,*numneigh,**firstneigh,*type,inum,gnum; }; struct NNarchitecture{ - int layers; - int *dimensions;//vector of length layers with entries for neurons per layer - double **Weights; - double **Biases; - int *activations;//unused - int maxlayer;//longest layer (for memory allocation) + int layers; + int *dimensions;//vector of length layers with entries for neurons per layer + double **Weights; + double **Biases; + int *activations;//unused + int maxlayer;//longest layer (for memory allocation) }; Simulation *sims; NNarchitecture *net;//array of networks, 1 for each element. + protected: + RANN::Activation ***activation; + RANN::Fingerprint ***fingerprints; + private: - template static RANN::Fingerprint *fingerprint_creator(PairRANN *); - template static RANN::Activation *activation_creator(PairRANN *); //new functions - void allocate(std::vector);//called after reading element list, but before reading the rest of the potential + void allocate(const std::vector);//called after reading element list, but before reading the rest of the potential void read_file(char *);//read potential file - void strip_comments(char *,FILE *fp); - void read_atom_types(std::vector,std::vector); - void read_mass(std::vector,std::vector); - void read_fpe(std::vector,std::vector);//fingerprints per element. Count total fingerprints defined for each 1st element in element combinations - void read_fingerprints(std::vector,std::vector); - void read_fingerprint_constants(std::vector,std::vector); - void read_network_layers(std::vector,std::vector);//include input and output layer (hidden layers + 2) - void read_layer_size(std::vector,std::vector); - void read_weight(std::vector,std::vector,FILE*);//weights should be formatted as properly shaped matrices - void read_bias(std::vector,std::vector,FILE*);//biases should be formatted as properly shaped vectors - void read_activation_functions(std::vector,std::vector); - void read_screening(std::vector,std::vector); + void read_atom_types(std::vector,std::vector,char*,int); + void read_mass(std::vector,std::vector,char*,int); + void read_fpe(std::vector,std::vector,char*,int);//fingerprints per element. Count total fingerprints defined for each 1st element in element combinations + void read_fingerprints(std::vector,std::vector,char*,int); + void read_fingerprint_constants(std::vector,std::vector,char*,int); + void read_network_layers(std::vector,std::vector,char*,int);//include input and output layer (hidden layers + 2) + void read_layer_size(std::vector,std::vector,char*,int); + void read_weight(std::vector,std::vector,FILE*,char*,int*);//weights should be formatted as properly shaped matrices + void read_bias(std::vector,std::vector,FILE*,char*,int*);//biases should be formatted as properly shaped vectors + void read_activation_functions(std::vector,std::vector,char*,int); + void read_screening(std::vector,std::vector,char*,int); bool check_potential();//after finishing reading potential file void propagateforward(double *,double **,double **,int,int);//called by compute to get force and energy void propagateforwardspin(double *,double **,double **,double**,int,int);//called by compute to get force and energy From fdf06e48b2cfc0b8ec6264c73c3dfafbb05261ec Mon Sep 17 00:00:00 2001 From: kipbarrett Date: Fri, 5 Mar 2021 16:53:49 -0600 Subject: [PATCH 09/25] removed factory creation --- src/USER-RANN/pair_rann.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/USER-RANN/pair_rann.h b/src/USER-RANN/pair_rann.h index a50a46f8a2..23bea7a800 100644 --- a/src/USER-RANN/pair_rann.h +++ b/src/USER-RANN/pair_rann.h @@ -65,12 +65,6 @@ namespace LAMMPS_NS { void errorf(const char*,int,const char*); int factorial(int); -// typedef RANN::Fingerprint *(*FingerprintCreator)(PairRANN *); -// typedef RANN::Activation *(*ActivationCreator)(PairRANN *); -// typedef std::map FingerprintCreatorMap; -// typedef std::map ActivationCreatorMap; -// FingerprintCreatorMap *fingerprint_map; -// ActivationCreatorMap *activation_map; RANN::Fingerprint * create_fingerprint(const char *); RANN::Activation * create_activation(const char *); From 4ea9a9bf049e7185b949a5f52d83ddb14563e071 Mon Sep 17 00:00:00 2001 From: kipbarrett Date: Mon, 29 Mar 2021 15:23:22 -0500 Subject: [PATCH 10/25] Removed screening symmetry and added rann example --- examples/USER/rann/TiZr_2.nn | 277 +++++++++++++++++++++++++++++++++++ examples/USER/rann/in.lammps | 45 ++++++ src/USER-RANN/pair_rann.cpp | 3 - 3 files changed, 322 insertions(+), 3 deletions(-) create mode 100644 examples/USER/rann/TiZr_2.nn create mode 100644 examples/USER/rann/in.lammps diff --git a/examples/USER/rann/TiZr_2.nn b/examples/USER/rann/TiZr_2.nn new file mode 100644 index 0000000000..7ebdebf320 --- /dev/null +++ b/examples/USER/rann/TiZr_2.nn @@ -0,0 +1,277 @@ +#iter: 3957, evals: 6770, e_err: 1.2959304580e-05, e1: 1.2959304580e-05, ev_err 1.4570936792e-05, r_err: 1.0147937957e-06, lambda: 1.4986245485e+50 +atomtypes: +Ti Zr +mass:Ti: +47.867000 +mass:Zr: +91.224000 +fingerprintsperelement:Ti: +3 +fingerprintsperelement:Zr: +3 +fingerprints:Ti_Ti: +radialscreened_0 +fingerprints:Ti_all_all: +bondscreened_0 +fingerprints:Ti_Zr: +radialscreened_0 +fingerprints:Zr_Zr: +radialscreened_0 +fingerprints:Zr_all_all: +bondscreened_0 +fingerprints:Zr_Ti: +radialscreened_0 +fingerprintconstants:Ti_Ti:radialscreened_0:re: +2.943843 +fingerprintconstants:Ti_Ti:radialscreened_0:rc: +8.000000 +fingerprintconstants:Ti_Ti:radialscreened_0:alpha: +4.720000 4.720000 4.720000 4.720000 4.720000 +fingerprintconstants:Ti_Ti:radialscreened_0:dr: +5.056157 +fingerprintconstants:Ti_Ti:radialscreened_0:o: +-1 +fingerprintconstants:Ti_Ti:radialscreened_0:n: +3 +fingerprintconstants:Ti_all_all:bondscreened_0:re: +2.943843 +fingerprintconstants:Ti_all_all:bondscreened_0:rc: +8.000000 +fingerprintconstants:Ti_all_all:bondscreened_0:alphak: +1.000000 2.000000 4.000000 6.000000 9.000000 +fingerprintconstants:Ti_all_all:bondscreened_0:dr: +5.056157 +fingerprintconstants:Ti_all_all:bondscreened_0:k: +5 +fingerprintconstants:Ti_all_all:bondscreened_0:m: +8 +fingerprintconstants:Ti_Zr:radialscreened_0:re: +2.943843 +fingerprintconstants:Ti_Zr:radialscreened_0:rc: +8.000000 +fingerprintconstants:Ti_Zr:radialscreened_0:alpha: +4.720000 4.720000 4.720000 4.720000 4.720000 +fingerprintconstants:Ti_Zr:radialscreened_0:dr: +5.056157 +fingerprintconstants:Ti_Zr:radialscreened_0:o: +-1 +fingerprintconstants:Ti_Zr:radialscreened_0:n: +3 +fingerprintconstants:Zr_Zr:radialscreened_0:re: +3.234381 +fingerprintconstants:Zr_Zr:radialscreened_0:rc: +8.000000 +fingerprintconstants:Zr_Zr:radialscreened_0:alpha: +4.450000 4.450000 4.450000 4.450000 4.450000 +fingerprintconstants:Zr_Zr:radialscreened_0:dr: +4.765619 +fingerprintconstants:Zr_Zr:radialscreened_0:o: +-1 +fingerprintconstants:Zr_Zr:radialscreened_0:n: +3 +fingerprintconstants:Zr_all_all:bondscreened_0:re: +3.234381 +fingerprintconstants:Zr_all_all:bondscreened_0:rc: +8.000000 +fingerprintconstants:Zr_all_all:bondscreened_0:alphak: +1.000000 2.000000 6.000000 9.000000 +fingerprintconstants:Zr_all_all:bondscreened_0:dr: +4.765619 +fingerprintconstants:Zr_all_all:bondscreened_0:k: +4 +fingerprintconstants:Zr_all_all:bondscreened_0:m: +8 +fingerprintconstants:Zr_Ti:radialscreened_0:re: +3.234381 +fingerprintconstants:Zr_Ti:radialscreened_0:rc: +8.000000 +fingerprintconstants:Zr_Ti:radialscreened_0:alpha: +4.450000 4.450000 4.450000 4.450000 4.450000 +fingerprintconstants:Zr_Ti:radialscreened_0:dr: +4.765619 +fingerprintconstants:Zr_Ti:radialscreened_0:o: +-1 +fingerprintconstants:Zr_Ti:radialscreened_0:n: +3 +screening:Ti_Ti_Ti:Cmax: +0.900000 +screening:Ti_Ti_Ti:Cmin: +0.490000 +screening:Ti_Ti_Zr:Cmax: +0.850000 +screening:Ti_Ti_Zr:Cmin: +0.440000 +screening:Ti_Zr_Ti:Cmax: +1.500000 +screening:Ti_Zr_Ti:Cmin: +0.700000 +screening:Ti_Zr_Zr:Cmax: +0.950000 +screening:Ti_Zr_Zr:Cmin: +0.470000 +screening:Zr_Ti_Ti:Cmax: +2.700000 +screening:Zr_Ti_Ti:Cmin: +0.470000 +screening:Zr_Ti_Zr:Cmax: +1.900000 +screening:Zr_Ti_Zr:Cmin: +0.440000 +screening:Zr_Zr_Ti:Cmax: +2.950000 +screening:Zr_Zr_Ti:Cmin: +1.200000 +screening:Zr_Zr_Zr:Cmax: +2.900000 +screening:Zr_Zr_Zr:Cmin: +0.490000 +networklayers:Ti: +3 +networklayers:Zr: +3 +layersize:Ti:0: +50 +layersize:Ti:1: +20 +layersize:Ti:2: +1 +layersize:Zr:0: +42 +layersize:Zr:1: +20 +layersize:Zr:2: +1 +weight:Ti:0: +2.959065631457990e+01 8.820178365370960e+00 3.567479250699050e+01 -9.520944737974550e+01 5.810216841766590e+01 9.002124484009080e-03 1.229243737965220e-01 8.308975217587410e-01 6.823375462445510e-01 -2.120116364747350e+00 -5.042944013969450e+00 8.888536859810211e-01 4.730113767902510e+00 -3.561046029798420e-01 -5.268119595319890e+00 -5.022196630576951e+00 1.408878320391390e+01 1.468387176035110e+01 3.760997999097570e+01 -6.917447867710290e+00 -5.365770859257360e+01 2.298166523864800e+01 3.868330833699280e+02 -1.716548340302800e+02 -1.893938251864540e+03 7.087497678108080e+01 6.758413925648071e+02 -1.879116886681510e+01 1.086082362821260e+03 -2.582591099463280e+03 -6.919949629103320e+03 6.653492220309850e+03 3.910779971401370e+04 -7.590339154383870e+03 -2.022471894606200e+04 5.146509910417540e+03 -1.785463453281940e+04 4.562627218960931e+04 1.101701455067090e+05 -3.084309856150380e+05 -9.971094440845660e+05 6.441995235572750e+05 6.416524220576230e+05 -5.569111763100200e+05 4.328915131668910e+05 5.428524342952564e+01 -4.807139553935529e+01 3.674056463489699e+01 -1.977223569852695e+01 1.398466060959636e+01 +1.115693858967680e+02 -5.209779939312010e+00 -1.092385668269330e+01 -7.571784442383159e+01 -1.662179555544060e+01 6.916594544622801e-02 3.413942491148800e+00 4.480188413646630e-01 -2.802071362110940e+00 4.856749991432370e-01 3.705116153321830e+00 -2.506064444643240e-01 4.559599774503270e-01 -1.221308069065120e+00 -1.641607115739850e+01 3.587904146265880e+00 -2.383416507477550e+01 -9.053907553863560e-01 -2.345767274757610e+00 2.209763752910380e+00 -2.673114428269780e+01 8.868866584244550e+00 -9.266724447503009e+02 1.276638625895970e+02 7.168919250618770e+02 3.363071672846350e+02 1.444136022401220e+03 3.037219474351350e+02 6.597654623185430e+02 -3.584719368857490e+03 1.436854292524340e+04 1.250649758704310e+02 -1.134443963945180e+04 -9.877927968886390e+03 -7.232548546930680e+03 -1.764631584481190e+01 -1.378082415237150e+04 5.896464207004850e+04 -9.422840447102470e+04 2.948993551487030e+04 2.008982788928040e+03 7.562262912574749e+04 -4.983163988565260e+04 -8.575889316913020e+04 2.236873807148270e+05 1.354471135914414e+02 -3.150983530345522e+01 -6.539829926937760e+00 -3.528134551545980e+01 -3.035896296858233e+01 +8.785785932652220e+01 -4.720301334844530e+01 -2.020078576639370e+01 -8.255733692970909e+01 1.178751057600940e+02 9.264406483588231e-02 -8.591966416908700e-01 -2.857387389805440e-01 3.015871584381770e+00 1.521919611154890e-01 -2.855075022109020e+00 -2.903254706936460e-01 -3.875576775518040e-01 -1.502710449510660e+00 1.520339443967300e+01 1.731954001149110e+00 -5.593960128660860e+01 -2.295786748665170e+00 5.184952484874350e+01 1.592105947138620e+01 1.044288938102470e+01 1.080112064482300e+02 -6.503242958941140e+02 5.126387212054780e+01 1.597542448224040e+03 5.525892218471130e+00 -2.044692134406340e+02 -4.378343406176560e+02 -1.365572260486900e+03 5.425057742978480e+02 1.300810235708670e+04 -4.023490852286060e+03 -1.988158982819950e+04 6.967310910979560e+03 -2.024171606454450e+04 -3.946519618937470e+03 3.272873458153340e+04 -6.329517027391020e+04 -6.758621346995250e+05 -8.901399431816940e+04 5.802311652874351e+05 2.469897516161080e+05 -2.953675934297680e+05 2.508985896982250e+05 3.461023887148230e+04 1.352813198749896e+02 -1.630380500385758e+02 -1.059726795027444e+02 -4.718842231531175e+01 2.097108477308344e+02 +-5.983315673949120e+01 -5.919307194682480e+01 -2.313899936627500e+01 -1.379967160974440e+01 -5.689633174295660e+00 2.558411500579730e-02 4.966535582181171e-01 -1.127104896784800e-01 6.616245113484800e-01 1.512024678970050e+00 1.261340306063010e-01 -8.939209739253280e-01 3.836435145531750e-01 -9.152933589729160e-01 -2.819515446321520e+00 2.370269820057920e-02 -3.518535110763860e+00 -5.912237597981070e+00 -4.743613153004790e+00 -9.646383685996600e+00 -1.251890320875510e+01 1.196420918486560e+02 -3.106534430102290e+01 1.234735282275300e+02 3.222034272429480e+02 -8.517391382048750e+01 -1.336644870819130e+02 2.301334896952550e+02 2.795984833086180e+02 -7.564031065509090e+02 4.407754317028220e+03 -7.773963274447460e+01 -1.013680532461270e+04 -2.137688884394740e+03 1.854556641011860e+03 4.584784172458900e+03 3.070062887959150e+03 -1.650713622650290e+04 -1.690054624853500e+05 -9.892176689015090e+04 4.202313825462020e+05 1.823855045104630e+05 -3.431732355464990e+05 -1.288820654713850e+05 1.153329116697660e+05 -9.512788431741470e+01 -1.083147074683482e+02 -1.401980252358567e+01 5.077341232589099e+01 1.611760202769135e+01 +6.043868296995040e+01 4.953730803784700e+01 7.444491996599690e+01 2.069602350040530e+01 2.885023876509890e+01 -1.819594904018430e-02 -3.848784799773810e-01 -1.481217043109310e-01 1.376200375927920e+00 -1.047720682285890e-02 -3.575729995777320e+00 -1.600916160440440e+00 1.794687661779280e-01 7.996111823895621e-01 -1.099747849865890e+01 8.461579059755990e-01 1.912020946657630e+01 -2.330922291393970e+00 -3.201760021603340e+00 5.967674495276551e+00 7.202403588231940e+00 -3.963009841931790e+01 1.232746458298290e+02 7.293629493154040e+01 9.070915000036319e+01 7.821017738799991e+01 1.030456292377630e+02 2.367832546260190e+01 7.465984980998800e+02 -2.222946622172020e+03 2.365811170850490e+03 -4.316665836652120e+03 -5.681650496185500e+03 -4.705610717173330e+03 -2.463533711738170e+03 4.277433987676700e+02 -1.340783803475190e+04 8.114394517862870e+04 -1.371771041031440e+05 7.645477649479060e+04 1.381604663006290e+05 -9.358182445605620e+04 1.497249059051430e+05 3.740090050028630e+04 -2.951225783430170e+04 7.899947268818528e+01 1.744184194432216e+01 7.251446838854935e+01 5.429577897804942e+01 7.807542695718272e+00 +7.336413357703550e+01 5.385735724250819e+01 -1.013025042673250e+02 -3.775215413344070e+01 3.856228680957000e+01 -2.774006629323010e-01 3.529706536044520e+00 1.051024631506050e+00 -9.126702013427540e+00 -3.036141107572870e-01 6.965836125304440e+00 2.370710254085180e-01 -2.453818030419200e+00 3.584431481868390e+00 -3.955211197897520e+01 -2.946319634169590e+01 1.075342223305780e+02 3.106469607072350e+01 -5.639364892412801e+01 -1.608059058708440e-01 5.568683573148920e+00 1.095331213085640e+02 7.356684893782630e+02 -1.953531461722100e+02 -2.290279364852280e+03 -7.626123846589050e+01 -1.093150014594480e+03 -4.785211317880390e+02 1.823212591707460e+03 -7.110275609460000e+03 -8.718444264025210e+02 2.761255219512280e+04 4.288711262044300e+04 7.873341657826530e+03 2.101411900064320e+04 -2.549447846479280e+04 -4.781367612174040e+04 3.798098289652220e+03 -1.231616040097590e+06 -1.636924466717420e+06 -8.535898658236240e+05 -1.069993108285150e+06 7.918258980567560e+04 2.785945734799830e+06 1.341027760457690e+06 3.999352207637106e+01 -2.084141902956322e+01 -5.860760267787311e+00 8.807230220822389e+01 -7.620161545548299e+01 +-5.454503514021350e+01 3.022937868044680e+00 1.036302323371130e+02 1.935381124326150e+01 -4.612595619827530e+01 8.792376998749740e-02 3.958336360908130e-01 -3.611972157525290e-01 -7.637152495511270e-01 3.653562740495300e-01 3.067551830757980e-01 -3.161256031699760e-01 4.744168004022800e-02 1.328386675030670e-02 -2.283213430935990e+00 -7.905546692629679e-02 -8.415206885898829e+00 3.763465287005150e+00 1.822358427888100e+01 -2.102569135625870e+00 -8.119986083501260e+00 -4.299383232184290e+01 -6.319797969630640e+01 1.364977306635730e+01 1.116474530878040e+03 6.481020621915920e+01 -1.135738338453160e+03 -1.755614422178900e+02 6.704888124888900e+01 8.115636002388160e+02 2.229292409804530e+03 4.152068637760440e+02 -2.300186571663850e+04 -8.991813724806230e+03 9.833563087692790e+03 1.007435440408350e+04 1.268059452291430e+04 -6.100360643113080e+04 -7.679226754674291e+04 -4.324234891085850e+04 5.104133002498230e+05 5.100622558505500e+05 5.687417836825640e+05 -4.065563558156510e+05 -1.061487530145130e+06 -5.003180676080586e+01 4.052841198873614e+01 7.087821421181067e+01 -4.393348440683287e+01 7.746042081722949e+00 +-1.716350791787660e+01 7.669125478653530e+01 3.361398252746390e+00 -1.823274223785960e+02 1.680571316955560e+02 5.044485048795341e-02 -1.554309491130320e+00 -1.040567622332270e-01 5.403793929246860e+00 -9.332473544329940e-01 -3.328691452127940e+00 7.276367356846971e-01 -1.466253850993270e+00 -2.049238235100090e+00 1.890511806957930e+01 -1.365603915317670e-01 -7.306887579902040e+01 1.804106245632960e+01 4.985504986813700e+01 -1.387868082177220e+01 1.509060210160700e+01 -4.283272769576120e+01 -5.638949573162710e+02 -1.147260037690820e+01 1.990318793808500e+03 -1.291052217409060e+02 -7.864632802727400e+02 1.714942131555120e+02 -9.047631218077070e+02 1.594135040047940e+03 5.057802021444400e+03 2.765903434357460e+03 -5.421551955012629e+03 -1.460714485552360e+04 -2.242060556352510e+04 9.175879529415230e+03 2.631222640155590e+04 -1.290337306291940e+05 3.174622597120970e+05 -3.531368075740880e+05 -9.863082748151441e+05 1.052808298304350e+06 2.019305533585840e+05 -5.362818651229400e+05 4.057391172423450e+05 6.166117974861679e+01 -1.733823613019336e+01 -3.276018836488415e+01 -1.102900890440716e+02 1.431606844789580e+02 +4.277587614028520e+01 -5.541473137759560e+01 -1.102024827305630e+01 5.257858445795200e+01 -3.425341040033230e+01 -5.103011537222040e-02 1.131369327308280e-01 -2.892417383021370e-01 -3.408892711180270e-01 4.987019733292620e-01 5.930401521399159e+00 3.573649251910180e-01 -6.196824517342410e+00 3.493614018252210e-02 4.466306254045950e+00 -2.141513647484160e+00 -1.643052132619940e+01 7.878931556659919e+00 -5.834432405562180e+01 -6.326641211588000e+00 7.387894467468740e+01 6.867106305603799e+01 -2.651950831795120e+02 -4.817891301084070e+01 1.714170745131860e+03 -1.662565378656220e+02 5.075078770601480e+02 3.532164567001380e+02 -1.688617047555710e+03 -2.348133577164790e+03 -3.835231374568170e+03 5.031215766012700e+03 -2.913252889346310e+04 -1.018714388790040e+04 1.131417862036770e+04 7.321582219471570e+03 2.002936335361840e+04 2.917068634474880e+05 1.116083541827690e+06 1.198457175470130e+05 -5.669370558466420e+05 -3.745999354981260e+05 7.447029070304430e+04 -1.889247408188940e+05 -2.017056816322920e+05 8.475147542077808e+01 -1.769890954110007e+02 5.862177082179904e+00 1.923396463667033e+02 -1.132367725685456e+02 +2.127944540103450e+01 -2.877490844198130e+01 5.903642848966370e+01 3.205853304780400e+00 6.690385675269400e+01 -1.550046529349520e-01 8.612501177660180e-01 2.451744371445420e-02 -2.418332147292460e+00 2.130934772577300e-01 3.602492255934550e-01 -6.336639965844749e-02 7.128735584523610e-01 5.204016397389720e-01 -1.428851379175280e-01 -1.098637221879920e+00 -1.514115944100120e+01 -3.997867152468980e+00 1.926736020692510e+01 3.182059523652050e+00 -1.878696122769460e+01 -2.037225647171810e+01 -2.525319448922870e+02 -6.541187163682530e+01 5.997373834256399e+02 2.676468877629580e+02 -2.162646066318250e+02 -4.122274734310440e+02 -3.584287388298700e+02 -6.287776493875820e+02 3.234653603322630e+03 1.708512593874380e+03 -2.727209058828810e+03 1.033810889939680e+03 -7.805596568289660e+03 -6.217798368030160e+03 5.313748576584260e+03 3.782843343209730e+04 -6.327484327593841e+04 -1.061552540069060e+05 -2.166129924583750e+04 1.334816983273110e+05 2.349340167555280e+05 -1.858449942928970e+03 -1.503039371950090e+05 3.974641964015988e+01 -6.098888036471162e+01 5.695862343246636e+01 3.662466881845616e+01 4.564119577544508e+01 +-1.809019814601920e+01 -6.318546075726380e+01 3.502313213382470e+01 2.537223513907520e+01 2.139592943381480e+01 6.497971721711360e-02 -2.541186757927500e-01 1.331003658270460e-01 -1.149611183868250e+00 7.191503838203580e-01 -7.984961611912481e-02 -3.034047471169860e-01 -3.752559589532610e-01 -1.459226938296720e+00 -8.074197858798611e+00 -1.749726257636480e+00 5.068428107922120e+01 1.870829404153490e+00 1.189599350957090e+01 1.056999138261870e+01 1.815394425479030e+01 -8.770611613711820e+01 4.766163355057220e+02 -5.835197574323640e+01 -6.412462403239050e+02 -5.534327678560210e+01 -5.714475346906891e+02 -1.916294922174240e+02 -2.059172424432570e+02 2.152982801219270e+03 -3.197765552742720e+03 1.214725535748060e+03 2.979752928144600e+03 -1.059319412352340e+03 4.010636576154850e+03 8.730065384619330e+01 1.416071470392590e+03 -2.480004127031560e+04 4.130113532056310e+03 2.696725909732280e+04 1.350230086967440e+05 -2.104408453509880e+04 -1.870080707984100e+05 9.258425664851280e+03 2.270199436544050e+04 3.874358737148040e-01 -9.538899256479260e+01 3.295543854351155e+01 5.880075690806045e+01 1.425146633849586e-01 +-6.287562290750431e+01 -1.256743566101110e+01 1.186515639771760e+02 4.448885777059110e+01 -8.655564354879640e+01 1.595312781983040e-01 1.110252834715520e+00 -6.728476391469840e-01 -4.767156094912900e+00 -5.684009350323000e-01 4.579771722243120e+00 -2.456192762060000e-01 -2.776347381266540e+00 2.020337937589390e+00 1.243352952853730e+01 -4.866495322917700e-01 -6.829757251604780e+00 3.109726419700340e+00 1.639409904201660e+00 5.336533994115300e+00 -3.830578054157360e+00 -1.581757722751310e+01 -1.395663345783050e+02 -9.372283713117540e+01 1.346416062603650e+02 5.310234552809910e+01 1.764352528448100e+02 -5.583382655188281e+02 -1.671614656241800e+02 -1.155396041321240e+03 4.943126679254260e+02 1.027179627044370e+03 1.635112143739060e+02 4.849942865254680e+03 -6.899574251683660e+03 6.643786277678040e+02 4.566027778907500e+03 5.214306944633080e+04 3.540346669080600e+04 7.892295323196100e+04 8.273562649930600e+04 -2.596956367011940e+05 -1.488814354406500e+05 9.783358918515230e+04 4.433509034746130e+04 -4.441209222489129e+01 -4.478147672621296e+01 1.165766141987243e+02 7.791327490368327e+01 -1.078098706882099e+02 +-1.129050987598760e+01 -1.064541855473100e+02 -7.128503516512480e+00 -6.453299364158001e+01 -1.211842272514140e+02 -1.432994958956060e-01 -4.920505992800340e-01 6.006413098366169e-01 3.461329088596560e+00 -2.998490277733280e+00 -7.466558029079150e+00 1.444037214220510e+00 2.664068255392900e+00 6.349796872002090e+00 -4.233220413417680e+00 1.174955929427830e+01 -1.296278332359900e+01 -1.212974652006810e+01 4.615816393256650e+01 1.222731370360360e+01 2.199633528849840e+00 1.197655633479170e+02 4.185118414251960e+02 -5.410074419928320e+02 -8.011246407469890e+02 6.864786471573329e+02 -6.262561405889981e+02 9.465933235349200e+01 9.927815158125890e+01 3.610725123550870e+03 -1.046068383906190e+04 -2.462571483744750e+03 3.209910271331160e+04 1.012499832057500e+04 4.447909159349940e+03 -1.430989259072110e+04 -1.323291979818500e+04 1.316261475411740e+04 2.834634933114450e+05 2.630501465736330e+05 -8.645569870102340e+04 -2.053856359685850e+04 -2.369991590369040e+05 -2.965843834083010e+05 -4.409599532396930e+04 1.347335082570862e+02 -1.666426990810843e+02 -8.727053995175037e+01 -7.345910633318029e+01 -1.069741498356160e+02 +1.320973530791700e+02 1.133744177141020e+02 6.187724893682460e+01 -1.036257536830240e+02 -6.711739425491170e+01 -2.361802771282950e-02 2.852818677612850e+00 -5.763113597522780e-02 -5.754645017157180e+00 1.040226353964420e+00 -7.188164230414800e+00 8.884067862570069e-01 -3.338922522957300e+00 -1.830898005699390e+00 6.420876673786810e+01 -4.093058268227900e+00 -2.624123626170260e+01 -6.070285210535170e+00 -4.136775103420210e+01 -3.106575523655030e+00 -1.170680617250370e+01 -8.932374517039530e+01 -8.795441283927320e+02 -1.694005532298300e+02 7.289997970841830e+01 1.274307640624960e+02 1.039711213416940e+03 5.500505833839030e+02 1.011388720913690e+03 -3.338045408785700e+03 1.459457972380790e+02 -1.093001969648530e+03 8.346012452448140e+03 3.942859030732620e+03 7.209887485535430e+03 2.063913337114790e+04 1.726277649630800e+04 -4.375686580512670e+05 -4.334965941900989e+05 2.520663302832980e+04 -1.975121234131820e+05 -6.972869237695930e+04 -3.958293518819950e+04 3.157469424712080e+05 1.469868050563580e+05 1.510297172571374e+02 8.174083334624558e+01 6.050773979909467e+01 -6.935968739127078e+01 -8.738587281474005e+01 +-7.680083713548920e+01 -2.885579283049770e+01 8.230918168172470e+01 -2.879211280721080e+00 -1.502918483015010e+02 1.724684493190230e-02 2.405636998267920e-01 -5.191089978005340e-01 -3.908004839649150e+00 -1.149104213600200e+00 5.623119733181780e+00 3.202891744101100e+00 -4.198194201255600e+00 3.434108485139931e+00 1.669727873396220e+01 1.843422989710170e+00 -1.778376425248270e+01 -8.848918908776380e+00 -2.820847151335140e+01 -5.555859896695160e+00 5.906172198123640e+01 -8.815749977758810e+01 -7.073641353278190e+02 1.361368756288440e+02 2.161766946802510e+03 4.319482649640560e+02 -1.345860454878010e+03 -1.651617448977750e+02 -7.951328420274290e+02 2.064063700098160e+03 5.963440573047770e+03 8.486607123360481e+02 -2.151883495306340e+04 -1.547872222331930e+04 -5.826866815020149e+02 8.289831536661310e+03 2.767385574431240e+04 -3.130380986270620e+04 1.432236375805380e+05 2.662252894939030e+05 -2.028384328729530e+05 -8.671824378835870e+05 3.489184006508940e+05 7.166138082697390e+05 -4.161462700086611e+05 -9.509749589540242e+01 -6.239116927882034e+01 1.355811944826567e+02 1.045509318465184e+02 -2.542652647320133e+02 +2.092015377584270e+01 -6.818146651595410e+01 -3.962051090650320e+01 6.298697276595180e+00 4.978455687558160e+01 -2.133167764421440e-03 -4.228408643390770e+00 -1.574679657025820e-01 4.652489412972160e+00 1.733331459289110e-01 9.950307502565490e+00 -1.837649610790410e-01 1.670753494312190e+00 -5.452686146305620e-01 -9.939087460650070e+00 -2.288461945407100e+00 5.371501324556300e+00 -1.030098894662700e+01 1.110409318938780e+01 -3.379978051391610e+00 -2.077708918933370e+01 -1.740409212661940e+01 6.179426972594830e+02 1.202112107144330e+01 -1.272542035621630e+03 -1.693409267633910e+02 -1.215662561898050e+03 -3.769491663120790e+02 -2.471368250515080e+02 2.460931072666510e+03 -6.112302974891570e+03 5.576028754777240e+03 1.494463766585660e+04 -5.844549337907069e+02 -4.023838198942170e+03 1.828075889404760e+03 -6.856904185154880e+01 1.472734042646860e+04 -2.422000894715169e+04 -1.750059740610240e+05 1.824411937467380e+05 -1.162243993332650e+05 -1.546180026284920e+05 1.457903320438880e+05 7.260952292331720e+04 3.943660694116207e+01 -1.003457748667055e+02 -4.164853601174104e+01 3.976746887667212e+01 2.857221230025209e+01 +5.549236330002110e+00 8.510464271612239e+00 1.499915930872850e+00 -5.718076776176819e+01 -1.073400737021230e+02 1.913734210571670e-02 -1.897976106885310e+00 9.474353027541720e-02 6.559895938589190e+00 3.847861539699660e-01 -1.197530597842370e+01 -2.502985321272610e-01 1.021236923490620e+01 2.075785921157220e+00 -6.506928209049970e+00 6.234279325535130e+00 1.752790175510280e+01 -9.361615516391020e-02 -3.637988402046640e+01 -1.035563439659020e+01 -2.104567867330320e+01 1.590829936726210e+02 1.463762464824570e+03 4.385982942807070e+02 -1.722479327485010e+03 -6.585308438558330e-01 1.139079783125020e+03 -8.350487082617450e+02 -7.343631692232960e+01 -4.728152000583490e+01 -9.143160143408950e+03 4.266010242928260e+03 -1.001379527078610e+04 -3.570221809676630e+03 2.321762918844290e+04 -1.378614329552220e+03 -1.252462675350270e+04 -9.977546699884468e+04 -2.165451322108980e+05 -1.244428306954970e+05 1.647110199826280e+05 -6.868788643158780e+04 5.939294657377000e+05 3.361439704050320e+05 -5.152691654531129e+05 7.005560538924354e-03 -2.994889224868999e+01 1.379153078197083e+01 -5.778826551302973e+00 -1.509172064436118e+02 +-7.916671728129339e+00 4.492823948998120e+01 -2.321361896168350e+00 -1.307990846578830e+02 8.765869130093630e+01 -9.432882458046210e-02 1.611005810242830e+00 -1.492405431125900e-02 -4.882611306436191e+00 1.355693318261030e+00 7.347697810758220e+00 -1.005947608673520e+00 -4.361056799092970e+00 9.247886198515159e-02 -2.009908475018450e+01 -8.766169433333260e+00 6.434501739699240e+01 5.061307399216700e+00 -8.580659555328150e+01 8.467487932199029e+00 4.795338088214070e+01 1.223215802782500e+02 2.099492630433860e+02 -1.899923297323580e+02 -8.744126753927590e+02 1.763805850118000e+02 1.138206840449200e+03 -5.264380804364580e+02 -9.034346921159790e+02 -4.059105563840720e+03 6.875493804896340e+03 1.735011124704730e+04 -4.579734146321170e+03 -9.297778126741820e+03 -2.341425160868980e+03 -1.554197660004220e+03 8.525873364765690e+03 1.618272281833870e+04 -1.029347626249580e+06 -1.377874758793990e+06 1.133230497940440e+06 1.535001290882850e+06 4.483416847289580e+05 -1.249958276970500e+05 -9.474144957910458e+05 -9.177308441563005e+01 1.716609154039195e+02 1.202551244452341e+00 -2.251239259883857e+02 1.329545258333232e+02 +-7.802632807816740e+01 -6.845340364662910e+01 1.356713670586950e+01 6.429559291889871e+01 5.969112686840559e+01 -1.476459646859460e-01 -9.014179718702729e-01 2.539243605349720e-01 6.578331994696370e-01 6.567788654511670e-01 2.672971790084560e+00 -4.045417196641020e-01 -2.480889831451430e+00 -2.173085187939530e+00 -6.149384313374290e-01 1.237555532875510e+00 3.398910583700700e+00 3.748468846399340e+00 -1.356194023597960e+01 3.576828207684910e-01 1.028514022166650e+01 -2.452974645090860e+01 1.472219899103320e+02 3.531820910869280e+01 -1.830872227158560e+02 -7.121290468102021e+01 -3.227075248363260e+02 -1.353082919292390e+02 2.733126427158990e+02 2.841383806359940e+03 -3.265593290646150e+03 -4.267522007397480e+02 1.466201562416410e+03 -2.517201653687010e+03 1.254021916995560e+04 1.578186339790410e+03 -1.196054098260550e+04 -5.449534436381410e+03 6.576862020272011e+04 -8.695350896731610e+04 -8.814270606378430e+04 4.587074072723950e+05 7.623642768318400e+04 -3.517609551203240e+05 -4.378004867922440e+04 -5.681797561372628e+01 -9.779539200282534e+01 1.443245457550560e+01 1.006885844130784e+02 4.141105727390936e+01 +-8.073601889023701e+01 -1.294665120866080e+02 5.945805590714150e+01 -2.898290131951680e+01 -1.137372595027620e+01 1.219346386197720e-01 -3.839491851396980e-02 -3.595476170701780e-01 8.224162070888551e-01 3.344070630946880e-01 -1.361143505206730e-01 6.625530309825680e-01 2.537011728158460e-01 -4.266564294031260e-01 -1.194978121256970e+01 1.737482385185800e+00 2.043919378151330e+01 -4.788563396789360e+00 -3.474946133830100e+01 -4.220943925467510e+00 2.517221961878410e+01 1.060184179513230e+01 1.781504656839610e+02 1.365399582956040e+01 -3.400000871925320e+02 4.642900563873431e+01 3.718217200852840e+02 1.563519292553870e+02 -4.059289015912770e+02 1.917350342938080e+03 -2.168254395331960e+03 -5.048353631651640e+02 7.841144679334910e+02 -1.920899103395900e+02 7.535043890794460e+03 -9.790152729192910e+02 -3.407548179745761e+03 -2.289116277601350e+04 2.424830526185240e+04 -1.711510685927520e+04 -3.676143854672500e+04 7.968742284328659e+04 -3.199123493424850e+04 -3.494703283466890e+04 3.043202096109460e+04 -6.209159849717116e+01 -1.614908073286566e+02 5.757761883838479e+01 4.637524166135631e+00 -3.243304600499138e+01 +weight:Ti:1: +-1.900909743994830e+01 -7.578770479490130e+00 -3.218496428548700e+00 -4.236167744297790e+00 -1.186749689073690e+01 5.376081602840550e+00 -6.790956567542070e+00 -1.773830000868000e+01 -5.501967698076490e+00 -1.126457217402020e+01 -9.679843884554650e+00 -4.136760185943520e+00 -5.854885706629030e+00 -6.673888840718900e+00 -2.988839238536750e+00 -9.253564488744130e+00 -2.641721529732370e+00 -8.536185712280711e+00 -5.034707016809750e+00 -7.113274560516300e+00 +weight:Zr:0: +2.533572249648930e+01 -3.104581412524160e+01 8.841104450754280e+01 -7.985007792792420e+01 1.105808295039840e+02 -2.253538179994260e-01 -1.217589435913240e+00 -3.123739899897850e-01 9.157750022278430e+00 -6.194932975999620e-01 1.805558285462210e+00 9.357252380200199e-01 -8.814314612982440e-01 -5.372602165349510e-01 -1.992290532411720e+00 -3.180677179120500e+00 -7.224133471766901e+01 1.155030255834780e+00 2.075891577317090e+01 -5.232664886315670e+00 1.524105164832800e+00 -1.458171074797400e+03 6.080706785724720e+03 2.667380590374640e+03 -2.816532409598860e+03 -2.266503801594660e+03 -3.497749759328590e+03 -1.121776586769620e+04 -7.879967440006579e+03 1.386491948216740e+05 -3.193806071289290e+05 3.308221046077160e+04 6.743087983549030e+05 1.806390176571200e+05 -3.207206812968620e+05 -1.175492428241280e+05 -2.019157932932850e+04 1.339548490080990e+01 -1.551532847085550e+01 9.935243320837451e+01 -9.381032226564771e+01 1.259985684965357e+02 +8.641356211895409e+01 2.926871756471990e+01 1.137002479624610e+02 -6.088770796726430e+01 6.856146552249691e+00 5.032351871125780e-01 8.187734713481200e+00 -3.476244749478940e-02 -7.683172824505160e+00 -8.962907555979780e-01 5.163687504426310e-01 -5.533027836530370e+00 5.380657254803910e+00 1.863276616282680e+00 -8.995095022460541e+01 -7.288066972238700e+00 8.405780166521951e+01 5.110412820173250e+00 -4.475402613800050e+01 3.056775458291590e-01 -1.966026700692910e+01 -6.044195576037370e+03 1.094040144482330e+03 3.434070247275919e+03 -4.324493055396300e+02 2.396835704792020e+03 -4.786326256678370e+03 -5.413992175022420e+03 -2.702704511838280e+03 1.394418979423900e+05 3.944325141044279e+04 -7.188166063628149e+04 1.418586533975730e+05 2.230081550297510e+05 -7.428337596593521e+04 -2.675348378012910e+05 -4.628800797585280e+04 1.130323785646560e+02 3.502541884152883e+01 8.823797097404974e+01 -1.180913281083844e+02 -1.029789795456498e+01 +8.182902023347150e+01 -8.502416465112761e+01 -2.763321450364950e+01 -1.313909805815120e+02 5.463117835242790e+01 -3.782161893922071e-01 3.335583887237500e+00 2.888202736469640e+00 -7.193511304589880e+00 -1.240613513989550e+00 -2.525794255058170e+00 -6.080916633394290e+00 3.079661108116500e+00 5.082544529122120e+00 -2.845369664618080e+01 -5.691066249022370e+00 5.831268688342400e+01 1.650423069905090e+00 4.340558836334050e+01 4.057624699330630e+01 -4.956388161707650e+01 2.471787602550810e+03 1.440741355003530e+04 2.241189533780660e+03 -2.903320384580420e+04 -7.600180707459649e+03 2.684462629754650e+04 -1.419309127842040e+03 -5.611970822069090e+03 -1.583688341174910e+05 -4.652870961930530e+05 -4.888759958784170e+05 3.488465566479620e+05 5.842197530580350e+05 -1.513214383617390e+05 9.028378709143749e+04 1.572594959847890e+05 1.317973513728643e+02 -3.183767987119257e+01 -1.043035336997356e+01 -1.788886889820495e+02 -1.339410350013497e+01 +-5.652441775088680e+02 -3.129914392467210e+01 5.776487271895490e+02 6.648560055409160e+01 -1.439142742809110e+03 7.303517222923140e-01 -1.986755880395500e+01 6.181443845570690e+00 3.085984797843680e+01 -8.283096136717610e+00 -3.660476730408280e+01 -2.524588834830200e+01 1.318575482677720e+01 4.176612923056790e+01 9.283533384778779e+01 -7.182594840793200e+01 -2.254176428654160e+02 -1.025976171903940e+02 1.611287027554690e+02 3.895800750604409e+02 6.426095247283079e+01 4.498850293159150e+03 -1.462349405161030e+04 -2.518915996673100e+04 -7.265862062220550e+04 4.172752544042370e+04 2.987993108002130e+05 -5.736070620427340e+04 -1.589440191723990e+05 -1.399372096816560e+06 -4.839223894563860e+04 2.825626450509210e+06 -1.687356257140730e+06 8.277560578207459e+06 -2.062383216276100e+06 -9.599817498706000e+06 3.392792196540230e+06 -3.264002378786422e+01 -6.629362463611876e+02 -1.919215048310130e+01 1.738528692222605e+02 -8.100975145711094e+02 +-5.431631319817260e+01 -3.628324047087360e+01 1.022210382717950e+02 -1.074838507269040e+02 -2.831943351413090e+00 -1.988238481861890e-01 -8.861289582437939e-01 -2.659934829782150e-01 -2.500791955145240e+00 -4.659806866606560e-01 3.926169295504710e+00 2.669166718326410e-01 -1.514094441740170e+00 1.034511626848980e+00 6.820065074437121e+00 7.932716071919410e+00 2.180195590260740e+01 1.978786508820320e+01 -2.732010728150630e+01 -9.474679834058371e+00 1.360591611527890e+01 -1.035706138546610e+03 7.017440123881720e+02 -6.953359657419940e+02 -5.295377159648910e+02 1.137939133817210e+03 -3.485970789141290e+02 -3.210992515023680e+03 -5.762571673570000e+01 2.747991946789470e+04 -5.128063482846500e+04 3.520300450792160e+04 4.437774556615860e+04 -1.709565787239910e+05 -1.757127494146750e+05 1.822865848646780e+05 1.322706507800000e+05 -6.823778558801978e+01 -2.250810945077585e+01 1.119819809206000e+02 -1.217369676067614e+02 1.346314014865552e+01 +-3.669941545939720e+01 -8.405586768963340e+01 8.692672852590420e+01 3.985890209828150e+01 8.319750257128629e+01 -7.887057799613520e-01 -5.520154317958050e+00 3.762045115966520e-01 2.773079096577780e+00 3.369996096451810e+00 9.292037353957291e+00 -5.032923222293260e-01 -6.373844844165419e+00 2.334757531809900e+00 5.619931100129070e+01 -4.453094727354520e+00 -2.306287892302360e+01 -2.595764677221580e+01 -9.529921264066989e+01 3.852844185321880e-01 5.783284185778750e+01 3.986431492895560e+03 -1.532710219721710e+04 -2.227510481912310e+04 2.046059979317870e+03 1.353745934057660e+04 -1.092753370052650e+03 5.584268784963220e+04 3.919881477473020e+04 -6.221728732152170e+05 -2.133437162841550e+05 -3.634587471619811e+05 1.106570454775120e+05 1.617775128979920e+05 -7.156897525130800e+05 2.336653838425920e+05 5.313218262254350e+05 -1.570427171455060e+02 -3.300252397580416e+01 2.032969299259227e+02 9.261314953642727e+01 -1.656667663289629e+01 +4.071084977766680e+01 -3.225883971466690e+02 -2.375031277591230e+02 -1.144178314279990e+02 3.949278167358970e+02 -2.327326862841910e+00 -1.997338673727920e+01 1.175739111677390e+01 4.996803588453490e+01 -2.194751719287660e+01 -5.309675785043421e+01 2.778685283616090e+00 1.911111627596840e+01 1.744384392108320e+01 1.322852126122420e+02 -1.391581651419830e+01 -1.950757677292500e+02 -1.134007478261480e+02 -9.985415441581139e+01 2.464424565825630e+02 2.542236329797270e+02 -1.110434420152410e+03 -3.040151344108270e+04 6.801164885510380e+03 -2.810289094479380e+03 8.192168112080690e+04 1.627059952332300e+05 -5.848126177715840e+04 -1.170526778773960e+05 -2.924793255307260e+05 5.657072556399970e+05 -1.160747035645160e+06 -1.037995892636170e+06 1.324813413756760e+06 5.914431119804890e+05 -5.122684826753260e+05 -2.212069483141570e+04 1.310701958000760e+02 -2.236101109794340e+02 -1.896886828639565e+02 -1.791410593088798e+02 2.135917914953256e+02 +-8.305346344791120e+01 -3.235620238557810e+01 1.540280898552070e+02 -8.505069184329680e+01 -8.864670528524121e+00 4.186669782715560e-01 2.167213368682270e+00 -3.963222117224930e-01 -4.180821628950010e+00 9.786501790988951e-01 2.759223243589140e+00 -2.376728776775800e+00 -2.207928709370440e+00 1.370561494773690e+00 -6.812936025730320e+00 -9.797735484929360e+00 4.795569195576270e+00 8.433143089998490e-01 1.755956390953760e+01 6.235057554831759e+00 -4.915300325225690e+00 4.386018681689310e+02 8.742558615017920e+02 -7.459525176599220e+02 -3.482673795419380e+03 9.701066633749530e+03 8.927499699024700e+03 -1.007378842613340e+04 -1.248205754978190e+04 2.137476925711530e+04 -3.846197532195120e+04 2.350862940428050e+04 1.889340182611190e+05 -1.613308006095720e+05 1.565764464358310e+04 1.305963361619490e+05 -5.881336805585201e+04 -7.360400305758367e+01 -2.839923413629685e+01 1.390331604361033e+02 -1.166881156667366e+02 2.122752542365443e+01 +8.510909239982939e+01 -1.050260911362220e+02 6.030975416867520e+00 -8.419401053125510e+01 7.324867679391581e+01 5.088133446817030e-01 -2.144620786387980e-01 1.505617320863300e-01 3.870175605355199e+00 -4.128049110812650e+00 -8.503334831034071e+00 -4.076570262352580e-01 8.337258283742670e-01 -1.656775376069380e+00 -4.081917850165220e+00 2.066031539450400e+01 -1.682683308594650e+01 1.213477846358850e+01 4.235722023829860e+01 8.311850485217191e+00 1.225552817962400e+01 -1.670858301911210e+03 1.548132226476110e+04 -2.792768805516890e+03 -2.310328624289540e+04 -1.229076194298200e+04 8.893642787684799e+03 3.620671322443900e+03 -6.958421306423869e+03 1.414849008530630e+05 -5.864480519843830e+05 4.968700870485260e+04 7.832729249462371e+05 3.148801691625880e+04 -2.353638238153300e+05 1.608464356260650e+05 -3.508851526595750e+04 6.689888434954611e+01 -9.563488361383232e+01 1.116335860897162e+01 -1.034659998054885e+02 8.399127754279677e+01 +-1.114570099991160e+01 -6.926243212951100e+01 9.386496431939491e+01 -2.295510931757380e+00 -6.046763404444400e+00 2.898642905444560e-01 -1.625310241796620e+00 -1.218170412307850e+00 7.489729742415911e+00 8.361561362691129e-01 -1.115938591585690e+01 6.679754821153540e-02 5.785064857006460e+00 -4.044742253368670e+00 1.073715686572580e+01 1.033453524594790e+01 -5.877278601248240e+01 -3.356635731688480e+00 8.570736512869060e+01 -1.239987551502300e+00 -4.267012445092090e+01 1.384890831540650e+03 -5.063147634513090e+03 -1.569683963456500e+03 2.129101312565610e+04 5.159650055402110e+01 -1.413253003623380e+04 -8.469153207531510e+02 -3.104436472061270e+02 -1.274776881436820e+05 2.958284670480920e+05 8.592025056220101e+04 -8.455860485870300e+05 -3.204900083786110e+05 -1.026291950041460e+06 3.318209425356080e+05 1.522454093638370e+06 -3.778296971893572e+01 -3.995218818506164e+01 1.081103567856049e+02 -8.891857970473525e+00 -1.566634417513517e+01 +-1.352697655693660e+02 -7.553260847079370e+01 1.786105945396520e+02 1.636313459349920e+00 -9.732920165993470e+01 -3.806781170792960e-01 -6.335260275640000e-01 1.096623130060620e+00 -8.604275384802211e+00 1.507234884406940e+00 1.212456310573770e+01 -3.268968127116560e+00 -5.992761003730370e+00 2.723683218198630e+00 6.223975209537880e+00 6.504645083849810e+00 7.333398035742310e+01 -2.631914631181600e+01 -1.147578612525850e+02 3.036217850565730e+01 5.857762112134800e+01 1.500014061192680e+03 -2.823171430138920e+03 4.200336833759470e+03 -8.499746884217300e+03 -7.399598459308570e+03 9.185462737591170e+03 1.140137183175320e+04 5.753186452408380e+03 2.023196157306570e+04 2.985571779456290e+05 -6.056963200121589e+05 -2.751624275131960e+04 7.414814251577060e+05 3.856959782321730e+05 -5.443630306958930e+05 -4.367232882232639e+05 -1.050676134248258e+02 -8.984025763253389e+01 9.379297081568865e+01 -7.472614286653091e+01 6.220076959430686e+01 +-3.615132092490310e+01 -3.858340262737140e+01 1.634387171920810e+02 -5.680771453886280e+01 2.380907581661240e+01 -7.055083207411091e-02 2.116798575043050e+00 -5.757518389320500e-02 2.062120025660740e+00 -4.427217969752861e-01 -4.587169063560870e+00 8.569009610394041e-01 5.586321813120700e+00 -5.247797129652870e-01 -1.963974356071750e+01 -8.708569850782829e-01 6.928543384793290e+00 -5.185002494593450e-01 -1.373621411619710e+01 -5.705775320716000e+00 -8.306890053043070e+00 -2.245413685718130e+02 2.755077502611750e+03 2.575808566495810e+03 -3.094664279216610e+03 -5.039940922691360e+03 4.097637156460780e+03 6.865879737984740e+02 -3.332723417658070e+03 1.047610726556520e+04 -5.811147047617920e+04 -1.266588731691560e+05 -1.061037605449640e+05 -2.815624151483800e+04 -6.291924571268640e+04 1.600516630465110e+05 1.994397826501680e+05 -5.240050768041203e+01 -2.732329896989961e+01 1.704830869255617e+02 -7.399627421789091e+01 3.693020881236266e+01 +7.226963234590970e+01 -1.131292657040380e+02 3.268696250613230e+00 5.627277170054580e+01 -3.427120227200370e+01 2.734003672029740e-03 -2.906310742205300e-01 -2.225861856268850e-01 6.586741206415870e-01 5.848937088477630e-01 -6.548934844319469e-01 -6.519043364624360e-01 9.562630677798431e-02 2.193083987055510e-01 2.315122669410550e+00 3.125822581201339e+00 -5.885061699930230e+00 -6.350385021559251e+00 4.197115414215730e+00 6.290329062273900e+00 6.565397925628610e-01 8.739910288604840e+02 -1.895228713772440e+03 -1.677744955179130e+03 7.062956153365851e+03 3.664908560289650e+03 -4.256519163487670e+03 -2.283625686598360e+03 -3.144907367753580e+02 -3.667040237896290e+04 1.673278305812640e+05 1.429250380308550e+05 -6.902302039536190e+05 -2.801116064591860e+05 5.949695690657950e+05 1.443847666529710e+05 -5.736033864491480e+04 4.653755433477311e+01 -6.274448840552078e+01 1.107281049566416e+01 -1.853146365973967e+01 8.876760616316000e+00 +-4.080642934953081e+01 -6.516640400179880e+01 2.484641241756290e+01 -7.823170980354840e+01 3.925038674887500e+01 -1.199200598880390e-01 -1.189389535467320e+00 -3.630313211277510e-01 6.026203559571330e+00 6.953669584012189e-03 -1.211331625001940e+01 -8.283560399191811e-01 5.862229443015400e+00 1.238628474245990e+00 9.194561117202550e+00 6.274293734474210e+00 -4.597991044277630e+01 -1.057632295744130e+01 8.567261031292701e+01 1.567821971324760e+01 -3.697704388358490e+01 2.702141318098890e+03 -4.013475832320740e+03 -1.823300815517460e+02 1.217734350465610e+04 2.903060891279720e+03 -1.450507323096950e+04 -1.677469333268600e+03 6.117578165518090e+03 4.462250140329540e+04 2.790494985020640e+05 -3.475435798661080e+05 -2.533266658411400e+05 4.209619921241840e+05 -2.367655556436450e+05 -1.996473301191440e+05 3.429295831952530e+05 -2.698119327323881e+01 -1.226503290831413e+02 4.004529089926289e+01 -9.204578406853539e+00 2.413184289179218e+00 +1.873285799630320e+01 -1.167334386914860e+02 2.206341383109620e+02 1.993026904498310e+02 -2.600559688160810e+02 2.507809313862140e-01 1.371977059217770e+00 -2.589674095079710e+00 -5.137241402607950e+00 7.102121862890379e+00 1.432424381160370e+01 2.358434606006580e-01 -7.431225192281209e+00 2.536280585420020e+00 -1.099315868597960e+01 -2.221065250728070e+00 3.639816831869160e+01 -1.087726459647240e+01 -9.234935903671770e+01 -3.548875423462670e+01 3.340327938565450e+01 -1.030326299001860e+03 -2.034101980394670e+03 4.992000555709520e+03 -2.296303896406780e+04 -1.162606232588940e+04 6.234539324912170e+04 1.529673701716010e+04 -3.617092876033260e+04 9.557403397150971e+04 3.038216250263159e+05 -2.176382559912470e+05 2.564076797401850e+05 -1.222746193955690e+05 6.685876473124009e+04 7.879165108633500e+04 -4.744603439128560e+05 3.291428128845545e+01 -8.585287104530059e+01 2.339440544796711e+02 1.725094379192837e+02 -2.748862509561272e+02 +9.845444206406150e+00 -2.415750770672310e+01 5.034391247360530e+01 -4.425497839507670e+01 2.735250906830970e+01 -8.370945088175161e-02 -2.471574962532890e+00 6.966916358946820e-01 6.756892242329070e-01 2.608941732570010e+00 4.265807029744230e+00 4.808373016046690e+00 -4.109588936109370e+00 -3.073745527963980e+00 3.039293463313370e+01 -9.337351059041030e+00 -1.023622691494740e+01 -4.466709596864100e-01 3.153921890443010e+01 -8.168954600867051e-01 -1.836802651802990e+01 -7.937674266264991e+02 -1.163123022283180e+04 -4.325923038500940e+03 -5.224164902633120e+03 -2.961725474125090e+03 -8.304411116361360e+03 -1.124142827178260e+03 1.642841535246150e+04 1.132620837658520e+05 3.368271807678040e+05 3.071118192248400e+05 4.628944159999200e+05 5.246782046822310e+04 -4.960772198359710e+05 -3.095590715698010e+05 -2.433691743004140e+05 -4.577295045811584e+00 -1.021606321873773e+01 6.093166505971111e+01 -5.700796564855787e+01 4.584992629845553e+01 +-6.675084179059741e+01 -5.319611005507720e+00 7.491875537438330e+01 -5.237096066083861e+01 3.717211864140010e+01 -1.409763988324450e-01 -1.521419828704840e+00 2.130185158959690e-01 -4.156290734829960e+00 -2.727335324009150e+00 6.699849182115780e+00 2.051772232537070e+00 -3.868040913321810e+00 3.463354324343020e-01 2.740797373496460e+00 2.860277490234231e+00 3.262103918360760e+01 5.009000163850530e+00 -3.901916736240690e+01 -7.145170617094230e+00 1.542786044384030e+01 7.154011856241409e+01 1.299020043306170e+03 -2.029247496088070e+02 -9.094679091607150e+03 -1.309859707266300e+03 7.295831527249220e+03 -1.406740322771730e+03 -3.634412782314169e+03 2.799416361678240e+04 -6.686518973624610e+04 -5.325166001392089e+04 2.057682253131430e+05 1.596981733699540e+04 -2.558655388800600e+05 5.472623514840820e+04 1.509683891199390e+05 -7.955180069688193e+01 9.319937153787935e+00 8.528410039045046e+01 -6.628391842334683e+01 5.353816593201972e+01 +1.552251191146970e+02 2.926168344795230e+01 -1.975963221781200e+01 -1.767123937750160e+02 -4.064599841989800e+01 -4.061069620099700e-02 3.102679823058760e+00 1.562394981650100e-01 -8.991948619788200e+00 3.036354312209300e+00 -4.560676602938530e+00 -2.121975314751200e-01 4.260683318184590e-01 -2.284711567035990e+00 2.630899015700080e+01 -1.377247327115220e+01 4.121986751814490e+01 1.555293878059420e+01 -1.526606696261670e+01 -2.150435607700940e+00 2.034345473156460e+01 -1.314812987963530e+03 -6.655539714447120e+03 5.876087935861181e+03 5.460882669941640e+03 6.319618759495910e+03 8.953514047677760e+03 9.670636612518680e+03 1.501097343014040e+04 -3.197182430829710e+05 -4.059529176635650e+04 2.069408059291140e+05 5.714902553126360e+05 -2.165961111026020e+05 -3.394478504822790e+05 -2.206524231481800e+05 -3.721550556458730e+05 1.484236100637929e+02 4.837861034425413e+01 -1.034516753470562e+01 -2.021774280076698e+02 -5.296186530802704e+01 +-1.296586666798590e+01 -9.126528123641710e+01 1.114857831083380e+01 -6.728714614183200e+01 8.612466627553160e+01 1.889118996778360e-01 2.258019271133150e+00 3.929291837353300e-01 -2.467956398573290e+00 -8.006567452709210e-01 3.878406343686240e+00 3.512346206158590e+00 -4.753836015830060e-01 -2.161700050088120e+00 8.009353797204399e+00 -1.225645636759810e+01 -5.899202175307560e+00 -2.130163905959490e+00 1.453550632648960e+01 4.167032623664090e+00 -1.450518723354680e+01 2.572283568219910e+03 -4.272923240955890e+02 2.832332706192290e+03 9.810424981300040e+02 1.836452288374570e+03 -1.869428532828810e+02 -3.878513276928310e+03 1.427922634890410e+03 -9.326818311252800e+04 3.157656622121350e+03 -2.687783976236190e+04 8.793991398604171e+04 8.123241501170451e+04 -6.418348147866150e+04 -2.985051950682400e+04 -2.920583833894430e+04 -3.228022285917200e+01 -7.906163904779172e+01 2.073573536270432e+01 -8.040165986006356e+01 1.061998645840528e+02 +9.959709062534900e+01 1.087502667955940e+01 6.436094130202110e+01 -3.606892523904480e+01 5.290601532225030e+01 -4.193056943169590e-02 -3.898885751261870e+00 3.949896656482370e-01 3.662370941675750e+00 -1.778355788278790e+00 2.930598927783389e+00 5.714011717804970e-01 -2.466140683777800e+00 -4.174264058702390e-01 -3.039258956469940e+00 -8.248792926836001e-01 -1.852127217208240e+01 3.803546859375490e+00 -1.847726641274240e+01 -2.560674697863870e+01 9.995432341534119e+00 -2.340208868175690e+03 5.297835251929640e+03 4.320759148084090e+03 1.167588258688800e+04 -5.817161570754710e+03 -1.725326860015780e+04 -7.965064390236350e+03 -7.323066834087200e+03 9.620006625259769e+04 -9.591248324384430e+04 7.421213722488130e+04 1.119510461026150e+05 2.931552681902420e+04 -2.000404269113050e+05 -5.578042521727410e+04 1.908442441085770e+05 8.322641687128646e+01 2.198679825560096e+01 7.123296439417778e+01 -5.345105172984309e+01 6.581547611099977e+01 +weight:Zr:1: +-8.449402603952080e+00 -6.338794008660490e+00 -3.646475639589930e+00 -4.568817240756670e-02 -7.486395335332810e+00 -3.785050765188870e+00 -3.485773491732340e-01 -5.538686152537460e+00 -7.433810976865260e+00 -5.821849208003560e+00 -3.395190456952280e+00 -8.333672632254331e+00 -3.029331386730920e+01 -8.956537722110630e+00 -3.920136298332350e+00 -6.736243977919150e+00 -9.649168312913330e+00 -8.048165313887120e+00 -6.960447300715590e+00 -9.643037059291860e+00 +bias:Ti:0: +-1.956139686368849e+00 +2.316102584868799e+00 +-5.873577280820660e+00 +2.540633238613090e+01 +2.169586324610206e+00 +-6.132550222727400e-01 +6.490063401842909e-01 +-2.951927218533048e+00 +-8.218012457375847e-01 +1.774990864410230e+01 +1.988342296137330e+01 +1.990921933487670e+01 +1.131818275713660e+01 +1.317146636683290e+01 +1.234521162759310e+01 +4.176334634524130e+01 +7.732436210630709e+00 +2.952926382581680e+00 +1.848343983326470e+01 +3.602895726219770e+01 +bias:Ti:1: +-2.511965921735320e+01 +bias:Zr:0: +1.370501580095990e+01 +2.772761128809670e+00 +5.124080364684149e+00 +9.604164800454713e+01 +2.052952479827250e+01 +-3.172235149688250e+00 +-5.149625266581623e+00 +1.816107898644540e+01 +1.763964253937473e-01 +4.436246684052568e+00 +1.092585291778570e+01 +1.491088913020820e+01 +-2.483576459966645e-01 +1.297333763833140e+01 +-3.864339565119073e+00 +4.631895807524710e+00 +2.375195292636960e+01 +1.209498628860100e+01 +2.227387923911460e+01 +8.401986227903949e+00 +bias:Zr:1: +-1.947972075332220e+01 +activationfunctions:Ti:0: +sigI +activationfunctions:Ti:1: +linear +activationfunctions:Zr:0: +sigI +activationfunctions:Zr:1: +linear +calibrationparameters:algorithm: +LM_ch +calibrationparameters:dumpdirectory: +. +calibrationparameters:doforces: +0 +calibrationparameters:normalizeinput: +1 +calibrationparameters:tolerance: +1.0000000000e-07 +calibrationparameters:regularizer: +1.0000000000e-04 +calibrationparameters:logfile: +TiZr.log +calibrationparameters:potentialoutputfile: +TiZr_output_2.nn +calibrationparameters:potentialoutputfreq: +10 +calibrationparameters:maxepochs: +10000000 +calibrationparameters:dimsreserved:Ti:0: +45 +calibrationparameters:dimsreserved:Ti:1: +20 +calibrationparameters:dimsreserved:Ti:2: +0 +calibrationparameters:dimsreserved:Zr:0: +37 +calibrationparameters:dimsreserved:Zr:1: +20 +calibrationparameters:dimsreserved:Zr:2: +0 +calibrationparameters:validation: +0.100000 diff --git a/examples/USER/rann/in.lammps b/examples/USER/rann/in.lammps new file mode 100644 index 0000000000..3f831fca21 --- /dev/null +++ b/examples/USER/rann/in.lammps @@ -0,0 +1,45 @@ +units metal +dimension 3 +boundary p p p +atom_style atomic + + +lattice hcp 2.9962594 +region whole block 0 10 0 10 0 10 units lattice +create_box 2 whole +create_atoms 2 box +timestep 0.001 +set group all type 1 +set group all type/fraction 2 0.10 486 + +pair_style rann +pair_coeff * * TiZr_2.nn Ti Zr + + + +compute peratom all pe/atom +shell mkdir ovito_files2 +dump 1 all custom 10 ovito_files2/dump.*.gz id type x y z c_peratom +dump_modify 1 element Ti Zr + +thermo 1 +thermo_style custom step lx ly lz press pxx pyy pzz pxy pxz pyz pe temp + +variable etol equal 1.0e-32 +variable ftol equal 1.0e-32 +variable maxiter equal 1.0e+9 +variable maxeval equal 1.0e+9 +variable dmax equal 1.0e-2 + +fix 1 all box/relax aniso 0.0 +min_style cg +minimize ${etol} ${ftol} ${maxiter} ${maxeval} +unfix 1 +write_restart TiZr.min + +#-------------------------EQUILIBRATION-------------------------------- + +velocity all create 300 12345 mom yes rot no +fix 1 all npt temp 300 300 0.1 aniso 0 0 1 +run 100 +unfix 1 diff --git a/src/USER-RANN/pair_rann.cpp b/src/USER-RANN/pair_rann.cpp index 0dcf3740a6..6a100db244 100644 --- a/src/USER-RANN/pair_rann.cpp +++ b/src/USER-RANN/pair_rann.cpp @@ -619,14 +619,11 @@ void PairRANN::read_screening(std::vector line,std::vectorone(filename,linenum-1,"unrecognized screening keyword"); } From 92abca3910137e02845d563185edece6661d9cd1 Mon Sep 17 00:00:00 2001 From: kipbarrett Date: Mon, 19 Apr 2021 13:40:19 -0500 Subject: [PATCH 11/25] bug fixes --- src/USER-RANN/pair_rann.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/USER-RANN/pair_rann.cpp b/src/USER-RANN/pair_rann.cpp index 6a100db244..d2b9535b56 100644 --- a/src/USER-RANN/pair_rann.cpp +++ b/src/USER-RANN/pair_rann.cpp @@ -164,12 +164,12 @@ PairRANN::~PairRANN() memory->destroy(sx); memory->destroy(sy); memory->destroy(sz); - memory->destroy(dlayerx); - memory->destroy(dlayery); - memory->destroy(dlayerz); - memory->destroy(dlayersumx); - memory->destroy(dlayersumy); - memory->destroy(dlayersumz); + memory->destroy(dsx); + memory->destroy(dsy); + memory->destroy(dsz); + memory->destroy(dssumx); + memory->destroy(dssumy); + memory->destroy(dssumz); } } @@ -538,7 +538,7 @@ void PairRANN::read_weight(std::vector line,std::vectorone(filename,*linenum,"unexpected end of potential file!"); @@ -569,7 +569,7 @@ void PairRANN::read_bias(std::vector line,std::vector net[l].Biases[i][0] = utils::numeric(filename,*linenum,line1[0].c_str(),1,lmp); for (j=1;jcreate(sx,fmax*nmax2,"pair:sx"); memory->create(sy,fmax*nmax2,"pair:sy"); memory->create(sz,fmax*nmax2,"pair:sz"); - memory->create(dlayerx,nmax2,fnmax,"pair:dsx"); - memory->create(dlayery,nmax2,fnmax,"pair:dsy"); - memory->create(dlayerz,nmax2,fnmax,"pair:dsz"); - memory->create(dlayersumx,nmax2,fnmax,"pair:dssumx"); - memory->create(dlayersumy,nmax2,fnmax,"pair:dssumy"); - memory->create(dlayersumz,nmax2,fnmax,"pair:dssumz"); + memory->create(dsx,nmax2,fnmax,"pair:dsx"); + memory->create(dsy,nmax2,fnmax,"pair:dsy"); + memory->create(dsz,nmax2,fnmax,"pair:dsz"); + memory->create(dssumx,nmax2,fnmax,"pair:dssumx"); + memory->create(dssumy,nmax2,fnmax,"pair:dssumy"); + memory->create(dssumz,nmax2,fnmax,"pair:dssumz"); } return false;//everything looks good } From 9c21c8e3efc36466d096669056d445ad57659b41 Mon Sep 17 00:00:00 2001 From: kipbarrett Date: Fri, 23 Apr 2021 10:42:26 -0500 Subject: [PATCH 12/25] added upstream changes --- cmake/CMakeLists.txt | 862 +++++++++++++++++++++++++++++++++++++++++++ src/Makefile.txt | 443 ++++++++++++++++++++++ 2 files changed, 1305 insertions(+) create mode 100644 cmake/CMakeLists.txt create mode 100644 src/Makefile.txt diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt new file mode 100644 index 0000000000..426d2f76e0 --- /dev/null +++ b/cmake/CMakeLists.txt @@ -0,0 +1,862 @@ +######################################## +# CMake build system +# This file is part of LAMMPS +# Created by Christoph Junghans and Richard Berger +cmake_minimum_required(VERSION 3.10) +# set policy to silence warnings about ignoring _ROOT but use it +if(POLICY CMP0074) + cmake_policy(SET CMP0074 NEW) +endif() +######################################## + +project(lammps CXX) +set(SOVERSION 0) + +get_filename_component(LAMMPS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/.. ABSOLUTE) +get_filename_component(LAMMPS_LIB_BINARY_DIR ${CMAKE_BINARY_DIR}/lib ABSOLUTE) + +set(LAMMPS_SOURCE_DIR ${LAMMPS_DIR}/src) +set(LAMMPS_LIB_SOURCE_DIR ${LAMMPS_DIR}/lib) +set(LAMMPS_DOC_DIR ${LAMMPS_DIR}/doc) +set(LAMMPS_TOOLS_DIR ${LAMMPS_DIR}/tools) +set(LAMMPS_PYTHON_DIR ${LAMMPS_DIR}/python) +set(LAMMPS_POTENTIALS_DIR ${LAMMPS_DIR}/potentials) + +set(LAMMPS_DOWNLOADS_URL "https://download.lammps.org" CACHE STRING "Base URL for LAMMPS downloads") +set(LAMMPS_POTENTIALS_URL "${LAMMPS_DOWNLOADS_URL}/potentials") +set(LAMMPS_THIRDPARTY_URL "${LAMMPS_DOWNLOADS_URL}/thirdparty") +mark_as_advanced(LAMMPS_DOWNLOADS_URL) + +find_package(Git) + +# by default, install into $HOME/.local (not /usr/local), so that no root access (and sudo!!) is needed +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/.local" CACHE PATH "Default install path" FORCE) +endif() + +# If enabled, no need to use LD_LIBRARY_PATH / DYLD_LIBRARY_PATH when installed +option(LAMMPS_INSTALL_RPATH "Set runtime path for shared libraries linked to LAMMPS binaries" OFF) +if(LAMMPS_INSTALL_RPATH) + set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}) + set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON) +endif() + +# Cmake modules/macros are in a subdirectory to keep this file cleaner +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Modules) + +# make sure LIBRARY_PATH is set if environment variable is set +if(DEFINED ENV{LIBRARY_PATH}) + list(APPEND CMAKE_LIBRARY_PATH "$ENV{LIBRARY_PATH}") + message(STATUS "Appending $ENV{LIBRARY_PATH} to CMAKE_LIBRARY_PATH: ${CMAKE_LIBRARY_PATH}") +endif() + +include(LAMMPSUtils) + +get_lammps_version(${LAMMPS_SOURCE_DIR}/version.h PROJECT_VERSION) + +include(PreventInSourceBuilds) + +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CXX_FLAGS) + set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE) +endif(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CXX_FLAGS) +string(TOUPPER "${CMAKE_BUILD_TYPE}" BTYPE) + +# check for files auto-generated by make-based buildsystem +# this is fast, so check for it all the time +check_for_autogen_files(${LAMMPS_SOURCE_DIR}) + +###################################################################### +# compiler tests +# these need ot be done early (before further tests). +##################################################################### +include(CheckIncludeFileCXX) + +# set required compiler flags and compiler/CPU arch specific optimizations +if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -restrict") + if(CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 17.3 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 17.4) + set(CMAKE_TUNE_DEFAULT "-xCOMMON-AVX512") + else() + set(CMAKE_TUNE_DEFAULT "-xHost") + endif() +endif() + +# we require C++11 without extensions +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF CACHE BOOL "Use compiler extensions") + +######################################################################## +# User input options # +######################################################################## +set(LAMMPS_MACHINE "" CACHE STRING "Suffix to append to lmp binary (WON'T enable any features automatically") +mark_as_advanced(LAMMPS_MACHINE) +if(LAMMPS_MACHINE) + set(LAMMPS_MACHINE "_${LAMMPS_MACHINE}") +endif() +set(LAMMPS_BINARY lmp${LAMMPS_MACHINE}) + +option(BUILD_SHARED_LIBS "Build shared library" OFF) +if(BUILD_SHARED_LIBS) # for all pkg libs, mpi_stubs and linalg + set(CMAKE_POSITION_INDEPENDENT_CODE ON) +endif() + +option(BUILD_TOOLS "Build and install LAMMPS tools (msi2lmp, binary2txt, chain)" OFF) +option(BUILD_LAMMPS_SHELL "Build and install the LAMMPS shell" OFF) + +include(GNUInstallDirs) +file(GLOB ALL_SOURCES ${LAMMPS_SOURCE_DIR}/[^.]*.cpp) +file(GLOB MAIN_SOURCES ${LAMMPS_SOURCE_DIR}/main.cpp) +list(REMOVE_ITEM ALL_SOURCES ${MAIN_SOURCES}) +add_library(lammps ${ALL_SOURCES}) +add_executable(lmp ${MAIN_SOURCES}) +target_link_libraries(lmp PRIVATE lammps) +set_target_properties(lmp PROPERTIES OUTPUT_NAME ${LAMMPS_BINARY}) +install(TARGETS lmp EXPORT LAMMPS_Targets DESTINATION ${CMAKE_INSTALL_BINDIR}) + +option(CMAKE_VERBOSE_MAKEFILE "Generate verbose Makefiles" OFF) + +set(STANDARD_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS DIPOLE + GRANULAR KSPACE LATTE MANYBODY MC MESSAGE MISC MLIAP MOLECULE PERI POEMS + PLUGIN QEQ REPLICA RIGID SHOCK SPIN SNAP SRD KIM PYTHON MSCG MPIIO VORONOI + USER-ADIOS USER-ATC USER-AWPMD USER-BOCS USER-CGDNA USER-MESODPD USER-CGSDK + USER-COLVARS USER-DIFFRACTION USER-DPD USER-DRUDE USER-EFF USER-FEP USER-H5MD + USER-LB USER-MANIFOLD USER-MEAMC USER-MESONT USER-MGPT USER-MISC USER-MOFFF + USER-MOLFILE USER-NETCDF USER-PHONON USER-PLUMED USER-PTM USER-QTB + USER-RANN USER-REACTION USER-REAXC USER-SCAFACOS USER-SDPD USER-SMD USER-SMTBQ USER-SPH + USER-TALLY USER-UEF USER-VTK USER-QUIP USER-QMMM USER-YAFF USER-PACE) + +set(SUFFIX_PACKAGES CORESHELL GPU KOKKOS OPT USER-INTEL USER-OMP) + +foreach(PKG ${STANDARD_PACKAGES} ${SUFFIX_PACKAGES}) + option(PKG_${PKG} "Build ${PKG} Package" OFF) +endforeach() + +###################################################### +# packages with special compiler needs or external libs +###################################################### +target_include_directories(lammps PUBLIC $) + +if(PKG_USER-ADIOS) + # The search for ADIOS2 must come before MPI because + # it includes its own MPI search with the latest FindMPI.cmake + # script that defines the MPI::MPI_C target + enable_language(C) + find_package(ADIOS2 REQUIRED) + target_link_libraries(lammps PRIVATE adios2::adios2) +endif() + +if(NOT CMAKE_CROSSCOMPILING) + set(MPI_CXX_SKIP_MPICXX TRUE) + find_package(MPI QUIET) + option(BUILD_MPI "Build MPI version" ${MPI_FOUND}) +else() + option(BUILD_MPI "Build MPI version" OFF) +endif() + +if(BUILD_MPI) + # We use a non-standard procedure to cross-compile with MPI on Windows + if((CMAKE_SYSTEM_NAME STREQUAL Windows) AND CMAKE_CROSSCOMPILING) + include(MPI4WIN) + target_link_libraries(lammps PUBLIC MPI::MPI_CXX) + else() + find_package(MPI REQUIRED) + target_link_libraries(lammps PUBLIC MPI::MPI_CXX) + option(LAMMPS_LONGLONG_TO_LONG "Workaround if your system or MPI version does not recognize 'long long' data types" OFF) + if(LAMMPS_LONGLONG_TO_LONG) + target_compile_definitions(lammps PRIVATE -DLAMMPS_LONGLONG_TO_LONG) + endif() + endif() +else() + file(GLOB MPI_SOURCES ${LAMMPS_SOURCE_DIR}/STUBS/mpi.cpp) + add_library(mpi_stubs STATIC ${MPI_SOURCES}) + set_target_properties(mpi_stubs PROPERTIES OUTPUT_NAME lammps_mpi_stubs${LAMMPS_MACHINE}) + target_include_directories(mpi_stubs PUBLIC $) + if(BUILD_SHARED_LIBS) + target_link_libraries(lammps PRIVATE mpi_stubs) + target_include_directories(lammps INTERFACE $) + target_compile_definitions(lammps INTERFACE $) + else() + target_link_libraries(lammps PUBLIC mpi_stubs) + endif() + add_library(MPI::MPI_CXX ALIAS mpi_stubs) +endif() + +set(LAMMPS_SIZES "smallbig" CACHE STRING "LAMMPS integer sizes (smallsmall: all 32-bit, smallbig: 64-bit #atoms #timesteps, bigbig: also 64-bit imageint, 64-bit atom ids)") +set(LAMMPS_SIZES_VALUES smallbig bigbig smallsmall) +set_property(CACHE LAMMPS_SIZES PROPERTY STRINGS ${LAMMPS_SIZES_VALUES}) +validate_option(LAMMPS_SIZES LAMMPS_SIZES_VALUES) +string(TOUPPER ${LAMMPS_SIZES} LAMMPS_SIZES) +target_compile_definitions(lammps PUBLIC -DLAMMPS_${LAMMPS_SIZES}) + +# posix_memalign is not available on Windows +if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + set(LAMMPS_MEMALIGN "0" CACHE STRING "posix_memalign() is not available on Windows" FORCE) +else() + set(LAMMPS_MEMALIGN "64" CACHE STRING "enables the use of the posix_memalign() call instead of malloc() when large chunks or memory are allocated by LAMMPS. Set to 0 to disable") +endif() +if(NOT ${LAMMPS_MEMALIGN} STREQUAL "0") + target_compile_definitions(lammps PRIVATE -DLAMMPS_MEMALIGN=${LAMMPS_MEMALIGN}) +endif() + +option(LAMMPS_EXCEPTIONS "enable the use of C++ exceptions for error messages (useful for library interface)" ${ENABLE_TESTING}) +if(LAMMPS_EXCEPTIONS) + target_compile_definitions(lammps PUBLIC -DLAMMPS_EXCEPTIONS) +endif() + +# "hard" dependencies between packages resulting +# in an error instead of skipping over files +pkg_depends(MLIAP SNAP) +pkg_depends(MPIIO MPI) +pkg_depends(USER-ATC MANYBODY) +pkg_depends(USER-LB MPI) +pkg_depends(USER-PHONON KSPACE) +pkg_depends(USER-SCAFACOS MPI) + +# detect if we may enable OpenMP support by default +set(BUILD_OMP_DEFAULT OFF) +find_package(OpenMP QUIET) +if(OpenMP_FOUND) + check_include_file_cxx(omp.h HAVE_OMP_H_INCLUDE) + if(HAVE_OMP_H_INCLUDE) + set(BUILD_OMP_DEFAULT ON) + endif() +endif() + +option(BUILD_OMP "Build with OpenMP support" ${BUILD_OMP_DEFAULT}) + +if(BUILD_OMP) + find_package(OpenMP REQUIRED) + check_include_file_cxx(omp.h HAVE_OMP_H_INCLUDE) + if(NOT HAVE_OMP_H_INCLUDE) + message(FATAL_ERROR "Cannot find the 'omp.h' header file required for full OpenMP support") + endif() + + if (((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9.0)) OR + (CMAKE_CXX_COMPILER_ID STREQUAL "PGI") OR + ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 10.0)) OR + ((CMAKE_CXX_COMPILER_ID STREQUAL "Intel") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.0))) + # GCC 9.x and later plus Clang 10.x and later implement strict OpenMP 4.0 semantics for consts. + # Intel 18.0 was tested to support both, so we switch to OpenMP 4+ from 19.x onward to be safe. + target_compile_definitions(lammps PRIVATE -DLAMMPS_OMP_COMPAT=4) + else() + target_compile_definitions(lammps PRIVATE -DLAMMPS_OMP_COMPAT=3) + endif() + target_link_libraries(lammps PRIVATE OpenMP::OpenMP_CXX) +endif() + +# Compiler specific features for testing +if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") + option(ENABLE_COVERAGE "Enable collecting code coverage data" OFF) + mark_as_advanced(ENABLE_COVERAGE) + if(ENABLE_COVERAGE) + if(CMAKE_VERSION VERSION_LESS 3.13) + if(CMAKE_CXX_FLAGS) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_${CMAKE_BUILD_TYPE}_FLAGS} --coverage") + endif() + else() + target_compile_options(lammps PUBLIC --coverage) + target_link_options(lammps PUBLIC --coverage) + endif() + endif() +endif() + +####################################### +# add custom target for IWYU analysis +####################################### +set(ENABLE_IWYU OFF CACHE BOOL "Add 'iwyu' build target to call the include-what-you-use tool") +mark_as_advanced(ENABLE_IWYU) +if(ENABLE_IWYU) + set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + find_program(IWYU_EXE NAMES include-what-you-use iwyu) + find_program(IWYU_TOOL NAMES iwyu_tool iwyu-tool iwyu_tool.py) + if (IWYU_EXE AND IWYU_TOOL) + add_custom_target( + iwyu + ${IWYU_TOOL} -o clang -p ${CMAKE_CURRENT_BINARY_DIR} -- -Xiwyu --mapping_file=${CMAKE_CURRENT_SOURCE_DIR}/iwyu/iwyu-extra-map.imp + COMMENT "Running IWYU") + add_dependencies(iwyu lammps) + else() + message(FATAL_ERROR "To use IWYU you need the include-what-you-use/iwyu executable" + "and the iwyu-tool/iwyu_tool script installed in your PATH") + endif() +endif() + +set(ENABLE_SANITIZER "none" CACHE STRING "Select a code sanitizer option (none (default), address, leak, thread, undefined)") +mark_as_advanced(ENABLE_SANITIZER) +set(ENABLE_SANITIZER_VALUES none address leak thread undefined) +set_property(CACHE ENABLE_SANITIZER PROPERTY STRINGS ${ENABLE_SANITIZER_VALUES}) +validate_option(ENABLE_SANITIZER ENABLE_SANITIZER_VALUES) +string(TOLOWER ${ENABLE_SANITIZER} ENABLE_SANITIZER) +if(NOT ENABLE_SANITIZER STREQUAL "none") + if((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")) + if(CMAKE_VERSION VERSION_LESS 3.13) + if(CMAKE_CXX_FLAGS) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=${ENABLE_SANITIZER}") + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_${CMAKE_BUILD_TYPE}_FLAGS} -fsanitize=${ENABLE_SANITIZER}") + endif() + else() + target_compile_options(lammps PUBLIC -fsanitize=${ENABLE_SANITIZER}) + target_link_options(lammps PUBLIC -fsanitize=${ENABLE_SANITIZER}) + endif() + else() + message(WARNING "ENABLE_SANITIZER option not supported by ${CMAKE_CXX_COMPILER_ID} compilers. Ignoring.") + set(ENABLE_SANITIZER "none") + endif() +endif() + +if(PKG_MSCG OR PKG_USER-ATC OR PKG_USER-AWPMD OR PKG_USER-QUIP OR PKG_LATTE) + enable_language(C) + find_package(LAPACK) + find_package(BLAS) + if(NOT LAPACK_FOUND OR NOT BLAS_FOUND) + include(CheckGeneratorSupport) + if(NOT CMAKE_GENERATOR_SUPPORT_FORTRAN) + status(FATAL_ERROR "Cannot build internal linear algebra library as CMake build tool lacks Fortran support") + endif() + enable_language(Fortran) + file(GLOB LAPACK_SOURCES ${LAMMPS_LIB_SOURCE_DIR}/linalg/[^.]*.[fF]) + add_library(linalg STATIC ${LAPACK_SOURCES}) + set_target_properties(linalg PROPERTIES OUTPUT_NAME lammps_linalg${LAMMPS_MACHINE}) + set(BLAS_LIBRARIES "$") + set(LAPACK_LIBRARIES "$") + else() + list(APPEND LAPACK_LIBRARIES ${BLAS_LIBRARIES}) + endif() +endif() + +find_package(JPEG QUIET) +option(WITH_JPEG "Enable JPEG support" ${JPEG_FOUND}) +if(WITH_JPEG) + find_package(JPEG REQUIRED) + target_compile_definitions(lammps PRIVATE -DLAMMPS_JPEG) + if(CMAKE_VERSION VERSION_LESS 3.12) + target_include_directories(lammps PRIVATE ${JPEG_INCLUDE_DIRS}) + target_link_libraries(lammps PRIVATE ${JPEG_LIBRARIES}) + else() + target_link_libraries(lammps PRIVATE JPEG::JPEG) + endif() +endif() + +find_package(PNG QUIET) +find_package(ZLIB QUIET) +if(PNG_FOUND AND ZLIB_FOUND) + option(WITH_PNG "Enable PNG support" ON) +else() + option(WITH_PNG "Enable PNG support" OFF) +endif() +if(WITH_PNG) + find_package(PNG REQUIRED) + find_package(ZLIB REQUIRED) + target_link_libraries(lammps PRIVATE PNG::PNG ZLIB::ZLIB) + target_compile_definitions(lammps PRIVATE -DLAMMPS_PNG) +endif() + +find_program(GZIP_EXECUTABLE gzip) +find_package_handle_standard_args(GZIP REQUIRED_VARS GZIP_EXECUTABLE) +option(WITH_GZIP "Enable GZIP support" ${GZIP_FOUND}) +if(WITH_GZIP) + if(GZIP_FOUND OR ((CMAKE_SYSTEM_NAME STREQUAL Windows) AND CMAKE_CROSSCOMPILING)) + target_compile_definitions(lammps PRIVATE -DLAMMPS_GZIP) + else() + message(FATAL_ERROR "gzip executable not found") + endif() +endif() + +find_program(FFMPEG_EXECUTABLE ffmpeg) +find_package_handle_standard_args(FFMPEG REQUIRED_VARS FFMPEG_EXECUTABLE) +option(WITH_FFMPEG "Enable FFMPEG support" ${FFMPEG_FOUND}) +if(WITH_FFMPEG) + if(FFMPEG_FOUND OR ((CMAKE_SYSTEM_NAME STREQUAL Windows) AND CMAKE_CROSSCOMPILING)) + target_compile_definitions(lammps PRIVATE -DLAMMPS_FFMPEG) + else() + message(FATAL_ERROR "ffmpeg executable not found") + endif() +endif() + +if(BUILD_SHARED_LIBS) + set(CONFIGURE_REQUEST_PIC "--with-pic") + set(CMAKE_REQUEST_PIC "-DCMAKE_POSITION_INDEPENDENT_CODE=${CMAKE_POSITION_INDEPENDENT_CODE}") + set(CUDA_REQUEST_PIC "-Xcompiler ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}") +else() + set(CONFIGURE_REQUEST_PIC) + set(CMAKE_REQUEST_PIC) + set(CUDA_REQUEST_PIC) +endif() + +foreach(PKG_WITH_INCL KSPACE PYTHON MLIAP VORONOI USER-COLVARS USER-MOLFILE USER-NETCDF USER-PLUMED USER-QMMM + USER-QUIP USER-SCAFACOS USER-SMD USER-VTK KIM LATTE MESSAGE MSCG COMPRESS USER-PACE) + if(PKG_${PKG_WITH_INCL}) + include(Packages/${PKG_WITH_INCL}) + endif() +endforeach() + +# optionally enable building script wrappers using swig +option(WITH_SWIG "Build scripting language wrappers with SWIG" OFF) +if(WITH_SWIG) + get_filename_component(LAMMPS_SWIG_DIR ${LAMMPS_SOURCE_DIR}/../tools/swig ABSOLUTE) + add_subdirectory(${LAMMPS_SWIG_DIR} swig) +endif() + +set(CMAKE_TUNE_FLAGS "${CMAKE_TUNE_DEFAULT}" CACHE STRING "Compiler and machine specific optimization flags (compilation only)") +separate_arguments(CMAKE_TUNE_FLAGS) +foreach(_FLAG ${CMAKE_TUNE_FLAGS}) + target_compile_options(lammps PRIVATE ${_FLAG}) +endforeach() +######################################################################## +# Basic system tests (standard libraries, headers, functions, types) # +######################################################################## +foreach(HEADER cmath) + check_include_file_cxx(${HEADER} FOUND_${HEADER}) + if(NOT FOUND_${HEADER}) + message(FATAL_ERROR "Could not find needed header - ${HEADER}") + endif(NOT FOUND_${HEADER}) +endforeach(HEADER) + +set(MATH_LIBRARIES "m" CACHE STRING "math library") +mark_as_advanced( MATH_LIBRARIES ) +target_link_libraries(lammps PRIVATE ${MATH_LIBRARIES}) + +###################################### +# Generate Basic Style files +###################################### +include(StyleHeaderUtils) +RegisterStyles(${LAMMPS_SOURCE_DIR}) + +######################################################## +# Fetch missing external files and archives for packages +######################################################## +foreach(PKG ${STANDARD_PACKAGES} ${SUFFIX_PACKAGES}) + if(PKG_${PKG}) + FetchPotentials(${LAMMPS_SOURCE_DIR}/${PKG} ${LAMMPS_POTENTIALS_DIR}) + endif() +endforeach() + +############################################## +# add sources of enabled packages +############################################ +foreach(PKG ${STANDARD_PACKAGES}) + set(${PKG}_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/${PKG}) + + file(GLOB ${PKG}_SOURCES ${${PKG}_SOURCES_DIR}/[^.]*.cpp) + file(GLOB ${PKG}_HEADERS ${${PKG}_SOURCES_DIR}/[^.]*.h) + + # check for package files in src directory due to old make system + DetectBuildSystemConflict(${LAMMPS_SOURCE_DIR} ${${PKG}_SOURCES} ${${PKG}_HEADERS}) + + if(PKG_${PKG}) + # detects styles in package and adds them to global list + RegisterStyles(${${PKG}_SOURCES_DIR}) + + target_sources(lammps PRIVATE ${${PKG}_SOURCES}) + target_include_directories(lammps PRIVATE ${${PKG}_SOURCES_DIR}) + endif() + + RegisterPackages(${${PKG}_SOURCES_DIR}) +endforeach() + +# packages that need defines set +foreach(PKG MPIIO) + if(PKG_${PKG}) + target_compile_definitions(lammps PRIVATE -DLMP_${PKG}) + endif() +endforeach() + +# dedicated check for entire contents of accelerator packages +foreach(PKG ${SUFFIX_PACKAGES}) + set(${PKG}_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/${PKG}) + + file(GLOB ${PKG}_SOURCES ${${PKG}_SOURCES_DIR}/[^.]*.cpp) + file(GLOB ${PKG}_HEADERS ${${PKG}_SOURCES_DIR}/[^.]*.h) + + # check for package files in src directory due to old make system + DetectBuildSystemConflict(${LAMMPS_SOURCE_DIR} ${${PKG}_SOURCES} ${${PKG}_HEADERS}) + + RegisterPackages(${${PKG}_SOURCES_DIR}) +endforeach() + +############################################## +# add lib sources of (simple) enabled packages +############################################ +foreach(SIMPLE_LIB POEMS USER-ATC USER-AWPMD USER-H5MD USER-MESONT) + if(PKG_${SIMPLE_LIB}) + string(REGEX REPLACE "^USER-" "" PKG_LIB "${SIMPLE_LIB}") + string(TOLOWER "${PKG_LIB}" PKG_LIB) + if(PKG_LIB STREQUAL mesont) + enable_language(Fortran) + file(GLOB_RECURSE ${PKG_LIB}_SOURCES + ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/[^.]*.f90) + else() + file(GLOB_RECURSE ${PKG_LIB}_SOURCES + ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/[^.]*.c + ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}/[^.]*.cpp) + endif() + add_library(${PKG_LIB} STATIC ${${PKG_LIB}_SOURCES}) + set_target_properties(${PKG_LIB} PROPERTIES OUTPUT_NAME lammps_${PKG_LIB}${LAMMPS_MACHINE}) + target_link_libraries(lammps PRIVATE ${PKG_LIB}) + if(PKG_LIB STREQUAL awpmd) + target_include_directories(awpmd PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/awpmd/systems/interact ${LAMMPS_LIB_SOURCE_DIR}/awpmd/ivutils/include) + elseif(PKG_LIB STREQUAL h5md) + target_include_directories(h5md PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/h5md/include ${HDF5_INCLUDE_DIRS}) + else() + target_include_directories(${PKG_LIB} PUBLIC ${LAMMPS_LIB_SOURCE_DIR}/${PKG_LIB}) + endif() + endif() +endforeach() + +if(PKG_USER-AWPMD) + target_link_libraries(awpmd PRIVATE ${LAPACK_LIBRARIES}) +endif() + +if(PKG_USER-ATC) + if(LAMMPS_SIZES STREQUAL BIGBIG) + message(FATAL_ERROR "The USER-ATC Package is not compatible with -DLAMMPS_BIGBIG") + endif() + target_link_libraries(atc PRIVATE ${LAPACK_LIBRARIES}) + if(BUILD_MPI) + target_link_libraries(atc PRIVATE MPI::MPI_CXX) + else() + target_link_libraries(atc PRIVATE mpi_stubs) + endif() + target_include_directories(atc PRIVATE ${LAMMPS_SOURCE_DIR}) + target_compile_definitions(atc PRIVATE -DLAMMPS_${LAMMPS_SIZES}) +endif() + +if(PKG_USER-H5MD) + include(Packages/USER-H5MD) +endif() + +###################################################################### +# packages which selectively include variants based on enabled styles +# e.g. accelerator packages +###################################################################### +foreach(PKG_WITH_INCL CORESHELL QEQ USER-OMP USER-SDPD KOKKOS OPT USER-INTEL GPU) + if(PKG_${PKG_WITH_INCL}) + include(Packages/${PKG_WITH_INCL}) + endif() +endforeach() + +if(PKG_PLUGIN) + if(BUILD_SHARED_LIBS) + target_compile_definitions(lammps PRIVATE -DLMP_PLUGIN) + else() + message(WARNING "Plugin loading will not work unless BUILD_SHARED_LIBS is enabled") + endif() + # link with -ldl or equivalent for plugin loading; except on Windows + if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + target_link_libraries(lammps PRIVATE ${CMAKE_DL_LIBS}) + endif() +endif() + +###################################################################### +# the windows version of LAMMPS requires a couple extra libraries +# and the MPI library - if use - has to be linked right before those +# and after everything else that is compiled locally +###################################################################### +if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + target_link_libraries(lammps PRIVATE -lwsock32 -lpsapi) +endif() + +###################################################### +# Generate style headers based on global list of +# styles registered during package selection +# Generate packages headers from all packages +###################################################### +set(LAMMPS_STYLE_HEADERS_DIR ${CMAKE_CURRENT_BINARY_DIR}/styles) + +GenerateStyleHeaders(${LAMMPS_STYLE_HEADERS_DIR}) +GeneratePackagesHeaders(${LAMMPS_STYLE_HEADERS_DIR}) + +target_include_directories(lammps PRIVATE ${LAMMPS_STYLE_HEADERS_DIR}) + +###################################### +# Generate lmpinstalledpkgs.h +###################################### +set(temp "#ifndef LMP_INSTALLED_PKGS_H\n#define LMP_INSTALLED_PKGS_H\n") +set(temp "${temp}const char * LAMMPS_NS::LAMMPS::installed_packages[] = {\n") +set(temp_PKG_LIST ${STANDARD_PACKAGES} ${SUFFIX_PACKAGES}) +list(SORT temp_PKG_LIST) +foreach(PKG ${temp_PKG_LIST}) + if(PKG_${PKG}) + set(temp "${temp} \"${PKG}\",\n") + endif() +endforeach() +set(temp "${temp} NULL\n};\n#endif\n\n") +message(STATUS "Generating lmpinstalledpkgs.h...") +file(WRITE "${LAMMPS_STYLE_HEADERS_DIR}/lmpinstalledpkgs.h.tmp" "${temp}" ) +execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${LAMMPS_STYLE_HEADERS_DIR}/lmpinstalledpkgs.h.tmp" "${LAMMPS_STYLE_HEADERS_DIR}/lmpinstalledpkgs.h") + +###################################### +# Generate lmpgitversion.h +###################################### +add_custom_target(gitversion COMMAND ${CMAKE_COMMAND} + -DLAMMPS_DIR="${LAMMPS_DIR}" + -DGIT_EXECUTABLE="${GIT_EXECUTABLE}" + -DGIT_FOUND="${GIT_FOUND}" + -DLAMMPS_STYLE_HEADERS_DIR="${LAMMPS_STYLE_HEADERS_DIR}" + -P ${CMAKE_CURRENT_SOURCE_DIR}/Modules/generate_lmpgitversion.cmake) +set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${LAMMPS_STYLE_HEADERS_DIR}/gitversion.h) +add_dependencies(lammps gitversion) + +########################################### +# Actually add executable and lib to build +############################################ +get_property(LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) +list (FIND LANGUAGES "Fortran" _index) +if(${_index} GREATER -1) + target_link_libraries(lammps PRIVATE ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES}) +endif() +set(LAMMPS_CXX_HEADERS angle.h atom.h bond.h citeme.h comm.h compute.h dihedral.h domain.h error.h fix.h force.h group.h improper.h + input.h info.h kspace.h lammps.h lattice.h library.h lmppython.h lmptype.h memory.h modify.h neighbor.h neigh_list.h output.h + pair.h pointers.h region.h timer.h universe.h update.h utils.h variable.h) +if(LAMMPS_EXCEPTIONS) + list(APPEND LAMMPS_CXX_HEADERS exceptions.h) +endif() + +set_target_properties(lammps PROPERTIES OUTPUT_NAME lammps${LAMMPS_MACHINE}) +set_target_properties(lammps PROPERTIES SOVERSION ${SOVERSION}) +target_include_directories(lammps PUBLIC $) +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/includes/lammps) +foreach(_HEADER ${LAMMPS_CXX_HEADERS}) + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/includes/lammps/${_HEADER} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${LAMMPS_SOURCE_DIR}/${_HEADER} ${CMAKE_CURRENT_BINARY_DIR}/includes/lammps/${_HEADER} DEPENDS ${LAMMPS_SOURCE_DIR}/${_HEADER}) + add_custom_target(${_HEADER} DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/includes/lammps/${_HEADER}) + add_dependencies(lammps ${_HEADER}) + if(BUILD_SHARED_LIBS) + install(FILES ${LAMMPS_SOURCE_DIR}/${_HEADER} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lammps) + endif() +endforeach() +target_include_directories(lammps INTERFACE $) +add_library(LAMMPS::lammps ALIAS lammps) +get_target_property(LAMMPS_DEFINES lammps INTERFACE_COMPILE_DEFINITIONS) +set(LAMMPS_API_DEFINES) +foreach(_DEF ${LAMMPS_DEFINES}) + set(LAMMPS_API_DEFINES "${LAMMPS_API_DEFINES} -D${_DEF}") +endforeach() +if(BUILD_SHARED_LIBS) + install(TARGETS lammps EXPORT LAMMPS_Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + configure_file(pkgconfig/liblammps.pc.in ${CMAKE_CURRENT_BINARY_DIR}/liblammps${LAMMPS_MACHINE}.pc @ONLY) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/liblammps${LAMMPS_MACHINE}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + install(EXPORT LAMMPS_Targets FILE LAMMPS_Targets.cmake NAMESPACE LAMMPS:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LAMMPS) + include(CMakePackageConfigHelpers) + configure_file(LAMMPSConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/LAMMPSConfig.cmake @ONLY) + write_basic_package_version_file("LAMMPSConfigVersion.cmake" VERSION ${PROJECT_VERSION} COMPATIBILITY ExactVersion) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/LAMMPSConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/LAMMPSConfigVersion.cmake" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LAMMPS) +endif() +install(FILES ${LAMMPS_DOC_DIR}/lammps.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 RENAME ${LAMMPS_BINARY}.1) + +include(Tools) +include(Documentation) + +############################################################################### +# Install potential and force field files in data directory +############################################################################### +set(LAMMPS_INSTALL_DATADIR ${CMAKE_INSTALL_FULL_DATADIR}/lammps) +install(DIRECTORY ${LAMMPS_POTENTIALS_DIR} DESTINATION ${LAMMPS_INSTALL_DATADIR}) +if(BUILD_TOOLS) + install(DIRECTORY ${LAMMPS_TOOLS_DIR}/msi2lmp/frc_files DESTINATION ${LAMMPS_INSTALL_DATADIR}) +endif() + +configure_file(etc/profile.d/lammps.sh.in ${CMAKE_BINARY_DIR}/etc/profile.d/lammps.sh @ONLY) +configure_file(etc/profile.d/lammps.csh.in ${CMAKE_BINARY_DIR}/etc/profile.d/lammps.csh @ONLY) +install( + FILES ${CMAKE_BINARY_DIR}/etc/profile.d/lammps.sh + ${CMAKE_BINARY_DIR}/etc/profile.d/lammps.csh + DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/profile.d +) + +############################################################################### +# Install LAMMPS lib and python module into site-packages folder with +# "install-python" target. Behaves exactly like "make install-python" for +# conventional build. Only available, if a shared library is built. +# This is primarily for people that only want to use the Python wrapper. +############################################################################### +if(BUILD_SHARED_LIBS) + if(CMAKE_VERSION VERSION_LESS 3.12) + # adjust so we find Python 3 versions before Python 2 on old systems with old CMake + set(Python_ADDITIONAL_VERSIONS 3.9 3.8 3.7 3.6 3.5) + find_package(PythonInterp) # Deprecated since version 3.12 + if(PYTHONINTERP_FOUND) + set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) + endif() + else() + find_package(Python COMPONENTS Interpreter) + endif() + if (Python_EXECUTABLE) + add_custom_target( + install-python ${CMAKE_COMMAND} -E remove_directory build + COMMAND ${Python_EXECUTABLE} install.py -v ${LAMMPS_SOURCE_DIR}/version.h + -p ${LAMMPS_PYTHON_DIR}/lammps + -l ${CMAKE_BINARY_DIR}/liblammps${LAMMPS_MACHINE}${CMAKE_SHARED_LIBRARY_SUFFIX} + WORKING_DIRECTORY ${LAMMPS_PYTHON_DIR} + COMMENT "Installing LAMMPS Python module") + else() + add_custom_target( + install-python + ${CMAKE_COMMAND} -E echo "Must have Python installed to install the LAMMPS Python module") + endif() +else() + add_custom_target( + install-python + ${CMAKE_COMMAND} -E echo "Must build LAMMPS as a shared library to use the Python module") +endif() + +############################################################################### +# Add LAMMPS python module to "install" target. This is taylored for building +# LAMMPS for package managers and with different prefix settings. +# This requires either a shared library or that the PYTHON package is included. +############################################################################### +if(BUILD_SHARED_LIBS OR PKG_PYTHON) + if(CMAKE_VERSION VERSION_LESS 3.12) + find_package(PythonInterp) # Deprecated since version 3.12 + if(PYTHONINTERP_FOUND) + set(Python_EXECUTABLE ${PYTHON_EXECUTABLE}) + endif() + else() + find_package(Python COMPONENTS Interpreter) + endif() + if (Python_EXECUTABLE) + file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/python) + install(CODE "execute_process(COMMAND ${Python_EXECUTABLE} setup.py build -b ${CMAKE_BINARY_DIR}/python install --prefix=${CMAKE_INSTALL_PREFIX} --root=\$ENV{DESTDIR}/ WORKING_DIRECTORY ${LAMMPS_PYTHON_DIR})") + endif() +endif() + +include(Testing) +include(CodeCoverage) +include(CodingStandard) + +get_target_property(DEFINES lammps COMPILE_DEFINITIONS) +include(FeatureSummary) +feature_summary(DESCRIPTION "The following tools and libraries have been found and configured:" WHAT PACKAGES_FOUND) +message(STATUS "<<< Build configuration >>> + Operating System: ${CMAKE_SYSTEM_NAME} ${CMAKE_LINUX_DISTRO} ${CMAKE_DISTRO_VERSION} + Build type: ${CMAKE_BUILD_TYPE} + Install path: ${CMAKE_INSTALL_PREFIX} + Generator: ${CMAKE_GENERATOR} using ${CMAKE_MAKE_PROGRAM}") +############################################################################### +# Print package summary +############################################################################### +set(ENABLED_PACKAGES) +foreach(PKG ${STANDARD_PACKAGES} ${SUFFIX_PACKAGES}) + if(PKG_${PKG}) + list(APPEND ENABLED_PACKAGES ${PKG}) + endif() +endforeach() +if(ENABLED_PACKAGES) + list(SORT ENABLED_PACKAGES) +else() + set(ENABLED_PACKAGES "") +endif() +message(STATUS "Enabled packages: ${ENABLED_PACKAGES}") + +message(STATUS "<<< Compilers and Flags: >>> +-- C++ Compiler: ${CMAKE_CXX_COMPILER} + Type: ${CMAKE_CXX_COMPILER_ID} + Version: ${CMAKE_CXX_COMPILER_VERSION} + C++ Flags: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BTYPE}} + Defines: ${DEFINES}") +get_target_property(OPTIONS lammps COMPILE_OPTIONS) +if(OPTIONS) + message(" Options: ${OPTIONS}") +endif() +get_property(LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) +list (FIND LANGUAGES "Fortran" _index) +if(${_index} GREATER -1) + message(STATUS "Fortran Compiler: ${CMAKE_Fortran_COMPILER} + Type: ${CMAKE_Fortran_COMPILER_ID} + Version: ${CMAKE_Fortran_COMPILER_VERSION} + Fortran Flags:${CMAKE_Fortran_FLAGS} ${CMAKE_Fortran_FLAGS_${BTYPE}}") +endif() +list (FIND LANGUAGES "C" _index) +if(${_index} GREATER -1) + message(STATUS "C compiler: ${CMAKE_C_COMPILER} + Type: ${CMAKE_C_COMPILER_ID} + Version: ${CMAKE_C_COMPILER_VERSION} + C Flags: ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${BTYPE}}") +endif() +message(STATUS "<<< Linker flags: >>>") +message(STATUS "Executable name: ${LAMMPS_BINARY}") +if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.13) + get_target_property(OPTIONS lammps LINK_OPTIONS) + if(OPTIONS) + message(STATUS "Linker options: ${OPTIONS}") + endif() +endif() +if(CMAKE_EXE_LINKER_FLAGS) + message(STATUS "Executable linker flags: ${CMAKE_EXE_LINKER_FLAGS}") +endif() +if(BUILD_SHARED_LIBS) + message(STATUS "Shared library flags: ${CMAKE_SHARED_LINKER_FLAGS}") +else() + message(STATUS "Static library flags: ${CMAKE_STATIC_LINKER_FLAGS}") +endif() +if(BUILD_MPI) + message(STATUS "<<< MPI flags >>> +-- MPI_defines: ${MPI_CXX_COMPILE_DEFINITIONS} +-- MPI includes: ${MPI_CXX_INCLUDE_PATH} +-- MPI libraries: ${MPI_CXX_LIBRARIES};${MPI_Fortran_LIBRARIES}") +endif() +if(PKG_GPU) + message(STATUS "<<< GPU package settings >>> +-- GPU API: ${GPU_API}") + if(GPU_API STREQUAL "CUDA") + message(STATUS "CUDA Compiler: ${CUDA_NVCC_EXECUTABLE}") + message(STATUS "GPU default architecture: ${GPU_ARCH}") + message(STATUS "GPU binning with CUDPP: ${CUDPP_OPT}") + message(STATUS "CUDA MPS support: ${CUDA_MPS_SUPPORT}") + elseif(GPU_API STREQUAL "HIP") + message(STATUS "HIP platform: ${HIP_PLATFORM}") + message(STATUS "HIP architecture: ${HIP_ARCH}") + if(HIP_USE_DEVICE_SORT) + message(STATUS "HIP GPU sorting: on") + else() + message(STATUS "HIP GPU sorting: off") + endif() + endif() + message(STATUS "GPU precision: ${GPU_PREC}") +endif() +if(PKG_KOKKOS) + message(STATUS "Kokkos Arch: ${KOKKOS_ARCH}") +endif() +if(PKG_KSPACE) + message(STATUS "<<< FFT settings >>> +-- Primary FFT lib: ${FFT}") + if(FFT_SINGLE) + message(STATUS "Using single precision FFTs") + else() + message(STATUS "Using double precision FFTs") + endif() + if(FFT_FFTW_THREADS OR FFT_MKL_THREADS) + message(STATUS "Using threaded FFTs") + else() + message(STATUS "Using non-threaded FFTs") + endif() + if(PKG_KOKKOS) + if(Kokkos_ENABLE_CUDA) + if (${FFT} STREQUAL "KISS") + message(STATUS "Kokkos FFT: KISS") + else() + message(STATUS "Kokkos FFT: cuFFT") + endif() + else() + message(STATUS "Kokkos FFT: ${FFT}") + endif() + endif() +endif() +if(BUILD_DOC) + message(STATUS "<<< Building HTML Manual >>>") +endif() +if(BUILD_TOOLS) + message(STATUS "<<< Building Tools >>>") +endif() +if(BUILD_LAMMPS_SHELL) + message(STATUS "<<< Building LAMMPS Shell >>>") +endif() +if(ENABLE_TESTING) + message(STATUS "<<< Building Unit Tests >>>") + if(ENABLE_COVERAGE) + message(STATUS "Collecting code coverage data") + endif() +endif() diff --git a/src/Makefile.txt b/src/Makefile.txt new file mode 100644 index 0000000000..5542ed0cc5 --- /dev/null +++ b/src/Makefile.txt @@ -0,0 +1,443 @@ +# LAMMPS multiple-machine -*- Makefile -*- + +SHELL = /bin/bash +PYTHON = python + +#.IGNORE: + +# Definitions + +ROOT = lmp +EXE = lmp_$@ +ARLIB = liblammps_$@.a +SHLIB = liblammps_$@.so +ARLINK = liblammps.a +SHLINK = liblammps.so +TMPNAME= tmp_$@_name +LMPLINK= -L. -llammps_$@ + +OBJDIR = Obj_$@ +OBJSHDIR = Obj_shared_$@ + +SRC = $(wildcard *.cpp) +INC = $(filter-out lmpinstalledpkgs.h lmpgitversion.h,$(wildcard *.h)) +OBJ = $(SRC:.cpp=.o) + +SRCLIB = $(filter-out main.cpp,$(SRC)) +OBJLIB = $(filter-out main.o,$(OBJ)) + +# Command-line options for mode: static (default), shared, or print + +mode = static +objdir = $(OBJDIR) + +ifeq ($(mode),shared) +objdir = $(OBJSHDIR) +endif + +# Package variables + +# PACKAGE = standard packages +# PACKUSER = user packagse +# PACKLIB = all packages that require an additional lib +# should be PACKSYS + PACKINT + PACKEXT +# PACKSYS = subset that reqiure a common system library +# include MPIIO and LB b/c require full MPI, not just STUBS +# PACKINT = subset that require an internal (provided) library +# PACKEXT = subset that require an external (downloaded) library + +PACKAGE = asphere body class2 colloid compress coreshell dipole gpu \ + granular kim kokkos kspace latte manybody mc message misc \ + mliap molecule mpiio mscg opt peri plugin poems \ + python qeq replica rigid shock snap spin srd voronoi + +PACKUSER = user-adios user-atc user-awpmd user-bocs user-cgdna user-cgsdk user-colvars \ + user-diffraction user-dpd user-drude user-eff user-fep user-h5md \ + user-intel user-lb user-manifold user-meamc user-mesodpd user-mesont \ + user-mgpt user-misc user-mofff user-molfile \ + user-netcdf user-omp user-phonon user-pace user-plumed user-ptm user-qmmm \ + user-qtb user-quip user-rann user-reaction user-reaxc user-scafacos user-smd user-smtbq \ + user-sdpd user-sph user-tally user-uef user-vtk user-yaff + +PACKLIB = compress gpu kim kokkos latte message mpiio mscg poems \ + python voronoi \ + user-adios user-atc user-awpmd user-colvars user-h5md user-lb user-molfile \ + user-netcdf user-plumed user-qmmm user-quip user-scafacos \ + user-smd user-vtk user-mesont user-pace + +PACKSYS = compress mpiio python user-lb + +PACKINT = gpu kokkos message poems user-atc user-awpmd user-colvars user-mesont + +PACKEXT = kim latte mscg voronoi \ + user-adios user-h5md user-molfile user-netcdf user-pace user-plumed \ + user-qmmm user-quip user-smd user-vtk + +PACKALL = $(PACKAGE) $(PACKUSER) + +# Helper GNU make function for conversion to upper case without using shell commands +uppercase_TABLE:=a,A b,B c,C d,D e,E f,F g,G h,H i,I j,J k,K l,L m,M n,N o,O p,P q,Q r,R s,S t,T u,U v,V w,W x,X y,Y z,Z +uppercase_internal=$(if $1,$$(subst $(firstword $1),$(call uppercase_internal,$(wordlist 2,$(words $1),$1),$2)),$2) +uppercase=$(eval uppercase_RESULT:=$(call uppercase_internal,$(uppercase_TABLE),$1))$(uppercase_RESULT) + +PACKAGEUC = $(call uppercase,$(PACKAGE)) +PACKUSERUC = $(call uppercase,$(PACKUSER)) + +YESDIR = $(call uppercase,$(@:yes-%=%)) +NODIR = $(call uppercase,$(@:no-%=%)) +LIBDIR = $(@:lib-%=%) +LIBUSERDIR = $(@:lib-user-%=%) + +# List of all targets + +help: + @echo '' + @echo 'make clean-all delete all object files' + @echo 'make clean-machine delete object files for one machine' + @echo 'make mpi-stubs build dummy MPI library in STUBS' + @echo 'make install-python install LAMMPS wrapper in Python' + @echo 'make tar create lmp_src.tar.gz for src dir and packages' + @echo '' + @echo 'make package list available packages and their dependencies' + @echo 'make package-status (ps) status of all packages' + @echo 'make package-installed (pi) list of installed packages' + @echo 'make yes-package install a single pgk in src dir' + @echo 'make no-package remove a single pkg from src dir' + @echo 'make yes-all install all pgks in src dir' + @echo 'make no-all remove all pkgs from src dir' + @echo 'make yes-standard (yes-std) install all standard pkgs' + @echo 'make no-standard (no-std) remove all standard pkgs' + @echo 'make yes-user install all user pkgs' + @echo 'make no-user remove all user pkgs' + @echo 'make yes-lib install all pkgs with libs (included or ext)' + @echo 'make no-lib remove all pkgs with libs (included or ext)' + @echo 'make yes-ext install all pkgs with external libs' + @echo 'make no-ext remove all pkgs with external libs' + @echo '' + @echo 'make package-update (pu) replace src files with updated package files' + @echo 'make package-overwrite replace package files with src files' + @echo 'make package-diff (pd) diff src files against package files' + @echo '' + @echo 'make lib-package help for download/build/install a package library' + @echo 'make lib-package args="..." download/build/install a package library' + @echo 'make purge purge obsolete copies of source files' + @echo '' + @echo 'make machine build LAMMPS for machine with static library' + @echo 'make mode=static machine same as above' + @echo 'make mode=shared machine build LAMMPS for machine with shared library' + @echo 'make mode=print machine print compiler/linker flags' + @echo '' + @echo 'machine is one of these from src/MAKE:' + @echo '' + @files="`ls MAKE/Makefile.*`"; \ + for file in $$files; do head -1 $$file; done + @echo '' + @echo '... or one of these from src/MAKE/OPTIONS:' + @echo '' + @files="`ls MAKE/OPTIONS/Makefile.*`"; \ + for file in $$files; do head -1 $$file; done + @echo '' + @echo '... or one of these from src/MAKE/MACHINES:' + @echo '' + @files="`ls MAKE/MACHINES/Makefile.*`"; \ + for file in $$files; do head -1 $$file; done + @echo '' + @echo '... or one of these from src/MAKE/MINE:' + @echo '' + @files="`ls MAKE/MINE/Makefile.* 2>/dev/null`"; \ + for file in $$files; do head -1 $$file; done + @echo '' + + +lmpinstalledpkgs.h: $(SRC) $(INC) + @echo '#ifndef LMP_INSTALLED_PKGS_H' > ${TMPNAME}.lmpinstalled + @echo '#define LMP_INSTALLED_PKGS_H' >> ${TMPNAME}.lmpinstalled + @echo 'const char * LAMMPS_NS::LAMMPS::installed_packages[] = {' >> ${TMPNAME}.lmpinstalled + @for p in $(PACKAGEUC) $(PACKUSERUC); do info=$$($(SHELL) Package.sh $$p installed); \ + [ -n "$$info" ] && echo "\"$$info\"" | sed -e 's/".*package \(.*\)"/"\1",/' >> ${TMPNAME}.lmpinstalled || :; done + @echo ' NULL };' >> ${TMPNAME}.lmpinstalled + @echo '#endif' >> ${TMPNAME}.lmpinstalled + @if [ -f lmpinstalledpkgs.h ]; \ + then test "`diff --brief ${TMPNAME}.lmpinstalled lmpinstalledpkgs.h`" != "" && \ + mv ${TMPNAME}.lmpinstalled lmpinstalledpkgs.h || rm ${TMPNAME}.lmpinstalled ; \ + else mv ${TMPNAME}.lmpinstalled lmpinstalledpkgs.h ; fi + +gitversion: + @echo 'Gathering git version information' + @echo '#ifndef LMP_GIT_VERSION_H' > ${TMPNAME}.lmpgitversion + @echo '#define LMP_GIT_VERSION_H' >> ${TMPNAME}.lmpgitversion + @if (type git && test -e ../.git ) >> /dev/null 2>> /dev/null ; then \ + git='true'; \ + commit=$$(git rev-parse HEAD); \ + branch=$$(git rev-parse --abbrev-ref HEAD); \ + describe=$$(git describe --dirty=-modified); \ + else \ + git='false' ; \ + commit='(unknown)' ; \ + branch='(unknown)' ; \ + describe='(unknown)' ; \ + fi ; \ + echo "const bool LAMMPS_NS::LAMMPS::has_git_info = $${git};" >> ${TMPNAME}.lmpgitversion ; \ + echo "const char LAMMPS_NS::LAMMPS::git_commit[] = \"$${commit}\";" >> ${TMPNAME}.lmpgitversion ; \ + echo "const char LAMMPS_NS::LAMMPS::git_branch[] = \"$${branch}\";" >> ${TMPNAME}.lmpgitversion ; \ + echo "const char LAMMPS_NS::LAMMPS::git_descriptor[] = \"$${describe}\";" >> ${TMPNAME}.lmpgitversion + @echo '#endif' >> ${TMPNAME}.lmpgitversion + @if [ -f lmpgitversion.h ]; \ + then test "`diff --brief ${TMPNAME}.lmpgitversion lmpgitversion.h`" != "" && \ + mv ${TMPNAME}.lmpgitversion lmpgitversion.h || rm ${TMPNAME}.lmpgitversion ; \ + else mv ${TMPNAME}.lmpgitversion lmpgitversion.h ; fi + +# Build LAMMPS in one of 2 modes +# static = static compile in Obj_machine (default) +# shared = shared compile in Obj_shared_machine + +.DEFAULT: + @if [ $@ = "serial" ]; \ + then cd STUBS; $(MAKE); cd ..; fi + @test -f MAKE/Makefile.$@ -o -f MAKE/OPTIONS/Makefile.$@ -o \ + -f MAKE/MACHINES/Makefile.$@ -o -f MAKE/MINE/Makefile.$@ + @if [ ! -d $(objdir) ]; then mkdir $(objdir); fi + @echo 'Gathering installed package information (may take a little while)' + @$(SHELL) Make.sh style + @$(SHELL) Make.sh packages + @$(MAKE) $(MFLAGS) lmpinstalledpkgs.h gitversion + @echo 'Compiling LAMMPS for machine $@' + @if [ -f MAKE/MACHINES/Makefile.$@ ]; \ + then cp MAKE/MACHINES/Makefile.$@ $(objdir)/Makefile; fi + @if [ -f MAKE/OPTIONS/Makefile.$@ ]; \ + then cp MAKE/OPTIONS/Makefile.$@ $(objdir)/Makefile; fi + @if [ -f MAKE/Makefile.$@ ]; \ + then cp MAKE/Makefile.$@ $(objdir)/Makefile; fi + @if [ -f MAKE/MINE/Makefile.$@ ]; \ + then cp MAKE/MINE/Makefile.$@ $(objdir)/Makefile; fi + @if [ ! -e Makefile.package ]; \ + then cp Makefile.package.empty Makefile.package; fi + @if [ ! -e Makefile.package.settings ]; \ + then cp Makefile.package.settings.empty Makefile.package.settings; fi + @cp Makefile.package Makefile.package.settings $(objdir) + @cd $(objdir); rm -f .depend; \ + $(MAKE) $(MFLAGS) "SRC = $(SRC)" "INC = $(INC)" depend || : + @rm -f $(ARLINK) $(SHLINK) $(EXE) +ifeq ($(mode),static) + @cd $(objdir); \ + $(MAKE) $(MFLAGS) "OBJ = $(OBJLIB)" "INC = $(INC)" "SHFLAGS =" \ + "LMPLIB = $(ARLIB)" "ARLIB = $(ARLIB)" "SHLIB = $(SHLIB)" \ + "LMPLINK = $(LMPLINK)" "EXE = ../$(EXE)" ../$(EXE) + @ln -s $(ARLIB) $(ARLINK) +endif +ifeq ($(mode),shared) + @cd $(objdir); \ + $(MAKE) $(MFLAGS) "OBJ = $(OBJLIB)" "INC = $(INC)" \ + "LMPLIB = $(SHLIB)" "ARLIB = $(ARLIB)" "SHLIB = $(SHLIB)" \ + "LMPLINK = $(LMPLINK)" "EXE = ../$(EXE)" ../$(EXE) + @ln -s $(SHLIB) $(SHLINK) +endif +# backward compatibility +ifeq ($(mode),exe) + $(MAKE) $(MFLAGS) mode=static $@ +endif +ifeq ($(mode),lib) + $(MAKE) $(MFLAGS) mode=static $@ +endif +ifeq ($(mode),shexe) + $(MAKE) $(MFLAGS) mode=shared $@ +endif +ifeq ($(mode),shlib) + $(MAKE) $(MFLAGS) mode=shared $@ +endif + +ifeq ($(mode),print) + @cd $(objdir); \ + $(MAKE) $(MFLAGS) "OBJ = $(OBJLIB)" "INC = $(INC)" \ + "EXE = ../$(ARLIB)" -f ../Makefile.print +endif + +# Remove machine-specific object files + +clean: + @echo 'make clean-all delete all object files' + @echo 'make clean-machine delete object files for one machine' + +clean-all: + rm -rf Obj_* + +clean-%: + @if [ $@ = "clean-serial" ]; \ + then cd STUBS; $(MAKE) clean; cd ..; fi + rm -rf Obj_$(@:clean-%=%) Obj_shared_$(@:clean-%=%) + +# Make MPI STUBS library + +mpi-stubs: + @cd STUBS; $(MAKE) clean; $(MAKE) + +# install LAMMPS shared lib and Python wrapper for Python usage +# include python package settings to automatically adapt name of +# the python interpreter. must purge build folder to not install +# unwanted outdated files. + +sinclude ../lib/python/Makefile.lammps +install-python: + @rm -rf ../python/build + @$(PYTHON) ../python/install.py -v ../src/version.h \ + -p ../python/lammps -l ../src/liblammps.so + +# Create a tarball of src dir and packages + +tar: + @cd STUBS; $(MAKE) clean + @cd ..; tar cvzf src/$(ROOT)_src.tar.gz \ + src/Make* src/Package.sh src/Depend.sh src/Install.sh src/Fetch.sh \ + src/MAKE src/DEPEND src/*.cpp src/*.h src/STUBS \ + $(patsubst %,src/%,$(PACKAGEUC)) $(patsubst %,src/%,$(PACKUSERUC)) \ + --exclude=*/.svn + @cd STUBS; $(MAKE) + @echo "Created $(ROOT)_src.tar.gz" + +# Package management + +package: + @echo 'Standard packages:' $(PACKAGE) + @echo '' + @echo 'User-contributed packages:' $(PACKUSER) + @echo '' + @echo 'Packages that need system libraries:' $(PACKSYS) + @echo '' + @echo 'Packages that need provided libraries:' $(PACKINT) + @echo '' + @echo 'Packages that need external libraries:' $(PACKEXT) + @echo '' + @echo 'make package list available packages' + @echo 'make package list available packages' + @echo 'make package-status (ps) status of all packages' + @echo 'make package-installed (pi) list of installed packages' + @echo 'make yes-package install a single pgk in src dir' + @echo 'make no-package remove a single pkg from src dir' + @echo 'make yes-all install all pgks in src dir' + @echo 'make no-all remove all pkgs from src dir' + @echo 'make yes-standard (yes-std) install all standard pkgs' + @echo 'make no-standard (no-std) remove all standard pkgs' + @echo 'make yes-user install all user pkgs' + @echo 'make no-user remove all user pkgs' + @echo 'make yes-lib install all pkgs with libs (included or ext)' + @echo 'make no-lib remove all pkgs with libs (included or ext)' + @echo 'make yes-ext install all pkgs with external libs' + @echo 'make no-ext remove all pkgs with external libs' + @echo '' + @echo 'make package-update (pu) replace src files with package files' + @echo 'make package-overwrite replace package files with src files' + @echo 'make package-diff (pd) diff src files against package file' + @echo '' + @echo 'make lib-package build and/or download a package library' + +yes-all: + @for p in $(PACKALL); do $(MAKE) yes-$$p; done + +no-all: + @for p in $(PACKALL); do $(MAKE) no-$$p; done + +yes-standard yes-std: + @for p in $(PACKAGE); do $(MAKE) yes-$$p; done + +no-standard no-std: + @for p in $(PACKAGE); do $(MAKE) no-$$p; done + +yes-user: + @for p in $(PACKUSER); do $(MAKE) yes-$$p; done + +no-user: + @for p in $(PACKUSER); do $(MAKE) no-$$p; done + +yes-lib: + @for p in $(PACKLIB); do $(MAKE) yes-$$p; done + +no-lib: + @for p in $(PACKLIB); do $(MAKE) no-$$p; done + +yes-ext: + @for p in $(PACKEXT); do $(MAKE) yes-$$p; done + +no-ext: + @for p in $(PACKEXT); do $(MAKE) no-$$p; done + +yes-%: + @if [ ! -e Makefile.package ]; \ + then cp Makefile.package.empty Makefile.package; fi + @if [ ! -e Makefile.package.settings ]; \ + then cp Makefile.package.settings.empty Makefile.package.settings; fi + @if [ ! -e $(YESDIR) ]; then \ + echo "Package $(YESDIR) does not exist"; exit 1; \ + elif [ -e $(YESDIR)/Install.sh ]; then \ + echo "Installing package $(@:yes-%=%)"; \ + cd $(YESDIR); $(SHELL) Install.sh 1; cd ..; \ + $(SHELL) Depend.sh $(YESDIR) 1; \ + else \ + echo "Installing package $(@:yes-%=%)"; \ + cd $(YESDIR); $(SHELL) ../Install.sh 1; cd ..; \ + $(SHELL) Depend.sh $(YESDIR) 1; \ + fi; + @$(SHELL) Fetch.sh $(YESDIR) + +no-%: + @if [ ! -e $(NODIR) ]; then \ + echo "Package $(NODIR) does not exist"; exit 1; \ + elif [ -e $(NODIR)/Install.sh ]; then \ + echo "Uninstalling package $(@:no-%=%)"; \ + cd $(NODIR); $(SHELL) Install.sh 0; cd ..; \ + $(SHELL) Depend.sh $(NODIR) 0; \ + else \ + echo "Uninstalling package $(@:no-%=%)"; \ + cd $(NODIR); $(SHELL) ../Install.sh 0; cd ..; \ + $(SHELL) Depend.sh $(NODIR) 0; \ + fi; + +# download/build/install a package library +# update the timestamp on main.cpp to trigger a relink with "make machine" + +lib-%: + @if [ -e ../lib/$(LIBDIR)/Install.py ]; then \ + echo "Installing lib $(@:lib-%=%)"; \ + ( cd ../lib/$(LIBDIR); $(PYTHON) Install.py $(args) ); \ + elif [ -e ../lib/$(LIBUSERDIR)/Install.py ]; then \ + echo "Installing lib $(@:lib-user-%=%)"; \ + ( cd ../lib/$(LIBUSERDIR); $(PYTHON) Install.py $(args) ); \ + else \ + echo "Install script for lib $(@:lib-%=%) does not exist"; \ + fi; touch main.cpp + +# status = list src files that differ from package files +# installed = list of installed packages +# update = replace src files with newer package files +# overwrite = overwrite package files with newer src files +# diff = show differences between src and package files +# purge = delete obsolete and auto-generated package files + +package-status ps: + @for p in $(PACKAGEUC); do $(SHELL) Package.sh $$p status; done + @echo '' + @for p in $(PACKUSERUC); do $(SHELL) Package.sh $$p status; done + +package-installed pi: + @for p in $(PACKAGEUC); do $(SHELL) Package.sh $$p installed; done + @for p in $(PACKUSERUC); do $(SHELL) Package.sh $$p installed; done + +package-update pu: purge + @for p in $(PACKAGEUC); do $(SHELL) Package.sh $$p update; done + @echo '' + @for p in $(PACKUSERUC); do $(SHELL) Package.sh $$p update; done + +package-overwrite: purge + @for p in $(PACKAGEUC); do $(SHELL) Package.sh $$p overwrite; done + @echo '' + @for p in $(PACKUSERUC); do $(SHELL) Package.sh $$p overwrite; done + +package-diff pd: + @for p in $(PACKAGEUC); do $(SHELL) Package.sh $$p diff; done + @echo '' + @for p in $(PACKUSERUC); do $(SHELL) Package.sh $$p diff; done + +purge: Purge.list + @echo 'Purging obsolete and auto-generated source files' + @for f in `grep -v '#' Purge.list` ; \ + do test -f $$f && rm $$f && echo $$f || : ; \ + done From 792b411e46e03a6bf665ebd56dc02de16e0e90f6 Mon Sep 17 00:00:00 2001 From: kipbarrett Date: Fri, 23 Apr 2021 11:18:46 -0500 Subject: [PATCH 13/25] fix messed up merge --- src/Makefile | 443 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 443 insertions(+) create mode 100644 src/Makefile diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000000..5542ed0cc5 --- /dev/null +++ b/src/Makefile @@ -0,0 +1,443 @@ +# LAMMPS multiple-machine -*- Makefile -*- + +SHELL = /bin/bash +PYTHON = python + +#.IGNORE: + +# Definitions + +ROOT = lmp +EXE = lmp_$@ +ARLIB = liblammps_$@.a +SHLIB = liblammps_$@.so +ARLINK = liblammps.a +SHLINK = liblammps.so +TMPNAME= tmp_$@_name +LMPLINK= -L. -llammps_$@ + +OBJDIR = Obj_$@ +OBJSHDIR = Obj_shared_$@ + +SRC = $(wildcard *.cpp) +INC = $(filter-out lmpinstalledpkgs.h lmpgitversion.h,$(wildcard *.h)) +OBJ = $(SRC:.cpp=.o) + +SRCLIB = $(filter-out main.cpp,$(SRC)) +OBJLIB = $(filter-out main.o,$(OBJ)) + +# Command-line options for mode: static (default), shared, or print + +mode = static +objdir = $(OBJDIR) + +ifeq ($(mode),shared) +objdir = $(OBJSHDIR) +endif + +# Package variables + +# PACKAGE = standard packages +# PACKUSER = user packagse +# PACKLIB = all packages that require an additional lib +# should be PACKSYS + PACKINT + PACKEXT +# PACKSYS = subset that reqiure a common system library +# include MPIIO and LB b/c require full MPI, not just STUBS +# PACKINT = subset that require an internal (provided) library +# PACKEXT = subset that require an external (downloaded) library + +PACKAGE = asphere body class2 colloid compress coreshell dipole gpu \ + granular kim kokkos kspace latte manybody mc message misc \ + mliap molecule mpiio mscg opt peri plugin poems \ + python qeq replica rigid shock snap spin srd voronoi + +PACKUSER = user-adios user-atc user-awpmd user-bocs user-cgdna user-cgsdk user-colvars \ + user-diffraction user-dpd user-drude user-eff user-fep user-h5md \ + user-intel user-lb user-manifold user-meamc user-mesodpd user-mesont \ + user-mgpt user-misc user-mofff user-molfile \ + user-netcdf user-omp user-phonon user-pace user-plumed user-ptm user-qmmm \ + user-qtb user-quip user-rann user-reaction user-reaxc user-scafacos user-smd user-smtbq \ + user-sdpd user-sph user-tally user-uef user-vtk user-yaff + +PACKLIB = compress gpu kim kokkos latte message mpiio mscg poems \ + python voronoi \ + user-adios user-atc user-awpmd user-colvars user-h5md user-lb user-molfile \ + user-netcdf user-plumed user-qmmm user-quip user-scafacos \ + user-smd user-vtk user-mesont user-pace + +PACKSYS = compress mpiio python user-lb + +PACKINT = gpu kokkos message poems user-atc user-awpmd user-colvars user-mesont + +PACKEXT = kim latte mscg voronoi \ + user-adios user-h5md user-molfile user-netcdf user-pace user-plumed \ + user-qmmm user-quip user-smd user-vtk + +PACKALL = $(PACKAGE) $(PACKUSER) + +# Helper GNU make function for conversion to upper case without using shell commands +uppercase_TABLE:=a,A b,B c,C d,D e,E f,F g,G h,H i,I j,J k,K l,L m,M n,N o,O p,P q,Q r,R s,S t,T u,U v,V w,W x,X y,Y z,Z +uppercase_internal=$(if $1,$$(subst $(firstword $1),$(call uppercase_internal,$(wordlist 2,$(words $1),$1),$2)),$2) +uppercase=$(eval uppercase_RESULT:=$(call uppercase_internal,$(uppercase_TABLE),$1))$(uppercase_RESULT) + +PACKAGEUC = $(call uppercase,$(PACKAGE)) +PACKUSERUC = $(call uppercase,$(PACKUSER)) + +YESDIR = $(call uppercase,$(@:yes-%=%)) +NODIR = $(call uppercase,$(@:no-%=%)) +LIBDIR = $(@:lib-%=%) +LIBUSERDIR = $(@:lib-user-%=%) + +# List of all targets + +help: + @echo '' + @echo 'make clean-all delete all object files' + @echo 'make clean-machine delete object files for one machine' + @echo 'make mpi-stubs build dummy MPI library in STUBS' + @echo 'make install-python install LAMMPS wrapper in Python' + @echo 'make tar create lmp_src.tar.gz for src dir and packages' + @echo '' + @echo 'make package list available packages and their dependencies' + @echo 'make package-status (ps) status of all packages' + @echo 'make package-installed (pi) list of installed packages' + @echo 'make yes-package install a single pgk in src dir' + @echo 'make no-package remove a single pkg from src dir' + @echo 'make yes-all install all pgks in src dir' + @echo 'make no-all remove all pkgs from src dir' + @echo 'make yes-standard (yes-std) install all standard pkgs' + @echo 'make no-standard (no-std) remove all standard pkgs' + @echo 'make yes-user install all user pkgs' + @echo 'make no-user remove all user pkgs' + @echo 'make yes-lib install all pkgs with libs (included or ext)' + @echo 'make no-lib remove all pkgs with libs (included or ext)' + @echo 'make yes-ext install all pkgs with external libs' + @echo 'make no-ext remove all pkgs with external libs' + @echo '' + @echo 'make package-update (pu) replace src files with updated package files' + @echo 'make package-overwrite replace package files with src files' + @echo 'make package-diff (pd) diff src files against package files' + @echo '' + @echo 'make lib-package help for download/build/install a package library' + @echo 'make lib-package args="..." download/build/install a package library' + @echo 'make purge purge obsolete copies of source files' + @echo '' + @echo 'make machine build LAMMPS for machine with static library' + @echo 'make mode=static machine same as above' + @echo 'make mode=shared machine build LAMMPS for machine with shared library' + @echo 'make mode=print machine print compiler/linker flags' + @echo '' + @echo 'machine is one of these from src/MAKE:' + @echo '' + @files="`ls MAKE/Makefile.*`"; \ + for file in $$files; do head -1 $$file; done + @echo '' + @echo '... or one of these from src/MAKE/OPTIONS:' + @echo '' + @files="`ls MAKE/OPTIONS/Makefile.*`"; \ + for file in $$files; do head -1 $$file; done + @echo '' + @echo '... or one of these from src/MAKE/MACHINES:' + @echo '' + @files="`ls MAKE/MACHINES/Makefile.*`"; \ + for file in $$files; do head -1 $$file; done + @echo '' + @echo '... or one of these from src/MAKE/MINE:' + @echo '' + @files="`ls MAKE/MINE/Makefile.* 2>/dev/null`"; \ + for file in $$files; do head -1 $$file; done + @echo '' + + +lmpinstalledpkgs.h: $(SRC) $(INC) + @echo '#ifndef LMP_INSTALLED_PKGS_H' > ${TMPNAME}.lmpinstalled + @echo '#define LMP_INSTALLED_PKGS_H' >> ${TMPNAME}.lmpinstalled + @echo 'const char * LAMMPS_NS::LAMMPS::installed_packages[] = {' >> ${TMPNAME}.lmpinstalled + @for p in $(PACKAGEUC) $(PACKUSERUC); do info=$$($(SHELL) Package.sh $$p installed); \ + [ -n "$$info" ] && echo "\"$$info\"" | sed -e 's/".*package \(.*\)"/"\1",/' >> ${TMPNAME}.lmpinstalled || :; done + @echo ' NULL };' >> ${TMPNAME}.lmpinstalled + @echo '#endif' >> ${TMPNAME}.lmpinstalled + @if [ -f lmpinstalledpkgs.h ]; \ + then test "`diff --brief ${TMPNAME}.lmpinstalled lmpinstalledpkgs.h`" != "" && \ + mv ${TMPNAME}.lmpinstalled lmpinstalledpkgs.h || rm ${TMPNAME}.lmpinstalled ; \ + else mv ${TMPNAME}.lmpinstalled lmpinstalledpkgs.h ; fi + +gitversion: + @echo 'Gathering git version information' + @echo '#ifndef LMP_GIT_VERSION_H' > ${TMPNAME}.lmpgitversion + @echo '#define LMP_GIT_VERSION_H' >> ${TMPNAME}.lmpgitversion + @if (type git && test -e ../.git ) >> /dev/null 2>> /dev/null ; then \ + git='true'; \ + commit=$$(git rev-parse HEAD); \ + branch=$$(git rev-parse --abbrev-ref HEAD); \ + describe=$$(git describe --dirty=-modified); \ + else \ + git='false' ; \ + commit='(unknown)' ; \ + branch='(unknown)' ; \ + describe='(unknown)' ; \ + fi ; \ + echo "const bool LAMMPS_NS::LAMMPS::has_git_info = $${git};" >> ${TMPNAME}.lmpgitversion ; \ + echo "const char LAMMPS_NS::LAMMPS::git_commit[] = \"$${commit}\";" >> ${TMPNAME}.lmpgitversion ; \ + echo "const char LAMMPS_NS::LAMMPS::git_branch[] = \"$${branch}\";" >> ${TMPNAME}.lmpgitversion ; \ + echo "const char LAMMPS_NS::LAMMPS::git_descriptor[] = \"$${describe}\";" >> ${TMPNAME}.lmpgitversion + @echo '#endif' >> ${TMPNAME}.lmpgitversion + @if [ -f lmpgitversion.h ]; \ + then test "`diff --brief ${TMPNAME}.lmpgitversion lmpgitversion.h`" != "" && \ + mv ${TMPNAME}.lmpgitversion lmpgitversion.h || rm ${TMPNAME}.lmpgitversion ; \ + else mv ${TMPNAME}.lmpgitversion lmpgitversion.h ; fi + +# Build LAMMPS in one of 2 modes +# static = static compile in Obj_machine (default) +# shared = shared compile in Obj_shared_machine + +.DEFAULT: + @if [ $@ = "serial" ]; \ + then cd STUBS; $(MAKE); cd ..; fi + @test -f MAKE/Makefile.$@ -o -f MAKE/OPTIONS/Makefile.$@ -o \ + -f MAKE/MACHINES/Makefile.$@ -o -f MAKE/MINE/Makefile.$@ + @if [ ! -d $(objdir) ]; then mkdir $(objdir); fi + @echo 'Gathering installed package information (may take a little while)' + @$(SHELL) Make.sh style + @$(SHELL) Make.sh packages + @$(MAKE) $(MFLAGS) lmpinstalledpkgs.h gitversion + @echo 'Compiling LAMMPS for machine $@' + @if [ -f MAKE/MACHINES/Makefile.$@ ]; \ + then cp MAKE/MACHINES/Makefile.$@ $(objdir)/Makefile; fi + @if [ -f MAKE/OPTIONS/Makefile.$@ ]; \ + then cp MAKE/OPTIONS/Makefile.$@ $(objdir)/Makefile; fi + @if [ -f MAKE/Makefile.$@ ]; \ + then cp MAKE/Makefile.$@ $(objdir)/Makefile; fi + @if [ -f MAKE/MINE/Makefile.$@ ]; \ + then cp MAKE/MINE/Makefile.$@ $(objdir)/Makefile; fi + @if [ ! -e Makefile.package ]; \ + then cp Makefile.package.empty Makefile.package; fi + @if [ ! -e Makefile.package.settings ]; \ + then cp Makefile.package.settings.empty Makefile.package.settings; fi + @cp Makefile.package Makefile.package.settings $(objdir) + @cd $(objdir); rm -f .depend; \ + $(MAKE) $(MFLAGS) "SRC = $(SRC)" "INC = $(INC)" depend || : + @rm -f $(ARLINK) $(SHLINK) $(EXE) +ifeq ($(mode),static) + @cd $(objdir); \ + $(MAKE) $(MFLAGS) "OBJ = $(OBJLIB)" "INC = $(INC)" "SHFLAGS =" \ + "LMPLIB = $(ARLIB)" "ARLIB = $(ARLIB)" "SHLIB = $(SHLIB)" \ + "LMPLINK = $(LMPLINK)" "EXE = ../$(EXE)" ../$(EXE) + @ln -s $(ARLIB) $(ARLINK) +endif +ifeq ($(mode),shared) + @cd $(objdir); \ + $(MAKE) $(MFLAGS) "OBJ = $(OBJLIB)" "INC = $(INC)" \ + "LMPLIB = $(SHLIB)" "ARLIB = $(ARLIB)" "SHLIB = $(SHLIB)" \ + "LMPLINK = $(LMPLINK)" "EXE = ../$(EXE)" ../$(EXE) + @ln -s $(SHLIB) $(SHLINK) +endif +# backward compatibility +ifeq ($(mode),exe) + $(MAKE) $(MFLAGS) mode=static $@ +endif +ifeq ($(mode),lib) + $(MAKE) $(MFLAGS) mode=static $@ +endif +ifeq ($(mode),shexe) + $(MAKE) $(MFLAGS) mode=shared $@ +endif +ifeq ($(mode),shlib) + $(MAKE) $(MFLAGS) mode=shared $@ +endif + +ifeq ($(mode),print) + @cd $(objdir); \ + $(MAKE) $(MFLAGS) "OBJ = $(OBJLIB)" "INC = $(INC)" \ + "EXE = ../$(ARLIB)" -f ../Makefile.print +endif + +# Remove machine-specific object files + +clean: + @echo 'make clean-all delete all object files' + @echo 'make clean-machine delete object files for one machine' + +clean-all: + rm -rf Obj_* + +clean-%: + @if [ $@ = "clean-serial" ]; \ + then cd STUBS; $(MAKE) clean; cd ..; fi + rm -rf Obj_$(@:clean-%=%) Obj_shared_$(@:clean-%=%) + +# Make MPI STUBS library + +mpi-stubs: + @cd STUBS; $(MAKE) clean; $(MAKE) + +# install LAMMPS shared lib and Python wrapper for Python usage +# include python package settings to automatically adapt name of +# the python interpreter. must purge build folder to not install +# unwanted outdated files. + +sinclude ../lib/python/Makefile.lammps +install-python: + @rm -rf ../python/build + @$(PYTHON) ../python/install.py -v ../src/version.h \ + -p ../python/lammps -l ../src/liblammps.so + +# Create a tarball of src dir and packages + +tar: + @cd STUBS; $(MAKE) clean + @cd ..; tar cvzf src/$(ROOT)_src.tar.gz \ + src/Make* src/Package.sh src/Depend.sh src/Install.sh src/Fetch.sh \ + src/MAKE src/DEPEND src/*.cpp src/*.h src/STUBS \ + $(patsubst %,src/%,$(PACKAGEUC)) $(patsubst %,src/%,$(PACKUSERUC)) \ + --exclude=*/.svn + @cd STUBS; $(MAKE) + @echo "Created $(ROOT)_src.tar.gz" + +# Package management + +package: + @echo 'Standard packages:' $(PACKAGE) + @echo '' + @echo 'User-contributed packages:' $(PACKUSER) + @echo '' + @echo 'Packages that need system libraries:' $(PACKSYS) + @echo '' + @echo 'Packages that need provided libraries:' $(PACKINT) + @echo '' + @echo 'Packages that need external libraries:' $(PACKEXT) + @echo '' + @echo 'make package list available packages' + @echo 'make package list available packages' + @echo 'make package-status (ps) status of all packages' + @echo 'make package-installed (pi) list of installed packages' + @echo 'make yes-package install a single pgk in src dir' + @echo 'make no-package remove a single pkg from src dir' + @echo 'make yes-all install all pgks in src dir' + @echo 'make no-all remove all pkgs from src dir' + @echo 'make yes-standard (yes-std) install all standard pkgs' + @echo 'make no-standard (no-std) remove all standard pkgs' + @echo 'make yes-user install all user pkgs' + @echo 'make no-user remove all user pkgs' + @echo 'make yes-lib install all pkgs with libs (included or ext)' + @echo 'make no-lib remove all pkgs with libs (included or ext)' + @echo 'make yes-ext install all pkgs with external libs' + @echo 'make no-ext remove all pkgs with external libs' + @echo '' + @echo 'make package-update (pu) replace src files with package files' + @echo 'make package-overwrite replace package files with src files' + @echo 'make package-diff (pd) diff src files against package file' + @echo '' + @echo 'make lib-package build and/or download a package library' + +yes-all: + @for p in $(PACKALL); do $(MAKE) yes-$$p; done + +no-all: + @for p in $(PACKALL); do $(MAKE) no-$$p; done + +yes-standard yes-std: + @for p in $(PACKAGE); do $(MAKE) yes-$$p; done + +no-standard no-std: + @for p in $(PACKAGE); do $(MAKE) no-$$p; done + +yes-user: + @for p in $(PACKUSER); do $(MAKE) yes-$$p; done + +no-user: + @for p in $(PACKUSER); do $(MAKE) no-$$p; done + +yes-lib: + @for p in $(PACKLIB); do $(MAKE) yes-$$p; done + +no-lib: + @for p in $(PACKLIB); do $(MAKE) no-$$p; done + +yes-ext: + @for p in $(PACKEXT); do $(MAKE) yes-$$p; done + +no-ext: + @for p in $(PACKEXT); do $(MAKE) no-$$p; done + +yes-%: + @if [ ! -e Makefile.package ]; \ + then cp Makefile.package.empty Makefile.package; fi + @if [ ! -e Makefile.package.settings ]; \ + then cp Makefile.package.settings.empty Makefile.package.settings; fi + @if [ ! -e $(YESDIR) ]; then \ + echo "Package $(YESDIR) does not exist"; exit 1; \ + elif [ -e $(YESDIR)/Install.sh ]; then \ + echo "Installing package $(@:yes-%=%)"; \ + cd $(YESDIR); $(SHELL) Install.sh 1; cd ..; \ + $(SHELL) Depend.sh $(YESDIR) 1; \ + else \ + echo "Installing package $(@:yes-%=%)"; \ + cd $(YESDIR); $(SHELL) ../Install.sh 1; cd ..; \ + $(SHELL) Depend.sh $(YESDIR) 1; \ + fi; + @$(SHELL) Fetch.sh $(YESDIR) + +no-%: + @if [ ! -e $(NODIR) ]; then \ + echo "Package $(NODIR) does not exist"; exit 1; \ + elif [ -e $(NODIR)/Install.sh ]; then \ + echo "Uninstalling package $(@:no-%=%)"; \ + cd $(NODIR); $(SHELL) Install.sh 0; cd ..; \ + $(SHELL) Depend.sh $(NODIR) 0; \ + else \ + echo "Uninstalling package $(@:no-%=%)"; \ + cd $(NODIR); $(SHELL) ../Install.sh 0; cd ..; \ + $(SHELL) Depend.sh $(NODIR) 0; \ + fi; + +# download/build/install a package library +# update the timestamp on main.cpp to trigger a relink with "make machine" + +lib-%: + @if [ -e ../lib/$(LIBDIR)/Install.py ]; then \ + echo "Installing lib $(@:lib-%=%)"; \ + ( cd ../lib/$(LIBDIR); $(PYTHON) Install.py $(args) ); \ + elif [ -e ../lib/$(LIBUSERDIR)/Install.py ]; then \ + echo "Installing lib $(@:lib-user-%=%)"; \ + ( cd ../lib/$(LIBUSERDIR); $(PYTHON) Install.py $(args) ); \ + else \ + echo "Install script for lib $(@:lib-%=%) does not exist"; \ + fi; touch main.cpp + +# status = list src files that differ from package files +# installed = list of installed packages +# update = replace src files with newer package files +# overwrite = overwrite package files with newer src files +# diff = show differences between src and package files +# purge = delete obsolete and auto-generated package files + +package-status ps: + @for p in $(PACKAGEUC); do $(SHELL) Package.sh $$p status; done + @echo '' + @for p in $(PACKUSERUC); do $(SHELL) Package.sh $$p status; done + +package-installed pi: + @for p in $(PACKAGEUC); do $(SHELL) Package.sh $$p installed; done + @for p in $(PACKUSERUC); do $(SHELL) Package.sh $$p installed; done + +package-update pu: purge + @for p in $(PACKAGEUC); do $(SHELL) Package.sh $$p update; done + @echo '' + @for p in $(PACKUSERUC); do $(SHELL) Package.sh $$p update; done + +package-overwrite: purge + @for p in $(PACKAGEUC); do $(SHELL) Package.sh $$p overwrite; done + @echo '' + @for p in $(PACKUSERUC); do $(SHELL) Package.sh $$p overwrite; done + +package-diff pd: + @for p in $(PACKAGEUC); do $(SHELL) Package.sh $$p diff; done + @echo '' + @for p in $(PACKUSERUC); do $(SHELL) Package.sh $$p diff; done + +purge: Purge.list + @echo 'Purging obsolete and auto-generated source files' + @for f in `grep -v '#' Purge.list` ; \ + do test -f $$f && rm $$f && echo $$f || : ; \ + done From dca509a5d8937cbbdff3f79ecc9516cbbd27b9d6 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 24 May 2021 14:43:13 -0400 Subject: [PATCH 14/25] update the all on/off CMake presets --- cmake/presets/all_off.cmake | 6 +++--- cmake/presets/all_on.cmake | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmake/presets/all_off.cmake b/cmake/presets/all_off.cmake index 7c0d1baeb7..186aa5c5c7 100644 --- a/cmake/presets/all_off.cmake +++ b/cmake/presets/all_off.cmake @@ -9,9 +9,9 @@ set(ALL_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS CORESHELL DIPOLE GPU USER-COLVARS USER-DIFFRACTION USER-DPD USER-DRUDE USER-EFF USER-FEP USER-H5MD USER-INTEL USER-LB USER-MANIFOLD USER-MDI USER-MEAMC USER-MESODPD USER-MESONT USER-MGPT USER-MISC USER-MOFFF USER-MOLFILE USER-NETCDF USER-OMP USER-PACE - USER-PHONON USER-PLUMED USER-PTM USER-QMMM USER-QTB USER-QUIP USER-REACTION - USER-REAXC USER-SCAFACOS USER-SDPD USER-SMD USER-SMTBQ USER-SPH USER-TALLY - USER-UEF USER-VTK USER-YAFF) + USER-PHONON USER-PLUMED USER-PTM USER-QMMM USER-QTB USER-QUIP USER-RANN + USER-REACTION USER-REAXC USER-SCAFACOS USER-SDPD USER-SMD USER-SMTBQ USER-SPH + USER-TALLY USER-UEF USER-VTK USER-YAFF) foreach(PKG ${ALL_PACKAGES}) set(PKG_${PKG} OFF CACHE BOOL "" FORCE) diff --git a/cmake/presets/all_on.cmake b/cmake/presets/all_on.cmake index 5647c61833..d8235d3c78 100644 --- a/cmake/presets/all_on.cmake +++ b/cmake/presets/all_on.cmake @@ -11,9 +11,9 @@ set(ALL_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS CORESHELL DIPOLE GPU USER-COLVARS USER-DIFFRACTION USER-DPD USER-DRUDE USER-EFF USER-FEP USER-H5MD USER-INTEL USER-LB USER-MANIFOLD USER-MDI USER-MEAMC USER-MESODPD USER-MESONT USER-MGPT USER-MISC USER-MOFFF USER-MOLFILE USER-NETCDF USER-OMP USER-PACE - USER-PHONON USER-PLUMED USER-PTM USER-QMMM USER-QTB USER-QUIP USER-REACTION - USER-REAXC USER-SCAFACOS USER-SDPD USER-SMD USER-SMTBQ USER-SPH USER-TALLY - USER-UEF USER-VTK USER-YAFF) + USER-PHONON USER-PLUMED USER-PTM USER-QMMM USER-QTB USER-QUIP USER-RANN + USER-REACTION USER-REAXC USER-SCAFACOS USER-SDPD USER-SMD USER-SMTBQ USER-SPH + USER-TALLY USER-UEF USER-VTK USER-YAFF) foreach(PKG ${ALL_PACKAGES}) set(PKG_${PKG} ON CACHE BOOL "" FORCE) From 7cc00e3fed8bd28d735124cebe0af4059e5b02d4 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 24 May 2021 16:21:48 -0400 Subject: [PATCH 15/25] fix spelling --- doc/src/pair_rann.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/src/pair_rann.rst b/doc/src/pair_rann.rst index af9b90de14..ed2c9bab3d 100644 --- a/doc/src/pair_rann.rst +++ b/doc/src/pair_rann.rst @@ -168,9 +168,9 @@ length of the fingerprint vector is m*k. 3 *screening* specifies the Cmax and Cmin values used in the screening fingerprints. Neighbors' contribution to the -fingerprint are ommitted if they are blocked by a closer neighbor, and reduced if they are partially blocked. +fingerprint are omitted if they are blocked by a closer neighbor, and reduced if they are partially blocked. Larger values of Cmin correspond to neighbors being blocked more easily. Cmax cannot be greater than 3, and -Cmin cannot be greater than Cmax or less than zero. Screening may be ommitted in which case the default values +Cmin cannot be greater than Cmax or less than zero. Screening may be omitted in which case the default values Cmax = 2.8, Cmin = 0.8 are used. Since screening is a bond computation, it is specified separately for each combination of three elements in which the latter two may be interchanged with no effect. From 1af45388588b711487be3566f018e52293d2706a Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 26 May 2021 15:19:00 -0400 Subject: [PATCH 16/25] update homepage URLs --- src/USER-RANN/pair_rann.cpp | 2 +- src/USER-RANN/pair_rann.h | 2 +- src/USER-RANN/rann_activation.h | 2 +- src/USER-RANN/rann_activation_linear.h | 2 +- src/USER-RANN/rann_activation_sig_i.h | 2 +- src/USER-RANN/rann_fingerprint.cpp | 2 +- src/USER-RANN/rann_fingerprint.h | 2 +- src/USER-RANN/rann_fingerprint_bond.cpp | 2 +- src/USER-RANN/rann_fingerprint_bond.h | 2 +- src/USER-RANN/rann_fingerprint_bondscreened.cpp | 2 +- src/USER-RANN/rann_fingerprint_bondscreened.h | 2 +- src/USER-RANN/rann_fingerprint_bondscreenedspin.cpp | 2 +- src/USER-RANN/rann_fingerprint_bondscreenedspin.h | 2 +- src/USER-RANN/rann_fingerprint_bondspin.cpp | 2 +- src/USER-RANN/rann_fingerprint_bondspin.h | 2 +- src/USER-RANN/rann_fingerprint_radial.cpp | 2 +- src/USER-RANN/rann_fingerprint_radial.h | 2 +- src/USER-RANN/rann_fingerprint_radialscreened.cpp | 2 +- src/USER-RANN/rann_fingerprint_radialscreened.h | 2 +- src/USER-RANN/rann_fingerprint_radialscreenedspin.cpp | 2 +- src/USER-RANN/rann_fingerprint_radialscreenedspin.h | 2 +- src/USER-RANN/rann_fingerprint_radialspin.cpp | 2 +- src/USER-RANN/rann_fingerprint_radialspin.h | 2 +- 23 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/USER-RANN/pair_rann.cpp b/src/USER-RANN/pair_rann.cpp index d2b9535b56..bc6df76e4a 100644 --- a/src/USER-RANN/pair_rann.cpp +++ b/src/USER-RANN/pair_rann.cpp @@ -1,6 +1,6 @@ /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories + https://www.lammps.org/ Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract diff --git a/src/USER-RANN/pair_rann.h b/src/USER-RANN/pair_rann.h index 23bea7a800..80475f366e 100644 --- a/src/USER-RANN/pair_rann.h +++ b/src/USER-RANN/pair_rann.h @@ -1,6 +1,6 @@ /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories + https://www.lammps.org/ Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract diff --git a/src/USER-RANN/rann_activation.h b/src/USER-RANN/rann_activation.h index d8d2940228..b924dff63c 100644 --- a/src/USER-RANN/rann_activation.h +++ b/src/USER-RANN/rann_activation.h @@ -1,6 +1,6 @@ /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories + https://www.lammps.org/ Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract diff --git a/src/USER-RANN/rann_activation_linear.h b/src/USER-RANN/rann_activation_linear.h index 812c570d3a..f610907943 100644 --- a/src/USER-RANN/rann_activation_linear.h +++ b/src/USER-RANN/rann_activation_linear.h @@ -1,7 +1,7 @@ /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories + https://www.lammps.org/ Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract diff --git a/src/USER-RANN/rann_activation_sig_i.h b/src/USER-RANN/rann_activation_sig_i.h index 9ca9c55d3d..283ff3ee02 100644 --- a/src/USER-RANN/rann_activation_sig_i.h +++ b/src/USER-RANN/rann_activation_sig_i.h @@ -1,6 +1,6 @@ /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories + https://www.lammps.org/ Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract diff --git a/src/USER-RANN/rann_fingerprint.cpp b/src/USER-RANN/rann_fingerprint.cpp index f0bf62ed62..c417a0c497 100644 --- a/src/USER-RANN/rann_fingerprint.cpp +++ b/src/USER-RANN/rann_fingerprint.cpp @@ -1,6 +1,6 @@ /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories + https://www.lammps.org/ Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract diff --git a/src/USER-RANN/rann_fingerprint.h b/src/USER-RANN/rann_fingerprint.h index 8b777ce398..ef362cc1c4 100644 --- a/src/USER-RANN/rann_fingerprint.h +++ b/src/USER-RANN/rann_fingerprint.h @@ -1,6 +1,6 @@ /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories + https://www.lammps.org/ Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract diff --git a/src/USER-RANN/rann_fingerprint_bond.cpp b/src/USER-RANN/rann_fingerprint_bond.cpp index 672cea718d..c50c5e0cfc 100644 --- a/src/USER-RANN/rann_fingerprint_bond.cpp +++ b/src/USER-RANN/rann_fingerprint_bond.cpp @@ -1,6 +1,6 @@ /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories + https://www.lammps.org/ Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract diff --git a/src/USER-RANN/rann_fingerprint_bond.h b/src/USER-RANN/rann_fingerprint_bond.h index 16e72b5222..183887404f 100644 --- a/src/USER-RANN/rann_fingerprint_bond.h +++ b/src/USER-RANN/rann_fingerprint_bond.h @@ -1,6 +1,6 @@ /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories + https://www.lammps.org/ Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract diff --git a/src/USER-RANN/rann_fingerprint_bondscreened.cpp b/src/USER-RANN/rann_fingerprint_bondscreened.cpp index 5a9a9b7a4c..97ae87547d 100644 --- a/src/USER-RANN/rann_fingerprint_bondscreened.cpp +++ b/src/USER-RANN/rann_fingerprint_bondscreened.cpp @@ -1,6 +1,6 @@ /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories + https://www.lammps.org/ Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract diff --git a/src/USER-RANN/rann_fingerprint_bondscreened.h b/src/USER-RANN/rann_fingerprint_bondscreened.h index e829844d65..44bb28c265 100644 --- a/src/USER-RANN/rann_fingerprint_bondscreened.h +++ b/src/USER-RANN/rann_fingerprint_bondscreened.h @@ -1,7 +1,7 @@ /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories + https://www.lammps.org/ Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract diff --git a/src/USER-RANN/rann_fingerprint_bondscreenedspin.cpp b/src/USER-RANN/rann_fingerprint_bondscreenedspin.cpp index f41dde883d..550fe323c4 100644 --- a/src/USER-RANN/rann_fingerprint_bondscreenedspin.cpp +++ b/src/USER-RANN/rann_fingerprint_bondscreenedspin.cpp @@ -1,6 +1,6 @@ /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories + https://www.lammps.org/ Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract diff --git a/src/USER-RANN/rann_fingerprint_bondscreenedspin.h b/src/USER-RANN/rann_fingerprint_bondscreenedspin.h index 6bf7b0bf52..e2f5f941f3 100644 --- a/src/USER-RANN/rann_fingerprint_bondscreenedspin.h +++ b/src/USER-RANN/rann_fingerprint_bondscreenedspin.h @@ -1,7 +1,7 @@ /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories + https://www.lammps.org/ Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract diff --git a/src/USER-RANN/rann_fingerprint_bondspin.cpp b/src/USER-RANN/rann_fingerprint_bondspin.cpp index 6aadbada86..e773bdf854 100644 --- a/src/USER-RANN/rann_fingerprint_bondspin.cpp +++ b/src/USER-RANN/rann_fingerprint_bondspin.cpp @@ -1,6 +1,6 @@ /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories + https://www.lammps.org/ Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract diff --git a/src/USER-RANN/rann_fingerprint_bondspin.h b/src/USER-RANN/rann_fingerprint_bondspin.h index 69a37594c3..9514779a5c 100644 --- a/src/USER-RANN/rann_fingerprint_bondspin.h +++ b/src/USER-RANN/rann_fingerprint_bondspin.h @@ -1,7 +1,7 @@ /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories + https://www.lammps.org/ Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract diff --git a/src/USER-RANN/rann_fingerprint_radial.cpp b/src/USER-RANN/rann_fingerprint_radial.cpp index 5df13aa094..d14b862db7 100644 --- a/src/USER-RANN/rann_fingerprint_radial.cpp +++ b/src/USER-RANN/rann_fingerprint_radial.cpp @@ -1,6 +1,6 @@ /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories + https://www.lammps.org/ Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract diff --git a/src/USER-RANN/rann_fingerprint_radial.h b/src/USER-RANN/rann_fingerprint_radial.h index 5f9876f493..e6e4e85294 100644 --- a/src/USER-RANN/rann_fingerprint_radial.h +++ b/src/USER-RANN/rann_fingerprint_radial.h @@ -1,7 +1,7 @@ /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories + https://www.lammps.org/ Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract diff --git a/src/USER-RANN/rann_fingerprint_radialscreened.cpp b/src/USER-RANN/rann_fingerprint_radialscreened.cpp index 79333a4e3a..0c14152c0b 100644 --- a/src/USER-RANN/rann_fingerprint_radialscreened.cpp +++ b/src/USER-RANN/rann_fingerprint_radialscreened.cpp @@ -1,6 +1,6 @@ /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories + https://www.lammps.org/ Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract diff --git a/src/USER-RANN/rann_fingerprint_radialscreened.h b/src/USER-RANN/rann_fingerprint_radialscreened.h index db564e4553..d385f9b29c 100644 --- a/src/USER-RANN/rann_fingerprint_radialscreened.h +++ b/src/USER-RANN/rann_fingerprint_radialscreened.h @@ -1,7 +1,7 @@ /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories + https://www.lammps.org/ Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract diff --git a/src/USER-RANN/rann_fingerprint_radialscreenedspin.cpp b/src/USER-RANN/rann_fingerprint_radialscreenedspin.cpp index f594e92077..7b50714978 100644 --- a/src/USER-RANN/rann_fingerprint_radialscreenedspin.cpp +++ b/src/USER-RANN/rann_fingerprint_radialscreenedspin.cpp @@ -1,6 +1,6 @@ /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories + https://www.lammps.org/ Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract diff --git a/src/USER-RANN/rann_fingerprint_radialscreenedspin.h b/src/USER-RANN/rann_fingerprint_radialscreenedspin.h index ff76dcd3c9..3e58d3aef5 100644 --- a/src/USER-RANN/rann_fingerprint_radialscreenedspin.h +++ b/src/USER-RANN/rann_fingerprint_radialscreenedspin.h @@ -1,7 +1,7 @@ /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories + https://www.lammps.org/ Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract diff --git a/src/USER-RANN/rann_fingerprint_radialspin.cpp b/src/USER-RANN/rann_fingerprint_radialspin.cpp index 9d61fc08ed..1b63df0739 100644 --- a/src/USER-RANN/rann_fingerprint_radialspin.cpp +++ b/src/USER-RANN/rann_fingerprint_radialspin.cpp @@ -1,6 +1,6 @@ /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories + https://www.lammps.org/ Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract diff --git a/src/USER-RANN/rann_fingerprint_radialspin.h b/src/USER-RANN/rann_fingerprint_radialspin.h index 6abddd910d..72c3b5b286 100644 --- a/src/USER-RANN/rann_fingerprint_radialspin.h +++ b/src/USER-RANN/rann_fingerprint_radialspin.h @@ -1,6 +1,6 @@ /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories + https://www.lammps.org/ Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract From 9d9a7e853ec3f5e9c1ef71be0146480907e4a3d4 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 26 May 2021 15:26:08 -0400 Subject: [PATCH 17/25] make header ready for use with clang-format and apply conventions --- src/USER-HDNNP/pair_hdnnp.h | 6 +++--- src/USER-RANN/pair_rann.h | 15 +++++++-------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/USER-HDNNP/pair_hdnnp.h b/src/USER-HDNNP/pair_hdnnp.h index 9ad2969b8c..c7cbc8188a 100644 --- a/src/USER-HDNNP/pair_hdnnp.h +++ b/src/USER-HDNNP/pair_hdnnp.h @@ -19,9 +19,9 @@ ------------------------------------------------------------------------- */ #ifdef PAIR_CLASS - -PairStyle(hdnnp,PairHDNNP) - +// clang-format off +PairStyle(hdnnp,PairHDNNP); +// clang-format on #else #ifndef LMP_PAIR_HDNNP_H diff --git a/src/USER-RANN/pair_rann.h b/src/USER-RANN/pair_rann.h index 80475f366e..97461d2437 100644 --- a/src/USER-RANN/pair_rann.h +++ b/src/USER-RANN/pair_rann.h @@ -29,19 +29,18 @@ DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 */ #ifdef PAIR_CLASS - -PairStyle(rann,PairRANN) - +// clang-format off +PairStyle(rann,PairRANN); +// clang-format on #else #ifndef LMP_PAIR_RANN #define LMP_PAIR_RANN - -#include "neighbor.h" -#include "neigh_list.h" #include "pair.h" +#include +#include namespace LAMMPS_NS { @@ -65,8 +64,8 @@ namespace LAMMPS_NS { void errorf(const char*,int,const char*); int factorial(int); - RANN::Fingerprint * create_fingerprint(const char *); - RANN::Activation * create_activation(const char *); + RANN::Fingerprint *create_fingerprint(const char *); + RANN::Activation *create_activation(const char *); //global variables int nelements; // # of elements (distinct from LAMMPS atom types since multiple atom types can be mapped to one element) From 4794b4cd38a68d5d693659e1c4ddeaa2a4ae0eb5 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 26 May 2021 15:26:25 -0400 Subject: [PATCH 18/25] update include files according to LAMMPS' conventions --- src/USER-RANN/pair_rann.cpp | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/USER-RANN/pair_rann.cpp b/src/USER-RANN/pair_rann.cpp index bc6df76e4a..949c4baa4f 100644 --- a/src/USER-RANN/pair_rann.cpp +++ b/src/USER-RANN/pair_rann.cpp @@ -27,22 +27,26 @@ do not necessarily reflect the views of the United States Army.​” DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 */ -#define MAXLINE 1024 + #include "pair_rann.h" -#include "tokenizer.h" -#include -#include -#include -#include + #include "atom.h" -#include "force.h" #include "comm.h" -#include "memory.h" -#include "neigh_request.h" -#include "memory.h" #include "error.h" -#include "update.h" +#include "force.h" #include "math_special.h" +#include "memory.h" +#include "neighbor.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "tokenizer.h" +#include "update.h" + +#include +#include + +#include "rann_activation_linear.h" +#include "rann_activation_sig_i.h" #include "rann_fingerprint_bond.h" #include "rann_fingerprint_bondscreened.h" #include "rann_fingerprint_bondscreenedspin.h" @@ -51,9 +55,8 @@ DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 #include "rann_fingerprint_radialscreened.h" #include "rann_fingerprint_radialscreenedspin.h" #include "rann_fingerprint_radialspin.h" -#include "rann_activation_linear.h" -#include "rann_activation_sig_i.h" +#define MAXLINE 1024 using namespace LAMMPS_NS; From 769183c94f1f39dbe2c18042b43bb1da154d7abd Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 26 May 2021 15:40:15 -0400 Subject: [PATCH 19/25] simplify and reformat --- src/USER-RANN/rann_fingerprint.cpp | 78 +++++++------------------- src/USER-RANN/rann_fingerprint.h | 88 +++++++++++++++++++----------- 2 files changed, 76 insertions(+), 90 deletions(-) diff --git a/src/USER-RANN/rann_fingerprint.cpp b/src/USER-RANN/rann_fingerprint.cpp index c417a0c497..b90e04f9a5 100644 --- a/src/USER-RANN/rann_fingerprint.cpp +++ b/src/USER-RANN/rann_fingerprint.cpp @@ -1,4 +1,4 @@ -/* -*- c++ -*- ---------------------------------------------------------- +/* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/ Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov @@ -43,74 +43,36 @@ Fingerprint::Fingerprint(PairRANN *_pair) pair = _pair; } -Fingerprint::~Fingerprint() { +// Smooth cutoff, goes from 1 to zero over the interval rc-dr to rc. +// Same as MEAM uses. Used by generateradialtable and generatexpcuttable. -} - -bool Fingerprint::parse_values(std::string line,std::vector line1) { - return false; -} - -void Fingerprint::init(int *i,int id) { - -} - -void Fingerprint::allocate() { - -} - -void Fingerprint::compute_fingerprint(double *features,double *dfeaturesx,double *dfeaturesy,double * dfeaturesz, int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl) { - -} - -void Fingerprint::compute_fingerprint(double *features,double *dfeaturesx,double *dfeaturesy,double * dfeaturesz,double *Sik, double *dSikx, double*dSiky, double *dSikz, double *dSijkx, double *dSijky, double *dSijkz, bool *Bij, int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl) { - -} - -void Fingerprint::compute_fingerprint(double *features,double *dfeaturesx,double *dfeaturesy,double * dfeaturesz,double *sx, double *sy, double *sz, int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl) { - -} - -void Fingerprint::compute_fingerprint(double *features,double *dfeaturesx,double *dfeaturesy,double * dfeaturesz,double *sx, double *sy, double *sz, double *Sik, double *dSikx, double*dSiky, double *dSikz, double *dSijkx, double *dSijky, double *dSijkz, bool *Bij, int ii,int sid,double *xn,double *yn,double*zn,int *tn,int jnum,int *jl) { - -} - -void Fingerprint::write_values(FILE *fid) { - -} - -int Fingerprint::get_length() { - return 0; -} - -//Smooth cutoff, goes from 1 to zero over the interval rc-dr to rc. Same as MEAM uses. Used by generateradialtable and generatexpcuttable. -double Fingerprint::cutofffunction(double r,double rc, double dr) { +double Fingerprint::cutofffunction(double r, double rc, double dr) +{ double out; - if (r < (rc -dr))out=1; - else if (r>rc)out=0; + if (r < (rc - dr)) + out = 1; + else if (r > rc) + out = 0; else { - out = 1-(rc-r)/dr; - out *= out; - out *= out; - out = 1-out; - out *= out; + out = 1 - (rc - r) / dr; + out *= out; + out *= out; + out = 1 - out; + out *= out; } return out; } -void Fingerprint::generate_rinvssqrttable() { +void Fingerprint::generate_rinvssqrttable() +{ int buf = 5; int m; double r1; double cutmax = pair->cutmax; int res = pair->res; - rinvsqrttable = new double[res+buf]; - for (m=0;m<(res+buf);m++) { - r1 = cutmax*cutmax*(double)(m)/(double)(res); - rinvsqrttable[m] = 1/sqrt(r1); + rinvsqrttable = new double[res + buf]; + for (m = 0; m < (res + buf); m++) { + r1 = cutmax * cutmax * (double) (m) / (double) (res); + rinvsqrttable[m] = 1 / sqrt(r1); } } - - - - diff --git a/src/USER-RANN/rann_fingerprint.h b/src/USER-RANN/rann_fingerprint.h index ef362cc1c4..e4ca22ffe1 100644 --- a/src/USER-RANN/rann_fingerprint.h +++ b/src/USER-RANN/rann_fingerprint.h @@ -35,38 +35,62 @@ DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 #include "pair_rann.h" namespace LAMMPS_NS { - namespace RANN { - class Fingerprint { - public: - Fingerprint(PairRANN *); - virtual ~Fingerprint(); - virtual bool parse_values(std::string,std::vector); - virtual void write_values(FILE *); - virtual void init(int*,int); - virtual void allocate(); - void init_screen(int); - virtual void compute_fingerprint(double*,double*,double*,double*,int,int,double*,double*,double*,int*,int,int*);//no screen,no spin - virtual void compute_fingerprint(double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,bool*,int,int,double*,double*,double*,int*,int,int*);//screen - virtual void compute_fingerprint(double*,double*,double*,double*,double*,double*,double*,int,int,double*,double*,double*,int*,int,int*);//spin - virtual void compute_fingerprint(double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,double*,bool*,int,int,double*,double*,double*,int*,int,int*);//spin,screen - virtual int get_length(); - virtual double cutofffunction(double,double, double); - virtual void generate_rinvssqrttable(); - bool spin; - bool screen; - int n_body_type;//i-j vs. i-j-k vs. i-j-k-l, etc. - bool empty; - bool fullydefined; - int startingneuron; - int id;//based on ordering of fingerprints listed for i-j in potential file - const char *style; - int* atomtypes; - double *rinvsqrttable; - double rc; - PairRANN *pair; - }; - } -} +namespace RANN { + class Fingerprint { + public: + Fingerprint(PairRANN *); + virtual ~Fingerprint() {} + virtual bool parse_values(std::string, std::vector) { return false; } + virtual void write_values(FILE *) {} + + virtual void init(int *, int) {} + virtual void allocate() {} + + void init_screen(int); + + //no screen,no spin + virtual void compute_fingerprint(double *, double *, double *, double *, int, int, double *, + double *, double *, int *, int, int *) + { + } + //screen + virtual void compute_fingerprint(double *, double *, double *, double *, double *, double *, + double *, double *, double *, double *, double *, bool *, int, + int, double *, double *, double *, int *, int, int *) + { + } + //spin + virtual void compute_fingerprint(double *, double *, double *, double *, double *, double *, + double *, int, int, double *, double *, double *, int *, int, + int *) + { + } + //spin,screen + virtual void compute_fingerprint(double *, double *, double *, double *, double *, double *, + double *, double *, double *, double *, double *, double *, + double *, double *, bool *, int, int, double *, double *, + double *, int *, int, int *) + { + } + + virtual int get_length(){return 0}; + virtual double cutofffunction(double, double, double); + virtual void generate_rinvssqrttable(); + bool spin; + bool screen; + int n_body_type; //i-j vs. i-j-k vs. i-j-k-l, etc. + bool empty; + bool fullydefined; + int startingneuron; + int id; //based on ordering of fingerprints listed for i-j in potential file + const char *style; + int *atomtypes; + double *rinvsqrttable; + double rc; + PairRANN *pair; + }; +} // namespace RANN +} // namespace LAMMPS_NS #endif /* RANN_FINGERPRINT_H_ */ From 368765f10ff4e36d21623bef36166859084dcdd0 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 26 May 2021 15:41:44 -0400 Subject: [PATCH 20/25] disable automatic clang-format processing for .cpp files --- src/USER-RANN/pair_rann.cpp | 1 + src/USER-RANN/rann_fingerprint_bond.cpp | 1 + src/USER-RANN/rann_fingerprint_bondscreened.cpp | 1 + src/USER-RANN/rann_fingerprint_bondscreenedspin.cpp | 1 + src/USER-RANN/rann_fingerprint_bondspin.cpp | 1 + src/USER-RANN/rann_fingerprint_radial.cpp | 1 + src/USER-RANN/rann_fingerprint_radialscreened.cpp | 1 + src/USER-RANN/rann_fingerprint_radialscreenedspin.cpp | 1 + src/USER-RANN/rann_fingerprint_radialspin.cpp | 1 + 9 files changed, 9 insertions(+) diff --git a/src/USER-RANN/pair_rann.cpp b/src/USER-RANN/pair_rann.cpp index 949c4baa4f..f2e3af1ae5 100644 --- a/src/USER-RANN/pair_rann.cpp +++ b/src/USER-RANN/pair_rann.cpp @@ -1,3 +1,4 @@ +// clang-format off /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/ Sandia National Laboratories diff --git a/src/USER-RANN/rann_fingerprint_bond.cpp b/src/USER-RANN/rann_fingerprint_bond.cpp index c50c5e0cfc..94522eba1c 100644 --- a/src/USER-RANN/rann_fingerprint_bond.cpp +++ b/src/USER-RANN/rann_fingerprint_bond.cpp @@ -1,3 +1,4 @@ +// clang-format off /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/ Sandia National Laboratories diff --git a/src/USER-RANN/rann_fingerprint_bondscreened.cpp b/src/USER-RANN/rann_fingerprint_bondscreened.cpp index 97ae87547d..c81fcd428a 100644 --- a/src/USER-RANN/rann_fingerprint_bondscreened.cpp +++ b/src/USER-RANN/rann_fingerprint_bondscreened.cpp @@ -1,3 +1,4 @@ +// clang-format off /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/ Sandia National Laboratories diff --git a/src/USER-RANN/rann_fingerprint_bondscreenedspin.cpp b/src/USER-RANN/rann_fingerprint_bondscreenedspin.cpp index 550fe323c4..fc051d08ee 100644 --- a/src/USER-RANN/rann_fingerprint_bondscreenedspin.cpp +++ b/src/USER-RANN/rann_fingerprint_bondscreenedspin.cpp @@ -1,3 +1,4 @@ +// clang-format off /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/ Sandia National Laboratories diff --git a/src/USER-RANN/rann_fingerprint_bondspin.cpp b/src/USER-RANN/rann_fingerprint_bondspin.cpp index e773bdf854..22b88f5026 100644 --- a/src/USER-RANN/rann_fingerprint_bondspin.cpp +++ b/src/USER-RANN/rann_fingerprint_bondspin.cpp @@ -1,3 +1,4 @@ +// clang-format off /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/ Sandia National Laboratories diff --git a/src/USER-RANN/rann_fingerprint_radial.cpp b/src/USER-RANN/rann_fingerprint_radial.cpp index d14b862db7..26c60df2b8 100644 --- a/src/USER-RANN/rann_fingerprint_radial.cpp +++ b/src/USER-RANN/rann_fingerprint_radial.cpp @@ -1,3 +1,4 @@ +// clang-format off /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/ Sandia National Laboratories diff --git a/src/USER-RANN/rann_fingerprint_radialscreened.cpp b/src/USER-RANN/rann_fingerprint_radialscreened.cpp index 0c14152c0b..ba9cee8de7 100644 --- a/src/USER-RANN/rann_fingerprint_radialscreened.cpp +++ b/src/USER-RANN/rann_fingerprint_radialscreened.cpp @@ -1,3 +1,4 @@ +// clang-format off /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/ Sandia National Laboratories diff --git a/src/USER-RANN/rann_fingerprint_radialscreenedspin.cpp b/src/USER-RANN/rann_fingerprint_radialscreenedspin.cpp index 7b50714978..01defe8a7e 100644 --- a/src/USER-RANN/rann_fingerprint_radialscreenedspin.cpp +++ b/src/USER-RANN/rann_fingerprint_radialscreenedspin.cpp @@ -1,3 +1,4 @@ +// clang-format off /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/ Sandia National Laboratories diff --git a/src/USER-RANN/rann_fingerprint_radialspin.cpp b/src/USER-RANN/rann_fingerprint_radialspin.cpp index 1b63df0739..1ce43a44b2 100644 --- a/src/USER-RANN/rann_fingerprint_radialspin.cpp +++ b/src/USER-RANN/rann_fingerprint_radialspin.cpp @@ -1,3 +1,4 @@ +// clang-format off /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/ Sandia National Laboratories From f703025c32900b1b094dc810a362155a7818b54f Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 26 May 2021 16:01:03 -0400 Subject: [PATCH 21/25] whitespace --- doc/src/pair_rann.rst | 86 ++++++++++++++++---------------- src/USER-RANN/rann_fingerprint.h | 2 +- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/doc/src/pair_rann.rst b/doc/src/pair_rann.rst index ed2c9bab3d..197bdfdd07 100644 --- a/doc/src/pair_rann.rst +++ b/doc/src/pair_rann.rst @@ -15,7 +15,7 @@ Examples """""""" .. code-block:: LAMMPS - + pair_style rann pair_coeff ** Mg.rann Mg pair_coeff ** MgAlalloy.rann Mg Mg Al Mg @@ -28,9 +28,9 @@ using rapid atomistic neural network (RANN) potentials (:ref:`Dickel ` , Neural network potentials work by first generating a series of symmetry functions i.e. structural fingerprints from the neighbor list and then using these values as the input layer of a neural network. There is a single output neuron in the -final layer which is the energy. Atomic forces are found by analytical +final layer which is the energy. Atomic forces are found by analytical derivatives computed via backpropagation. For alloy systems, each element has a unique -network. +network. Potential file syntax """"""""""""""""""""" @@ -64,20 +64,20 @@ The potential file is divided into several sections which are identified by one * calibrationparameters (ignored) # is treated as a comment marker, similar to LAMMPS input scripts. Sections are not required to follow a rigid -ordering, but do require previous definition of prerequisite information. E.g., fingerprintconstants for a -particular fingerprint must follow the fingerprints definition; layersize for a particular layer must follow +ordering, but do require previous definition of prerequisite information. E.g., fingerprintconstants for a +particular fingerprint must follow the fingerprints definition; layersize for a particular layer must follow the declaration of network layers. *atomtypes* are defined as follows using element keywords separated by spaces. -.. code-block:: +.. code-block:: atomtypes: Fe Mg Al etc. *mass* must be specified for each element keyword as follows: -.. code-block:: +.. code-block:: mass:Mg: 24.305 @@ -87,35 +87,35 @@ the declaration of network layers. 26.982 *fingerprintsperelement* specifies how many fingerprints are active for computing the energy of a given atom. -This number must be specified for each element keyword. Active elements for each fingerprint depend upon the +This number must be specified for each element keyword. Active elements for each fingerprint depend upon the type of the central atom and the neighboring atoms. Pairwise fingerprints may be defined for a Mg atom based exclusively on its Al neighbors, for example. Bond fingerprints may use two neighborlists of different -element types. In computing fingerprintsperelement from all defined fingerprints, only the fingerprints -defined for atoms of a particular element should be considered, regardless of the elements used in its +element types. In computing fingerprintsperelement from all defined fingerprints, only the fingerprints +defined for atoms of a particular element should be considered, regardless of the elements used in its neighbor list. In the following code, for example, some fingerprints may compute pairwise fingerprints summing -contributions about Fe atoms based on a neighbor list of exclusively Al atoms, but if there are no fingerprints +contributions about Fe atoms based on a neighbor list of exclusively Al atoms, but if there are no fingerprints summing contributions of all neighbors about a central Al atom, then fingerprintsperelement of Al is zero: -.. code-block:: - +.. code-block:: + fingerprintsperelement:Mg: 5 fingerprintsperelement:Fe: 2 fingerprintsperelement:Al: - 0 + 0 *fingerprints* specifies the active fingerprints for a certain element combination. Pair fingerprints are specified for two elements, while bond fingerprints are specified for three elements. Only one fingerprints -header should be used for an individual combination of elements. The ordering of the fingerprints in the -network input layer is determined by the order of element combinations specified by subsequent *fingerprints* +header should be used for an individual combination of elements. The ordering of the fingerprints in the +network input layer is determined by the order of element combinations specified by subsequent *fingerprints* lines, and the order of the fingerprints defined for each element combination. Multiple fingerprints of the same style or different ones may be specified. If the same style and element combination is used for multiple fingerprints, they should have different id numbers. The first element specifies the atoms for which this fingerprint is -computed while the other(s) specify which atoms to use in the neighbor lists for the computation. Switching +computed while the other(s) specify which atoms to use in the neighbor lists for the computation. Switching the second and third element type in bond fingerprints has no effect on the computation: -.. code-block:: +.. code-block:: fingerprints:Mg_Mg: radial_0 radialscreened_0 radial_1 @@ -144,11 +144,11 @@ The following fingerprint styles are currently defined. See the :ref:`formulatio *fingerprintconstants* specifies the metaparameters for a defined fingerprint. For all radial styles, re, rc, alpha, dr, o, and n must be specified. re should usually be the stable interatomic distance, rc is the cutoff -radius, dr is the cutoff smoothing distance, o is the lowest radial power term (which may be negative), and n +radius, dr is the cutoff smoothing distance, o is the lowest radial power term (which may be negative), and n is the highest power term. The total length of the fingerprint vector is (n-o+1). alpha is a list of decay parameters used for exponential decay of radial contributions. It may be set proportionally to the bulk modulus similarly to MEAM potentials, but other values may provided better fitting in special cases. Bond style fingerprints require -specification of re, rc, alphak, dr, k, and m. Here m is the power of the bond cosines and k is the number of +specification of re, rc, alphak, dr, k, and m. Here m is the power of the bond cosines and k is the number of decay parameters. Cosine powers go from 0 to m-1 and are each computed for all values of alphak. Thus the total length of the fingerprint vector is m*k. @@ -159,7 +159,7 @@ length of the fingerprint vector is m*k. fingerprintconstants:Mg_Mg:radialscreened_0:rc: 6.000000 fingerprintconstants:Mg_Mg:radialscreened_0:alpha: - 5.520000 5.520000 5.520000 5.520000 5.520000 + 5.520000 5.520000 5.520000 5.520000 5.520000 fingerprintconstants:Mg_Mg:radialscreened_0:dr: 2.806408 fingerprintconstants:Mg_Mg:radialscreened_0:o: @@ -169,7 +169,7 @@ length of the fingerprint vector is m*k. *screening* specifies the Cmax and Cmin values used in the screening fingerprints. Neighbors' contribution to the fingerprint are omitted if they are blocked by a closer neighbor, and reduced if they are partially blocked. -Larger values of Cmin correspond to neighbors being blocked more easily. Cmax cannot be greater than 3, and +Larger values of Cmin correspond to neighbors being blocked more easily. Cmax cannot be greater than 3, and Cmin cannot be greater than Cmax or less than zero. Screening may be omitted in which case the default values Cmax = 2.8, Cmin = 0.8 are used. Since screening is a bond computation, it is specified separately for each combination of three elements in which the latter two may be interchanged with no effect. @@ -189,8 +189,8 @@ and so is 2+hiddenlayers. networklayers:Mg: 3 -*layersize* specifies the length of each layer, including the input layer and output layer. The input layer is -layer 0. The size of the input layer size must match the summed length of all the fingerprints for that element, +*layersize* specifies the length of each layer, including the input layer and output layer. The input layer is +layer 0. The size of the input layer size must match the summed length of all the fingerprints for that element, and the output layer size must be 1: .. code-block:: @@ -226,7 +226,7 @@ The bias of layer i is a nx1 vector where n is the layer size of i+1: *activationfunctions* specifies the activation function for a given element and layer. Activation functions cannot be specified for the output layer: -.. code-block:: +.. code-block:: activationfunctions:Mg:0: sigI @@ -249,34 +249,34 @@ In the RANN formulation, the total energy of a system of atoms is given by: .. math:: - + E = \sum_{\alpha} E^{\alpha}\\\\ E^{\alpha} = {}^{N}\!A^{\alpha}\\\\ {}^{n+1}\!A_i^{\alpha} = {}^{n}\!F\left({}^{n}\!W_{ij}{\;}^{n}\!A_j^{\alpha}+{}^{n}\!B_i\right)\\\\ {}^{0}\!A_i^{\alpha} = \left[\begin{array}{c} {}^1\!S\!f^\alpha\\ {}^2\!S\!f^\alpha \\...\\\end{array}\right] - -Here :math:`E^\alpha` is the energy of atom :math:`\alpha`, :math:`{}^n\!F()`, :math:`{}^n\!W_{ij}` and :math:`{}^n\!B_i` are + +Here :math:`E^\alpha` is the energy of atom :math:`\alpha`, :math:`{}^n\!F()`, :math:`{}^n\!W_{ij}` and :math:`{}^n\!B_i` are the activation function, weight matrix and bias vector of the n-th layer respectively. The inputs to the first layer are a collection of structural fingerprints which are collected and reshaped into a single long vector. The individual fingerprints may be defined in any order and have various shapes and sizes. Multiple fingerprints of the same type and varying parameters may also be defined in the input layer. Eight types of structural fingerprints are currently defined. In the following, :math:`\beta` and :math:`\gamma` span the -full neighborlist of atom :math:`\alpha`. :math:`\delta_i` are decay metaparameters, and :math:`r_e` is a metaparameter +full neighborlist of atom :math:`\alpha`. :math:`\delta_i` are decay metaparameters, and :math:`r_e` is a metaparameter roughly proportional to the first neighbor distance. :math:`r_c` and :math:`dr` are the neighbor cutoff distance and -cutoff smoothing distance respectively. :math:`S^{\alpha\beta}` is the MEAM screening function +cutoff smoothing distance respectively. :math:`S^{\alpha\beta}` is the MEAM screening function :ref:`(Baskes) `, :math:`s_i^\alpha` and :math:`s_i^\beta` are the atom spin vectors :ref:`(Tranchida) `. -:math:`r^{\alpha\beta}` is the distance from atom :math:`\alpha` to atom :math:`\beta`, and :math:`\theta^{\alpha\beta\gamma}` +:math:`r^{\alpha\beta}` is the distance from atom :math:`\alpha` to atom :math:`\beta`, and :math:`\theta^{\alpha\beta\gamma}` is the bond angle: .. math :: - + cos\left(\theta^{\alpha\beta\gamma}\right)=\frac{\mathbf{r}^{\alpha\beta} \cdot \mathbf{r}^{\alpha\gamma}}{r^{\alpha\beta}r^{\alpha\gamma}} :math:`S^{\alpha\beta}` is defined as :ref:`(Baskes) `: .. math:: - + X^{\gamma\beta} = \left(\frac{r^{\gamma\beta}}{r^{\alpha\beta}}\right)^2\\ \\ X^{\alpha\gamma} = \left(\frac{r^{\alpha\gamma}}{r^{\alpha\beta}}\right)^2\\ @@ -288,7 +288,7 @@ is the bond angle: S^{\alpha\beta\gamma} = f_c\left(\frac{C-C_{min}}{C_{max}-C_{min}}\right)\\ \\ S^{\alpha\beta} = \prod_\gamma S^{\alpha\beta\gamma}\\ - + The structural fingerprints are computed as follows: @@ -297,31 +297,31 @@ The structural fingerprints are computed as follows: * **radial** .. math:: - + {}^r\!S\!f_i^\alpha = \sum_{\beta} \left(\frac{r^{\alpha\beta}}{r_e}\right)^ie^{-\delta_i \frac{r^{\alpha\beta}}{r_e}}f_c\left(\frac{r_c-r^{\alpha\beta}}{dr}\right) * **bond** .. math:: - + {}^b\!S\!f_{ij}^\alpha = \sum_{\beta}\sum_{\gamma} \left(cos(\theta_{\alpha\beta\gamma})\right)^ie^{-\delta_j \frac{r^{\alpha\beta}}{r_e}}e^{-\delta_j \frac{r^{\alpha\gamma}}{r_e}}f_c\left(\frac{r_c-r^{\alpha\beta}}{dr}\right)f_c\left(\frac{r_c-r^{\alpha\gamma}}{dr}\right) * **radialscreened** .. math:: - + {}^{rsc}\!S\!f_i^\alpha = \sum_{\beta} \left(\frac{r^{\alpha\beta}}{r_e}\right)^ie^{-\delta_i \frac{r^{\alpha\beta}}{r_e}}S^{\alpha\beta}f_c\left(\frac{r_c-r^{\alpha\beta}}{dr}\right) * **bondscreened** .. math:: - + {}^{bsc}\!S\!f_{ij}^\alpha = \sum_{\beta}\sum_{\gamma} \left(cos(\theta_{\alpha\beta\gamma})\right)^ie^{-\delta_j \frac{r^{\alpha\beta}}{r_e}}e^{-\delta_j \frac{r^{\alpha\gamma}}{r_e}}S^{\alpha\beta}S^{\alpha\gamma}f_c\left(\frac{r_c-r^{\alpha\beta}}{dr}\right)f_c\left(\frac{r_c-r^{\alpha\gamma}}{dr}\right) * **radialspin** .. math:: - + {}^{rsp}\!S\!f_i^\alpha = \sum_{\beta} \left(\frac{r^{\alpha\beta}}{r_e}\right)^ie^{-\delta_i \frac{r^{\alpha\beta}}{r_e}}\left(\mathbf{s^\alpha \cdot s^\beta}\right)f_c\left(\frac{r_c-r^{\alpha\beta}}{dr}\right) * **bondspin** @@ -333,13 +333,13 @@ The structural fingerprints are computed as follows: * **radialscreenedspin** .. math:: - + {}^{rscsp}\!S\!f_i^\alpha = \sum_{\beta} \left(\frac{r^{\alpha\beta}}{r_e}\right)^ie^{-\delta_i \frac{r^{\alpha\beta}}{r_e}}S^{\alpha\beta}\left(\mathbf{s^\alpha \cdot s^\beta}\right)f_c\left(\frac{r_c-r^{\alpha\beta}}{dr}\right) * **bondscreenedspin** .. math:: - + {}^{bscsp}\!S\!f_{ij}^\alpha = \sum_{\beta}\sum_{\gamma} \left(cos(\theta_{\alpha\beta\gamma})\right)^ie^{-\delta_j \frac{r^{\alpha\beta}}{r_e}}e^{-\delta_j \frac{r^{\alpha\gamma}}{r_e}}S^{\alpha\beta}S^{\alpha\gamma}\left(\mathbf{s^\alpha \cdot s^\beta}\right)\left(\mathbf{s^\alpha \cdot s^\gamma}\right)f_c\left(\frac{r_c-r^{\alpha\beta}}{dr}\right)f_c\left(\frac{r_c-r^{\alpha\gamma}}{dr}\right) The activation functions are computed as follows: @@ -361,8 +361,8 @@ The activation functions are computed as follows: Restrictions """""""""""" -pair_style rann requires the USER-RANN package. It is only enabled if LAMMPS was built with that -package. Additionally, if any spin fingerprint styles are used LAMMPS must be built with the SPIN +pair_style rann requires the USER-RANN package. It is only enabled if LAMMPS was built with that +package. Additionally, if any spin fingerprint styles are used LAMMPS must be built with the SPIN package as well. Defaults diff --git a/src/USER-RANN/rann_fingerprint.h b/src/USER-RANN/rann_fingerprint.h index e4ca22ffe1..5a32a1c74d 100644 --- a/src/USER-RANN/rann_fingerprint.h +++ b/src/USER-RANN/rann_fingerprint.h @@ -74,7 +74,7 @@ namespace RANN { { } - virtual int get_length(){return 0}; + virtual int get_length(){return 0;}; virtual double cutofffunction(double, double, double); virtual void generate_rinvssqrttable(); bool spin; From 64aa84a8514ea3b91a8dd7663462fcac0f3d4455 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 26 May 2021 16:01:26 -0400 Subject: [PATCH 22/25] remove dead code --- src/USER-RANN/rann_activation_linear.h | 7 ------- src/USER-RANN/rann_activation_sig_i.h | 7 ------- src/USER-RANN/rann_fingerprint_bond.h | 8 -------- src/USER-RANN/rann_fingerprint_bondscreened.h | 7 ------- src/USER-RANN/rann_fingerprint_bondscreenedspin.h | 7 ------- src/USER-RANN/rann_fingerprint_bondspin.h | 7 ------- src/USER-RANN/rann_fingerprint_radial.h | 6 ------ src/USER-RANN/rann_fingerprint_radialscreened.h | 10 ---------- src/USER-RANN/rann_fingerprint_radialscreenedspin.h | 10 ---------- src/USER-RANN/rann_fingerprint_radialspin.h | 7 ------- 10 files changed, 76 deletions(-) diff --git a/src/USER-RANN/rann_activation_linear.h b/src/USER-RANN/rann_activation_linear.h index f610907943..5596ddaef7 100644 --- a/src/USER-RANN/rann_activation_linear.h +++ b/src/USER-RANN/rann_activation_linear.h @@ -28,12 +28,6 @@ do not necessarily reflect the views of the United States Army.​” DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 */ -#ifdef ACTIVATION_CLASS - -ActivationStyle(linear,Activation_linear) - -#else - #ifndef LMP_RANN_ACTIVATION_LINEAR_H #define LMP_RANN_ACTIVATION_LINEAR_H @@ -73,5 +67,4 @@ namespace LAMMPS_NS { } } -#endif #endif /* ACTIVATION_LINEAR_H_ */ diff --git a/src/USER-RANN/rann_activation_sig_i.h b/src/USER-RANN/rann_activation_sig_i.h index 283ff3ee02..9983862b31 100644 --- a/src/USER-RANN/rann_activation_sig_i.h +++ b/src/USER-RANN/rann_activation_sig_i.h @@ -28,12 +28,6 @@ do not necessarily reflect the views of the United States Army.​” DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 */ -#ifdef ACTIVATION_CLASS - -ActivationStyle(sigI,Activation_sigI) - -#else - #ifndef LMP_RANN_ACTIVATION_SIGI_H #define LMP_RANN_ACTIVATION_SIGI_H @@ -73,5 +67,4 @@ namespace LAMMPS_NS { } } -#endif #endif /* ACTIVATION_SIGI_H_ */ diff --git a/src/USER-RANN/rann_fingerprint_bond.h b/src/USER-RANN/rann_fingerprint_bond.h index 183887404f..041c29a742 100644 --- a/src/USER-RANN/rann_fingerprint_bond.h +++ b/src/USER-RANN/rann_fingerprint_bond.h @@ -28,12 +28,6 @@ do not necessarily reflect the views of the United States Army.​” DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 */ -#ifdef FINGERPRINT_CLASS - -FingerprintStyle(bond,Fingerprint_bond) - -#else - #ifndef LMP_RANN_FINGERPRINT_BOND_H #define LMP_RANN_FINGERPRINT_BOND_H @@ -75,6 +69,4 @@ namespace LAMMPS_NS { } } - -#endif #endif /* FINGERPRINT_BOND_H_ */ diff --git a/src/USER-RANN/rann_fingerprint_bondscreened.h b/src/USER-RANN/rann_fingerprint_bondscreened.h index 44bb28c265..7e9216933f 100644 --- a/src/USER-RANN/rann_fingerprint_bondscreened.h +++ b/src/USER-RANN/rann_fingerprint_bondscreened.h @@ -28,11 +28,6 @@ do not necessarily reflect the views of the United States Army.​” DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 */ -#ifdef FINGERPRINT_CLASS - -FingerprintStyle(bondscreened,Fingerprint_bondscreened) - -#else #ifndef LMP_RANN_FINGERPRINT_BONDSCREENED_H #define LMP_RANN_FINGERPRINT_BONDSCREENED_H @@ -75,6 +70,4 @@ namespace LAMMPS_NS { } - -#endif #endif /* FINGERPRINT_BOND_H_ */ diff --git a/src/USER-RANN/rann_fingerprint_bondscreenedspin.h b/src/USER-RANN/rann_fingerprint_bondscreenedspin.h index e2f5f941f3..6bf12e5041 100644 --- a/src/USER-RANN/rann_fingerprint_bondscreenedspin.h +++ b/src/USER-RANN/rann_fingerprint_bondscreenedspin.h @@ -28,11 +28,6 @@ do not necessarily reflect the views of the United States Army.​” DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 */ -#ifdef FINGERPRINT_CLASS - -FingerprintStyle(bondscreenedspin,Fingerprint_bondscreenedspin) - -#else #ifndef LMP_RANN_FINGERPRINT_BONDSCREENEDSPIN_H #define LMP_RANN_FINGERPRINT_BONDSCREENEDSPIN_H @@ -75,6 +70,4 @@ namespace LAMMPS_NS { } } - -#endif #endif /* FINGERPRINT_BOND_H_ */ diff --git a/src/USER-RANN/rann_fingerprint_bondspin.h b/src/USER-RANN/rann_fingerprint_bondspin.h index 9514779a5c..845c88d062 100644 --- a/src/USER-RANN/rann_fingerprint_bondspin.h +++ b/src/USER-RANN/rann_fingerprint_bondspin.h @@ -28,11 +28,6 @@ do not necessarily reflect the views of the United States Army.​” DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 */ -#ifdef FINGERPRINT_CLASS - -FingerprintStyle(bondspin,Fingerprint_bondspin) - -#else #ifndef LMP_RANN_FINGERPRINT_BONDSPIN_H #define LMP_RANN_FINGERPRINT_BONDSPIN_H @@ -74,6 +69,4 @@ namespace LAMMPS_NS { } } - -#endif #endif /* FINGERPRINT_BOND_H_ */ diff --git a/src/USER-RANN/rann_fingerprint_radial.h b/src/USER-RANN/rann_fingerprint_radial.h index e6e4e85294..20ec18e8ec 100644 --- a/src/USER-RANN/rann_fingerprint_radial.h +++ b/src/USER-RANN/rann_fingerprint_radial.h @@ -28,11 +28,6 @@ do not necessarily reflect the views of the United States Army.​” DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 */ -#ifdef FINGERPRINT_CLASS - -FingerprintStyle(radial,Fingerprint_radial) - -#else #ifndef LMP_RANN_FINGERPRINT_RADIAL_H #define LMP_RANN_FINGERPRINT_RADIAL_H @@ -66,5 +61,4 @@ namespace LAMMPS_NS { } } -#endif #endif /* FINGERPRINT_RADIAL_H_ */ diff --git a/src/USER-RANN/rann_fingerprint_radialscreened.h b/src/USER-RANN/rann_fingerprint_radialscreened.h index d385f9b29c..ef7d612902 100644 --- a/src/USER-RANN/rann_fingerprint_radialscreened.h +++ b/src/USER-RANN/rann_fingerprint_radialscreened.h @@ -1,4 +1,3 @@ - /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/ Sandia National Laboratories @@ -28,15 +27,10 @@ do not necessarily reflect the views of the United States Army.​” DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 */ -#ifdef FINGERPRINT_CLASS -FingerprintStyle(radialscreened,Fingerprint_radialscreened) - -#else #ifndef LMP_RANN_FINGERPRINT_RADIALSCREENED_H #define LMP_RANN_FINGERPRINT_RADIALSCREENED_H - #include "rann_fingerprint.h" namespace LAMMPS_NS { @@ -65,8 +59,4 @@ namespace LAMMPS_NS { } -#endif - - - #endif /* FINGERPRINT_RADIALSCREENED_H_ */ diff --git a/src/USER-RANN/rann_fingerprint_radialscreenedspin.h b/src/USER-RANN/rann_fingerprint_radialscreenedspin.h index 3e58d3aef5..646a0b93f1 100644 --- a/src/USER-RANN/rann_fingerprint_radialscreenedspin.h +++ b/src/USER-RANN/rann_fingerprint_radialscreenedspin.h @@ -1,4 +1,3 @@ - /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/ Sandia National Laboratories @@ -28,15 +27,10 @@ do not necessarily reflect the views of the United States Army.​” DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 */ -#ifdef FINGERPRINT_CLASS -FingerprintStyle(radialscreenedspin,Fingerprint_radialscreenedspin) - -#else #ifndef LMP_RANN_FINGERPRINT_RADIALSCREENEDSPIN_H #define LMP_RANN_FINGERPRINT_RADIALSCREENEDSPIN_H - #include "rann_fingerprint.h" namespace LAMMPS_NS { @@ -65,8 +59,4 @@ namespace LAMMPS_NS { } -#endif - - - #endif /* FINGERPRINT_RADIALSCREENED_H_ */ diff --git a/src/USER-RANN/rann_fingerprint_radialspin.h b/src/USER-RANN/rann_fingerprint_radialspin.h index 72c3b5b286..90c3ce1f22 100644 --- a/src/USER-RANN/rann_fingerprint_radialspin.h +++ b/src/USER-RANN/rann_fingerprint_radialspin.h @@ -28,12 +28,6 @@ do not necessarily reflect the views of the United States Army.​” DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 */ -#ifdef FINGERPRINT_CLASS - -FingerprintStyle(radialspin,Fingerprint_radialspin) - -#else - #ifndef LMP_RANN_FINGERPRINT_RADIALSPIN_H #define LMP_RANN_FINGERPRINT_RADIALSPIN_H @@ -65,5 +59,4 @@ namespace LAMMPS_NS { } -#endif #endif /* FINGERPRINT_RADIAL_H_ */ From 80fc111b5ca3be592fe3539165ee37eccb79f863 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 26 May 2021 16:05:45 -0400 Subject: [PATCH 23/25] add new package to .gitignore --- src/.gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/.gitignore b/src/.gitignore index b63256d931..72bb8a3004 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -87,6 +87,11 @@ /fix_pafi*.cpp /fix_pafi*.h +/pair_rann.cpp +/pair_rann.h +/rann_*.cpp +/rann_*.h + /compute_test_nbl.cpp /compute_test_nbl.h /pair_multi_lucy.cpp From 258afaafd8d72142cefaae0afafa4a6de74248d6 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 26 May 2021 16:05:52 -0400 Subject: [PATCH 24/25] whitespace --- src/USER-RANN/rann_activation_linear.h | 1 - src/USER-RANN/rann_fingerprint_bondscreened.h | 1 - src/USER-RANN/rann_fingerprint_bondscreenedspin.h | 1 - src/USER-RANN/rann_fingerprint_bondspin.h | 1 - src/USER-RANN/rann_fingerprint_radial.h | 1 - 5 files changed, 5 deletions(-) diff --git a/src/USER-RANN/rann_activation_linear.h b/src/USER-RANN/rann_activation_linear.h index 5596ddaef7..2d94859cb0 100644 --- a/src/USER-RANN/rann_activation_linear.h +++ b/src/USER-RANN/rann_activation_linear.h @@ -1,4 +1,3 @@ - /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/ Sandia National Laboratories diff --git a/src/USER-RANN/rann_fingerprint_bondscreened.h b/src/USER-RANN/rann_fingerprint_bondscreened.h index 7e9216933f..71083cc04f 100644 --- a/src/USER-RANN/rann_fingerprint_bondscreened.h +++ b/src/USER-RANN/rann_fingerprint_bondscreened.h @@ -1,4 +1,3 @@ - /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/ Sandia National Laboratories diff --git a/src/USER-RANN/rann_fingerprint_bondscreenedspin.h b/src/USER-RANN/rann_fingerprint_bondscreenedspin.h index 6bf12e5041..6a0df27f80 100644 --- a/src/USER-RANN/rann_fingerprint_bondscreenedspin.h +++ b/src/USER-RANN/rann_fingerprint_bondscreenedspin.h @@ -1,4 +1,3 @@ - /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/ Sandia National Laboratories diff --git a/src/USER-RANN/rann_fingerprint_bondspin.h b/src/USER-RANN/rann_fingerprint_bondspin.h index 845c88d062..9ab8008189 100644 --- a/src/USER-RANN/rann_fingerprint_bondspin.h +++ b/src/USER-RANN/rann_fingerprint_bondspin.h @@ -1,4 +1,3 @@ - /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/ Sandia National Laboratories diff --git a/src/USER-RANN/rann_fingerprint_radial.h b/src/USER-RANN/rann_fingerprint_radial.h index 20ec18e8ec..d5a73a486c 100644 --- a/src/USER-RANN/rann_fingerprint_radial.h +++ b/src/USER-RANN/rann_fingerprint_radial.h @@ -1,4 +1,3 @@ - /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/ Sandia National Laboratories From 0713e9587389ae50b5828c66db8bb496bbd81841 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 26 May 2021 16:51:32 -0400 Subject: [PATCH 25/25] integrate documentation --- doc/src/Packages_details.rst | 26 +++ doc/src/Packages_user.rst | 2 + doc/src/pair_rann.rst | 209 +++++++++++--------- doc/utils/sphinx-config/false_positives.txt | 21 ++ 4 files changed, 163 insertions(+), 95 deletions(-) diff --git a/doc/src/Packages_details.rst b/doc/src/Packages_details.rst index 07a1794bd1..e7dc905e22 100644 --- a/doc/src/Packages_details.rst +++ b/doc/src/Packages_details.rst @@ -100,6 +100,7 @@ page gives those details. * :ref:`USER-QMMM ` * :ref:`USER-QTB ` * :ref:`USER-QUIP ` + * :ref:`USER-RANN ` * :ref:`USER-REACTION ` * :ref:`USER-REAXC ` * :ref:`USER-SCAFACOS ` @@ -2277,6 +2278,31 @@ This package has :ref:`specific installation instructions ` on the :d ---------- +.. _PKG-USER-RANN: + +USER-RANN package +----------------- + +**Contents:** + +A pair style for using rapid atomistic neural network (RANN) potentials. +These neural network potentials work by first generating a series of symmetry +functions from the neighbor list and then using these values as the input layer +of a neural network. + +**Authors:** + +This package was written by Christopher Barrett +with contributions by Doyl Dickel, Mississippi State University. + +**Supporting info:** + +* src/USER-RANN: filenames -> commands +* :doc:`pair_style rann ` +* examples/USER/rann + +---------- + .. _PKG-USER-REACTION: USER-REACTION package diff --git a/doc/src/Packages_user.rst b/doc/src/Packages_user.rst index 33226d1b1d..3bf1323d16 100644 --- a/doc/src/Packages_user.rst +++ b/doc/src/Packages_user.rst @@ -101,6 +101,8 @@ package: +------------------------------------------------+-----------------------------------------------------------------+-------------------------------------------------------------------------------+------------------------------------------------------+---------+ | :ref:`USER-QUIP ` | QUIP/libatoms interface | :doc:`pair_style quip ` | USER/quip | ext | +------------------------------------------------+-----------------------------------------------------------------+-------------------------------------------------------------------------------+------------------------------------------------------+---------+ +| :ref:`USER-RANN ` | rapid atomistic neural network (RANN) potentials | :doc:`pair rann ` | USER/rann | no | ++------------------------------------------------+-----------------------------------------------------------------+-------------------------------------------------------------------------------+------------------------------------------------------+---------+ | :ref:`USER-REACTION ` | chemical reactions in classical MD | :doc:`fix bond/react ` | USER/reaction | no | +------------------------------------------------+-----------------------------------------------------------------+-------------------------------------------------------------------------------+------------------------------------------------------+---------+ | :ref:`USER-REAXC ` | ReaxFF potential (C/C++) | :doc:`pair_style reaxc ` | reax | no | diff --git a/doc/src/pair_rann.rst b/doc/src/pair_rann.rst index 197bdfdd07..4177bae0c7 100644 --- a/doc/src/pair_rann.rst +++ b/doc/src/pair_rann.rst @@ -23,49 +23,43 @@ Examples Description """"""""""" -Style *rann* computes pairwise interactions for a variety of materials -using rapid atomistic neural network (RANN) potentials (:ref:`Dickel ` , :ref:`Nitol `). -Neural network potentials work by first generating a series of symmetry functions -i.e. structural fingerprints from the neighbor list and then using these values -as the input layer of a neural network. There is a single output neuron in the -final layer which is the energy. Atomic forces are found by analytical -derivatives computed via backpropagation. For alloy systems, each element has a unique -network. +Pair style *rann* computes pairwise interactions for a variety of +materials using rapid atomistic neural network (RANN) potentials +(:ref:`Dickel ` , :ref:`Nitol `). Neural network +potentials work by first generating a series of symmetry functions +i.e. structural fingerprints from the neighbor list and then using these +values as the input layer of a neural network. There is a single output +neuron in the final layer which is the energy. Atomic forces are found +by analytical derivatives computed via back-propagation. For alloy +systems, each element has a unique network. Potential file syntax """"""""""""""""""""" -The RANN potential is defined by a single text file which contains all the fitting parameters for the alloy system. -The potential file also defines the active fingerprints, network architecture, activation functions, etc. -The potential file is divided into several sections which are identified by one of the following keywords: +The RANN potential is defined by a single text file which contains all +the fitting parameters for the alloy system. The potential file also +defines the active fingerprints, network architecture, activation +functions, etc. The potential file is divided into several sections +which are identified by one of the following keywords: * atomtypes - * mass - * fingerprintsperelement - * fingerprints - * fingerprintconstants - * screening (optional) - * networklayers - * layersize - * weight - * bias - * activationfunctions - * calibrationparameters (ignored) -# is treated as a comment marker, similar to LAMMPS input scripts. Sections are not required to follow a rigid -ordering, but do require previous definition of prerequisite information. E.g., fingerprintconstants for a -particular fingerprint must follow the fingerprints definition; layersize for a particular layer must follow +The '#' character is treated as a comment marker, similar to LAMMPS +input scripts. Sections are not required to follow a rigid ordering, +but do require previous definition of prerequisite information. E.g., +fingerprintconstants for a particular fingerprint must follow the +fingerprints definition; layersize for a particular layer must follow the declaration of network layers. *atomtypes* are defined as follows using element keywords separated by spaces. @@ -86,15 +80,20 @@ the declaration of network layers. mass:Al: 26.982 -*fingerprintsperelement* specifies how many fingerprints are active for computing the energy of a given atom. -This number must be specified for each element keyword. Active elements for each fingerprint depend upon the -type of the central atom and the neighboring atoms. Pairwise fingerprints may be defined for a Mg atom based -exclusively on its Al neighbors, for example. Bond fingerprints may use two neighborlists of different -element types. In computing fingerprintsperelement from all defined fingerprints, only the fingerprints -defined for atoms of a particular element should be considered, regardless of the elements used in its -neighbor list. In the following code, for example, some fingerprints may compute pairwise fingerprints summing -contributions about Fe atoms based on a neighbor list of exclusively Al atoms, but if there are no fingerprints -summing contributions of all neighbors about a central Al atom, then fingerprintsperelement of Al is zero: +*fingerprintsperelement* specifies how many fingerprints are active for +computing the energy of a given atom. This number must be specified for +each element keyword. Active elements for each fingerprint depend upon +the type of the central atom and the neighboring atoms. Pairwise +fingerprints may be defined for a Mg atom based exclusively on its Al +neighbors, for example. Bond fingerprints may use two neighbor lists of +different element types. In computing fingerprintsperelement from all +defined fingerprints, only the fingerprints defined for atoms of a +particular element should be considered, regardless of the elements used +in its neighbor list. In the following code, for example, some +fingerprints may compute pairwise fingerprints summing contributions +about Fe atoms based on a neighbor list of exclusively Al atoms, but if +there are no fingerprints summing contributions of all neighbors about a +central Al atom, then fingerprintsperelement of Al is zero: .. code-block:: @@ -105,15 +104,21 @@ summing contributions of all neighbors about a central Al atom, then fingerprint fingerprintsperelement:Al: 0 -*fingerprints* specifies the active fingerprints for a certain element combination. Pair fingerprints are -specified for two elements, while bond fingerprints are specified for three elements. Only one fingerprints -header should be used for an individual combination of elements. The ordering of the fingerprints in the -network input layer is determined by the order of element combinations specified by subsequent *fingerprints* -lines, and the order of the fingerprints defined for each element combination. Multiple fingerprints of the same style or -different ones may be specified. If the same style and element combination is used for multiple fingerprints, -they should have different id numbers. The first element specifies the atoms for which this fingerprint is -computed while the other(s) specify which atoms to use in the neighbor lists for the computation. Switching -the second and third element type in bond fingerprints has no effect on the computation: +*fingerprints* specifies the active fingerprints for a certain element +combination. Pair fingerprints are specified for two elements, while +bond fingerprints are specified for three elements. Only one +fingerprints header should be used for an individual combination of +elements. The ordering of the fingerprints in the network input layer +is determined by the order of element combinations specified by +subsequent *fingerprints* lines, and the order of the fingerprints +defined for each element combination. Multiple fingerprints of the same +style or different ones may be specified. If the same style and element +combination is used for multiple fingerprints, they should have +different id numbers. The first element specifies the atoms for which +this fingerprint is computed while the other(s) specify which atoms to +use in the neighbor lists for the computation. Switching the second and +third element type in bond fingerprints has no effect on the +computation: .. code-block:: @@ -124,32 +129,26 @@ the second and third element type in bond fingerprints has no effect on the comp fingerprints:Mg_Al: radial_0 radialscreened_0 -The following fingerprint styles are currently defined. See the :ref:`formulation section ` below for their definitions: +The following fingerprint styles are currently defined. See the +:ref:`formulation section ` below for their definitions: * radial - * radialscreened - * radialspin - * radialscreenedspin - * bond - * bondscreened - * bondspin - * bondscreenedspin -*fingerprintconstants* specifies the metaparameters for a defined fingerprint. For all radial styles, re, rc, -alpha, dr, o, and n must be specified. re should usually be the stable interatomic distance, rc is the cutoff +*fingerprintconstants* specifies the meta-parameters for a defined fingerprint. For all radial styles, re, rc, +alpha, dr, o, and n must be specified. re should usually be the stable interatomic distance, rc is the cutoff radius, dr is the cutoff smoothing distance, o is the lowest radial power term (which may be negative), and n -is the highest power term. The total length of the fingerprint vector is (n-o+1). alpha is a list of decay parameters -used for exponential decay of radial contributions. It may be set proportionally to the bulk modulus similarly -to MEAM potentials, but other values may provided better fitting in special cases. Bond style fingerprints require -specification of re, rc, alphak, dr, k, and m. Here m is the power of the bond cosines and k is the number of -decay parameters. Cosine powers go from 0 to m-1 and are each computed for all values of alphak. Thus the total +is the highest power term. The total length of the fingerprint vector is (n-o+1). alpha is a list of decay parameters +used for exponential decay of radial contributions. It may be set proportionally to the bulk modulus similarly +to MEAM potentials, but other values may provided better fitting in special cases. Bond style fingerprints require +specification of re, rc, alphak, dr, k, and m. Here m is the power of the bond cosines and k is the number of +decay parameters. Cosine powers go from 0 to m-1 and are each computed for all values of alphak. Thus the total length of the fingerprint vector is m*k. .. code-block:: @@ -167,12 +166,16 @@ length of the fingerprint vector is m*k. fingerprintconstants:Mg_Mg:radialscreened_0:n: 3 -*screening* specifies the Cmax and Cmin values used in the screening fingerprints. Neighbors' contribution to the -fingerprint are omitted if they are blocked by a closer neighbor, and reduced if they are partially blocked. -Larger values of Cmin correspond to neighbors being blocked more easily. Cmax cannot be greater than 3, and -Cmin cannot be greater than Cmax or less than zero. Screening may be omitted in which case the default values -Cmax = 2.8, Cmin = 0.8 are used. Since screening is a bond computation, it is specified separately for each -combination of three elements in which the latter two may be interchanged with no effect. +*screening* specifies the Cmax and Cmin values used in the screening +fingerprints. Contributions form neighbors to the fingerprint are +omitted if they are blocked by a closer neighbor, and reduced if they +are partially blocked. Larger values of Cmin correspond to neighbors +being blocked more easily. Cmax cannot be greater than 3, and Cmin +cannot be greater than Cmax or less than zero. Screening may be omitted +in which case the default values Cmax = 2.8, Cmin = 0.8 are used. Since +screening is a bond computation, it is specified separately for each +combination of three elements in which the latter two may be +interchanged with no effect. .. code-block:: @@ -181,17 +184,18 @@ combination of three elements in which the latter two may be interchanged with n screening:Mg_Mg_Mg:Cmin: 0.400000 -*networklayers* species the size of the neural network for each atom. It counts both the input and output layer -and so is 2+hiddenlayers. +*networklayers* species the size of the neural network for each atom. +It counts both the input and output layer and so is 2 + \. .. code-block:: networklayers:Mg: 3 -*layersize* specifies the length of each layer, including the input layer and output layer. The input layer is -layer 0. The size of the input layer size must match the summed length of all the fingerprints for that element, -and the output layer size must be 1: +*layersize* specifies the length of each layer, including the input +layer and output layer. The input layer is layer 0. The size of the +input layer size must match the summed length of all the fingerprints +for that element, and the output layer size must be 1: .. code-block:: @@ -202,8 +206,11 @@ and the output layer size must be 1: layersize:Mg:2: 1 -*weight* specifies the weight for a given element and layer. Weight cannot be specified for the output layer. -The weight of layer i is a mxn matrix where m is the layer size of i and n is the layer size of i+1: + +*weight* specifies the weight for a given element and layer. Weight +cannot be specified for the output layer. The weight of layer i is a +*m* x *n* matrix where *m* is the layer size of *i* and *n* is the layer size of +*i*\ +1: .. code-block:: @@ -212,8 +219,9 @@ The weight of layer i is a mxn matrix where m is the layer size of i and n is th w21 w22 w23 ... ... -*bias* specifies the bias for a given element and layer. Bias cannot be specified for the output layer. -The bias of layer i is a nx1 vector where n is the layer size of i+1: +*bias* specifies the bias for a given element and layer. Bias cannot be +specified for the output layer. The bias of layer i is a nx1 vector +where n is the layer size of i+1: .. code-block:: @@ -223,8 +231,9 @@ The bias of layer i is a nx1 vector where n is the layer size of i+1: b3 ... -*activationfunctions* specifies the activation function for a given element and layer. Activation functions -cannot be specified for the output layer: +*activationfunctions* specifies the activation function for a given +element and layer. Activation functions cannot be specified for the +output layer: .. code-block:: @@ -233,7 +242,8 @@ cannot be specified for the output layer: activationfunctions:Mg:1: linear -The following activation styles are currently specified. See the :ref:`formulation section ` below for their definitions. +The following activation styles are currently specified. See the +:ref:`formulation section ` below for their definitions. * sigI @@ -255,19 +265,26 @@ is given by: {}^{n+1}\!A_i^{\alpha} = {}^{n}\!F\left({}^{n}\!W_{ij}{\;}^{n}\!A_j^{\alpha}+{}^{n}\!B_i\right)\\\\ {}^{0}\!A_i^{\alpha} = \left[\begin{array}{c} {}^1\!S\!f^\alpha\\ {}^2\!S\!f^\alpha \\...\\\end{array}\right] -Here :math:`E^\alpha` is the energy of atom :math:`\alpha`, :math:`{}^n\!F()`, :math:`{}^n\!W_{ij}` and :math:`{}^n\!B_i` are -the activation function, weight matrix and bias vector of the n-th layer respectively. The -inputs to the first layer are a collection of structural fingerprints which are collected and reshaped into a single long vector. -The individual fingerprints may be defined in any order and have various shapes and sizes. Multiple fingerprints of the same +Here :math:`E^\alpha` is the energy of atom :math:`\alpha`, +:math:`{}^n\!F()`, :math:`{}^n\!W_{ij}` and :math:`{}^n\!B_i` are the +activation function, weight matrix and bias vector of the n-th layer +respectively. The inputs to the first layer are a collection of +structural fingerprints which are collected and reshaped into a single +long vector. The individual fingerprints may be defined in any order +and have various shapes and sizes. Multiple fingerprints of the same type and varying parameters may also be defined in the input layer. -Eight types of structural fingerprints are currently defined. In the following, :math:`\beta` and :math:`\gamma` span the -full neighborlist of atom :math:`\alpha`. :math:`\delta_i` are decay metaparameters, and :math:`r_e` is a metaparameter -roughly proportional to the first neighbor distance. :math:`r_c` and :math:`dr` are the neighbor cutoff distance and -cutoff smoothing distance respectively. :math:`S^{\alpha\beta}` is the MEAM screening function -:ref:`(Baskes) `, :math:`s_i^\alpha` and :math:`s_i^\beta` are the atom spin vectors :ref:`(Tranchida) `. -:math:`r^{\alpha\beta}` is the distance from atom :math:`\alpha` to atom :math:`\beta`, and :math:`\theta^{\alpha\beta\gamma}` -is the bond angle: +Eight types of structural fingerprints are currently defined. In the +following, :math:`\beta` and :math:`\gamma` span the full neighbor list +of atom :math:`\alpha`. :math:`\delta_i` are decay meta-parameters, and +:math:`r_e` is a meta-parameter roughly proportional to the first +neighbor distance. :math:`r_c` and :math:`dr` are the neighbor cutoff +distance and cutoff smoothing distance respectively. +:math:`S^{\alpha\beta}` is the MEAM screening function :ref:`(Baskes) +`, :math:`s_i^\alpha` and :math:`s_i^\beta` are the atom spin +vectors :ref:`(Tranchida) `. :math:`r^{\alpha\beta}` is the +distance from atom :math:`\alpha` to atom :math:`\beta`, and +:math:`\theta^{\alpha\beta\gamma}` is the bond angle: .. math :: @@ -361,8 +378,8 @@ The activation functions are computed as follows: Restrictions """""""""""" -pair_style rann requires the USER-RANN package. It is only enabled if LAMMPS was built with that -package. Additionally, if any spin fingerprint styles are used LAMMPS must be built with the SPIN +Pair style *rann* is part of the USER-RANN package. It is only enabled if LAMMPS was built with that +package. Additionally, if any spin fingerprint styles are used LAMMPS must be built with the SPIN package as well. Defaults @@ -372,22 +389,24 @@ Cmin = 0.8, Cmax = 2.8. ---------- + .. _Baskes97: -.. _Nitol: - -.. _Dickel: - -.. _Dickel1: - **(Baskes)** Baskes, Materials Chemistry and Physics, 50(2), 152-158, (1997). +.. _Dickel: + **(Dickel)** Dickel, Francis, and Barrett, Computational Materials Science 171 (2020): 109157. +.. _Nitol: + **(Nitol)** Nitol, Dickel, and Barrett, Computational Materials Science 188 (2021): 110207. +.. _Tranchida7: + **(Tranchida)** Tranchida, Plimpton, Thibaudeau and Thompson, Journal of Computational Physics, 372, 406-425, (2018). + diff --git a/doc/utils/sphinx-config/false_positives.txt b/doc/utils/sphinx-config/false_positives.txt index d92cf4694e..0367808002 100644 --- a/doc/utils/sphinx-config/false_positives.txt +++ b/doc/utils/sphinx-config/false_positives.txt @@ -23,6 +23,7 @@ acolor acos Acta actinide +activationfunctions acylindricity addforce Addington @@ -75,6 +76,7 @@ allocaters allosws AlO Alonso +alphak alphashrink amap Amatrix @@ -153,6 +155,7 @@ atomfile AtomicPairStyle atomID atomistic +atomtypes attogram attograms attrac @@ -288,6 +291,9 @@ BondAngle BondBond bondchk bondmax +bondscreened +bondscreenedspin +bondspin bondtype Bonet Bonomi @@ -340,6 +346,8 @@ bz cadetblue Cagin calc +calibrationfunctions +calibrationparameters calibre caltech Caltech @@ -670,6 +678,7 @@ diagonalized diagonalizers diagonalizing Diallo +Dickel diel differentiable diffusively @@ -722,6 +731,7 @@ doxygenclass doxygenfunction downarrow Doye +Doyl dpd DPD dpdTheta @@ -1638,6 +1648,7 @@ Laupretre Lauriat lavenderblush lawngreen +layersize lB lbfgs lbl @@ -2164,6 +2175,7 @@ nemd netcdf netstat Nettleton +networklayers Neumann Nevent nevery @@ -2198,6 +2210,7 @@ Ninteger NiO Nissila nist +Nitol nitride nitrides niu @@ -2672,6 +2685,9 @@ qw qx qy qz +radialscreened +radialscreenedspin +radialspin radian radians Rafferty @@ -2684,6 +2700,8 @@ ramping Ramprasad Randisi randomizations +rann +RANN Raphson Rappe Ravelo @@ -2960,6 +2978,7 @@ SiC Siegmund Siepmann Sievers +sigI sigmoid Sij Sikandar @@ -3661,6 +3680,8 @@ zz Zm PowerShell filesystems +fingerprintconstants +fingerprintsperelement zincblende Zstandard Zstd