From fa7e02ea71a5a6e9080df131e0ecc7a38cd5a1ce Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Mon, 3 Dec 2018 20:28:01 -0700 Subject: [PATCH 1/2] Removed redundant element list from pair_coeff snap syntax --- doc/src/pair_snap.txt | 32 +++++----- examples/snap/Mo_Chen_PRM2017.snap | 8 +-- examples/snap/Mo_Chen_PRM2017.snapcoeff | 36 +----------- examples/snap/Mo_Chen_PRM2017.snapparam | 5 +- examples/snap/Ta06A.snap | 18 +----- examples/snap/Ta06A.snapcoeff | 38 +----------- examples/snap/Ta06A.snapparam | 16 +---- examples/snap/W_2940_2017_2.snap | 17 +----- examples/snap/W_2940_2017_2.snapcoeff | 63 +------------------- examples/snap/W_2940_2017_2.snapparam | 14 +---- examples/snap/W_2940_2017_2_He_JW2013.snap | 18 +----- potentials/Mo_Chen_PRM2017.snap | 3 +- potentials/Ta06A.snap | 4 +- potentials/Ta06A.snapparam | 3 +- potentials/W_2940_2017_2.snap | 4 +- potentials/W_2940_2017_2.snapparam | 3 +- potentials/W_2940_2017_2_He_JW2013.snap | 6 +- src/SNAP/pair_snap.cpp | 68 +++++----------------- src/SNAP/pair_snap.h | 4 ++ 19 files changed, 54 insertions(+), 306 deletions(-) mode change 100644 => 120000 examples/snap/Mo_Chen_PRM2017.snap mode change 100644 => 120000 examples/snap/Mo_Chen_PRM2017.snapcoeff mode change 100644 => 120000 examples/snap/Mo_Chen_PRM2017.snapparam mode change 100644 => 120000 examples/snap/Ta06A.snap mode change 100644 => 120000 examples/snap/Ta06A.snapcoeff mode change 100644 => 120000 examples/snap/Ta06A.snapparam mode change 100644 => 120000 examples/snap/W_2940_2017_2.snap mode change 100644 => 120000 examples/snap/W_2940_2017_2.snapcoeff mode change 100644 => 120000 examples/snap/W_2940_2017_2.snapparam mode change 100644 => 120000 examples/snap/W_2940_2017_2_He_JW2013.snap diff --git a/doc/src/pair_snap.txt b/doc/src/pair_snap.txt index 6f8cc3d8a8..16cf0313c5 100644 --- a/doc/src/pair_snap.txt +++ b/doc/src/pair_snap.txt @@ -16,7 +16,7 @@ pair_style snap :pre [Examples:] pair_style snap -pair_coeff * * InP.snapcoeff In P InP.snapparam In In P P :pre +pair_coeff * * InP.snapcoeff InP.snapparam In In P P :pre [Description:] @@ -48,14 +48,12 @@ not set in the pair_style or pair_coeff command; they are specified in the SNAP potential files themselves. Only a single pair_coeff command is used with the {snap} style which -specifies two SNAP files and the list SNAP element(s) to be -extracted. -The SNAP elements are mapped to LAMMPS atom types by specifying -N additional arguments after the 2nd filename in the pair_coeff -command, where N is the number of LAMMPS atom types: +specifies a SNAP coefficient file followed by a SNAP parameter file +and then N additional arguments specifying the mapping of SNAP +elements to LAMMPS atom types, where N is the number of +LAMMPS atom types: -SNAP element file -Elem1, Elem2, ... +SNAP coefficient file SNAP parameter file N element names = mapping of SNAP elements to atom types :ul @@ -63,13 +61,11 @@ As an example, if a LAMMPS indium phosphide simulation has 4 atoms types, with the first two being indium and the 3rd and 4th being phophorous, the pair_coeff command would look like this: -pair_coeff * * snap InP.snapcoeff In P InP.snapparam In In P P :pre +pair_coeff * * snap InP.snapcoeff InP.snapparam In In P P :pre The 1st 2 arguments must be * * so as to span all LAMMPS atom types. -The two filenames are for the element and parameter files, respectively. -The 'In' and 'P' arguments (between the file names) are the two elements -which will be extracted from the element file. The -two trailing 'In' arguments map LAMMPS atom types 1 and 2 to the +The two filenames are for the coefficient and parameter files, respectively. +The two trailing 'In' arguments map LAMMPS atom types 1 and 2 to the SNAP 'In' element. The two trailing 'P' arguments map LAMMPS atom types 3 and 4 to the SNAP 'P' element. @@ -79,10 +75,11 @@ This can be used when a {snap} potential is used as part of the {hybrid} pair style. The NULL values are placeholders for atom types that will be used with other potentials. -The name of the SNAP element file usually ends in the +The name of the SNAP coefficient file usually ends in the ".snapcoeff" extension. It may contain coefficients -for many SNAP elements. -Only those elements listed in the pair_coeff command are extracted. +for many SNAP elements. The only requirement is that it +contain at least those element names appearing in the +LAMMPS mapping list. The name of the SNAP parameter file usually ends in the ".snapparam" extension. It contains a small number of parameters that define the overall form of the SNAP potential. @@ -110,8 +107,7 @@ It is convenient to keep these commands in a separate file that can be inserted in any LAMMPS input script using the "include"_include.html command. -The top of the SNAP element file can contain any number of blank and comment -lines (start with #), but follows a strict +The top of the SNAP coefficient file can contain any number of blank and comment lines (start with #), but follows a strict format after that. The first non-blank non-comment line must contain two integers: diff --git a/examples/snap/Mo_Chen_PRM2017.snap b/examples/snap/Mo_Chen_PRM2017.snap deleted file mode 100644 index e5e5f3e180..0000000000 --- a/examples/snap/Mo_Chen_PRM2017.snap +++ /dev/null @@ -1,7 +0,0 @@ - -# DATE: 2017-09-18 CONTRIBUTOR: Chi Chen CITATION: C. Chen, Z. Deng, R. Tran, H. Tang, I.-H. Chu, S. P. Ong, "Accurate force field for molybdenum by machine learning large materials data" Physical Review Materials 1, 04 3603 (2017) -# Generated by Materials Virtual Lab -# Definition of SNAP potential. -pair_style snap -pair_coeff * * Mo_Chen_PRM2017.snapcoeff Mo Mo_Chen_PRM2017.snapparam Mo - diff --git a/examples/snap/Mo_Chen_PRM2017.snap b/examples/snap/Mo_Chen_PRM2017.snap new file mode 120000 index 0000000000..78422c66e2 --- /dev/null +++ b/examples/snap/Mo_Chen_PRM2017.snap @@ -0,0 +1 @@ +../../potentials/Mo_Chen_PRM2017.snap \ No newline at end of file diff --git a/examples/snap/Mo_Chen_PRM2017.snapcoeff b/examples/snap/Mo_Chen_PRM2017.snapcoeff deleted file mode 100644 index 577c45bd76..0000000000 --- a/examples/snap/Mo_Chen_PRM2017.snapcoeff +++ /dev/null @@ -1,35 +0,0 @@ -# DATE: 2017-09-18 CONTRIBUTOR: Chi Chen CITATION: C. Chen, Z. Deng, R. Tran, H. Tang, I.-H. Chu, S. P. Ong, "Accurate force field for molybdenum by machine learning large materials data" Physical Review Materials 1, 04 3603 (2017) -# Generated by Materials Virtual Lab -1 31 -Mo 0.5 1 --17.2757958404 -0.00431015861472 -0.0657685117891 -0.477733335702 -0.0152688837211 -0.77559888196 -0.284846429566 -0.148804982644 -0.0573702179736 -0.19281989434 -0.323441703578 -0.101324335724 -0.0139639846514 --0.0324444749083 -0.0349797952779 -0.0613023441282 -0.0881078513046 -0.118716074611 -0.0069662975532 --0.0174658914685 --0.0178902177779 -0.0195993756659 -0.0719238160707 -0.0344832661036 --0.0358616891662 --0.0292380783172 --0.0334933909866 -0.00595462520243 -0.0754556638328 --0.000972545258845 --0.0100170422751 diff --git a/examples/snap/Mo_Chen_PRM2017.snapcoeff b/examples/snap/Mo_Chen_PRM2017.snapcoeff new file mode 120000 index 0000000000..b2dfa99a06 --- /dev/null +++ b/examples/snap/Mo_Chen_PRM2017.snapcoeff @@ -0,0 +1 @@ +../../potentials/Mo_Chen_PRM2017.snapcoeff \ No newline at end of file diff --git a/examples/snap/Mo_Chen_PRM2017.snapparam b/examples/snap/Mo_Chen_PRM2017.snapparam deleted file mode 100644 index e618bc1dd4..0000000000 --- a/examples/snap/Mo_Chen_PRM2017.snapparam +++ /dev/null @@ -1,4 +0,0 @@ -# DATE: 2017-09-18 CONTRIBUTOR: Chi Chen CITATION: C. Chen, Z. Deng, R. Tran, H. Tang, I.-H. Chu, S. P. Ong, "Accurate force field for molybdenum by machine learning large materials data" Physical Review Materials 1, 04 3603 (2017) -# Generated by Materials Virtual Lab -rcutfac 4.615858 -twojmax 6 diff --git a/examples/snap/Mo_Chen_PRM2017.snapparam b/examples/snap/Mo_Chen_PRM2017.snapparam new file mode 120000 index 0000000000..b1dc628e01 --- /dev/null +++ b/examples/snap/Mo_Chen_PRM2017.snapparam @@ -0,0 +1 @@ +../../potentials/Mo_Chen_PRM2017.snapparam \ No newline at end of file diff --git a/examples/snap/Ta06A.snap b/examples/snap/Ta06A.snap deleted file mode 100644 index edcc002524..0000000000 --- a/examples/snap/Ta06A.snap +++ /dev/null @@ -1,17 +0,0 @@ -# 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_coeff 1 1 zbl ${zblz} ${zblz} -pair_coeff * * snap Ta06A.snapcoeff Ta Ta06A.snapparam Ta - diff --git a/examples/snap/Ta06A.snap b/examples/snap/Ta06A.snap new file mode 120000 index 0000000000..cc26b99d64 --- /dev/null +++ b/examples/snap/Ta06A.snap @@ -0,0 +1 @@ +../../potentials/Ta06A.snap \ No newline at end of file diff --git a/examples/snap/Ta06A.snapcoeff b/examples/snap/Ta06A.snapcoeff deleted file mode 100644 index ad2dfa4bc5..0000000000 --- a/examples/snap/Ta06A.snapcoeff +++ /dev/null @@ -1,37 +0,0 @@ -# DATE: 2014-09-05 CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: Thompson, Swiler, Trott, Foiles and Tucker, arxiv.org, 1409.3880 (2014) - -# LAMMPS SNAP coefficients for Ta_Cand06A - -1 31 -Ta 0.5 1 --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/snap/Ta06A.snapcoeff b/examples/snap/Ta06A.snapcoeff new file mode 120000 index 0000000000..311d582ec6 --- /dev/null +++ b/examples/snap/Ta06A.snapcoeff @@ -0,0 +1 @@ +../../potentials/Ta06A.snapcoeff \ No newline at end of file diff --git a/examples/snap/Ta06A.snapparam b/examples/snap/Ta06A.snapparam deleted file mode 100644 index 283629d658..0000000000 --- a/examples/snap/Ta06A.snapparam +++ /dev/null @@ -1,15 +0,0 @@ -# DATE: 2014-09-05 CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: Thompson, Swiler, Trott, Foiles and Tucker, arxiv.org, 1409.3880 (2014) - -# LAMMPS SNAP parameters for Ta_Cand06A - -# required -rcutfac 4.67637 -twojmax 6 - -# optional - -rfac0 0.99363 -rmin0 0 -diagonalstyle 3 -bzeroflag 0 -quadraticflag 0 diff --git a/examples/snap/Ta06A.snapparam b/examples/snap/Ta06A.snapparam new file mode 120000 index 0000000000..e697069cba --- /dev/null +++ b/examples/snap/Ta06A.snapparam @@ -0,0 +1 @@ +../../potentials/Ta06A.snapparam \ No newline at end of file diff --git a/examples/snap/W_2940_2017_2.snap b/examples/snap/W_2940_2017_2.snap deleted file mode 100644 index 04b8d58094..0000000000 --- a/examples/snap/W_2940_2017_2.snap +++ /dev/null @@ -1,16 +0,0 @@ -# DATE: 2017-02-20 CONTRIBUTOR: Mitchell Wood mitwood@sandia.gov CITATION: Wood, M. A. and Thompson, A. P. "Quantum-Accurate Molecular Dynamics Potential for Tungsten" arXiv:1702.07042 [physics.comp-ph] -# -# 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} & -snap -pair_coeff 1 1 zbl ${zblz} ${zblz} -pair_coeff * * snap W_2940_2017_2.snapcoeff W W_2940_2017_2.snapparam W - -#Nomenclature on the snap files are Element_DakotaID_Year_Month diff --git a/examples/snap/W_2940_2017_2.snap b/examples/snap/W_2940_2017_2.snap new file mode 120000 index 0000000000..907ee91562 --- /dev/null +++ b/examples/snap/W_2940_2017_2.snap @@ -0,0 +1 @@ +../../potentials/W_2940_2017_2.snap \ No newline at end of file diff --git a/examples/snap/W_2940_2017_2.snapcoeff b/examples/snap/W_2940_2017_2.snapcoeff deleted file mode 100644 index dcfea3feaf..0000000000 --- a/examples/snap/W_2940_2017_2.snapcoeff +++ /dev/null @@ -1,62 +0,0 @@ -# DATE: 2017-02-20 CONTRIBUTOR: Mitchell Wood mitwood@sandia.gov CITATION: Wood, M. A. and Thompson, A. P. "Quantum-Accurate Molecular Dynamics Potential for Tungsten" arXiv:1702.07042 [physics.comp-ph] -# -# LAMMPS SNAP coefficients for W - -1 56 -W 0.5 1 - 0.781170857801 - -0.001794941735 - -0.016628679036 - -0.066625537037 - -0.073716343967 - -0.062913923923 - 0.032552694672 - -0.134901744419 - -0.075076334103 - -0.148558616547 - -0.140808831101 - -0.166749145704 - -0.047487675984 - -0.049892090603 - -0.032483739965 - -0.114766534860 - -0.106759718242 - -0.125894850485 - -0.103409735225 - -0.095247335447 - -0.061998736346 - -0.053895610976 - -0.010799734206 - -0.011644828900 - -0.028316826924 - 0.011176085541 - 0.064619474684 - -0.023886279996 - -0.004099224312 - -0.056084222496 - -0.035551497650 - -0.056678501024 - -0.004905851656 - -0.015701146162 - -0.008462280779 - 0.016429018676 - 0.032432633993 - -0.010805361272 - -0.014841893457 - 0.019414134562 - -0.008112452759 - -0.002700775447 - 0.007032887063 - -0.009706065042 - 0.008385967833 - 0.028606085876 - -0.007003591067 - 0.006467260152 - -0.006666986361 - 0.029243285316 - 0.002477673872 - -0.000199497504 - 0.004068954075 - 0.006036129972 - -0.013010633924 - -0.008314173699 diff --git a/examples/snap/W_2940_2017_2.snapcoeff b/examples/snap/W_2940_2017_2.snapcoeff new file mode 120000 index 0000000000..5eff37c936 --- /dev/null +++ b/examples/snap/W_2940_2017_2.snapcoeff @@ -0,0 +1 @@ +../../potentials/W_2940_2017_2.snapcoeff \ No newline at end of file diff --git a/examples/snap/W_2940_2017_2.snapparam b/examples/snap/W_2940_2017_2.snapparam deleted file mode 100644 index 27ab61a266..0000000000 --- a/examples/snap/W_2940_2017_2.snapparam +++ /dev/null @@ -1,13 +0,0 @@ -# DATE: 2017-02-20 CONTRIBUTOR: Mitchell Wood mitwood@sandia.gov CITATION: Wood, M. A. and Thompson, A. P. "Quantum-Accurate Molecular Dynamics Potential for Tungsten" arXiv:1702.07042 [physics.comp-ph] -# -# required -rcutfac 4.73442 -twojmax 8 - -# optional - -rfac0 0.99363 -rmin0 0 -diagonalstyle 3 -bzeroflag 0 -quadraticflag 0 diff --git a/examples/snap/W_2940_2017_2.snapparam b/examples/snap/W_2940_2017_2.snapparam new file mode 120000 index 0000000000..af9dec2e52 --- /dev/null +++ b/examples/snap/W_2940_2017_2.snapparam @@ -0,0 +1 @@ +../../potentials/W_2940_2017_2.snapparam \ No newline at end of file diff --git a/examples/snap/W_2940_2017_2_He_JW2013.snap b/examples/snap/W_2940_2017_2_He_JW2013.snap deleted file mode 100644 index cb70916ec4..0000000000 --- a/examples/snap/W_2940_2017_2_He_JW2013.snap +++ /dev/null @@ -1,17 +0,0 @@ -# DATE: 2017-02-20 CONTRIBUTOR: Mitchell Wood mitwood@sandia.gov CITATION: Wood, M. A. and Thompson, A. P. "Quantum-Accurate Molecular Dynamics Potential for Tungsten" arXiv:1702.07042 [physics.comp-ph] -# -# Definition of SNAP+ZBL+Tabulated 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} snap table spline 10000 table spline 10000 -pair_coeff 1 1 zbl ${zblz} ${zblz} -pair_coeff * * snap W_2940_2017_2.snapcoeff W W_2940_2017_2.snapparam W NULL -pair_coeff 2 2 table 1 He_He_JW2013.table HeHe -pair_coeff 1 2 table 2 W_He_JW2013.table WHe -#Hybrid/overlay will take all pair styles and add their contributions equally, order of pair_coeff doesnt matter here -#This is not the case for pair_style hybrid ... where only one pair_coeff is read for each type combination, order matters here. - diff --git a/examples/snap/W_2940_2017_2_He_JW2013.snap b/examples/snap/W_2940_2017_2_He_JW2013.snap new file mode 120000 index 0000000000..5e0f21ab3b --- /dev/null +++ b/examples/snap/W_2940_2017_2_He_JW2013.snap @@ -0,0 +1 @@ +../../potentials/W_2940_2017_2_He_JW2013.snap \ No newline at end of file diff --git a/potentials/Mo_Chen_PRM2017.snap b/potentials/Mo_Chen_PRM2017.snap index 579315b3dd..05d642358e 100644 --- a/potentials/Mo_Chen_PRM2017.snap +++ b/potentials/Mo_Chen_PRM2017.snap @@ -1,6 +1,7 @@ + # DATE: 2017-09-18 CONTRIBUTOR: Chi Chen CITATION: C. Chen, Z. Deng, R. Tran, H. Tang, I.-H. Chu, S. P. Ong, "Accurate force field for molybdenum by machine learning large materials data" Physical Review Materials 1, 04 3603 (2017) # Generated by Materials Virtual Lab # Definition of SNAP potential. pair_style snap -pair_coeff * * Mo_Chen_PRM2017.snapcoeff Mo Mo_Chen_PRM2017.snapparam Mo +pair_coeff * * Mo_Chen_PRM2017.snapcoeff Mo_Chen_PRM2017.snapparam Mo diff --git a/potentials/Ta06A.snap b/potentials/Ta06A.snap index 43ce31fdcc..d9feae0b46 100644 --- a/potentials/Ta06A.snap +++ b/potentials/Ta06A.snap @@ -2,7 +2,7 @@ # Definition of SNAP potential Ta_Cand06A # Assumes 1 LAMMPS atom type - + variable zblcutinner equal 4 variable zblcutouter equal 4.8 variable zblz equal 73 @@ -13,5 +13,5 @@ pair_style hybrid/overlay & zbl ${zblcutinner} ${zblcutouter} & snap pair_coeff 1 1 zbl ${zblz} ${zblz} -pair_coeff * * snap Ta06A.snapcoeff Ta Ta06A.snapparam Ta +pair_coeff * * snap Ta06A.snapcoeff Ta06A.snapparam Ta diff --git a/potentials/Ta06A.snapparam b/potentials/Ta06A.snapparam index 0627253341..283629d658 100644 --- a/potentials/Ta06A.snapparam +++ b/potentials/Ta06A.snapparam @@ -8,7 +8,8 @@ twojmax 6 # optional -gamma 1 rfac0 0.99363 rmin0 0 diagonalstyle 3 +bzeroflag 0 +quadraticflag 0 diff --git a/potentials/W_2940_2017_2.snap b/potentials/W_2940_2017_2.snap index 51eee41a0a..93c2bf866a 100644 --- a/potentials/W_2940_2017_2.snap +++ b/potentials/W_2940_2017_2.snap @@ -5,12 +5,12 @@ variable zblcutinner equal 4 variable zblcutouter equal 4.8 variable zblz equal 74 -# Specify hybrid with SNAP, ZBL, and long-range Coulomb +# Specify hybrid with SNAP and ZBL pair_style hybrid/overlay & zbl ${zblcutinner} ${zblcutouter} & snap pair_coeff 1 1 zbl ${zblz} ${zblz} -pair_coeff * * snap W_2940_2017_2.snapcoeff W W_2940_2017_2.snapparam W +pair_coeff * * snap W_2940_2017_2.snapcoeff W_2940_2017_2.snapparam W #Nomenclature on the snap files are Element_DakotaID_Year_Month diff --git a/potentials/W_2940_2017_2.snapparam b/potentials/W_2940_2017_2.snapparam index e0b20005e6..27ab61a266 100644 --- a/potentials/W_2940_2017_2.snapparam +++ b/potentials/W_2940_2017_2.snapparam @@ -6,7 +6,8 @@ twojmax 8 # optional -gamma 1 rfac0 0.99363 rmin0 0 diagonalstyle 3 +bzeroflag 0 +quadraticflag 0 diff --git a/potentials/W_2940_2017_2_He_JW2013.snap b/potentials/W_2940_2017_2_He_JW2013.snap index ff0827c138..7eb4f65401 100644 --- a/potentials/W_2940_2017_2_He_JW2013.snap +++ b/potentials/W_2940_2017_2_He_JW2013.snap @@ -5,11 +5,11 @@ variable zblcutinner equal 4 variable zblcutouter equal 4.8 variable zblz equal 74 -# Specify hybrid with SNAP, ZBL, and long-range Coulomb +# Specify hybrid with SNAP and ZBL pair_style hybrid/overlay zbl ${zblcutinner} ${zblcutouter} snap table spline 10000 table spline 10000 -pair_coeff 1 1 zbl ${zblz} ${zblz} -pair_coeff * * snap W_2940_2017_2.snapcoeff W W_2940_2017_2.snapparam W NULL +pair_coeff 1 1 zbl ${zblz} ${zblz} +pair_coeff * * snap W_2940_2017_2.snapcoeff W_2940_2017_2.snapparam W NULL pair_coeff 2 2 table 1 He_He_JW2013.table HeHe pair_coeff 1 2 table 2 W_He_JW2013.table WHe #Hybrid/overlay will take all pair styles and add their contributions equally, order of pair_coeff doesnt matter here diff --git a/src/SNAP/pair_snap.cpp b/src/SNAP/pair_snap.cpp index 9f4c6bf5e2..81c5e9f6d1 100644 --- a/src/SNAP/pair_snap.cpp +++ b/src/SNAP/pair_snap.cpp @@ -1416,11 +1416,7 @@ void PairSNAP::settings(int narg, char **arg) void PairSNAP::coeff(int narg, char **arg) { - // read SNAP element names between 2 filenames - // nelements = # of SNAP elements - // elements = list of unique element names - - if (narg < 6) error->all(FLERR,"Incorrect args for pair coefficients"); + if (narg < 5) error->all(FLERR,"Incorrect args for pair coefficients"); if (!allocated) allocate(); if (nelements) { @@ -1432,30 +1428,17 @@ void PairSNAP::coeff(int narg, char **arg) memory->destroy(coeffelem); } - nelements = narg - 4 - atom->ntypes; - if (nelements < 1) error->all(FLERR,"Incorrect args for pair coefficients"); - char* type1 = arg[0]; char* type2 = arg[1]; char* coefffilename = arg[2]; - char** elemlist = &arg[3]; - char* paramfilename = arg[3+nelements]; - char** elemtypes = &arg[4+nelements]; + char* paramfilename = arg[3]; + char** elemtypes = &arg[4]; // insure I,J args are * * if (strcmp(type1,"*") != 0 || strcmp(type2,"*") != 0) error->all(FLERR,"Incorrect args for pair coefficients"); - elements = new char*[nelements]; - - for (int i = 0; i < nelements; i++) { - char* elemname = elemlist[i]; - int n = strlen(elemname) + 1; - elements[i] = new char[n]; - strcpy(elements[i],elemname); - } - // read snapcoeff and snapparam files read_files(coefffilename,paramfilename); @@ -1631,22 +1614,19 @@ void PairSNAP::read_files(char *coefffilename, char *paramfilename) iword = 1; words[iword] = strtok(NULL,"' \t\n\r\f"); - int nelemfile = atoi(words[0]); + nelements = atoi(words[0]); ncoeffall = atoi(words[1]); - // Set up element lists + // set up element lists + elements = new char*[nelements]; memory->create(radelem,nelements,"pair:radelem"); memory->create(wjelem,nelements,"pair:wjelem"); memory->create(coeffelem,nelements,ncoeffall,"pair:coeffelem"); - int *found = new int[nelements]; - for (int ielem = 0; ielem < nelements; ielem++) - found[ielem] = 0; + // Loop over nelements blocks in the SNAP coefficient file - // Loop over elements in the SNAP coefficient file - - for (int ielemfile = 0; ielemfile < nelemfile; ielemfile++) { + for (int ielem = 0; ielem < nelements; ielem++) { if (comm->me == 0) { ptr = fgets(line,MAXLINE,fpcoeff); @@ -1673,33 +1653,12 @@ void PairSNAP::read_files(char *coefffilename, char *paramfilename) words[iword] = strtok(NULL,"' \t\n\r\f"); char* elemtmp = words[0]; - double radtmp = atof(words[1]); - double wjtmp = atof(words[2]); + int n = strlen(elemtmp) + 1; + elements[ielem] = new char[n]; + strcpy(elements[ielem],elemtmp); - // skip if element name isn't in element list - - int ielem; - for (ielem = 0; ielem < nelements; ielem++) - if (strcmp(elemtmp,elements[ielem]) == 0) break; - if (ielem == nelements) { - if (comm->me == 0) - for (int icoeff = 0; icoeff < ncoeffall; icoeff++) - ptr = fgets(line,MAXLINE,fpcoeff); - continue; - } - - // skip if element already appeared - - if (found[ielem]) { - if (comm->me == 0) - for (int icoeff = 0; icoeff < ncoeffall; icoeff++) - ptr = fgets(line,MAXLINE,fpcoeff); - continue; - } - - found[ielem] = 1; - radelem[ielem] = radtmp; - wjelem[ielem] = wjtmp; + radelem[ielem] = atof(words[1]); + wjelem[ielem] = atof(words[2]); if (comm->me == 0) { @@ -1821,7 +1780,6 @@ void PairSNAP::read_files(char *coefffilename, char *paramfilename) if (rcutfacflag == 0 || twojmaxflag == 0) error->all(FLERR,"Incorrect SNAP parameter file"); - delete[] found; } /* ---------------------------------------------------------------------- diff --git a/src/SNAP/pair_snap.h b/src/SNAP/pair_snap.h index d39cb0f8d4..1fa065755c 100644 --- a/src/SNAP/pair_snap.h +++ b/src/SNAP/pair_snap.h @@ -173,4 +173,8 @@ E: Incorrect format in SNAP parameter file Incorrect number of words per line in the parameter file. +E: Did not find all elements in SNAP coefficient file. + +One or more elements listed in the pair_coeff command were not found in the coefficient file. + */ From 00d719459f267c7756fb87b50a0b6507d88faf4e Mon Sep 17 00:00:00 2001 From: Aidan Thompson Date: Tue, 4 Dec 2018 17:46:31 -0700 Subject: [PATCH 2/2] Fixed one error --- doc/src/pair_snap.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/src/pair_snap.txt b/doc/src/pair_snap.txt index 16cf0313c5..a796cfdeba 100644 --- a/doc/src/pair_snap.txt +++ b/doc/src/pair_snap.txt @@ -100,8 +100,7 @@ by the following commands: zbl $\{zblcutinner\} $\{zblcutouter\} snap pair_coeff * * zbl 0.0 pair_coeff 1 1 zbl $\{zblz\} - pair_coeff * * snap ../potentials/Ta06A.snapcoeff Ta & - ../potentials/Ta06A.snapparam Ta :pre + pair_coeff * * snap Ta06A.snapcoeff Ta06A.snapparam Ta :pre It is convenient to keep these commands in a separate file that can be inserted in any LAMMPS input script using the "include"_include.html