From 89011570e917250210d84805a79299a4c57f860c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Antonio=20Santos=20Fl=C3=B3rez?= Date: Thu, 11 Feb 2021 17:59:02 -0300 Subject: [PATCH 01/30] Update MLIAP --- src/MLIAP/mliap_data.cpp | 1 + src/MLIAP/mliap_data.h | 1 + src/MLIAP/mliap_model.cpp | 154 ++++++++++++++++++--- src/MLIAP/mliap_model.h | 6 +- src/MLIAP/mliap_model_nn.cpp | 220 ++++++++++++++++++++++++++++++ src/MLIAP/mliap_model_nn.h | 60 ++++++++ src/MLIAP/pair_mliap.cpp | 5 + src/mliap_model_python_couple.pyx | 120 ++++++++++++++++ 8 files changed, 550 insertions(+), 17 deletions(-) create mode 100644 src/MLIAP/mliap_model_nn.cpp create mode 100644 src/MLIAP/mliap_model_nn.h create mode 100644 src/mliap_model_python_couple.pyx diff --git a/src/MLIAP/mliap_data.cpp b/src/MLIAP/mliap_data.cpp index 8eff580dd7..49b6740d7d 100644 --- a/src/MLIAP/mliap_data.cpp +++ b/src/MLIAP/mliap_data.cpp @@ -44,6 +44,7 @@ MLIAPData::MLIAPData(LAMMPS *lmp, int gradgradflag_in, int *map_in, ndescriptors = descriptor->ndescriptors; nelements = descriptor->nelements; nparams = model->get_nparams(); + nlayers = model->nlayers; gamma_nnz = model->get_gamma_nnz(this); ndims_force = 3; diff --git a/src/MLIAP/mliap_data.h b/src/MLIAP/mliap_data.h index 7fb60bd723..4199187e2a 100644 --- a/src/MLIAP/mliap_data.h +++ b/src/MLIAP/mliap_data.h @@ -41,6 +41,7 @@ class MLIAPData : protected Pointers { int ndescriptors; // number of descriptors int nparams; // number of model parameters per element int nelements; // number of elements + int nlayers; // number of layers per element // data structures for grad-grad list (gamma) diff --git a/src/MLIAP/mliap_model.cpp b/src/MLIAP/mliap_model.cpp index f993aeb725..67abe3d19f 100644 --- a/src/MLIAP/mliap_model.cpp +++ b/src/MLIAP/mliap_model.cpp @@ -36,7 +36,9 @@ MLIAPModel::MLIAPModel(LAMMPS *lmp, char *) : Pointers(lmp) nparams = 0; nelements = 0; ndescriptors = 0; + nlayers = 0; nonlinearflag = 0; + nnflag = 0; } /* ---------------------------------------------------------------------- */ @@ -77,6 +79,9 @@ void MLIAPModel::set_ndescriptors(int ndescriptors_in) MLIAPModelSimple::MLIAPModelSimple(LAMMPS *lmp, char *coefffilename) : MLIAPModel(lmp, coefffilename) { coeffelem = nullptr; + nnodes = nullptr; + activation = nullptr; + scale = nullptr; if (coefffilename) read_coeffs(coefffilename); } @@ -85,6 +90,11 @@ MLIAPModelSimple::MLIAPModelSimple(LAMMPS *lmp, char *coefffilename) : MLIAPMode MLIAPModelSimple::~MLIAPModelSimple() { memory->destroy(coeffelem); + if (nnflag) { + memory->destroy(nnodes); + memory->destroy(activation); + memory->destroy(scale); + } } /* ---------------------------------------------------------------------- */ @@ -102,7 +112,7 @@ void MLIAPModelSimple::read_coeffs(char *coefffilename) coefffilename,utils::getsyserror())); } - char line[MAXLINE],*ptr; + char line[MAXLINE],*ptr, *tstr; int eof = 0; int n; @@ -123,6 +133,10 @@ void MLIAPModelSimple::read_coeffs(char *coefffilename) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; + if ((ptr = strstr(line,"nn"))) { + *ptr = '\0'; + nnflag = 1; + } nwords = utils::count_words(line); } if (nwords != 2) @@ -144,10 +158,49 @@ void MLIAPModelSimple::read_coeffs(char *coefffilename) memory->create(coeffelem,nelements,nparams,"mliap_snap_model:coeffelem"); + if (nnflag == 0) { + // Loop over nelements blocks in the coefficient file - for (int ielem = 0; ielem < nelements; ielem++) { - for (int icoeff = 0; icoeff < nparams; icoeff++) { + for (int ielem = 0; ielem < nelements; ielem++) { + for (int icoeff = 0; icoeff < nparams; icoeff++) { + if (comm->me == 0) { + ptr = fgets(line,MAXLINE,fpcoeff); + if (ptr == nullptr) { + eof = 1; + fclose(fpcoeff); + } else n = strlen(line) + 1; + } + + MPI_Bcast(&eof,1,MPI_INT,0,world); + if (eof) + error->all(FLERR,"Incorrect format in MLIAPModel coefficient file"); + MPI_Bcast(&n,1,MPI_INT,0,world); + MPI_Bcast(line,n,MPI_CHAR,0,world); + + try { + ValueTokenizer coeffs(utils::trim_comment(line)); + if (coeffs.count() != 1) + throw TokenizerException("Wrong number of items",""); + coeffelem[ielem][icoeff] = coeffs.next_double(); + } catch (TokenizerException &e) { + error->all(FLERR,fmt::format("Incorrect format in MLIAPModel " + "coefficient file: {}",e.what())); + } + } + } + + if (comm->me == 0) fclose(fpcoeff); + } + + // set up the NET parameters + + else { + int stats = 0; + int ielem = 0; + int l = 0; + + while (1) { if (comm->me == 0) { ptr = fgets(line,MAXLINE,fpcoeff); if (ptr == nullptr) { @@ -157,24 +210,88 @@ void MLIAPModelSimple::read_coeffs(char *coefffilename) } MPI_Bcast(&eof,1,MPI_INT,0,world); - if (eof) - error->all(FLERR,"Incorrect format in MLIAPModel coefficient file"); + if (eof) break; MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); + + // strip comment, skip line if blank - try { - ValueTokenizer coeffs(utils::trim_comment(line)); - if (coeffs.count() != 1) - throw TokenizerException("Wrong number of items",""); - coeffelem[ielem][icoeff] = coeffs.next_double(); - } catch (TokenizerException &e) { - error->all(FLERR,fmt::format("Incorrect format in MLIAPModel " - "coefficient file: {}",e.what())); + if ((ptr = strchr(line,'#'))) *ptr = '\0'; + nwords = utils::trim_and_count_words(line); + if (nwords == 0) continue; + +// std::cout << "nwords : " << nwords << std::endl; +// std::cout << "line : " << std::string(line) << std::endl; + + if (stats == 0) { // Header NET + tstr = strtok(line,"' \t\n\r\f"); +// std::cout << "is ok NET? : " << tstr << std::endl; + if (strncmp(tstr, "NET", 3) != 0) error->all(FLERR,"Incorrect format in NET coefficient file"); + + ndescriptors = atoi(strtok(nullptr,"' \t\n\r\f")); +// std::cout << "ndescriptors : " << tstr << std::endl; + nlayers = atoi(strtok(nullptr,"' \t\n\r\f")); +// std::cout << "nlayers : " << nparams << std::endl; + + memory->create(activation,nlayers,"mliap_model:activation"); + memory->create(nnodes,nlayers,"mliap_model:nnodes"); + memory->create(scale,nelements,2,ndescriptors,"mliap_model:scale"); + + for (int ilayer = 0; ilayer < nlayers; ilayer++) { + tstr = strtok(NULL,"' \t\n\r\f"); +// std::cout << "AF of layer " << ilayer+1 << " :" << tstr << std::endl; + nnodes[ilayer] = atoi(strtok(NULL,"' \t\n\r\f")); +// std::cout << "nnodes of layer " << ilayer+1 << " :" << nnodes[ilayer] << std::endl; + + if (strncmp(tstr, "linear", 6) == 0) activation[ilayer] = 0; + else if (strncmp(tstr, "sigmoid", 7) == 0) activation[ilayer] = 1; + else if (strncmp(tstr, "tanh", 4) == 0) activation[ilayer] = 2; + else if (strncmp(tstr, "relu", 4) == 0) activation[ilayer] = 3; + else activation[ilayer] = 4; + } + + stats = 1; + + } else if (stats == 1) { + scale[ielem][0][l] = atof(strtok(line,"' \t\n\r\f")); + for (int icoeff = 1; icoeff < nwords; icoeff++) { + scale[ielem][0][l+icoeff] = atof(strtok(nullptr,"' \t\n\r\f")); + } + l += nwords; + if (l == ndescriptors) { + stats = 2; + l = 0; + } + + } else if (stats == 2) { + scale[ielem][1][l] = atof(strtok(line,"' \t\n\r\f")); + for (int icoeff = 1; icoeff < nwords; icoeff++) { + scale[ielem][1][l+icoeff] = atof(strtok(nullptr,"' \t\n\r\f")); + } + l += nwords; + if (l == ndescriptors) { + stats = 3; + l = 0; + } + + // set up coeff lists + + } else if (stats == 3) { + // if (nwords > 5) error->all(FLERR,"Incorrect format in coefficient file"); + + coeffelem[ielem][l] = atof(strtok(line,"' \t\n\r\f")); + for (int icoeff = 1; icoeff < nwords; icoeff++) { + coeffelem[ielem][l+icoeff] = atof(strtok(nullptr,"' \t\n\r\f")); + } + l += nwords; + if (l == nparams) { + stats = 0; + ielem++; + } } - } } - if (comm->me == 0) fclose(fpcoeff); + } } /* ---------------------------------------------------------------------- @@ -185,7 +302,12 @@ double MLIAPModelSimple::memory_usage() { double bytes = 0; - bytes += (double)nelements*nparams*sizeof(double); // coeffelem + bytes += (double)nelements*nparams*sizeof(double); // coeffelem + if (nnflag) { + bytes += (double)nelements*2*ndescriptors*sizeof(double); // scale + bytes += (int)nlayers*sizeof(int); // nnodes + bytes += (int)nlayers*sizeof(int); // activation + } return bytes; } diff --git a/src/MLIAP/mliap_model.h b/src/MLIAP/mliap_model.h index 96cfff0a3d..9506f063c2 100644 --- a/src/MLIAP/mliap_model.h +++ b/src/MLIAP/mliap_model.h @@ -33,8 +33,10 @@ public: virtual double memory_usage()=0; int nelements; // # of unique elements int nonlinearflag; // 1 if gradient() requires descriptors + int nnflag; // 1 if model is nn int ndescriptors; // number of descriptors int nparams; // number of parameters per element + int nlayers; // number of layers per element protected: virtual void read_coeffs(char *)=0; @@ -47,9 +49,11 @@ public: virtual double memory_usage(); protected: + int *activation; // activation functions + int *nnodes; // number of nodes per layer + double ***scale; // element scale values double **coeffelem; // element coefficients virtual void read_coeffs(char *); - }; } diff --git a/src/MLIAP/mliap_model_nn.cpp b/src/MLIAP/mliap_model_nn.cpp new file mode 100644 index 0000000000..d8671c8ab2 --- /dev/null +++ b/src/MLIAP/mliap_model_nn.cpp @@ -0,0 +1,220 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://lammps.sandia.gov/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#include "mliap_model_nn.h" +#include "pair_mliap.h" +#include "mliap_data.h" +#include "error.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +MLIAPModelNN::MLIAPModelNN(LAMMPS* lmp, char* coefffilename) : + MLIAPModelSimple(lmp, coefffilename) +{ + ndescriptors = ndescriptors; +} + +/* ---------------------------------------------------------------------- */ + +MLIAPModelNN::~MLIAPModelNN(){} + +/* ---------------------------------------------------------------------- + get number of parameters + ---------------------------------------------------------------------- */ + +int MLIAPModelNN::get_nparams() +{ + if (nparams == 0) { + if (ndescriptors == 0) error->all(FLERR,"ndescriptors not defined"); + } + return nparams; +} + +/* ---------------------------------------------------------------------- + Calculate model gradients w.r.t descriptors + for each atom beta_i = dE(B_i)/dB_i + ---------------------------------------------------------------------- */ + +void MLIAPModelNN::compute_gradients(MLIAPData* data) +{ + data->energy = 0.0; + + for (int ii = 0; ii < data->natoms; ii++) { + const int i = data->iatoms[ii]; + const int ielem = data->ielems[ii]; + const int nl = data->nlayers; + + double* coeffi = coeffelem[ielem]; + double** scalei = scale[ielem]; + double **nodes, **dnodes, **bnodes; + + nodes = new double*[nl]; + dnodes = new double*[nl]; + bnodes = new double*[nl]; + for (int l=0; lndescriptors; icoeff++) { + nodes[0][n] += coeffi[n*((data->ndescriptors)+1)+icoeff+1] * (data->descriptors[ii][icoeff] - scalei[0][icoeff]) / scalei[1][icoeff]; + } + if (activation[0] == 1) { + nodes[0][n] = sigm(nodes[0][n] + coeffi[n*((data->ndescriptors)+1)], dnodes[0][n]); + } + else if (activation[0] == 2) { + nodes[0][n] = tanh(nodes[0][n] + coeffi[n*((data->ndescriptors)+1)], dnodes[0][n]); + } + else if (activation[0] == 3) { + nodes[0][n] = relu(nodes[0][n] + coeffi[n*((data->ndescriptors)+1)], dnodes[0][n]); + } + else { + nodes[0][n] += coeffi[n*((data->ndescriptors)+1)]; + dnodes[0][n] = 1; + } + } + + // hidden~output + int k = 0; + if (nl > 1) { + k += ((data->ndescriptors)+1)*nnodes[0]; + for (int l=1; l < nl; l++) { + for (int n=0; n < nnodes[l]; n++) { + nodes[l][n] = 0; + for (int j=0; j < nnodes[l-1]; j++) { + nodes[l][n] += coeffi[k+n*(nnodes[l-1]+1)+j+1] * nodes[l-1][j]; + } + if (activation[l] == 1) { + nodes[l][n] = sigm(nodes[l][n] + coeffi[k+n*(nnodes[l-1]+1)], dnodes[l][n]); + } + else if (activation[l] == 2) { + nodes[l][n] = tanh(nodes[l][n] + coeffi[k+n*(nnodes[l-1]+1)], dnodes[l][n]); + } + else if (activation[l] == 3) { + nodes[l][n] = relu(nodes[l][n] + coeffi[k+n*(nnodes[l-1]+1)], dnodes[l][n]); + } + else { + nodes[l][n] += coeffi[k+n*(nnodes[l-1]+1)]; + dnodes[l][n] = 1; + } + } + k += (nnodes[l-1]+1)*nnodes[l]; + } + } + + // backwardprop + // output layer dnode initialized to 1. + + for (int n=0; n 1) { + for (int l=nl-1; l>0; l--) { + k -= (nnodes[l-1]+1)*nnodes[l]; + for (int n=0; n= 1) { + bnodes[l-1][n] *= dnodes[l-1][n]; + } + } + } + } + + for (int icoeff = 0; icoeff < data->ndescriptors; icoeff++) { + data->betas[ii][icoeff] = 0; + for (int j=0; jbetas[ii][icoeff] += coeffi[j*((data->ndescriptors)+1)+icoeff+1] * bnodes[0][j]; + } + data->betas[ii][icoeff] = data->betas[ii][icoeff]/scalei[1][icoeff]; + } + + if (data->eflag) { + + // energy of atom I (E_i) + + double etmp = nodes[nl-1][0]; + + data->energy += etmp; + data->eatoms[ii] = etmp; + } + // Deleting the variables + + for (int n=0; nall(FLERR,"compute_gradgrads not implemented"); +} + +/* ---------------------------------------------------------------------- + calculate gradients of forces w.r.t. parameters + egradient is derivative of energy w.r.t. parameters + ---------------------------------------------------------------------- */ + +void MLIAPModelNN::compute_force_gradients(class MLIAPData* data) +{ + error->all(FLERR,"compute_force_gradients not implemented"); +} + +/* ---------------------------------------------------------------------- + count the number of non-zero entries in gamma matrix + ---------------------------------------------------------------------- */ + +int MLIAPModelNN::get_gamma_nnz(class MLIAPData* data) +{ + // todo: get_gamma_nnz + return 0; +} + diff --git a/src/MLIAP/mliap_model_nn.h b/src/MLIAP/mliap_model_nn.h new file mode 100644 index 0000000000..aa9f6a2338 --- /dev/null +++ b/src/MLIAP/mliap_model_nn.h @@ -0,0 +1,60 @@ +/* -*- 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. +------------------------------------------------------------------------- */ + +#ifndef LMP_MLIAP_MODEL_NN_H +#define LMP_MLIAP_MODEL_NN_H + +#include "mliap_model.h" +#include + +namespace LAMMPS_NS { + +class MLIAPModelNN : public MLIAPModelSimple { +public: + MLIAPModelNN(LAMMPS*, char* = nullptr); + ~MLIAPModelNN(); + virtual int get_nparams(); + virtual int get_gamma_nnz(class MLIAPData*); + virtual void compute_gradients(class MLIAPData*); + virtual void compute_gradgrads(class MLIAPData*); + virtual void compute_force_gradients(class MLIAPData*); + +protected: +}; + +} + +static inline double sigm(double x, double &deriv) { + double expl = 1./(1.+exp(-x)); + deriv = expl*(1-expl); + return expl; +} + +static inline double tanh(double x, double &deriv) { + double expl = 2./(1.+exp(-2.*x))-1; + deriv = 1.-expl*expl; + return expl; +} + +static inline double relu(double x, double &deriv) { + if (x > 0) { + deriv = 1.; + return x; + } else { + deriv = 0.; + return 0; + } +} + +#endif + diff --git a/src/MLIAP/pair_mliap.cpp b/src/MLIAP/pair_mliap.cpp index ef8a4c974e..f280795399 100644 --- a/src/MLIAP/pair_mliap.cpp +++ b/src/MLIAP/pair_mliap.cpp @@ -20,6 +20,7 @@ #include "mliap_data.h" #include "mliap_model_linear.h" #include "mliap_model_quadratic.h" +#include "mliap_model_nn.h" #include "mliap_descriptor_snap.h" #ifdef MLIAP_PYTHON #include "mliap_model_python.h" @@ -152,6 +153,10 @@ void PairMLIAP::settings(int narg, char ** arg) if (iarg+3 > narg) error->all(FLERR,"Illegal pair_style mliap command"); model = new MLIAPModelQuadratic(lmp,arg[iarg+2]); iarg += 3; + } else if (strcmp(arg[iarg+1],"nn") == 0) { + if (iarg+3 > narg) error->all(FLERR,"Illegal pair_style mliap command"); + model = new MLIAPModelNN(lmp,arg[iarg+2]); + iarg += 3; #ifdef MLIAP_PYTHON } else if (strcmp(arg[iarg+1],"mliappy") == 0) { if (iarg+3 > narg) error->all(FLERR,"Illegal pair_style mliap command"); diff --git a/src/mliap_model_python_couple.pyx b/src/mliap_model_python_couple.pyx new file mode 100644 index 0000000000..1f04964ef6 --- /dev/null +++ b/src/mliap_model_python_couple.pyx @@ -0,0 +1,120 @@ +# cython: language_level=3 +# distutils: language = c++ + +cimport cython + +import pickle + +# For converting C arrays to numpy arrays +import numpy as np + +# For converting void * to integer for tracking object identity +from libc.stdint cimport uintptr_t + +from libcpp.string cimport string + + +cdef extern from "mliap_data.h" namespace "LAMMPS_NS": + cdef cppclass MLIAPData: + # Array shapes + int natoms + int ndescriptors + + # Input data + int * ielems # types for all atoms in list + double ** descriptors # descriptors for all atoms in list + + # Output data to write to + double ** betas # betas for all atoms in list + double * eatoms # energy for all atoms in list + double energy + +cdef extern from "mliap_model_python.h" namespace "LAMMPS_NS": + cdef cppclass MLIAPModelPython: + void connect_param_counts() + + +class MLIAPPYModelNotLinked(Exception): pass + + +LOADED_MODELS = {} + +cdef object c_id(MLIAPModelPython * c_model): + """ + Use python-style id of object to keep track of identity. + Note, this is probably not a perfect general strategy but it should work fine with LAMMPS pair styles. + """ + return int( c_model) + +cdef object retrieve(MLIAPModelPython * c_model) with gil: + try: + model = LOADED_MODELS[c_id(c_model)] + except KeyError as ke: + raise KeyError("Model has not been loaded.") from ke + if model is None: + raise MLIAPPYModelNotLinked("Model not linked, connect the model from the python side.") + return model + +cdef public int MLIAPPY_load_model(MLIAPModelPython * c_model, char* fname) with gil: + str_fname = fname.decode('utf-8') # Python 3 only; not Python 2 not supported. + if str_fname == "LATER": + model = None + returnval = 0 + else: + if str_fname.endswith(".pt") or str_fname.endswith('.pth'): + import torch + model = torch.load(str_fname) + else: + with open(str_fname,'rb') as pfile: + model = pickle.load(pfile) + returnval = 1 + LOADED_MODELS[c_id(c_model)] = model + return returnval + +def load_from_python(model): + unloaded_models = [k for k, v in LOADED_MODELS.items() if v is None] + num_models = len(unloaded_models) + cdef MLIAPModelPython * lmp_model + + if num_models == 0: + raise ValueError("No model in the waiting area.") + elif num_models > 1: + raise ValueError("Model is amibguous, more than one model in waiting area.") + else: + c_id = unloaded_models[0] + LOADED_MODELS[c_id]=model + lmp_model = c_id + lmp_model.connect_param_counts() + + +cdef public void MLIAPPY_unload_model(MLIAPModelPython * c_model) with gil: + del LOADED_MODELS[c_id(c_model)] + +cdef public int MLIAPPY_nparams(MLIAPModelPython * c_model) with gil: + return int(retrieve(c_model).n_params) + +cdef public int MLIAPPY_nelements(MLIAPModelPython * c_model) with gil: + return int(retrieve(c_model).n_elements) + +cdef public int MLIAPPY_ndescriptors(MLIAPModelPython * c_model) with gil: + return int(retrieve(c_model).n_descriptors) + +cdef public void MLIAPPY_compute_gradients(MLIAPModelPython * c_model, MLIAPData * data) with gil: + model = retrieve(c_model) + + n_d = data.ndescriptors + n_a = data.natoms + + # Make numpy arrays from pointers + beta_np = np.asarray( &data.betas[0][0]) + desc_np = np.asarray( &data.descriptors[0][0]) + elem_np = np.asarray( &data.ielems[0]) + en_np = np.asarray( &data.eatoms[0]) + + # Invoke python model on numpy arrays. + model(elem_np,desc_np,beta_np,en_np) + + # Get the total energy from the atom energy. + energy = np.sum(en_np) + data.energy = energy + return From 6bbda594b1a111c7ba1f5b6059985ff0cd3251be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Antonio=20Santos=20Fl=C3=B3rez?= Date: Fri, 12 Feb 2021 12:18:44 -0300 Subject: [PATCH 02/30] Update mliap_model_nn.cpp --- src/MLIAP/mliap_model_nn.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/MLIAP/mliap_model_nn.cpp b/src/MLIAP/mliap_model_nn.cpp index d8671c8ab2..a49a6d1665 100644 --- a/src/MLIAP/mliap_model_nn.cpp +++ b/src/MLIAP/mliap_model_nn.cpp @@ -52,7 +52,6 @@ void MLIAPModelNN::compute_gradients(MLIAPData* data) data->energy = 0.0; for (int ii = 0; ii < data->natoms; ii++) { - const int i = data->iatoms[ii]; const int ielem = data->ielems[ii]; const int nl = data->nlayers; From b165d5a7ed369c51f974e0bedbbc78c1ee2f018f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Antonio=20Santos=20Fl=C3=B3rez?= Date: Fri, 12 Feb 2021 13:03:24 -0300 Subject: [PATCH 03/30] Update mliap_model.cpp --- src/MLIAP/mliap_model.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/MLIAP/mliap_model.cpp b/src/MLIAP/mliap_model.cpp index 67abe3d19f..7c62115f54 100644 --- a/src/MLIAP/mliap_model.cpp +++ b/src/MLIAP/mliap_model.cpp @@ -193,7 +193,7 @@ void MLIAPModelSimple::read_coeffs(char *coefffilename) if (comm->me == 0) fclose(fpcoeff); } - // set up the NET parameters + // set up the NN parameters else { int stats = 0; @@ -220,18 +220,12 @@ void MLIAPModelSimple::read_coeffs(char *coefffilename) nwords = utils::trim_and_count_words(line); if (nwords == 0) continue; -// std::cout << "nwords : " << nwords << std::endl; -// std::cout << "line : " << std::string(line) << std::endl; - if (stats == 0) { // Header NET tstr = strtok(line,"' \t\n\r\f"); -// std::cout << "is ok NET? : " << tstr << std::endl; if (strncmp(tstr, "NET", 3) != 0) error->all(FLERR,"Incorrect format in NET coefficient file"); ndescriptors = atoi(strtok(nullptr,"' \t\n\r\f")); -// std::cout << "ndescriptors : " << tstr << std::endl; nlayers = atoi(strtok(nullptr,"' \t\n\r\f")); -// std::cout << "nlayers : " << nparams << std::endl; memory->create(activation,nlayers,"mliap_model:activation"); memory->create(nnodes,nlayers,"mliap_model:nnodes"); @@ -239,9 +233,7 @@ void MLIAPModelSimple::read_coeffs(char *coefffilename) for (int ilayer = 0; ilayer < nlayers; ilayer++) { tstr = strtok(NULL,"' \t\n\r\f"); -// std::cout << "AF of layer " << ilayer+1 << " :" << tstr << std::endl; nnodes[ilayer] = atoi(strtok(NULL,"' \t\n\r\f")); -// std::cout << "nnodes of layer " << ilayer+1 << " :" << nnodes[ilayer] << std::endl; if (strncmp(tstr, "linear", 6) == 0) activation[ilayer] = 0; else if (strncmp(tstr, "sigmoid", 7) == 0) activation[ilayer] = 1; @@ -277,7 +269,7 @@ void MLIAPModelSimple::read_coeffs(char *coefffilename) // set up coeff lists } else if (stats == 3) { - // if (nwords > 5) error->all(FLERR,"Incorrect format in coefficient file"); + // if (nwords > 30) error->all(FLERR,"Wrong number of items per line, max 30"); coeffelem[ielem][l] = atof(strtok(line,"' \t\n\r\f")); for (int icoeff = 1; icoeff < nwords; icoeff++) { From 389f8b040dbe85a2ddca69f44c8c47e2712836b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Antonio=20Santos=20Fl=C3=B3rez?= Date: Fri, 12 Feb 2021 20:09:28 -0300 Subject: [PATCH 04/30] Testing examples --- examples/mliap/compute.quadratic.gg0.dat | 17 ++ examples/mliap/compute.quadratic.gg1.dat | 17 ++ examples/mliap/compute.snap.gg0.dat | 17 ++ examples/mliap/compute.snap.gg1.dat | 17 ++ examples/mliap/log.Ta06_v2 | 156 +++++++++++++ examples/mliap/log.WBe_v2 | 167 ++++++++++++++ examples/mliap/log.chem_v2 | 158 +++++++++++++ examples/mliap/log.compute_v2 | 282 +++++++++++++++++++++++ examples/mliap/log.quadratic_compute_v2 | 282 +++++++++++++++++++++++ examples/mliap/log.quadratic_v2 | 158 +++++++++++++ 10 files changed, 1271 insertions(+) create mode 100644 examples/mliap/compute.quadratic.gg0.dat create mode 100644 examples/mliap/compute.quadratic.gg1.dat create mode 100644 examples/mliap/compute.snap.gg0.dat create mode 100644 examples/mliap/compute.snap.gg1.dat create mode 100644 examples/mliap/log.Ta06_v2 create mode 100644 examples/mliap/log.WBe_v2 create mode 100644 examples/mliap/log.chem_v2 create mode 100644 examples/mliap/log.compute_v2 create mode 100644 examples/mliap/log.quadratic_compute_v2 create mode 100644 examples/mliap/log.quadratic_v2 diff --git a/examples/mliap/compute.quadratic.gg0.dat b/examples/mliap/compute.quadratic.gg0.dat new file mode 100644 index 0000000000..0a6695c1ab --- /dev/null +++ b/examples/mliap/compute.quadratic.gg0.dat @@ -0,0 +1,17 @@ +# Time-averaged data for fix snap +# TimeStep Number-of-rows +# Row c_snap[1] c_snap[2] c_snap[3] c_snap[4] c_snap[5] c_snap[6] c_snap[7] c_snap[8] c_snap[9] c_snap[10] c_snap[11] c_snap[12] c_snap[13] c_snap[14] c_snap[15] c_snap[16] c_snap[17] c_snap[18] c_snap[19] c_snap[20] c_snap[21] c_snap[22] c_snap[23] c_snap[24] c_snap[25] c_snap[26] c_snap[27] c_snap[28] c_snap[29] c_snap[30] c_snap[31] c_snap[32] c_snap[33] c_snap[34] c_snap[35] c_snap[36] c_snap[37] c_snap[38] c_snap[39] c_snap[40] c_snap[41] c_snap[42] c_snap[43] +0 13 +1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 364183 213523 107428 122916 41227.5 3.31573e+10 3.88807e+10 1.95617e+10 2.23819e+10 7.50718e+09 1.1398e+10 1.14692e+10 1.31227e+10 4.40152e+09 2.88519e+09 6.60228e+09 2.21449e+09 3.77706e+09 2.53375e+09 4.24928e+08 322.87 +2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -206.978 -293.105 -434.029 -217.39 0 -3.76889e+07 -5.33719e+07 -7.9033e+07 -3.95849e+07 -2.20973e+07 -4.24099e+07 -5.9058e+07 -2.74755e+07 -1.57438e+07 -4.1327e+07 -1.77189e+07 -2.66745e+07 -2.23073e+07 -4.48124e+06 -20.7188 +3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1277.1 -1841.02 -2752.08 -1381.8 0 -2.3255e+08 -3.35235e+08 -5.0113e+08 -2.51613e+08 -1.36345e+08 -2.65149e+08 -3.72304e+08 -1.73849e+08 -9.88886e+07 -2.6097e+08 -1.12172e+08 -1.69137e+08 -1.41653e+08 -2.8484e+07 -106.829 +4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 804.916 1147.62 1705.6 855.045 0 1.46568e+08 2.08973e+08 3.10574e+08 1.55696e+08 8.59341e+07 1.65757e+08 2.3156e+08 1.07878e+08 6.16434e+07 1.62145e+08 6.95847e+07 1.04822e+08 8.77079e+07 1.76257e+07 74.8128 +5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 206.978 293.105 434.029 217.39 0 3.76889e+07 5.33719e+07 7.9033e+07 3.95849e+07 2.20973e+07 4.24099e+07 5.9058e+07 2.74755e+07 1.57438e+07 4.1327e+07 1.77189e+07 2.66745e+07 2.23073e+07 4.48124e+06 20.7188 +6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1277.1 1841.02 2752.08 1381.8 0 2.3255e+08 3.35235e+08 5.0113e+08 2.51613e+08 1.36345e+08 2.65149e+08 3.72304e+08 1.73849e+08 9.88886e+07 2.6097e+08 1.12172e+08 1.69137e+08 1.41653e+08 2.8484e+07 106.829 +7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -804.916 -1147.62 -1705.6 -855.045 0 -1.46568e+08 -2.08973e+08 -3.10574e+08 -1.55696e+08 -8.59341e+07 -1.65757e+08 -2.3156e+08 -1.07878e+08 -6.16434e+07 -1.62145e+08 -6.95847e+07 -1.04822e+08 -8.77079e+07 -1.76257e+07 -74.8128 +8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -368289 -407156 -507654 -255414 0 -6.70623e+10 -7.41396e+10 -9.24395e+10 -4.65087e+10 -3.93191e+10 -6.32509e+10 -7.68322e+10 -3.48602e+10 -2.18699e+10 -5.2291e+10 -2.21123e+10 -3.11993e+10 -2.61618e+10 -5.26504e+09 1.3152e+08 +9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -366906 -404336 -502742 -252940 0 -6.68105e+10 -7.36261e+10 -9.1545e+10 -4.60582e+10 -3.91714e+10 -6.28755e+10 -7.62227e+10 -3.45676e+10 -2.17185e+10 -5.18538e+10 -2.19213e+10 -3.08974e+10 -2.59085e+10 -5.21405e+09 1.2154e+08 +10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -367764 -406084 -505786 -254475 0 -6.69666e+10 -7.39444e+10 -9.20993e+10 -4.63376e+10 -3.9263e+10 -6.31081e+10 -7.66004e+10 -3.47491e+10 -2.18124e+10 -5.21248e+10 -2.20397e+10 -3.10845e+10 -2.60656e+10 -5.24568e+09 1.27407e+08 +11 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1133.9 -1843.91 -2924.6 -1483.25 0 -2.06474e+08 -3.3576e+08 -5.32545e+08 -2.70086e+08 -1.21057e+08 -2.57765e+08 -3.81922e+08 -1.81728e+08 -9.90436e+07 -2.70414e+08 -1.17681e+08 -1.7974e+08 -1.51444e+08 -3.05753e+07 -5.32884e+06 +12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -183.403 -298.662 -473.996 -240.251 0 -3.33961e+07 -5.43839e+07 -8.63107e+07 -4.37476e+07 -1.95804e+07 -4.17369e+07 -6.18761e+07 -2.94301e+07 -1.60423e+07 -4.38153e+07 -1.90614e+07 -2.91308e+07 -2.45361e+07 -4.95247e+06 -1.08912e+06 +13 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 291.353 474.04 752.045 381.322 0 5.30528e+07 8.63186e+07 1.36941e+08 6.94355e+07 3.11053e+07 6.62589e+07 9.81954e+07 4.67164e+07 2.54626e+07 6.95288e+07 3.02541e+07 4.6219e+07 3.89377e+07 7.86049e+06 1.50556e+06 diff --git a/examples/mliap/compute.quadratic.gg1.dat b/examples/mliap/compute.quadratic.gg1.dat new file mode 100644 index 0000000000..0a6695c1ab --- /dev/null +++ b/examples/mliap/compute.quadratic.gg1.dat @@ -0,0 +1,17 @@ +# Time-averaged data for fix snap +# TimeStep Number-of-rows +# Row c_snap[1] c_snap[2] c_snap[3] c_snap[4] c_snap[5] c_snap[6] c_snap[7] c_snap[8] c_snap[9] c_snap[10] c_snap[11] c_snap[12] c_snap[13] c_snap[14] c_snap[15] c_snap[16] c_snap[17] c_snap[18] c_snap[19] c_snap[20] c_snap[21] c_snap[22] c_snap[23] c_snap[24] c_snap[25] c_snap[26] c_snap[27] c_snap[28] c_snap[29] c_snap[30] c_snap[31] c_snap[32] c_snap[33] c_snap[34] c_snap[35] c_snap[36] c_snap[37] c_snap[38] c_snap[39] c_snap[40] c_snap[41] c_snap[42] c_snap[43] +0 13 +1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 364183 213523 107428 122916 41227.5 3.31573e+10 3.88807e+10 1.95617e+10 2.23819e+10 7.50718e+09 1.1398e+10 1.14692e+10 1.31227e+10 4.40152e+09 2.88519e+09 6.60228e+09 2.21449e+09 3.77706e+09 2.53375e+09 4.24928e+08 322.87 +2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -206.978 -293.105 -434.029 -217.39 0 -3.76889e+07 -5.33719e+07 -7.9033e+07 -3.95849e+07 -2.20973e+07 -4.24099e+07 -5.9058e+07 -2.74755e+07 -1.57438e+07 -4.1327e+07 -1.77189e+07 -2.66745e+07 -2.23073e+07 -4.48124e+06 -20.7188 +3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1277.1 -1841.02 -2752.08 -1381.8 0 -2.3255e+08 -3.35235e+08 -5.0113e+08 -2.51613e+08 -1.36345e+08 -2.65149e+08 -3.72304e+08 -1.73849e+08 -9.88886e+07 -2.6097e+08 -1.12172e+08 -1.69137e+08 -1.41653e+08 -2.8484e+07 -106.829 +4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 804.916 1147.62 1705.6 855.045 0 1.46568e+08 2.08973e+08 3.10574e+08 1.55696e+08 8.59341e+07 1.65757e+08 2.3156e+08 1.07878e+08 6.16434e+07 1.62145e+08 6.95847e+07 1.04822e+08 8.77079e+07 1.76257e+07 74.8128 +5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 206.978 293.105 434.029 217.39 0 3.76889e+07 5.33719e+07 7.9033e+07 3.95849e+07 2.20973e+07 4.24099e+07 5.9058e+07 2.74755e+07 1.57438e+07 4.1327e+07 1.77189e+07 2.66745e+07 2.23073e+07 4.48124e+06 20.7188 +6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1277.1 1841.02 2752.08 1381.8 0 2.3255e+08 3.35235e+08 5.0113e+08 2.51613e+08 1.36345e+08 2.65149e+08 3.72304e+08 1.73849e+08 9.88886e+07 2.6097e+08 1.12172e+08 1.69137e+08 1.41653e+08 2.8484e+07 106.829 +7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -804.916 -1147.62 -1705.6 -855.045 0 -1.46568e+08 -2.08973e+08 -3.10574e+08 -1.55696e+08 -8.59341e+07 -1.65757e+08 -2.3156e+08 -1.07878e+08 -6.16434e+07 -1.62145e+08 -6.95847e+07 -1.04822e+08 -8.77079e+07 -1.76257e+07 -74.8128 +8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -368289 -407156 -507654 -255414 0 -6.70623e+10 -7.41396e+10 -9.24395e+10 -4.65087e+10 -3.93191e+10 -6.32509e+10 -7.68322e+10 -3.48602e+10 -2.18699e+10 -5.2291e+10 -2.21123e+10 -3.11993e+10 -2.61618e+10 -5.26504e+09 1.3152e+08 +9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -366906 -404336 -502742 -252940 0 -6.68105e+10 -7.36261e+10 -9.1545e+10 -4.60582e+10 -3.91714e+10 -6.28755e+10 -7.62227e+10 -3.45676e+10 -2.17185e+10 -5.18538e+10 -2.19213e+10 -3.08974e+10 -2.59085e+10 -5.21405e+09 1.2154e+08 +10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -367764 -406084 -505786 -254475 0 -6.69666e+10 -7.39444e+10 -9.20993e+10 -4.63376e+10 -3.9263e+10 -6.31081e+10 -7.66004e+10 -3.47491e+10 -2.18124e+10 -5.21248e+10 -2.20397e+10 -3.10845e+10 -2.60656e+10 -5.24568e+09 1.27407e+08 +11 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1133.9 -1843.91 -2924.6 -1483.25 0 -2.06474e+08 -3.3576e+08 -5.32545e+08 -2.70086e+08 -1.21057e+08 -2.57765e+08 -3.81922e+08 -1.81728e+08 -9.90436e+07 -2.70414e+08 -1.17681e+08 -1.7974e+08 -1.51444e+08 -3.05753e+07 -5.32884e+06 +12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -183.403 -298.662 -473.996 -240.251 0 -3.33961e+07 -5.43839e+07 -8.63107e+07 -4.37476e+07 -1.95804e+07 -4.17369e+07 -6.18761e+07 -2.94301e+07 -1.60423e+07 -4.38153e+07 -1.90614e+07 -2.91308e+07 -2.45361e+07 -4.95247e+06 -1.08912e+06 +13 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 291.353 474.04 752.045 381.322 0 5.30528e+07 8.63186e+07 1.36941e+08 6.94355e+07 3.11053e+07 6.62589e+07 9.81954e+07 4.67164e+07 2.54626e+07 6.95288e+07 3.02541e+07 4.6219e+07 3.89377e+07 7.86049e+06 1.50556e+06 diff --git a/examples/mliap/compute.snap.gg0.dat b/examples/mliap/compute.snap.gg0.dat new file mode 100644 index 0000000000..4351b21103 --- /dev/null +++ b/examples/mliap/compute.snap.gg0.dat @@ -0,0 +1,17 @@ +# Time-averaged data for fix snap +# TimeStep Number-of-rows +# Row c_snap[1] c_snap[2] c_snap[3] c_snap[4] c_snap[5] c_snap[6] c_snap[7] c_snap[8] c_snap[9] c_snap[10] c_snap[11] c_snap[12] c_snap[13] +0 13 +1 0 0 0 0 0 0 2 364183 213523 107428 122916 41227.5 322.87 +2 0 0 0 0 0 0 0 0 -206.978 -293.105 -434.029 -217.39 -20.7188 +3 0 0 0 0 0 0 0 0 -1277.1 -1841.02 -2752.08 -1381.8 -106.829 +4 0 0 0 0 0 0 0 0 804.916 1147.62 1705.6 855.045 74.8128 +5 0 0 0 0 0 0 0 0 206.978 293.105 434.029 217.39 20.7188 +6 0 0 0 0 0 0 0 0 1277.1 1841.02 2752.08 1381.8 106.829 +7 0 0 0 0 0 0 0 0 -804.916 -1147.62 -1705.6 -855.045 -74.8128 +8 0 0 0 0 0 0 0 0 -368289 -407156 -507654 -255414 1.3152e+08 +9 0 0 0 0 0 0 0 0 -366906 -404336 -502742 -252940 1.2154e+08 +10 0 0 0 0 0 0 0 0 -367764 -406084 -505786 -254475 1.27407e+08 +11 0 0 0 0 0 0 0 0 -1133.9 -1843.91 -2924.6 -1483.25 -5.32884e+06 +12 0 0 0 0 0 0 0 0 -183.403 -298.662 -473.996 -240.251 -1.08912e+06 +13 0 0 0 0 0 0 0 0 291.353 474.04 752.045 381.322 1.50556e+06 diff --git a/examples/mliap/compute.snap.gg1.dat b/examples/mliap/compute.snap.gg1.dat new file mode 100644 index 0000000000..4351b21103 --- /dev/null +++ b/examples/mliap/compute.snap.gg1.dat @@ -0,0 +1,17 @@ +# Time-averaged data for fix snap +# TimeStep Number-of-rows +# Row c_snap[1] c_snap[2] c_snap[3] c_snap[4] c_snap[5] c_snap[6] c_snap[7] c_snap[8] c_snap[9] c_snap[10] c_snap[11] c_snap[12] c_snap[13] +0 13 +1 0 0 0 0 0 0 2 364183 213523 107428 122916 41227.5 322.87 +2 0 0 0 0 0 0 0 0 -206.978 -293.105 -434.029 -217.39 -20.7188 +3 0 0 0 0 0 0 0 0 -1277.1 -1841.02 -2752.08 -1381.8 -106.829 +4 0 0 0 0 0 0 0 0 804.916 1147.62 1705.6 855.045 74.8128 +5 0 0 0 0 0 0 0 0 206.978 293.105 434.029 217.39 20.7188 +6 0 0 0 0 0 0 0 0 1277.1 1841.02 2752.08 1381.8 106.829 +7 0 0 0 0 0 0 0 0 -804.916 -1147.62 -1705.6 -855.045 -74.8128 +8 0 0 0 0 0 0 0 0 -368289 -407156 -507654 -255414 1.3152e+08 +9 0 0 0 0 0 0 0 0 -366906 -404336 -502742 -252940 1.2154e+08 +10 0 0 0 0 0 0 0 0 -367764 -406084 -505786 -254475 1.27407e+08 +11 0 0 0 0 0 0 0 0 -1133.9 -1843.91 -2924.6 -1483.25 -5.32884e+06 +12 0 0 0 0 0 0 0 0 -183.403 -298.662 -473.996 -240.251 -1.08912e+06 +13 0 0 0 0 0 0 0 0 291.353 474.04 752.045 381.322 1.50556e+06 diff --git a/examples/mliap/log.Ta06_v2 b/examples/mliap/log.Ta06_v2 new file mode 100644 index 0000000000..64b37a45c5 --- /dev/null +++ b/examples/mliap/log.Ta06_v2 @@ -0,0 +1,156 @@ +LAMMPS (10 Feb 2021) +# Demonstrate MLIAP interface to linear SNAP potential + +# Initialize simulation + +variable nsteps index 100 +variable nrep equal 4 +variable a equal 3.316 +units metal + +# generate the box and atom positions using a BCC lattice + +variable nx equal ${nrep} +variable nx equal 4 +variable ny equal ${nrep} +variable ny equal 4 +variable nz equal ${nrep} +variable nz equal 4 + +boundary p p p + +lattice bcc $a +lattice bcc 3.316 +Lattice spacing in x,y,z = 3.3160000 3.3160000 3.3160000 +region box block 0 ${nx} 0 ${ny} 0 ${nz} +region box block 0 4 0 ${ny} 0 ${nz} +region box block 0 4 0 4 0 ${nz} +region box block 0 4 0 4 0 4 +create_box 1 box +Created orthogonal box = (0.0000000 0.0000000 0.0000000) to (13.264000 13.264000 13.264000) + 1 by 1 by 1 MPI processor grid +create_atoms 1 box +Created 128 atoms + create_atoms CPU = 0.000 seconds + +mass 1 180.88 + +# choose potential + +include Ta06A.mliap +# DATE: 2014-09-05 UNITS: metal CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: Thompson, Swiler, Trott, Foiles and Tucker, arxiv.org, 1409.3880 (2014) + +# Definition of SNAP potential Ta_Cand06A +# Assumes 1 LAMMPS atom type + +variable zblcutinner equal 4 +variable zblcutouter equal 4.8 +variable zblz equal 73 + +# Specify hybrid with SNAP, ZBL + +pair_style hybrid/overlay zbl ${zblcutinner} ${zblcutouter} mliap model linear Ta06A.mliap.model descriptor sna Ta06A.mliap.descriptor +pair_style hybrid/overlay zbl 4 ${zblcutouter} mliap model linear Ta06A.mliap.model descriptor sna Ta06A.mliap.descriptor +pair_style hybrid/overlay zbl 4 4.8 mliap model linear Ta06A.mliap.model descriptor sna Ta06A.mliap.descriptor +Reading potential file Ta06A.mliap.model with DATE: 2014-09-05 +Reading potential file Ta06A.mliap.descriptor with DATE: 2014-09-05 +SNAP keyword rcutfac 4.67637 +SNAP keyword twojmax 6 +SNAP keyword nelems 1 +SNAP keyword elems Ta +SNAP keyword radelems 0.5 +SNAP keyword welems 1 +SNAP keyword rfac0 0.99363 +SNAP keyword rmin0 0 +SNAP keyword bzeroflag 0 +pair_coeff 1 1 zbl ${zblz} ${zblz} +pair_coeff 1 1 zbl 73 ${zblz} +pair_coeff 1 1 zbl 73 73 +pair_coeff * * mliap Ta + + +# Setup output + +compute eatom all pe/atom +compute energy all reduce sum c_eatom + +compute satom all stress/atom NULL +compute str all reduce sum c_satom[1] c_satom[2] c_satom[3] +variable press equal (c_str[1]+c_str[2]+c_str[3])/(3*vol) + +thermo_style custom step temp epair c_energy etotal press v_press +thermo 10 +thermo_modify norm yes + +# Set up NVE run + +timestep 0.5e-3 +neighbor 1.0 bin +neigh_modify once no every 1 delay 0 check yes + +# Run MD + +velocity all create 300.0 4928459 loop geom +fix 1 all nve +run ${nsteps} +run 100 +Neighbor list info ... + update every 1 steps, delay 0 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 5.8 + ghost atom cutoff = 5.8 + binsize = 2.9, bins = 5 5 5 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair zbl, perpetual, half/full from (2) + attributes: half, newton on + pair build: halffull/newton + stencil: none + bin: none + (2) pair mliap, perpetual + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 18.15 | 18.15 | 18.15 Mbytes +Step Temp E_pair c_energy TotEng Press v_press + 0 300 -11.85157 -11.85157 -11.813095 2717.1661 -2717.1661 + 10 296.01467 -11.851059 -11.851059 -11.813095 2697.4796 -2697.4796 + 20 284.53666 -11.849587 -11.849587 -11.813095 2289.1527 -2289.1527 + 30 266.51577 -11.847275 -11.847275 -11.813095 1851.7131 -1851.7131 + 40 243.05007 -11.844266 -11.844266 -11.813095 1570.684 -1570.684 + 50 215.51032 -11.840734 -11.840734 -11.813094 1468.1899 -1468.1899 + 60 185.48331 -11.836883 -11.836883 -11.813094 1524.8757 -1524.8757 + 70 154.6736 -11.832931 -11.832931 -11.813094 1698.3351 -1698.3351 + 80 124.79303 -11.829099 -11.829099 -11.813094 1947.0715 -1947.0715 + 90 97.448054 -11.825592 -11.825592 -11.813094 2231.9563 -2231.9563 + 100 74.035418 -11.822589 -11.822589 -11.813094 2515.8526 -2515.8526 +Loop time of 1.80936 on 1 procs for 100 steps with 128 atoms + +Performance: 2.388 ns/day, 10.052 hours/ns, 55.268 timesteps/s +80.9% CPU use with 1 MPI tasks x no OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 1.8055 | 1.8055 | 1.8055 | 0.0 | 99.78 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 0.00133 | 0.00133 | 0.00133 | 0.0 | 0.07 +Output | 0.001145 | 0.001145 | 0.001145 | 0.0 | 0.06 +Modify | 0.000669 | 0.000669 | 0.000669 | 0.0 | 0.04 +Other | | 0.000749 | | | 0.04 + +Nlocal: 128.000 ave 128 max 128 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 727.000 ave 727 max 727 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 3712.00 ave 3712 max 3712 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +FullNghs: 7424.00 ave 7424 max 7424 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 7424 +Ave neighs/atom = 58.000000 +Neighbor list builds = 0 +Dangerous builds = 0 + +Total wall time: 0:00:01 diff --git a/examples/mliap/log.WBe_v2 b/examples/mliap/log.WBe_v2 new file mode 100644 index 0000000000..74e3a934ac --- /dev/null +++ b/examples/mliap/log.WBe_v2 @@ -0,0 +1,167 @@ +LAMMPS (10 Feb 2021) +# Demonstrate MLIAP interface to SNAP W-Be potential + +# Initialize simulation + +variable nsteps index 100 +variable nrep equal 4 +variable a equal 3.1803 +units metal + +# generate the box and atom positions using a BCC lattice + +variable nx equal ${nrep} +variable nx equal 4 +variable ny equal ${nrep} +variable ny equal 4 +variable nz equal ${nrep} +variable nz equal 4 + +boundary p p p + +lattice bcc $a +lattice bcc 3.1803 +Lattice spacing in x,y,z = 3.1803000 3.1803000 3.1803000 +region box block 0 ${nx} 0 ${ny} 0 ${nz} +region box block 0 4 0 ${ny} 0 ${nz} +region box block 0 4 0 4 0 ${nz} +region box block 0 4 0 4 0 4 +create_box 2 box +Created orthogonal box = (0.0000000 0.0000000 0.0000000) to (12.721200 12.721200 12.721200) + 1 by 1 by 1 MPI processor grid +create_atoms 1 box +Created 128 atoms + create_atoms CPU = 0.000 seconds +mass 1 183.84 +mass 2 9.012182 + +set group all type/fraction 2 0.05 3590153 # Change 5% of W to He +Setting atom values ... + 5 settings made for type/fraction +group tungsten type 1 +123 atoms in group tungsten +group beryllium type 2 +5 atoms in group beryllium +# choose potential + +include WBe_Wood_PRB2019.mliap +# DATE: 2019-09-18 UNITS: metal CONTRIBUTOR: Mary Alice Cusentino mcusent@sandia.gov CITATION: M.A. Wood, M.A. Cusentino, B.D. Wirth, and A.P. Thompson, "Data-driven material models for atomistic simulation", Physical Review B 99, 184305 (2019) +# Definition of SNAP+ZBL potential. +variable zblcutinner equal 4 +variable zblcutouter equal 4.8 +variable zblz1 equal 74 +variable zblz2 equal 4 + +# Specify hybrid with SNAP and ZBL + +pair_style hybrid/overlay zbl ${zblcutinner} ${zblcutouter} mliap model linear WBe_Wood_PRB2019.mliap.model descriptor sna WBe_Wood_PRB2019.mliap.descriptor +pair_style hybrid/overlay zbl 4 ${zblcutouter} mliap model linear WBe_Wood_PRB2019.mliap.model descriptor sna WBe_Wood_PRB2019.mliap.descriptor +pair_style hybrid/overlay zbl 4 4.8 mliap model linear WBe_Wood_PRB2019.mliap.model descriptor sna WBe_Wood_PRB2019.mliap.descriptor +Reading potential file WBe_Wood_PRB2019.mliap.model with DATE: 2019-09-18 +Reading potential file WBe_Wood_PRB2019.mliap.descriptor with DATE: 2019-09-18 +SNAP keyword rcutfac 4.8123 +SNAP keyword twojmax 8 +SNAP keyword nelems 2 +SNAP keyword elems W +SNAP keyword radelems 0.5 +SNAP keyword welems 1 +SNAP keyword rfac0 0.99363 +SNAP keyword rmin0 0 +SNAP keyword bzeroflag 1 +pair_coeff 1 1 zbl ${zblz1} ${zblz1} +pair_coeff 1 1 zbl 74 ${zblz1} +pair_coeff 1 1 zbl 74 74 +pair_coeff 1 2 zbl ${zblz1} ${zblz2} +pair_coeff 1 2 zbl 74 ${zblz2} +pair_coeff 1 2 zbl 74 4 +pair_coeff 2 2 zbl ${zblz2} ${zblz2} +pair_coeff 2 2 zbl 4 ${zblz2} +pair_coeff 2 2 zbl 4 4 +pair_coeff * * mliap W Be + + +# Setup output + +compute eatom all pe/atom +compute energy all reduce sum c_eatom + +compute satom all stress/atom NULL +compute str all reduce sum c_satom[1] c_satom[2] c_satom[3] +variable press equal (c_str[1]+c_str[2]+c_str[3])/(3*vol) + +thermo_style custom step temp epair c_energy etotal press v_press +thermo 10 +thermo_modify norm yes + +# Set up NVE run + +timestep 0.5e-3 +neighbor 1.0 bin +neigh_modify once no every 1 delay 0 check yes + +# Run MD + +velocity all create 300.0 4928459 loop geom +fix 1 all nve +run ${nsteps} +run 100 +Neighbor list info ... + update every 1 steps, delay 0 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 5.8123 + ghost atom cutoff = 5.8123 + binsize = 2.90615, bins = 5 5 5 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair zbl, perpetual, half/full from (2) + attributes: half, newton on + pair build: halffull/newton + stencil: none + bin: none + (2) pair mliap, perpetual + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 48.80 | 48.80 | 48.80 Mbytes +Step Temp E_pair c_energy TotEng Press v_press + 0 300 -8.5980876 -8.5980876 -8.5596125 -35284.855 35284.855 + 10 296.32664 -8.5976164 -8.5976164 -8.5596124 -35188.339 35188.339 + 20 282.41417 -8.595832 -8.595832 -8.5596123 -34782.293 34782.293 + 30 259.69014 -8.5929175 -8.5929175 -8.5596121 -34113.316 34113.316 + 40 230.50415 -8.5891741 -8.5891741 -8.5596119 -33260.777 33260.777 + 50 197.88816 -8.5849908 -8.5849908 -8.5596116 -32309.975 32309.975 + 60 165.27259 -8.5808076 -8.5808076 -8.5596113 -31365.766 31365.766 + 70 136.15697 -8.5770733 -8.5770733 -8.5596111 -30542.657 30542.657 + 80 113.58947 -8.5741788 -8.5741788 -8.5596109 -29939.23 29939.23 + 90 99.477916 -8.572369 -8.572369 -8.5596109 -29619.939 29619.939 + 100 94.121939 -8.5716822 -8.5716822 -8.559611 -29598.002 29598.002 +Loop time of 5.14269 on 1 procs for 100 steps with 128 atoms + +Performance: 0.840 ns/day, 28.570 hours/ns, 19.445 timesteps/s +82.5% CPU use with 1 MPI tasks x no OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 5.1376 | 5.1376 | 5.1376 | 0.0 | 99.90 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 0.001657 | 0.001657 | 0.001657 | 0.0 | 0.03 +Output | 0.002107 | 0.002107 | 0.002107 | 0.0 | 0.04 +Modify | 0.00052 | 0.00052 | 0.00052 | 0.0 | 0.01 +Other | | 0.00078 | | | 0.02 + +Nlocal: 128.000 ave 128 max 128 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 727.000 ave 727 max 727 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 3712.00 ave 3712 max 3712 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +FullNghs: 7424.00 ave 7424 max 7424 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 7424 +Ave neighs/atom = 58.000000 +Neighbor list builds = 0 +Dangerous builds = 0 + +Total wall time: 0:00:05 diff --git a/examples/mliap/log.chem_v2 b/examples/mliap/log.chem_v2 new file mode 100644 index 0000000000..801ea84c53 --- /dev/null +++ b/examples/mliap/log.chem_v2 @@ -0,0 +1,158 @@ +LAMMPS (10 Feb 2021) +# Demonstrate MLIAP interface to ChemSNAP potential + +# Initialize simulation + +variable nsteps index 100 +variable nrep equal 4 +variable a equal 5.83 +units metal + +# generate the box and atom positions using a FCC lattice + +variable nx equal ${nrep} +variable nx equal 4 +variable ny equal ${nrep} +variable ny equal 4 +variable nz equal ${nrep} +variable nz equal 4 + +boundary p p p + +lattice diamond $a +lattice diamond 5.83 +Lattice spacing in x,y,z = 5.8300000 5.8300000 5.8300000 +region box block 0 ${nx} 0 ${ny} 0 ${nz} +region box block 0 4 0 ${ny} 0 ${nz} +region box block 0 4 0 4 0 ${nz} +region box block 0 4 0 4 0 4 +create_box 2 box +Created orthogonal box = (0.0000000 0.0000000 0.0000000) to (23.320000 23.320000 23.320000) + 1 by 1 by 1 MPI processor grid +create_atoms 1 box basis 5 2 basis 6 2 basis 7 2 basis 8 2 +Created 512 atoms + create_atoms CPU = 0.000 seconds + +mass 1 114.76 +mass 2 30.98 + +# choose potential + +include InP_JCPA2020.mliap +# DATE: 2020-06-01 UNITS: metal CONTRIBUTOR: Mary Alice Cusentino mcusent@sandia.gov CITATION: M.A. Cusentino, M. A. Wood, and A.P. Thompson, "Explicit Multi-element Extension of the Spectral Neighbor Analysis Potential for Chemically Complex Systems", J. Phys. Chem. A, xxxxxx (2020) + +# Definition of SNAP+ZBL potential. + +variable zblcutinner index 4 +variable zblcutouter index 4.2 +variable zblz1 index 49 +variable zblz2 index 15 + +# Specify hybrid with SNAP and ZBL + +pair_style hybrid/overlay zbl ${zblcutinner} ${zblcutouter} mliap model linear InP_JCPA2020.mliap.model descriptor sna InP_JCPA2020.mliap.descriptor +pair_style hybrid/overlay zbl 4 ${zblcutouter} mliap model linear InP_JCPA2020.mliap.model descriptor sna InP_JCPA2020.mliap.descriptor +pair_style hybrid/overlay zbl 4 4.2 mliap model linear InP_JCPA2020.mliap.model descriptor sna InP_JCPA2020.mliap.descriptor +Reading potential file InP_JCPA2020.mliap.model with DATE: 2020-06-01 +Reading potential file InP_JCPA2020.mliap.descriptor with DATE: 2020-06-01 +SNAP keyword rcutfac 1.0 +SNAP keyword twojmax 6 +SNAP keyword nelems 2 +SNAP keyword elems In +SNAP keyword radelems 3.81205 +SNAP keyword welems 1 +SNAP keyword rfac0 0.99363 +SNAP keyword rmin0 0.0 +SNAP keyword bzeroflag 1 +SNAP keyword wselfallflag 1 +SNAP keyword chemflag 1 +SNAP keyword bnormflag 1 +pair_coeff 1 1 zbl ${zblz1} ${zblz1} +pair_coeff 1 1 zbl 49 ${zblz1} +pair_coeff 1 1 zbl 49 49 +pair_coeff 1 2 zbl ${zblz1} ${zblz2} +pair_coeff 1 2 zbl 49 ${zblz2} +pair_coeff 1 2 zbl 49 15 +pair_coeff 2 2 zbl ${zblz2} ${zblz2} +pair_coeff 2 2 zbl 15 ${zblz2} +pair_coeff 2 2 zbl 15 15 +pair_coeff * * mliap In P + + +# Setup output + +thermo 10 +thermo_modify norm yes + +# Set up NVE run + +timestep 0.5e-3 +neighbor 1.0 bin +neigh_modify once no every 1 delay 0 check yes + +# Run MD + +velocity all create 300.0 4928459 loop geom +fix 1 all nve +run ${nsteps} +run 100 +Neighbor list info ... + update every 1 steps, delay 0 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 8.6589 + ghost atom cutoff = 8.6589 + binsize = 4.32945, bins = 6 6 6 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair zbl, perpetual, half/full from (2) + attributes: half, newton on + pair build: halffull/newton + stencil: none + bin: none + (2) pair mliap, perpetual + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 187.1 | 187.1 | 187.1 Mbytes +Step Temp E_pair E_mol TotEng Press + 0 300 -3.4805794 0 -3.4418771 1353.5968 + 10 285.84677 -3.4787531 0 -3.4418766 1611.7131 + 20 248.14649 -3.4738884 0 -3.4418756 2312.0308 + 30 198.94136 -3.4675394 0 -3.4418744 3168.1543 + 40 152.74831 -3.4615791 0 -3.4418734 3903.5749 + 50 121.9796 -3.4576091 0 -3.4418728 4387.1254 + 60 113.27555 -3.4564863 0 -3.4418729 4556.3003 + 70 125.68089 -3.4580873 0 -3.4418735 4431.2083 + 80 151.47475 -3.4614159 0 -3.4418745 4107.2369 + 90 179.18708 -3.4649919 0 -3.4418754 3739.5881 + 100 197.50662 -3.4673559 0 -3.441876 3492.7778 +Loop time of 24.0349 on 1 procs for 100 steps with 512 atoms + +Performance: 0.180 ns/day, 133.527 hours/ns, 4.161 timesteps/s +92.5% CPU use with 1 MPI tasks x no OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 24.031 | 24.031 | 24.031 | 0.0 | 99.99 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 0.001691 | 0.001691 | 0.001691 | 0.0 | 0.01 +Output | 0.00034 | 0.00034 | 0.00034 | 0.0 | 0.00 +Modify | 0.00082 | 0.00082 | 0.00082 | 0.0 | 0.00 +Other | | 0.000746 | | | 0.00 + +Nlocal: 512.000 ave 512 max 512 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 1959.00 ave 1959 max 1959 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 31232.0 ave 31232 max 31232 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +FullNghs: 62464.0 ave 62464 max 62464 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 62464 +Ave neighs/atom = 122.00000 +Neighbor list builds = 0 +Dangerous builds = 0 + +Total wall time: 0:00:24 diff --git a/examples/mliap/log.compute_v2 b/examples/mliap/log.compute_v2 new file mode 100644 index 0000000000..859afe2eac --- /dev/null +++ b/examples/mliap/log.compute_v2 @@ -0,0 +1,282 @@ +LAMMPS (10 Feb 2021) +# Demonstrate bispectrum computes + +# initialize simulation + +variable nsteps index 0 +variable nrep equal 1 +variable a equal 2.0 +units metal + +# generate the box and atom positions using a BCC lattice + +variable nx equal ${nrep} +variable nx equal 1 +variable ny equal ${nrep} +variable ny equal 1 +variable nz equal ${nrep} +variable nz equal 1 + +boundary p p p + +atom_modify map hash +lattice bcc $a +lattice bcc 2 +Lattice spacing in x,y,z = 2.0000000 2.0000000 2.0000000 +region box block 0 ${nx} 0 ${ny} 0 ${nz} +region box block 0 1 0 ${ny} 0 ${nz} +region box block 0 1 0 1 0 ${nz} +region box block 0 1 0 1 0 1 +create_box 2 box +Created orthogonal box = (0.0000000 0.0000000 0.0000000) to (2.0000000 2.0000000 2.0000000) + 1 by 1 by 1 MPI processor grid +create_atoms 2 box +Created 2 atoms + create_atoms CPU = 0.001 seconds + +mass * 180.88 + +displace_atoms all random 0.1 0.1 0.1 123456 +Displacing atoms ... + +# set up reference potential + +variable zblcutinner equal 4 +variable zblcutouter equal 4.8 +variable zblz equal 73 +pair_style zbl ${zblcutinner} ${zblcutouter} +pair_style zbl 4 ${zblcutouter} +pair_style zbl 4 4.8 +pair_coeff * * ${zblz} ${zblz} +pair_coeff * * 73 ${zblz} +pair_coeff * * 73 73 + +# choose SNA parameters + +variable twojmax equal 2 +variable rcutfac equal 1.0 +variable rfac0 equal 0.99363 +variable rmin0 equal 0 +variable radelem1 equal 2.3 +variable radelem2 equal 2.0 +variable wj1 equal 1.0 +variable wj2 equal 0.96 +variable quadratic equal 0 +variable bzero equal 0 +variable switch equal 0 +variable snap_options string "${rcutfac} ${rfac0} ${twojmax} ${radelem1} ${radelem2} ${wj1} ${wj2} rmin0 ${rmin0} quadraticflag ${quadratic} bzeroflag ${bzero} switchflag ${switch}" +1 ${rfac0} ${twojmax} ${radelem1} ${radelem2} ${wj1} ${wj2} rmin0 ${rmin0} quadraticflag ${quadratic} bzeroflag ${bzero} switchflag ${switch} +1 0.99363 ${twojmax} ${radelem1} ${radelem2} ${wj1} ${wj2} rmin0 ${rmin0} quadraticflag ${quadratic} bzeroflag ${bzero} switchflag ${switch} +1 0.99363 2 ${radelem1} ${radelem2} ${wj1} ${wj2} rmin0 ${rmin0} quadraticflag ${quadratic} bzeroflag ${bzero} switchflag ${switch} +1 0.99363 2 2.3 ${radelem2} ${wj1} ${wj2} rmin0 ${rmin0} quadraticflag ${quadratic} bzeroflag ${bzero} switchflag ${switch} +1 0.99363 2 2.3 2 ${wj1} ${wj2} rmin0 ${rmin0} quadraticflag ${quadratic} bzeroflag ${bzero} switchflag ${switch} +1 0.99363 2 2.3 2 1 ${wj2} rmin0 ${rmin0} quadraticflag ${quadratic} bzeroflag ${bzero} switchflag ${switch} +1 0.99363 2 2.3 2 1 0.96 rmin0 ${rmin0} quadraticflag ${quadratic} bzeroflag ${bzero} switchflag ${switch} +1 0.99363 2 2.3 2 1 0.96 rmin0 0 quadraticflag ${quadratic} bzeroflag ${bzero} switchflag ${switch} +1 0.99363 2 2.3 2 1 0.96 rmin0 0 quadraticflag 0 bzeroflag ${bzero} switchflag ${switch} +1 0.99363 2 2.3 2 1 0.96 rmin0 0 quadraticflag 0 bzeroflag 0 switchflag ${switch} +1 0.99363 2 2.3 2 1 0.96 rmin0 0 quadraticflag 0 bzeroflag 0 switchflag 0 + +# set up per-atom computes + +compute b all sna/atom ${snap_options} +compute b all sna/atom 1 0.99363 2 2.3 2 1 0.96 rmin0 0 quadraticflag 0 bzeroflag 0 switchflag 0 +compute vb all snav/atom ${snap_options} +compute vb all snav/atom 1 0.99363 2 2.3 2 1 0.96 rmin0 0 quadraticflag 0 bzeroflag 0 switchflag 0 +compute db all snad/atom ${snap_options} +compute db all snad/atom 1 0.99363 2 2.3 2 1 0.96 rmin0 0 quadraticflag 0 bzeroflag 0 switchflag 0 + +# perform sums over atoms + +group snapgroup1 type 1 +0 atoms in group snapgroup1 +group snapgroup2 type 2 +2 atoms in group snapgroup2 +compute bsum1 snapgroup1 reduce sum c_b[*] +compute bsum2 snapgroup2 reduce sum c_b[*] +# fix bsum1 all ave/time 1 1 1 c_bsum1 file bsum1.dat mode vector +# fix bsum2 all ave/time 1 1 1 c_bsum2 file bsum2.dat mode vector +compute vbsum all reduce sum c_vb[*] +# fix vbsum all ave/time 1 1 1 c_vbsum file vbsum.dat mode vector +variable db_2_25 equal c_db[2][25] + +thermo 100 + +# test output: 1: total potential energy +# 2: xy component of stress tensor +# 3: Sum(B_{000}^i, all i of type 2) +# 4: xz component of Sum(Sum(r_j*dB_{222}^i/dR[j]), all i of type 2), all j) +# 5: y component of -Sum(d(B_{222}^i)/dR[2]), all i of type 2) +# +# followed by 5 counterparts from compute snap + +# run compute mliap with gradgradflag = 1 + +compute snap all mliap descriptor sna compute.mliap.descriptor model linear gradgradflag 1 +SNAP keyword rcutfac 1.0 +SNAP keyword twojmax 2 +SNAP keyword nelems 2 +SNAP keyword elems A +SNAP keyword radelems 2.3 +SNAP keyword welems 1.0 +SNAP keyword rfac0 0.99363 +SNAP keyword rmin0 0 +SNAP keyword bzeroflag 0 +SNAP keyword switchflag 0 +fix snap all ave/time 1 1 1 c_snap[*] file compute.snap.gg1.dat mode vector + +thermo_style custom pe pxy c_bsum2[1] c_vbsum[55] v_db_2_25 c_snap[1][13] c_snap[13][13] c_snap[1][8] c_snap[12][12] c_snap[6][12] +thermo_modify norm no + +run ${nsteps} +run 0 +Neighbor list info ... + update every 1 steps, delay 10 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 6.8 + ghost atom cutoff = 6.8 + binsize = 3.4, bins = 1 1 1 + 5 neighbor lists, perpetual/occasional/extra = 1 4 0 + (1) pair zbl, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/3d/newton + bin: standard + (2) compute sna/atom, occasional + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard + (3) compute snav/atom, occasional + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard + (4) compute snad/atom, occasional + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard + (5) compute mliap, occasional + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 10.75 | 10.75 | 10.75 Mbytes +PotEng Pxy c_bsum2[1] c_vbsum[55] v_db_2_25 c_snap[1][13] c_snap[13][13] c_snap[1][8] c_snap[12][12] c_snap[6][12] + 322.86952 1505558.1 364182.88 -240.25066 1381.7961 322.86952 1505558.1 364182.88 -240.25066 1381.7961 +Loop time of 1e-06 on 1 procs for 0 steps with 2 atoms + +200.0% CPU use with 1 MPI tasks x no OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0 | 0 | 0 | 0.0 | 0.00 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 0 | 0 | 0 | 0.0 | 0.00 +Output | 0 | 0 | 0 | 0.0 | 0.00 +Modify | 0 | 0 | 0 | 0.0 | 0.00 +Other | | 1e-06 | | |100.00 + +Nlocal: 2.00000 ave 2 max 2 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 853.000 ave 853 max 853 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 330.000 ave 330 max 330 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +FullNghs: 660.000 ave 660 max 660 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 660 +Ave neighs/atom = 330.00000 +Neighbor list builds = 0 +Dangerous builds = 0 + +uncompute snap +unfix snap + +# run compute mliap with gradgradflag = 0 + +compute snap all mliap descriptor sna compute.mliap.descriptor model linear gradgradflag 0 +SNAP keyword rcutfac 1.0 +SNAP keyword twojmax 2 +SNAP keyword nelems 2 +SNAP keyword elems A +SNAP keyword radelems 2.3 +SNAP keyword welems 1.0 +SNAP keyword rfac0 0.99363 +SNAP keyword rmin0 0 +SNAP keyword bzeroflag 0 +SNAP keyword switchflag 0 +fix snap all ave/time 1 1 1 c_snap[*] file compute.snap.gg0.dat mode vector + +thermo_style custom pe pxy c_bsum2[1] c_vbsum[55] v_db_2_25 c_snap[1][13] c_snap[13][13] c_snap[1][8] c_snap[12][12] c_snap[6][12] +WARNING: New thermo_style command, previous thermo_modify settings will be lost (../output.cpp:691) +thermo_modify norm no + +run ${nsteps} +run 0 +Neighbor list info ... + update every 1 steps, delay 10 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 6.8 + ghost atom cutoff = 6.8 + binsize = 3.4, bins = 1 1 1 + 5 neighbor lists, perpetual/occasional/extra = 1 4 0 + (1) pair zbl, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/3d/newton + bin: standard + (2) compute sna/atom, occasional + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard + (3) compute snav/atom, occasional + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard + (4) compute snad/atom, occasional + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard + (5) compute mliap, occasional + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 22.89 | 22.89 | 22.89 Mbytes +PotEng Pxy c_bsum2[1] c_vbsum[55] v_db_2_25 c_snap[1][13] c_snap[13][13] c_snap[1][8] c_snap[12][12] c_snap[6][12] + 322.86952 1505558.1 364182.88 -240.25066 1381.7961 322.86952 1505558.1 364182.88 -240.25066 1381.7961 +Loop time of 1e-06 on 1 procs for 0 steps with 2 atoms + +100.0% CPU use with 1 MPI tasks x no OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0 | 0 | 0 | 0.0 | 0.00 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 0 | 0 | 0 | 0.0 | 0.00 +Output | 0 | 0 | 0 | 0.0 | 0.00 +Modify | 0 | 0 | 0 | 0.0 | 0.00 +Other | | 1e-06 | | |100.00 + +Nlocal: 2.00000 ave 2 max 2 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 853.000 ave 853 max 853 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 330.000 ave 330 max 330 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +FullNghs: 660.000 ave 660 max 660 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 660 +Ave neighs/atom = 330.00000 +Neighbor list builds = 0 +Dangerous builds = 0 +Total wall time: 0:00:00 diff --git a/examples/mliap/log.quadratic_compute_v2 b/examples/mliap/log.quadratic_compute_v2 new file mode 100644 index 0000000000..ed623ac105 --- /dev/null +++ b/examples/mliap/log.quadratic_compute_v2 @@ -0,0 +1,282 @@ +LAMMPS (10 Feb 2021) +# Demonstrate MLIAP quadratic compute + +# initialize simulation + +variable nsteps index 0 +variable nrep equal 1 +variable a equal 2.0 +units metal + +# generate the box and atom positions using a BCC lattice + +variable nx equal ${nrep} +variable nx equal 1 +variable ny equal ${nrep} +variable ny equal 1 +variable nz equal ${nrep} +variable nz equal 1 + +boundary p p p + +atom_modify map hash +lattice bcc $a +lattice bcc 2 +Lattice spacing in x,y,z = 2.0000000 2.0000000 2.0000000 +region box block 0 ${nx} 0 ${ny} 0 ${nz} +region box block 0 1 0 ${ny} 0 ${nz} +region box block 0 1 0 1 0 ${nz} +region box block 0 1 0 1 0 1 +create_box 2 box +Created orthogonal box = (0.0000000 0.0000000 0.0000000) to (2.0000000 2.0000000 2.0000000) + 1 by 1 by 1 MPI processor grid +create_atoms 2 box +Created 2 atoms + create_atoms CPU = 0.001 seconds + +mass * 180.88 + +displace_atoms all random 0.1 0.1 0.1 123456 +Displacing atoms ... + +# set up reference potential + +variable zblcutinner equal 4 +variable zblcutouter equal 4.8 +variable zblz equal 73 +pair_style zbl ${zblcutinner} ${zblcutouter} +pair_style zbl 4 ${zblcutouter} +pair_style zbl 4 4.8 +pair_coeff * * ${zblz} ${zblz} +pair_coeff * * 73 ${zblz} +pair_coeff * * 73 73 + +# choose SNA parameters + +variable twojmax equal 2 +variable rcutfac equal 1.0 +variable rfac0 equal 0.99363 +variable rmin0 equal 0 +variable radelem1 equal 2.3 +variable radelem2 equal 2.0 +variable wj1 equal 1.0 +variable wj2 equal 0.96 +variable quadratic equal 1 +variable bzero equal 0 +variable switch equal 0 +variable snap_options string "${rcutfac} ${rfac0} ${twojmax} ${radelem1} ${radelem2} ${wj1} ${wj2} rmin0 ${rmin0} quadraticflag ${quadratic} bzeroflag ${bzero} switchflag ${switch}" +1 ${rfac0} ${twojmax} ${radelem1} ${radelem2} ${wj1} ${wj2} rmin0 ${rmin0} quadraticflag ${quadratic} bzeroflag ${bzero} switchflag ${switch} +1 0.99363 ${twojmax} ${radelem1} ${radelem2} ${wj1} ${wj2} rmin0 ${rmin0} quadraticflag ${quadratic} bzeroflag ${bzero} switchflag ${switch} +1 0.99363 2 ${radelem1} ${radelem2} ${wj1} ${wj2} rmin0 ${rmin0} quadraticflag ${quadratic} bzeroflag ${bzero} switchflag ${switch} +1 0.99363 2 2.3 ${radelem2} ${wj1} ${wj2} rmin0 ${rmin0} quadraticflag ${quadratic} bzeroflag ${bzero} switchflag ${switch} +1 0.99363 2 2.3 2 ${wj1} ${wj2} rmin0 ${rmin0} quadraticflag ${quadratic} bzeroflag ${bzero} switchflag ${switch} +1 0.99363 2 2.3 2 1 ${wj2} rmin0 ${rmin0} quadraticflag ${quadratic} bzeroflag ${bzero} switchflag ${switch} +1 0.99363 2 2.3 2 1 0.96 rmin0 ${rmin0} quadraticflag ${quadratic} bzeroflag ${bzero} switchflag ${switch} +1 0.99363 2 2.3 2 1 0.96 rmin0 0 quadraticflag ${quadratic} bzeroflag ${bzero} switchflag ${switch} +1 0.99363 2 2.3 2 1 0.96 rmin0 0 quadraticflag 1 bzeroflag ${bzero} switchflag ${switch} +1 0.99363 2 2.3 2 1 0.96 rmin0 0 quadraticflag 1 bzeroflag 0 switchflag ${switch} +1 0.99363 2 2.3 2 1 0.96 rmin0 0 quadraticflag 1 bzeroflag 0 switchflag 0 + +# set up per-atom computes + +compute b all sna/atom ${snap_options} +compute b all sna/atom 1 0.99363 2 2.3 2 1 0.96 rmin0 0 quadraticflag 1 bzeroflag 0 switchflag 0 +compute vb all snav/atom ${snap_options} +compute vb all snav/atom 1 0.99363 2 2.3 2 1 0.96 rmin0 0 quadraticflag 1 bzeroflag 0 switchflag 0 +compute db all snad/atom ${snap_options} +compute db all snad/atom 1 0.99363 2 2.3 2 1 0.96 rmin0 0 quadraticflag 1 bzeroflag 0 switchflag 0 + +# perform sums over atoms + +group snapgroup1 type 1 +0 atoms in group snapgroup1 +group snapgroup2 type 2 +2 atoms in group snapgroup2 +compute bsum1 snapgroup1 reduce sum c_b[*] +compute bsum2 snapgroup2 reduce sum c_b[*] +# fix bsum1 all ave/time 1 1 1 c_bsum1 file bsum1.dat mode vector +# fix bsum2 all ave/time 1 1 1 c_bsum2 file bsum2.dat mode vector +compute vbsum all reduce sum c_vb[*] +# fix vbsum all ave/time 1 1 1 c_vbsum file vbsum.dat mode vector +variable db_2_100 equal c_db[2][100] + +# test output: 1: total potential energy +# 2: xy component of stress tensor +# 3: Sum(0.5*(B_{222}^i)^2, all i of type 2) +# 4: xz component of Sum(Sum(r_j*(0.5*(dB_{222}^i)^2/dR[j]), all i of type 2), all j) +# 5: y component of -Sum(d(0.5*(B_{222}^i)^2/dR[2]), all i of type 2) +# +# followed by 5 counterparts from compute snap +thermo 100 + +# run compute mliap with gradgradflag = 1 + +compute snap all mliap descriptor sna compute.mliap.descriptor model quadratic gradgradflag 1 +SNAP keyword rcutfac 1.0 +SNAP keyword twojmax 2 +SNAP keyword nelems 2 +SNAP keyword elems A +SNAP keyword radelems 2.3 +SNAP keyword welems 1.0 +SNAP keyword rfac0 0.99363 +SNAP keyword rmin0 0 +SNAP keyword bzeroflag 0 +SNAP keyword switchflag 0 +fix snap all ave/time 1 1 1 c_snap[*] file compute.quadratic.gg1.dat mode vector + +thermo_style custom pe pxy c_bsum2[20] c_vbsum[220] v_db_2_100 c_snap[1][43] c_snap[13][43] c_snap[1][42] c_snap[12][42] c_snap[6][42] +thermo_modify norm no + +run ${nsteps} +run 0 +Neighbor list info ... + update every 1 steps, delay 10 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 6.8 + ghost atom cutoff = 6.8 + binsize = 3.4, bins = 1 1 1 + 5 neighbor lists, perpetual/occasional/extra = 1 4 0 + (1) pair zbl, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/3d/newton + bin: standard + (2) compute sna/atom, occasional + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard + (3) compute snav/atom, occasional + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard + (4) compute snad/atom, occasional + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard + (5) compute mliap, occasional + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 22.47 | 22.47 | 22.47 Mbytes +PotEng Pxy c_bsum2[20] c_vbsum[220] v_db_2_100 c_snap[1][43] c_snap[13][43] c_snap[1][42] c_snap[12][42] c_snap[6][42] + 322.86952 1505558.1 4.2492771e+08 -4952473 28484035 322.86952 1505558.1 4.2492771e+08 -4952473 28484035 +Loop time of 1e-06 on 1 procs for 0 steps with 2 atoms + +200.0% CPU use with 1 MPI tasks x no OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0 | 0 | 0 | 0.0 | 0.00 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 0 | 0 | 0 | 0.0 | 0.00 +Output | 0 | 0 | 0 | 0.0 | 0.00 +Modify | 0 | 0 | 0 | 0.0 | 0.00 +Other | | 1e-06 | | |100.00 + +Nlocal: 2.00000 ave 2 max 2 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 853.000 ave 853 max 853 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 330.000 ave 330 max 330 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +FullNghs: 660.000 ave 660 max 660 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 660 +Ave neighs/atom = 330.00000 +Neighbor list builds = 0 +Dangerous builds = 0 + +uncompute snap +unfix snap + +# run compute mliap with gradgradflag = 0 + +compute snap all mliap descriptor sna compute.mliap.descriptor model quadratic gradgradflag 0 +SNAP keyword rcutfac 1.0 +SNAP keyword twojmax 2 +SNAP keyword nelems 2 +SNAP keyword elems A +SNAP keyword radelems 2.3 +SNAP keyword welems 1.0 +SNAP keyword rfac0 0.99363 +SNAP keyword rmin0 0 +SNAP keyword bzeroflag 0 +SNAP keyword switchflag 0 +fix snap all ave/time 1 1 1 c_snap[*] file compute.quadratic.gg0.dat mode vector + +thermo_style custom pe pxy c_bsum2[20] c_vbsum[220] v_db_2_100 c_snap[1][43] c_snap[13][43] c_snap[1][42] c_snap[12][42] c_snap[6][42] +WARNING: New thermo_style command, previous thermo_modify settings will be lost (../output.cpp:691) +thermo_modify norm no + +run ${nsteps} +run 0 +Neighbor list info ... + update every 1 steps, delay 10 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 6.8 + ghost atom cutoff = 6.8 + binsize = 3.4, bins = 1 1 1 + 5 neighbor lists, perpetual/occasional/extra = 1 4 0 + (1) pair zbl, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/3d/newton + bin: standard + (2) compute sna/atom, occasional + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard + (3) compute snav/atom, occasional + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard + (4) compute snad/atom, occasional + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard + (5) compute mliap, occasional + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 70.24 | 70.24 | 70.24 Mbytes +PotEng Pxy c_bsum2[20] c_vbsum[220] v_db_2_100 c_snap[1][43] c_snap[13][43] c_snap[1][42] c_snap[12][42] c_snap[6][42] + 322.86952 1505558.1 4.2492771e+08 -4952473 28484035 322.86952 1505558.1 4.2492771e+08 -4952473 28484035 +Loop time of 1e-06 on 1 procs for 0 steps with 2 atoms + +100.0% CPU use with 1 MPI tasks x no OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0 | 0 | 0 | 0.0 | 0.00 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 0 | 0 | 0 | 0.0 | 0.00 +Output | 0 | 0 | 0 | 0.0 | 0.00 +Modify | 0 | 0 | 0 | 0.0 | 0.00 +Other | | 1e-06 | | |100.00 + +Nlocal: 2.00000 ave 2 max 2 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 853.000 ave 853 max 853 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 330.000 ave 330 max 330 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +FullNghs: 660.000 ave 660 max 660 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 660 +Ave neighs/atom = 330.00000 +Neighbor list builds = 0 +Dangerous builds = 0 + +Total wall time: 0:00:00 diff --git a/examples/mliap/log.quadratic_v2 b/examples/mliap/log.quadratic_v2 new file mode 100644 index 0000000000..3f7880abe4 --- /dev/null +++ b/examples/mliap/log.quadratic_v2 @@ -0,0 +1,158 @@ +LAMMPS (10 Feb 2021) + +# Demonstrate MLIAP interface to quadratic SNAP potential + +# Initialize simulation + +variable nsteps index 100 +variable nrep equal 4 +variable a equal 3.1803 +units metal + +# generate the box and atom positions using a BCC lattice + +variable nx equal ${nrep} +variable nx equal 4 +variable ny equal ${nrep} +variable ny equal 4 +variable nz equal ${nrep} +variable nz equal 4 + +boundary p p p + +lattice bcc $a +lattice bcc 3.1803 +Lattice spacing in x,y,z = 3.1803000 3.1803000 3.1803000 +region box block 0 ${nx} 0 ${ny} 0 ${nz} +region box block 0 4 0 ${ny} 0 ${nz} +region box block 0 4 0 4 0 ${nz} +region box block 0 4 0 4 0 4 +create_box 1 box +Created orthogonal box = (0.0000000 0.0000000 0.0000000) to (12.721200 12.721200 12.721200) + 1 by 1 by 1 MPI processor grid +create_atoms 1 box +Created 128 atoms + create_atoms CPU = 0.000 seconds +displace_atoms all random 0.01 0.01 0.01 12345 +Displacing atoms ... + +mass 1 183.84 + +# choose potential + +include W.quadratic.mliap +# DATE: 2020-06-21 UNITS: metal CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: none + +# Definition of SNAP+ZBL potential. +variable zblcutinner equal 4 +variable zblcutouter equal 4.8 +variable zblz equal 74 + +# Specify hybrid with SNAP and ZBL + +pair_style hybrid/overlay zbl ${zblcutinner} ${zblcutouter} mliap model quadratic W.quadratic.mliap.model descriptor sna W.quadratic.mliap.descriptor +pair_style hybrid/overlay zbl 4 ${zblcutouter} mliap model quadratic W.quadratic.mliap.model descriptor sna W.quadratic.mliap.descriptor +pair_style hybrid/overlay zbl 4 4.8 mliap model quadratic W.quadratic.mliap.model descriptor sna W.quadratic.mliap.descriptor +Reading potential file W.quadratic.mliap.model with DATE: 2020-06-21 +Reading potential file W.quadratic.mliap.model with DATE: 2020-06-21 +Reading potential file W.quadratic.mliap.descriptor with DATE: 2020-06-21 +SNAP keyword rcutfac 4.73442 +SNAP keyword twojmax 6 +SNAP keyword nelems 1 +SNAP keyword elems W +SNAP keyword radelems 0.5 +SNAP keyword welems 1 +SNAP keyword rfac0 0.99363 +SNAP keyword rmin0 0 +SNAP keyword bzeroflag 1 +pair_coeff 1 1 zbl ${zblz} ${zblz} +pair_coeff 1 1 zbl 74 ${zblz} +pair_coeff 1 1 zbl 74 74 +pair_coeff * * mliap W + + +# Setup output + +compute eatom all pe/atom +compute energy all reduce sum c_eatom + +compute satom all stress/atom NULL +compute str all reduce sum c_satom[1] c_satom[2] c_satom[3] +variable press equal (c_str[1]+c_str[2]+c_str[3])/(3*vol) + +thermo_style custom step temp epair c_energy etotal press v_press +thermo 10 +thermo_modify norm yes + +# Set up NVE run + +timestep 0.5e-3 +neighbor 1.0 bin +neigh_modify once no every 1 delay 0 check no + +# Run MD + +velocity all create 300.0 4928459 loop geom +fix 1 all nve +run ${nsteps} +run 100 +Neighbor list info ... + update every 1 steps, delay 0 steps, check no + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 5.8 + ghost atom cutoff = 5.8 + binsize = 2.9, bins = 5 5 5 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair zbl, perpetual, half/full from (2) + attributes: half, newton on + pair build: halffull/newton + stencil: none + bin: none + (2) pair mliap, perpetual + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 192.1 | 192.1 | 192.1 Mbytes +Step Temp E_pair c_energy TotEng Press v_press + 0 300 -1.1602728 -1.1602728 -1.1217977 600047.3 -600047.3 + 10 288.46387 -1.1587932 -1.1587932 -1.1217976 600359.75 -600359.75 + 20 268.69718 -1.1562579 -1.1562579 -1.1217974 600870.22 -600870.22 + 30 243.19855 -1.1529874 -1.1529874 -1.1217971 601511.5 -601511.5 + 40 215.13122 -1.1493875 -1.1493875 -1.1217969 602202.36 -602202.36 + 50 187.82673 -1.1458855 -1.1458855 -1.1217966 602860.26 -602860.26 + 60 164.26822 -1.1428639 -1.1428639 -1.1217965 603413.25 -603413.25 + 70 146.65179 -1.1406045 -1.1406045 -1.1217964 603809.35 -603809.35 + 80 136.10769 -1.1392522 -1.1392522 -1.1217964 604022.32 -604022.32 + 90 132.62756 -1.138806 -1.138806 -1.1217964 604053.33 -604053.33 + 100 135.19841 -1.1391358 -1.1391358 -1.1217966 603928.48 -603928.48 +Loop time of 2.19167 on 1 procs for 100 steps with 128 atoms + +Performance: 1.971 ns/day, 12.176 hours/ns, 45.627 timesteps/s +99.2% CPU use with 1 MPI tasks x no OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 2.1547 | 2.1547 | 2.1547 | 0.0 | 98.32 +Neigh | 0.033584 | 0.033584 | 0.033584 | 0.0 | 1.53 +Comm | 0.001943 | 0.001943 | 0.001943 | 0.0 | 0.09 +Output | 0.000658 | 0.000658 | 0.000658 | 0.0 | 0.03 +Modify | 0.000365 | 0.000365 | 0.000365 | 0.0 | 0.02 +Other | | 0.000379 | | | 0.02 + +Nlocal: 128.000 ave 128 max 128 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 727.000 ave 727 max 727 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 3712.00 ave 3712 max 3712 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +FullNghs: 7424.00 ave 7424 max 7424 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 7424 +Ave neighs/atom = 58.000000 +Neighbor list builds = 100 +Dangerous builds not checked + +Total wall time: 0:00:02 From 1fc3fe108e3a348a265d98f1ca3cb1188d14c9c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Antonio=20Santos=20Fl=C3=B3rez?= Date: Sat, 13 Feb 2021 19:27:29 -0300 Subject: [PATCH 05/30] Update mliap_model.cpp --- src/MLIAP/mliap_model.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/MLIAP/mliap_model.cpp b/src/MLIAP/mliap_model.cpp index 7c62115f54..f738bac5b8 100644 --- a/src/MLIAP/mliap_model.cpp +++ b/src/MLIAP/mliap_model.cpp @@ -189,7 +189,6 @@ void MLIAPModelSimple::read_coeffs(char *coefffilename) } } } - if (comm->me == 0) fclose(fpcoeff); } @@ -281,8 +280,8 @@ void MLIAPModelSimple::read_coeffs(char *coefffilename) ielem++; } } - } - if (comm->me == 0) fclose(fpcoeff); + } + if (comm->me == 0) fclose(fpcoeff); } } From 9713c11d6cc5c2e3e0f76c99704f542931f253b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Antonio=20Santos=20Fl=C3=B3rez?= Date: Tue, 16 Feb 2021 12:27:12 -0300 Subject: [PATCH 06/30] Original MLIAP --- src/MLIAP/README | 0 src/MLIAP/compute_mliap.cpp | 0 src/MLIAP/compute_mliap.h | 0 src/MLIAP/mliap_data.cpp | 1 - src/MLIAP/mliap_data.h | 1 - src/MLIAP/mliap_descriptor.cpp | 0 src/MLIAP/mliap_descriptor.h | 0 src/MLIAP/mliap_descriptor_snap.cpp | 0 src/MLIAP/mliap_descriptor_snap.h | 0 src/MLIAP/mliap_model.cpp | 145 ++-------------- src/MLIAP/mliap_model.h | 6 +- src/MLIAP/mliap_model_linear.cpp | 0 src/MLIAP/mliap_model_linear.h | 0 src/MLIAP/mliap_model_nn.cpp | 219 ------------------------ src/MLIAP/mliap_model_nn.h | 60 ------- src/MLIAP/mliap_model_python.cpp | 0 src/MLIAP/mliap_model_python.h | 0 src/MLIAP/mliap_model_python_couple.pyx | 0 src/MLIAP/mliap_model_quadratic.cpp | 0 src/MLIAP/mliap_model_quadratic.h | 0 src/MLIAP/pair_mliap.cpp | 5 - src/MLIAP/pair_mliap.h | 0 22 files changed, 17 insertions(+), 420 deletions(-) mode change 100644 => 100755 src/MLIAP/README mode change 100644 => 100755 src/MLIAP/compute_mliap.cpp mode change 100644 => 100755 src/MLIAP/compute_mliap.h mode change 100644 => 100755 src/MLIAP/mliap_data.cpp mode change 100644 => 100755 src/MLIAP/mliap_data.h mode change 100644 => 100755 src/MLIAP/mliap_descriptor.cpp mode change 100644 => 100755 src/MLIAP/mliap_descriptor.h mode change 100644 => 100755 src/MLIAP/mliap_descriptor_snap.cpp mode change 100644 => 100755 src/MLIAP/mliap_descriptor_snap.h mode change 100644 => 100755 src/MLIAP/mliap_model.cpp mode change 100644 => 100755 src/MLIAP/mliap_model.h mode change 100644 => 100755 src/MLIAP/mliap_model_linear.cpp mode change 100644 => 100755 src/MLIAP/mliap_model_linear.h delete mode 100644 src/MLIAP/mliap_model_nn.cpp delete mode 100644 src/MLIAP/mliap_model_nn.h mode change 100644 => 100755 src/MLIAP/mliap_model_python.cpp mode change 100644 => 100755 src/MLIAP/mliap_model_python.h mode change 100644 => 100755 src/MLIAP/mliap_model_python_couple.pyx mode change 100644 => 100755 src/MLIAP/mliap_model_quadratic.cpp mode change 100644 => 100755 src/MLIAP/mliap_model_quadratic.h mode change 100644 => 100755 src/MLIAP/pair_mliap.cpp mode change 100644 => 100755 src/MLIAP/pair_mliap.h diff --git a/src/MLIAP/README b/src/MLIAP/README old mode 100644 new mode 100755 diff --git a/src/MLIAP/compute_mliap.cpp b/src/MLIAP/compute_mliap.cpp old mode 100644 new mode 100755 diff --git a/src/MLIAP/compute_mliap.h b/src/MLIAP/compute_mliap.h old mode 100644 new mode 100755 diff --git a/src/MLIAP/mliap_data.cpp b/src/MLIAP/mliap_data.cpp old mode 100644 new mode 100755 index 49b6740d7d..8eff580dd7 --- a/src/MLIAP/mliap_data.cpp +++ b/src/MLIAP/mliap_data.cpp @@ -44,7 +44,6 @@ MLIAPData::MLIAPData(LAMMPS *lmp, int gradgradflag_in, int *map_in, ndescriptors = descriptor->ndescriptors; nelements = descriptor->nelements; nparams = model->get_nparams(); - nlayers = model->nlayers; gamma_nnz = model->get_gamma_nnz(this); ndims_force = 3; diff --git a/src/MLIAP/mliap_data.h b/src/MLIAP/mliap_data.h old mode 100644 new mode 100755 index 4199187e2a..7fb60bd723 --- a/src/MLIAP/mliap_data.h +++ b/src/MLIAP/mliap_data.h @@ -41,7 +41,6 @@ class MLIAPData : protected Pointers { int ndescriptors; // number of descriptors int nparams; // number of model parameters per element int nelements; // number of elements - int nlayers; // number of layers per element // data structures for grad-grad list (gamma) diff --git a/src/MLIAP/mliap_descriptor.cpp b/src/MLIAP/mliap_descriptor.cpp old mode 100644 new mode 100755 diff --git a/src/MLIAP/mliap_descriptor.h b/src/MLIAP/mliap_descriptor.h old mode 100644 new mode 100755 diff --git a/src/MLIAP/mliap_descriptor_snap.cpp b/src/MLIAP/mliap_descriptor_snap.cpp old mode 100644 new mode 100755 diff --git a/src/MLIAP/mliap_descriptor_snap.h b/src/MLIAP/mliap_descriptor_snap.h old mode 100644 new mode 100755 diff --git a/src/MLIAP/mliap_model.cpp b/src/MLIAP/mliap_model.cpp old mode 100644 new mode 100755 index f738bac5b8..f993aeb725 --- a/src/MLIAP/mliap_model.cpp +++ b/src/MLIAP/mliap_model.cpp @@ -36,9 +36,7 @@ MLIAPModel::MLIAPModel(LAMMPS *lmp, char *) : Pointers(lmp) nparams = 0; nelements = 0; ndescriptors = 0; - nlayers = 0; nonlinearflag = 0; - nnflag = 0; } /* ---------------------------------------------------------------------- */ @@ -79,9 +77,6 @@ void MLIAPModel::set_ndescriptors(int ndescriptors_in) MLIAPModelSimple::MLIAPModelSimple(LAMMPS *lmp, char *coefffilename) : MLIAPModel(lmp, coefffilename) { coeffelem = nullptr; - nnodes = nullptr; - activation = nullptr; - scale = nullptr; if (coefffilename) read_coeffs(coefffilename); } @@ -90,11 +85,6 @@ MLIAPModelSimple::MLIAPModelSimple(LAMMPS *lmp, char *coefffilename) : MLIAPMode MLIAPModelSimple::~MLIAPModelSimple() { memory->destroy(coeffelem); - if (nnflag) { - memory->destroy(nnodes); - memory->destroy(activation); - memory->destroy(scale); - } } /* ---------------------------------------------------------------------- */ @@ -112,7 +102,7 @@ void MLIAPModelSimple::read_coeffs(char *coefffilename) coefffilename,utils::getsyserror())); } - char line[MAXLINE],*ptr, *tstr; + char line[MAXLINE],*ptr; int eof = 0; int n; @@ -133,10 +123,6 @@ void MLIAPModelSimple::read_coeffs(char *coefffilename) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - if ((ptr = strstr(line,"nn"))) { - *ptr = '\0'; - nnflag = 1; - } nwords = utils::count_words(line); } if (nwords != 2) @@ -158,48 +144,10 @@ void MLIAPModelSimple::read_coeffs(char *coefffilename) memory->create(coeffelem,nelements,nparams,"mliap_snap_model:coeffelem"); - if (nnflag == 0) { - // Loop over nelements blocks in the coefficient file - for (int ielem = 0; ielem < nelements; ielem++) { - for (int icoeff = 0; icoeff < nparams; icoeff++) { - if (comm->me == 0) { - ptr = fgets(line,MAXLINE,fpcoeff); - if (ptr == nullptr) { - eof = 1; - fclose(fpcoeff); - } else n = strlen(line) + 1; - } - - MPI_Bcast(&eof,1,MPI_INT,0,world); - if (eof) - error->all(FLERR,"Incorrect format in MLIAPModel coefficient file"); - MPI_Bcast(&n,1,MPI_INT,0,world); - MPI_Bcast(line,n,MPI_CHAR,0,world); - - try { - ValueTokenizer coeffs(utils::trim_comment(line)); - if (coeffs.count() != 1) - throw TokenizerException("Wrong number of items",""); - coeffelem[ielem][icoeff] = coeffs.next_double(); - } catch (TokenizerException &e) { - error->all(FLERR,fmt::format("Incorrect format in MLIAPModel " - "coefficient file: {}",e.what())); - } - } - } - if (comm->me == 0) fclose(fpcoeff); - } - - // set up the NN parameters - - else { - int stats = 0; - int ielem = 0; - int l = 0; - - while (1) { + for (int ielem = 0; ielem < nelements; ielem++) { + for (int icoeff = 0; icoeff < nparams; icoeff++) { if (comm->me == 0) { ptr = fgets(line,MAXLINE,fpcoeff); if (ptr == nullptr) { @@ -209,80 +157,24 @@ void MLIAPModelSimple::read_coeffs(char *coefffilename) } MPI_Bcast(&eof,1,MPI_INT,0,world); - if (eof) break; + if (eof) + error->all(FLERR,"Incorrect format in MLIAPModel coefficient file"); MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); - - // strip comment, skip line if blank - if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = utils::trim_and_count_words(line); - if (nwords == 0) continue; - - if (stats == 0) { // Header NET - tstr = strtok(line,"' \t\n\r\f"); - if (strncmp(tstr, "NET", 3) != 0) error->all(FLERR,"Incorrect format in NET coefficient file"); - - ndescriptors = atoi(strtok(nullptr,"' \t\n\r\f")); - nlayers = atoi(strtok(nullptr,"' \t\n\r\f")); - - memory->create(activation,nlayers,"mliap_model:activation"); - memory->create(nnodes,nlayers,"mliap_model:nnodes"); - memory->create(scale,nelements,2,ndescriptors,"mliap_model:scale"); - - for (int ilayer = 0; ilayer < nlayers; ilayer++) { - tstr = strtok(NULL,"' \t\n\r\f"); - nnodes[ilayer] = atoi(strtok(NULL,"' \t\n\r\f")); - - if (strncmp(tstr, "linear", 6) == 0) activation[ilayer] = 0; - else if (strncmp(tstr, "sigmoid", 7) == 0) activation[ilayer] = 1; - else if (strncmp(tstr, "tanh", 4) == 0) activation[ilayer] = 2; - else if (strncmp(tstr, "relu", 4) == 0) activation[ilayer] = 3; - else activation[ilayer] = 4; - } - - stats = 1; - - } else if (stats == 1) { - scale[ielem][0][l] = atof(strtok(line,"' \t\n\r\f")); - for (int icoeff = 1; icoeff < nwords; icoeff++) { - scale[ielem][0][l+icoeff] = atof(strtok(nullptr,"' \t\n\r\f")); - } - l += nwords; - if (l == ndescriptors) { - stats = 2; - l = 0; - } - - } else if (stats == 2) { - scale[ielem][1][l] = atof(strtok(line,"' \t\n\r\f")); - for (int icoeff = 1; icoeff < nwords; icoeff++) { - scale[ielem][1][l+icoeff] = atof(strtok(nullptr,"' \t\n\r\f")); - } - l += nwords; - if (l == ndescriptors) { - stats = 3; - l = 0; - } - - // set up coeff lists - - } else if (stats == 3) { - // if (nwords > 30) error->all(FLERR,"Wrong number of items per line, max 30"); - - coeffelem[ielem][l] = atof(strtok(line,"' \t\n\r\f")); - for (int icoeff = 1; icoeff < nwords; icoeff++) { - coeffelem[ielem][l+icoeff] = atof(strtok(nullptr,"' \t\n\r\f")); - } - l += nwords; - if (l == nparams) { - stats = 0; - ielem++; - } + try { + ValueTokenizer coeffs(utils::trim_comment(line)); + if (coeffs.count() != 1) + throw TokenizerException("Wrong number of items",""); + coeffelem[ielem][icoeff] = coeffs.next_double(); + } catch (TokenizerException &e) { + error->all(FLERR,fmt::format("Incorrect format in MLIAPModel " + "coefficient file: {}",e.what())); } } - if (comm->me == 0) fclose(fpcoeff); } + + if (comm->me == 0) fclose(fpcoeff); } /* ---------------------------------------------------------------------- @@ -293,12 +185,7 @@ double MLIAPModelSimple::memory_usage() { double bytes = 0; - bytes += (double)nelements*nparams*sizeof(double); // coeffelem - if (nnflag) { - bytes += (double)nelements*2*ndescriptors*sizeof(double); // scale - bytes += (int)nlayers*sizeof(int); // nnodes - bytes += (int)nlayers*sizeof(int); // activation - } + bytes += (double)nelements*nparams*sizeof(double); // coeffelem return bytes; } diff --git a/src/MLIAP/mliap_model.h b/src/MLIAP/mliap_model.h old mode 100644 new mode 100755 index 9506f063c2..96cfff0a3d --- a/src/MLIAP/mliap_model.h +++ b/src/MLIAP/mliap_model.h @@ -33,10 +33,8 @@ public: virtual double memory_usage()=0; int nelements; // # of unique elements int nonlinearflag; // 1 if gradient() requires descriptors - int nnflag; // 1 if model is nn int ndescriptors; // number of descriptors int nparams; // number of parameters per element - int nlayers; // number of layers per element protected: virtual void read_coeffs(char *)=0; @@ -49,11 +47,9 @@ public: virtual double memory_usage(); protected: - int *activation; // activation functions - int *nnodes; // number of nodes per layer - double ***scale; // element scale values double **coeffelem; // element coefficients virtual void read_coeffs(char *); + }; } diff --git a/src/MLIAP/mliap_model_linear.cpp b/src/MLIAP/mliap_model_linear.cpp old mode 100644 new mode 100755 diff --git a/src/MLIAP/mliap_model_linear.h b/src/MLIAP/mliap_model_linear.h old mode 100644 new mode 100755 diff --git a/src/MLIAP/mliap_model_nn.cpp b/src/MLIAP/mliap_model_nn.cpp deleted file mode 100644 index a49a6d1665..0000000000 --- a/src/MLIAP/mliap_model_nn.cpp +++ /dev/null @@ -1,219 +0,0 @@ -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://lammps.sandia.gov/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - Copyright (2003) Sandia Corporation. Under the terms of Contract - DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under - the GNU General Public License. - - See the README file in the top-level LAMMPS directory. -------------------------------------------------------------------------- */ - -#include "mliap_model_nn.h" -#include "pair_mliap.h" -#include "mliap_data.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -MLIAPModelNN::MLIAPModelNN(LAMMPS* lmp, char* coefffilename) : - MLIAPModelSimple(lmp, coefffilename) -{ - ndescriptors = ndescriptors; -} - -/* ---------------------------------------------------------------------- */ - -MLIAPModelNN::~MLIAPModelNN(){} - -/* ---------------------------------------------------------------------- - get number of parameters - ---------------------------------------------------------------------- */ - -int MLIAPModelNN::get_nparams() -{ - if (nparams == 0) { - if (ndescriptors == 0) error->all(FLERR,"ndescriptors not defined"); - } - return nparams; -} - -/* ---------------------------------------------------------------------- - Calculate model gradients w.r.t descriptors - for each atom beta_i = dE(B_i)/dB_i - ---------------------------------------------------------------------- */ - -void MLIAPModelNN::compute_gradients(MLIAPData* data) -{ - data->energy = 0.0; - - for (int ii = 0; ii < data->natoms; ii++) { - const int ielem = data->ielems[ii]; - const int nl = data->nlayers; - - double* coeffi = coeffelem[ielem]; - double** scalei = scale[ielem]; - double **nodes, **dnodes, **bnodes; - - nodes = new double*[nl]; - dnodes = new double*[nl]; - bnodes = new double*[nl]; - for (int l=0; lndescriptors; icoeff++) { - nodes[0][n] += coeffi[n*((data->ndescriptors)+1)+icoeff+1] * (data->descriptors[ii][icoeff] - scalei[0][icoeff]) / scalei[1][icoeff]; - } - if (activation[0] == 1) { - nodes[0][n] = sigm(nodes[0][n] + coeffi[n*((data->ndescriptors)+1)], dnodes[0][n]); - } - else if (activation[0] == 2) { - nodes[0][n] = tanh(nodes[0][n] + coeffi[n*((data->ndescriptors)+1)], dnodes[0][n]); - } - else if (activation[0] == 3) { - nodes[0][n] = relu(nodes[0][n] + coeffi[n*((data->ndescriptors)+1)], dnodes[0][n]); - } - else { - nodes[0][n] += coeffi[n*((data->ndescriptors)+1)]; - dnodes[0][n] = 1; - } - } - - // hidden~output - int k = 0; - if (nl > 1) { - k += ((data->ndescriptors)+1)*nnodes[0]; - for (int l=1; l < nl; l++) { - for (int n=0; n < nnodes[l]; n++) { - nodes[l][n] = 0; - for (int j=0; j < nnodes[l-1]; j++) { - nodes[l][n] += coeffi[k+n*(nnodes[l-1]+1)+j+1] * nodes[l-1][j]; - } - if (activation[l] == 1) { - nodes[l][n] = sigm(nodes[l][n] + coeffi[k+n*(nnodes[l-1]+1)], dnodes[l][n]); - } - else if (activation[l] == 2) { - nodes[l][n] = tanh(nodes[l][n] + coeffi[k+n*(nnodes[l-1]+1)], dnodes[l][n]); - } - else if (activation[l] == 3) { - nodes[l][n] = relu(nodes[l][n] + coeffi[k+n*(nnodes[l-1]+1)], dnodes[l][n]); - } - else { - nodes[l][n] += coeffi[k+n*(nnodes[l-1]+1)]; - dnodes[l][n] = 1; - } - } - k += (nnodes[l-1]+1)*nnodes[l]; - } - } - - // backwardprop - // output layer dnode initialized to 1. - - for (int n=0; n 1) { - for (int l=nl-1; l>0; l--) { - k -= (nnodes[l-1]+1)*nnodes[l]; - for (int n=0; n= 1) { - bnodes[l-1][n] *= dnodes[l-1][n]; - } - } - } - } - - for (int icoeff = 0; icoeff < data->ndescriptors; icoeff++) { - data->betas[ii][icoeff] = 0; - for (int j=0; jbetas[ii][icoeff] += coeffi[j*((data->ndescriptors)+1)+icoeff+1] * bnodes[0][j]; - } - data->betas[ii][icoeff] = data->betas[ii][icoeff]/scalei[1][icoeff]; - } - - if (data->eflag) { - - // energy of atom I (E_i) - - double etmp = nodes[nl-1][0]; - - data->energy += etmp; - data->eatoms[ii] = etmp; - } - // Deleting the variables - - for (int n=0; nall(FLERR,"compute_gradgrads not implemented"); -} - -/* ---------------------------------------------------------------------- - calculate gradients of forces w.r.t. parameters - egradient is derivative of energy w.r.t. parameters - ---------------------------------------------------------------------- */ - -void MLIAPModelNN::compute_force_gradients(class MLIAPData* data) -{ - error->all(FLERR,"compute_force_gradients not implemented"); -} - -/* ---------------------------------------------------------------------- - count the number of non-zero entries in gamma matrix - ---------------------------------------------------------------------- */ - -int MLIAPModelNN::get_gamma_nnz(class MLIAPData* data) -{ - // todo: get_gamma_nnz - return 0; -} - diff --git a/src/MLIAP/mliap_model_nn.h b/src/MLIAP/mliap_model_nn.h deleted file mode 100644 index aa9f6a2338..0000000000 --- a/src/MLIAP/mliap_model_nn.h +++ /dev/null @@ -1,60 +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. -------------------------------------------------------------------------- */ - -#ifndef LMP_MLIAP_MODEL_NN_H -#define LMP_MLIAP_MODEL_NN_H - -#include "mliap_model.h" -#include - -namespace LAMMPS_NS { - -class MLIAPModelNN : public MLIAPModelSimple { -public: - MLIAPModelNN(LAMMPS*, char* = nullptr); - ~MLIAPModelNN(); - virtual int get_nparams(); - virtual int get_gamma_nnz(class MLIAPData*); - virtual void compute_gradients(class MLIAPData*); - virtual void compute_gradgrads(class MLIAPData*); - virtual void compute_force_gradients(class MLIAPData*); - -protected: -}; - -} - -static inline double sigm(double x, double &deriv) { - double expl = 1./(1.+exp(-x)); - deriv = expl*(1-expl); - return expl; -} - -static inline double tanh(double x, double &deriv) { - double expl = 2./(1.+exp(-2.*x))-1; - deriv = 1.-expl*expl; - return expl; -} - -static inline double relu(double x, double &deriv) { - if (x > 0) { - deriv = 1.; - return x; - } else { - deriv = 0.; - return 0; - } -} - -#endif - diff --git a/src/MLIAP/mliap_model_python.cpp b/src/MLIAP/mliap_model_python.cpp old mode 100644 new mode 100755 diff --git a/src/MLIAP/mliap_model_python.h b/src/MLIAP/mliap_model_python.h old mode 100644 new mode 100755 diff --git a/src/MLIAP/mliap_model_python_couple.pyx b/src/MLIAP/mliap_model_python_couple.pyx old mode 100644 new mode 100755 diff --git a/src/MLIAP/mliap_model_quadratic.cpp b/src/MLIAP/mliap_model_quadratic.cpp old mode 100644 new mode 100755 diff --git a/src/MLIAP/mliap_model_quadratic.h b/src/MLIAP/mliap_model_quadratic.h old mode 100644 new mode 100755 diff --git a/src/MLIAP/pair_mliap.cpp b/src/MLIAP/pair_mliap.cpp old mode 100644 new mode 100755 index f280795399..ef8a4c974e --- a/src/MLIAP/pair_mliap.cpp +++ b/src/MLIAP/pair_mliap.cpp @@ -20,7 +20,6 @@ #include "mliap_data.h" #include "mliap_model_linear.h" #include "mliap_model_quadratic.h" -#include "mliap_model_nn.h" #include "mliap_descriptor_snap.h" #ifdef MLIAP_PYTHON #include "mliap_model_python.h" @@ -153,10 +152,6 @@ void PairMLIAP::settings(int narg, char ** arg) if (iarg+3 > narg) error->all(FLERR,"Illegal pair_style mliap command"); model = new MLIAPModelQuadratic(lmp,arg[iarg+2]); iarg += 3; - } else if (strcmp(arg[iarg+1],"nn") == 0) { - if (iarg+3 > narg) error->all(FLERR,"Illegal pair_style mliap command"); - model = new MLIAPModelNN(lmp,arg[iarg+2]); - iarg += 3; #ifdef MLIAP_PYTHON } else if (strcmp(arg[iarg+1],"mliappy") == 0) { if (iarg+3 > narg) error->all(FLERR,"Illegal pair_style mliap command"); diff --git a/src/MLIAP/pair_mliap.h b/src/MLIAP/pair_mliap.h old mode 100644 new mode 100755 From 2512b3b942cdd06d054b5d124eaac6b1744e9923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Antonio=20Santos=20Fl=C3=B3rez?= Date: Tue, 16 Feb 2021 12:28:11 -0300 Subject: [PATCH 07/30] Adding nn model --- src/MLIAP/mliap_model_nn.cpp | 393 +++++++++++++++++++++++++++++++++++ src/MLIAP/mliap_model_nn.h | 68 ++++++ src/MLIAP/pair_mliap.cpp | 5 + 3 files changed, 466 insertions(+) create mode 100644 src/MLIAP/mliap_model_nn.cpp create mode 100644 src/MLIAP/mliap_model_nn.h mode change 100755 => 100644 src/MLIAP/pair_mliap.cpp diff --git a/src/MLIAP/mliap_model_nn.cpp b/src/MLIAP/mliap_model_nn.cpp new file mode 100644 index 0000000000..8d8be35d0e --- /dev/null +++ b/src/MLIAP/mliap_model_nn.cpp @@ -0,0 +1,393 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://lammps.sandia.gov/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +#include "mliap_model_nn.h" +#include "pair_mliap.h" +#include "mliap_data.h" +#include "error.h" + +#include "comm.h" +#include "memory.h" +#include "tokenizer.h" + +using namespace LAMMPS_NS; + +#define MAXLINE 1024 + +/* ---------------------------------------------------------------------- */ + +MLIAPModelNN::MLIAPModelNN(LAMMPS* lmp, char* coefffilename) : + MLIAPModel(lmp, coefffilename) +{ + coeffelem = nullptr; + nnodes = nullptr; + activation = nullptr; + scale = nullptr; + if (coefffilename) read_coeffs(coefffilename); +} + +/* ---------------------------------------------------------------------- */ + +MLIAPModelNN::~MLIAPModelNN() +{ + memory->destroy(coeffelem); + memory->destroy(nnodes); + memory->destroy(activation); + memory->destroy(scale); +} + +/* ---------------------------------------------------------------------- + get number of parameters + ---------------------------------------------------------------------- */ + +int MLIAPModelNN::get_nparams() +{ + if (nparams == 0) { + if (ndescriptors == 0) error->all(FLERR,"ndescriptors not defined"); + } + return nparams; +} + +void MLIAPModelNN::read_coeffs(char *coefffilename) +{ + + // open coefficient file on proc 0 + + FILE *fpcoeff; + if (comm->me == 0) { + fpcoeff = utils::open_potential(coefffilename,lmp,nullptr); + if (fpcoeff == nullptr) + error->one(FLERR,fmt::format("Cannot open MLIAPModel coeff file {}: {}", + coefffilename,utils::getsyserror())); + } + + char line[MAXLINE],*ptr, *tstr; + int eof = 0; + + int n; + int nwords = 0; + while (nwords == 0) { + if (comm->me == 0) { + ptr = fgets(line,MAXLINE,fpcoeff); + if (ptr == nullptr) { + eof = 1; + fclose(fpcoeff); + } else n = strlen(line) + 1; + } + MPI_Bcast(&eof,1,MPI_INT,0,world); + if (eof) break; + MPI_Bcast(&n,1,MPI_INT,0,world); + MPI_Bcast(line,n,MPI_CHAR,0,world); + + // strip comment, skip line if blank + + if ((ptr = strchr(line,'#'))) *ptr = '\0'; + if ((ptr = strstr(line,"nn"))) { + *ptr = '\0'; + } + nwords = utils::count_words(line); + } + if (nwords != 2) + error->all(FLERR,"Incorrect format in MLIAPModel coefficient file"); + + // words = ptrs to all words in line + // strip single and double quotes from words + + try { + ValueTokenizer coeffs(line); + nelements = coeffs.next_int(); + nparams = coeffs.next_int(); + } catch (TokenizerException &e) { + error->all(FLERR,fmt::format("Incorrect format in MLIAPModel coefficient " + "file: {}",e.what())); + } + + // set up coeff lists + + memory->create(coeffelem,nelements,nparams,"mliap_snap_model:coeffelem"); + + int stats = 0; + int ielem = 0; + int l = 0; + + while (1) { + if (comm->me == 0) { + ptr = fgets(line,MAXLINE,fpcoeff); + if (ptr == nullptr) { + eof = 1; + fclose(fpcoeff); + } else n = strlen(line) + 1; + } + + MPI_Bcast(&eof,1,MPI_INT,0,world); + if (eof) break; + MPI_Bcast(&n,1,MPI_INT,0,world); + MPI_Bcast(line,n,MPI_CHAR,0,world); + + // strip comment, skip line if blank + + if ((ptr = strchr(line,'#'))) *ptr = '\0'; + nwords = utils::trim_and_count_words(line); + if (nwords == 0) continue; + + if (stats == 0) { // Header NET + tstr = strtok(line,"' \t\n\r\f"); + if (strncmp(tstr, "NET", 3) != 0) error->all(FLERR,"Incorrect format in NET coefficient file"); + + ndescriptors = atoi(strtok(nullptr,"' \t\n\r\f")); + nlayers = atoi(strtok(nullptr,"' \t\n\r\f")); + + memory->create(activation,nlayers,"mliap_model:activation"); + memory->create(nnodes,nlayers,"mliap_model:nnodes"); + memory->create(scale,nelements,2,ndescriptors,"mliap_model:scale"); + + for (int ilayer = 0; ilayer < nlayers; ilayer++) { + tstr = strtok(NULL,"' \t\n\r\f"); + nnodes[ilayer] = atoi(strtok(NULL,"' \t\n\r\f")); + + if (strncmp(tstr, "linear", 6) == 0) activation[ilayer] = 0; + else if (strncmp(tstr, "sigmoid", 7) == 0) activation[ilayer] = 1; + else if (strncmp(tstr, "tanh", 4) == 0) activation[ilayer] = 2; + else if (strncmp(tstr, "relu", 4) == 0) activation[ilayer] = 3; + else activation[ilayer] = 4; + } + + stats = 1; + + } else if (stats == 1) { + scale[ielem][0][l] = atof(strtok(line,"' \t\n\r\f")); + for (int icoeff = 1; icoeff < nwords; icoeff++) { + scale[ielem][0][l+icoeff] = atof(strtok(nullptr,"' \t\n\r\f")); + } + l += nwords; + if (l == ndescriptors) { + stats = 2; + l = 0; + } + + } else if (stats == 2) { + scale[ielem][1][l] = atof(strtok(line,"' \t\n\r\f")); + for (int icoeff = 1; icoeff < nwords; icoeff++) { + scale[ielem][1][l+icoeff] = atof(strtok(nullptr,"' \t\n\r\f")); + } + l += nwords; + if (l == ndescriptors) { + stats = 3; + l = 0; + } + + // set up coeff lists + + } else if (stats == 3) { + // if (nwords > 30) error->all(FLERR,"Wrong number of items per line, max 30"); + + coeffelem[ielem][l] = atof(strtok(line,"' \t\n\r\f")); + for (int icoeff = 1; icoeff < nwords; icoeff++) { + coeffelem[ielem][l+icoeff] = atof(strtok(nullptr,"' \t\n\r\f")); + } + l += nwords; + if (l == nparams) { + stats = 0; + ielem++; + } + } + } + if (comm->me == 0) fclose(fpcoeff); +} + + +/* ---------------------------------------------------------------------- + Calculate model gradients w.r.t descriptors + for each atom beta_i = dE(B_i)/dB_i + ---------------------------------------------------------------------- */ + +void MLIAPModelNN::compute_gradients(MLIAPData* data) +{ + data->energy = 0.0; + + for (int ii = 0; ii < data->natoms; ii++) { + const int ielem = data->ielems[ii]; + const int nl = nlayers; + + double* coeffi = coeffelem[ielem]; + double** scalei = scale[ielem]; + double **nodes, **dnodes, **bnodes; + + nodes = new double*[nl]; + dnodes = new double*[nl]; + bnodes = new double*[nl]; + for (int l=0; lndescriptors; icoeff++) { + nodes[0][n] += coeffi[n*((data->ndescriptors)+1)+icoeff+1] * (data->descriptors[ii][icoeff] - scalei[0][icoeff]) / scalei[1][icoeff]; + } + if (activation[0] == 1) { + nodes[0][n] = sigm(nodes[0][n] + coeffi[n*((data->ndescriptors)+1)], dnodes[0][n]); + } + else if (activation[0] == 2) { + nodes[0][n] = tanh(nodes[0][n] + coeffi[n*((data->ndescriptors)+1)], dnodes[0][n]); + } + else if (activation[0] == 3) { + nodes[0][n] = relu(nodes[0][n] + coeffi[n*((data->ndescriptors)+1)], dnodes[0][n]); + } + else { + nodes[0][n] += coeffi[n*((data->ndescriptors)+1)]; + dnodes[0][n] = 1; + } + } + + // hidden~output + int k = 0; + if (nl > 1) { + k += ((data->ndescriptors)+1)*nnodes[0]; + for (int l=1; l < nl; l++) { + for (int n=0; n < nnodes[l]; n++) { + nodes[l][n] = 0; + for (int j=0; j < nnodes[l-1]; j++) { + nodes[l][n] += coeffi[k+n*(nnodes[l-1]+1)+j+1] * nodes[l-1][j]; + } + if (activation[l] == 1) { + nodes[l][n] = sigm(nodes[l][n] + coeffi[k+n*(nnodes[l-1]+1)], dnodes[l][n]); + } + else if (activation[l] == 2) { + nodes[l][n] = tanh(nodes[l][n] + coeffi[k+n*(nnodes[l-1]+1)], dnodes[l][n]); + } + else if (activation[l] == 3) { + nodes[l][n] = relu(nodes[l][n] + coeffi[k+n*(nnodes[l-1]+1)], dnodes[l][n]); + } + else { + nodes[l][n] += coeffi[k+n*(nnodes[l-1]+1)]; + dnodes[l][n] = 1; + } + } + k += (nnodes[l-1]+1)*nnodes[l]; + } + } + + // backwardprop + // output layer dnode initialized to 1. + + for (int n=0; n 1) { + for (int l=nl-1; l>0; l--) { + k -= (nnodes[l-1]+1)*nnodes[l]; + for (int n=0; n= 1) { + bnodes[l-1][n] *= dnodes[l-1][n]; + } + } + } + } + + for (int icoeff = 0; icoeff < data->ndescriptors; icoeff++) { + data->betas[ii][icoeff] = 0; + for (int j=0; jbetas[ii][icoeff] += coeffi[j*((data->ndescriptors)+1)+icoeff+1] * bnodes[0][j]; + } + data->betas[ii][icoeff] = data->betas[ii][icoeff]/scalei[1][icoeff]; + } + + if (data->eflag) { + + // energy of atom I (E_i) + + double etmp = nodes[nl-1][0]; + + data->energy += etmp; + data->eatoms[ii] = etmp; + } + // Deleting the variables + + for (int n=0; nall(FLERR,"compute_gradgrads not implemented"); +} + +/* ---------------------------------------------------------------------- + calculate gradients of forces w.r.t. parameters + egradient is derivative of energy w.r.t. parameters + ---------------------------------------------------------------------- */ + +void MLIAPModelNN::compute_force_gradients(class MLIAPData* data) +{ + error->all(FLERR,"compute_force_gradients not implemented"); +} + +/* ---------------------------------------------------------------------- + count the number of non-zero entries in gamma matrix + ---------------------------------------------------------------------- */ + +int MLIAPModelNN::get_gamma_nnz(class MLIAPData* data) +{ + // todo: get_gamma_nnz + return 0; +} + +double MLIAPModelNN::memory_usage() +{ + double bytes = 0; + + bytes += (double)nelements*nparams*sizeof(double); // coeffelem + bytes += (double)nelements*2*ndescriptors*sizeof(double); // scale + bytes += (int)nlayers*sizeof(int); // nnodes + bytes += (int)nlayers*sizeof(int); // activation + return bytes; +} diff --git a/src/MLIAP/mliap_model_nn.h b/src/MLIAP/mliap_model_nn.h new file mode 100644 index 0000000000..8facf9d446 --- /dev/null +++ b/src/MLIAP/mliap_model_nn.h @@ -0,0 +1,68 @@ +/* -*- 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. +------------------------------------------------------------------------- */ + +#ifndef LMP_MLIAP_MODEL_NN_H +#define LMP_MLIAP_MODEL_NN_H + +#include "mliap_model.h" +#include + +namespace LAMMPS_NS { + +class MLIAPModelNN : public MLIAPModel { +public: + MLIAPModelNN(LAMMPS*, char* = nullptr); + ~MLIAPModelNN(); + virtual int get_nparams(); + virtual int get_gamma_nnz(class MLIAPData*); + virtual void compute_gradients(class MLIAPData*); + virtual void compute_gradgrads(class MLIAPData*); + virtual void compute_force_gradients(class MLIAPData*); + virtual double memory_usage(); + + int nlayers; // number of layers per element + +protected: + int *activation; // activation functions + int *nnodes; // number of nodes per layer + double ***scale; // element scale values + double **coeffelem; // element coefficients + virtual void read_coeffs(char *); +}; + +} + +static inline double sigm(double x, double &deriv) { + double expl = 1./(1.+exp(-x)); + deriv = expl*(1-expl); + return expl; +} + +static inline double tanh(double x, double &deriv) { + double expl = 2./(1.+exp(-2.*x))-1; + deriv = 1.-expl*expl; + return expl; +} + +static inline double relu(double x, double &deriv) { + if (x > 0) { + deriv = 1.; + return x; + } else { + deriv = 0.; + return 0; + } +} + +#endif + diff --git a/src/MLIAP/pair_mliap.cpp b/src/MLIAP/pair_mliap.cpp old mode 100755 new mode 100644 index ef8a4c974e..f280795399 --- a/src/MLIAP/pair_mliap.cpp +++ b/src/MLIAP/pair_mliap.cpp @@ -20,6 +20,7 @@ #include "mliap_data.h" #include "mliap_model_linear.h" #include "mliap_model_quadratic.h" +#include "mliap_model_nn.h" #include "mliap_descriptor_snap.h" #ifdef MLIAP_PYTHON #include "mliap_model_python.h" @@ -152,6 +153,10 @@ void PairMLIAP::settings(int narg, char ** arg) if (iarg+3 > narg) error->all(FLERR,"Illegal pair_style mliap command"); model = new MLIAPModelQuadratic(lmp,arg[iarg+2]); iarg += 3; + } else if (strcmp(arg[iarg+1],"nn") == 0) { + if (iarg+3 > narg) error->all(FLERR,"Illegal pair_style mliap command"); + model = new MLIAPModelNN(lmp,arg[iarg+2]); + iarg += 3; #ifdef MLIAP_PYTHON } else if (strcmp(arg[iarg+1],"mliappy") == 0) { if (iarg+3 > narg) error->all(FLERR,"Illegal pair_style mliap command"); From 96643cc5ec37badc956ce6944f71e18b94b5ebf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Antonio=20Santos=20Fl=C3=B3rez?= Date: Tue, 16 Feb 2021 12:31:29 -0300 Subject: [PATCH 08/30] Updating README file --- src/MLIAP/README.md | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/MLIAP/README.md diff --git a/src/MLIAP/README.md b/src/MLIAP/README.md new file mode 100644 index 0000000000..65e6a4cc36 --- /dev/null +++ b/src/MLIAP/README.md @@ -0,0 +1,41 @@ +This package provides a general interface to families of machine-learning interatomic potentials (MLIAPs). +This interface consists of a `mliap pair style` and a `mliap compute`. +The `mliap pair style` is used when running simulations with energies and +forces calculated by an MLIAP. The interface allows separate +definitions of the interatomic potential functional form (`model`) +and the geometric quantities that characterize the atomic positions +(`descriptor`). By defining `model` and `descriptor` separately, +it is possible to use many different models with a given descriptor, +or many different descriptors with a given model. The pair_style +supports the following models: + +- `linear`, +- `quadratic`, +- `nn` (neural networks) +- `mliappy` (general Python interface to things like PyTorch). + +It currently supports only one class of descriptors, `sna`, the SNAP descriptors. +It is straightforward to add new descriptor and model styles. + +The `mliap compute` style provides gradients of the energy, force, +and stress tensor w.r.t. model parameters. +These are useful when training MLIAPs to match target data. +Any `model` or `descriptor` that has been implemented for the +`mliap` pair style can also be accessed by the `mliap` compute. +In addition to the energy, force, and stress gradients, w.r.t. +each `model` parameter, the compute also calculates the energy, +force, and stress contributions from a user-specified +reference potential. + +## Generating the model files from the third-party packages +- To train the `linear` and `quardratic` model with the SNAP descritptors, see the examples in [FitSNAP](https://github.com/FitSNAP/FitSNAP). +- To train the `nn` model with the SNAP descriptors, check the examples in [PyXtal\_FF](https://github.com/qzhu2017/PyXtal_FF). + +## Building MLIAP with Python support + +The `mliappy` energy model requires that the MLIAP package be compiled with Python support enabled. This extension, written by Nick Lubbers (LANL), provides a coupling to PyTorch and other Python modules. This should be automatically enabled by default if the prerequisite software is installed. It can be enforced during CMake configuration by setting the variable `MLIAP_ENABLE_PYTHON=yes` or for conventional build by adding `-DMLIAP_PYTHON` to the `LMP_INC` variable in your makefile and running the cythonize script on the .pyx file(s) copied to the src folder. + +This requires to also install the PYTHON package and have the [cython](https://cython.org) software installed. During configuration/compilation +the cythonize script will be used to convert the provided .pyx file(s) to C++ code. Please do not run the cythonize script in the src/MLIAP folder. If you have done so by accident, you need to delete the generated .cpp and .h file(s) in the src/MLIAP folder or there may be problems during compilation. + +More information on building LAMMPS with this package is [here](https://lammps.sandia.gov/doc/Build_extras.html#mliap). From 7bdbdad2719fa4abcc431402946199a4fe38b9f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Antonio=20Santos=20Fl=C3=B3rez?= Date: Tue, 16 Feb 2021 14:07:16 -0300 Subject: [PATCH 09/30] Update mliap_model_nn.cpp --- src/MLIAP/mliap_model_nn.cpp | 173 +++++++++++++++++------------------ 1 file changed, 85 insertions(+), 88 deletions(-) diff --git a/src/MLIAP/mliap_model_nn.cpp b/src/MLIAP/mliap_model_nn.cpp index 8d8be35d0e..018641e3c9 100644 --- a/src/MLIAP/mliap_model_nn.cpp +++ b/src/MLIAP/mliap_model_nn.cpp @@ -92,9 +92,6 @@ void MLIAPModelNN::read_coeffs(char *coefffilename) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - if ((ptr = strstr(line,"nn"))) { - *ptr = '\0'; - } nwords = utils::count_words(line); } if (nwords != 2) @@ -116,93 +113,93 @@ void MLIAPModelNN::read_coeffs(char *coefffilename) memory->create(coeffelem,nelements,nparams,"mliap_snap_model:coeffelem"); - int stats = 0; - int ielem = 0; - int l = 0; + int stats = 0; + int ielem = 0; + int l = 0; - while (1) { - if (comm->me == 0) { - ptr = fgets(line,MAXLINE,fpcoeff); - if (ptr == nullptr) { - eof = 1; - fclose(fpcoeff); - } else n = strlen(line) + 1; - } - - MPI_Bcast(&eof,1,MPI_INT,0,world); - if (eof) break; - MPI_Bcast(&n,1,MPI_INT,0,world); - MPI_Bcast(line,n,MPI_CHAR,0,world); - - // strip comment, skip line if blank - - if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = utils::trim_and_count_words(line); - if (nwords == 0) continue; - - if (stats == 0) { // Header NET - tstr = strtok(line,"' \t\n\r\f"); - if (strncmp(tstr, "NET", 3) != 0) error->all(FLERR,"Incorrect format in NET coefficient file"); - - ndescriptors = atoi(strtok(nullptr,"' \t\n\r\f")); - nlayers = atoi(strtok(nullptr,"' \t\n\r\f")); - - memory->create(activation,nlayers,"mliap_model:activation"); - memory->create(nnodes,nlayers,"mliap_model:nnodes"); - memory->create(scale,nelements,2,ndescriptors,"mliap_model:scale"); - - for (int ilayer = 0; ilayer < nlayers; ilayer++) { - tstr = strtok(NULL,"' \t\n\r\f"); - nnodes[ilayer] = atoi(strtok(NULL,"' \t\n\r\f")); - - if (strncmp(tstr, "linear", 6) == 0) activation[ilayer] = 0; - else if (strncmp(tstr, "sigmoid", 7) == 0) activation[ilayer] = 1; - else if (strncmp(tstr, "tanh", 4) == 0) activation[ilayer] = 2; - else if (strncmp(tstr, "relu", 4) == 0) activation[ilayer] = 3; - else activation[ilayer] = 4; - } - - stats = 1; - - } else if (stats == 1) { - scale[ielem][0][l] = atof(strtok(line,"' \t\n\r\f")); - for (int icoeff = 1; icoeff < nwords; icoeff++) { - scale[ielem][0][l+icoeff] = atof(strtok(nullptr,"' \t\n\r\f")); - } - l += nwords; - if (l == ndescriptors) { - stats = 2; - l = 0; - } - - } else if (stats == 2) { - scale[ielem][1][l] = atof(strtok(line,"' \t\n\r\f")); - for (int icoeff = 1; icoeff < nwords; icoeff++) { - scale[ielem][1][l+icoeff] = atof(strtok(nullptr,"' \t\n\r\f")); - } - l += nwords; - if (l == ndescriptors) { - stats = 3; - l = 0; - } - - // set up coeff lists - - } else if (stats == 3) { - // if (nwords > 30) error->all(FLERR,"Wrong number of items per line, max 30"); - - coeffelem[ielem][l] = atof(strtok(line,"' \t\n\r\f")); - for (int icoeff = 1; icoeff < nwords; icoeff++) { - coeffelem[ielem][l+icoeff] = atof(strtok(nullptr,"' \t\n\r\f")); - } - l += nwords; - if (l == nparams) { - stats = 0; - ielem++; - } - } + while (1) { + if (comm->me == 0) { + ptr = fgets(line,MAXLINE,fpcoeff); + if (ptr == nullptr) { + eof = 1; + fclose(fpcoeff); + } else n = strlen(line) + 1; } - if (comm->me == 0) fclose(fpcoeff); + + MPI_Bcast(&eof,1,MPI_INT,0,world); + if (eof) break; + MPI_Bcast(&n,1,MPI_INT,0,world); + MPI_Bcast(line,n,MPI_CHAR,0,world); + + // strip comment, skip line if blank + + if ((ptr = strchr(line,'#'))) *ptr = '\0'; + nwords = utils::trim_and_count_words(line); + if (nwords == 0) continue; + + if (stats == 0) { // Header NET + tstr = strtok(line,"' \t\n\r\f"); + if (strncmp(tstr, "NET", 3) != 0) error->all(FLERR,"Incorrect format in MLIAPModel coefficient file"); + + ndescriptors = atoi(strtok(nullptr,"' \t\n\r\f")); + nlayers = atoi(strtok(nullptr,"' \t\n\r\f")); + + memory->create(activation,nlayers,"mliap_model:activation"); + memory->create(nnodes,nlayers,"mliap_model:nnodes"); + memory->create(scale,nelements,2,ndescriptors,"mliap_model:scale"); + + for (int ilayer = 0; ilayer < nlayers; ilayer++) { + tstr = strtok(NULL,"' \t\n\r\f"); + nnodes[ilayer] = atoi(strtok(NULL,"' \t\n\r\f")); + + if (strncmp(tstr, "linear", 6) == 0) activation[ilayer] = 0; + else if (strncmp(tstr, "sigmoid", 7) == 0) activation[ilayer] = 1; + else if (strncmp(tstr, "tanh", 4) == 0) activation[ilayer] = 2; + else if (strncmp(tstr, "relu", 4) == 0) activation[ilayer] = 3; + else activation[ilayer] = 4; + } + + stats = 1; + + } else if (stats == 1) { + scale[ielem][0][l] = atof(strtok(line,"' \t\n\r\f")); + for (int icoeff = 1; icoeff < nwords; icoeff++) { + scale[ielem][0][l+icoeff] = atof(strtok(nullptr,"' \t\n\r\f")); + } + l += nwords; + if (l == ndescriptors) { + stats = 2; + l = 0; + } + + } else if (stats == 2) { + scale[ielem][1][l] = atof(strtok(line,"' \t\n\r\f")); + for (int icoeff = 1; icoeff < nwords; icoeff++) { + scale[ielem][1][l+icoeff] = atof(strtok(nullptr,"' \t\n\r\f")); + } + l += nwords; + if (l == ndescriptors) { + stats = 3; + l = 0; + } + + // set up coeff lists + + } else if (stats == 3) { + if (nwords > 30) error->all(FLERR,"Incorrect format in MLIAPModel coefficient file"); + + coeffelem[ielem][l] = atof(strtok(line,"' \t\n\r\f")); + for (int icoeff = 1; icoeff < nwords; icoeff++) { + coeffelem[ielem][l+icoeff] = atof(strtok(nullptr,"' \t\n\r\f")); + } + l += nwords; + if (l == nparams) { + stats = 0; + ielem++; + } + } + } + if (comm->me == 0) fclose(fpcoeff); } From 59eaa46f8d8031fc9d599bb2edd8dd38886b1204 Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Mon, 1 Mar 2021 17:41:02 -0700 Subject: [PATCH 10/30] Tweaked README.md and changed permissions on source --- src/MLIAP/README | 57 ----------------------------- src/MLIAP/README.md | 2 +- src/MLIAP/compute_mliap.cpp | 0 src/MLIAP/compute_mliap.h | 0 src/MLIAP/mliap_data.cpp | 0 src/MLIAP/mliap_data.h | 0 src/MLIAP/mliap_descriptor.cpp | 0 src/MLIAP/mliap_descriptor.h | 0 src/MLIAP/mliap_descriptor_snap.cpp | 0 src/MLIAP/mliap_descriptor_snap.h | 0 src/MLIAP/mliap_model.cpp | 0 src/MLIAP/mliap_model.h | 0 src/MLIAP/mliap_model_linear.cpp | 0 src/MLIAP/mliap_model_linear.h | 0 src/MLIAP/mliap_model_python.cpp | 0 src/MLIAP/mliap_model_python.h | 0 src/MLIAP/mliap_model_quadratic.cpp | 0 src/MLIAP/mliap_model_quadratic.h | 0 src/MLIAP/pair_mliap.h | 0 19 files changed, 1 insertion(+), 58 deletions(-) delete mode 100755 src/MLIAP/README mode change 100755 => 100644 src/MLIAP/compute_mliap.cpp mode change 100755 => 100644 src/MLIAP/compute_mliap.h mode change 100755 => 100644 src/MLIAP/mliap_data.cpp mode change 100755 => 100644 src/MLIAP/mliap_data.h mode change 100755 => 100644 src/MLIAP/mliap_descriptor.cpp mode change 100755 => 100644 src/MLIAP/mliap_descriptor.h mode change 100755 => 100644 src/MLIAP/mliap_descriptor_snap.cpp mode change 100755 => 100644 src/MLIAP/mliap_descriptor_snap.h mode change 100755 => 100644 src/MLIAP/mliap_model.cpp mode change 100755 => 100644 src/MLIAP/mliap_model.h mode change 100755 => 100644 src/MLIAP/mliap_model_linear.cpp mode change 100755 => 100644 src/MLIAP/mliap_model_linear.h mode change 100755 => 100644 src/MLIAP/mliap_model_python.cpp mode change 100755 => 100644 src/MLIAP/mliap_model_python.h mode change 100755 => 100644 src/MLIAP/mliap_model_quadratic.cpp mode change 100755 => 100644 src/MLIAP/mliap_model_quadratic.h mode change 100755 => 100644 src/MLIAP/pair_mliap.h diff --git a/src/MLIAP/README b/src/MLIAP/README deleted file mode 100755 index 1ff1e250c5..0000000000 --- a/src/MLIAP/README +++ /dev/null @@ -1,57 +0,0 @@ -This package provides a general interface to families of -machine-learning interatomic potentials (MLIAPs). This interface consists -of a mliap pair style and a mliap compute. - -The mliap pair style is used when running simulations with energies and -forces calculated by an MLIAP. The interface allows separate -definitions of the interatomic potential functional form (*model*) -and the geometric quantities that characterize the atomic positions -(*descriptor*). By defining *model* and *descriptor* separately, -it is possible to use many different models with a given descriptor, -or many different descriptors with a given model. The pair_style -supports the following models: *linear*, *quadratic*, and -*mliappy* (general Python interface to things like PyTorch, see below -for build instructions). -It currently supports only one class of descriptors, -*sna*, the SNAP descriptors, including the -linear, quadratic, and chem variants. -It is straightforward to add new descriptor and model -styles. - -The mliap compute style provides gradients of the energy, force, -and stress tensor w.r.t. model parameters. -These are useful when training MLIAPs to match target data. -Any *model or *descriptor* that has been implemented for the -*mliap* pair style can also be accessed by the *mliap* compute. -In addition to the energy, force, and stress gradients, w.r.t. -each *model* parameter, the compute also calculates the energy, -force, and stress contributions from a user-specified -reference potential. - -To see how this command -can be used within a Python workflow to train machine-learning interatomic -potentials, see the examples in FitSNAP https://github.com/FitSNAP/FitSNAP. - -*Additional instructions for building MLIAP with Python support enabled* - -The *mliappy* energy model requires that the MLIAP package -be compiled with Python support enabled. -This extension, written by Nick Lubbers (LANL), -provides a coupling to PyTorch and other Python modules. -This should be automatically -enabled by default if the prerequisite software is installed. It can be -enforced during CMake configuration by setting the variable -MLIAP_ENABLE_PYTHON=yes or for conventional build by adding -DMLIAP_PYTHON -to the LMP_INC variable in your makefile and running the cythonize script -on the .pyx file(s) copied to the src folder. - -This requires to also install the PYTHON package and have the cython -(https://cython.org) software installed. During configuration/compilation -the cythonize script will be used to convert the provided .pyx file(s) -to C++ code. Please do not run the cythonize script in the src/MLIAP folder. -If you have done so by accident, you need to delete the generated .cpp and .h -file(s) in the src/MLIAP folder or there may be problems during compilation. - -More information on building LAMMPS with this package is here: - -https://lammps.sandia.gov/doc/Build_extras.html#mliap diff --git a/src/MLIAP/README.md b/src/MLIAP/README.md index 65e6a4cc36..92b3e26b83 100644 --- a/src/MLIAP/README.md +++ b/src/MLIAP/README.md @@ -28,7 +28,7 @@ force, and stress contributions from a user-specified reference potential. ## Generating the model files from the third-party packages -- To train the `linear` and `quardratic` model with the SNAP descritptors, see the examples in [FitSNAP](https://github.com/FitSNAP/FitSNAP). +- To train the `linear` and `quadratic` models with the SNAP descriptors, see the examples in [FitSNAP](https://github.com/FitSNAP/FitSNAP). - To train the `nn` model with the SNAP descriptors, check the examples in [PyXtal\_FF](https://github.com/qzhu2017/PyXtal_FF). ## Building MLIAP with Python support diff --git a/src/MLIAP/compute_mliap.cpp b/src/MLIAP/compute_mliap.cpp old mode 100755 new mode 100644 diff --git a/src/MLIAP/compute_mliap.h b/src/MLIAP/compute_mliap.h old mode 100755 new mode 100644 diff --git a/src/MLIAP/mliap_data.cpp b/src/MLIAP/mliap_data.cpp old mode 100755 new mode 100644 diff --git a/src/MLIAP/mliap_data.h b/src/MLIAP/mliap_data.h old mode 100755 new mode 100644 diff --git a/src/MLIAP/mliap_descriptor.cpp b/src/MLIAP/mliap_descriptor.cpp old mode 100755 new mode 100644 diff --git a/src/MLIAP/mliap_descriptor.h b/src/MLIAP/mliap_descriptor.h old mode 100755 new mode 100644 diff --git a/src/MLIAP/mliap_descriptor_snap.cpp b/src/MLIAP/mliap_descriptor_snap.cpp old mode 100755 new mode 100644 diff --git a/src/MLIAP/mliap_descriptor_snap.h b/src/MLIAP/mliap_descriptor_snap.h old mode 100755 new mode 100644 diff --git a/src/MLIAP/mliap_model.cpp b/src/MLIAP/mliap_model.cpp old mode 100755 new mode 100644 diff --git a/src/MLIAP/mliap_model.h b/src/MLIAP/mliap_model.h old mode 100755 new mode 100644 diff --git a/src/MLIAP/mliap_model_linear.cpp b/src/MLIAP/mliap_model_linear.cpp old mode 100755 new mode 100644 diff --git a/src/MLIAP/mliap_model_linear.h b/src/MLIAP/mliap_model_linear.h old mode 100755 new mode 100644 diff --git a/src/MLIAP/mliap_model_python.cpp b/src/MLIAP/mliap_model_python.cpp old mode 100755 new mode 100644 diff --git a/src/MLIAP/mliap_model_python.h b/src/MLIAP/mliap_model_python.h old mode 100755 new mode 100644 diff --git a/src/MLIAP/mliap_model_quadratic.cpp b/src/MLIAP/mliap_model_quadratic.cpp old mode 100755 new mode 100644 diff --git a/src/MLIAP/mliap_model_quadratic.h b/src/MLIAP/mliap_model_quadratic.h old mode 100755 new mode 100644 diff --git a/src/MLIAP/pair_mliap.h b/src/MLIAP/pair_mliap.h old mode 100755 new mode 100644 From 38d076e22e3b0291f278ad5b007f92dc060c0d2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Antonio=20Santos=20Fl=C3=B3rez?= Date: Wed, 3 Mar 2021 13:36:00 -0300 Subject: [PATCH 11/30] Updating nn example and mliap .rst --- doc/src/pair_mliap.rst | 25 +++++++++-- examples/mliap/Cu_nn.mliap.model | 41 ++++++++++++++++++ examples/mliap/Cu_snap.mliap.descriptor | 21 ++++++++++ examples/mliap/in.mliap.snap.nn.Cu | 55 +++++++++++++++++++++++++ 4 files changed, 139 insertions(+), 3 deletions(-) create mode 100644 examples/mliap/Cu_nn.mliap.model create mode 100644 examples/mliap/Cu_snap.mliap.descriptor create mode 100644 examples/mliap/in.mliap.snap.nn.Cu diff --git a/doc/src/pair_mliap.rst b/doc/src/pair_mliap.rst index af0cc9e855..7ef7380abc 100644 --- a/doc/src/pair_mliap.rst +++ b/doc/src/pair_mliap.rst @@ -16,7 +16,7 @@ Syntax .. parsed-literal:: *model* values = style filename - style = *linear* or *quadratic* or *mliappy* + style = *linear* or *quadratic* or *nn* or *mliappy* filename = name of file containing model definitions *descriptor* values = style filename style = *sna* @@ -45,7 +45,7 @@ pair style currently supports just one descriptor style, but it is is straightforward to add new descriptor styles. The SNAP descriptor style *sna* is the same as that used by :doc:`pair_style snap `, including the linear, quadratic, and chem variants. -The available models are *linear*, *quadratic*, and *mliappy*. +The available models are *linear*, *quadratic*, *nn*, and *mliappy*. The *mliappy* style can be used to couple python models, e.g. PyTorch neural network energy models, and requires building LAMMPS with the PYTHON package (see below). @@ -77,13 +77,32 @@ line must contain two integers: * nelems = Number of elements * nparams = Number of parameters -This is followed by one block for each of the *nelem* elements. +When the *model* keyword is *linear* or *quadratic*, +this is followed by one block for each of the *nelem* elements. Each block consists of *nparams* parameters, one per line. Note that this format is similar, but not identical to that used for the :doc:`pair_style snap ` coefficient file. Specifically, the line containing the element weight and radius is omitted, since these are handled by the *descriptor*. +When the *model* keyword is *nn* (neural networks), the model file can contain +blank and comment lines (start with #) anywhere. The second non-blank non-comment +line must contain the string NET, followed by two integers: + +* ndescriptors = Number of descriptors +* nlayers = Number of layers (including the hidden layers and the output layer) + +and followed by a sequence of a string and an integer for each layer: + +* Activation function (linear, sigmoid, tanh or relu) +* nnodes = Number of nodes + +This is followed by one block for each of the *nelem* elements. Each block consists +of *scale0* minimum values, *scale1* (maximum - minimum) values, +in order to normalize the descriptors, followed by *nparams* parameters, +including *bias* and *weights* of the model, starting with the first node of the first layer +and so on, max. 30 parameters per line. + Notes on mliappy models: When the *model* keyword is *mliappy*, the filename should end in '.pt', '.pth' for pytorch models, or be a pickle file. To load a model from diff --git a/examples/mliap/Cu_nn.mliap.model b/examples/mliap/Cu_nn.mliap.model new file mode 100644 index 0000000000..7c94959764 --- /dev/null +++ b/examples/mliap/Cu_nn.mliap.model @@ -0,0 +1,41 @@ +# DATE: 2021-03-03 UNITS: metal CONTRIBUTOR: Pedro Antonio Santos Florez pedroantoniosantosf@gmail.com CITATION: none +# Neural networks weights generated in PyXtal_FF + +# total_species nparams +1 71 + +# NET ndescriptors nlayers activation_func for layer 1, number of nodes for layer 1, ..., ..., ...., +NET 30 3 tanh 2 tanh 2 linear 1 + +# Scale0 + 98.5564567301067 0.1817576370006 -5.0513436999162 0.0453581866073 -4.4382278670569 + -2.6985391112026 -4.9445068940273 7.8840372041149 -12.8729456412560 -2.9748781222888 + -1.7702149043285 -4.6911979511282 -1.8167140506334 67.7067032503211 -12.5675074252146 + -10.3889411514447 -2.6194029974308 1.8750503488944 -5.0934919399232 4.2037760919263 + 20.6488797181668 -8.2381178902428 -3.1311436510232 -1.1570117080256 2.1652328079269 + 0.0854872341687 73.5970916724043 -5.3230176040510 -5.3409170596296 -6.4491186818574 + +# Scale1 + 783.0204659783215 33.6453931227955 7.9068346594951 32.2509031640463 5.6624925894670 + 5.6511565657016 8.2175114613285 108.9434600935519 16.3162547782998 6.4485086884047 + 9.5767453287024 24.1576638495153 25.1723098340896 202.6741688060115 26.3843102888906 + 19.7937707236334 13.9016635198379 14.1399097533048 72.7078614093291 39.8358080634714 + 370.1745750951991 21.6864533954642 14.6554778261065 18.6456437491491 43.2946309680355 + 68.9168418942695 481.9819429675007 14.5585849595560 61.9026061535013 112.5968384702330 + +# Coefficients + -0.2503221860648 0.4607794046378 0.4080552184108 0.0043328332206 0.2778722163950 + -0.0050555739235 0.0406748042003 -0.1188215011883 0.4669700426246 0.4050949681583 + 0.3004118858813 -0.3937378155782 0.5165632847373 0.1381866719908 -0.3996533578004 + 0.1330571447244 0.1124773980921 0.1548275555377 -0.6221152970188 -0.7813275942231 + -0.4320969824072 0.2045533448767 -0.1687644566507 -0.0424066840175 -0.1981208883936 + -0.3406471991751 0.1272788573915 -0.1236220514264 0.6482374783971 -0.0590428211363 + 0.1326060235944 0.1890472518561 -0.5428894028577 0.0229420637813 0.0750842032804 + -0.2443049940974 0.5265826743321 -0.1802773940492 0.0309737044359 -0.4987806786020 + -0.6233577810656 -0.9910225261357 0.3430680860751 0.2918559145139 0.0666915892882 + -0.2558026088950 0.0417769401952 -0.2582828540822 -0.3685977011673 0.4793473883461 + 1.0290706767456 0.0400544448686 -0.1474888333296 0.2403156153173 0.1050109023846 + 0.1413378531949 0.0907250056918 -0.1185878739508 0.1471942864979 -0.2829701766758 + 0.1137318187684 0.0476123438306 0.8040349098084 -0.5432518550512 0.2312003570779 + 0.6886872913686 -0.1247049894693 0.6848986783339 -2.6353147047309 -0.7173579584864 + -1.0543148168289 diff --git a/examples/mliap/Cu_snap.mliap.descriptor b/examples/mliap/Cu_snap.mliap.descriptor new file mode 100644 index 0000000000..eb9b6bbe9c --- /dev/null +++ b/examples/mliap/Cu_snap.mliap.descriptor @@ -0,0 +1,21 @@ +# DATE: 2021-03-03 UNITS: metal CONTRIBUTOR: Pedro Antonio Santos Florez pedroantoniosantosf@gmail.com CITATION: none + +# LAMMPS SNAP parameters for Cu + +# required +rcutfac 5.0 +twojmax 6 + +# elements + +nelems 1 +elems Cu +radelems 0.5 +welems 1.0 + +# optional + +rfac0 0.99363 +rmin0 0 +bzeroflag 0 +switchflag 1 diff --git a/examples/mliap/in.mliap.snap.nn.Cu b/examples/mliap/in.mliap.snap.nn.Cu new file mode 100644 index 0000000000..db217468b0 --- /dev/null +++ b/examples/mliap/in.mliap.snap.nn.Cu @@ -0,0 +1,55 @@ + +# Demonstrate MLIAP interface to SNAP nn Cu potential + +# Initialize simulation + +variable nsteps index 100 +variable nrep equal 4 +variable a equal 3.621262 +units metal + + +# generate the box and atom positions using a BCC lattice + +variable nx equal ${nrep} +variable ny equal ${nrep} +variable nz equal ${nrep} + +boundary p p p + +lattice fcc $a +region box block 0 ${nx} 0 ${ny} 0 ${nz} +create_box 1 box +create_atoms 1 box + +mass 1 63.546 + +# choose potential + +pair_style mliap model nn Cu_nn.mliap.model descriptor sna Cu_snap.mliap.descriptor +pair_coeff * * Cu Cu + +# Setup output + +compute eatom all pe/atom +compute energy all reduce sum c_eatom + +compute satom all stress/atom NULL +compute str all reduce sum c_satom[1] c_satom[2] c_satom[3] +variable press equal (c_str[1]+c_str[2]+c_str[3])/(3*vol) + +thermo_style custom step temp epair c_energy etotal press v_press +thermo 10 +thermo_modify norm yes + +# Set up NVE run + +timestep 0.5e-3 +neighbor 1.0 bin +neigh_modify once no every 1 delay 0 check yes + +# Run MD + +velocity all create 300.0 4928459 loop geom +fix 1 all nve +run ${nsteps} From 8f9520b4bbcef961a7de89766f4211ee61d0041f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Antonio=20Santos=20Fl=C3=B3rez?= Date: Wed, 3 Mar 2021 13:39:26 -0300 Subject: [PATCH 12/30] Create log.Cu_nn --- examples/mliap/log.Cu_nn | 135 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 examples/mliap/log.Cu_nn diff --git a/examples/mliap/log.Cu_nn b/examples/mliap/log.Cu_nn new file mode 100644 index 0000000000..69aacd817f --- /dev/null +++ b/examples/mliap/log.Cu_nn @@ -0,0 +1,135 @@ +LAMMPS (10 Feb 2021) + +# Demonstrate MLIAP interface to SNAP nn Cu potential + +# Initialize simulation + +variable nsteps index 100 +variable nrep equal 4 +variable a equal 3.621262 +units metal + + +# generate the box and atom positions using a BCC lattice + +variable nx equal ${nrep} +variable nx equal 4 +variable ny equal ${nrep} +variable ny equal 4 +variable nz equal ${nrep} +variable nz equal 4 + +boundary p p p + +lattice fcc $a +lattice fcc 3.621262 +Lattice spacing in x,y,z = 3.6212620 3.6212620 3.6212620 +region box block 0 ${nx} 0 ${ny} 0 ${nz} +region box block 0 4 0 ${ny} 0 ${nz} +region box block 0 4 0 4 0 ${nz} +region box block 0 4 0 4 0 4 +create_box 1 box +Created orthogonal box = (0.0000000 0.0000000 0.0000000) to (14.485048 14.485048 14.485048) + 1 by 1 by 1 MPI processor grid +create_atoms 1 box +Created 256 atoms + create_atoms CPU = 0.000 seconds + +mass 1 63.546 + +# choose potential + +pair_style mliap model nn Cu_nn.mliap.model descriptor sna Cu_snap.mliap.descriptor +Reading potential file Cu_nn.mliap.model with DATE: 2021-03-03 +Reading potential file Cu_snap.mliap.descriptor with DATE: 2021-03-03 +SNAP keyword rcutfac 5.0 +SNAP keyword twojmax 6 +SNAP keyword nelems 1 +SNAP keyword elems Cu +SNAP keyword radelems 0.5 +SNAP keyword welems 1.0 +SNAP keyword rfac0 0.99363 +SNAP keyword rmin0 0 +SNAP keyword bzeroflag 0 +SNAP keyword switchflag 1 +pair_coeff * * Cu Cu + +# Setup output + +compute eatom all pe/atom +compute energy all reduce sum c_eatom + +compute satom all stress/atom NULL +compute str all reduce sum c_satom[1] c_satom[2] c_satom[3] +variable press equal (c_str[1]+c_str[2]+c_str[3])/(3*vol) + +thermo_style custom step temp epair c_energy etotal press v_press +thermo 10 +thermo_modify norm yes + +# Set up NVE run + +timestep 0.5e-3 +neighbor 1.0 bin +neigh_modify once no every 1 delay 0 check yes + +# Run MD + +velocity all create 300.0 4928459 loop geom +fix 1 all nve +run ${nsteps} +run 100 +Neighbor list info ... + update every 1 steps, delay 0 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 6 + ghost atom cutoff = 6 + binsize = 3, bins = 5 5 5 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair mliap, perpetual + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 31.17 | 31.17 | 31.17 Mbytes +Step Temp E_pair c_energy TotEng Press v_press + 0 300 -4.0935581 -4.0935581 -4.0549315 -2916.7505 2916.7505 + 10 294.19698 -4.0927997 -4.0927997 -4.0549203 -2653.7504 2653.7504 + 20 277.15991 -4.0905816 -4.0905816 -4.0548958 -1875.7718 1875.7718 + 30 250.30462 -4.0870777 -4.0870777 -4.0548496 -618.45378 618.45378 + 40 215.94455 -4.0825861 -4.0825861 -4.0547821 1014.6151 -1014.6151 + 50 177.29307 -4.0775299 -4.0775299 -4.0547025 2846.7675 -2846.7675 + 60 138.26899 -4.072429 -4.072429 -4.0546261 4698.9654 -4698.9654 + 70 103.04321 -4.0678341 -4.0678341 -4.0545667 6401.8077 -6401.8077 + 80 75.426905 -4.0642423 -4.0642423 -4.0545307 7766.2217 -7766.2217 + 90 58.150738 -4.0620015 -4.0620015 -4.0545143 8668.0598 -8668.0598 + 100 52.301012 -4.0612408 -4.0612408 -4.0545067 9049.3141 -9049.3141 +Loop time of 4.41003 on 1 procs for 100 steps with 256 atoms + +Performance: 0.980 ns/day, 24.500 hours/ns, 22.676 timesteps/s +98.1% CPU use with 1 MPI tasks x no OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 4.4064 | 4.4064 | 4.4064 | 0.0 | 99.92 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 0.001466 | 0.001466 | 0.001466 | 0.0 | 0.03 +Output | 0.000872 | 0.000872 | 0.000872 | 0.0 | 0.02 +Modify | 0.000699 | 0.000699 | 0.000699 | 0.0 | 0.02 +Other | | 0.000632 | | | 0.01 + +Nlocal: 256.000 ave 256 max 256 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 1431.00 ave 1431 max 1431 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 0.00000 ave 0 max 0 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +FullNghs: 19968.0 ave 19968 max 19968 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 19968 +Ave neighs/atom = 78.000000 +Neighbor list builds = 0 +Dangerous builds = 0 +Total wall time: 0:00:04 From b7367e713acd8164ace92eb362601117da0b214a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Antonio=20Santos=20Fl=C3=B3rez?= Date: Wed, 3 Mar 2021 14:09:03 -0300 Subject: [PATCH 13/30] Update in.mliap.snap.nn.Cu --- examples/mliap/in.mliap.snap.nn.Cu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/mliap/in.mliap.snap.nn.Cu b/examples/mliap/in.mliap.snap.nn.Cu index db217468b0..bc6648ff46 100644 --- a/examples/mliap/in.mliap.snap.nn.Cu +++ b/examples/mliap/in.mliap.snap.nn.Cu @@ -9,7 +9,7 @@ variable a equal 3.621262 units metal -# generate the box and atom positions using a BCC lattice +# generate the box and atom positions using a FCC lattice variable nx equal ${nrep} variable ny equal ${nrep} From 6c0c6ce3b0f643474e6d811018b115bfaacdfdc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Antonio=20Santos=20Fl=C3=B3rez?= Date: Wed, 3 Mar 2021 14:53:56 -0300 Subject: [PATCH 14/30] example Ta06A using nn --- examples/mliap/Ta06A.mliap.nn | 18 +++ examples/mliap/Ta06A_nn.mliap.model | 15 +++ examples/mliap/in.mliap.nn.Ta06A | 53 ++++++++ examples/mliap/log.03Mar21.mliap.nn_Ta06A | 156 ++++++++++++++++++++++ 4 files changed, 242 insertions(+) create mode 100644 examples/mliap/Ta06A.mliap.nn create mode 100644 examples/mliap/Ta06A_nn.mliap.model create mode 100644 examples/mliap/in.mliap.nn.Ta06A create mode 100644 examples/mliap/log.03Mar21.mliap.nn_Ta06A diff --git a/examples/mliap/Ta06A.mliap.nn b/examples/mliap/Ta06A.mliap.nn new file mode 100644 index 0000000000..01246354c5 --- /dev/null +++ b/examples/mliap/Ta06A.mliap.nn @@ -0,0 +1,18 @@ +# DATE: 2014-09-05 UNITS: metal CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: Thompson, Swiler, Trott, Foiles and Tucker, arxiv.org, 1409.3880 (2014) + +# Definition of SNAP potential Ta_Cand06A +# Assumes 1 LAMMPS atom type + +variable zblcutinner equal 4 +variable zblcutouter equal 4.8 +variable zblz equal 73 + +# Specify hybrid with SNAP, ZBL + +pair_style hybrid/overlay & +zbl ${zblcutinner} ${zblcutouter} & +mliap model nn Ta06A_nn.mliap.model & +descriptor sna Ta06A.mliap.descriptor +pair_coeff 1 1 zbl ${zblz} ${zblz} +pair_coeff * * mliap Ta + diff --git a/examples/mliap/Ta06A_nn.mliap.model b/examples/mliap/Ta06A_nn.mliap.model new file mode 100644 index 0000000000..551a98f572 --- /dev/null +++ b/examples/mliap/Ta06A_nn.mliap.model @@ -0,0 +1,15 @@ +# DATE: 2021-03-03 UNITS: metal CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: Thompson, Swiler, Trott, Foiles and Tucker, arxiv.org, 1409.3880 (2014) + +# LAMMPS SNAP_nn coefficients for Ta_Cand06A + +# nelements nparams +1 31 +# NET #ndescriptors #nlayers #activation_func for layer 1 #number of nodes for layer 1, ..., ..., ...., +NET 30 1 linear 1 +#scale0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +#scale1 +1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 +#coeff +-2.92477 +-0.01137 -0.00775 -0.04907 -0.15047 0.09157 0.05590 0.05785 -0.11615 -0.17122 -0.10583 0.03941 -0.11284 0.03939 -0.07331 -0.06582 -0.09341 -0.10587 -0.15497 0.04820 0.00205 0.00060 -0.04898 -0.05084 -0.03371 -0.01441 -0.01501 -0.00599 -0.06373 0.03965 0.01072 diff --git a/examples/mliap/in.mliap.nn.Ta06A b/examples/mliap/in.mliap.nn.Ta06A new file mode 100644 index 0000000000..f33744184a --- /dev/null +++ b/examples/mliap/in.mliap.nn.Ta06A @@ -0,0 +1,53 @@ +# Demonstrate MLIAP interface to linear SNAP potential + +# Initialize simulation + +variable nsteps index 100 +variable nrep equal 4 +variable a equal 3.316 +units metal + +# generate the box and atom positions using a BCC lattice + +variable nx equal ${nrep} +variable ny equal ${nrep} +variable nz equal ${nrep} + +boundary p p p + +lattice bcc $a +region box block 0 ${nx} 0 ${ny} 0 ${nz} +create_box 1 box +create_atoms 1 box + +mass 1 180.88 + +# choose potential + +include Ta06A.mliap.nn + +# Setup output + +compute eatom all pe/atom +compute energy all reduce sum c_eatom + +compute satom all stress/atom NULL +compute str all reduce sum c_satom[1] c_satom[2] c_satom[3] +variable press equal (c_str[1]+c_str[2]+c_str[3])/(3*vol) + +thermo_style custom step temp epair c_energy etotal press v_press +thermo 10 +thermo_modify norm yes + +# Set up NVE run + +timestep 0.5e-3 +neighbor 1.0 bin +neigh_modify once no every 1 delay 0 check yes + +# Run MD + +velocity all create 300.0 4928459 loop geom +fix 1 all nve +run ${nsteps} + diff --git a/examples/mliap/log.03Mar21.mliap.nn_Ta06A b/examples/mliap/log.03Mar21.mliap.nn_Ta06A new file mode 100644 index 0000000000..966f644684 --- /dev/null +++ b/examples/mliap/log.03Mar21.mliap.nn_Ta06A @@ -0,0 +1,156 @@ +LAMMPS (10 Feb 2021) +# Demonstrate MLIAP interface to linear SNAP potential + +# Initialize simulation + +variable nsteps index 100 +variable nrep equal 4 +variable a equal 3.316 +units metal + +# generate the box and atom positions using a BCC lattice + +variable nx equal ${nrep} +variable nx equal 4 +variable ny equal ${nrep} +variable ny equal 4 +variable nz equal ${nrep} +variable nz equal 4 + +boundary p p p + +lattice bcc $a +lattice bcc 3.316 +Lattice spacing in x,y,z = 3.3160000 3.3160000 3.3160000 +region box block 0 ${nx} 0 ${ny} 0 ${nz} +region box block 0 4 0 ${ny} 0 ${nz} +region box block 0 4 0 4 0 ${nz} +region box block 0 4 0 4 0 4 +create_box 1 box +Created orthogonal box = (0.0000000 0.0000000 0.0000000) to (13.264000 13.264000 13.264000) + 1 by 1 by 1 MPI processor grid +create_atoms 1 box +Created 128 atoms + create_atoms CPU = 0.000 seconds + +mass 1 180.88 + +# choose potential + +include Ta06A.mliap.nn +# DATE: 2014-09-05 UNITS: metal CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: Thompson, Swiler, Trott, Foiles and Tucker, arxiv.org, 1409.3880 (2014) + +# Definition of SNAP potential Ta_Cand06A +# Assumes 1 LAMMPS atom type + +variable zblcutinner equal 4 +variable zblcutouter equal 4.8 +variable zblz equal 73 + +# Specify hybrid with SNAP, ZBL + +pair_style hybrid/overlay zbl ${zblcutinner} ${zblcutouter} mliap model nn Ta06A_nn.mliap.model descriptor sna Ta06A.mliap.descriptor +pair_style hybrid/overlay zbl 4 ${zblcutouter} mliap model nn Ta06A_nn.mliap.model descriptor sna Ta06A.mliap.descriptor +pair_style hybrid/overlay zbl 4 4.8 mliap model nn Ta06A_nn.mliap.model descriptor sna Ta06A.mliap.descriptor +Reading potential file Ta06A_nn.mliap.model with DATE: 2021-03-03 +Reading potential file Ta06A.mliap.descriptor with DATE: 2014-09-05 +SNAP keyword rcutfac 4.67637 +SNAP keyword twojmax 6 +SNAP keyword nelems 1 +SNAP keyword elems Ta +SNAP keyword radelems 0.5 +SNAP keyword welems 1 +SNAP keyword rfac0 0.99363 +SNAP keyword rmin0 0 +SNAP keyword bzeroflag 0 +pair_coeff 1 1 zbl ${zblz} ${zblz} +pair_coeff 1 1 zbl 73 ${zblz} +pair_coeff 1 1 zbl 73 73 +pair_coeff * * mliap Ta + + +# Setup output + +compute eatom all pe/atom +compute energy all reduce sum c_eatom + +compute satom all stress/atom NULL +compute str all reduce sum c_satom[1] c_satom[2] c_satom[3] +variable press equal (c_str[1]+c_str[2]+c_str[3])/(3*vol) + +thermo_style custom step temp epair c_energy etotal press v_press +thermo 10 +thermo_modify norm yes + +# Set up NVE run + +timestep 0.5e-3 +neighbor 1.0 bin +neigh_modify once no every 1 delay 0 check yes + +# Run MD + +velocity all create 300.0 4928459 loop geom +fix 1 all nve +run ${nsteps} +run 100 +Neighbor list info ... + update every 1 steps, delay 0 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 5.8 + ghost atom cutoff = 5.8 + binsize = 2.9, bins = 5 5 5 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair zbl, perpetual, half/full from (2) + attributes: half, newton on + pair build: halffull/newton + stencil: none + bin: none + (2) pair mliap, perpetual + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 18.15 | 18.15 | 18.15 Mbytes +Step Temp E_pair c_energy TotEng Press v_press + 0 300 -11.85157 -11.85157 -11.813095 2717.1661 -2717.1661 + 10 296.01467 -11.851059 -11.851059 -11.813095 2697.4796 -2697.4796 + 20 284.53666 -11.849587 -11.849587 -11.813095 2289.1527 -2289.1527 + 30 266.51577 -11.847275 -11.847275 -11.813095 1851.7131 -1851.7131 + 40 243.05007 -11.844266 -11.844266 -11.813095 1570.684 -1570.684 + 50 215.51032 -11.840734 -11.840734 -11.813094 1468.1899 -1468.1899 + 60 185.48331 -11.836883 -11.836883 -11.813094 1524.8757 -1524.8757 + 70 154.6736 -11.832931 -11.832931 -11.813094 1698.3351 -1698.3351 + 80 124.79303 -11.829099 -11.829099 -11.813094 1947.0715 -1947.0715 + 90 97.448054 -11.825592 -11.825592 -11.813094 2231.9563 -2231.9563 + 100 74.035418 -11.822589 -11.822589 -11.813094 2515.8526 -2515.8526 +Loop time of 1.19515 on 1 procs for 100 steps with 128 atoms + +Performance: 3.615 ns/day, 6.640 hours/ns, 83.671 timesteps/s +98.5% CPU use with 1 MPI tasks x no OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 1.1924 | 1.1924 | 1.1924 | 0.0 | 99.77 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 0.000961 | 0.000961 | 0.000961 | 0.0 | 0.08 +Output | 0.000707 | 0.000707 | 0.000707 | 0.0 | 0.06 +Modify | 0.000459 | 0.000459 | 0.000459 | 0.0 | 0.04 +Other | | 0.00065 | | | 0.05 + +Nlocal: 128.000 ave 128 max 128 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 727.000 ave 727 max 727 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 3712.00 ave 3712 max 3712 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +FullNghs: 7424.00 ave 7424 max 7424 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 7424 +Ave neighs/atom = 58.000000 +Neighbor list builds = 0 +Dangerous builds = 0 + +Total wall time: 0:00:01 From abfc4465b090fb7ac4313f9f0f6a8af41220dbdf Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Wed, 3 Mar 2021 11:38:05 -0700 Subject: [PATCH 15/30] Rearranged nn file locations and names --- examples/mliap/Cu.nn.mliap.model | 1 + examples/mliap/Cu.snap.mliap.descriptor | 1 + examples/mliap/Ta06A.mliap.nn | 19 +-- examples/mliap/Ta06A.nn.mliap.model | 1 + examples/mliap/in.mliap.snap.nn.Cu | 6 +- ....mliap.nn.Ta06A => in.mliap.snap.nn.Ta06A} | 0 ..._nn => log.03Mar21.mliap.snap.nn.Cu.g++.1} | 31 ++-- .../mliap/log.03Mar21.mliap.snap.nn.Cu.g++.4 | 134 +++++++++++++++ ... => log.03Mar21.mliap.snap.nn.Ta06A.g++.1} | 27 +-- .../log.03Mar21.mliap.snap.nn.Ta06A.g++.4 | 157 ++++++++++++++++++ examples/mliap/log.snap.Ta06A.ref | 154 ----------------- .../Cu.nn.mliap.model | 0 .../Cu.snap.mliap.descriptor | 0 potentials/Ta06A.mliap.nn | 18 ++ .../mliap => potentials}/Ta06A.mliap.pytorch | 0 .../Ta06A.nn.mliap.model | 0 16 files changed, 344 insertions(+), 205 deletions(-) create mode 120000 examples/mliap/Cu.nn.mliap.model create mode 120000 examples/mliap/Cu.snap.mliap.descriptor mode change 100644 => 120000 examples/mliap/Ta06A.mliap.nn create mode 120000 examples/mliap/Ta06A.nn.mliap.model rename examples/mliap/{in.mliap.nn.Ta06A => in.mliap.snap.nn.Ta06A} (100%) rename examples/mliap/{log.Cu_nn => log.03Mar21.mliap.snap.nn.Cu.g++.1} (82%) create mode 100644 examples/mliap/log.03Mar21.mliap.snap.nn.Cu.g++.4 rename examples/mliap/{log.03Mar21.mliap.nn_Ta06A => log.03Mar21.mliap.snap.nn.Ta06A.g++.1} (85%) create mode 100644 examples/mliap/log.03Mar21.mliap.snap.nn.Ta06A.g++.4 delete mode 100644 examples/mliap/log.snap.Ta06A.ref rename examples/mliap/Cu_nn.mliap.model => potentials/Cu.nn.mliap.model (100%) rename examples/mliap/Cu_snap.mliap.descriptor => potentials/Cu.snap.mliap.descriptor (100%) create mode 100644 potentials/Ta06A.mliap.nn rename {examples/mliap => potentials}/Ta06A.mliap.pytorch (100%) rename examples/mliap/Ta06A_nn.mliap.model => potentials/Ta06A.nn.mliap.model (100%) diff --git a/examples/mliap/Cu.nn.mliap.model b/examples/mliap/Cu.nn.mliap.model new file mode 120000 index 0000000000..5905004548 --- /dev/null +++ b/examples/mliap/Cu.nn.mliap.model @@ -0,0 +1 @@ +../../potentials/Cu.nn.mliap.model \ No newline at end of file diff --git a/examples/mliap/Cu.snap.mliap.descriptor b/examples/mliap/Cu.snap.mliap.descriptor new file mode 120000 index 0000000000..6cc612ec54 --- /dev/null +++ b/examples/mliap/Cu.snap.mliap.descriptor @@ -0,0 +1 @@ +../../potentials/Cu.snap.mliap.descriptor \ No newline at end of file diff --git a/examples/mliap/Ta06A.mliap.nn b/examples/mliap/Ta06A.mliap.nn deleted file mode 100644 index 01246354c5..0000000000 --- a/examples/mliap/Ta06A.mliap.nn +++ /dev/null @@ -1,18 +0,0 @@ -# DATE: 2014-09-05 UNITS: metal CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: Thompson, Swiler, Trott, Foiles and Tucker, arxiv.org, 1409.3880 (2014) - -# Definition of SNAP potential Ta_Cand06A -# Assumes 1 LAMMPS atom type - -variable zblcutinner equal 4 -variable zblcutouter equal 4.8 -variable zblz equal 73 - -# Specify hybrid with SNAP, ZBL - -pair_style hybrid/overlay & -zbl ${zblcutinner} ${zblcutouter} & -mliap model nn Ta06A_nn.mliap.model & -descriptor sna Ta06A.mliap.descriptor -pair_coeff 1 1 zbl ${zblz} ${zblz} -pair_coeff * * mliap Ta - diff --git a/examples/mliap/Ta06A.mliap.nn b/examples/mliap/Ta06A.mliap.nn new file mode 120000 index 0000000000..4aab212e4f --- /dev/null +++ b/examples/mliap/Ta06A.mliap.nn @@ -0,0 +1 @@ +../../potentials/Ta06A.mliap.nn \ No newline at end of file diff --git a/examples/mliap/Ta06A.nn.mliap.model b/examples/mliap/Ta06A.nn.mliap.model new file mode 120000 index 0000000000..a67f930cf8 --- /dev/null +++ b/examples/mliap/Ta06A.nn.mliap.model @@ -0,0 +1 @@ +../../potentials/Ta06A.nn.mliap.model \ No newline at end of file diff --git a/examples/mliap/in.mliap.snap.nn.Cu b/examples/mliap/in.mliap.snap.nn.Cu index bc6648ff46..7ac7d4b56e 100644 --- a/examples/mliap/in.mliap.snap.nn.Cu +++ b/examples/mliap/in.mliap.snap.nn.Cu @@ -1,4 +1,3 @@ - # Demonstrate MLIAP interface to SNAP nn Cu potential # Initialize simulation @@ -8,7 +7,6 @@ variable nrep equal 4 variable a equal 3.621262 units metal - # generate the box and atom positions using a FCC lattice variable nx equal ${nrep} @@ -26,8 +24,8 @@ mass 1 63.546 # choose potential -pair_style mliap model nn Cu_nn.mliap.model descriptor sna Cu_snap.mliap.descriptor -pair_coeff * * Cu Cu +pair_style mliap model nn Cu.nn.mliap.model descriptor sna Cu.snap.mliap.descriptor +pair_coeff * * Cu # Setup output diff --git a/examples/mliap/in.mliap.nn.Ta06A b/examples/mliap/in.mliap.snap.nn.Ta06A similarity index 100% rename from examples/mliap/in.mliap.nn.Ta06A rename to examples/mliap/in.mliap.snap.nn.Ta06A diff --git a/examples/mliap/log.Cu_nn b/examples/mliap/log.03Mar21.mliap.snap.nn.Cu.g++.1 similarity index 82% rename from examples/mliap/log.Cu_nn rename to examples/mliap/log.03Mar21.mliap.snap.nn.Cu.g++.1 index 69aacd817f..678de992f7 100644 --- a/examples/mliap/log.Cu_nn +++ b/examples/mliap/log.03Mar21.mliap.snap.nn.Cu.g++.1 @@ -1,5 +1,5 @@ LAMMPS (10 Feb 2021) - + using 1 OpenMP thread(s) per MPI task # Demonstrate MLIAP interface to SNAP nn Cu potential # Initialize simulation @@ -9,8 +9,7 @@ variable nrep equal 4 variable a equal 3.621262 units metal - -# generate the box and atom positions using a BCC lattice +# generate the box and atom positions using a FCC lattice variable nx equal ${nrep} variable nx equal 4 @@ -39,9 +38,9 @@ mass 1 63.546 # choose potential -pair_style mliap model nn Cu_nn.mliap.model descriptor sna Cu_snap.mliap.descriptor -Reading potential file Cu_nn.mliap.model with DATE: 2021-03-03 -Reading potential file Cu_snap.mliap.descriptor with DATE: 2021-03-03 +pair_style mliap model nn Cu.nn.mliap.model descriptor sna Cu.snap.mliap.descriptor +Reading potential file Cu.nn.mliap.model with DATE: 2021-03-03 +Reading potential file Cu.snap.mliap.descriptor with DATE: 2021-03-03 SNAP keyword rcutfac 5.0 SNAP keyword twojmax 6 SNAP keyword nelems 1 @@ -52,7 +51,7 @@ SNAP keyword rfac0 0.99363 SNAP keyword rmin0 0 SNAP keyword bzeroflag 0 SNAP keyword switchflag 1 -pair_coeff * * Cu Cu +pair_coeff * * Cu # Setup output @@ -104,20 +103,20 @@ Step Temp E_pair c_energy TotEng Press v_press 80 75.426905 -4.0642423 -4.0642423 -4.0545307 7766.2217 -7766.2217 90 58.150738 -4.0620015 -4.0620015 -4.0545143 8668.0598 -8668.0598 100 52.301012 -4.0612408 -4.0612408 -4.0545067 9049.3141 -9049.3141 -Loop time of 4.41003 on 1 procs for 100 steps with 256 atoms +Loop time of 12.8453 on 1 procs for 100 steps with 256 atoms -Performance: 0.980 ns/day, 24.500 hours/ns, 22.676 timesteps/s -98.1% CPU use with 1 MPI tasks x no OpenMP threads +Performance: 0.336 ns/day, 71.363 hours/ns, 7.785 timesteps/s +100.0% CPU use with 1 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 4.4064 | 4.4064 | 4.4064 | 0.0 | 99.92 +Pair | 12.842 | 12.842 | 12.842 | 0.0 | 99.97 Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0.001466 | 0.001466 | 0.001466 | 0.0 | 0.03 -Output | 0.000872 | 0.000872 | 0.000872 | 0.0 | 0.02 -Modify | 0.000699 | 0.000699 | 0.000699 | 0.0 | 0.02 -Other | | 0.000632 | | | 0.01 +Comm | 0.0014137 | 0.0014137 | 0.0014137 | 0.0 | 0.01 +Output | 0.00090703 | 0.00090703 | 0.00090703 | 0.0 | 0.01 +Modify | 0.0007583 | 0.0007583 | 0.0007583 | 0.0 | 0.01 +Other | | 0.0003434 | | | 0.00 Nlocal: 256.000 ave 256 max 256 min Histogram: 1 0 0 0 0 0 0 0 0 0 @@ -132,4 +131,4 @@ Total # of neighbors = 19968 Ave neighs/atom = 78.000000 Neighbor list builds = 0 Dangerous builds = 0 -Total wall time: 0:00:04 +Total wall time: 0:00:13 diff --git a/examples/mliap/log.03Mar21.mliap.snap.nn.Cu.g++.4 b/examples/mliap/log.03Mar21.mliap.snap.nn.Cu.g++.4 new file mode 100644 index 0000000000..cc4e98a249 --- /dev/null +++ b/examples/mliap/log.03Mar21.mliap.snap.nn.Cu.g++.4 @@ -0,0 +1,134 @@ +LAMMPS (10 Feb 2021) + using 1 OpenMP thread(s) per MPI task +# Demonstrate MLIAP interface to SNAP nn Cu potential + +# Initialize simulation + +variable nsteps index 100 +variable nrep equal 4 +variable a equal 3.621262 +units metal + +# generate the box and atom positions using a FCC lattice + +variable nx equal ${nrep} +variable nx equal 4 +variable ny equal ${nrep} +variable ny equal 4 +variable nz equal ${nrep} +variable nz equal 4 + +boundary p p p + +lattice fcc $a +lattice fcc 3.621262 +Lattice spacing in x,y,z = 3.6212620 3.6212620 3.6212620 +region box block 0 ${nx} 0 ${ny} 0 ${nz} +region box block 0 4 0 ${ny} 0 ${nz} +region box block 0 4 0 4 0 ${nz} +region box block 0 4 0 4 0 4 +create_box 1 box +Created orthogonal box = (0.0000000 0.0000000 0.0000000) to (14.485048 14.485048 14.485048) + 1 by 2 by 2 MPI processor grid +create_atoms 1 box +Created 256 atoms + create_atoms CPU = 0.000 seconds + +mass 1 63.546 + +# choose potential + +pair_style mliap model nn Cu.nn.mliap.model descriptor sna Cu.snap.mliap.descriptor +Reading potential file Cu.nn.mliap.model with DATE: 2021-03-03 +Reading potential file Cu.snap.mliap.descriptor with DATE: 2021-03-03 +SNAP keyword rcutfac 5.0 +SNAP keyword twojmax 6 +SNAP keyword nelems 1 +SNAP keyword elems Cu +SNAP keyword radelems 0.5 +SNAP keyword welems 1.0 +SNAP keyword rfac0 0.99363 +SNAP keyword rmin0 0 +SNAP keyword bzeroflag 0 +SNAP keyword switchflag 1 +pair_coeff * * Cu + +# Setup output + +compute eatom all pe/atom +compute energy all reduce sum c_eatom + +compute satom all stress/atom NULL +compute str all reduce sum c_satom[1] c_satom[2] c_satom[3] +variable press equal (c_str[1]+c_str[2]+c_str[3])/(3*vol) + +thermo_style custom step temp epair c_energy etotal press v_press +thermo 10 +thermo_modify norm yes + +# Set up NVE run + +timestep 0.5e-3 +neighbor 1.0 bin +neigh_modify once no every 1 delay 0 check yes + +# Run MD + +velocity all create 300.0 4928459 loop geom +fix 1 all nve +run ${nsteps} +run 100 +Neighbor list info ... + update every 1 steps, delay 0 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 6 + ghost atom cutoff = 6 + binsize = 3, bins = 5 5 5 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair mliap, perpetual + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 30.85 | 30.85 | 30.85 Mbytes +Step Temp E_pair c_energy TotEng Press v_press + 0 300 -4.0935581 -4.0935581 -4.0549315 -2916.7505 2916.7505 + 10 294.19698 -4.0927997 -4.0927997 -4.0549203 -2653.7504 2653.7504 + 20 277.15991 -4.0905816 -4.0905816 -4.0548958 -1875.7718 1875.7718 + 30 250.30462 -4.0870777 -4.0870777 -4.0548496 -618.45378 618.45378 + 40 215.94455 -4.0825861 -4.0825861 -4.0547821 1014.6151 -1014.6151 + 50 177.29307 -4.0775299 -4.0775299 -4.0547025 2846.7675 -2846.7675 + 60 138.26899 -4.072429 -4.072429 -4.0546261 4698.9654 -4698.9654 + 70 103.04321 -4.0678341 -4.0678341 -4.0545667 6401.8077 -6401.8077 + 80 75.426905 -4.0642423 -4.0642423 -4.0545307 7766.2217 -7766.2217 + 90 58.150738 -4.0620015 -4.0620015 -4.0545143 8668.0598 -8668.0598 + 100 52.301012 -4.0612408 -4.0612408 -4.0545067 9049.3141 -9049.3141 +Loop time of 3.39121 on 4 procs for 100 steps with 256 atoms + +Performance: 1.274 ns/day, 18.840 hours/ns, 29.488 timesteps/s +100.1% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 3.3037 | 3.3421 | 3.3808 | 2.0 | 98.55 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 0.0084965 | 0.047256 | 0.085777 | 17.1 | 1.39 +Output | 0.00091401 | 0.00094114 | 0.00099209 | 0.0 | 0.03 +Modify | 0.00022695 | 0.00024041 | 0.00026185 | 0.0 | 0.01 +Other | | 0.0006503 | | | 0.02 + +Nlocal: 64.0000 ave 64 max 64 min +Histogram: 4 0 0 0 0 0 0 0 0 0 +Nghost: 843.000 ave 843 max 843 min +Histogram: 4 0 0 0 0 0 0 0 0 0 +Neighs: 0.00000 ave 0 max 0 min +Histogram: 4 0 0 0 0 0 0 0 0 0 +FullNghs: 4992.00 ave 4992 max 4992 min +Histogram: 4 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 19968 +Ave neighs/atom = 78.000000 +Neighbor list builds = 0 +Dangerous builds = 0 +Total wall time: 0:00:03 diff --git a/examples/mliap/log.03Mar21.mliap.nn_Ta06A b/examples/mliap/log.03Mar21.mliap.snap.nn.Ta06A.g++.1 similarity index 85% rename from examples/mliap/log.03Mar21.mliap.nn_Ta06A rename to examples/mliap/log.03Mar21.mliap.snap.nn.Ta06A.g++.1 index 966f644684..58dd94a5f0 100644 --- a/examples/mliap/log.03Mar21.mliap.nn_Ta06A +++ b/examples/mliap/log.03Mar21.mliap.snap.nn.Ta06A.g++.1 @@ -1,4 +1,5 @@ LAMMPS (10 Feb 2021) + using 1 OpenMP thread(s) per MPI task # Demonstrate MLIAP interface to linear SNAP potential # Initialize simulation @@ -49,10 +50,10 @@ variable zblz equal 73 # Specify hybrid with SNAP, ZBL -pair_style hybrid/overlay zbl ${zblcutinner} ${zblcutouter} mliap model nn Ta06A_nn.mliap.model descriptor sna Ta06A.mliap.descriptor -pair_style hybrid/overlay zbl 4 ${zblcutouter} mliap model nn Ta06A_nn.mliap.model descriptor sna Ta06A.mliap.descriptor -pair_style hybrid/overlay zbl 4 4.8 mliap model nn Ta06A_nn.mliap.model descriptor sna Ta06A.mliap.descriptor -Reading potential file Ta06A_nn.mliap.model with DATE: 2021-03-03 +pair_style hybrid/overlay zbl ${zblcutinner} ${zblcutouter} mliap model nn Ta06A.nn.mliap.model descriptor sna Ta06A.mliap.descriptor +pair_style hybrid/overlay zbl 4 ${zblcutouter} mliap model nn Ta06A.nn.mliap.model descriptor sna Ta06A.mliap.descriptor +pair_style hybrid/overlay zbl 4 4.8 mliap model nn Ta06A.nn.mliap.model descriptor sna Ta06A.mliap.descriptor +Reading potential file Ta06A.nn.mliap.model with DATE: 2021-03-03 Reading potential file Ta06A.mliap.descriptor with DATE: 2014-09-05 SNAP keyword rcutfac 4.67637 SNAP keyword twojmax 6 @@ -124,20 +125,20 @@ Step Temp E_pair c_energy TotEng Press v_press 80 124.79303 -11.829099 -11.829099 -11.813094 1947.0715 -1947.0715 90 97.448054 -11.825592 -11.825592 -11.813094 2231.9563 -2231.9563 100 74.035418 -11.822589 -11.822589 -11.813094 2515.8526 -2515.8526 -Loop time of 1.19515 on 1 procs for 100 steps with 128 atoms +Loop time of 2.93897 on 1 procs for 100 steps with 128 atoms -Performance: 3.615 ns/day, 6.640 hours/ns, 83.671 timesteps/s -98.5% CPU use with 1 MPI tasks x no OpenMP threads +Performance: 1.470 ns/day, 16.328 hours/ns, 34.026 timesteps/s +100.0% CPU use with 1 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 1.1924 | 1.1924 | 1.1924 | 0.0 | 99.77 +Pair | 2.9368 | 2.9368 | 2.9368 | 0.0 | 99.93 Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0.000961 | 0.000961 | 0.000961 | 0.0 | 0.08 -Output | 0.000707 | 0.000707 | 0.000707 | 0.0 | 0.06 -Modify | 0.000459 | 0.000459 | 0.000459 | 0.0 | 0.04 -Other | | 0.00065 | | | 0.05 +Comm | 0.00074209 | 0.00074209 | 0.00074209 | 0.0 | 0.03 +Output | 0.00078955 | 0.00078955 | 0.00078955 | 0.0 | 0.03 +Modify | 0.00039202 | 0.00039202 | 0.00039202 | 0.0 | 0.01 +Other | | 0.0002685 | | | 0.01 Nlocal: 128.000 ave 128 max 128 min Histogram: 1 0 0 0 0 0 0 0 0 0 @@ -153,4 +154,4 @@ Ave neighs/atom = 58.000000 Neighbor list builds = 0 Dangerous builds = 0 -Total wall time: 0:00:01 +Total wall time: 0:00:02 diff --git a/examples/mliap/log.03Mar21.mliap.snap.nn.Ta06A.g++.4 b/examples/mliap/log.03Mar21.mliap.snap.nn.Ta06A.g++.4 new file mode 100644 index 0000000000..31ca171200 --- /dev/null +++ b/examples/mliap/log.03Mar21.mliap.snap.nn.Ta06A.g++.4 @@ -0,0 +1,157 @@ +LAMMPS (10 Feb 2021) + using 1 OpenMP thread(s) per MPI task +# Demonstrate MLIAP interface to linear SNAP potential + +# Initialize simulation + +variable nsteps index 100 +variable nrep equal 4 +variable a equal 3.316 +units metal + +# generate the box and atom positions using a BCC lattice + +variable nx equal ${nrep} +variable nx equal 4 +variable ny equal ${nrep} +variable ny equal 4 +variable nz equal ${nrep} +variable nz equal 4 + +boundary p p p + +lattice bcc $a +lattice bcc 3.316 +Lattice spacing in x,y,z = 3.3160000 3.3160000 3.3160000 +region box block 0 ${nx} 0 ${ny} 0 ${nz} +region box block 0 4 0 ${ny} 0 ${nz} +region box block 0 4 0 4 0 ${nz} +region box block 0 4 0 4 0 4 +create_box 1 box +Created orthogonal box = (0.0000000 0.0000000 0.0000000) to (13.264000 13.264000 13.264000) + 1 by 2 by 2 MPI processor grid +create_atoms 1 box +Created 128 atoms + create_atoms CPU = 0.000 seconds + +mass 1 180.88 + +# choose potential + +include Ta06A.mliap.nn +# DATE: 2014-09-05 UNITS: metal CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: Thompson, Swiler, Trott, Foiles and Tucker, arxiv.org, 1409.3880 (2014) + +# Definition of SNAP potential Ta_Cand06A +# Assumes 1 LAMMPS atom type + +variable zblcutinner equal 4 +variable zblcutouter equal 4.8 +variable zblz equal 73 + +# Specify hybrid with SNAP, ZBL + +pair_style hybrid/overlay zbl ${zblcutinner} ${zblcutouter} mliap model nn Ta06A.nn.mliap.model descriptor sna Ta06A.mliap.descriptor +pair_style hybrid/overlay zbl 4 ${zblcutouter} mliap model nn Ta06A.nn.mliap.model descriptor sna Ta06A.mliap.descriptor +pair_style hybrid/overlay zbl 4 4.8 mliap model nn Ta06A.nn.mliap.model descriptor sna Ta06A.mliap.descriptor +Reading potential file Ta06A.nn.mliap.model with DATE: 2021-03-03 +Reading potential file Ta06A.mliap.descriptor with DATE: 2014-09-05 +SNAP keyword rcutfac 4.67637 +SNAP keyword twojmax 6 +SNAP keyword nelems 1 +SNAP keyword elems Ta +SNAP keyword radelems 0.5 +SNAP keyword welems 1 +SNAP keyword rfac0 0.99363 +SNAP keyword rmin0 0 +SNAP keyword bzeroflag 0 +pair_coeff 1 1 zbl ${zblz} ${zblz} +pair_coeff 1 1 zbl 73 ${zblz} +pair_coeff 1 1 zbl 73 73 +pair_coeff * * mliap Ta + + +# Setup output + +compute eatom all pe/atom +compute energy all reduce sum c_eatom + +compute satom all stress/atom NULL +compute str all reduce sum c_satom[1] c_satom[2] c_satom[3] +variable press equal (c_str[1]+c_str[2]+c_str[3])/(3*vol) + +thermo_style custom step temp epair c_energy etotal press v_press +thermo 10 +thermo_modify norm yes + +# Set up NVE run + +timestep 0.5e-3 +neighbor 1.0 bin +neigh_modify once no every 1 delay 0 check yes + +# Run MD + +velocity all create 300.0 4928459 loop geom +fix 1 all nve +run ${nsteps} +run 100 +Neighbor list info ... + update every 1 steps, delay 0 steps, check yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 5.8 + ghost atom cutoff = 5.8 + binsize = 2.9, bins = 5 5 5 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair zbl, perpetual, half/full from (2) + attributes: half, newton on + pair build: halffull/newton + stencil: none + bin: none + (2) pair mliap, perpetual + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 18.06 | 18.06 | 18.06 Mbytes +Step Temp E_pair c_energy TotEng Press v_press + 0 300 -11.85157 -11.85157 -11.813095 2717.1661 -2717.1661 + 10 296.01467 -11.851059 -11.851059 -11.813095 2697.4796 -2697.4796 + 20 284.53666 -11.849587 -11.849587 -11.813095 2289.1527 -2289.1527 + 30 266.51577 -11.847275 -11.847275 -11.813095 1851.7131 -1851.7131 + 40 243.05007 -11.844266 -11.844266 -11.813095 1570.684 -1570.684 + 50 215.51032 -11.840734 -11.840734 -11.813094 1468.1899 -1468.1899 + 60 185.48331 -11.836883 -11.836883 -11.813094 1524.8757 -1524.8757 + 70 154.6736 -11.832931 -11.832931 -11.813094 1698.3351 -1698.3351 + 80 124.79303 -11.829099 -11.829099 -11.813094 1947.0715 -1947.0715 + 90 97.448054 -11.825592 -11.825592 -11.813094 2231.9563 -2231.9563 + 100 74.035418 -11.822589 -11.822589 -11.813094 2515.8526 -2515.8526 +Loop time of 0.806392 on 4 procs for 100 steps with 128 atoms + +Performance: 5.357 ns/day, 4.480 hours/ns, 124.009 timesteps/s +100.0% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.75456 | 0.77908 | 0.7935 | 1.7 | 96.61 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 0.0116 | 0.026033 | 0.050547 | 9.2 | 3.23 +Output | 0.00071782 | 0.00075547 | 0.0008103 | 0.0 | 0.09 +Modify | 0.00011633 | 0.00012274 | 0.0001295 | 0.0 | 0.02 +Other | | 0.0004031 | | | 0.05 + +Nlocal: 32.0000 ave 32 max 32 min +Histogram: 4 0 0 0 0 0 0 0 0 0 +Nghost: 431.000 ave 431 max 431 min +Histogram: 4 0 0 0 0 0 0 0 0 0 +Neighs: 928.000 ave 928 max 928 min +Histogram: 4 0 0 0 0 0 0 0 0 0 +FullNghs: 1856.00 ave 1856 max 1856 min +Histogram: 4 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 7424 +Ave neighs/atom = 58.000000 +Neighbor list builds = 0 +Dangerous builds = 0 + +Total wall time: 0:00:00 diff --git a/examples/mliap/log.snap.Ta06A.ref b/examples/mliap/log.snap.Ta06A.ref deleted file mode 100644 index 8c89ac1957..0000000000 --- a/examples/mliap/log.snap.Ta06A.ref +++ /dev/null @@ -1,154 +0,0 @@ -LAMMPS (19 Mar 2020) -# Demonstrate SNAP Ta potential - -# Initialize simulation - -variable nsteps index 100 -variable nrep equal 4 -variable a equal 3.316 -units metal - -# generate the box and atom positions using a BCC lattice - -variable nx equal ${nrep} -variable nx equal 4 -variable ny equal ${nrep} -variable ny equal 4 -variable nz equal ${nrep} -variable nz equal 4 - -boundary p p p - -lattice bcc $a -lattice bcc 3.316 -Lattice spacing in x,y,z = 3.316 3.316 3.316 -region box block 0 ${nx} 0 ${ny} 0 ${nz} -region box block 0 4 0 ${ny} 0 ${nz} -region box block 0 4 0 4 0 ${nz} -region box block 0 4 0 4 0 4 -create_box 1 box -Created orthogonal box = (0 0 0) to (13.264 13.264 13.264) - 1 by 1 by 1 MPI processor grid -create_atoms 1 box -Created 128 atoms - create_atoms CPU = 0.000254 secs - -mass 1 180.88 - -# choose potential - -include Ta06A.snap -# DATE: 2014-09-05 CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: Thompson, Swiler, Trott, Foiles and Tucker, arxiv.org, 1409.3880 (2014) - -# Definition of SNAP potential Ta_Cand06A -# Assumes 1 LAMMPS atom type - -variable zblcutinner equal 4 -variable zblcutouter equal 4.8 -variable zblz equal 73 - -# Specify hybrid with SNAP, ZBL - -pair_style hybrid/overlay zbl ${zblcutinner} ${zblcutouter} snap -pair_style hybrid/overlay zbl 4 ${zblcutouter} snap -pair_style hybrid/overlay zbl 4 4.8 snap -pair_coeff 1 1 zbl ${zblz} ${zblz} -pair_coeff 1 1 zbl 73 ${zblz} -pair_coeff 1 1 zbl 73 73 -pair_coeff * * snap Ta06A.snapcoeff Ta06A.snapparam Ta -Reading potential file Ta06A.snapcoeff with DATE: 2014-09-05 -SNAP Element = Ta, Radius 0.5, Weight 1 -Reading potential file Ta06A.snapparam with DATE: 2014-09-05 -SNAP keyword rcutfac 4.67637 -SNAP keyword twojmax 6 -SNAP keyword rfac0 0.99363 -SNAP keyword rmin0 0 -SNAP keyword bzeroflag 0 -SNAP keyword quadraticflag 0 - - -# Setup output - -compute eatom all pe/atom -compute energy all reduce sum c_eatom - -compute satom all stress/atom NULL -compute str all reduce sum c_satom[1] c_satom[2] c_satom[3] -variable press equal (c_str[1]+c_str[2]+c_str[3])/(3*vol) - -thermo_style custom step temp epair c_energy etotal press v_press -thermo 10 -thermo_modify norm yes - -# Set up NVE run - -timestep 0.5e-3 -neighbor 1.0 bin -neigh_modify once no every 1 delay 0 check yes - -# Run MD - -velocity all create 300.0 4928459 -fix 1 all nve -run ${nsteps} -run 100 -Neighbor list info ... - update every 1 steps, delay 0 steps, check yes - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 5.8 - ghost atom cutoff = 5.8 - binsize = 2.9, bins = 5 5 5 - 2 neighbor lists, perpetual/occasional/extra = 2 0 0 - (1) pair zbl, perpetual, half/full from (2) - attributes: half, newton on - pair build: halffull/newton - stencil: none - bin: none - (2) pair snap, perpetual - attributes: full, newton on - pair build: full/bin/atomonly - stencil: full/bin/3d - bin: standard -Per MPI rank memory allocation (min/avg/max) = 6.591 | 6.591 | 6.591 Mbytes -Step Temp E_pair c_energy TotEng Press v_press - 0 300 -11.85157 -11.85157 -11.813095 2717.1661 -2717.1661 - 10 295.96579 -11.851053 -11.851053 -11.813095 2696.1559 -2696.1559 - 20 284.32535 -11.84956 -11.84956 -11.813095 2301.3713 -2301.3713 - 30 266.04602 -11.847215 -11.847215 -11.813095 1832.1745 -1832.1745 - 40 242.2862 -11.844168 -11.844168 -11.813095 1492.6765 -1492.6765 - 50 214.48968 -11.840603 -11.840603 -11.813094 1312.8908 -1312.8908 - 60 184.32523 -11.836734 -11.836734 -11.813094 1284.582 -1284.582 - 70 153.58055 -11.832791 -11.832791 -11.813094 1374.4457 -1374.4457 - 80 124.04276 -11.829003 -11.829003 -11.813094 1537.703 -1537.703 - 90 97.37622 -11.825582 -11.825582 -11.813094 1734.9662 -1734.9662 - 100 75.007873 -11.822714 -11.822714 -11.813094 1930.8005 -1930.8005 -Loop time of 0.995328 on 1 procs for 100 steps with 128 atoms - -Performance: 4.340 ns/day, 5.530 hours/ns, 100.469 timesteps/s -99.5% CPU use with 1 MPI tasks x no OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 0.99426 | 0.99426 | 0.99426 | 0.0 | 99.89 -Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0.000305 | 0.000305 | 0.000305 | 0.0 | 0.03 -Output | 0.000413 | 0.000413 | 0.000413 | 0.0 | 0.04 -Modify | 0.000159 | 0.000159 | 0.000159 | 0.0 | 0.02 -Other | | 0.000191 | | | 0.02 - -Nlocal: 128 ave 128 max 128 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Nghost: 727 ave 727 max 727 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 3712 ave 3712 max 3712 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -FullNghs: 7424 ave 7424 max 7424 min -Histogram: 1 0 0 0 0 0 0 0 0 0 - -Total # of neighbors = 7424 -Ave neighs/atom = 58 -Neighbor list builds = 0 -Dangerous builds = 0 - -Total wall time: 0:00:01 diff --git a/examples/mliap/Cu_nn.mliap.model b/potentials/Cu.nn.mliap.model similarity index 100% rename from examples/mliap/Cu_nn.mliap.model rename to potentials/Cu.nn.mliap.model diff --git a/examples/mliap/Cu_snap.mliap.descriptor b/potentials/Cu.snap.mliap.descriptor similarity index 100% rename from examples/mliap/Cu_snap.mliap.descriptor rename to potentials/Cu.snap.mliap.descriptor diff --git a/potentials/Ta06A.mliap.nn b/potentials/Ta06A.mliap.nn new file mode 100644 index 0000000000..01246354c5 --- /dev/null +++ b/potentials/Ta06A.mliap.nn @@ -0,0 +1,18 @@ +# DATE: 2014-09-05 UNITS: metal CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: Thompson, Swiler, Trott, Foiles and Tucker, arxiv.org, 1409.3880 (2014) + +# Definition of SNAP potential Ta_Cand06A +# Assumes 1 LAMMPS atom type + +variable zblcutinner equal 4 +variable zblcutouter equal 4.8 +variable zblz equal 73 + +# Specify hybrid with SNAP, ZBL + +pair_style hybrid/overlay & +zbl ${zblcutinner} ${zblcutouter} & +mliap model nn Ta06A_nn.mliap.model & +descriptor sna Ta06A.mliap.descriptor +pair_coeff 1 1 zbl ${zblz} ${zblz} +pair_coeff * * mliap Ta + diff --git a/examples/mliap/Ta06A.mliap.pytorch b/potentials/Ta06A.mliap.pytorch similarity index 100% rename from examples/mliap/Ta06A.mliap.pytorch rename to potentials/Ta06A.mliap.pytorch diff --git a/examples/mliap/Ta06A_nn.mliap.model b/potentials/Ta06A.nn.mliap.model similarity index 100% rename from examples/mliap/Ta06A_nn.mliap.model rename to potentials/Ta06A.nn.mliap.model From aa5da53b8a18c6a636102fb4fb2fff1d41d6129c Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Wed, 3 Mar 2021 11:55:26 -0700 Subject: [PATCH 16/30] more rearranging, tried to elimiante unnecessary name elements --- examples/mliap/README | 9 +++++++++ examples/mliap/Ta06A.mliap.nn | 1 - examples/mliap/Ta06A.nn.mliap | 1 + .../{in.mliap.snap.nn.Cu => in.mliap.nn.Cu} | 0 ...n.mliap.snap.nn.Ta06A => in.mliap.nn.Ta06A} | 2 +- ....Cu.g++.1 => log.03Mar21.mliap.nn.Cu.g++.1} | 16 ++++++++-------- ....Cu.g++.4 => log.03Mar21.mliap.nn.Cu.g++.4} | 16 ++++++++-------- ....g++.1 => log.03Mar21.mliap.nn.Ta06A.g++.1} | 18 +++++++++--------- ....g++.4 => log.03Mar21.mliap.nn.Ta06A.g++.4} | 18 +++++++++--------- potentials/{Ta06A.mliap.nn => Ta06A.nn.mliap} | 2 +- 10 files changed, 46 insertions(+), 37 deletions(-) delete mode 120000 examples/mliap/Ta06A.mliap.nn create mode 120000 examples/mliap/Ta06A.nn.mliap rename examples/mliap/{in.mliap.snap.nn.Cu => in.mliap.nn.Cu} (100%) rename examples/mliap/{in.mliap.snap.nn.Ta06A => in.mliap.nn.Ta06A} (97%) rename examples/mliap/{log.03Mar21.mliap.snap.nn.Cu.g++.1 => log.03Mar21.mliap.nn.Cu.g++.1} (90%) rename examples/mliap/{log.03Mar21.mliap.snap.nn.Cu.g++.4 => log.03Mar21.mliap.nn.Cu.g++.4} (89%) rename examples/mliap/{log.03Mar21.mliap.snap.nn.Ta06A.g++.1 => log.03Mar21.mliap.nn.Ta06A.g++.1} (91%) rename examples/mliap/{log.03Mar21.mliap.snap.nn.Ta06A.g++.4 => log.03Mar21.mliap.nn.Ta06A.g++.4} (90%) rename potentials/{Ta06A.mliap.nn => Ta06A.nn.mliap} (93%) diff --git a/examples/mliap/README b/examples/mliap/README index af848e42ba..c16fa218e0 100644 --- a/examples/mliap/README +++ b/examples/mliap/README @@ -101,3 +101,12 @@ pickle data that will execute arbitrary code during unpickling. Never load data that could have come from an untrusted source, or that could have been tampered with. Only load data you trust. +in.mliap.nn.Ta06A +------------------- +Run linear SNAP using the "nn" model style, equivalent to examples/snap/in.snap.Ta06A + +in.mliap.nn.cu +------------------------- +Run a neural network potential for Cu, a combination of SNAP descriptors and the "nn" model style + + diff --git a/examples/mliap/Ta06A.mliap.nn b/examples/mliap/Ta06A.mliap.nn deleted file mode 120000 index 4aab212e4f..0000000000 --- a/examples/mliap/Ta06A.mliap.nn +++ /dev/null @@ -1 +0,0 @@ -../../potentials/Ta06A.mliap.nn \ No newline at end of file diff --git a/examples/mliap/Ta06A.nn.mliap b/examples/mliap/Ta06A.nn.mliap new file mode 120000 index 0000000000..b3a3b9fdbd --- /dev/null +++ b/examples/mliap/Ta06A.nn.mliap @@ -0,0 +1 @@ +../../potentials/Ta06A.nn.mliap \ No newline at end of file diff --git a/examples/mliap/in.mliap.snap.nn.Cu b/examples/mliap/in.mliap.nn.Cu similarity index 100% rename from examples/mliap/in.mliap.snap.nn.Cu rename to examples/mliap/in.mliap.nn.Cu diff --git a/examples/mliap/in.mliap.snap.nn.Ta06A b/examples/mliap/in.mliap.nn.Ta06A similarity index 97% rename from examples/mliap/in.mliap.snap.nn.Ta06A rename to examples/mliap/in.mliap.nn.Ta06A index f33744184a..41c448a232 100644 --- a/examples/mliap/in.mliap.snap.nn.Ta06A +++ b/examples/mliap/in.mliap.nn.Ta06A @@ -24,7 +24,7 @@ mass 1 180.88 # choose potential -include Ta06A.mliap.nn +include Ta06A.nn.mliap # Setup output diff --git a/examples/mliap/log.03Mar21.mliap.snap.nn.Cu.g++.1 b/examples/mliap/log.03Mar21.mliap.nn.Cu.g++.1 similarity index 90% rename from examples/mliap/log.03Mar21.mliap.snap.nn.Cu.g++.1 rename to examples/mliap/log.03Mar21.mliap.nn.Cu.g++.1 index 678de992f7..151972e99a 100644 --- a/examples/mliap/log.03Mar21.mliap.snap.nn.Cu.g++.1 +++ b/examples/mliap/log.03Mar21.mliap.nn.Cu.g++.1 @@ -103,20 +103,20 @@ Step Temp E_pair c_energy TotEng Press v_press 80 75.426905 -4.0642423 -4.0642423 -4.0545307 7766.2217 -7766.2217 90 58.150738 -4.0620015 -4.0620015 -4.0545143 8668.0598 -8668.0598 100 52.301012 -4.0612408 -4.0612408 -4.0545067 9049.3141 -9049.3141 -Loop time of 12.8453 on 1 procs for 100 steps with 256 atoms +Loop time of 12.7584 on 1 procs for 100 steps with 256 atoms -Performance: 0.336 ns/day, 71.363 hours/ns, 7.785 timesteps/s +Performance: 0.339 ns/day, 70.880 hours/ns, 7.838 timesteps/s 100.0% CPU use with 1 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 12.842 | 12.842 | 12.842 | 0.0 | 99.97 +Pair | 12.755 | 12.755 | 12.755 | 0.0 | 99.97 Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0.0014137 | 0.0014137 | 0.0014137 | 0.0 | 0.01 -Output | 0.00090703 | 0.00090703 | 0.00090703 | 0.0 | 0.01 -Modify | 0.0007583 | 0.0007583 | 0.0007583 | 0.0 | 0.01 -Other | | 0.0003434 | | | 0.00 +Comm | 0.0014069 | 0.0014069 | 0.0014069 | 0.0 | 0.01 +Output | 0.00085897 | 0.00085897 | 0.00085897 | 0.0 | 0.01 +Modify | 0.00075486 | 0.00075486 | 0.00075486 | 0.0 | 0.01 +Other | | 0.0003242 | | | 0.00 Nlocal: 256.000 ave 256 max 256 min Histogram: 1 0 0 0 0 0 0 0 0 0 @@ -131,4 +131,4 @@ Total # of neighbors = 19968 Ave neighs/atom = 78.000000 Neighbor list builds = 0 Dangerous builds = 0 -Total wall time: 0:00:13 +Total wall time: 0:00:12 diff --git a/examples/mliap/log.03Mar21.mliap.snap.nn.Cu.g++.4 b/examples/mliap/log.03Mar21.mliap.nn.Cu.g++.4 similarity index 89% rename from examples/mliap/log.03Mar21.mliap.snap.nn.Cu.g++.4 rename to examples/mliap/log.03Mar21.mliap.nn.Cu.g++.4 index cc4e98a249..a7be3b1415 100644 --- a/examples/mliap/log.03Mar21.mliap.snap.nn.Cu.g++.4 +++ b/examples/mliap/log.03Mar21.mliap.nn.Cu.g++.4 @@ -103,20 +103,20 @@ Step Temp E_pair c_energy TotEng Press v_press 80 75.426905 -4.0642423 -4.0642423 -4.0545307 7766.2217 -7766.2217 90 58.150738 -4.0620015 -4.0620015 -4.0545143 8668.0598 -8668.0598 100 52.301012 -4.0612408 -4.0612408 -4.0545067 9049.3141 -9049.3141 -Loop time of 3.39121 on 4 procs for 100 steps with 256 atoms +Loop time of 3.22769 on 4 procs for 100 steps with 256 atoms -Performance: 1.274 ns/day, 18.840 hours/ns, 29.488 timesteps/s -100.1% CPU use with 4 MPI tasks x 1 OpenMP threads +Performance: 1.338 ns/day, 17.932 hours/ns, 30.982 timesteps/s +100.0% CPU use with 4 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 3.3037 | 3.3421 | 3.3808 | 2.0 | 98.55 +Pair | 3.19 | 3.2037 | 3.2196 | 0.7 | 99.26 Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0.0084965 | 0.047256 | 0.085777 | 17.1 | 1.39 -Output | 0.00091401 | 0.00094114 | 0.00099209 | 0.0 | 0.03 -Modify | 0.00022695 | 0.00024041 | 0.00026185 | 0.0 | 0.01 -Other | | 0.0006503 | | | 0.02 +Comm | 0.0061415 | 0.022081 | 0.035855 | 8.9 | 0.68 +Output | 0.00093221 | 0.00094824 | 0.00098861 | 0.0 | 0.03 +Modify | 0.0002173 | 0.00022773 | 0.00024477 | 0.0 | 0.01 +Other | | 0.0006805 | | | 0.02 Nlocal: 64.0000 ave 64 max 64 min Histogram: 4 0 0 0 0 0 0 0 0 0 diff --git a/examples/mliap/log.03Mar21.mliap.snap.nn.Ta06A.g++.1 b/examples/mliap/log.03Mar21.mliap.nn.Ta06A.g++.1 similarity index 91% rename from examples/mliap/log.03Mar21.mliap.snap.nn.Ta06A.g++.1 rename to examples/mliap/log.03Mar21.mliap.nn.Ta06A.g++.1 index 58dd94a5f0..e22afa65f0 100644 --- a/examples/mliap/log.03Mar21.mliap.snap.nn.Ta06A.g++.1 +++ b/examples/mliap/log.03Mar21.mliap.nn.Ta06A.g++.1 @@ -38,7 +38,7 @@ mass 1 180.88 # choose potential -include Ta06A.mliap.nn +include Ta06A.nn.mliap # DATE: 2014-09-05 UNITS: metal CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: Thompson, Swiler, Trott, Foiles and Tucker, arxiv.org, 1409.3880 (2014) # Definition of SNAP potential Ta_Cand06A @@ -125,20 +125,20 @@ Step Temp E_pair c_energy TotEng Press v_press 80 124.79303 -11.829099 -11.829099 -11.813094 1947.0715 -1947.0715 90 97.448054 -11.825592 -11.825592 -11.813094 2231.9563 -2231.9563 100 74.035418 -11.822589 -11.822589 -11.813094 2515.8526 -2515.8526 -Loop time of 2.93897 on 1 procs for 100 steps with 128 atoms +Loop time of 3.05207 on 1 procs for 100 steps with 128 atoms -Performance: 1.470 ns/day, 16.328 hours/ns, 34.026 timesteps/s +Performance: 1.415 ns/day, 16.956 hours/ns, 32.765 timesteps/s 100.0% CPU use with 1 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 2.9368 | 2.9368 | 2.9368 | 0.0 | 99.93 +Pair | 3.0503 | 3.0503 | 3.0503 | 0.0 | 99.94 Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0.00074209 | 0.00074209 | 0.00074209 | 0.0 | 0.03 -Output | 0.00078955 | 0.00078955 | 0.00078955 | 0.0 | 0.03 -Modify | 0.00039202 | 0.00039202 | 0.00039202 | 0.0 | 0.01 -Other | | 0.0002685 | | | 0.01 +Comm | 0.00072395 | 0.00072395 | 0.00072395 | 0.0 | 0.02 +Output | 0.00050893 | 0.00050893 | 0.00050893 | 0.0 | 0.02 +Modify | 0.00037375 | 0.00037375 | 0.00037375 | 0.0 | 0.01 +Other | | 0.0001878 | | | 0.01 Nlocal: 128.000 ave 128 max 128 min Histogram: 1 0 0 0 0 0 0 0 0 0 @@ -154,4 +154,4 @@ Ave neighs/atom = 58.000000 Neighbor list builds = 0 Dangerous builds = 0 -Total wall time: 0:00:02 +Total wall time: 0:00:03 diff --git a/examples/mliap/log.03Mar21.mliap.snap.nn.Ta06A.g++.4 b/examples/mliap/log.03Mar21.mliap.nn.Ta06A.g++.4 similarity index 90% rename from examples/mliap/log.03Mar21.mliap.snap.nn.Ta06A.g++.4 rename to examples/mliap/log.03Mar21.mliap.nn.Ta06A.g++.4 index 31ca171200..b0fdd57ce2 100644 --- a/examples/mliap/log.03Mar21.mliap.snap.nn.Ta06A.g++.4 +++ b/examples/mliap/log.03Mar21.mliap.nn.Ta06A.g++.4 @@ -38,7 +38,7 @@ mass 1 180.88 # choose potential -include Ta06A.mliap.nn +include Ta06A.nn.mliap # DATE: 2014-09-05 UNITS: metal CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: Thompson, Swiler, Trott, Foiles and Tucker, arxiv.org, 1409.3880 (2014) # Definition of SNAP potential Ta_Cand06A @@ -125,20 +125,20 @@ Step Temp E_pair c_energy TotEng Press v_press 80 124.79303 -11.829099 -11.829099 -11.813094 1947.0715 -1947.0715 90 97.448054 -11.825592 -11.825592 -11.813094 2231.9563 -2231.9563 100 74.035418 -11.822589 -11.822589 -11.813094 2515.8526 -2515.8526 -Loop time of 0.806392 on 4 procs for 100 steps with 128 atoms +Loop time of 0.858301 on 4 procs for 100 steps with 128 atoms -Performance: 5.357 ns/day, 4.480 hours/ns, 124.009 timesteps/s -100.0% CPU use with 4 MPI tasks x 1 OpenMP threads +Performance: 5.033 ns/day, 4.768 hours/ns, 116.509 timesteps/s +100.2% CPU use with 4 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 0.75456 | 0.77908 | 0.7935 | 1.7 | 96.61 +Pair | 0.75351 | 0.79999 | 0.85429 | 4.2 | 93.21 Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0.0116 | 0.026033 | 0.050547 | 9.2 | 3.23 -Output | 0.00071782 | 0.00075547 | 0.0008103 | 0.0 | 0.09 -Modify | 0.00011633 | 0.00012274 | 0.0001295 | 0.0 | 0.02 -Other | | 0.0004031 | | | 0.05 +Comm | 0.0026857 | 0.057019 | 0.10354 | 15.8 | 6.64 +Output | 0.00078796 | 0.00080864 | 0.00085671 | 0.0 | 0.09 +Modify | 0.00011437 | 0.00012275 | 0.00013339 | 0.0 | 0.01 +Other | | 0.0003564 | | | 0.04 Nlocal: 32.0000 ave 32 max 32 min Histogram: 4 0 0 0 0 0 0 0 0 0 diff --git a/potentials/Ta06A.mliap.nn b/potentials/Ta06A.nn.mliap similarity index 93% rename from potentials/Ta06A.mliap.nn rename to potentials/Ta06A.nn.mliap index 01246354c5..a5b2f0bfce 100644 --- a/potentials/Ta06A.mliap.nn +++ b/potentials/Ta06A.nn.mliap @@ -11,7 +11,7 @@ variable zblz equal 73 pair_style hybrid/overlay & zbl ${zblcutinner} ${zblcutouter} & -mliap model nn Ta06A_nn.mliap.model & +mliap model nn Ta06A.nn.mliap.model & descriptor sna Ta06A.mliap.descriptor pair_coeff 1 1 zbl ${zblz} ${zblz} pair_coeff * * mliap Ta From 862a5ad2b64fcbf05a7716c0048a2cccaa8163ce Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Wed, 3 Mar 2021 12:07:45 -0700 Subject: [PATCH 17/30] Cleaned up names of PyTorch files --- examples/mliap/Ta06A.pytorch.mliap | 1 + examples/mliap/in.mliap.pytorch.Ta06A | 2 +- .../log.04Dec20.mliap.pytorch.Ta06A.g++.1 | 32 ++++++++--------- .../log.04Dec20.mliap.pytorch.Ta06A.g++.4 | 34 +++++++++---------- potentials/README | 3 ++ ...a06A.mliap.pytorch => Ta06A.pytorch.mliap} | 0 6 files changed, 38 insertions(+), 34 deletions(-) create mode 120000 examples/mliap/Ta06A.pytorch.mliap rename potentials/{Ta06A.mliap.pytorch => Ta06A.pytorch.mliap} (100%) diff --git a/examples/mliap/Ta06A.pytorch.mliap b/examples/mliap/Ta06A.pytorch.mliap new file mode 120000 index 0000000000..22bb47850e --- /dev/null +++ b/examples/mliap/Ta06A.pytorch.mliap @@ -0,0 +1 @@ +../../potentials/Ta06A.pytorch.mliap \ No newline at end of file diff --git a/examples/mliap/in.mliap.pytorch.Ta06A b/examples/mliap/in.mliap.pytorch.Ta06A index 59cdcc8c81..e346c8a864 100644 --- a/examples/mliap/in.mliap.pytorch.Ta06A +++ b/examples/mliap/in.mliap.pytorch.Ta06A @@ -24,7 +24,7 @@ mass 1 180.88 # choose potential -include Ta06A.mliap.pytorch +include Ta06A.pytorch.mliap # Setup output diff --git a/examples/mliap/log.04Dec20.mliap.pytorch.Ta06A.g++.1 b/examples/mliap/log.04Dec20.mliap.pytorch.Ta06A.g++.1 index f56a79650e..0527e40757 100644 --- a/examples/mliap/log.04Dec20.mliap.pytorch.Ta06A.g++.1 +++ b/examples/mliap/log.04Dec20.mliap.pytorch.Ta06A.g++.1 @@ -1,5 +1,5 @@ -LAMMPS (30 Nov 2020) - using 48 OpenMP thread(s) per MPI task +LAMMPS (10 Feb 2021) + using 1 OpenMP thread(s) per MPI task # Demonstrate MLIAP/PyTorch interface to linear SNAP potential # Initialize simulation @@ -32,13 +32,13 @@ Created orthogonal box = (0.0000000 0.0000000 0.0000000) to (13.264000 13.264000 1 by 1 by 1 MPI processor grid create_atoms 1 box Created 128 atoms - create_atoms CPU = 0.002 seconds + create_atoms CPU = 0.000 seconds mass 1 180.88 # choose potential -include Ta06A.mliap.pytorch +include Ta06A.pytorch.mliap # DATE: 2014-09-05 UNITS: metal CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: Thompson, Swiler, Trott, Foiles and Tucker, arxiv.org, 1409.3880 (2014) # Definition of SNAP potential Ta_Cand06A @@ -50,9 +50,9 @@ variable zblz equal 73 # Specify hybrid with SNAP, ZBL -pair_style hybrid/overlay zbl ${zblcutinner} ${zblcutouter} mliap model mliappy Ta06A.mliap.pytorch.model.pkl descriptor sna Ta06A.mliap.descriptor -pair_style hybrid/overlay zbl 4 ${zblcutouter} mliap model mliappy Ta06A.mliap.pytorch.model.pkl descriptor sna Ta06A.mliap.descriptor -pair_style hybrid/overlay zbl 4 4.8 mliap model mliappy Ta06A.mliap.pytorch.model.pkl descriptor sna Ta06A.mliap.descriptor +pair_style hybrid/overlay zbl ${zblcutinner} ${zblcutouter} mliap model mliappy Ta06A.mliap.pytorch.model.pt descriptor sna Ta06A.mliap.descriptor +pair_style hybrid/overlay zbl 4 ${zblcutouter} mliap model mliappy Ta06A.mliap.pytorch.model.pt descriptor sna Ta06A.mliap.descriptor +pair_style hybrid/overlay zbl 4 4.8 mliap model mliappy Ta06A.mliap.pytorch.model.pt descriptor sna Ta06A.mliap.descriptor Loading python model complete. Reading potential file Ta06A.mliap.descriptor with DATE: 2014-09-05 SNAP keyword rcutfac 4.67637 @@ -112,7 +112,7 @@ Neighbor list info ... pair build: full/bin/atomonly stencil: full/bin/3d bin: standard -Per MPI rank memory allocation (min/avg/max) = 159.8 | 159.8 | 159.8 Mbytes +Per MPI rank memory allocation (min/avg/max) = 18.15 | 18.15 | 18.15 Mbytes Step Temp E_pair c_energy TotEng Press v_press 0 300 -11.85157 -11.85157 -11.813095 2717.1661 -2717.1661 10 296.01467 -11.851059 -11.851059 -11.813095 2697.4796 -2697.4796 @@ -125,20 +125,20 @@ Step Temp E_pair c_energy TotEng Press v_press 80 124.79303 -11.829099 -11.829099 -11.813094 1947.0715 -1947.0715 90 97.448054 -11.825592 -11.825592 -11.813094 2231.9563 -2231.9563 100 74.035418 -11.822589 -11.822589 -11.813094 2515.8526 -2515.8526 -Loop time of 2.00236 on 48 procs for 100 steps with 128 atoms +Loop time of 2.0472 on 1 procs for 100 steps with 128 atoms -Performance: 2.157 ns/day, 11.124 hours/ns, 49.941 timesteps/s -288.8% CPU use with 1 MPI tasks x 48 OpenMP threads +Performance: 2.110 ns/day, 11.373 hours/ns, 48.847 timesteps/s +100.2% CPU use with 1 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 1.9998 | 1.9998 | 1.9998 | 0.0 | 99.87 +Pair | 2.0443 | 2.0443 | 2.0443 | 0.0 | 99.86 Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0.0011814 | 0.0011814 | 0.0011814 | 0.0 | 0.06 -Output | 0.00059724 | 0.00059724 | 0.00059724 | 0.0 | 0.03 -Modify | 0.00047352 | 0.00047352 | 0.00047352 | 0.0 | 0.02 -Other | | 0.0003468 | | | 0.02 +Comm | 0.001157 | 0.001157 | 0.001157 | 0.0 | 0.06 +Output | 0.00080857 | 0.00080857 | 0.00080857 | 0.0 | 0.04 +Modify | 0.00053188 | 0.00053188 | 0.00053188 | 0.0 | 0.03 +Other | | 0.0004304 | | | 0.02 Nlocal: 128.000 ave 128 max 128 min Histogram: 1 0 0 0 0 0 0 0 0 0 diff --git a/examples/mliap/log.04Dec20.mliap.pytorch.Ta06A.g++.4 b/examples/mliap/log.04Dec20.mliap.pytorch.Ta06A.g++.4 index 7f1bc818d1..3c5bf24bf2 100644 --- a/examples/mliap/log.04Dec20.mliap.pytorch.Ta06A.g++.4 +++ b/examples/mliap/log.04Dec20.mliap.pytorch.Ta06A.g++.4 @@ -1,5 +1,5 @@ -LAMMPS (30 Nov 2020) - using 48 OpenMP thread(s) per MPI task +LAMMPS (10 Feb 2021) + using 1 OpenMP thread(s) per MPI task # Demonstrate MLIAP/PyTorch interface to linear SNAP potential # Initialize simulation @@ -32,13 +32,13 @@ Created orthogonal box = (0.0000000 0.0000000 0.0000000) to (13.264000 13.264000 1 by 2 by 2 MPI processor grid create_atoms 1 box Created 128 atoms - create_atoms CPU = 0.002 seconds + create_atoms CPU = 0.000 seconds mass 1 180.88 # choose potential -include Ta06A.mliap.pytorch +include Ta06A.pytorch.mliap # DATE: 2014-09-05 UNITS: metal CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: Thompson, Swiler, Trott, Foiles and Tucker, arxiv.org, 1409.3880 (2014) # Definition of SNAP potential Ta_Cand06A @@ -50,9 +50,9 @@ variable zblz equal 73 # Specify hybrid with SNAP, ZBL -pair_style hybrid/overlay zbl ${zblcutinner} ${zblcutouter} mliap model mliappy Ta06A.mliap.pytorch.model.pkl descriptor sna Ta06A.mliap.descriptor -pair_style hybrid/overlay zbl 4 ${zblcutouter} mliap model mliappy Ta06A.mliap.pytorch.model.pkl descriptor sna Ta06A.mliap.descriptor -pair_style hybrid/overlay zbl 4 4.8 mliap model mliappy Ta06A.mliap.pytorch.model.pkl descriptor sna Ta06A.mliap.descriptor +pair_style hybrid/overlay zbl ${zblcutinner} ${zblcutouter} mliap model mliappy Ta06A.mliap.pytorch.model.pt descriptor sna Ta06A.mliap.descriptor +pair_style hybrid/overlay zbl 4 ${zblcutouter} mliap model mliappy Ta06A.mliap.pytorch.model.pt descriptor sna Ta06A.mliap.descriptor +pair_style hybrid/overlay zbl 4 4.8 mliap model mliappy Ta06A.mliap.pytorch.model.pt descriptor sna Ta06A.mliap.descriptor Loading python model complete. Reading potential file Ta06A.mliap.descriptor with DATE: 2014-09-05 SNAP keyword rcutfac 4.67637 @@ -112,7 +112,7 @@ Neighbor list info ... pair build: full/bin/atomonly stencil: full/bin/3d bin: standard -Per MPI rank memory allocation (min/avg/max) = 159.7 | 159.7 | 159.7 Mbytes +Per MPI rank memory allocation (min/avg/max) = 18.06 | 18.06 | 18.06 Mbytes Step Temp E_pair c_energy TotEng Press v_press 0 300 -11.85157 -11.85157 -11.813095 2717.1661 -2717.1661 10 296.01467 -11.851059 -11.851059 -11.813095 2697.4796 -2697.4796 @@ -125,20 +125,20 @@ Step Temp E_pair c_energy TotEng Press v_press 80 124.79303 -11.829099 -11.829099 -11.813094 1947.0715 -1947.0715 90 97.448054 -11.825592 -11.825592 -11.813094 2231.9563 -2231.9563 100 74.035418 -11.822589 -11.822589 -11.813094 2515.8526 -2515.8526 -Loop time of 0.562802 on 192 procs for 100 steps with 128 atoms +Loop time of 0.572344 on 4 procs for 100 steps with 128 atoms -Performance: 7.676 ns/day, 3.127 hours/ns, 177.682 timesteps/s -99.7% CPU use with 4 MPI tasks x 48 OpenMP threads +Performance: 7.548 ns/day, 3.180 hours/ns, 174.720 timesteps/s +100.6% CPU use with 4 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 0.53583 | 0.54622 | 0.55401 | 0.9 | 97.05 +Pair | 0.51796 | 0.5401 | 0.56608 | 2.4 | 94.37 Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0.0071442 | 0.01491 | 0.025289 | 5.4 | 2.65 -Output | 0.00092525 | 0.00095771 | 0.0010166 | 0.0 | 0.17 -Modify | 0.00014479 | 0.00015043 | 0.00015893 | 0.0 | 0.03 -Other | | 0.0005624 | | | 0.10 +Comm | 0.0044844 | 0.030393 | 0.052464 | 10.2 | 5.31 +Output | 0.001 | 0.0010351 | 0.0011083 | 0.1 | 0.18 +Modify | 0.0001468 | 0.00016417 | 0.00017977 | 0.0 | 0.03 +Other | | 0.0006567 | | | 0.11 Nlocal: 32.0000 ave 32 max 32 min Histogram: 4 0 0 0 0 0 0 0 0 0 @@ -154,4 +154,4 @@ Ave neighs/atom = 58.000000 Neighbor list builds = 0 Dangerous builds = 0 -Total wall time: 0:00:02 +Total wall time: 0:00:05 diff --git a/potentials/README b/potentials/README index 63b32b6f4a..fbc49f8613 100644 --- a/potentials/README +++ b/potentials/README @@ -100,6 +100,9 @@ meam.spline modified EAM (MEAM) spline potential meam.sw.spline modified EAM (MEAM) Stillinger-Weber spline potential mesocnt mesoscopic carbon nanotube (CNT) potential mgpt model generalized pseudopotential theory (MGPT) potential +mliap MLIAP potential +mliap.descriptor MLIAP potential descriptor +mliap.model MLIAP potential model nb3b.harmonic nonbonded 3-body harmonic potential poly polymorphic 3-body potential reax ReaxFF potential (see README.reax for more info) diff --git a/potentials/Ta06A.mliap.pytorch b/potentials/Ta06A.pytorch.mliap similarity index 100% rename from potentials/Ta06A.mliap.pytorch rename to potentials/Ta06A.pytorch.mliap From 2f9cca97a9ec13b457c3dcc325a41006fd0717b6 Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Wed, 3 Mar 2021 13:12:02 -0700 Subject: [PATCH 18/30] Removed static functions and cmath include from header --- src/MLIAP/mliap_model_nn.cpp | 54 ++++++++++++++++++++++++++---------- src/MLIAP/mliap_model_nn.h | 18 ++++++------ 2 files changed, 48 insertions(+), 24 deletions(-) diff --git a/src/MLIAP/mliap_model_nn.cpp b/src/MLIAP/mliap_model_nn.cpp index 018641e3c9..76b60bbb71 100644 --- a/src/MLIAP/mliap_model_nn.cpp +++ b/src/MLIAP/mliap_model_nn.cpp @@ -11,6 +11,10 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + Contributing author: Pedro Antonio Santos Flórez (UNLV) +------------------------------------------------------------------------- */ + #include "mliap_model_nn.h" #include "pair_mliap.h" #include "mliap_data.h" @@ -20,6 +24,8 @@ #include "memory.h" #include "tokenizer.h" +#include + using namespace LAMMPS_NS; #define MAXLINE 1024 @@ -52,9 +58,9 @@ MLIAPModelNN::~MLIAPModelNN() int MLIAPModelNN::get_nparams() { - if (nparams == 0) { + if (nparams == 0) if (ndescriptors == 0) error->all(FLERR,"ndescriptors not defined"); - } + return nparams; } @@ -71,7 +77,7 @@ void MLIAPModelNN::read_coeffs(char *coefffilename) coefffilename,utils::getsyserror())); } - char line[MAXLINE],*ptr, *tstr; + char line[MAXLINE], *ptr, *tstr; int eof = 0; int n; @@ -199,10 +205,8 @@ void MLIAPModelNN::read_coeffs(char *coefffilename) } } } - if (comm->me == 0) fclose(fpcoeff); } - /* ---------------------------------------------------------------------- Calculate model gradients w.r.t descriptors for each atom beta_i = dE(B_i)/dB_i @@ -231,19 +235,28 @@ void MLIAPModelNN::compute_gradients(MLIAPData* data) // forwardprop // input - hidden1 + for (int n=0; n < nnodes[0]; n++) { nodes[0][n] = 0; for (int icoeff = 0; icoeff < data->ndescriptors; icoeff++) { - nodes[0][n] += coeffi[n*((data->ndescriptors)+1)+icoeff+1] * (data->descriptors[ii][icoeff] - scalei[0][icoeff]) / scalei[1][icoeff]; + nodes[0][n] += coeffi[n*((data->ndescriptors)+1)+icoeff+1] * + (data->descriptors[ii][icoeff] - scalei[0][icoeff]) / + scalei[1][icoeff]; } if (activation[0] == 1) { - nodes[0][n] = sigm(nodes[0][n] + coeffi[n*((data->ndescriptors)+1)], dnodes[0][n]); + nodes[0][n] = sigm(nodes[0][n] + + coeffi[n*((data->ndescriptors)+1)], + dnodes[0][n]); } else if (activation[0] == 2) { - nodes[0][n] = tanh(nodes[0][n] + coeffi[n*((data->ndescriptors)+1)], dnodes[0][n]); + nodes[0][n] = tanh(nodes[0][n] + + coeffi[n*((data->ndescriptors)+1)], + dnodes[0][n]); } else if (activation[0] == 3) { - nodes[0][n] = relu(nodes[0][n] + coeffi[n*((data->ndescriptors)+1)], dnodes[0][n]); + nodes[0][n] = relu(nodes[0][n] + + coeffi[n*((data->ndescriptors)+1)], + dnodes[0][n]); } else { nodes[0][n] += coeffi[n*((data->ndescriptors)+1)]; @@ -252,6 +265,7 @@ void MLIAPModelNN::compute_gradients(MLIAPData* data) } // hidden~output + int k = 0; if (nl > 1) { k += ((data->ndescriptors)+1)*nnodes[0]; @@ -259,16 +273,23 @@ void MLIAPModelNN::compute_gradients(MLIAPData* data) for (int n=0; n < nnodes[l]; n++) { nodes[l][n] = 0; for (int j=0; j < nnodes[l-1]; j++) { - nodes[l][n] += coeffi[k+n*(nnodes[l-1]+1)+j+1] * nodes[l-1][j]; + nodes[l][n] += coeffi[k+n*(nnodes[l-1]+1)+j+1] * + nodes[l-1][j]; } if (activation[l] == 1) { - nodes[l][n] = sigm(nodes[l][n] + coeffi[k+n*(nnodes[l-1]+1)], dnodes[l][n]); + nodes[l][n] = sigm(nodes[l][n] + + coeffi[k+n*(nnodes[l-1]+1)], + dnodes[l][n]); } else if (activation[l] == 2) { - nodes[l][n] = tanh(nodes[l][n] + coeffi[k+n*(nnodes[l-1]+1)], dnodes[l][n]); + nodes[l][n] = tanh(nodes[l][n] + + coeffi[k+n*(nnodes[l-1]+1)], + dnodes[l][n]); } else if (activation[l] == 3) { - nodes[l][n] = relu(nodes[l][n] + coeffi[k+n*(nnodes[l-1]+1)], dnodes[l][n]); + nodes[l][n] = relu(nodes[l][n] + + coeffi[k+n*(nnodes[l-1]+1)], + dnodes[l][n]); } else { nodes[l][n] += coeffi[k+n*(nnodes[l-1]+1)]; @@ -297,7 +318,8 @@ void MLIAPModelNN::compute_gradients(MLIAPData* data) for (int n=0; n= 1) { bnodes[l-1][n] *= dnodes[l-1][n]; @@ -309,7 +331,9 @@ void MLIAPModelNN::compute_gradients(MLIAPData* data) for (int icoeff = 0; icoeff < data->ndescriptors; icoeff++) { data->betas[ii][icoeff] = 0; for (int j=0; jbetas[ii][icoeff] += coeffi[j*((data->ndescriptors)+1)+icoeff+1] * bnodes[0][j]; + data->betas[ii][icoeff] += + coeffi[j*((data->ndescriptors)+1)+icoeff+1] * + bnodes[0][j]; } data->betas[ii][icoeff] = data->betas[ii][icoeff]/scalei[1][icoeff]; } diff --git a/src/MLIAP/mliap_model_nn.h b/src/MLIAP/mliap_model_nn.h index 8facf9d446..abdb9dec0f 100644 --- a/src/MLIAP/mliap_model_nn.h +++ b/src/MLIAP/mliap_model_nn.h @@ -15,7 +15,6 @@ #define LMP_MLIAP_MODEL_NN_H #include "mliap_model.h" -#include namespace LAMMPS_NS { @@ -38,23 +37,20 @@ protected: double ***scale; // element scale values double **coeffelem; // element coefficients virtual void read_coeffs(char *); -}; -} - -static inline double sigm(double x, double &deriv) { + inline double sigm(double x, double &deriv) { double expl = 1./(1.+exp(-x)); deriv = expl*(1-expl); return expl; -} + } -static inline double tanh(double x, double &deriv) { + inline double tanh(double x, double &deriv) { double expl = 2./(1.+exp(-2.*x))-1; deriv = 1.-expl*expl; return expl; -} + } -static inline double relu(double x, double &deriv) { + inline double relu(double x, double &deriv) { if (x > 0) { deriv = 1.; return x; @@ -62,6 +58,10 @@ static inline double relu(double x, double &deriv) { deriv = 0.; return 0; } + } + +}; + } #endif From cf04303daf0b33e7ff488ba42460eca10d1ebf6b Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Wed, 3 Mar 2021 14:27:04 -0700 Subject: [PATCH 19/30] Final edits to doc page --- doc/src/pair_mliap.rst | 4 ++-- doc/utils/sphinx-config/false_positives.txt | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/doc/src/pair_mliap.rst b/doc/src/pair_mliap.rst index 7ef7380abc..4c22c0ee9a 100644 --- a/doc/src/pair_mliap.rst +++ b/doc/src/pair_mliap.rst @@ -98,10 +98,10 @@ and followed by a sequence of a string and an integer for each layer: * nnodes = Number of nodes This is followed by one block for each of the *nelem* elements. Each block consists -of *scale0* minimum values, *scale1* (maximum - minimum) values, +of *scale0* minimum value, *scale1* (maximum - minimum) value, in order to normalize the descriptors, followed by *nparams* parameters, including *bias* and *weights* of the model, starting with the first node of the first layer -and so on, max. 30 parameters per line. +and so on, with a maximum of 30 values per line. Notes on mliappy models: When the *model* keyword is *mliappy*, the filename should end in '.pt', diff --git a/doc/utils/sphinx-config/false_positives.txt b/doc/utils/sphinx-config/false_positives.txt index 9937a98850..dd853c3cbc 100644 --- a/doc/utils/sphinx-config/false_positives.txt +++ b/doc/utils/sphinx-config/false_positives.txt @@ -2096,6 +2096,7 @@ ncol ncorr ncount nd +ndescriptors ndihedrals ndihedraltypes Ndihedraltype @@ -2156,6 +2157,7 @@ niu Nk nktv nl +nlayers nlen Nlines nlo @@ -2171,6 +2173,7 @@ Nmin nmin Nmols nn +nnodes Nocedal nocite nocoeff @@ -2651,6 +2654,7 @@ reinit relaxbox relink relTol +relu remappings remd Ren @@ -2878,6 +2882,7 @@ si SiC Siepmann Sievers +sigmoid Sij Sikandar Silbert From 31cf07947ec4d921bfd151b47f0906c1698ade52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Antonio=20Santos=20Fl=C3=B3rez?= Date: Thu, 4 Mar 2021 03:11:45 -0300 Subject: [PATCH 20/30] fix typo --- src/MLIAP/mliap_model_nn.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/MLIAP/mliap_model_nn.cpp b/src/MLIAP/mliap_model_nn.cpp index 76b60bbb71..cd533e8599 100644 --- a/src/MLIAP/mliap_model_nn.cpp +++ b/src/MLIAP/mliap_model_nn.cpp @@ -200,7 +200,8 @@ void MLIAPModelNN::read_coeffs(char *coefffilename) } l += nwords; if (l == nparams) { - stats = 0; + stats = 1; + l = 0; ielem++; } } From 3bda036ca5958a36914e967bce72629586683079 Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Thu, 4 Mar 2021 08:49:06 -0700 Subject: [PATCH 21/30] Eliminated shortcut exit that was causing memory overflow --- src/MLIAP/mliap_data.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/MLIAP/mliap_data.cpp b/src/MLIAP/mliap_data.cpp index 8eff580dd7..be8d165611 100644 --- a/src/MLIAP/mliap_data.cpp +++ b/src/MLIAP/mliap_data.cpp @@ -210,10 +210,11 @@ void MLIAPData::grow_neigharrays() int *numneigh = list->numneigh; int **firstneigh = list->firstneigh; - int iilast = list->inum-1; - int ilast = list->ilist[iilast]; - int upperbound = firstneigh[ilast] - firstneigh[0] + numneigh[ilast]; - if (nneigh_max >= upperbound) return; + // This saves some time, but is not always correct + // int iilast = list->inum-1; + // int ilast = list->ilist[iilast]; + // int upperbound = firstneigh[ilast] - firstneigh[0] + numneigh[ilast]; + // if (nneigh_max >= upperbound) return; double **x = atom->x; int *type = atom->type; From add929fa0607432383eb069615992957e28a2ba4 Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Thu, 4 Mar 2021 11:48:42 -0700 Subject: [PATCH 22/30] Removed incorrect and useless early-exit --- src/MLIAP/mliap_data.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/MLIAP/mliap_data.cpp b/src/MLIAP/mliap_data.cpp index be8d165611..55b9e02bc9 100644 --- a/src/MLIAP/mliap_data.cpp +++ b/src/MLIAP/mliap_data.cpp @@ -102,6 +102,7 @@ void MLIAPData::generate_neighdata(NeighList* list_in, int eflag_in, int vflag_i double **x = atom->x; int *type = atom->type; + int *ilist = list->ilist; int *numneigh = list->numneigh; int **firstneigh = list->firstneigh; @@ -146,8 +147,8 @@ void MLIAPData::generate_neighdata(NeighList* list_in, int eflag_in, int vflag_i grow_neigharrays(); int ij = 0; - for (int ii = 0; ii < list->inum; ii++) { - const int i = list->ilist[ii]; + for (int ii = 0; ii < natoms; ii++) { + const int i = ilist[ii]; const double xtmp = x[i][0]; const double ytmp = x[i][1]; @@ -207,21 +208,15 @@ void MLIAPData::grow_neigharrays() // grow neighbor arrays if necessary + int *ilist = list->ilist; int *numneigh = list->numneigh; int **firstneigh = list->firstneigh; - - // This saves some time, but is not always correct - // int iilast = list->inum-1; - // int ilast = list->ilist[iilast]; - // int upperbound = firstneigh[ilast] - firstneigh[0] + numneigh[ilast]; - // if (nneigh_max >= upperbound) return; - double **x = atom->x; int *type = atom->type; int nneigh = 0; - for (int ii = 0; ii < list->inum; ii++) { - const int i = list->ilist[ii]; + for (int ii = 0; ii < natomneigh; ii++) { + const int i = ilist[ii]; const double xtmp = x[i][0]; const double ytmp = x[i][1]; From 38586669f854142e0b663a4c5065321030c338ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Antonio=20Santos=20Fl=C3=B3rez?= Date: Thu, 4 Mar 2021 19:03:11 -0300 Subject: [PATCH 23/30] Removed compute*.dat and *v2 files --- examples/mliap/compute.quadratic.gg0.dat | 17 -- examples/mliap/compute.quadratic.gg1.dat | 17 -- examples/mliap/compute.snap.gg0.dat | 17 -- examples/mliap/compute.snap.gg1.dat | 17 -- examples/mliap/log.Ta06_v2 | 156 ------------- examples/mliap/log.WBe_v2 | 167 -------------- examples/mliap/log.chem_v2 | 158 ------------- examples/mliap/log.compute_v2 | 282 ----------------------- examples/mliap/log.quadratic_compute_v2 | 282 ----------------------- examples/mliap/log.quadratic_v2 | 158 ------------- 10 files changed, 1271 deletions(-) delete mode 100644 examples/mliap/compute.quadratic.gg0.dat delete mode 100644 examples/mliap/compute.quadratic.gg1.dat delete mode 100644 examples/mliap/compute.snap.gg0.dat delete mode 100644 examples/mliap/compute.snap.gg1.dat delete mode 100644 examples/mliap/log.Ta06_v2 delete mode 100644 examples/mliap/log.WBe_v2 delete mode 100644 examples/mliap/log.chem_v2 delete mode 100644 examples/mliap/log.compute_v2 delete mode 100644 examples/mliap/log.quadratic_compute_v2 delete mode 100644 examples/mliap/log.quadratic_v2 diff --git a/examples/mliap/compute.quadratic.gg0.dat b/examples/mliap/compute.quadratic.gg0.dat deleted file mode 100644 index 0a6695c1ab..0000000000 --- a/examples/mliap/compute.quadratic.gg0.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Time-averaged data for fix snap -# TimeStep Number-of-rows -# Row c_snap[1] c_snap[2] c_snap[3] c_snap[4] c_snap[5] c_snap[6] c_snap[7] c_snap[8] c_snap[9] c_snap[10] c_snap[11] c_snap[12] c_snap[13] c_snap[14] c_snap[15] c_snap[16] c_snap[17] c_snap[18] c_snap[19] c_snap[20] c_snap[21] c_snap[22] c_snap[23] c_snap[24] c_snap[25] c_snap[26] c_snap[27] c_snap[28] c_snap[29] c_snap[30] c_snap[31] c_snap[32] c_snap[33] c_snap[34] c_snap[35] c_snap[36] c_snap[37] c_snap[38] c_snap[39] c_snap[40] c_snap[41] c_snap[42] c_snap[43] -0 13 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 364183 213523 107428 122916 41227.5 3.31573e+10 3.88807e+10 1.95617e+10 2.23819e+10 7.50718e+09 1.1398e+10 1.14692e+10 1.31227e+10 4.40152e+09 2.88519e+09 6.60228e+09 2.21449e+09 3.77706e+09 2.53375e+09 4.24928e+08 322.87 -2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -206.978 -293.105 -434.029 -217.39 0 -3.76889e+07 -5.33719e+07 -7.9033e+07 -3.95849e+07 -2.20973e+07 -4.24099e+07 -5.9058e+07 -2.74755e+07 -1.57438e+07 -4.1327e+07 -1.77189e+07 -2.66745e+07 -2.23073e+07 -4.48124e+06 -20.7188 -3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1277.1 -1841.02 -2752.08 -1381.8 0 -2.3255e+08 -3.35235e+08 -5.0113e+08 -2.51613e+08 -1.36345e+08 -2.65149e+08 -3.72304e+08 -1.73849e+08 -9.88886e+07 -2.6097e+08 -1.12172e+08 -1.69137e+08 -1.41653e+08 -2.8484e+07 -106.829 -4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 804.916 1147.62 1705.6 855.045 0 1.46568e+08 2.08973e+08 3.10574e+08 1.55696e+08 8.59341e+07 1.65757e+08 2.3156e+08 1.07878e+08 6.16434e+07 1.62145e+08 6.95847e+07 1.04822e+08 8.77079e+07 1.76257e+07 74.8128 -5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 206.978 293.105 434.029 217.39 0 3.76889e+07 5.33719e+07 7.9033e+07 3.95849e+07 2.20973e+07 4.24099e+07 5.9058e+07 2.74755e+07 1.57438e+07 4.1327e+07 1.77189e+07 2.66745e+07 2.23073e+07 4.48124e+06 20.7188 -6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1277.1 1841.02 2752.08 1381.8 0 2.3255e+08 3.35235e+08 5.0113e+08 2.51613e+08 1.36345e+08 2.65149e+08 3.72304e+08 1.73849e+08 9.88886e+07 2.6097e+08 1.12172e+08 1.69137e+08 1.41653e+08 2.8484e+07 106.829 -7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -804.916 -1147.62 -1705.6 -855.045 0 -1.46568e+08 -2.08973e+08 -3.10574e+08 -1.55696e+08 -8.59341e+07 -1.65757e+08 -2.3156e+08 -1.07878e+08 -6.16434e+07 -1.62145e+08 -6.95847e+07 -1.04822e+08 -8.77079e+07 -1.76257e+07 -74.8128 -8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -368289 -407156 -507654 -255414 0 -6.70623e+10 -7.41396e+10 -9.24395e+10 -4.65087e+10 -3.93191e+10 -6.32509e+10 -7.68322e+10 -3.48602e+10 -2.18699e+10 -5.2291e+10 -2.21123e+10 -3.11993e+10 -2.61618e+10 -5.26504e+09 1.3152e+08 -9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -366906 -404336 -502742 -252940 0 -6.68105e+10 -7.36261e+10 -9.1545e+10 -4.60582e+10 -3.91714e+10 -6.28755e+10 -7.62227e+10 -3.45676e+10 -2.17185e+10 -5.18538e+10 -2.19213e+10 -3.08974e+10 -2.59085e+10 -5.21405e+09 1.2154e+08 -10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -367764 -406084 -505786 -254475 0 -6.69666e+10 -7.39444e+10 -9.20993e+10 -4.63376e+10 -3.9263e+10 -6.31081e+10 -7.66004e+10 -3.47491e+10 -2.18124e+10 -5.21248e+10 -2.20397e+10 -3.10845e+10 -2.60656e+10 -5.24568e+09 1.27407e+08 -11 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1133.9 -1843.91 -2924.6 -1483.25 0 -2.06474e+08 -3.3576e+08 -5.32545e+08 -2.70086e+08 -1.21057e+08 -2.57765e+08 -3.81922e+08 -1.81728e+08 -9.90436e+07 -2.70414e+08 -1.17681e+08 -1.7974e+08 -1.51444e+08 -3.05753e+07 -5.32884e+06 -12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -183.403 -298.662 -473.996 -240.251 0 -3.33961e+07 -5.43839e+07 -8.63107e+07 -4.37476e+07 -1.95804e+07 -4.17369e+07 -6.18761e+07 -2.94301e+07 -1.60423e+07 -4.38153e+07 -1.90614e+07 -2.91308e+07 -2.45361e+07 -4.95247e+06 -1.08912e+06 -13 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 291.353 474.04 752.045 381.322 0 5.30528e+07 8.63186e+07 1.36941e+08 6.94355e+07 3.11053e+07 6.62589e+07 9.81954e+07 4.67164e+07 2.54626e+07 6.95288e+07 3.02541e+07 4.6219e+07 3.89377e+07 7.86049e+06 1.50556e+06 diff --git a/examples/mliap/compute.quadratic.gg1.dat b/examples/mliap/compute.quadratic.gg1.dat deleted file mode 100644 index 0a6695c1ab..0000000000 --- a/examples/mliap/compute.quadratic.gg1.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Time-averaged data for fix snap -# TimeStep Number-of-rows -# Row c_snap[1] c_snap[2] c_snap[3] c_snap[4] c_snap[5] c_snap[6] c_snap[7] c_snap[8] c_snap[9] c_snap[10] c_snap[11] c_snap[12] c_snap[13] c_snap[14] c_snap[15] c_snap[16] c_snap[17] c_snap[18] c_snap[19] c_snap[20] c_snap[21] c_snap[22] c_snap[23] c_snap[24] c_snap[25] c_snap[26] c_snap[27] c_snap[28] c_snap[29] c_snap[30] c_snap[31] c_snap[32] c_snap[33] c_snap[34] c_snap[35] c_snap[36] c_snap[37] c_snap[38] c_snap[39] c_snap[40] c_snap[41] c_snap[42] c_snap[43] -0 13 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 364183 213523 107428 122916 41227.5 3.31573e+10 3.88807e+10 1.95617e+10 2.23819e+10 7.50718e+09 1.1398e+10 1.14692e+10 1.31227e+10 4.40152e+09 2.88519e+09 6.60228e+09 2.21449e+09 3.77706e+09 2.53375e+09 4.24928e+08 322.87 -2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -206.978 -293.105 -434.029 -217.39 0 -3.76889e+07 -5.33719e+07 -7.9033e+07 -3.95849e+07 -2.20973e+07 -4.24099e+07 -5.9058e+07 -2.74755e+07 -1.57438e+07 -4.1327e+07 -1.77189e+07 -2.66745e+07 -2.23073e+07 -4.48124e+06 -20.7188 -3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1277.1 -1841.02 -2752.08 -1381.8 0 -2.3255e+08 -3.35235e+08 -5.0113e+08 -2.51613e+08 -1.36345e+08 -2.65149e+08 -3.72304e+08 -1.73849e+08 -9.88886e+07 -2.6097e+08 -1.12172e+08 -1.69137e+08 -1.41653e+08 -2.8484e+07 -106.829 -4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 804.916 1147.62 1705.6 855.045 0 1.46568e+08 2.08973e+08 3.10574e+08 1.55696e+08 8.59341e+07 1.65757e+08 2.3156e+08 1.07878e+08 6.16434e+07 1.62145e+08 6.95847e+07 1.04822e+08 8.77079e+07 1.76257e+07 74.8128 -5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 206.978 293.105 434.029 217.39 0 3.76889e+07 5.33719e+07 7.9033e+07 3.95849e+07 2.20973e+07 4.24099e+07 5.9058e+07 2.74755e+07 1.57438e+07 4.1327e+07 1.77189e+07 2.66745e+07 2.23073e+07 4.48124e+06 20.7188 -6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1277.1 1841.02 2752.08 1381.8 0 2.3255e+08 3.35235e+08 5.0113e+08 2.51613e+08 1.36345e+08 2.65149e+08 3.72304e+08 1.73849e+08 9.88886e+07 2.6097e+08 1.12172e+08 1.69137e+08 1.41653e+08 2.8484e+07 106.829 -7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -804.916 -1147.62 -1705.6 -855.045 0 -1.46568e+08 -2.08973e+08 -3.10574e+08 -1.55696e+08 -8.59341e+07 -1.65757e+08 -2.3156e+08 -1.07878e+08 -6.16434e+07 -1.62145e+08 -6.95847e+07 -1.04822e+08 -8.77079e+07 -1.76257e+07 -74.8128 -8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -368289 -407156 -507654 -255414 0 -6.70623e+10 -7.41396e+10 -9.24395e+10 -4.65087e+10 -3.93191e+10 -6.32509e+10 -7.68322e+10 -3.48602e+10 -2.18699e+10 -5.2291e+10 -2.21123e+10 -3.11993e+10 -2.61618e+10 -5.26504e+09 1.3152e+08 -9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -366906 -404336 -502742 -252940 0 -6.68105e+10 -7.36261e+10 -9.1545e+10 -4.60582e+10 -3.91714e+10 -6.28755e+10 -7.62227e+10 -3.45676e+10 -2.17185e+10 -5.18538e+10 -2.19213e+10 -3.08974e+10 -2.59085e+10 -5.21405e+09 1.2154e+08 -10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -367764 -406084 -505786 -254475 0 -6.69666e+10 -7.39444e+10 -9.20993e+10 -4.63376e+10 -3.9263e+10 -6.31081e+10 -7.66004e+10 -3.47491e+10 -2.18124e+10 -5.21248e+10 -2.20397e+10 -3.10845e+10 -2.60656e+10 -5.24568e+09 1.27407e+08 -11 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1133.9 -1843.91 -2924.6 -1483.25 0 -2.06474e+08 -3.3576e+08 -5.32545e+08 -2.70086e+08 -1.21057e+08 -2.57765e+08 -3.81922e+08 -1.81728e+08 -9.90436e+07 -2.70414e+08 -1.17681e+08 -1.7974e+08 -1.51444e+08 -3.05753e+07 -5.32884e+06 -12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -183.403 -298.662 -473.996 -240.251 0 -3.33961e+07 -5.43839e+07 -8.63107e+07 -4.37476e+07 -1.95804e+07 -4.17369e+07 -6.18761e+07 -2.94301e+07 -1.60423e+07 -4.38153e+07 -1.90614e+07 -2.91308e+07 -2.45361e+07 -4.95247e+06 -1.08912e+06 -13 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 291.353 474.04 752.045 381.322 0 5.30528e+07 8.63186e+07 1.36941e+08 6.94355e+07 3.11053e+07 6.62589e+07 9.81954e+07 4.67164e+07 2.54626e+07 6.95288e+07 3.02541e+07 4.6219e+07 3.89377e+07 7.86049e+06 1.50556e+06 diff --git a/examples/mliap/compute.snap.gg0.dat b/examples/mliap/compute.snap.gg0.dat deleted file mode 100644 index 4351b21103..0000000000 --- a/examples/mliap/compute.snap.gg0.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Time-averaged data for fix snap -# TimeStep Number-of-rows -# Row c_snap[1] c_snap[2] c_snap[3] c_snap[4] c_snap[5] c_snap[6] c_snap[7] c_snap[8] c_snap[9] c_snap[10] c_snap[11] c_snap[12] c_snap[13] -0 13 -1 0 0 0 0 0 0 2 364183 213523 107428 122916 41227.5 322.87 -2 0 0 0 0 0 0 0 0 -206.978 -293.105 -434.029 -217.39 -20.7188 -3 0 0 0 0 0 0 0 0 -1277.1 -1841.02 -2752.08 -1381.8 -106.829 -4 0 0 0 0 0 0 0 0 804.916 1147.62 1705.6 855.045 74.8128 -5 0 0 0 0 0 0 0 0 206.978 293.105 434.029 217.39 20.7188 -6 0 0 0 0 0 0 0 0 1277.1 1841.02 2752.08 1381.8 106.829 -7 0 0 0 0 0 0 0 0 -804.916 -1147.62 -1705.6 -855.045 -74.8128 -8 0 0 0 0 0 0 0 0 -368289 -407156 -507654 -255414 1.3152e+08 -9 0 0 0 0 0 0 0 0 -366906 -404336 -502742 -252940 1.2154e+08 -10 0 0 0 0 0 0 0 0 -367764 -406084 -505786 -254475 1.27407e+08 -11 0 0 0 0 0 0 0 0 -1133.9 -1843.91 -2924.6 -1483.25 -5.32884e+06 -12 0 0 0 0 0 0 0 0 -183.403 -298.662 -473.996 -240.251 -1.08912e+06 -13 0 0 0 0 0 0 0 0 291.353 474.04 752.045 381.322 1.50556e+06 diff --git a/examples/mliap/compute.snap.gg1.dat b/examples/mliap/compute.snap.gg1.dat deleted file mode 100644 index 4351b21103..0000000000 --- a/examples/mliap/compute.snap.gg1.dat +++ /dev/null @@ -1,17 +0,0 @@ -# Time-averaged data for fix snap -# TimeStep Number-of-rows -# Row c_snap[1] c_snap[2] c_snap[3] c_snap[4] c_snap[5] c_snap[6] c_snap[7] c_snap[8] c_snap[9] c_snap[10] c_snap[11] c_snap[12] c_snap[13] -0 13 -1 0 0 0 0 0 0 2 364183 213523 107428 122916 41227.5 322.87 -2 0 0 0 0 0 0 0 0 -206.978 -293.105 -434.029 -217.39 -20.7188 -3 0 0 0 0 0 0 0 0 -1277.1 -1841.02 -2752.08 -1381.8 -106.829 -4 0 0 0 0 0 0 0 0 804.916 1147.62 1705.6 855.045 74.8128 -5 0 0 0 0 0 0 0 0 206.978 293.105 434.029 217.39 20.7188 -6 0 0 0 0 0 0 0 0 1277.1 1841.02 2752.08 1381.8 106.829 -7 0 0 0 0 0 0 0 0 -804.916 -1147.62 -1705.6 -855.045 -74.8128 -8 0 0 0 0 0 0 0 0 -368289 -407156 -507654 -255414 1.3152e+08 -9 0 0 0 0 0 0 0 0 -366906 -404336 -502742 -252940 1.2154e+08 -10 0 0 0 0 0 0 0 0 -367764 -406084 -505786 -254475 1.27407e+08 -11 0 0 0 0 0 0 0 0 -1133.9 -1843.91 -2924.6 -1483.25 -5.32884e+06 -12 0 0 0 0 0 0 0 0 -183.403 -298.662 -473.996 -240.251 -1.08912e+06 -13 0 0 0 0 0 0 0 0 291.353 474.04 752.045 381.322 1.50556e+06 diff --git a/examples/mliap/log.Ta06_v2 b/examples/mliap/log.Ta06_v2 deleted file mode 100644 index 64b37a45c5..0000000000 --- a/examples/mliap/log.Ta06_v2 +++ /dev/null @@ -1,156 +0,0 @@ -LAMMPS (10 Feb 2021) -# Demonstrate MLIAP interface to linear SNAP potential - -# Initialize simulation - -variable nsteps index 100 -variable nrep equal 4 -variable a equal 3.316 -units metal - -# generate the box and atom positions using a BCC lattice - -variable nx equal ${nrep} -variable nx equal 4 -variable ny equal ${nrep} -variable ny equal 4 -variable nz equal ${nrep} -variable nz equal 4 - -boundary p p p - -lattice bcc $a -lattice bcc 3.316 -Lattice spacing in x,y,z = 3.3160000 3.3160000 3.3160000 -region box block 0 ${nx} 0 ${ny} 0 ${nz} -region box block 0 4 0 ${ny} 0 ${nz} -region box block 0 4 0 4 0 ${nz} -region box block 0 4 0 4 0 4 -create_box 1 box -Created orthogonal box = (0.0000000 0.0000000 0.0000000) to (13.264000 13.264000 13.264000) - 1 by 1 by 1 MPI processor grid -create_atoms 1 box -Created 128 atoms - create_atoms CPU = 0.000 seconds - -mass 1 180.88 - -# choose potential - -include Ta06A.mliap -# DATE: 2014-09-05 UNITS: metal CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: Thompson, Swiler, Trott, Foiles and Tucker, arxiv.org, 1409.3880 (2014) - -# Definition of SNAP potential Ta_Cand06A -# Assumes 1 LAMMPS atom type - -variable zblcutinner equal 4 -variable zblcutouter equal 4.8 -variable zblz equal 73 - -# Specify hybrid with SNAP, ZBL - -pair_style hybrid/overlay zbl ${zblcutinner} ${zblcutouter} mliap model linear Ta06A.mliap.model descriptor sna Ta06A.mliap.descriptor -pair_style hybrid/overlay zbl 4 ${zblcutouter} mliap model linear Ta06A.mliap.model descriptor sna Ta06A.mliap.descriptor -pair_style hybrid/overlay zbl 4 4.8 mliap model linear Ta06A.mliap.model descriptor sna Ta06A.mliap.descriptor -Reading potential file Ta06A.mliap.model with DATE: 2014-09-05 -Reading potential file Ta06A.mliap.descriptor with DATE: 2014-09-05 -SNAP keyword rcutfac 4.67637 -SNAP keyword twojmax 6 -SNAP keyword nelems 1 -SNAP keyword elems Ta -SNAP keyword radelems 0.5 -SNAP keyword welems 1 -SNAP keyword rfac0 0.99363 -SNAP keyword rmin0 0 -SNAP keyword bzeroflag 0 -pair_coeff 1 1 zbl ${zblz} ${zblz} -pair_coeff 1 1 zbl 73 ${zblz} -pair_coeff 1 1 zbl 73 73 -pair_coeff * * mliap Ta - - -# Setup output - -compute eatom all pe/atom -compute energy all reduce sum c_eatom - -compute satom all stress/atom NULL -compute str all reduce sum c_satom[1] c_satom[2] c_satom[3] -variable press equal (c_str[1]+c_str[2]+c_str[3])/(3*vol) - -thermo_style custom step temp epair c_energy etotal press v_press -thermo 10 -thermo_modify norm yes - -# Set up NVE run - -timestep 0.5e-3 -neighbor 1.0 bin -neigh_modify once no every 1 delay 0 check yes - -# Run MD - -velocity all create 300.0 4928459 loop geom -fix 1 all nve -run ${nsteps} -run 100 -Neighbor list info ... - update every 1 steps, delay 0 steps, check yes - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 5.8 - ghost atom cutoff = 5.8 - binsize = 2.9, bins = 5 5 5 - 2 neighbor lists, perpetual/occasional/extra = 2 0 0 - (1) pair zbl, perpetual, half/full from (2) - attributes: half, newton on - pair build: halffull/newton - stencil: none - bin: none - (2) pair mliap, perpetual - attributes: full, newton on - pair build: full/bin/atomonly - stencil: full/bin/3d - bin: standard -Per MPI rank memory allocation (min/avg/max) = 18.15 | 18.15 | 18.15 Mbytes -Step Temp E_pair c_energy TotEng Press v_press - 0 300 -11.85157 -11.85157 -11.813095 2717.1661 -2717.1661 - 10 296.01467 -11.851059 -11.851059 -11.813095 2697.4796 -2697.4796 - 20 284.53666 -11.849587 -11.849587 -11.813095 2289.1527 -2289.1527 - 30 266.51577 -11.847275 -11.847275 -11.813095 1851.7131 -1851.7131 - 40 243.05007 -11.844266 -11.844266 -11.813095 1570.684 -1570.684 - 50 215.51032 -11.840734 -11.840734 -11.813094 1468.1899 -1468.1899 - 60 185.48331 -11.836883 -11.836883 -11.813094 1524.8757 -1524.8757 - 70 154.6736 -11.832931 -11.832931 -11.813094 1698.3351 -1698.3351 - 80 124.79303 -11.829099 -11.829099 -11.813094 1947.0715 -1947.0715 - 90 97.448054 -11.825592 -11.825592 -11.813094 2231.9563 -2231.9563 - 100 74.035418 -11.822589 -11.822589 -11.813094 2515.8526 -2515.8526 -Loop time of 1.80936 on 1 procs for 100 steps with 128 atoms - -Performance: 2.388 ns/day, 10.052 hours/ns, 55.268 timesteps/s -80.9% CPU use with 1 MPI tasks x no OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 1.8055 | 1.8055 | 1.8055 | 0.0 | 99.78 -Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0.00133 | 0.00133 | 0.00133 | 0.0 | 0.07 -Output | 0.001145 | 0.001145 | 0.001145 | 0.0 | 0.06 -Modify | 0.000669 | 0.000669 | 0.000669 | 0.0 | 0.04 -Other | | 0.000749 | | | 0.04 - -Nlocal: 128.000 ave 128 max 128 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Nghost: 727.000 ave 727 max 727 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 3712.00 ave 3712 max 3712 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -FullNghs: 7424.00 ave 7424 max 7424 min -Histogram: 1 0 0 0 0 0 0 0 0 0 - -Total # of neighbors = 7424 -Ave neighs/atom = 58.000000 -Neighbor list builds = 0 -Dangerous builds = 0 - -Total wall time: 0:00:01 diff --git a/examples/mliap/log.WBe_v2 b/examples/mliap/log.WBe_v2 deleted file mode 100644 index 74e3a934ac..0000000000 --- a/examples/mliap/log.WBe_v2 +++ /dev/null @@ -1,167 +0,0 @@ -LAMMPS (10 Feb 2021) -# Demonstrate MLIAP interface to SNAP W-Be potential - -# Initialize simulation - -variable nsteps index 100 -variable nrep equal 4 -variable a equal 3.1803 -units metal - -# generate the box and atom positions using a BCC lattice - -variable nx equal ${nrep} -variable nx equal 4 -variable ny equal ${nrep} -variable ny equal 4 -variable nz equal ${nrep} -variable nz equal 4 - -boundary p p p - -lattice bcc $a -lattice bcc 3.1803 -Lattice spacing in x,y,z = 3.1803000 3.1803000 3.1803000 -region box block 0 ${nx} 0 ${ny} 0 ${nz} -region box block 0 4 0 ${ny} 0 ${nz} -region box block 0 4 0 4 0 ${nz} -region box block 0 4 0 4 0 4 -create_box 2 box -Created orthogonal box = (0.0000000 0.0000000 0.0000000) to (12.721200 12.721200 12.721200) - 1 by 1 by 1 MPI processor grid -create_atoms 1 box -Created 128 atoms - create_atoms CPU = 0.000 seconds -mass 1 183.84 -mass 2 9.012182 - -set group all type/fraction 2 0.05 3590153 # Change 5% of W to He -Setting atom values ... - 5 settings made for type/fraction -group tungsten type 1 -123 atoms in group tungsten -group beryllium type 2 -5 atoms in group beryllium -# choose potential - -include WBe_Wood_PRB2019.mliap -# DATE: 2019-09-18 UNITS: metal CONTRIBUTOR: Mary Alice Cusentino mcusent@sandia.gov CITATION: M.A. Wood, M.A. Cusentino, B.D. Wirth, and A.P. Thompson, "Data-driven material models for atomistic simulation", Physical Review B 99, 184305 (2019) -# Definition of SNAP+ZBL potential. -variable zblcutinner equal 4 -variable zblcutouter equal 4.8 -variable zblz1 equal 74 -variable zblz2 equal 4 - -# Specify hybrid with SNAP and ZBL - -pair_style hybrid/overlay zbl ${zblcutinner} ${zblcutouter} mliap model linear WBe_Wood_PRB2019.mliap.model descriptor sna WBe_Wood_PRB2019.mliap.descriptor -pair_style hybrid/overlay zbl 4 ${zblcutouter} mliap model linear WBe_Wood_PRB2019.mliap.model descriptor sna WBe_Wood_PRB2019.mliap.descriptor -pair_style hybrid/overlay zbl 4 4.8 mliap model linear WBe_Wood_PRB2019.mliap.model descriptor sna WBe_Wood_PRB2019.mliap.descriptor -Reading potential file WBe_Wood_PRB2019.mliap.model with DATE: 2019-09-18 -Reading potential file WBe_Wood_PRB2019.mliap.descriptor with DATE: 2019-09-18 -SNAP keyword rcutfac 4.8123 -SNAP keyword twojmax 8 -SNAP keyword nelems 2 -SNAP keyword elems W -SNAP keyword radelems 0.5 -SNAP keyword welems 1 -SNAP keyword rfac0 0.99363 -SNAP keyword rmin0 0 -SNAP keyword bzeroflag 1 -pair_coeff 1 1 zbl ${zblz1} ${zblz1} -pair_coeff 1 1 zbl 74 ${zblz1} -pair_coeff 1 1 zbl 74 74 -pair_coeff 1 2 zbl ${zblz1} ${zblz2} -pair_coeff 1 2 zbl 74 ${zblz2} -pair_coeff 1 2 zbl 74 4 -pair_coeff 2 2 zbl ${zblz2} ${zblz2} -pair_coeff 2 2 zbl 4 ${zblz2} -pair_coeff 2 2 zbl 4 4 -pair_coeff * * mliap W Be - - -# Setup output - -compute eatom all pe/atom -compute energy all reduce sum c_eatom - -compute satom all stress/atom NULL -compute str all reduce sum c_satom[1] c_satom[2] c_satom[3] -variable press equal (c_str[1]+c_str[2]+c_str[3])/(3*vol) - -thermo_style custom step temp epair c_energy etotal press v_press -thermo 10 -thermo_modify norm yes - -# Set up NVE run - -timestep 0.5e-3 -neighbor 1.0 bin -neigh_modify once no every 1 delay 0 check yes - -# Run MD - -velocity all create 300.0 4928459 loop geom -fix 1 all nve -run ${nsteps} -run 100 -Neighbor list info ... - update every 1 steps, delay 0 steps, check yes - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 5.8123 - ghost atom cutoff = 5.8123 - binsize = 2.90615, bins = 5 5 5 - 2 neighbor lists, perpetual/occasional/extra = 2 0 0 - (1) pair zbl, perpetual, half/full from (2) - attributes: half, newton on - pair build: halffull/newton - stencil: none - bin: none - (2) pair mliap, perpetual - attributes: full, newton on - pair build: full/bin/atomonly - stencil: full/bin/3d - bin: standard -Per MPI rank memory allocation (min/avg/max) = 48.80 | 48.80 | 48.80 Mbytes -Step Temp E_pair c_energy TotEng Press v_press - 0 300 -8.5980876 -8.5980876 -8.5596125 -35284.855 35284.855 - 10 296.32664 -8.5976164 -8.5976164 -8.5596124 -35188.339 35188.339 - 20 282.41417 -8.595832 -8.595832 -8.5596123 -34782.293 34782.293 - 30 259.69014 -8.5929175 -8.5929175 -8.5596121 -34113.316 34113.316 - 40 230.50415 -8.5891741 -8.5891741 -8.5596119 -33260.777 33260.777 - 50 197.88816 -8.5849908 -8.5849908 -8.5596116 -32309.975 32309.975 - 60 165.27259 -8.5808076 -8.5808076 -8.5596113 -31365.766 31365.766 - 70 136.15697 -8.5770733 -8.5770733 -8.5596111 -30542.657 30542.657 - 80 113.58947 -8.5741788 -8.5741788 -8.5596109 -29939.23 29939.23 - 90 99.477916 -8.572369 -8.572369 -8.5596109 -29619.939 29619.939 - 100 94.121939 -8.5716822 -8.5716822 -8.559611 -29598.002 29598.002 -Loop time of 5.14269 on 1 procs for 100 steps with 128 atoms - -Performance: 0.840 ns/day, 28.570 hours/ns, 19.445 timesteps/s -82.5% CPU use with 1 MPI tasks x no OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 5.1376 | 5.1376 | 5.1376 | 0.0 | 99.90 -Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0.001657 | 0.001657 | 0.001657 | 0.0 | 0.03 -Output | 0.002107 | 0.002107 | 0.002107 | 0.0 | 0.04 -Modify | 0.00052 | 0.00052 | 0.00052 | 0.0 | 0.01 -Other | | 0.00078 | | | 0.02 - -Nlocal: 128.000 ave 128 max 128 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Nghost: 727.000 ave 727 max 727 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 3712.00 ave 3712 max 3712 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -FullNghs: 7424.00 ave 7424 max 7424 min -Histogram: 1 0 0 0 0 0 0 0 0 0 - -Total # of neighbors = 7424 -Ave neighs/atom = 58.000000 -Neighbor list builds = 0 -Dangerous builds = 0 - -Total wall time: 0:00:05 diff --git a/examples/mliap/log.chem_v2 b/examples/mliap/log.chem_v2 deleted file mode 100644 index 801ea84c53..0000000000 --- a/examples/mliap/log.chem_v2 +++ /dev/null @@ -1,158 +0,0 @@ -LAMMPS (10 Feb 2021) -# Demonstrate MLIAP interface to ChemSNAP potential - -# Initialize simulation - -variable nsteps index 100 -variable nrep equal 4 -variable a equal 5.83 -units metal - -# generate the box and atom positions using a FCC lattice - -variable nx equal ${nrep} -variable nx equal 4 -variable ny equal ${nrep} -variable ny equal 4 -variable nz equal ${nrep} -variable nz equal 4 - -boundary p p p - -lattice diamond $a -lattice diamond 5.83 -Lattice spacing in x,y,z = 5.8300000 5.8300000 5.8300000 -region box block 0 ${nx} 0 ${ny} 0 ${nz} -region box block 0 4 0 ${ny} 0 ${nz} -region box block 0 4 0 4 0 ${nz} -region box block 0 4 0 4 0 4 -create_box 2 box -Created orthogonal box = (0.0000000 0.0000000 0.0000000) to (23.320000 23.320000 23.320000) - 1 by 1 by 1 MPI processor grid -create_atoms 1 box basis 5 2 basis 6 2 basis 7 2 basis 8 2 -Created 512 atoms - create_atoms CPU = 0.000 seconds - -mass 1 114.76 -mass 2 30.98 - -# choose potential - -include InP_JCPA2020.mliap -# DATE: 2020-06-01 UNITS: metal CONTRIBUTOR: Mary Alice Cusentino mcusent@sandia.gov CITATION: M.A. Cusentino, M. A. Wood, and A.P. Thompson, "Explicit Multi-element Extension of the Spectral Neighbor Analysis Potential for Chemically Complex Systems", J. Phys. Chem. A, xxxxxx (2020) - -# Definition of SNAP+ZBL potential. - -variable zblcutinner index 4 -variable zblcutouter index 4.2 -variable zblz1 index 49 -variable zblz2 index 15 - -# Specify hybrid with SNAP and ZBL - -pair_style hybrid/overlay zbl ${zblcutinner} ${zblcutouter} mliap model linear InP_JCPA2020.mliap.model descriptor sna InP_JCPA2020.mliap.descriptor -pair_style hybrid/overlay zbl 4 ${zblcutouter} mliap model linear InP_JCPA2020.mliap.model descriptor sna InP_JCPA2020.mliap.descriptor -pair_style hybrid/overlay zbl 4 4.2 mliap model linear InP_JCPA2020.mliap.model descriptor sna InP_JCPA2020.mliap.descriptor -Reading potential file InP_JCPA2020.mliap.model with DATE: 2020-06-01 -Reading potential file InP_JCPA2020.mliap.descriptor with DATE: 2020-06-01 -SNAP keyword rcutfac 1.0 -SNAP keyword twojmax 6 -SNAP keyword nelems 2 -SNAP keyword elems In -SNAP keyword radelems 3.81205 -SNAP keyword welems 1 -SNAP keyword rfac0 0.99363 -SNAP keyword rmin0 0.0 -SNAP keyword bzeroflag 1 -SNAP keyword wselfallflag 1 -SNAP keyword chemflag 1 -SNAP keyword bnormflag 1 -pair_coeff 1 1 zbl ${zblz1} ${zblz1} -pair_coeff 1 1 zbl 49 ${zblz1} -pair_coeff 1 1 zbl 49 49 -pair_coeff 1 2 zbl ${zblz1} ${zblz2} -pair_coeff 1 2 zbl 49 ${zblz2} -pair_coeff 1 2 zbl 49 15 -pair_coeff 2 2 zbl ${zblz2} ${zblz2} -pair_coeff 2 2 zbl 15 ${zblz2} -pair_coeff 2 2 zbl 15 15 -pair_coeff * * mliap In P - - -# Setup output - -thermo 10 -thermo_modify norm yes - -# Set up NVE run - -timestep 0.5e-3 -neighbor 1.0 bin -neigh_modify once no every 1 delay 0 check yes - -# Run MD - -velocity all create 300.0 4928459 loop geom -fix 1 all nve -run ${nsteps} -run 100 -Neighbor list info ... - update every 1 steps, delay 0 steps, check yes - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 8.6589 - ghost atom cutoff = 8.6589 - binsize = 4.32945, bins = 6 6 6 - 2 neighbor lists, perpetual/occasional/extra = 2 0 0 - (1) pair zbl, perpetual, half/full from (2) - attributes: half, newton on - pair build: halffull/newton - stencil: none - bin: none - (2) pair mliap, perpetual - attributes: full, newton on - pair build: full/bin/atomonly - stencil: full/bin/3d - bin: standard -Per MPI rank memory allocation (min/avg/max) = 187.1 | 187.1 | 187.1 Mbytes -Step Temp E_pair E_mol TotEng Press - 0 300 -3.4805794 0 -3.4418771 1353.5968 - 10 285.84677 -3.4787531 0 -3.4418766 1611.7131 - 20 248.14649 -3.4738884 0 -3.4418756 2312.0308 - 30 198.94136 -3.4675394 0 -3.4418744 3168.1543 - 40 152.74831 -3.4615791 0 -3.4418734 3903.5749 - 50 121.9796 -3.4576091 0 -3.4418728 4387.1254 - 60 113.27555 -3.4564863 0 -3.4418729 4556.3003 - 70 125.68089 -3.4580873 0 -3.4418735 4431.2083 - 80 151.47475 -3.4614159 0 -3.4418745 4107.2369 - 90 179.18708 -3.4649919 0 -3.4418754 3739.5881 - 100 197.50662 -3.4673559 0 -3.441876 3492.7778 -Loop time of 24.0349 on 1 procs for 100 steps with 512 atoms - -Performance: 0.180 ns/day, 133.527 hours/ns, 4.161 timesteps/s -92.5% CPU use with 1 MPI tasks x no OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 24.031 | 24.031 | 24.031 | 0.0 | 99.99 -Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0.001691 | 0.001691 | 0.001691 | 0.0 | 0.01 -Output | 0.00034 | 0.00034 | 0.00034 | 0.0 | 0.00 -Modify | 0.00082 | 0.00082 | 0.00082 | 0.0 | 0.00 -Other | | 0.000746 | | | 0.00 - -Nlocal: 512.000 ave 512 max 512 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Nghost: 1959.00 ave 1959 max 1959 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 31232.0 ave 31232 max 31232 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -FullNghs: 62464.0 ave 62464 max 62464 min -Histogram: 1 0 0 0 0 0 0 0 0 0 - -Total # of neighbors = 62464 -Ave neighs/atom = 122.00000 -Neighbor list builds = 0 -Dangerous builds = 0 - -Total wall time: 0:00:24 diff --git a/examples/mliap/log.compute_v2 b/examples/mliap/log.compute_v2 deleted file mode 100644 index 859afe2eac..0000000000 --- a/examples/mliap/log.compute_v2 +++ /dev/null @@ -1,282 +0,0 @@ -LAMMPS (10 Feb 2021) -# Demonstrate bispectrum computes - -# initialize simulation - -variable nsteps index 0 -variable nrep equal 1 -variable a equal 2.0 -units metal - -# generate the box and atom positions using a BCC lattice - -variable nx equal ${nrep} -variable nx equal 1 -variable ny equal ${nrep} -variable ny equal 1 -variable nz equal ${nrep} -variable nz equal 1 - -boundary p p p - -atom_modify map hash -lattice bcc $a -lattice bcc 2 -Lattice spacing in x,y,z = 2.0000000 2.0000000 2.0000000 -region box block 0 ${nx} 0 ${ny} 0 ${nz} -region box block 0 1 0 ${ny} 0 ${nz} -region box block 0 1 0 1 0 ${nz} -region box block 0 1 0 1 0 1 -create_box 2 box -Created orthogonal box = (0.0000000 0.0000000 0.0000000) to (2.0000000 2.0000000 2.0000000) - 1 by 1 by 1 MPI processor grid -create_atoms 2 box -Created 2 atoms - create_atoms CPU = 0.001 seconds - -mass * 180.88 - -displace_atoms all random 0.1 0.1 0.1 123456 -Displacing atoms ... - -# set up reference potential - -variable zblcutinner equal 4 -variable zblcutouter equal 4.8 -variable zblz equal 73 -pair_style zbl ${zblcutinner} ${zblcutouter} -pair_style zbl 4 ${zblcutouter} -pair_style zbl 4 4.8 -pair_coeff * * ${zblz} ${zblz} -pair_coeff * * 73 ${zblz} -pair_coeff * * 73 73 - -# choose SNA parameters - -variable twojmax equal 2 -variable rcutfac equal 1.0 -variable rfac0 equal 0.99363 -variable rmin0 equal 0 -variable radelem1 equal 2.3 -variable radelem2 equal 2.0 -variable wj1 equal 1.0 -variable wj2 equal 0.96 -variable quadratic equal 0 -variable bzero equal 0 -variable switch equal 0 -variable snap_options string "${rcutfac} ${rfac0} ${twojmax} ${radelem1} ${radelem2} ${wj1} ${wj2} rmin0 ${rmin0} quadraticflag ${quadratic} bzeroflag ${bzero} switchflag ${switch}" -1 ${rfac0} ${twojmax} ${radelem1} ${radelem2} ${wj1} ${wj2} rmin0 ${rmin0} quadraticflag ${quadratic} bzeroflag ${bzero} switchflag ${switch} -1 0.99363 ${twojmax} ${radelem1} ${radelem2} ${wj1} ${wj2} rmin0 ${rmin0} quadraticflag ${quadratic} bzeroflag ${bzero} switchflag ${switch} -1 0.99363 2 ${radelem1} ${radelem2} ${wj1} ${wj2} rmin0 ${rmin0} quadraticflag ${quadratic} bzeroflag ${bzero} switchflag ${switch} -1 0.99363 2 2.3 ${radelem2} ${wj1} ${wj2} rmin0 ${rmin0} quadraticflag ${quadratic} bzeroflag ${bzero} switchflag ${switch} -1 0.99363 2 2.3 2 ${wj1} ${wj2} rmin0 ${rmin0} quadraticflag ${quadratic} bzeroflag ${bzero} switchflag ${switch} -1 0.99363 2 2.3 2 1 ${wj2} rmin0 ${rmin0} quadraticflag ${quadratic} bzeroflag ${bzero} switchflag ${switch} -1 0.99363 2 2.3 2 1 0.96 rmin0 ${rmin0} quadraticflag ${quadratic} bzeroflag ${bzero} switchflag ${switch} -1 0.99363 2 2.3 2 1 0.96 rmin0 0 quadraticflag ${quadratic} bzeroflag ${bzero} switchflag ${switch} -1 0.99363 2 2.3 2 1 0.96 rmin0 0 quadraticflag 0 bzeroflag ${bzero} switchflag ${switch} -1 0.99363 2 2.3 2 1 0.96 rmin0 0 quadraticflag 0 bzeroflag 0 switchflag ${switch} -1 0.99363 2 2.3 2 1 0.96 rmin0 0 quadraticflag 0 bzeroflag 0 switchflag 0 - -# set up per-atom computes - -compute b all sna/atom ${snap_options} -compute b all sna/atom 1 0.99363 2 2.3 2 1 0.96 rmin0 0 quadraticflag 0 bzeroflag 0 switchflag 0 -compute vb all snav/atom ${snap_options} -compute vb all snav/atom 1 0.99363 2 2.3 2 1 0.96 rmin0 0 quadraticflag 0 bzeroflag 0 switchflag 0 -compute db all snad/atom ${snap_options} -compute db all snad/atom 1 0.99363 2 2.3 2 1 0.96 rmin0 0 quadraticflag 0 bzeroflag 0 switchflag 0 - -# perform sums over atoms - -group snapgroup1 type 1 -0 atoms in group snapgroup1 -group snapgroup2 type 2 -2 atoms in group snapgroup2 -compute bsum1 snapgroup1 reduce sum c_b[*] -compute bsum2 snapgroup2 reduce sum c_b[*] -# fix bsum1 all ave/time 1 1 1 c_bsum1 file bsum1.dat mode vector -# fix bsum2 all ave/time 1 1 1 c_bsum2 file bsum2.dat mode vector -compute vbsum all reduce sum c_vb[*] -# fix vbsum all ave/time 1 1 1 c_vbsum file vbsum.dat mode vector -variable db_2_25 equal c_db[2][25] - -thermo 100 - -# test output: 1: total potential energy -# 2: xy component of stress tensor -# 3: Sum(B_{000}^i, all i of type 2) -# 4: xz component of Sum(Sum(r_j*dB_{222}^i/dR[j]), all i of type 2), all j) -# 5: y component of -Sum(d(B_{222}^i)/dR[2]), all i of type 2) -# -# followed by 5 counterparts from compute snap - -# run compute mliap with gradgradflag = 1 - -compute snap all mliap descriptor sna compute.mliap.descriptor model linear gradgradflag 1 -SNAP keyword rcutfac 1.0 -SNAP keyword twojmax 2 -SNAP keyword nelems 2 -SNAP keyword elems A -SNAP keyword radelems 2.3 -SNAP keyword welems 1.0 -SNAP keyword rfac0 0.99363 -SNAP keyword rmin0 0 -SNAP keyword bzeroflag 0 -SNAP keyword switchflag 0 -fix snap all ave/time 1 1 1 c_snap[*] file compute.snap.gg1.dat mode vector - -thermo_style custom pe pxy c_bsum2[1] c_vbsum[55] v_db_2_25 c_snap[1][13] c_snap[13][13] c_snap[1][8] c_snap[12][12] c_snap[6][12] -thermo_modify norm no - -run ${nsteps} -run 0 -Neighbor list info ... - update every 1 steps, delay 10 steps, check yes - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 6.8 - ghost atom cutoff = 6.8 - binsize = 3.4, bins = 1 1 1 - 5 neighbor lists, perpetual/occasional/extra = 1 4 0 - (1) pair zbl, perpetual - attributes: half, newton on - pair build: half/bin/atomonly/newton - stencil: half/bin/3d/newton - bin: standard - (2) compute sna/atom, occasional - attributes: full, newton on - pair build: full/bin/atomonly - stencil: full/bin/3d - bin: standard - (3) compute snav/atom, occasional - attributes: full, newton on - pair build: full/bin/atomonly - stencil: full/bin/3d - bin: standard - (4) compute snad/atom, occasional - attributes: full, newton on - pair build: full/bin/atomonly - stencil: full/bin/3d - bin: standard - (5) compute mliap, occasional - attributes: full, newton on - pair build: full/bin/atomonly - stencil: full/bin/3d - bin: standard -Per MPI rank memory allocation (min/avg/max) = 10.75 | 10.75 | 10.75 Mbytes -PotEng Pxy c_bsum2[1] c_vbsum[55] v_db_2_25 c_snap[1][13] c_snap[13][13] c_snap[1][8] c_snap[12][12] c_snap[6][12] - 322.86952 1505558.1 364182.88 -240.25066 1381.7961 322.86952 1505558.1 364182.88 -240.25066 1381.7961 -Loop time of 1e-06 on 1 procs for 0 steps with 2 atoms - -200.0% CPU use with 1 MPI tasks x no OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 0 | 0 | 0 | 0.0 | 0.00 -Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0 | 0 | 0 | 0.0 | 0.00 -Output | 0 | 0 | 0 | 0.0 | 0.00 -Modify | 0 | 0 | 0 | 0.0 | 0.00 -Other | | 1e-06 | | |100.00 - -Nlocal: 2.00000 ave 2 max 2 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Nghost: 853.000 ave 853 max 853 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 330.000 ave 330 max 330 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -FullNghs: 660.000 ave 660 max 660 min -Histogram: 1 0 0 0 0 0 0 0 0 0 - -Total # of neighbors = 660 -Ave neighs/atom = 330.00000 -Neighbor list builds = 0 -Dangerous builds = 0 - -uncompute snap -unfix snap - -# run compute mliap with gradgradflag = 0 - -compute snap all mliap descriptor sna compute.mliap.descriptor model linear gradgradflag 0 -SNAP keyword rcutfac 1.0 -SNAP keyword twojmax 2 -SNAP keyword nelems 2 -SNAP keyword elems A -SNAP keyword radelems 2.3 -SNAP keyword welems 1.0 -SNAP keyword rfac0 0.99363 -SNAP keyword rmin0 0 -SNAP keyword bzeroflag 0 -SNAP keyword switchflag 0 -fix snap all ave/time 1 1 1 c_snap[*] file compute.snap.gg0.dat mode vector - -thermo_style custom pe pxy c_bsum2[1] c_vbsum[55] v_db_2_25 c_snap[1][13] c_snap[13][13] c_snap[1][8] c_snap[12][12] c_snap[6][12] -WARNING: New thermo_style command, previous thermo_modify settings will be lost (../output.cpp:691) -thermo_modify norm no - -run ${nsteps} -run 0 -Neighbor list info ... - update every 1 steps, delay 10 steps, check yes - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 6.8 - ghost atom cutoff = 6.8 - binsize = 3.4, bins = 1 1 1 - 5 neighbor lists, perpetual/occasional/extra = 1 4 0 - (1) pair zbl, perpetual - attributes: half, newton on - pair build: half/bin/atomonly/newton - stencil: half/bin/3d/newton - bin: standard - (2) compute sna/atom, occasional - attributes: full, newton on - pair build: full/bin/atomonly - stencil: full/bin/3d - bin: standard - (3) compute snav/atom, occasional - attributes: full, newton on - pair build: full/bin/atomonly - stencil: full/bin/3d - bin: standard - (4) compute snad/atom, occasional - attributes: full, newton on - pair build: full/bin/atomonly - stencil: full/bin/3d - bin: standard - (5) compute mliap, occasional - attributes: full, newton on - pair build: full/bin/atomonly - stencil: full/bin/3d - bin: standard -Per MPI rank memory allocation (min/avg/max) = 22.89 | 22.89 | 22.89 Mbytes -PotEng Pxy c_bsum2[1] c_vbsum[55] v_db_2_25 c_snap[1][13] c_snap[13][13] c_snap[1][8] c_snap[12][12] c_snap[6][12] - 322.86952 1505558.1 364182.88 -240.25066 1381.7961 322.86952 1505558.1 364182.88 -240.25066 1381.7961 -Loop time of 1e-06 on 1 procs for 0 steps with 2 atoms - -100.0% CPU use with 1 MPI tasks x no OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 0 | 0 | 0 | 0.0 | 0.00 -Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0 | 0 | 0 | 0.0 | 0.00 -Output | 0 | 0 | 0 | 0.0 | 0.00 -Modify | 0 | 0 | 0 | 0.0 | 0.00 -Other | | 1e-06 | | |100.00 - -Nlocal: 2.00000 ave 2 max 2 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Nghost: 853.000 ave 853 max 853 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 330.000 ave 330 max 330 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -FullNghs: 660.000 ave 660 max 660 min -Histogram: 1 0 0 0 0 0 0 0 0 0 - -Total # of neighbors = 660 -Ave neighs/atom = 330.00000 -Neighbor list builds = 0 -Dangerous builds = 0 -Total wall time: 0:00:00 diff --git a/examples/mliap/log.quadratic_compute_v2 b/examples/mliap/log.quadratic_compute_v2 deleted file mode 100644 index ed623ac105..0000000000 --- a/examples/mliap/log.quadratic_compute_v2 +++ /dev/null @@ -1,282 +0,0 @@ -LAMMPS (10 Feb 2021) -# Demonstrate MLIAP quadratic compute - -# initialize simulation - -variable nsteps index 0 -variable nrep equal 1 -variable a equal 2.0 -units metal - -# generate the box and atom positions using a BCC lattice - -variable nx equal ${nrep} -variable nx equal 1 -variable ny equal ${nrep} -variable ny equal 1 -variable nz equal ${nrep} -variable nz equal 1 - -boundary p p p - -atom_modify map hash -lattice bcc $a -lattice bcc 2 -Lattice spacing in x,y,z = 2.0000000 2.0000000 2.0000000 -region box block 0 ${nx} 0 ${ny} 0 ${nz} -region box block 0 1 0 ${ny} 0 ${nz} -region box block 0 1 0 1 0 ${nz} -region box block 0 1 0 1 0 1 -create_box 2 box -Created orthogonal box = (0.0000000 0.0000000 0.0000000) to (2.0000000 2.0000000 2.0000000) - 1 by 1 by 1 MPI processor grid -create_atoms 2 box -Created 2 atoms - create_atoms CPU = 0.001 seconds - -mass * 180.88 - -displace_atoms all random 0.1 0.1 0.1 123456 -Displacing atoms ... - -# set up reference potential - -variable zblcutinner equal 4 -variable zblcutouter equal 4.8 -variable zblz equal 73 -pair_style zbl ${zblcutinner} ${zblcutouter} -pair_style zbl 4 ${zblcutouter} -pair_style zbl 4 4.8 -pair_coeff * * ${zblz} ${zblz} -pair_coeff * * 73 ${zblz} -pair_coeff * * 73 73 - -# choose SNA parameters - -variable twojmax equal 2 -variable rcutfac equal 1.0 -variable rfac0 equal 0.99363 -variable rmin0 equal 0 -variable radelem1 equal 2.3 -variable radelem2 equal 2.0 -variable wj1 equal 1.0 -variable wj2 equal 0.96 -variable quadratic equal 1 -variable bzero equal 0 -variable switch equal 0 -variable snap_options string "${rcutfac} ${rfac0} ${twojmax} ${radelem1} ${radelem2} ${wj1} ${wj2} rmin0 ${rmin0} quadraticflag ${quadratic} bzeroflag ${bzero} switchflag ${switch}" -1 ${rfac0} ${twojmax} ${radelem1} ${radelem2} ${wj1} ${wj2} rmin0 ${rmin0} quadraticflag ${quadratic} bzeroflag ${bzero} switchflag ${switch} -1 0.99363 ${twojmax} ${radelem1} ${radelem2} ${wj1} ${wj2} rmin0 ${rmin0} quadraticflag ${quadratic} bzeroflag ${bzero} switchflag ${switch} -1 0.99363 2 ${radelem1} ${radelem2} ${wj1} ${wj2} rmin0 ${rmin0} quadraticflag ${quadratic} bzeroflag ${bzero} switchflag ${switch} -1 0.99363 2 2.3 ${radelem2} ${wj1} ${wj2} rmin0 ${rmin0} quadraticflag ${quadratic} bzeroflag ${bzero} switchflag ${switch} -1 0.99363 2 2.3 2 ${wj1} ${wj2} rmin0 ${rmin0} quadraticflag ${quadratic} bzeroflag ${bzero} switchflag ${switch} -1 0.99363 2 2.3 2 1 ${wj2} rmin0 ${rmin0} quadraticflag ${quadratic} bzeroflag ${bzero} switchflag ${switch} -1 0.99363 2 2.3 2 1 0.96 rmin0 ${rmin0} quadraticflag ${quadratic} bzeroflag ${bzero} switchflag ${switch} -1 0.99363 2 2.3 2 1 0.96 rmin0 0 quadraticflag ${quadratic} bzeroflag ${bzero} switchflag ${switch} -1 0.99363 2 2.3 2 1 0.96 rmin0 0 quadraticflag 1 bzeroflag ${bzero} switchflag ${switch} -1 0.99363 2 2.3 2 1 0.96 rmin0 0 quadraticflag 1 bzeroflag 0 switchflag ${switch} -1 0.99363 2 2.3 2 1 0.96 rmin0 0 quadraticflag 1 bzeroflag 0 switchflag 0 - -# set up per-atom computes - -compute b all sna/atom ${snap_options} -compute b all sna/atom 1 0.99363 2 2.3 2 1 0.96 rmin0 0 quadraticflag 1 bzeroflag 0 switchflag 0 -compute vb all snav/atom ${snap_options} -compute vb all snav/atom 1 0.99363 2 2.3 2 1 0.96 rmin0 0 quadraticflag 1 bzeroflag 0 switchflag 0 -compute db all snad/atom ${snap_options} -compute db all snad/atom 1 0.99363 2 2.3 2 1 0.96 rmin0 0 quadraticflag 1 bzeroflag 0 switchflag 0 - -# perform sums over atoms - -group snapgroup1 type 1 -0 atoms in group snapgroup1 -group snapgroup2 type 2 -2 atoms in group snapgroup2 -compute bsum1 snapgroup1 reduce sum c_b[*] -compute bsum2 snapgroup2 reduce sum c_b[*] -# fix bsum1 all ave/time 1 1 1 c_bsum1 file bsum1.dat mode vector -# fix bsum2 all ave/time 1 1 1 c_bsum2 file bsum2.dat mode vector -compute vbsum all reduce sum c_vb[*] -# fix vbsum all ave/time 1 1 1 c_vbsum file vbsum.dat mode vector -variable db_2_100 equal c_db[2][100] - -# test output: 1: total potential energy -# 2: xy component of stress tensor -# 3: Sum(0.5*(B_{222}^i)^2, all i of type 2) -# 4: xz component of Sum(Sum(r_j*(0.5*(dB_{222}^i)^2/dR[j]), all i of type 2), all j) -# 5: y component of -Sum(d(0.5*(B_{222}^i)^2/dR[2]), all i of type 2) -# -# followed by 5 counterparts from compute snap -thermo 100 - -# run compute mliap with gradgradflag = 1 - -compute snap all mliap descriptor sna compute.mliap.descriptor model quadratic gradgradflag 1 -SNAP keyword rcutfac 1.0 -SNAP keyword twojmax 2 -SNAP keyword nelems 2 -SNAP keyword elems A -SNAP keyword radelems 2.3 -SNAP keyword welems 1.0 -SNAP keyword rfac0 0.99363 -SNAP keyword rmin0 0 -SNAP keyword bzeroflag 0 -SNAP keyword switchflag 0 -fix snap all ave/time 1 1 1 c_snap[*] file compute.quadratic.gg1.dat mode vector - -thermo_style custom pe pxy c_bsum2[20] c_vbsum[220] v_db_2_100 c_snap[1][43] c_snap[13][43] c_snap[1][42] c_snap[12][42] c_snap[6][42] -thermo_modify norm no - -run ${nsteps} -run 0 -Neighbor list info ... - update every 1 steps, delay 10 steps, check yes - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 6.8 - ghost atom cutoff = 6.8 - binsize = 3.4, bins = 1 1 1 - 5 neighbor lists, perpetual/occasional/extra = 1 4 0 - (1) pair zbl, perpetual - attributes: half, newton on - pair build: half/bin/atomonly/newton - stencil: half/bin/3d/newton - bin: standard - (2) compute sna/atom, occasional - attributes: full, newton on - pair build: full/bin/atomonly - stencil: full/bin/3d - bin: standard - (3) compute snav/atom, occasional - attributes: full, newton on - pair build: full/bin/atomonly - stencil: full/bin/3d - bin: standard - (4) compute snad/atom, occasional - attributes: full, newton on - pair build: full/bin/atomonly - stencil: full/bin/3d - bin: standard - (5) compute mliap, occasional - attributes: full, newton on - pair build: full/bin/atomonly - stencil: full/bin/3d - bin: standard -Per MPI rank memory allocation (min/avg/max) = 22.47 | 22.47 | 22.47 Mbytes -PotEng Pxy c_bsum2[20] c_vbsum[220] v_db_2_100 c_snap[1][43] c_snap[13][43] c_snap[1][42] c_snap[12][42] c_snap[6][42] - 322.86952 1505558.1 4.2492771e+08 -4952473 28484035 322.86952 1505558.1 4.2492771e+08 -4952473 28484035 -Loop time of 1e-06 on 1 procs for 0 steps with 2 atoms - -200.0% CPU use with 1 MPI tasks x no OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 0 | 0 | 0 | 0.0 | 0.00 -Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0 | 0 | 0 | 0.0 | 0.00 -Output | 0 | 0 | 0 | 0.0 | 0.00 -Modify | 0 | 0 | 0 | 0.0 | 0.00 -Other | | 1e-06 | | |100.00 - -Nlocal: 2.00000 ave 2 max 2 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Nghost: 853.000 ave 853 max 853 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 330.000 ave 330 max 330 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -FullNghs: 660.000 ave 660 max 660 min -Histogram: 1 0 0 0 0 0 0 0 0 0 - -Total # of neighbors = 660 -Ave neighs/atom = 330.00000 -Neighbor list builds = 0 -Dangerous builds = 0 - -uncompute snap -unfix snap - -# run compute mliap with gradgradflag = 0 - -compute snap all mliap descriptor sna compute.mliap.descriptor model quadratic gradgradflag 0 -SNAP keyword rcutfac 1.0 -SNAP keyword twojmax 2 -SNAP keyword nelems 2 -SNAP keyword elems A -SNAP keyword radelems 2.3 -SNAP keyword welems 1.0 -SNAP keyword rfac0 0.99363 -SNAP keyword rmin0 0 -SNAP keyword bzeroflag 0 -SNAP keyword switchflag 0 -fix snap all ave/time 1 1 1 c_snap[*] file compute.quadratic.gg0.dat mode vector - -thermo_style custom pe pxy c_bsum2[20] c_vbsum[220] v_db_2_100 c_snap[1][43] c_snap[13][43] c_snap[1][42] c_snap[12][42] c_snap[6][42] -WARNING: New thermo_style command, previous thermo_modify settings will be lost (../output.cpp:691) -thermo_modify norm no - -run ${nsteps} -run 0 -Neighbor list info ... - update every 1 steps, delay 10 steps, check yes - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 6.8 - ghost atom cutoff = 6.8 - binsize = 3.4, bins = 1 1 1 - 5 neighbor lists, perpetual/occasional/extra = 1 4 0 - (1) pair zbl, perpetual - attributes: half, newton on - pair build: half/bin/atomonly/newton - stencil: half/bin/3d/newton - bin: standard - (2) compute sna/atom, occasional - attributes: full, newton on - pair build: full/bin/atomonly - stencil: full/bin/3d - bin: standard - (3) compute snav/atom, occasional - attributes: full, newton on - pair build: full/bin/atomonly - stencil: full/bin/3d - bin: standard - (4) compute snad/atom, occasional - attributes: full, newton on - pair build: full/bin/atomonly - stencil: full/bin/3d - bin: standard - (5) compute mliap, occasional - attributes: full, newton on - pair build: full/bin/atomonly - stencil: full/bin/3d - bin: standard -Per MPI rank memory allocation (min/avg/max) = 70.24 | 70.24 | 70.24 Mbytes -PotEng Pxy c_bsum2[20] c_vbsum[220] v_db_2_100 c_snap[1][43] c_snap[13][43] c_snap[1][42] c_snap[12][42] c_snap[6][42] - 322.86952 1505558.1 4.2492771e+08 -4952473 28484035 322.86952 1505558.1 4.2492771e+08 -4952473 28484035 -Loop time of 1e-06 on 1 procs for 0 steps with 2 atoms - -100.0% CPU use with 1 MPI tasks x no OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 0 | 0 | 0 | 0.0 | 0.00 -Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0 | 0 | 0 | 0.0 | 0.00 -Output | 0 | 0 | 0 | 0.0 | 0.00 -Modify | 0 | 0 | 0 | 0.0 | 0.00 -Other | | 1e-06 | | |100.00 - -Nlocal: 2.00000 ave 2 max 2 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Nghost: 853.000 ave 853 max 853 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 330.000 ave 330 max 330 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -FullNghs: 660.000 ave 660 max 660 min -Histogram: 1 0 0 0 0 0 0 0 0 0 - -Total # of neighbors = 660 -Ave neighs/atom = 330.00000 -Neighbor list builds = 0 -Dangerous builds = 0 - -Total wall time: 0:00:00 diff --git a/examples/mliap/log.quadratic_v2 b/examples/mliap/log.quadratic_v2 deleted file mode 100644 index 3f7880abe4..0000000000 --- a/examples/mliap/log.quadratic_v2 +++ /dev/null @@ -1,158 +0,0 @@ -LAMMPS (10 Feb 2021) - -# Demonstrate MLIAP interface to quadratic SNAP potential - -# Initialize simulation - -variable nsteps index 100 -variable nrep equal 4 -variable a equal 3.1803 -units metal - -# generate the box and atom positions using a BCC lattice - -variable nx equal ${nrep} -variable nx equal 4 -variable ny equal ${nrep} -variable ny equal 4 -variable nz equal ${nrep} -variable nz equal 4 - -boundary p p p - -lattice bcc $a -lattice bcc 3.1803 -Lattice spacing in x,y,z = 3.1803000 3.1803000 3.1803000 -region box block 0 ${nx} 0 ${ny} 0 ${nz} -region box block 0 4 0 ${ny} 0 ${nz} -region box block 0 4 0 4 0 ${nz} -region box block 0 4 0 4 0 4 -create_box 1 box -Created orthogonal box = (0.0000000 0.0000000 0.0000000) to (12.721200 12.721200 12.721200) - 1 by 1 by 1 MPI processor grid -create_atoms 1 box -Created 128 atoms - create_atoms CPU = 0.000 seconds -displace_atoms all random 0.01 0.01 0.01 12345 -Displacing atoms ... - -mass 1 183.84 - -# choose potential - -include W.quadratic.mliap -# DATE: 2020-06-21 UNITS: metal CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: none - -# Definition of SNAP+ZBL potential. -variable zblcutinner equal 4 -variable zblcutouter equal 4.8 -variable zblz equal 74 - -# Specify hybrid with SNAP and ZBL - -pair_style hybrid/overlay zbl ${zblcutinner} ${zblcutouter} mliap model quadratic W.quadratic.mliap.model descriptor sna W.quadratic.mliap.descriptor -pair_style hybrid/overlay zbl 4 ${zblcutouter} mliap model quadratic W.quadratic.mliap.model descriptor sna W.quadratic.mliap.descriptor -pair_style hybrid/overlay zbl 4 4.8 mliap model quadratic W.quadratic.mliap.model descriptor sna W.quadratic.mliap.descriptor -Reading potential file W.quadratic.mliap.model with DATE: 2020-06-21 -Reading potential file W.quadratic.mliap.model with DATE: 2020-06-21 -Reading potential file W.quadratic.mliap.descriptor with DATE: 2020-06-21 -SNAP keyword rcutfac 4.73442 -SNAP keyword twojmax 6 -SNAP keyword nelems 1 -SNAP keyword elems W -SNAP keyword radelems 0.5 -SNAP keyword welems 1 -SNAP keyword rfac0 0.99363 -SNAP keyword rmin0 0 -SNAP keyword bzeroflag 1 -pair_coeff 1 1 zbl ${zblz} ${zblz} -pair_coeff 1 1 zbl 74 ${zblz} -pair_coeff 1 1 zbl 74 74 -pair_coeff * * mliap W - - -# Setup output - -compute eatom all pe/atom -compute energy all reduce sum c_eatom - -compute satom all stress/atom NULL -compute str all reduce sum c_satom[1] c_satom[2] c_satom[3] -variable press equal (c_str[1]+c_str[2]+c_str[3])/(3*vol) - -thermo_style custom step temp epair c_energy etotal press v_press -thermo 10 -thermo_modify norm yes - -# Set up NVE run - -timestep 0.5e-3 -neighbor 1.0 bin -neigh_modify once no every 1 delay 0 check no - -# Run MD - -velocity all create 300.0 4928459 loop geom -fix 1 all nve -run ${nsteps} -run 100 -Neighbor list info ... - update every 1 steps, delay 0 steps, check no - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 5.8 - ghost atom cutoff = 5.8 - binsize = 2.9, bins = 5 5 5 - 2 neighbor lists, perpetual/occasional/extra = 2 0 0 - (1) pair zbl, perpetual, half/full from (2) - attributes: half, newton on - pair build: halffull/newton - stencil: none - bin: none - (2) pair mliap, perpetual - attributes: full, newton on - pair build: full/bin/atomonly - stencil: full/bin/3d - bin: standard -Per MPI rank memory allocation (min/avg/max) = 192.1 | 192.1 | 192.1 Mbytes -Step Temp E_pair c_energy TotEng Press v_press - 0 300 -1.1602728 -1.1602728 -1.1217977 600047.3 -600047.3 - 10 288.46387 -1.1587932 -1.1587932 -1.1217976 600359.75 -600359.75 - 20 268.69718 -1.1562579 -1.1562579 -1.1217974 600870.22 -600870.22 - 30 243.19855 -1.1529874 -1.1529874 -1.1217971 601511.5 -601511.5 - 40 215.13122 -1.1493875 -1.1493875 -1.1217969 602202.36 -602202.36 - 50 187.82673 -1.1458855 -1.1458855 -1.1217966 602860.26 -602860.26 - 60 164.26822 -1.1428639 -1.1428639 -1.1217965 603413.25 -603413.25 - 70 146.65179 -1.1406045 -1.1406045 -1.1217964 603809.35 -603809.35 - 80 136.10769 -1.1392522 -1.1392522 -1.1217964 604022.32 -604022.32 - 90 132.62756 -1.138806 -1.138806 -1.1217964 604053.33 -604053.33 - 100 135.19841 -1.1391358 -1.1391358 -1.1217966 603928.48 -603928.48 -Loop time of 2.19167 on 1 procs for 100 steps with 128 atoms - -Performance: 1.971 ns/day, 12.176 hours/ns, 45.627 timesteps/s -99.2% CPU use with 1 MPI tasks x no OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 2.1547 | 2.1547 | 2.1547 | 0.0 | 98.32 -Neigh | 0.033584 | 0.033584 | 0.033584 | 0.0 | 1.53 -Comm | 0.001943 | 0.001943 | 0.001943 | 0.0 | 0.09 -Output | 0.000658 | 0.000658 | 0.000658 | 0.0 | 0.03 -Modify | 0.000365 | 0.000365 | 0.000365 | 0.0 | 0.02 -Other | | 0.000379 | | | 0.02 - -Nlocal: 128.000 ave 128 max 128 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Nghost: 727.000 ave 727 max 727 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 3712.00 ave 3712 max 3712 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -FullNghs: 7424.00 ave 7424 max 7424 min -Histogram: 1 0 0 0 0 0 0 0 0 0 - -Total # of neighbors = 7424 -Ave neighs/atom = 58.000000 -Neighbor list builds = 100 -Dangerous builds not checked - -Total wall time: 0:00:02 From cfcf30975d7bdc7da412b280784be9fc384dfafc Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 5 Mar 2021 22:14:21 -0500 Subject: [PATCH 24/30] move .pyx file back where it belongs --- src/{ => PYTHON}/mliap_model_python_couple.pyx | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/{ => PYTHON}/mliap_model_python_couple.pyx (100%) diff --git a/src/mliap_model_python_couple.pyx b/src/PYTHON/mliap_model_python_couple.pyx similarity index 100% rename from src/mliap_model_python_couple.pyx rename to src/PYTHON/mliap_model_python_couple.pyx From ed5b573286b2645f2161aa46d138f2b544800de9 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 5 Mar 2021 22:14:46 -0500 Subject: [PATCH 25/30] whitespace fixes --- doc/src/pair_mliap.rst | 6 +- src/MLIAP/README.md | 8 +-- src/MLIAP/mliap_model_nn.cpp | 108 +++++++++++++++++------------------ 3 files changed, 61 insertions(+), 61 deletions(-) diff --git a/doc/src/pair_mliap.rst b/doc/src/pair_mliap.rst index 4c22c0ee9a..c40b911087 100644 --- a/doc/src/pair_mliap.rst +++ b/doc/src/pair_mliap.rst @@ -85,7 +85,7 @@ for the :doc:`pair_style snap ` coefficient file. Specifically, the line containing the element weight and radius is omitted, since these are handled by the *descriptor*. -When the *model* keyword is *nn* (neural networks), the model file can contain +When the *model* keyword is *nn* (neural networks), the model file can contain blank and comment lines (start with #) anywhere. The second non-blank non-comment line must contain the string NET, followed by two integers: @@ -99,9 +99,9 @@ and followed by a sequence of a string and an integer for each layer: This is followed by one block for each of the *nelem* elements. Each block consists of *scale0* minimum value, *scale1* (maximum - minimum) value, -in order to normalize the descriptors, followed by *nparams* parameters, +in order to normalize the descriptors, followed by *nparams* parameters, including *bias* and *weights* of the model, starting with the first node of the first layer -and so on, with a maximum of 30 values per line. +and so on, with a maximum of 30 values per line. Notes on mliappy models: When the *model* keyword is *mliappy*, the filename should end in '.pt', diff --git a/src/MLIAP/README.md b/src/MLIAP/README.md index 92b3e26b83..c311168263 100644 --- a/src/MLIAP/README.md +++ b/src/MLIAP/README.md @@ -1,4 +1,4 @@ -This package provides a general interface to families of machine-learning interatomic potentials (MLIAPs). +This package provides a general interface to families of machine-learning interatomic potentials (MLIAPs). This interface consists of a `mliap pair style` and a `mliap compute`. The `mliap pair style` is used when running simulations with energies and forces calculated by an MLIAP. The interface allows separate @@ -7,10 +7,10 @@ and the geometric quantities that characterize the atomic positions (`descriptor`). By defining `model` and `descriptor` separately, it is possible to use many different models with a given descriptor, or many different descriptors with a given model. The pair_style -supports the following models: +supports the following models: -- `linear`, -- `quadratic`, +- `linear`, +- `quadratic`, - `nn` (neural networks) - `mliappy` (general Python interface to things like PyTorch). diff --git a/src/MLIAP/mliap_model_nn.cpp b/src/MLIAP/mliap_model_nn.cpp index cd533e8599..0fa7f7168b 100644 --- a/src/MLIAP/mliap_model_nn.cpp +++ b/src/MLIAP/mliap_model_nn.cpp @@ -66,7 +66,7 @@ int MLIAPModelNN::get_nparams() void MLIAPModelNN::read_coeffs(char *coefffilename) { - + // open coefficient file on proc 0 FILE *fpcoeff; @@ -122,7 +122,7 @@ void MLIAPModelNN::read_coeffs(char *coefffilename) int stats = 0; int ielem = 0; int l = 0; - + while (1) { if (comm->me == 0) { ptr = fgets(line,MAXLINE,fpcoeff); @@ -136,20 +136,20 @@ void MLIAPModelNN::read_coeffs(char *coefffilename) if (eof) break; MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); - + // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; nwords = utils::trim_and_count_words(line); if (nwords == 0) continue; - + if (stats == 0) { // Header NET tstr = strtok(line,"' \t\n\r\f"); if (strncmp(tstr, "NET", 3) != 0) error->all(FLERR,"Incorrect format in MLIAPModel coefficient file"); - + ndescriptors = atoi(strtok(nullptr,"' \t\n\r\f")); nlayers = atoi(strtok(nullptr,"' \t\n\r\f")); - + memory->create(activation,nlayers,"mliap_model:activation"); memory->create(nnodes,nlayers,"mliap_model:nnodes"); memory->create(scale,nelements,2,ndescriptors,"mliap_model:scale"); @@ -164,9 +164,9 @@ void MLIAPModelNN::read_coeffs(char *coefffilename) else if (strncmp(tstr, "relu", 4) == 0) activation[ilayer] = 3; else activation[ilayer] = 4; } - + stats = 1; - + } else if (stats == 1) { scale[ielem][0][l] = atof(strtok(line,"' \t\n\r\f")); for (int icoeff = 1; icoeff < nwords; icoeff++) { @@ -177,7 +177,7 @@ void MLIAPModelNN::read_coeffs(char *coefffilename) stats = 2; l = 0; } - + } else if (stats == 2) { scale[ielem][1][l] = atof(strtok(line,"' \t\n\r\f")); for (int icoeff = 1; icoeff < nwords; icoeff++) { @@ -188,12 +188,12 @@ void MLIAPModelNN::read_coeffs(char *coefffilename) stats = 3; l = 0; } - + // set up coeff lists - + } else if (stats == 3) { if (nwords > 30) error->all(FLERR,"Incorrect format in MLIAPModel coefficient file"); - + coeffelem[ielem][l] = atof(strtok(line,"' \t\n\r\f")); for (int icoeff = 1; icoeff < nwords; icoeff++) { coeffelem[ielem][l+icoeff] = atof(strtok(nullptr,"' \t\n\r\f")); @@ -220,11 +220,11 @@ void MLIAPModelNN::compute_gradients(MLIAPData* data) for (int ii = 0; ii < data->natoms; ii++) { const int ielem = data->ielems[ii]; const int nl = nlayers; - + double* coeffi = coeffelem[ielem]; double** scalei = scale[ielem]; double **nodes, **dnodes, **bnodes; - + nodes = new double*[nl]; dnodes = new double*[nl]; bnodes = new double*[nl]; @@ -233,31 +233,31 @@ void MLIAPModelNN::compute_gradients(MLIAPData* data) dnodes[l] = new double[nnodes[l]]; bnodes[l] = new double[nnodes[l]]; } - + // forwardprop // input - hidden1 for (int n=0; n < nnodes[0]; n++) { nodes[0][n] = 0; for (int icoeff = 0; icoeff < data->ndescriptors; icoeff++) { - nodes[0][n] += coeffi[n*((data->ndescriptors)+1)+icoeff+1] * - (data->descriptors[ii][icoeff] - scalei[0][icoeff]) / - scalei[1][icoeff]; + nodes[0][n] += coeffi[n*((data->ndescriptors)+1)+icoeff+1] * + (data->descriptors[ii][icoeff] - scalei[0][icoeff]) / + scalei[1][icoeff]; } if (activation[0] == 1) { - nodes[0][n] = sigm(nodes[0][n] + - coeffi[n*((data->ndescriptors)+1)], - dnodes[0][n]); + nodes[0][n] = sigm(nodes[0][n] + + coeffi[n*((data->ndescriptors)+1)], + dnodes[0][n]); } else if (activation[0] == 2) { - nodes[0][n] = tanh(nodes[0][n] + - coeffi[n*((data->ndescriptors)+1)], - dnodes[0][n]); + nodes[0][n] = tanh(nodes[0][n] + + coeffi[n*((data->ndescriptors)+1)], + dnodes[0][n]); } else if (activation[0] == 3) { - nodes[0][n] = relu(nodes[0][n] + - coeffi[n*((data->ndescriptors)+1)], - dnodes[0][n]); + nodes[0][n] = relu(nodes[0][n] + + coeffi[n*((data->ndescriptors)+1)], + dnodes[0][n]); } else { nodes[0][n] += coeffi[n*((data->ndescriptors)+1)]; @@ -274,36 +274,36 @@ void MLIAPModelNN::compute_gradients(MLIAPData* data) for (int n=0; n < nnodes[l]; n++) { nodes[l][n] = 0; for (int j=0; j < nnodes[l-1]; j++) { - nodes[l][n] += coeffi[k+n*(nnodes[l-1]+1)+j+1] * - nodes[l-1][j]; + nodes[l][n] += coeffi[k+n*(nnodes[l-1]+1)+j+1] * + nodes[l-1][j]; } if (activation[l] == 1) { - nodes[l][n] = sigm(nodes[l][n] + - coeffi[k+n*(nnodes[l-1]+1)], - dnodes[l][n]); + nodes[l][n] = sigm(nodes[l][n] + + coeffi[k+n*(nnodes[l-1]+1)], + dnodes[l][n]); } else if (activation[l] == 2) { - nodes[l][n] = tanh(nodes[l][n] + - coeffi[k+n*(nnodes[l-1]+1)], - dnodes[l][n]); + nodes[l][n] = tanh(nodes[l][n] + + coeffi[k+n*(nnodes[l-1]+1)], + dnodes[l][n]); } else if (activation[l] == 3) { - nodes[l][n] = relu(nodes[l][n] + - coeffi[k+n*(nnodes[l-1]+1)], - dnodes[l][n]); + nodes[l][n] = relu(nodes[l][n] + + coeffi[k+n*(nnodes[l-1]+1)], + dnodes[l][n]); } else { nodes[l][n] += coeffi[k+n*(nnodes[l-1]+1)]; dnodes[l][n] = 1; } } - k += (nnodes[l-1]+1)*nnodes[l]; + k += (nnodes[l-1]+1)*nnodes[l]; } } // backwardprop // output layer dnode initialized to 1. - + for (int n=0; n= 1) { bnodes[l-1][n] *= dnodes[l-1][n]; @@ -328,38 +328,38 @@ void MLIAPModelNN::compute_gradients(MLIAPData* data) } } } - + for (int icoeff = 0; icoeff < data->ndescriptors; icoeff++) { data->betas[ii][icoeff] = 0; for (int j=0; jbetas[ii][icoeff] += - coeffi[j*((data->ndescriptors)+1)+icoeff+1] * - bnodes[0][j]; + data->betas[ii][icoeff] += + coeffi[j*((data->ndescriptors)+1)+icoeff+1] * + bnodes[0][j]; } - data->betas[ii][icoeff] = data->betas[ii][icoeff]/scalei[1][icoeff]; + data->betas[ii][icoeff] = data->betas[ii][icoeff]/scalei[1][icoeff]; } - + if (data->eflag) { // energy of atom I (E_i) - + double etmp = nodes[nl-1][0]; - + data->energy += etmp; data->eatoms[ii] = etmp; } // Deleting the variables - + for (int n=0; n Date: Fri, 5 Mar 2021 23:14:57 -0500 Subject: [PATCH 26/30] add check when system becomes too large for MLIAP package --- src/MLIAP/mliap_data.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/MLIAP/mliap_data.cpp b/src/MLIAP/mliap_data.cpp index 55b9e02bc9..0a6683d733 100644 --- a/src/MLIAP/mliap_data.cpp +++ b/src/MLIAP/mliap_data.cpp @@ -50,6 +50,9 @@ MLIAPData::MLIAPData(LAMMPS *lmp, int gradgradflag_in, int *map_in, ndims_virial = 6; yoffset = nparams*nelements; zoffset = 2*yoffset; + // must check before storing bigint into regular int + if (atom->natoms > MAXSMALLINT) + error->all(FLERR,"Too many atoms for MLIAP package"); natoms_array = atom->natoms; size_array_rows = 1+ndims_force*natoms_array+ndims_virial; size_array_cols = nparams*nelements+1; From 42035ef99fc156372281a13334b1775708278eaa Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sat, 6 Mar 2021 00:28:12 -0500 Subject: [PATCH 27/30] forgot to include header for Error class --- src/MLIAP/mliap_data.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/MLIAP/mliap_data.cpp b/src/MLIAP/mliap_data.cpp index 0a6683d733..6afcc1e81c 100644 --- a/src/MLIAP/mliap_data.cpp +++ b/src/MLIAP/mliap_data.cpp @@ -18,6 +18,7 @@ #include "mliap_data.h" #include "atom.h" +#include "error.h" #include "memory.h" #include "mliap_descriptor.h" #include "mliap_model.h" From f1e01274b1670f44e9dcfccaa79f823a5f907043 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 8 Mar 2021 12:15:21 -0500 Subject: [PATCH 28/30] fix pyx file location --- src/MLIAP/mliap_model_python_couple.pyx | 0 src/PYTHON/mliap_model_python_couple.pyx | 120 ----------------------- 2 files changed, 120 deletions(-) mode change 100755 => 100644 src/MLIAP/mliap_model_python_couple.pyx delete mode 100644 src/PYTHON/mliap_model_python_couple.pyx diff --git a/src/MLIAP/mliap_model_python_couple.pyx b/src/MLIAP/mliap_model_python_couple.pyx old mode 100755 new mode 100644 diff --git a/src/PYTHON/mliap_model_python_couple.pyx b/src/PYTHON/mliap_model_python_couple.pyx deleted file mode 100644 index 1f04964ef6..0000000000 --- a/src/PYTHON/mliap_model_python_couple.pyx +++ /dev/null @@ -1,120 +0,0 @@ -# cython: language_level=3 -# distutils: language = c++ - -cimport cython - -import pickle - -# For converting C arrays to numpy arrays -import numpy as np - -# For converting void * to integer for tracking object identity -from libc.stdint cimport uintptr_t - -from libcpp.string cimport string - - -cdef extern from "mliap_data.h" namespace "LAMMPS_NS": - cdef cppclass MLIAPData: - # Array shapes - int natoms - int ndescriptors - - # Input data - int * ielems # types for all atoms in list - double ** descriptors # descriptors for all atoms in list - - # Output data to write to - double ** betas # betas for all atoms in list - double * eatoms # energy for all atoms in list - double energy - -cdef extern from "mliap_model_python.h" namespace "LAMMPS_NS": - cdef cppclass MLIAPModelPython: - void connect_param_counts() - - -class MLIAPPYModelNotLinked(Exception): pass - - -LOADED_MODELS = {} - -cdef object c_id(MLIAPModelPython * c_model): - """ - Use python-style id of object to keep track of identity. - Note, this is probably not a perfect general strategy but it should work fine with LAMMPS pair styles. - """ - return int( c_model) - -cdef object retrieve(MLIAPModelPython * c_model) with gil: - try: - model = LOADED_MODELS[c_id(c_model)] - except KeyError as ke: - raise KeyError("Model has not been loaded.") from ke - if model is None: - raise MLIAPPYModelNotLinked("Model not linked, connect the model from the python side.") - return model - -cdef public int MLIAPPY_load_model(MLIAPModelPython * c_model, char* fname) with gil: - str_fname = fname.decode('utf-8') # Python 3 only; not Python 2 not supported. - if str_fname == "LATER": - model = None - returnval = 0 - else: - if str_fname.endswith(".pt") or str_fname.endswith('.pth'): - import torch - model = torch.load(str_fname) - else: - with open(str_fname,'rb') as pfile: - model = pickle.load(pfile) - returnval = 1 - LOADED_MODELS[c_id(c_model)] = model - return returnval - -def load_from_python(model): - unloaded_models = [k for k, v in LOADED_MODELS.items() if v is None] - num_models = len(unloaded_models) - cdef MLIAPModelPython * lmp_model - - if num_models == 0: - raise ValueError("No model in the waiting area.") - elif num_models > 1: - raise ValueError("Model is amibguous, more than one model in waiting area.") - else: - c_id = unloaded_models[0] - LOADED_MODELS[c_id]=model - lmp_model = c_id - lmp_model.connect_param_counts() - - -cdef public void MLIAPPY_unload_model(MLIAPModelPython * c_model) with gil: - del LOADED_MODELS[c_id(c_model)] - -cdef public int MLIAPPY_nparams(MLIAPModelPython * c_model) with gil: - return int(retrieve(c_model).n_params) - -cdef public int MLIAPPY_nelements(MLIAPModelPython * c_model) with gil: - return int(retrieve(c_model).n_elements) - -cdef public int MLIAPPY_ndescriptors(MLIAPModelPython * c_model) with gil: - return int(retrieve(c_model).n_descriptors) - -cdef public void MLIAPPY_compute_gradients(MLIAPModelPython * c_model, MLIAPData * data) with gil: - model = retrieve(c_model) - - n_d = data.ndescriptors - n_a = data.natoms - - # Make numpy arrays from pointers - beta_np = np.asarray( &data.betas[0][0]) - desc_np = np.asarray( &data.descriptors[0][0]) - elem_np = np.asarray( &data.ielems[0]) - en_np = np.asarray( &data.eatoms[0]) - - # Invoke python model on numpy arrays. - model(elem_np,desc_np,beta_np,en_np) - - # Get the total energy from the atom energy. - energy = np.sum(en_np) - data.energy = energy - return From 025b18999a946d652287c4b444cb06552246b7d1 Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Mon, 8 Mar 2021 13:31:24 -0700 Subject: [PATCH 29/30] Cleaned up the MLIAPData variable names --- src/MLIAP/compute_mliap.cpp | 8 ++-- src/MLIAP/mliap_data.cpp | 62 ++++++++++++------------- src/MLIAP/mliap_data.h | 7 +-- src/MLIAP/mliap_descriptor_snap.cpp | 8 ++-- src/MLIAP/mliap_model_linear.cpp | 6 +-- src/MLIAP/mliap_model_nn.cpp | 2 +- src/MLIAP/mliap_model_python_couple.pyx | 4 +- src/MLIAP/mliap_model_quadratic.cpp | 6 +-- src/MLIAP/pair_mliap.cpp | 2 +- 9 files changed, 52 insertions(+), 53 deletions(-) diff --git a/src/MLIAP/compute_mliap.cpp b/src/MLIAP/compute_mliap.cpp index f119a64a49..ce271c4480 100644 --- a/src/MLIAP/compute_mliap.cpp +++ b/src/MLIAP/compute_mliap.cpp @@ -215,7 +215,7 @@ void ComputeMLIAP::init_list(int /*id*/, NeighList *ptr) void ComputeMLIAP::compute_array() { - int ntotal = atom->nlocal + atom->nghost; + int nall = atom->nlocal + atom->nghost; invoked_array = update->ntimestep; // clear global array @@ -261,7 +261,7 @@ void ComputeMLIAP::compute_array() for (int ielem = 0; ielem < data->nelements; ielem++) { const int elemoffset = data->nparams*ielem; for (int jparam = 0; jparam < data->nparams; jparam++) { - for (int i = 0; i < ntotal; i++) { + for (int i = 0; i < nall; i++) { double *gradforcei = data->gradforce[i]+elemoffset; tagint irow = 3*(atom->tag[i]-1)+1; mliaparray[irow][jparam+elemoffset] += gradforcei[jparam]; @@ -307,7 +307,7 @@ void ComputeMLIAP::compute_array() // switch to Voigt notation c_virial->compute_vector(); - irow += 3*data->natoms_array; + irow += 3*data->natoms; mliaparrayall[irow++][lastcol] = c_virial->vector[0]; mliaparrayall[irow++][lastcol] = c_virial->vector[1]; mliaparrayall[irow++][lastcol] = c_virial->vector[2]; @@ -325,7 +325,7 @@ void ComputeMLIAP::compute_array() void ComputeMLIAP::dbdotr_compute() { double **x = atom->x; - int irow0 = 1+data->ndims_force*data->natoms_array; + int irow0 = 1+data->ndims_force*data->natoms; // sum over bispectrum contributions to forces // on all particles including ghosts diff --git a/src/MLIAP/mliap_data.cpp b/src/MLIAP/mliap_data.cpp index 6afcc1e81c..d0ea51d1b1 100644 --- a/src/MLIAP/mliap_data.cpp +++ b/src/MLIAP/mliap_data.cpp @@ -54,12 +54,12 @@ MLIAPData::MLIAPData(LAMMPS *lmp, int gradgradflag_in, int *map_in, // must check before storing bigint into regular int if (atom->natoms > MAXSMALLINT) error->all(FLERR,"Too many atoms for MLIAP package"); - natoms_array = atom->natoms; - size_array_rows = 1+ndims_force*natoms_array+ndims_virial; + natoms = atom->natoms; + size_array_rows = 1+ndims_force*natoms+ndims_virial; size_array_cols = nparams*nelements+1; size_gradforce = ndims_force*nparams*nelements; - natoms_max = 0; + nlistatoms_max = 0; natomneigh_max = 0; nneigh_max = 0; nmax = 0; @@ -120,38 +120,37 @@ void MLIAPData::generate_neighdata(NeighList* list_in, int eflag_in, int vflag_i // clear gradforce array - int ntotal = atom->nlocal + atom->nghost; - for (int i = 0; i < ntotal; i++) + int nall = atom->nlocal + atom->nghost; + for (int i = 0; i < nall; i++) for (int j = 0; j < size_gradforce; j++) { gradforce[i][j] = 0.0; } + // grow arrays if necessary + + nlistatoms = list->inum; + if (nlistatoms_max < nlistatoms) { + memory->grow(betas,nlistatoms,ndescriptors,"MLIAPData:betas"); + memory->grow(descriptors,nlistatoms,ndescriptors,"MLIAPData:descriptors"); + memory->grow(eatoms,nlistatoms,"MLIAPData:eatoms"); + nlistatoms_max = nlistatoms; + } + // grow gamma arrays if necessary if (gradgradflag == 1) { - const int natomgamma = list->inum; - if (natomgamma_max < natomgamma) { - memory->grow(gamma_row_index,natomgamma,gamma_nnz,"MLIAPData:gamma_row_index"); - memory->grow(gamma_col_index,natomgamma,gamma_nnz,"MLIAPData:gamma_col_index"); - memory->grow(gamma,natomgamma,gamma_nnz,"MLIAPData:gamma"); - natomgamma_max = natomgamma; + if (natomgamma_max < nlistatoms) { + memory->grow(gamma_row_index,nlistatoms,gamma_nnz,"MLIAPData:gamma_row_index"); + memory->grow(gamma_col_index,nlistatoms,gamma_nnz,"MLIAPData:gamma_col_index"); + memory->grow(gamma,nlistatoms,gamma_nnz,"MLIAPData:gamma"); + natomgamma_max = nlistatoms; } } - // grow arrays if necessary - - natoms = list->inum; - if (natoms_max < natoms) { - memory->grow(betas,natoms,ndescriptors,"MLIAPData:betas"); - memory->grow(descriptors,natoms,ndescriptors,"MLIAPData:descriptors"); - memory->grow(eatoms,natoms,"MLIAPData:eatoms"); - natoms_max = natoms; - } - grow_neigharrays(); int ij = 0; - for (int ii = 0; ii < natoms; ii++) { + for (int ii = 0; ii < nlistatoms; ii++) { const int i = ilist[ii]; const double xtmp = x[i][0]; @@ -202,12 +201,11 @@ void MLIAPData::grow_neigharrays() // grow neighbor atom arrays if necessary - const int natomneigh = list->inum; - if (natomneigh_max < natomneigh) { - memory->grow(iatoms,natomneigh,"MLIAPData:iatoms"); - memory->grow(ielems,natomneigh,"MLIAPData:ielems"); - memory->grow(numneighs,natomneigh,"MLIAPData:numneighs"); - natomneigh_max = natomneigh; + if (natomneigh_max < nlistatoms) { + memory->grow(iatoms,nlistatoms,"MLIAPData:iatoms"); + memory->grow(ielems,nlistatoms,"MLIAPData:ielems"); + memory->grow(numneighs,nlistatoms,"MLIAPData:numneighs"); + natomneigh_max = nlistatoms; } // grow neighbor arrays if necessary @@ -219,7 +217,7 @@ void MLIAPData::grow_neigharrays() int *type = atom->type; int nneigh = 0; - for (int ii = 0; ii < natomneigh; ii++) { + for (int ii = 0; ii < nlistatoms; ii++) { const int i = ilist[ii]; const double xtmp = x[i][0]; @@ -272,9 +270,9 @@ double MLIAPData::memory_usage() gamma_nnz*sizeof(double); // gamma } - bytes += (double)natoms*ndescriptors*sizeof(int); // betas - bytes += (double)natoms*ndescriptors*sizeof(int); // descriptors - bytes += (double)natoms*sizeof(double); // eatoms + bytes += (double)nlistatoms*ndescriptors*sizeof(int); // betas + bytes += (double)nlistatoms*ndescriptors*sizeof(int); // descriptors + bytes += (double)nlistatoms*sizeof(double); // eatoms bytes += (double)natomneigh_max*sizeof(int); // iatoms bytes += (double)natomneigh_max*sizeof(int); // ielems diff --git a/src/MLIAP/mliap_data.h b/src/MLIAP/mliap_data.h index 7fb60bd723..a9ada7ebd7 100644 --- a/src/MLIAP/mliap_data.h +++ b/src/MLIAP/mliap_data.h @@ -30,7 +30,8 @@ class MLIAPData : protected Pointers { double memory_usage(); int size_array_rows, size_array_cols; - int natoms_array, size_gradforce; + int natoms; + int size_gradforce; int yoffset, zoffset; int ndims_force, ndims_virial; double **gradforce; @@ -54,8 +55,8 @@ class MLIAPData : protected Pointers { // data structures for mliap neighbor list // only neighbors strictly inside descriptor cutoff - int natoms; // current number of atoms - int natoms_max; // allocated size of descriptor array + int nlistatoms; // current number of atoms in neighborlist + int nlistatoms_max; // allocated size of descriptor array int natomneigh_max; // allocated size of atom neighbor arrays int *numneighs; // neighbors count for each atom int *iatoms; // index of each atom diff --git a/src/MLIAP/mliap_descriptor_snap.cpp b/src/MLIAP/mliap_descriptor_snap.cpp index 21de044f40..388561e248 100644 --- a/src/MLIAP/mliap_descriptor_snap.cpp +++ b/src/MLIAP/mliap_descriptor_snap.cpp @@ -78,7 +78,7 @@ MLIAPDescriptorSNAP::~MLIAPDescriptorSNAP() void MLIAPDescriptorSNAP::compute_descriptors(class MLIAPData* data) { int ij = 0; - for (int ii = 0; ii < data->natoms; ii++) { + for (int ii = 0; ii < data->nlistatoms; ii++) { const int ielem = data->ielems[ii]; // insure rij, inside, wj, and rcutij are of size jnum @@ -130,7 +130,7 @@ void MLIAPDescriptorSNAP::compute_forces(class MLIAPData* data) double **f = atom->f; int ij = 0; - for (int ii = 0; ii < data->natoms; ii++) { + for (int ii = 0; ii < data->nlistatoms; ii++) { const int i = data->iatoms[ii]; const int ielem = data->ielems[ii]; @@ -204,7 +204,7 @@ void MLIAPDescriptorSNAP::compute_forces(class MLIAPData* data) void MLIAPDescriptorSNAP::compute_force_gradients(class MLIAPData* data) { int ij = 0; - for (int ii = 0; ii < data->natoms; ii++) { + for (int ii = 0; ii < data->nlistatoms; ii++) { const int i = data->iatoms[ii]; const int ielem = data->ielems[ii]; @@ -279,7 +279,7 @@ void MLIAPDescriptorSNAP::compute_force_gradients(class MLIAPData* data) void MLIAPDescriptorSNAP::compute_descriptor_gradients(class MLIAPData* data) { int ij = 0; - for (int ii = 0; ii < data->natoms; ii++) { + for (int ii = 0; ii < data->nlistatoms; ii++) { const int ielem = data->ielems[ii]; // insure rij, inside, wj, and rcutij are of size jnum diff --git a/src/MLIAP/mliap_model_linear.cpp b/src/MLIAP/mliap_model_linear.cpp index 9d19dcf381..8417bcdd18 100644 --- a/src/MLIAP/mliap_model_linear.cpp +++ b/src/MLIAP/mliap_model_linear.cpp @@ -57,7 +57,7 @@ void MLIAPModelLinear::compute_gradients(MLIAPData* data) { data->energy = 0.0; - for (int ii = 0; ii < data->natoms; ii++) { + for (int ii = 0; ii < data->nlistatoms; ii++) { const int ielem = data->ielems[ii]; double* coeffi = coeffelem[ielem]; @@ -107,7 +107,7 @@ void MLIAPModelLinear::compute_gradgrads(class MLIAPData* data) for (int l = 0; l < data->nelements*data->nparams; l++) data->egradient[l] = 0.0; - for (int ii = 0; ii < data->natoms; ii++) { + for (int ii = 0; ii < data->nlistatoms; ii++) { const int ielem = data->ielems[ii]; const int elemoffset = data->nparams*ielem; @@ -143,7 +143,7 @@ void MLIAPModelLinear::compute_force_gradients(class MLIAPData* data) data->egradient[l] = 0.0; int ij = 0; - for (int ii = 0; ii < data->natoms; ii++) { + for (int ii = 0; ii < data->nlistatoms; ii++) { const int i = data->iatoms[ii]; const int ielem = data->ielems[ii]; const int elemoffset = data->nparams*ielem; diff --git a/src/MLIAP/mliap_model_nn.cpp b/src/MLIAP/mliap_model_nn.cpp index 0fa7f7168b..c66b52ae65 100644 --- a/src/MLIAP/mliap_model_nn.cpp +++ b/src/MLIAP/mliap_model_nn.cpp @@ -217,7 +217,7 @@ void MLIAPModelNN::compute_gradients(MLIAPData* data) { data->energy = 0.0; - for (int ii = 0; ii < data->natoms; ii++) { + for (int ii = 0; ii < data->nlistatoms; ii++) { const int ielem = data->ielems[ii]; const int nl = nlayers; diff --git a/src/MLIAP/mliap_model_python_couple.pyx b/src/MLIAP/mliap_model_python_couple.pyx index 1f04964ef6..1f5b739092 100644 --- a/src/MLIAP/mliap_model_python_couple.pyx +++ b/src/MLIAP/mliap_model_python_couple.pyx @@ -17,7 +17,7 @@ from libcpp.string cimport string cdef extern from "mliap_data.h" namespace "LAMMPS_NS": cdef cppclass MLIAPData: # Array shapes - int natoms + int nlistatoms int ndescriptors # Input data @@ -103,7 +103,7 @@ cdef public void MLIAPPY_compute_gradients(MLIAPModelPython * c_model, MLIAPData model = retrieve(c_model) n_d = data.ndescriptors - n_a = data.natoms + n_a = data.nlistatoms # Make numpy arrays from pointers beta_np = np.asarray( &data.betas[0][0]) diff --git a/src/MLIAP/mliap_model_quadratic.cpp b/src/MLIAP/mliap_model_quadratic.cpp index 0b640189b4..1f46704d1b 100644 --- a/src/MLIAP/mliap_model_quadratic.cpp +++ b/src/MLIAP/mliap_model_quadratic.cpp @@ -59,7 +59,7 @@ void MLIAPModelQuadratic::compute_gradients(MLIAPData* data) { data->energy = 0.0; - for (int ii = 0; ii < data->natoms; ii++) { + for (int ii = 0; ii < data->nlistatoms; ii++) { const int ielem = data->ielems[ii]; double* coeffi = coeffelem[ielem]; @@ -133,7 +133,7 @@ void MLIAPModelQuadratic::compute_gradgrads(class MLIAPData* data) for (int l = 0; l < data->nelements*data->nparams; l++) data->egradient[l] = 0.0; - for (int ii = 0; ii < data->natoms; ii++) { + for (int ii = 0; ii < data->nlistatoms; ii++) { const int ielem = data->ielems[ii]; const int elemoffset = data->nparams*ielem; @@ -215,7 +215,7 @@ void MLIAPModelQuadratic::compute_force_gradients(class MLIAPData* data) { data->egradient[l] = 0.0; int ij = 0; - for (int ii = 0; ii < data->natoms; ii++) { + for (int ii = 0; ii < data->nlistatoms; ii++) { const int i = data->iatoms[ii]; const int ielem = data->ielems[ii]; const int elemoffset = data->nparams*ielem; diff --git a/src/MLIAP/pair_mliap.cpp b/src/MLIAP/pair_mliap.cpp index f280795399..85374e9214 100644 --- a/src/MLIAP/pair_mliap.cpp +++ b/src/MLIAP/pair_mliap.cpp @@ -255,7 +255,7 @@ void PairMLIAP::e_tally(MLIAPData* data) { if (eflag_global) eng_vdwl += data->energy; if (eflag_atom) - for (int ii = 0; ii < data->natoms; ii++) { + for (int ii = 0; ii < data->nlistatoms; ii++) { const int i = data->iatoms[ii]; eatom[i] += data->eatoms[ii]; } From fc8b3bcfd653fb0c23ad80f9bb2960065405756b Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Mon, 8 Mar 2021 14:00:34 -0700 Subject: [PATCH 30/30] Fixed bigint check --- src/MLIAP/mliap_data.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/MLIAP/mliap_data.cpp b/src/MLIAP/mliap_data.cpp index d0ea51d1b1..0f23100a46 100644 --- a/src/MLIAP/mliap_data.cpp +++ b/src/MLIAP/mliap_data.cpp @@ -51,10 +51,13 @@ MLIAPData::MLIAPData(LAMMPS *lmp, int gradgradflag_in, int *map_in, ndims_virial = 6; yoffset = nparams*nelements; zoffset = 2*yoffset; - // must check before storing bigint into regular int - if (atom->natoms > MAXSMALLINT) - error->all(FLERR,"Too many atoms for MLIAP package"); natoms = atom->natoms; + + // must check before assigning bigint expression to regular int + + if (1+ndims_force*natoms+ndims_virial > MAXSMALLINT) + error->all(FLERR,"Too many atoms for MLIAP package"); + size_array_rows = 1+ndims_force*natoms+ndims_virial; size_array_cols = nparams*nelements+1; size_gradforce = ndims_force*nparams*nelements;