diff --git a/cmake/Modules/LAMMPSUtils.cmake b/cmake/Modules/LAMMPSUtils.cmake index 943c3d851e..9f624fc007 100644 --- a/cmake/Modules/LAMMPSUtils.cmake +++ b/cmake/Modules/LAMMPSUtils.cmake @@ -24,6 +24,24 @@ function(validate_option name values) endif() endfunction(validate_option) +# helper function for getting the most recently modified file or folder from a glob pattern +function(get_newest_file path variable) + file(GLOB _dirs ${path}) + set(_besttime 2000-01-01T00:00:00) + set(_bestfile "") + foreach(_dir ${_dirs}) + file(TIMESTAMP ${_dir} _newtime) + if(_newtime IS_NEWER_THAN _besttime) + set(_bestfile ${_dir}) + set(_besttime ${_newtime}) + endif() + endforeach() + if(_bestfile STREQUAL "") + message(FATAL_ERROR "Could not find valid path at: ${path}") + endif() + set(${variable} ${_bestfile} PARENT_SCOPE) +endfunction() + function(get_lammps_version version_header variable) file(STRINGS ${version_header} line REGEX LAMMPS_VERSION) set(MONTHS x Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec) diff --git a/cmake/Modules/Packages/ML-PACE.cmake b/cmake/Modules/Packages/ML-PACE.cmake index 635a9ff2f5..c647c8873a 100644 --- a/cmake/Modules/Packages/ML-PACE.cmake +++ b/cmake/Modules/Packages/ML-PACE.cmake @@ -1,6 +1,6 @@ -set(PACELIB_URL "https://github.com/ICAMS/lammps-user-pace/archive/refs/tags/v.2021.10.25.fix.tar.gz" CACHE STRING "URL for PACE evaluator library sources") +set(PACELIB_URL "https://github.com/ICAMS/lammps-user-pace/archive/refs/tags/v.2021.10.25.fix2.tar.gz" CACHE STRING "URL for PACE evaluator library sources") -set(PACELIB_MD5 "e0572de57039d4afedefb25707b6ceae" CACHE STRING "MD5 checksum of PACE evaluator library tarball") +set(PACELIB_MD5 "32394d799bc282bb57696c78c456e64f" CACHE STRING "MD5 checksum of PACE evaluator library tarball") mark_as_advanced(PACELIB_URL) mark_as_advanced(PACELIB_MD5) @@ -13,8 +13,8 @@ execute_process( COMMAND ${CMAKE_COMMAND} -E tar xzf libpace.tar.gz WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) +get_newest_file(${CMAKE_BINARY_DIR}/lammps-user-pace-* lib-pace) -file(GLOB lib-pace ${CMAKE_BINARY_DIR}/lammps-user-pace-*) # enforce building libyaml-cpp as static library and turn off optional features set(YAML_BUILD_SHARED_LIBS OFF) set(YAML_CPP_BUILD_CONTRIB OFF) diff --git a/examples/PACKAGES/pace/in.pace.product b/examples/PACKAGES/pace/in.pace.product index 11049ee922..1ba1fc679c 100644 --- a/examples/PACKAGES/pace/in.pace.product +++ b/examples/PACKAGES/pace/in.pace.product @@ -1,36 +1,36 @@ -# simple test of fcc Cu with ACE product +# simple test of fcc Cu with ACE product -units metal -atom_style atomic +units metal +atom_style atomic -neighbor 0.3 bin -neigh_modify every 2 delay 10 check yes +neighbor 0.3 bin +neigh_modify every 2 delay 10 check yes -variable a equal 3.597 -lattice fcc $a -region box block 0 4 0 4 0 4 -create_box 1 box -create_atoms 1 box +variable a equal 3.597 +lattice fcc $a +region box block 0 4 0 4 0 4 +create_box 1 box +create_atoms 1 box -mass 1 26.98 +mass 1 26.98 -pair_style pace product +pair_style pace product pair_coeff * * Cu-PBE-core-rep.ace Cu velocity all create 300 8728 loop geom timestep 0.0005 -fix 1 all nve +fix 1 all nve -compute eatom all pe/atom -compute energy all reduce sum c_eatom -variable delenergy equal c_energy-pe +compute eatom all pe/atom +compute energy all reduce sum c_eatom +variable delenergy equal c_energy-pe -compute satom all stress/atom NULL -compute str all reduce sum c_satom[1] c_satom[2] c_satom[3] -variable delpress equal -(c_str[1]+c_str[2]+c_str[3])/(3*vol)-press +compute satom all stress/atom NULL +compute str all reduce sum c_satom[1] c_satom[2] c_satom[3] +variable delpress equal -(c_str[1]+c_str[2]+c_str[3])/(3*vol)-press -thermo 10 +thermo 10 thermo_style custom step temp epair etotal press v_delenergy v_delpress -run 100 +run 100 diff --git a/examples/PACKAGES/pace/in.pace.recursive b/examples/PACKAGES/pace/in.pace.recursive index 1d6d9116f0..5d299fb033 100644 --- a/examples/PACKAGES/pace/in.pace.recursive +++ b/examples/PACKAGES/pace/in.pace.recursive @@ -1,36 +1,36 @@ -# simple test of fcc Cu with ACE recursive +# simple test of fcc Cu with ACE recursive -units metal -atom_style atomic +units metal +atom_style atomic -neighbor 0.3 bin -neigh_modify every 2 delay 10 check yes +neighbor 0.3 bin +neigh_modify every 2 delay 10 check yes -variable a equal 3.597 -lattice fcc $a -region box block 0 4 0 4 0 4 -create_box 1 box -create_atoms 1 box +variable a equal 3.597 +lattice fcc $a +region box block 0 4 0 4 0 4 +create_box 1 box +create_atoms 1 box -mass 1 26.98 +mass 1 26.98 -pair_style pace recursive +pair_style pace recursive pair_coeff * * Cu-PBE-core-rep.ace Cu velocity all create 300 8728 loop geom timestep 0.0005 -fix 1 all nve +fix 1 all nve -compute eatom all pe/atom -compute energy all reduce sum c_eatom -variable delenergy equal c_energy-pe +compute eatom all pe/atom +compute energy all reduce sum c_eatom +variable delenergy equal c_energy-pe -compute satom all stress/atom NULL -compute str all reduce sum c_satom[1] c_satom[2] c_satom[3] -variable delpress equal -(c_str[1]+c_str[2]+c_str[3])/(3*vol)-press +compute satom all stress/atom NULL +compute str all reduce sum c_satom[1] c_satom[2] c_satom[3] +variable delpress equal -(c_str[1]+c_str[2]+c_str[3])/(3*vol)-press -thermo 10 +thermo 10 thermo_style custom step temp epair etotal press v_delenergy v_delpress -run 100 +run 100 diff --git a/lib/pace/Install.py b/lib/pace/Install.py index c59c249657..790acd4cf4 100644 --- a/lib/pace/Install.py +++ b/lib/pace/Install.py @@ -15,7 +15,7 @@ from install_helpers import fullpath, geturl, checkmd5sum # settings thisdir = fullpath('.') -version = 'v.2021.10.25.fix' +version = 'v.2021.10.25.fix2' # known checksums for different PACE versions. used to validate the download. checksums = { \ @@ -23,7 +23,8 @@ checksums = { \ 'v.2021.4.9' : '4db54962fbd6adcf8c18d46e1798ceb5', 'v.2021.9.28' : 'f98363bb98adc7295ea63974738c2a1b', 'v.2021.10.25' : 'a2ac3315c41a1a4a5c912bcb1bc9c5cc', - 'v.2021.10.25.fix': 'e0572de57039d4afedefb25707b6ceae' + 'v.2021.10.25.fix': 'e0572de57039d4afedefb25707b6ceae', + 'v.2021.10.25.fix2': '32394d799bc282bb57696c78c456e64f' } diff --git a/src/ML-PACE/pair_pace.cpp b/src/ML-PACE/pair_pace.cpp index a583ebe508..87e580b8d3 100644 --- a/src/ML-PACE/pair_pace.cpp +++ b/src/ML-PACE/pair_pace.cpp @@ -146,18 +146,8 @@ void PairPACE::compute(int eflag, int vflag) // the pointer to the list of neighbors of "i" firstneigh = list->firstneigh; - if (inum != nlocal) error->all(FLERR, "inum: {} nlocal: {} are different", inum, nlocal); - - // Aidan Thompson told RD (26 July 2019) that practically always holds: - // inum = nlocal - // i = ilist(ii) < inum - // j = jlist(jj) < nall - // neighborlist contains neighbor atoms plus skin atoms, - // skin atoms can be removed by setting skin to zero but here - // they are disregarded anyway - //determine the maximum number of neighbours - int max_jnum = -1; + int max_jnum = 0; int nei = 0; for (ii = 0; ii < list->inum; ii++) { i = ilist[ii]; @@ -190,7 +180,7 @@ void PairPACE::compute(int eflag, int vflag) try { aceimpl->ace->compute_atom(i, x, type, jnum, jlist); - } catch (exception &e) { + } catch (std::exception &e) { error->one(FLERR, e.what()); } @@ -269,7 +259,7 @@ void PairPACE::settings(int narg, char **arg) recursive = false; iarg += 1; } else if (strcmp(arg[iarg], "chunksize") == 0) { - chunksize = utils::inumeric(FLERR,arg[iarg+1],false,lmp); + chunksize = utils::inumeric(FLERR, arg[iarg + 1], false, lmp); iarg += 2; } else error->all(FLERR, "Illegal pair_style command"); @@ -325,27 +315,34 @@ void PairPACE::coeff(int narg, char **arg) const int n = atom->ntypes; for (int i = 1; i <= n; i++) { - char *elemname = elemtypes[i - 1]; - int atomic_number = AtomicNumberByName_pace(elemname); - if (atomic_number == -1) error->all(FLERR, "'{}' is not a valid element\n", elemname); - - SPECIES_TYPE mu = aceimpl->basis_set->get_species_index_by_name(elemname); - if (mu != -1) { - if (comm->me == 0) - utils::logmesg(lmp, "Mapping LAMMPS atom type #{}({}) -> ACE species type #{}\n", i, - elemname, mu); - map[i] = mu; - // set up LAMMPS atom type to ACE species mapping for ace evaluator - aceimpl->ace->element_type_mapping(i) = mu; + char *elemname = arg[2 + i]; + if (strcmp(elemname, "NULL") == 0) { + // species_type=-1 value will not reach ACE Evaluator::compute_atom, + // but if it will ,then error will be thrown there + aceimpl->ace->element_type_mapping(i) = -1; + map[i] = -1; + if (comm->me == 0) utils::logmesg(lmp, "Skipping LAMMPS atom type #{}(NULL)\n", i); } else { - error->all(FLERR, "Element {} is not supported by ACE-potential from file {}", elemname, - potential_file_name); + int atomic_number = AtomicNumberByName_pace(elemname); + if (atomic_number == -1) error->all(FLERR, "'{}' is not a valid element\n", elemname); + SPECIES_TYPE mu = aceimpl->basis_set->get_species_index_by_name(elemname); + if (mu != -1) { + if (comm->me == 0) + utils::logmesg(lmp, "Mapping LAMMPS atom type #{}({}) -> ACE species type #{}\n", i, + elemname, mu); + map[i] = mu; + // set up LAMMPS atom type to ACE species mapping for ace evaluator + aceimpl->ace->element_type_mapping(i) = mu; + } else { + error->all(FLERR, "Element {} is not supported by ACE-potential from file {}", elemname, + potential_file_name); + } } } // initialize scale factor for (int i = 1; i <= n; i++) { - for (int j = i; j <= n; j++) { scale[i][j] = 1.0; } + for (int j = i; j <= n; j++) scale[i][j] = 1.0; } aceimpl->ace->set_basis(*aceimpl->basis_set, 1);