From 725afc1414dffe969f5e99aed2c843a99f84747e Mon Sep 17 00:00:00 2001 From: Ajinkya Hire Date: Tue, 24 Oct 2023 18:32:38 -0400 Subject: [PATCH 1/4] Bug fixes in coeff() function. 'pair_coeff i j FILENAME' was ignored, whenever i>j. Similarly 'pair_coeff i j k FILENAME' was ignored whenever j>k. Commit fixes it --- lammps_plugin/ML-UF3/pair_uf3.cpp | 42 +++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/lammps_plugin/ML-UF3/pair_uf3.cpp b/lammps_plugin/ML-UF3/pair_uf3.cpp index ccb5e538..1e370a94 100644 --- a/lammps_plugin/ML-UF3/pair_uf3.cpp +++ b/lammps_plugin/ML-UF3/pair_uf3.cpp @@ -129,25 +129,45 @@ void PairUF3::coeff(int narg, char **arg) if (narg == 3){ - for (int i = ilo; i <= ihi; i++) { - for (int j = MAX(jlo, i); j <= jhi; j++) { - if (comm->me == 0) - utils::logmesg(lmp, "\nUF3: Opening {} file\n", arg[2]); - uf3_read_pot_file(i,j,arg[2]); + if (utils::strmatch(arg[0],".*\\*.*") || utils::strmatch(arg[1],".*\\*.*")){ + for (int i = ilo; i <= ihi; i++) { + for (int j = MAX(jlo, i); j <= jhi; j++) { + if (comm->me == 0) + utils::logmesg(lmp, "\nUF3: Opening {} file\n", arg[2]); + uf3_read_pot_file(i,j,arg[2]); + } } } + + else{ + int i = utils::inumeric(FLERR, arg[0], true, lmp); + int j = utils::inumeric(FLERR, arg[1], true, lmp); + if (comm->me == 0) + utils::logmesg(lmp, "\nUF3: Opening {} file\n", arg[2]); + uf3_read_pot_file(i,j,arg[2]); + } } if (narg == 4){ - for (int i = ilo; i <= ihi; i++) { - for (int j = jlo; j <= jhi; j++) { - for (int k = MAX(klo, jlo); k <= khi; k++) { - if (comm->me == 0) - utils::logmesg(lmp, "\nUF3: Opening {} file\n", arg[3]); - uf3_read_pot_file(i,j,k,arg[3]); + if (utils::strmatch(arg[0],".*\\*.*") || utils::strmatch(arg[1],".*\\*.*") || utils::strmatch(arg[2],".*\\*.*")){ + for (int i = ilo; i <= ihi; i++) { + for (int j = jlo; j <= jhi; j++) { + for (int k = MAX(klo, jlo); k <= khi; k++) { + if (comm->me == 0) + utils::logmesg(lmp, "\nUF3: Opening {} file\n", arg[3]); + uf3_read_pot_file(i,j,k,arg[3]); + } } } } + else{ + if (comm->me == 0) + utils::logmesg(lmp, "\nUF3: Opening {} file\n", arg[3]); + int i = utils::inumeric(FLERR, arg[0], true, lmp); + int j = utils::inumeric(FLERR, arg[1], true, lmp); + int k = utils::inumeric(FLERR, arg[2], true, lmp); + uf3_read_pot_file(i,j,k,arg[3]); + } } } From e046c6373f8e61ce3e0b1319c155bca2f831d803 Mon Sep 17 00:00:00 2001 From: Ajinkya Hire Date: Tue, 24 Oct 2023 18:35:14 -0400 Subject: [PATCH 2/4] Bug Fix. If the UF3-LAMMPS POT file is not found an error is produced instead of core_dump --- lammps_plugin/ML-UF3/pair_uf3.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lammps_plugin/ML-UF3/pair_uf3.cpp b/lammps_plugin/ML-UF3/pair_uf3.cpp index 1e370a94..c2b6fc98 100644 --- a/lammps_plugin/ML-UF3/pair_uf3.cpp +++ b/lammps_plugin/ML-UF3/pair_uf3.cpp @@ -301,6 +301,9 @@ void PairUF3::uf3_read_pot_file(int itype, int jtype, char *potf_name) utils::logmesg(lmp, "UF3: {} file should contain UF3 potential for {} {}\n", \ potf_name, itype, jtype); + if (!platform::file_is_readable(potf_name)) + error->all(FLERR, "UF3: {} file is not readable", potf_name); + FILE *fp; fp = utils::open_potential(potf_name, lmp, nullptr); @@ -420,6 +423,9 @@ void PairUF3::uf3_read_pot_file(int itype, int jtype, int ktype, char *potf_name utils::logmesg(lmp, "UF3: {} file should contain UF3 potential for {} {} {}\n", potf_name, itype, jtype, ktype); + if (!platform::file_is_readable(potf_name)) + error->all(FLERR, "UF3: {} file is not readable", potf_name); + FILE *fp; fp = utils::open_potential(potf_name, lmp, nullptr); From 815a22d6204a1784c5d3a4a7c2c5c7f6173ec57e Mon Sep 17 00:00:00 2001 From: Ajinkya Hire Date: Tue, 24 Oct 2023 19:10:03 -0400 Subject: [PATCH 3/4] Updated documentation --- lammps_plugin/README.rst | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/lammps_plugin/README.rst b/lammps_plugin/README.rst index e8493014..ee1cc2b7 100644 --- a/lammps_plugin/README.rst +++ b/lammps_plugin/README.rst @@ -58,9 +58,9 @@ To use UF3 potentials in lammps just add the following tags to the lammps input The 'uf3' keyword in :code:`pair_style` invokes the UF3 potentials in lammps. The number next to the :code:`uf3` keyword tells lammps whether the user wants to run the MD code with just 2-body or 2 and 3-body UF3 potentials. The last number of this line specifies the number of elemnts in the system. So in the above example, the user wants to run MD simulation with UF3 potentials containing both 2-body and 3-body interactions on a system containing only 1 element. -The :code:`pair_coeff` tag is used to read in the user-provided UF3 lammps potential files. These files can be generated directly from the :code:`json` potential files of UF3. We recommend using the :code:`generate_uf3_lammps_pots.py` script (`found here `_) for generating the UF3 lammps potential files. It will also additionally print lines that should be added to the lammps input file for using UF3 lammps potential files. +The :code:`pair_coeff` tag is used to read in the user-provided UF3 lammps potential files. These files can be generated directly from the :code:`json` potential files of UF3. We recommend using the :code:`generate_uf3_lammps_pots.py` script (`found here `) for generating the UF3 lammps potential files. It will also additionally print lines that should be added to the lammps input file for using UF3 lammps potential files. **Note, nothing is inferred from the name of the UF3 lammps potential file. The name of the files can be completely arbitrary** -After :code:`pair_coeff` specify the interactions (two numbers for 2-body, three numbers for 3-body) followed by the name of the potential file. The user can also use asterisks:code:`*` for wild-card characters. In this case the behaviour is similar to other LAMMPS :code:`pair_style` for example LJ. The user can also specify. Make sure these files are present in the current run directory or in directories where lammps can find them. +After :code:`pair_coeff` specify the interactions (two numbers for 2-body, three numbers for 3-body) followed by the name of the potential file. The user can also use :code:`*` for wild-card characters. In this case the behaviour is similar to other LAMMPS :code:`pair_style` for example LJ. Make sure these files are present in the current run directory or in directories where lammps can find them. As an example for a multicomponet system containing elements 'A' and 'B' the above lines can be- @@ -77,6 +77,26 @@ As an example for a multicomponet system containing elements 'A' and 'B' the abo pair_coeff 2 1 2 B_A_B pair_coeff 2 2 2 B_B_B + +If potential file is specified for 2-1 interaction (:code:`pair_coeff 2 1 FileName`), the potential for 1-2 interaction is automatically mapped. So, the following lines are also valid- + +.. code:: bash + + pair_style uf3 3 2 + + pair_coeff 2 2 A_A + pair_coeff 1 1 B_B + pair_coeff 2 1 A_B + + pair_coeff 2 2 2 A_A_A + pair_coeff 2 2 1 A_A_B + pair_coeff 2 1 1 A_B_B + + pair_coeff 1 1 1 B_B_B + pair_coeff 1 2 1 B_A_B + pair_coeff 1 2 2 B_A_A + + Following format is also a valid for system containing elements 'A' and 'B' .. code:: bash From 01d33e13c4f720ff37f084a87f1e666e1dc3b795 Mon Sep 17 00:00:00 2001 From: Ajinkya Hire <48733363+monk-04@users.noreply.github.com> Date: Tue, 24 Oct 2023 19:17:56 -0400 Subject: [PATCH 4/4] Update README.rst Fixed hyperlink got generate_uf3_lammps_pots.py --- lammps_plugin/README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lammps_plugin/README.rst b/lammps_plugin/README.rst index ee1cc2b7..cc4cee6b 100644 --- a/lammps_plugin/README.rst +++ b/lammps_plugin/README.rst @@ -58,7 +58,7 @@ To use UF3 potentials in lammps just add the following tags to the lammps input The 'uf3' keyword in :code:`pair_style` invokes the UF3 potentials in lammps. The number next to the :code:`uf3` keyword tells lammps whether the user wants to run the MD code with just 2-body or 2 and 3-body UF3 potentials. The last number of this line specifies the number of elemnts in the system. So in the above example, the user wants to run MD simulation with UF3 potentials containing both 2-body and 3-body interactions on a system containing only 1 element. -The :code:`pair_coeff` tag is used to read in the user-provided UF3 lammps potential files. These files can be generated directly from the :code:`json` potential files of UF3. We recommend using the :code:`generate_uf3_lammps_pots.py` script (`found here `) for generating the UF3 lammps potential files. It will also additionally print lines that should be added to the lammps input file for using UF3 lammps potential files. **Note, nothing is inferred from the name of the UF3 lammps potential file. The name of the files can be completely arbitrary** +The :code:`pair_coeff` tag is used to read in the user-provided UF3 lammps potential files. These files can be generated directly from the :code:`json` potential files of UF3. We recommend using the :code:`generate_uf3_lammps_pots.py` script (`found here `_) for generating the UF3 lammps potential files. It will also additionally print lines that should be added to the lammps input file for using UF3 lammps potential files. **Note, nothing is inferred from the name of the UF3 lammps potential file. The name of the files can be completely arbitrary** After :code:`pair_coeff` specify the interactions (two numbers for 2-body, three numbers for 3-body) followed by the name of the potential file. The user can also use :code:`*` for wild-card characters. In this case the behaviour is similar to other LAMMPS :code:`pair_style` for example LJ. Make sure these files are present in the current run directory or in directories where lammps can find them.