diff --git a/cmake/Modules/CodeCoverage.cmake b/cmake/Modules/CodeCoverage.cmake index d018db43d9..3b323e37ff 100644 --- a/cmake/Modules/CodeCoverage.cmake +++ b/cmake/Modules/CodeCoverage.cmake @@ -15,14 +15,35 @@ if(ENABLE_COVERAGE) gen_coverage_xml COMMAND ${GCOVR_BINARY} -s -x -r ${ABSOLUTE_LAMMPS_SOURCE_DIR} --object-directory=${CMAKE_BINARY_DIR} -o coverage.xml WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - COMMENT "Generating XML Coverage Report..." + COMMENT "Generating XML coverage report..." ) + set(COVERAGE_HTML_DIR ${CMAKE_BINARY_DIR}/coverage_html) + + add_custom_target(coverage_html_folder + COMMAND ${CMAKE_COMMAND} -E make_directory ${COVERAGE_HTML_DIR}) + add_custom_target( gen_coverage_html - COMMAND ${GCOVR_BINARY} -s --html --html-details -r ${ABSOLUTE_LAMMPS_SOURCE_DIR} --object-directory=${CMAKE_BINARY_DIR} -o coverage.html + COMMAND ${GCOVR_BINARY} -s --html --html-details -r ${ABSOLUTE_LAMMPS_SOURCE_DIR} --object-directory=${CMAKE_BINARY_DIR} -o ${COVERAGE_HTML_DIR}/index.html WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - COMMENT "Generating HTML Coverage Report..." + COMMENT "Generating HTML coverage report..." ) + add_dependencies(gen_coverage_html coverage_html_folder) + + add_custom_target(clean_coverage_html + ${CMAKE_COMMAND} -E remove_directory ${COVERAGE_HTML_DIR} + COMMENT "Deleting HTML coverage report..." + ) + + add_custom_target(reset_coverage + ${CMAKE_COMMAND} -E remove -f */*.gcda */*/*.gcda */*/*/*.gcda + */*/*/*/*.gcda */*/*/*/*/*.gcda */*/*/*/*/*/*.gcda + */*/*/*/*/*/*/*.gcda */*/*/*/*/*/*/*/*.gcda + */*/*/*/*/*/*/*/*/*.gcda */*/*/*/*/*/*/*/*/*/*.gcda + WORKIND_DIRECTORY ${CMAKE_BINARY_DIR} + COMMENT "Deleting coverage data files..." + ) + add_dependencies(reset_coverage clean_coverage_html) endif() endif() diff --git a/doc/src/Build_cmake.rst b/doc/src/Build_cmake.rst index 3473d83143..52a240176f 100644 --- a/doc/src/Build_cmake.rst +++ b/doc/src/Build_cmake.rst @@ -107,7 +107,7 @@ re-compile and relink the LAMMPS executable with ``cmake --build .`` (or ``cmake .`` and then compile again. The included dependency tracking should make certain that only the necessary subset of files are re-compiled. You can also delete compiled objects, libraries and -executables with ``cmake --build . clean`` (or ``make clean``). +executables with ``cmake --build . --target clean`` (or ``make clean``). After compilation, you may optionally install the LAMMPS executable into your system with: diff --git a/doc/src/Build_development.rst b/doc/src/Build_development.rst index e55d00340f..94b78a4a9c 100644 --- a/doc/src/Build_development.rst +++ b/doc/src/Build_development.rst @@ -75,9 +75,9 @@ The unit testing facility is integrated into the CMake build process of the LAMMPS source code distribution itself. It can be enabled by setting ``-D ENABLE_TESTING=on`` during the CMake configuration step. It requires the `YAML `_ library and development -headers to compile and will download and compile the +headers to compile and will download and compile a recent version of the `Googletest `_ C++ test framework -for programming the tests. +for implementing the tests. After compilation is complete, the unit testing is started in the build folder using the ``ctest`` command, which is part of the CMake software. @@ -100,6 +100,30 @@ The output of this command will be looking something like this:: Total Test time (real) = 0.27 sec + +The ``ctest`` command has many options, the most important ones are: + +.. list-table:: + + * - Option + - Function + * - -V + - verbose output: display output of individual test runs + * - -j + - parallel run: run tests in parallel + * - -R + - run subset of tests matching the regular expression + * - -E + - exclude subset of tests matching the regular expression + * - -N + - dry-run: display list of tests without running them + +In its full implementation, the unit test framework will consist of multiple +kinds of tests implemented in different programming languages (C++, C, Python, +Fortran) and testing different aspects of the LAMMPS software and its features. +At the moment only tests for "force styles" are implemented. More on those +in the next section. + .. note:: This unit test framework is new and still under development. @@ -114,22 +138,141 @@ The output of this command will be looking something like this:: the contents of the YAML files for existing test programs will be provided in time as well. ------------- +Unit tests for force styles +^^^^^^^^^^^^^^^^^^^^^^^^^^^ -You can also collect code coverage metrics while running the tests by -enabling coverage support during building. +A large part of LAMMPS are different "styles" for computing non-bonded +and bonded interactions selected through the :doc:`pair_style`, +:doc:`bond_style`, :doc:`angle_style`, :doc:`dihedral_style`, +:doc:`improper_style`, and :doc:`kspace_style`. Since these all share +common interfaces, it is possible to write generic test programs that +will call those common interfaces for small test systems with less than +100 atoms and compare the results with pre-recorded reference results. +A test run is then a a collection multiple individual test runs each +with many comparisons to reference results based on template input +files, individual command settings, relative error margins, and +reference data stored in a YAML format file with ``.yaml`` +suffix. Currently the programs ``pair_style``, ``bond_style``, and +``angle_style`` are implemented. They will compare forces, energies and +(global) stress for all atoms after a ``run 0`` calculation and after a +few steps of MD with :doc:`fix nve `, each in multiple variants +with different settings and also for multiple accelerated styles. If a +prerequisite style or package is missing, the individual tests are +skipped. All tests will be executed on a single MPI process, so using +the CMake option ``-D BUILD_MPI=off`` can significantly speed up testing, +since this will skip the MPI initialization for each test run. +Below is an example command and output: + +.. parsed-literal:: + + [tests]$ pair_style mol-pair-lj_cut.yaml + [==========] Running 6 tests from 1 test suite. + [----------] Global test environment set-up. + [----------] 6 tests from PairStyle + [ RUN ] PairStyle.plain + [ OK ] PairStyle.plain (24 ms) + [ RUN ] PairStyle.omp + [ OK ] PairStyle.omp (18 ms) + [ RUN ] PairStyle.intel + [ OK ] PairStyle.intel (6 ms) + [ RUN ] PairStyle.opt + [ SKIPPED ] PairStyle.opt (0 ms) + [ RUN ] PairStyle.single + [ OK ] PairStyle.single (7 ms) + [ RUN ] PairStyle.extract + [ OK ] PairStyle.extract (6 ms) + [----------] 6 tests from PairStyle (62 ms total) + + [----------] Global test environment tear-down + [==========] 6 tests from 1 test suite ran. (63 ms total) + [ PASSED ] 5 tests. + [ SKIPPED ] 1 test, listed below: + [ SKIPPED ] PairStyle.opt + +In this particular case, 5 out of 6 sets of tests were conducted, the +tests for the ``lj/cut/opt`` pair style was skipped, since the tests +executable did not include it. To learn what individual tests are performed, +you (currently) need to read the source code. You can use code coverage +recording (see next section) to confirm how well the tests cover the individual +source files. + +The force style test programs have a common set of options: + +.. list-table:: + + * - Option + - Function + * - -g + - regenerate reference data in new YAML file + * - -u + - update reference data in the original YAML file + * - -s + - print error statistics for each group of comparisons + * - -v + - verbose output: also print the executed LAMMPS commands + +To add a test for a style that is not yet covered, it is usually best +to copy a YAML file for a similar style to a new file, edit the details +of the style (how to call it, how to set its coefficients) and then +run test command with either the *-g* and the replace the initial +test file with the regenerated one or the *-u* option. The *-u* option +will destroy the original file, if the generation run does not complete, +so using *-g* is recommended unless the YAML file is fully tested +and working. + +.. admonition:: Recommendations and notes for YAML files + :class: note + + - The reference results should be recorded without any code + optimization or related compiler flags enabled. + - The ``epsilon`` parameter defines the relative precision with which + the reference results must be met. The test geometries often have + high and low energy parts and thus a significant impact from + floating-point math truncation errors is to be expected. Some + functional forms and potentials are more noisy than others, so this + parameter needs to be adjusted. Typically a value around 1.0e-13 + can be used, but it may need to be as large as 1.0e-8 in some + cases. + - The tests for pair styles from OPT, USER-OMP and USER-INTEL are + performed with automatically rescaled epsilon to account for + additional loss of precision from code optimizations and different + summation orders. + - When compiling with aggressive compiler optimization, some tests + are likely to fail. It is recommended to inspect the individual + tests in detail to decide whether the specific error for a specific + property is acceptable (it often is), or this may be an indication + of mis-compiled code (or undesired large of precision due to + reordering of operations). + +Collect and visualize code coverage metrics +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +You can also collect code coverage metrics while running LAMMPS or the +tests by enabling code coverage support during the CMake configuration: .. code-block:: bash - -D ENABLE_COVERAGE=value # enable coverage measurements, value = no (default) or yes + -D ENABLE_COVERAGE=on # enable coverage measurements (off by default) -This will also add the following targets to generate coverage reports -after running the LAMMPS executable or the unit tests: +This will instrument all object files to write information about which +lines of code were accessed during execution in files next to the +corresponding object files. These can be post-processed to visually +show the degree of coverage and which code paths are accessed and which +are not taken. When working on unit tests (see above), this can be +extremely helpful to determine which parts of the code are not executed +and thus what kind of tests are still missing. The coverage data is +cumulative, i.e. new data is added with each new run. + +Enabling code coverage will also add the following build targets to +generate coverage reports after running the LAMMPS executable or the +unit tests: .. code-block:: bash - make gen_coverage_html # generate coverage report in HTML format - make gen_coverage_xml # generate coverage report in XML format + make gen_coverage_html # generate coverage report in HTML format + make gen_coverage_xml # generate coverage report in XML format + make clean_coverage_html # delete folder with HTML format coverage report + make reset_coverage # delete all collected coverage data and HTML output These reports require `GCOVR `_ to be installed. The easiest way to do this to install it via pip: @@ -137,3 +280,29 @@ to do this to install it via pip: .. code-block:: bash pip install git+https://github.com/gcovr/gcovr.git + +After post-processing with ``gen_coverage_html`` the results are in +a folder ``coverage_html`` and can be viewed with a web browser. +The images below illustrate how the data is presented. + +.. list-table:: + + * - .. figure:: JPG/coverage-overview-top.png + :target: JPG/coverage-overview-top.png + + Top of the overview page + + - .. figure:: JPG/coverage-overview-manybody.png + :target: JPG/coverage-overview-manybody.png + + Styles with good coverage + + - .. figure:: JPG/coverage-file-top.png + :target: JPG/coverage-file-top.png + + Top of individual source page + + - .. figure:: JPG/coverage-file-branches.png + :target: JPG/coverage-file-branches.png + + Source page with branches diff --git a/doc/src/Commands_pair.rst b/doc/src/Commands_pair.rst index b176e22a85..eac38af668 100644 --- a/doc/src/Commands_pair.rst +++ b/doc/src/Commands_pair.rst @@ -92,8 +92,8 @@ OPT. * :doc:`drip ` * :doc:`eam (gikot) ` * :doc:`eam/alloy (gikot) ` - * :doc:`eam/cd (o) ` - * :doc:`eam/cd/old (o) ` + * :doc:`eam/cd ` + * :doc:`eam/cd/old ` * :doc:`eam/fs (gikot) ` * :doc:`edip (o) ` * :doc:`edip/multi ` diff --git a/doc/src/Howto_cmake.rst b/doc/src/Howto_cmake.rst index fa6038efb5..9028893ddb 100644 --- a/doc/src/Howto_cmake.rst +++ b/doc/src/Howto_cmake.rst @@ -415,8 +415,10 @@ This is particularly convenient, if you have set a custom build command via the ``CMAKE_MAKE_PROGRAM`` variable. When calling the build program, you can also select which "target" is to -be build through appending the name of the target to the build command. -Example: ``cmake --build . all``. The following abstract targets are available: +be build through appending the ``--target`` flag and the name of the target +to the build command. When using ``make`` as build tool, you can just append +the target name to the command. Example: ``cmake --build . --target all`` or +``make all``. The following abstract targets are available: .. list-table:: :header-rows: 1 @@ -432,7 +434,7 @@ Example: ``cmake --build . all``. The following abstract targets are available: * - ``install`` - install all target files into folders in ``CMAKE_INSTALL_PREFIX`` * - ``test`` - - run some simple tests (if configured with ``-D ENABLE_TESTING=on``) + - run some tests (if configured with ``-D ENABLE_TESTING=on``) * - ``clean`` - remove all generated files diff --git a/doc/src/JPG/coverage-file-branches.png b/doc/src/JPG/coverage-file-branches.png new file mode 100644 index 0000000000..8bf3b6eefd Binary files /dev/null and b/doc/src/JPG/coverage-file-branches.png differ diff --git a/doc/src/JPG/coverage-file-top.png b/doc/src/JPG/coverage-file-top.png new file mode 100644 index 0000000000..cc834be27f Binary files /dev/null and b/doc/src/JPG/coverage-file-top.png differ diff --git a/doc/src/JPG/coverage-overview-manybody.png b/doc/src/JPG/coverage-overview-manybody.png new file mode 100644 index 0000000000..85fad27f74 Binary files /dev/null and b/doc/src/JPG/coverage-overview-manybody.png differ diff --git a/doc/src/JPG/coverage-overview-top.png b/doc/src/JPG/coverage-overview-top.png new file mode 100644 index 0000000000..e57486a293 Binary files /dev/null and b/doc/src/JPG/coverage-overview-top.png differ diff --git a/doc/src/pair_eam.rst b/doc/src/pair_eam.rst index 7384a4d54c..c93c694833 100644 --- a/doc/src/pair_eam.rst +++ b/doc/src/pair_eam.rst @@ -39,15 +39,9 @@ pair_style eam/alloy/opt command pair_style eam/cd command ========================= -pair_style eam/cd/omp command -============================= - pair_style eam/cd/old command ============================= -pair_style eam/cd/old/omp command -================================= - pair_style eam/fs command ========================= diff --git a/doc/utils/sphinx-config/false_positives.txt b/doc/utils/sphinx-config/false_positives.txt index 3d9f3ddcc9..bb2fac1492 100644 --- a/doc/utils/sphinx-config/false_positives.txt +++ b/doc/utils/sphinx-config/false_positives.txt @@ -1985,6 +1985,7 @@ Neumann Nevent nevery Nevery +newfile Newns newtype Neyts diff --git a/potentials/ffield.comb b/potentials/ffield.comb index 0ff3c16835..9edc478afd 100644 --- a/potentials/ffield.comb +++ b/potentials/ffield.comb @@ -19,13 +19,13 @@ # 27 entries for a system containing three elements A, B and C # These entries are in LAMMPS "metal" units # -Hf Hf Hf 1 0 1 0 1.011011 0.046511 0.959614 0.959614 55.9421 55.9421 3.85 0.20 2.069563 2.069563 707.53 707.53 0 0 0.008 0 0 0 1 1 1 1 -4 4 0.26152 -0.25918 -4 4 0.26152 -0.25918 0 3.139520d0 0 0.009410d0 0 0.679131 -3.92875 -3.92875 4.83958 4.83958 12 0 +Hf Hf Hf 1 0 1 0 1.011011 0.046511 0.959614 0.959614 55.9421 55.9421 3.85 0.20 2.069563 2.069563 707.53 707.53 0 0 0.008 0 0 0 1 1 1 1 -4 4 0.26152 -0.25918 -4 4 0.26152 -0.25918 0 3.139520 0 0.009410 0 0.679131 -3.92875 -3.92875 4.83958 4.83958 12 0 Ti Ti Ti 1 0 1 0 1.255016 0.089078 1.226342 1.226342 99.3916 99.3916 3.43 0.05 2.082408 2.082408 546.386 546.386 0 0 0.0084 0 0 0 1 1 1 1 -4 4 2.508854 -2.511416 -4 4 2.508854 -2.511416 0 2.46820415900968 0 0.151351003255176 0 0.873685 0.392632 0.392632 1.78349 1.78349 12 0 O O O 1 6.6 1 -0.229 1 2 2.68 2.68 260.893 260.893 2.8 0.2 5.36 5.36 3326.69 3326.69 0 0 0 0 0 0 1 1 1 1 -1.8349 5.5046 0.00148 -0.00112 -1.8349 5.5046 0.00148 -0.00112 5.63441383 7.689598017 4.51426991 1.330079082 0 2.243072 -3.922011 -3.922011 0.971086 0.971086 12 0 Cu Cu Cu 1 0 1 0 1 0.140835 1.681711 1.681711 146.987 146.987 3.0 0.05 2.794608 2.794608 952.693 952.693 0.077 0.0095 0 0 0 0 1 1 1 1 -6 2 0.1677645 -0.161007 -6 2 0.1677645 -0.161007 0 5.946437 0 0 0 0.454784 0.72571 0.72571 0.274649 0.274649 12 0 Si Si Si 3 100390 16.218 -0.59826 0.78734 1.0999E-06 1.7322 1.7322 471.18 471.18 2.90 0.10 2.4799 2.4799 1830.8 1830.8 0 0 0 0 0 0 1 1 1 1 -4 4 1.651725 -1.658949 -4 4 1.651725 -1.658949 0 3.625144859 0 0.087067714 0 0.772871 -0.499378 -0.499378 2.999911 2.999911 12 0 -Zr Zr Zr 1 0 1 0 1 0 0.929 0.929 39.9454 39.9454 3.8 0.31 1.857 1.857 382.6 382.6 0 0 0 0 0 0 1 1 1 1 -4 4 1.64 -1.5 -4 4 1.64 -1.5 0 3.139520d0 0 0.009410d0 0 0.679131 -3.92875 -3.92875 4.83958 4.83958 12 0 -U U U 1 0 1 0 4.346966 0.77617 0.832 0.832 162.6 162.6 3.9 0.15 1.835 1.835 795.6 795.6 0 0 0 0 0 0 1 1 1 1 -4 4 2 -2 -4 4 2 -2 0 3.139520d0 0 0.009410d0 0 0.679131 -3.92875 -3.92875 4.83958 4.83958 12 0 +Zr Zr Zr 1 0 1 0 1 0 0.929 0.929 39.9454 39.9454 3.8 0.31 1.857 1.857 382.6 382.6 0 0 0 0 0 0 1 1 1 1 -4 4 1.64 -1.5 -4 4 1.64 -1.5 0 3.139520 0 0.009410 0 0.679131 -3.92875 -3.92875 4.83958 4.83958 12 0 +U U U 1 0 1 0 4.346966 0.77617 0.832 0.832 162.6 162.6 3.9 0.15 1.835 1.835 795.6 795.6 0 0 0 0 0 0 1 1 1 1 -4 4 2 -2 -4 4 2 -2 0 3.139520 0 0.009410 0 0.679131 -3.92875 -3.92875 4.83958 4.83958 12 0 # Si O O 3 100390 16.218 -0.59826 0.78734 1.0999E-06 1.7322 2.68 471.18 260.893 2.80 0.25 2.4799 5.36 1830.8 3326.69 0 0 0 109.47 0.3122 0 1 1 1 1 -4 4 1.651725 -1.658949 -1.8349 5.5046 0.00148 -0.00112 0 3.625144859 0 0.087067714 0 0.772871 -0.499378 -3.922011 2.999911 0.971086 12 0 O Si Si 1 6.6 1 -0.229 1 2 2.68 1.7322 260.893 471.18 2.80 0.25 5.36 2.4799 3326.69 1830.8 0 0 0 143.73 2.6 0 1 1 1 1 -1.8349 5.5046 0.00148 -0.00112 -4 4 1.651725 -1.658949 5.63441383 7.689598017 4.51426991 1.330079082 0 2.243072 -3.922011 -0.499378 0.971086 2.999911 12 0 diff --git a/src/GPU/pair_eam_alloy_gpu.cpp b/src/GPU/pair_eam_alloy_gpu.cpp index 266a79bc3c..fcbc3c5d3c 100644 --- a/src/GPU/pair_eam_alloy_gpu.cpp +++ b/src/GPU/pair_eam_alloy_gpu.cpp @@ -31,11 +31,11 @@ #include "domain.h" #include "utils.h" #include "suffix.h" +#include "tokenizer.h" +#include "potential_file_reader.h" using namespace LAMMPS_NS; -#define MAXLINE 1024 - // External functions from cuda library for atom decomposition int eam_alloy_gpu_init(const int ntypes, double host_cutforcesq, @@ -369,94 +369,112 @@ void PairEAMAlloyGPU::read_file(char *filename) { Setfl *file = setfl; - // open potential file + // read potential file + if(comm->me == 0) { + PotentialFileReader reader(lmp, filename, "EAM"); - int me = comm->me; - FILE *fptr; - char line[MAXLINE]; + try { + char * line = nullptr; - if (me == 0) { - fptr = fopen(filename,"r"); - if (fptr == NULL) { - char str[128]; - snprintf(str,128,"Cannot open EAM potential file %s",filename); - error->one(FLERR,str); + reader.skip_line(); + reader.skip_line(); + reader.skip_line(); + + // extract element names from nelements line + line = reader.next_line(1); + ValueTokenizer values(line); + file->nelements = values.next_int(); + + if (values.count() != file->nelements + 1) + error->one(FLERR,"Incorrect element names in EAM potential file"); + + file->elements = new char*[file->nelements]; + for (int i = 0; i < file->nelements; i++) { + const std::string word = values.next_string(); + const int n = word.length() + 1; + file->elements[i] = new char[n]; + strcpy(file->elements[i], word.c_str()); + } + + // + + line = reader.next_line(5); + values = ValueTokenizer(line); + file->nrho = values.next_int(); + file->drho = values.next_double(); + file->nr = values.next_int(); + file->dr = values.next_double(); + file->cut = values.next_double(); + + if ((file->nrho <= 0) || (file->nr <= 0) || (file->dr <= 0.0)) + error->one(FLERR,"Invalid EAM potential file"); + + memory->create(file->mass, file->nelements, "pair:mass"); + memory->create(file->frho, file->nelements, file->nrho + 1, "pair:frho"); + memory->create(file->rhor, file->nelements, file->nr + 1, "pair:rhor"); + memory->create(file->z2r, file->nelements, file->nelements, file->nr + 1, "pair:z2r"); + + for (int i = 0; i < file->nelements; i++) { + line = reader.next_line(2); + values = ValueTokenizer(line); + values.next_int(); // ignore + file->mass[i] = values.next_double(); + + reader.next_dvector(file->nrho, &file->frho[i][1]); + reader.next_dvector(file->nr, &file->rhor[i][1]); + } + + for (int i = 0; i < file->nelements; i++) { + for (int j = 0; j <= i; j++) { + reader.next_dvector(file->nr, &file->z2r[i][j][1]); + } + } + } catch (TokenizerException & e) { + error->one(FLERR, e.what()); } } - // read and broadcast header - // extract element names from nelements line + // broadcast potential information + MPI_Bcast(&file->nelements, 1, MPI_INT, 0, world); - int n; - if (me == 0) { - utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error); - utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error); - utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error); - utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error); - n = strlen(line) + 1; + MPI_Bcast(&file->nrho, 1, MPI_INT, 0, world); + MPI_Bcast(&file->drho, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->nr, 1, MPI_INT, 0, world); + MPI_Bcast(&file->dr, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->cut, 1, MPI_DOUBLE, 0, world); + + // allocate memory on other procs + if (comm->me != 0) { + file->elements = new char*[file->nelements]; + for (int i = 0; i < file->nelements; i++) file->elements[i] = nullptr; + memory->create(file->mass, file->nelements, "pair:mass"); + memory->create(file->frho, file->nelements, file->nrho + 1, "pair:frho"); + memory->create(file->rhor, file->nelements, file->nr + 1, "pair:rhor"); + memory->create(file->z2r, file->nelements, file->nelements, file->nr + 1, "pair:z2r"); } - MPI_Bcast(&n,1,MPI_INT,0,world); - MPI_Bcast(line,n,MPI_CHAR,0,world); - sscanf(line,"%d",&file->nelements); - int nwords = atom->count_words(line); - if (nwords != file->nelements + 1) - error->all(FLERR,"Incorrect element names in EAM potential file"); - - char **words = new char*[file->nelements+1]; - nwords = 0; - strtok(line," \t\n\r\f"); - while ( (words[nwords++] = strtok(NULL," \t\n\r\f")) ) continue; - - file->elements = new char*[file->nelements]; + // broadcast file->elements string array for (int i = 0; i < file->nelements; i++) { - n = strlen(words[i]) + 1; - file->elements[i] = new char[n]; - strcpy(file->elements[i],words[i]); - } - delete [] words; - - if (me == 0) { - utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error); - sscanf(line,"%d %lg %d %lg %lg", - &file->nrho,&file->drho,&file->nr,&file->dr,&file->cut); + int n; + if (comm->me == 0) n = strlen(file->elements[i]) + 1; + MPI_Bcast(&n, 1, MPI_INT, 0, world); + if (comm->me != 0) file->elements[i] = new char[n]; + MPI_Bcast(file->elements[i], n, MPI_CHAR, 0, world); } - MPI_Bcast(&file->nrho,1,MPI_INT,0,world); - MPI_Bcast(&file->drho,1,MPI_DOUBLE,0,world); - MPI_Bcast(&file->nr,1,MPI_INT,0,world); - MPI_Bcast(&file->dr,1,MPI_DOUBLE,0,world); - MPI_Bcast(&file->cut,1,MPI_DOUBLE,0,world); + // broadcast file->mass, frho, rhor + for (int i = 0; i < file->nelements; i++) { + MPI_Bcast(&file->mass[i], 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->frho[i][1], file->nrho, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->rhor[i][1], file->nr, MPI_DOUBLE, 0, world); + } - file->mass = new double[file->nelements]; - memory->create(file->frho,file->nelements,file->nrho+1,"pair:frho"); - memory->create(file->rhor,file->nelements,file->nr+1,"pair:rhor"); - memory->create(file->z2r,file->nelements,file->nelements,file->nr+1, - "pair:z2r"); - - int i,j,tmp; - for (i = 0; i < file->nelements; i++) { - if (me == 0) { - utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error); - sscanf(line,"%d %lg",&tmp,&file->mass[i]); + // broadcast file->z2r + for (int i = 0; i < file->nelements; i++) { + for (int j = 0; j <= i; j++) { + MPI_Bcast(&file->z2r[i][j][1], file->nr, MPI_DOUBLE, 0, world); } - MPI_Bcast(&file->mass[i],1,MPI_DOUBLE,0,world); - - if (me == 0) grab(fptr,file->nrho,&file->frho[i][1]); - MPI_Bcast(&file->frho[i][1],file->nrho,MPI_DOUBLE,0,world); - if (me == 0) grab(fptr,file->nr,&file->rhor[i][1]); - MPI_Bcast(&file->rhor[i][1],file->nr,MPI_DOUBLE,0,world); } - - for (i = 0; i < file->nelements; i++) - for (j = 0; j <= i; j++) { - if (me == 0) grab(fptr,file->nr,&file->z2r[i][j][1]); - MPI_Bcast(&file->z2r[i][j][1],file->nr,MPI_DOUBLE,0,world); - } - - // close the potential file - - if (me == 0) fclose(fptr); } /* ---------------------------------------------------------------------- diff --git a/src/GPU/pair_eam_fs_gpu.cpp b/src/GPU/pair_eam_fs_gpu.cpp index 2bd5a53324..e674594498 100644 --- a/src/GPU/pair_eam_fs_gpu.cpp +++ b/src/GPU/pair_eam_fs_gpu.cpp @@ -30,11 +30,12 @@ #include "gpu_extra.h" #include "domain.h" #include "suffix.h" +#include "utils.h" +#include "tokenizer.h" +#include "potential_file_reader.h" using namespace LAMMPS_NS; -#define MAXLINE 1024 - // External functions from cuda library for atom decomposition int eam_fs_gpu_init(const int ntypes, double host_cutforcesq, @@ -368,99 +369,118 @@ void PairEAMFSGPU::read_file(char *filename) { Fs *file = fs; - // open potential file + // read potential file + if(comm->me == 0) { + PotentialFileReader reader(lmp, filename, "EAM"); - int me = comm->me; - FILE *fptr; - char line[MAXLINE]; + try { + char * line = nullptr; - if (me == 0) { - fptr = force->open_potential(filename); - if (fptr == NULL) { - char str[128]; - snprintf(str,128,"Cannot open EAM potential file %s",filename); - error->one(FLERR,str); + reader.skip_line(); + reader.skip_line(); + reader.skip_line(); + + // extract element names from nelements line + line = reader.next_line(1); + ValueTokenizer values(line); + file->nelements = values.next_int(); + + if (values.count() != file->nelements + 1) + error->one(FLERR,"Incorrect element names in EAM potential file"); + + file->elements = new char*[file->nelements]; + for (int i = 0; i < file->nelements; i++) { + const std::string word = values.next_string(); + const int n = word.length() + 1; + file->elements[i] = new char[n]; + strcpy(file->elements[i], word.c_str()); + } + + // + + line = reader.next_line(5); + values = ValueTokenizer(line); + file->nrho = values.next_int(); + file->drho = values.next_double(); + file->nr = values.next_int(); + file->dr = values.next_double(); + file->cut = values.next_double(); + + if ((file->nrho <= 0) || (file->nr <= 0) || (file->dr <= 0.0)) + error->one(FLERR,"Invalid EAM potential file"); + + memory->create(file->mass, file->nelements, "pair:mass"); + memory->create(file->frho, file->nelements, file->nrho + 1, "pair:frho"); + memory->create(file->rhor, file->nelements, file->nelements, file->nr + 1, "pair:rhor"); + memory->create(file->z2r, file->nelements, file->nelements, file->nr + 1, "pair:z2r"); + + for (int i = 0; i < file->nelements; i++) { + line = reader.next_line(2); + values = ValueTokenizer(line); + values.next_int(); // ignore + file->mass[i] = values.next_double(); + + reader.next_dvector(file->nrho, &file->frho[i][1]); + + for (int j = 0; j < file->nelements; j++) { + reader.next_dvector(file->nr, &file->rhor[i][j][1]); + } + } + + for (int i = 0; i < file->nelements; i++) { + for (int j = 0; j <= i; j++) { + reader.next_dvector(file->nr, &file->z2r[i][j][1]); + } + } + } catch (TokenizerException & e) { + error->one(FLERR, e.what()); } } - // read and broadcast header - // extract element names from nelements line + // broadcast potential information + MPI_Bcast(&file->nelements, 1, MPI_INT, 0, world); - int n; - if (me == 0) { - fgets(line,MAXLINE,fptr); - fgets(line,MAXLINE,fptr); - fgets(line,MAXLINE,fptr); - fgets(line,MAXLINE,fptr); - n = strlen(line) + 1; + MPI_Bcast(&file->nrho, 1, MPI_INT, 0, world); + MPI_Bcast(&file->drho, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->nr, 1, MPI_INT, 0, world); + MPI_Bcast(&file->dr, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->cut, 1, MPI_DOUBLE, 0, world); + + // allocate memory on other procs + if (comm->me != 0) { + file->elements = new char*[file->nelements]; + for (int i = 0; i < file->nelements; i++) file->elements[i] = nullptr; + memory->create(file->mass, file->nelements, "pair:mass"); + memory->create(file->frho, file->nelements, file->nrho + 1, "pair:frho"); + memory->create(file->rhor, file->nelements, file->nelements, file->nr + 1, "pair:rhor"); + memory->create(file->z2r, file->nelements, file->nelements, file->nr + 1, "pair:z2r"); } - MPI_Bcast(&n,1,MPI_INT,0,world); - MPI_Bcast(line,n,MPI_CHAR,0,world); - sscanf(line,"%d",&file->nelements); - int nwords = atom->count_words(line); - if (nwords != file->nelements + 1) - error->all(FLERR,"Incorrect element names in EAM potential file"); - - char **words = new char*[file->nelements+1]; - nwords = 0; - strtok(line," \t\n\r\f"); - while ((words[nwords++] = strtok(NULL," \t\n\r\f"))) continue; - - file->elements = new char*[file->nelements]; + // broadcast file->elements string array for (int i = 0; i < file->nelements; i++) { - n = strlen(words[i]) + 1; - file->elements[i] = new char[n]; - strcpy(file->elements[i],words[i]); - } - delete [] words; - - if (me == 0) { - fgets(line,MAXLINE,fptr); - sscanf(line,"%d %lg %d %lg %lg", - &file->nrho,&file->drho,&file->nr,&file->dr,&file->cut); + int n; + if (comm->me == 0) n = strlen(file->elements[i]) + 1; + MPI_Bcast(&n, 1, MPI_INT, 0, world); + if (comm->me != 0) file->elements[i] = new char[n]; + MPI_Bcast(file->elements[i], n, MPI_CHAR, 0, world); } - MPI_Bcast(&file->nrho,1,MPI_INT,0,world); - MPI_Bcast(&file->drho,1,MPI_DOUBLE,0,world); - MPI_Bcast(&file->nr,1,MPI_INT,0,world); - MPI_Bcast(&file->dr,1,MPI_DOUBLE,0,world); - MPI_Bcast(&file->cut,1,MPI_DOUBLE,0,world); + // broadcast file->mass, frho, rhor + for (int i = 0; i < file->nelements; i++) { + MPI_Bcast(&file->mass[i], 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->frho[i][1], file->nrho, MPI_DOUBLE, 0, world); - file->mass = new double[file->nelements]; - memory->create(file->frho,file->nelements,file->nrho+1, - "pair:frho"); - memory->create(file->rhor,file->nelements,file->nelements, - file->nr+1,"pair:rhor"); - memory->create(file->z2r,file->nelements,file->nelements, - file->nr+1,"pair:z2r"); - - int i,j,tmp; - for (i = 0; i < file->nelements; i++) { - if (me == 0) { - fgets(line,MAXLINE,fptr); - sscanf(line,"%d %lg",&tmp,&file->mass[i]); - } - MPI_Bcast(&file->mass[i],1,MPI_DOUBLE,0,world); - - if (me == 0) grab(fptr,file->nrho,&file->frho[i][1]); - MPI_Bcast(&file->frho[i][1],file->nrho,MPI_DOUBLE,0,world); - - for (j = 0; j < file->nelements; j++) { - if (me == 0) grab(fptr,file->nr,&file->rhor[i][j][1]); - MPI_Bcast(&file->rhor[i][j][1],file->nr,MPI_DOUBLE,0,world); + for (int j = 0; j < file->nelements; j++) { + MPI_Bcast(&file->rhor[i][j][1], file->nr, MPI_DOUBLE, 0, world); } } - for (i = 0; i < file->nelements; i++) - for (j = 0; j <= i; j++) { - if (me == 0) grab(fptr,file->nr,&file->z2r[i][j][1]); - MPI_Bcast(&file->z2r[i][j][1],file->nr,MPI_DOUBLE,0,world); + // broadcast file->z2r + for (int i = 0; i < file->nelements; i++) { + for (int j = 0; j <= i; j++) { + MPI_Bcast(&file->z2r[i][j][1], file->nr, MPI_DOUBLE, 0, world); } - - // close the potential file - - if (me == 0) fclose(fptr); + } } /* ---------------------------------------------------------------------- diff --git a/src/KIM/kim_property.cpp b/src/KIM/kim_property.cpp index d2f1d145c9..4e63a25ffb 100644 --- a/src/KIM/kim_property.cpp +++ b/src/KIM/kim_property.cpp @@ -464,7 +464,8 @@ void kimProperty::command(int narg, char **arg) error->one(FLERR, "Error Python `kim_property_dump` function " "evaluation failed!"); } - } + } else + pValue = NULL; // Destroy the variable kim_str_cmd[1] = const_cast("delete"); diff --git a/src/KOKKOS/pair_eam_alloy_kokkos.cpp b/src/KOKKOS/pair_eam_alloy_kokkos.cpp index 1963722d86..7f598f966d 100644 --- a/src/KOKKOS/pair_eam_alloy_kokkos.cpp +++ b/src/KOKKOS/pair_eam_alloy_kokkos.cpp @@ -29,11 +29,12 @@ #include "memory_kokkos.h" #include "error.h" #include "atom_masks.h" +#include "utils.h" +#include "tokenizer.h" +#include "potential_file_reader.h" using namespace LAMMPS_NS; -#define MAXLINE 1024 - // Cannot use virtual inheritance on the GPU, so must duplicate code /* ---------------------------------------------------------------------- */ @@ -982,94 +983,112 @@ void PairEAMAlloyKokkos::read_file(char *filename) { Setfl *file = setfl; - // open potential file + // read potential file + if(comm->me == 0) { + PotentialFileReader reader(lmp, filename, "EAM"); - int me = comm->me; - FILE *fptr; - char line[MAXLINE]; + try { + char * line = nullptr; - if (me == 0) { - fptr = force->open_potential(filename); - if (fptr == NULL) { - char str[128]; - snprintf(str,128,"Cannot open EAM potential file %s",filename); - error->one(FLERR,str); + reader.skip_line(); + reader.skip_line(); + reader.skip_line(); + + // extract element names from nelements line + line = reader.next_line(1); + ValueTokenizer values(line); + file->nelements = values.next_int(); + + if (values.count() != file->nelements + 1) + error->one(FLERR,"Incorrect element names in EAM potential file"); + + file->elements = new char*[file->nelements]; + for (int i = 0; i < file->nelements; i++) { + const std::string word = values.next_string(); + const int n = word.length() + 1; + file->elements[i] = new char[n]; + strcpy(file->elements[i], word.c_str()); + } + + // + + line = reader.next_line(5); + values = ValueTokenizer(line); + file->nrho = values.next_int(); + file->drho = values.next_double(); + file->nr = values.next_int(); + file->dr = values.next_double(); + file->cut = values.next_double(); + + if ((file->nrho <= 0) || (file->nr <= 0) || (file->dr <= 0.0)) + error->one(FLERR,"Invalid EAM potential file"); + + memory->create(file->mass, file->nelements, "pair:mass"); + memory->create(file->frho, file->nelements, file->nrho + 1, "pair:frho"); + memory->create(file->rhor, file->nelements, file->nr + 1, "pair:rhor"); + memory->create(file->z2r, file->nelements, file->nelements, file->nr + 1, "pair:z2r"); + + for (int i = 0; i < file->nelements; i++) { + line = reader.next_line(2); + values = ValueTokenizer(line); + values.next_int(); // ignore + file->mass[i] = values.next_double(); + + reader.next_dvector(file->nrho, &file->frho[i][1]); + reader.next_dvector(file->nr, &file->rhor[i][1]); + } + + for (int i = 0; i < file->nelements; i++) { + for (int j = 0; j <= i; j++) { + reader.next_dvector(file->nr, &file->z2r[i][j][1]); + } + } + } catch (TokenizerException & e) { + error->one(FLERR, e.what()); } } - // read and broadcast header - // extract element names from nelements line + // broadcast potential information + MPI_Bcast(&file->nelements, 1, MPI_INT, 0, world); - int n; - if (me == 0) { - fgets(line,MAXLINE,fptr); - fgets(line,MAXLINE,fptr); - fgets(line,MAXLINE,fptr); - fgets(line,MAXLINE,fptr); - n = strlen(line) + 1; + MPI_Bcast(&file->nrho, 1, MPI_INT, 0, world); + MPI_Bcast(&file->drho, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->nr, 1, MPI_INT, 0, world); + MPI_Bcast(&file->dr, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->cut, 1, MPI_DOUBLE, 0, world); + + // allocate memory on other procs + if (comm->me != 0) { + file->elements = new char*[file->nelements]; + for (int i = 0; i < file->nelements; i++) file->elements[i] = nullptr; + memory->create(file->mass, file->nelements, "pair:mass"); + memory->create(file->frho, file->nelements, file->nrho + 1, "pair:frho"); + memory->create(file->rhor, file->nelements, file->nr + 1, "pair:rhor"); + memory->create(file->z2r, file->nelements, file->nelements, file->nr + 1, "pair:z2r"); } - MPI_Bcast(&n,1,MPI_INT,0,world); - MPI_Bcast(line,n,MPI_CHAR,0,world); - sscanf(line,"%d",&file->nelements); - int nwords = atom->count_words(line); - if (nwords != file->nelements + 1) - error->all(FLERR,"Incorrect element names in EAM potential file"); - - char **words = new char*[file->nelements+1]; - nwords = 0; - strtok(line," \t\n\r\f"); - while ((words[nwords++] = strtok(NULL," \t\n\r\f"))) continue; - - file->elements = new char*[file->nelements]; + // broadcast file->elements string array for (int i = 0; i < file->nelements; i++) { - n = strlen(words[i]) + 1; - file->elements[i] = new char[n]; - strcpy(file->elements[i],words[i]); - } - delete [] words; - - if (me == 0) { - fgets(line,MAXLINE,fptr); - sscanf(line,"%d %lg %d %lg %lg", - &file->nrho,&file->drho,&file->nr,&file->dr,&file->cut); + int n; + if (comm->me == 0) n = strlen(file->elements[i]) + 1; + MPI_Bcast(&n, 1, MPI_INT, 0, world); + if (comm->me != 0) file->elements[i] = new char[n]; + MPI_Bcast(file->elements[i], n, MPI_CHAR, 0, world); } - MPI_Bcast(&file->nrho,1,MPI_INT,0,world); - MPI_Bcast(&file->drho,1,MPI_DOUBLE,0,world); - MPI_Bcast(&file->nr,1,MPI_INT,0,world); - MPI_Bcast(&file->dr,1,MPI_DOUBLE,0,world); - MPI_Bcast(&file->cut,1,MPI_DOUBLE,0,world); + // broadcast file->mass, frho, rhor + for (int i = 0; i < file->nelements; i++) { + MPI_Bcast(&file->mass[i], 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->frho[i][1], file->nrho, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->rhor[i][1], file->nr, MPI_DOUBLE, 0, world); + } - file->mass = new double[file->nelements]; - memory->create(file->frho,file->nelements,file->nrho+1,"pair:frho"); - memory->create(file->rhor,file->nelements,file->nr+1,"pair:rhor"); - memory->create(file->z2r,file->nelements,file->nelements,file->nr+1, - "pair:z2r"); - - int i,j,tmp; - for (i = 0; i < file->nelements; i++) { - if (me == 0) { - fgets(line,MAXLINE,fptr); - sscanf(line,"%d %lg",&tmp,&file->mass[i]); + // broadcast file->z2r + for (int i = 0; i < file->nelements; i++) { + for (int j = 0; j <= i; j++) { + MPI_Bcast(&file->z2r[i][j][1], file->nr, MPI_DOUBLE, 0, world); } - MPI_Bcast(&file->mass[i],1,MPI_DOUBLE,0,world); - - if (me == 0) grab(fptr,file->nrho,&file->frho[i][1]); - MPI_Bcast(&file->frho[i][1],file->nrho,MPI_DOUBLE,0,world); - if (me == 0) grab(fptr,file->nr,&file->rhor[i][1]); - MPI_Bcast(&file->rhor[i][1],file->nr,MPI_DOUBLE,0,world); } - - for (i = 0; i < file->nelements; i++) - for (j = 0; j <= i; j++) { - if (me == 0) grab(fptr,file->nr,&file->z2r[i][j][1]); - MPI_Bcast(&file->z2r[i][j][1],file->nr,MPI_DOUBLE,0,world); - } - - // close the potential file - - if (me == 0) fclose(fptr); } /* ---------------------------------------------------------------------- diff --git a/src/KOKKOS/pair_eam_fs_kokkos.cpp b/src/KOKKOS/pair_eam_fs_kokkos.cpp index a33923887b..e532a4ec38 100644 --- a/src/KOKKOS/pair_eam_fs_kokkos.cpp +++ b/src/KOKKOS/pair_eam_fs_kokkos.cpp @@ -29,11 +29,12 @@ #include "memory_kokkos.h" #include "error.h" #include "atom_masks.h" +#include "utils.h" +#include "tokenizer.h" +#include "potential_file_reader.h" using namespace LAMMPS_NS; -#define MAXLINE 1024 - // Cannot use virtual inheritance on the GPU, so must duplicate code /* ---------------------------------------------------------------------- */ @@ -982,99 +983,118 @@ void PairEAMFSKokkos::read_file(char *filename) { Fs *file = fs; - // open potential file + // read potential file + if(comm->me == 0) { + PotentialFileReader reader(lmp, filename, "EAM"); - int me = comm->me; - FILE *fptr; - char line[MAXLINE]; + try { + char * line = nullptr; - if (me == 0) { - fptr = force->open_potential(filename); - if (fptr == NULL) { - char str[128]; - snprintf(str,128,"Cannot open EAM potential file %s",filename); - error->one(FLERR,str); + reader.skip_line(); + reader.skip_line(); + reader.skip_line(); + + // extract element names from nelements line + line = reader.next_line(1); + ValueTokenizer values(line); + file->nelements = values.next_int(); + + if (values.count() != file->nelements + 1) + error->one(FLERR,"Incorrect element names in EAM potential file"); + + file->elements = new char*[file->nelements]; + for (int i = 0; i < file->nelements; i++) { + const std::string word = values.next_string(); + const int n = word.length() + 1; + file->elements[i] = new char[n]; + strcpy(file->elements[i], word.c_str()); + } + + // + + line = reader.next_line(5); + values = ValueTokenizer(line); + file->nrho = values.next_int(); + file->drho = values.next_double(); + file->nr = values.next_int(); + file->dr = values.next_double(); + file->cut = values.next_double(); + + if ((file->nrho <= 0) || (file->nr <= 0) || (file->dr <= 0.0)) + error->one(FLERR,"Invalid EAM potential file"); + + memory->create(file->mass, file->nelements, "pair:mass"); + memory->create(file->frho, file->nelements, file->nrho + 1, "pair:frho"); + memory->create(file->rhor, file->nelements, file->nelements, file->nr + 1, "pair:rhor"); + memory->create(file->z2r, file->nelements, file->nelements, file->nr + 1, "pair:z2r"); + + for (int i = 0; i < file->nelements; i++) { + line = reader.next_line(2); + values = ValueTokenizer(line); + values.next_int(); // ignore + file->mass[i] = values.next_double(); + + reader.next_dvector(file->nrho, &file->frho[i][1]); + + for (int j = 0; j < file->nelements; j++) { + reader.next_dvector(file->nr, &file->rhor[i][j][1]); + } + } + + for (int i = 0; i < file->nelements; i++) { + for (int j = 0; j <= i; j++) { + reader.next_dvector(file->nr, &file->z2r[i][j][1]); + } + } + } catch (TokenizerException & e) { + error->one(FLERR, e.what()); } } - // read and broadcast header - // extract element names from nelements line + // broadcast potential information + MPI_Bcast(&file->nelements, 1, MPI_INT, 0, world); - int n; - if (me == 0) { - fgets(line,MAXLINE,fptr); - fgets(line,MAXLINE,fptr); - fgets(line,MAXLINE,fptr); - fgets(line,MAXLINE,fptr); - n = strlen(line) + 1; + MPI_Bcast(&file->nrho, 1, MPI_INT, 0, world); + MPI_Bcast(&file->drho, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->nr, 1, MPI_INT, 0, world); + MPI_Bcast(&file->dr, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->cut, 1, MPI_DOUBLE, 0, world); + + // allocate memory on other procs + if (comm->me != 0) { + file->elements = new char*[file->nelements]; + for (int i = 0; i < file->nelements; i++) file->elements[i] = nullptr; + memory->create(file->mass, file->nelements, "pair:mass"); + memory->create(file->frho, file->nelements, file->nrho + 1, "pair:frho"); + memory->create(file->rhor, file->nelements, file->nelements, file->nr + 1, "pair:rhor"); + memory->create(file->z2r, file->nelements, file->nelements, file->nr + 1, "pair:z2r"); } - MPI_Bcast(&n,1,MPI_INT,0,world); - MPI_Bcast(line,n,MPI_CHAR,0,world); - sscanf(line,"%d",&file->nelements); - int nwords = atom->count_words(line); - if (nwords != file->nelements + 1) - error->all(FLERR,"Incorrect element names in EAM potential file"); - - char **words = new char*[file->nelements+1]; - nwords = 0; - strtok(line," \t\n\r\f"); - while ((words[nwords++] = strtok(NULL," \t\n\r\f"))) continue; - - file->elements = new char*[file->nelements]; + // broadcast file->elements string array for (int i = 0; i < file->nelements; i++) { - n = strlen(words[i]) + 1; - file->elements[i] = new char[n]; - strcpy(file->elements[i],words[i]); - } - delete [] words; - - if (me == 0) { - fgets(line,MAXLINE,fptr); - sscanf(line,"%d %lg %d %lg %lg", - &file->nrho,&file->drho,&file->nr,&file->dr,&file->cut); + int n; + if (comm->me == 0) n = strlen(file->elements[i]) + 1; + MPI_Bcast(&n, 1, MPI_INT, 0, world); + if (comm->me != 0) file->elements[i] = new char[n]; + MPI_Bcast(file->elements[i], n, MPI_CHAR, 0, world); } - MPI_Bcast(&file->nrho,1,MPI_INT,0,world); - MPI_Bcast(&file->drho,1,MPI_DOUBLE,0,world); - MPI_Bcast(&file->nr,1,MPI_INT,0,world); - MPI_Bcast(&file->dr,1,MPI_DOUBLE,0,world); - MPI_Bcast(&file->cut,1,MPI_DOUBLE,0,world); + // broadcast file->mass, frho, rhor + for (int i = 0; i < file->nelements; i++) { + MPI_Bcast(&file->mass[i], 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->frho[i][1], file->nrho, MPI_DOUBLE, 0, world); - file->mass = new double[file->nelements]; - memory->create(file->frho,file->nelements,file->nrho+1, - "pair:frho"); - memory->create(file->rhor,file->nelements,file->nelements, - file->nr+1,"pair:rhor"); - memory->create(file->z2r,file->nelements,file->nelements, - file->nr+1,"pair:z2r"); - - int i,j,tmp; - for (i = 0; i < file->nelements; i++) { - if (me == 0) { - fgets(line,MAXLINE,fptr); - sscanf(line,"%d %lg",&tmp,&file->mass[i]); - } - MPI_Bcast(&file->mass[i],1,MPI_DOUBLE,0,world); - - if (me == 0) grab(fptr,file->nrho,&file->frho[i][1]); - MPI_Bcast(&file->frho[i][1],file->nrho,MPI_DOUBLE,0,world); - - for (j = 0; j < file->nelements; j++) { - if (me == 0) grab(fptr,file->nr,&file->rhor[i][j][1]); - MPI_Bcast(&file->rhor[i][j][1],file->nr,MPI_DOUBLE,0,world); + for (int j = 0; j < file->nelements; j++) { + MPI_Bcast(&file->rhor[i][j][1], file->nr, MPI_DOUBLE, 0, world); } } - for (i = 0; i < file->nelements; i++) - for (j = 0; j <= i; j++) { - if (me == 0) grab(fptr,file->nr,&file->z2r[i][j][1]); - MPI_Bcast(&file->z2r[i][j][1],file->nr,MPI_DOUBLE,0,world); + // broadcast file->z2r + for (int i = 0; i < file->nelements; i++) { + for (int j = 0; j <= i; j++) { + MPI_Bcast(&file->z2r[i][j][1], file->nr, MPI_DOUBLE, 0, world); } - - // close the potential file - - if (me == 0) fclose(fptr); + } } /* ---------------------------------------------------------------------- diff --git a/src/KOKKOS/pair_exp6_rx_kokkos.cpp b/src/KOKKOS/pair_exp6_rx_kokkos.cpp index a64df08127..8c98e32d5b 100644 --- a/src/KOKKOS/pair_exp6_rx_kokkos.cpp +++ b/src/KOKKOS/pair_exp6_rx_kokkos.cpp @@ -32,6 +32,7 @@ #include "neigh_request.h" #include "atom_kokkos.h" #include "kokkos.h" +#include "utils.h" #ifdef _OPENMP #include @@ -1752,7 +1753,7 @@ void PairExp6rxKokkos::read_file(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -1771,7 +1772,7 @@ void PairExp6rxKokkos::read_file(char *file) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) diff --git a/src/MAKE/MACHINES/Makefile.aarch64_arm_openmpi_armpl b/src/MAKE/MACHINES/Makefile.aarch64_arm_openmpi_armpl index 07dedba32a..ead00277c6 100644 --- a/src/MAKE/MACHINES/Makefile.aarch64_arm_openmpi_armpl +++ b/src/MAKE/MACHINES/Makefile.aarch64_arm_openmpi_armpl @@ -93,6 +93,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/MACHINES/Makefile.aarch64_arm_serial_armpl b/src/MAKE/MACHINES/Makefile.aarch64_arm_serial_armpl index d415f69397..44c83ff1e0 100644 --- a/src/MAKE/MACHINES/Makefile.aarch64_arm_serial_armpl +++ b/src/MAKE/MACHINES/Makefile.aarch64_arm_serial_armpl @@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/MACHINES/Makefile.aarch64_g++_openmpi_armpl b/src/MAKE/MACHINES/Makefile.aarch64_g++_openmpi_armpl index b75d9ee06a..4174c9c5e7 100644 --- a/src/MAKE/MACHINES/Makefile.aarch64_g++_openmpi_armpl +++ b/src/MAKE/MACHINES/Makefile.aarch64_g++_openmpi_armpl @@ -93,6 +93,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/MACHINES/Makefile.aarch64_g++_serial_armpl b/src/MAKE/MACHINES/Makefile.aarch64_g++_serial_armpl index 73cd0d6bed..5cb6fa0cde 100644 --- a/src/MAKE/MACHINES/Makefile.aarch64_g++_serial_armpl +++ b/src/MAKE/MACHINES/Makefile.aarch64_g++_serial_armpl @@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/MACHINES/Makefile.astra_arm b/src/MAKE/MACHINES/Makefile.astra_arm index 3ea3e00935..f64f4da891 100644 --- a/src/MAKE/MACHINES/Makefile.astra_arm +++ b/src/MAKE/MACHINES/Makefile.astra_arm @@ -91,6 +91,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/MACHINES/Makefile.astra_gcc b/src/MAKE/MACHINES/Makefile.astra_gcc index d607fbec84..e67bf467c4 100644 --- a/src/MAKE/MACHINES/Makefile.astra_gcc +++ b/src/MAKE/MACHINES/Makefile.astra_gcc @@ -91,6 +91,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/MACHINES/Makefile.bgl b/src/MAKE/MACHINES/Makefile.bgl index 06d243e83a..170b18d173 100644 --- a/src/MAKE/MACHINES/Makefile.bgl +++ b/src/MAKE/MACHINES/Makefile.bgl @@ -98,6 +98,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/MACHINES/Makefile.bgq b/src/MAKE/MACHINES/Makefile.bgq index 3d8ea41f5f..f0401e0758 100644 --- a/src/MAKE/MACHINES/Makefile.bgq +++ b/src/MAKE/MACHINES/Makefile.bgq @@ -33,6 +33,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/MACHINES/Makefile.chama b/src/MAKE/MACHINES/Makefile.chama index a8a9cebfdb..ba6dceba58 100644 --- a/src/MAKE/MACHINES/Makefile.chama +++ b/src/MAKE/MACHINES/Makefile.chama @@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/MACHINES/Makefile.cori2 b/src/MAKE/MACHINES/Makefile.cori2 index 7883c75840..ca902617fd 100644 --- a/src/MAKE/MACHINES/Makefile.cori2 +++ b/src/MAKE/MACHINES/Makefile.cori2 @@ -102,6 +102,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/MACHINES/Makefile.cygwin b/src/MAKE/MACHINES/Makefile.cygwin index 5cd6e79b69..4c47860a56 100644 --- a/src/MAKE/MACHINES/Makefile.cygwin +++ b/src/MAKE/MACHINES/Makefile.cygwin @@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/MACHINES/Makefile.glory b/src/MAKE/MACHINES/Makefile.glory index a128f88515..d21fe668ec 100644 --- a/src/MAKE/MACHINES/Makefile.glory +++ b/src/MAKE/MACHINES/Makefile.glory @@ -109,6 +109,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/MACHINES/Makefile.icex b/src/MAKE/MACHINES/Makefile.icex index 6c3db3fb43..dc2019a8f4 100644 --- a/src/MAKE/MACHINES/Makefile.icex +++ b/src/MAKE/MACHINES/Makefile.icex @@ -94,6 +94,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/MACHINES/Makefile.mac b/src/MAKE/MACHINES/Makefile.mac index 1bbd805c65..67381fe622 100644 --- a/src/MAKE/MACHINES/Makefile.mac +++ b/src/MAKE/MACHINES/Makefile.mac @@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/MACHINES/Makefile.mac_mpi b/src/MAKE/MACHINES/Makefile.mac_mpi index 7c4fa6aa6d..0b6b4b5ba2 100644 --- a/src/MAKE/MACHINES/Makefile.mac_mpi +++ b/src/MAKE/MACHINES/Makefile.mac_mpi @@ -93,6 +93,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/MACHINES/Makefile.mingw32-cross b/src/MAKE/MACHINES/Makefile.mingw32-cross index c463d7df26..d1269668fd 100644 --- a/src/MAKE/MACHINES/Makefile.mingw32-cross +++ b/src/MAKE/MACHINES/Makefile.mingw32-cross @@ -97,6 +97,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/MACHINES/Makefile.mingw32-cross-mpi b/src/MAKE/MACHINES/Makefile.mingw32-cross-mpi index 7badd3bb79..6b8e4bdee5 100644 --- a/src/MAKE/MACHINES/Makefile.mingw32-cross-mpi +++ b/src/MAKE/MACHINES/Makefile.mingw32-cross-mpi @@ -97,6 +97,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/MACHINES/Makefile.mingw64-cross b/src/MAKE/MACHINES/Makefile.mingw64-cross index 66de4dedaf..bf3416de6a 100644 --- a/src/MAKE/MACHINES/Makefile.mingw64-cross +++ b/src/MAKE/MACHINES/Makefile.mingw64-cross @@ -97,6 +97,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/MACHINES/Makefile.mingw64-cross-mpi b/src/MAKE/MACHINES/Makefile.mingw64-cross-mpi index 40c52b6a73..7d80d2c4e1 100644 --- a/src/MAKE/MACHINES/Makefile.mingw64-cross-mpi +++ b/src/MAKE/MACHINES/Makefile.mingw64-cross-mpi @@ -97,6 +97,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/MACHINES/Makefile.myrinet b/src/MAKE/MACHINES/Makefile.myrinet index 82030fbeae..a74aee3eaf 100644 --- a/src/MAKE/MACHINES/Makefile.myrinet +++ b/src/MAKE/MACHINES/Makefile.myrinet @@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/MACHINES/Makefile.power b/src/MAKE/MACHINES/Makefile.power index d4d0f67fa5..1671fd6273 100644 --- a/src/MAKE/MACHINES/Makefile.power +++ b/src/MAKE/MACHINES/Makefile.power @@ -93,6 +93,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/MACHINES/Makefile.redsky b/src/MAKE/MACHINES/Makefile.redsky index 461139e2e9..7f8456284e 100644 --- a/src/MAKE/MACHINES/Makefile.redsky +++ b/src/MAKE/MACHINES/Makefile.redsky @@ -112,6 +112,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/MACHINES/Makefile.storm b/src/MAKE/MACHINES/Makefile.storm index 3178d840e9..55c92c9e9e 100644 --- a/src/MAKE/MACHINES/Makefile.storm +++ b/src/MAKE/MACHINES/Makefile.storm @@ -93,6 +93,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/MACHINES/Makefile.summit_kokkos b/src/MAKE/MACHINES/Makefile.summit_kokkos index a8abb97a62..95ee7e39a8 100644 --- a/src/MAKE/MACHINES/Makefile.summit_kokkos +++ b/src/MAKE/MACHINES/Makefile.summit_kokkos @@ -99,6 +99,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/MACHINES/Makefile.tacc b/src/MAKE/MACHINES/Makefile.tacc index 2cf263a8db..5a6f7d6a27 100644 --- a/src/MAKE/MACHINES/Makefile.tacc +++ b/src/MAKE/MACHINES/Makefile.tacc @@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/MACHINES/Makefile.theta b/src/MAKE/MACHINES/Makefile.theta index 698f3aafa1..62e125152d 100644 --- a/src/MAKE/MACHINES/Makefile.theta +++ b/src/MAKE/MACHINES/Makefile.theta @@ -97,6 +97,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/MACHINES/Makefile.ubuntu b/src/MAKE/MACHINES/Makefile.ubuntu index 2764f457a7..6c419ffdfa 100644 --- a/src/MAKE/MACHINES/Makefile.ubuntu +++ b/src/MAKE/MACHINES/Makefile.ubuntu @@ -96,6 +96,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/MACHINES/Makefile.ubuntu_simple b/src/MAKE/MACHINES/Makefile.ubuntu_simple index e162830ec5..98897f964f 100644 --- a/src/MAKE/MACHINES/Makefile.ubuntu_simple +++ b/src/MAKE/MACHINES/Makefile.ubuntu_simple @@ -95,6 +95,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/MACHINES/Makefile.white b/src/MAKE/MACHINES/Makefile.white index b07e14a30e..ff2103008c 100644 --- a/src/MAKE/MACHINES/Makefile.white +++ b/src/MAKE/MACHINES/Makefile.white @@ -96,6 +96,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/MACHINES/Makefile.xe6 b/src/MAKE/MACHINES/Makefile.xe6 index 0971965bbf..a6db78a053 100644 --- a/src/MAKE/MACHINES/Makefile.xe6 +++ b/src/MAKE/MACHINES/Makefile.xe6 @@ -93,6 +93,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/MACHINES/Makefile.xt3 b/src/MAKE/MACHINES/Makefile.xt3 index 5752e61692..a6ffe94ddd 100644 --- a/src/MAKE/MACHINES/Makefile.xt3 +++ b/src/MAKE/MACHINES/Makefile.xt3 @@ -94,6 +94,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/MACHINES/Makefile.xt5 b/src/MAKE/MACHINES/Makefile.xt5 index 9c4cbe6ee6..1a85e40333 100644 --- a/src/MAKE/MACHINES/Makefile.xt5 +++ b/src/MAKE/MACHINES/Makefile.xt5 @@ -93,6 +93,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/Makefile.mpi b/src/MAKE/Makefile.mpi index b79cfbb3fd..31aee94b85 100644 --- a/src/MAKE/Makefile.mpi +++ b/src/MAKE/Makefile.mpi @@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/Makefile.serial b/src/MAKE/Makefile.serial index 01a160df33..a0b2959c4b 100644 --- a/src/MAKE/Makefile.serial +++ b/src/MAKE/Makefile.serial @@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/OPTIONS/Makefile.big b/src/MAKE/OPTIONS/Makefile.big index 56b0c48249..bdc093c6ae 100644 --- a/src/MAKE/OPTIONS/Makefile.big +++ b/src/MAKE/OPTIONS/Makefile.big @@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/OPTIONS/Makefile.fftw b/src/MAKE/OPTIONS/Makefile.fftw index 1abb96f6dd..dd539fb5dc 100644 --- a/src/MAKE/OPTIONS/Makefile.fftw +++ b/src/MAKE/OPTIONS/Makefile.fftw @@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/OPTIONS/Makefile.g++_mpich b/src/MAKE/OPTIONS/Makefile.g++_mpich index fa30f64f0b..4ea855cfeb 100644 --- a/src/MAKE/OPTIONS/Makefile.g++_mpich +++ b/src/MAKE/OPTIONS/Makefile.g++_mpich @@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/OPTIONS/Makefile.g++_mpich_link b/src/MAKE/OPTIONS/Makefile.g++_mpich_link index 42d66b2317..7b92a3e77a 100644 --- a/src/MAKE/OPTIONS/Makefile.g++_mpich_link +++ b/src/MAKE/OPTIONS/Makefile.g++_mpich_link @@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/OPTIONS/Makefile.g++_openmpi b/src/MAKE/OPTIONS/Makefile.g++_openmpi index f52aa49ad7..548994f832 100644 --- a/src/MAKE/OPTIONS/Makefile.g++_openmpi +++ b/src/MAKE/OPTIONS/Makefile.g++_openmpi @@ -93,6 +93,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/OPTIONS/Makefile.g++_openmpi_link b/src/MAKE/OPTIONS/Makefile.g++_openmpi_link index 0aaa8bbede..6fc71fe2a5 100644 --- a/src/MAKE/OPTIONS/Makefile.g++_openmpi_link +++ b/src/MAKE/OPTIONS/Makefile.g++_openmpi_link @@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/OPTIONS/Makefile.g++_serial b/src/MAKE/OPTIONS/Makefile.g++_serial index 93e1c502d9..65de6a2c2c 100644 --- a/src/MAKE/OPTIONS/Makefile.g++_serial +++ b/src/MAKE/OPTIONS/Makefile.g++_serial @@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/OPTIONS/Makefile.gpu b/src/MAKE/OPTIONS/Makefile.gpu index 7cec50fbd8..26c98c120d 100644 --- a/src/MAKE/OPTIONS/Makefile.gpu +++ b/src/MAKE/OPTIONS/Makefile.gpu @@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/OPTIONS/Makefile.hip b/src/MAKE/OPTIONS/Makefile.hip index 062b92fb6d..8be9e7260f 100644 --- a/src/MAKE/OPTIONS/Makefile.hip +++ b/src/MAKE/OPTIONS/Makefile.hip @@ -98,6 +98,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/OPTIONS/Makefile.icc_mpich b/src/MAKE/OPTIONS/Makefile.icc_mpich index 81256f85b6..cf76506da5 100644 --- a/src/MAKE/OPTIONS/Makefile.icc_mpich +++ b/src/MAKE/OPTIONS/Makefile.icc_mpich @@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/OPTIONS/Makefile.icc_mpich_link b/src/MAKE/OPTIONS/Makefile.icc_mpich_link index 5a8ae8b228..3994968430 100644 --- a/src/MAKE/OPTIONS/Makefile.icc_mpich_link +++ b/src/MAKE/OPTIONS/Makefile.icc_mpich_link @@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/OPTIONS/Makefile.icc_openmpi b/src/MAKE/OPTIONS/Makefile.icc_openmpi index 1ed258e717..72e3d44093 100644 --- a/src/MAKE/OPTIONS/Makefile.icc_openmpi +++ b/src/MAKE/OPTIONS/Makefile.icc_openmpi @@ -93,6 +93,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/OPTIONS/Makefile.icc_openmpi_link b/src/MAKE/OPTIONS/Makefile.icc_openmpi_link index 33a5c529b8..e44486aeb5 100644 --- a/src/MAKE/OPTIONS/Makefile.icc_openmpi_link +++ b/src/MAKE/OPTIONS/Makefile.icc_openmpi_link @@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/OPTIONS/Makefile.icc_serial b/src/MAKE/OPTIONS/Makefile.icc_serial index 6880e9e2dc..a81c73c718 100644 --- a/src/MAKE/OPTIONS/Makefile.icc_serial +++ b/src/MAKE/OPTIONS/Makefile.icc_serial @@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/OPTIONS/Makefile.intel_coprocessor b/src/MAKE/OPTIONS/Makefile.intel_coprocessor index 738fcbeaf8..b11256baa1 100644 --- a/src/MAKE/OPTIONS/Makefile.intel_coprocessor +++ b/src/MAKE/OPTIONS/Makefile.intel_coprocessor @@ -97,6 +97,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/OPTIONS/Makefile.intel_cpu_intelmpi b/src/MAKE/OPTIONS/Makefile.intel_cpu_intelmpi index f085aac55a..4adc427d91 100644 --- a/src/MAKE/OPTIONS/Makefile.intel_cpu_intelmpi +++ b/src/MAKE/OPTIONS/Makefile.intel_cpu_intelmpi @@ -96,6 +96,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/OPTIONS/Makefile.intel_cpu_mpich b/src/MAKE/OPTIONS/Makefile.intel_cpu_mpich index 7f6b687334..762899722c 100644 --- a/src/MAKE/OPTIONS/Makefile.intel_cpu_mpich +++ b/src/MAKE/OPTIONS/Makefile.intel_cpu_mpich @@ -96,6 +96,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/OPTIONS/Makefile.intel_cpu_openmpi b/src/MAKE/OPTIONS/Makefile.intel_cpu_openmpi index 5401101546..9adb5b1af2 100644 --- a/src/MAKE/OPTIONS/Makefile.intel_cpu_openmpi +++ b/src/MAKE/OPTIONS/Makefile.intel_cpu_openmpi @@ -97,6 +97,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/OPTIONS/Makefile.jpeg b/src/MAKE/OPTIONS/Makefile.jpeg index 7d4e029033..e8f1f3e96a 100644 --- a/src/MAKE/OPTIONS/Makefile.jpeg +++ b/src/MAKE/OPTIONS/Makefile.jpeg @@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/OPTIONS/Makefile.knl b/src/MAKE/OPTIONS/Makefile.knl index 92030fb953..091fd7558f 100644 --- a/src/MAKE/OPTIONS/Makefile.knl +++ b/src/MAKE/OPTIONS/Makefile.knl @@ -95,6 +95,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/OPTIONS/Makefile.kokkos_cuda_mpi b/src/MAKE/OPTIONS/Makefile.kokkos_cuda_mpi index b9b262ed1d..3971cc6c06 100644 --- a/src/MAKE/OPTIONS/Makefile.kokkos_cuda_mpi +++ b/src/MAKE/OPTIONS/Makefile.kokkos_cuda_mpi @@ -97,6 +97,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/OPTIONS/Makefile.kokkos_mpi_only b/src/MAKE/OPTIONS/Makefile.kokkos_mpi_only index 8cc4375b59..0b2e42487f 100644 --- a/src/MAKE/OPTIONS/Makefile.kokkos_mpi_only +++ b/src/MAKE/OPTIONS/Makefile.kokkos_mpi_only @@ -93,6 +93,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/OPTIONS/Makefile.kokkos_omp b/src/MAKE/OPTIONS/Makefile.kokkos_omp index 750751b73c..3e8f7ba634 100644 --- a/src/MAKE/OPTIONS/Makefile.kokkos_omp +++ b/src/MAKE/OPTIONS/Makefile.kokkos_omp @@ -93,6 +93,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/OPTIONS/Makefile.kokkos_phi b/src/MAKE/OPTIONS/Makefile.kokkos_phi index 4e85b9e5b8..0e2bec0a5a 100644 --- a/src/MAKE/OPTIONS/Makefile.kokkos_phi +++ b/src/MAKE/OPTIONS/Makefile.kokkos_phi @@ -94,6 +94,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/OPTIONS/Makefile.mgptfast b/src/MAKE/OPTIONS/Makefile.mgptfast index 6baae1e2ee..dc8682c3a6 100644 --- a/src/MAKE/OPTIONS/Makefile.mgptfast +++ b/src/MAKE/OPTIONS/Makefile.mgptfast @@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/OPTIONS/Makefile.omp b/src/MAKE/OPTIONS/Makefile.omp index 80afad79ae..a6b45f7a31 100644 --- a/src/MAKE/OPTIONS/Makefile.omp +++ b/src/MAKE/OPTIONS/Makefile.omp @@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/OPTIONS/Makefile.opt b/src/MAKE/OPTIONS/Makefile.opt index 662f25eee6..8919e6e1d9 100644 --- a/src/MAKE/OPTIONS/Makefile.opt +++ b/src/MAKE/OPTIONS/Makefile.opt @@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/OPTIONS/Makefile.pgi_mpich_link b/src/MAKE/OPTIONS/Makefile.pgi_mpich_link index 57101c55ae..daa8a79166 100644 --- a/src/MAKE/OPTIONS/Makefile.pgi_mpich_link +++ b/src/MAKE/OPTIONS/Makefile.pgi_mpich_link @@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MAKE/OPTIONS/Makefile.png b/src/MAKE/OPTIONS/Makefile.png index 442dddeb66..9fd7b9b79c 100644 --- a/src/MAKE/OPTIONS/Makefile.png +++ b/src/MAKE/OPTIONS/Makefile.png @@ -92,6 +92,7 @@ $(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) # Library targets $(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) @rm -f $(ARLIB) @ln -s ../$(ARLIB) $(ARLIB) diff --git a/src/MANYBODY/pair_adp.cpp b/src/MANYBODY/pair_adp.cpp index e730466fcb..2a64839e98 100644 --- a/src/MANYBODY/pair_adp.cpp +++ b/src/MANYBODY/pair_adp.cpp @@ -29,11 +29,11 @@ #include "memory.h" #include "error.h" #include "utils.h" +#include "tokenizer.h" +#include "potential_file_reader.h" using namespace LAMMPS_NS; -#define MAXLINE 1024 - /* ---------------------------------------------------------------------- */ PairADP::PairADP(LAMMPS *lmp) : Pair(lmp) @@ -96,7 +96,7 @@ PairADP::~PairADP() if (setfl) { for (int i = 0; i < setfl->nelements; i++) delete [] setfl->elements[i]; delete [] setfl->elements; - delete [] setfl->mass; + memory->destroy(setfl->mass); memory->destroy(setfl->frho); memory->destroy(setfl->rhor); memory->destroy(setfl->z2r); @@ -453,7 +453,7 @@ void PairADP::coeff(int narg, char **arg) if (setfl) { for (i = 0; i < setfl->nelements; i++) delete [] setfl->elements[i]; delete [] setfl->elements; - delete [] setfl->mass; + memory->destroy(setfl->mass); memory->destroy(setfl->frho); memory->destroy(setfl->rhor); memory->destroy(setfl->z2r); @@ -541,110 +541,130 @@ void PairADP::read_file(char *filename) { Setfl *file = setfl; - // open potential file + // read potential file + if(comm->me == 0) { + PotentialFileReader reader(lmp, filename, "ADP"); - int me = comm->me; - FILE *fp; - char line[MAXLINE]; + try { + char * line = nullptr; - if (me == 0) { - fp = force->open_potential(filename); - if (fp == NULL) { - char str[128]; - snprintf(str,128,"Cannot open ADP potential file %s",filename); - error->one(FLERR,str); + reader.skip_line(); + reader.skip_line(); + reader.skip_line(); + + // extract element names from nelements line + line = reader.next_line(1); + ValueTokenizer values(line); + file->nelements = values.next_int(); + + if (values.count() != file->nelements + 1) + error->one(FLERR,"Incorrect element names in ADP potential file"); + + file->elements = new char*[file->nelements]; + for (int i = 0; i < file->nelements; i++) { + const std::string word = values.next_string(); + const int n = word.length() + 1; + file->elements[i] = new char[n]; + strcpy(file->elements[i], word.c_str()); + } + + // + + line = reader.next_line(5); + values = ValueTokenizer(line); + file->nrho = values.next_int(); + file->drho = values.next_double(); + file->nr = values.next_int(); + file->dr = values.next_double(); + file->cut = values.next_double(); + + if ((file->nrho <= 0) || (file->nr <= 0) || (file->dr <= 0.0)) + error->one(FLERR,"Invalid EAM potential file"); + + memory->create(file->mass, file->nelements, "pair:mass"); + memory->create(file->frho, file->nelements, file->nrho + 1, "pair:frho"); + memory->create(file->rhor, file->nelements, file->nr + 1, "pair:rhor"); + memory->create(file->z2r, file->nelements, file->nelements, file->nr + 1, "pair:z2r"); + memory->create(file->u2r, file->nelements, file->nelements, file->nr + 1, "pair:u2r"); + memory->create(file->w2r, file->nelements, file->nelements, file->nr + 1, "pair:w2r"); + + for (int i = 0; i < file->nelements; i++) { + line = reader.next_line(2); + values = ValueTokenizer(line); + values.next_int(); // ignore + file->mass[i] = values.next_double(); + + reader.next_dvector(file->nrho, &file->frho[i][1]); + reader.next_dvector(file->nr, &file->rhor[i][1]); + } + + for (int i = 0; i < file->nelements; i++) { + for (int j = 0; j <= i; j++) { + reader.next_dvector(file->nr, &file->z2r[i][j][1]); + } + } + + for (int i = 0; i < file->nelements; i++) { + for (int j = 0; j <= i; j++) { + reader.next_dvector(file->nr, &file->u2r[i][j][1]); + } + } + + for (int i = 0; i < file->nelements; i++) { + for (int j = 0; j <= i; j++) { + reader.next_dvector(file->nr, &file->w2r[i][j][1]); + } + } + } catch (TokenizerException & e) { + error->one(FLERR, e.what()); } } - // read and broadcast header - // extract element names from nelements line + // broadcast potential information + MPI_Bcast(&file->nelements, 1, MPI_INT, 0, world); - int n; - if (me == 0) { - utils::sfgets(FLERR,line,MAXLINE,fp,filename,error); - utils::sfgets(FLERR,line,MAXLINE,fp,filename,error); - utils::sfgets(FLERR,line,MAXLINE,fp,filename,error); - utils::sfgets(FLERR,line,MAXLINE,fp,filename,error); - n = strlen(line) + 1; + MPI_Bcast(&file->nrho, 1, MPI_INT, 0, world); + MPI_Bcast(&file->drho, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->nr, 1, MPI_INT, 0, world); + MPI_Bcast(&file->dr, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->cut, 1, MPI_DOUBLE, 0, world); + + // allocate memory on other procs + if (comm->me != 0) { + file->elements = new char*[file->nelements]; + for (int i = 0; i < file->nelements; i++) file->elements[i] = nullptr; + memory->create(file->mass, file->nelements, "pair:mass"); + memory->create(file->frho, file->nelements, file->nrho + 1, "pair:frho"); + memory->create(file->rhor, file->nelements, file->nr + 1, "pair:rhor"); + memory->create(file->z2r, file->nelements, file->nelements, file->nr + 1, "pair:z2r"); + memory->create(file->u2r, file->nelements, file->nelements, file->nr + 1, "pair:u2r"); + memory->create(file->w2r, file->nelements, file->nelements, file->nr + 1, "pair:w2r"); } - MPI_Bcast(&n,1,MPI_INT,0,world); - MPI_Bcast(line,n,MPI_CHAR,0,world); - sscanf(line,"%d",&file->nelements); - int nwords = atom->count_words(line); - if (nwords != file->nelements + 1) - error->all(FLERR,"Incorrect element names in ADP potential file"); - - char **words = new char*[file->nelements+1]; - nwords = 0; - strtok(line," \t\n\r\f"); - while ((words[nwords++] = strtok(NULL," \t\n\r\f"))) continue; - - file->elements = new char*[file->nelements]; + // broadcast file->elements string array for (int i = 0; i < file->nelements; i++) { - n = strlen(words[i]) + 1; - file->elements[i] = new char[n]; - strcpy(file->elements[i],words[i]); - } - delete [] words; - - if (me == 0) { - utils::sfgets(FLERR,line,MAXLINE,fp,filename,error); - sscanf(line,"%d %lg %d %lg %lg", - &file->nrho,&file->drho,&file->nr,&file->dr,&file->cut); + int n; + if (comm->me == 0) n = strlen(file->elements[i]) + 1; + MPI_Bcast(&n, 1, MPI_INT, 0, world); + if (comm->me != 0) file->elements[i] = new char[n]; + MPI_Bcast(file->elements[i], n, MPI_CHAR, 0, world); } - MPI_Bcast(&file->nrho,1,MPI_INT,0,world); - MPI_Bcast(&file->drho,1,MPI_DOUBLE,0,world); - MPI_Bcast(&file->nr,1,MPI_INT,0,world); - MPI_Bcast(&file->dr,1,MPI_DOUBLE,0,world); - MPI_Bcast(&file->cut,1,MPI_DOUBLE,0,world); - - file->mass = new double[file->nelements]; - memory->create(file->frho,file->nelements,file->nrho+1,"pair:frho"); - memory->create(file->rhor,file->nelements,file->nr+1,"pair:rhor"); - memory->create(file->z2r,file->nelements,file->nelements,file->nr+1, - "pair:z2r"); - memory->create(file->u2r,file->nelements,file->nelements,file->nr+1, - "pair:u2r"); - memory->create(file->w2r,file->nelements,file->nelements,file->nr+1, - "pair:w2r"); - - int i,j,tmp; - for (i = 0; i < file->nelements; i++) { - if (me == 0) { - utils::sfgets(FLERR,line,MAXLINE,fp,filename,error); - sscanf(line,"%d %lg",&tmp,&file->mass[i]); - } + // broadcast file->mass, frho, rhor + for (int i = 0; i < file->nelements; i++) { MPI_Bcast(&file->mass[i],1,MPI_DOUBLE,0,world); - - if (me == 0) grab(fp,filename,file->nrho,&file->frho[i][1]); MPI_Bcast(&file->frho[i][1],file->nrho,MPI_DOUBLE,0,world); - if (me == 0) grab(fp,filename,file->nr,&file->rhor[i][1]); MPI_Bcast(&file->rhor[i][1],file->nr,MPI_DOUBLE,0,world); } - for (i = 0; i < file->nelements; i++) - for (j = 0; j <= i; j++) { - if (me == 0) grab(fp,filename,file->nr,&file->z2r[i][j][1]); + // broadcast file->z2r, u2r, w2r + for (int i = 0; i < file->nelements; i++) { + for (int j = 0; j <= i; j++) { MPI_Bcast(&file->z2r[i][j][1],file->nr,MPI_DOUBLE,0,world); - } - - for (i = 0; i < file->nelements; i++) - for (j = 0; j <= i; j++) { - if (me == 0) grab(fp,filename,file->nr,&file->u2r[i][j][1]); MPI_Bcast(&file->u2r[i][j][1],file->nr,MPI_DOUBLE,0,world); - } - - for (i = 0; i < file->nelements; i++) - for (j = 0; j <= i; j++) { - if (me == 0) grab(fp,filename,file->nr,&file->w2r[i][j][1]); MPI_Bcast(&file->w2r[i][j][1],file->nr,MPI_DOUBLE,0,world); } - - // close the potential file - - if (me == 0) fclose(fp); + } } /* ---------------------------------------------------------------------- @@ -912,26 +932,6 @@ void PairADP::interpolate(int n, double delta, double *f, double **spline) } } -/* ---------------------------------------------------------------------- - grab n values from file fp and put them in list - values can be several to a line - only called by proc 0 -------------------------------------------------------------------------- */ - -void PairADP::grab(FILE *fp, char *filename, int n, double *list) -{ - char *ptr; - char line[MAXLINE]; - - int i = 0; - while (i < n) { - utils::sfgets(FLERR,line,MAXLINE,fp,filename,error); - ptr = strtok(line," \t\n\r\f"); - if (ptr) list[i++] = atof(ptr); - while ((ptr = strtok(NULL," \t\n\r\f"))) list[i++] = atof(ptr); - } -} - /* ---------------------------------------------------------------------- */ int PairADP::pack_forward_comm(int n, int *list, double *buf, diff --git a/src/MANYBODY/pair_adp.h b/src/MANYBODY/pair_adp.h index 360e910c2a..65596113ba 100644 --- a/src/MANYBODY/pair_adp.h +++ b/src/MANYBODY/pair_adp.h @@ -82,7 +82,6 @@ class PairADP : public Pair { void allocate(); void array2spline(); void interpolate(int, double, double *, double **); - void grab(FILE *, char *, int, double *); void read_file(char *); void file2array(); diff --git a/src/MANYBODY/pair_bop.cpp b/src/MANYBODY/pair_bop.cpp index 10ab1d7080..4b5f4c7d17 100644 --- a/src/MANYBODY/pair_bop.cpp +++ b/src/MANYBODY/pair_bop.cpp @@ -1035,145 +1035,6 @@ void PairBOP::gneigh() /* ---------------------------------------------------------------------- */ -void PairBOP::theta() -{ - int i,j,ii,jj,kk; - int itype,jtype,i12; - int temp_ij,temp_ik,temp_ijk; - int n,nlocal,nall,ks; - int nlisti; - int *ilist; - int *iilist; - int **firstneigh; - double rj2,rk2,rsq,ps; - double rj1k1,rj2k2; - double **x = atom->x; - int *type = atom->type; - - nlocal = atom->nlocal; - nall = nlocal+atom->nghost; - ilist = list->ilist; - firstneigh = list->firstneigh; - if(update_list!=0) - memory_theta_grow(); - else - memory_theta_create(); - for (ii = 0; ii < nall; ii++) { - if(ii=npairs) { - error->one(FLERR,"Too many atom pairs for pair bop"); - } - disij[0][temp_ij]=x[j][0]-x[i][0]; - disij[1][temp_ij]=x[j][1]-x[i][1]; - disij[2][temp_ij]=x[j][2]-x[i][2]; - rsq=disij[0][temp_ij]*disij[0][temp_ij] - +disij[1][temp_ij]*disij[1][temp_ij] - +disij[2][temp_ij]*disij[2][temp_ij]; - rij[temp_ij]=sqrt(rsq); - if(rij[temp_ij]<=rcut[i12]) - neigh_flag[temp_ij]=1; - else - neigh_flag[temp_ij]=0; - if(rij[temp_ij]<=rcut3[i12]) - neigh_flag3[temp_ij]=1; - else - neigh_flag3[temp_ij]=0; - ps=rij[temp_ij]*rdr[i12]+1.0; - ks=(int)ps; - if(nr-11.0) - ps=1.0; - betaS[temp_ij]=((pBetaS3[i12][ks-1]*ps+pBetaS2[i12][ks-1])*ps+pBetaS1[i12][ks-1])*ps+pBetaS[i12][ks-1]; - dBetaS[temp_ij]=(pBetaS6[i12][ks-1]*ps+pBetaS5[i12][ks-1])*ps - +pBetaS4[i12][ks-1]; - betaP[temp_ij]=((pBetaP3[i12][ks-1]*ps+pBetaP2[i12][ks-1])*ps - +pBetaP1[i12][ks-1])*ps+pBetaP[i12][ks-1]; - dBetaP[temp_ij]=(pBetaP6[i12][ks-1]*ps+pBetaP5[i12][ks-1])*ps - +pBetaP4[i12][ks-1]; - repul[temp_ij]=((pRepul3[i12][ks-1]*ps+pRepul2[i12][ks-1])*ps - +pRepul1[i12][ks-1])*ps+pRepul[i12][ks-1]; - dRepul[temp_ij]=(pRepul6[i12][ks-1]*ps+pRepul5[i12][ks-1])*ps - +pRepul4[i12][ks-1]; - } - } - for (ii = 0; ii < nall; ii++) { - n=0; - if(ii=cos_total) { - error->one(FLERR,"Too many atom triplets for pair bop"); - } - temp_ik=BOP_index[i]+kk; - temp_ijk=cos_index[i]+n; - if(temp_ijk>=cos_total) { - error->one(FLERR,"Too many atom triplets for pair bop"); - } - rk2=rij[temp_ik]*rij[temp_ik]; - rj1k1=rij[temp_ij]*rij[temp_ik]; - rj2k2=rj1k1*rj1k1; - if(temp_ijk>=cos_total) { - error->one(FLERR,"Too many atom triplets for pair bop"); - } - cosAng[temp_ijk]=(disij[0][temp_ij]*disij[0][temp_ik]+disij[1][temp_ij] - *disij[1][temp_ik]+disij[2][temp_ij]*disij[2][temp_ik])/rj1k1; - dcAng[temp_ijk][0][0]=(disij[0][temp_ik]*rj1k1-cosAng[temp_ijk] - *disij[0][temp_ij]*rk2)/(rj2k2); - dcAng[temp_ijk][1][0]=(disij[1][temp_ik]*rj1k1-cosAng[temp_ijk] - *disij[1][temp_ij]*rk2)/(rj2k2); - dcAng[temp_ijk][2][0]=(disij[2][temp_ik]*rj1k1-cosAng[temp_ijk] - *disij[2][temp_ij]*rk2)/(rj2k2); - dcAng[temp_ijk][0][1]=(disij[0][temp_ij]*rj1k1-cosAng[temp_ijk] - *disij[0][temp_ik]*rj2)/(rj2k2); - dcAng[temp_ijk][1][1]=(disij[1][temp_ij]*rj1k1-cosAng[temp_ijk] - *disij[1][temp_ik]*rj2)/(rj2k2); - dcAng[temp_ijk][2][1]=(disij[2][temp_ij]*rj1k1-cosAng[temp_ijk] - *disij[2][temp_ik]*rj2)/(rj2k2); - n++; - } - } - } -} - -/* ---------------------------------------------------------------------- */ - -void PairBOP::theta_mod() -{ - if(update_list!=0) - memory_theta_grow(); - else - memory_theta_create(); -} - -/* ---------------------------------------------------------------------- */ - /* The formulation differs slightly to avoid negative square roots in the calculation of Sigma^(1/2) of (a) Eq. 6 and (b) Eq. 11 */ @@ -5556,26 +5417,6 @@ void _noopt PairBOP::read_table(char *filename) } } -/* ---------------------------------------------------------------------- */ - -double PairBOP::cutoff(double rp,double vrcut,int mode,double r) -{ - double tmp,tmp_beta,tmp_alpha,cut_store; - - if(mode==1) { - tmp=(rsmall-rbig)*(r-rp)/(vrcut-rp)+rbig; - cut_store=(erfc(tmp)-erfc(rsmall))/(erfc(rbig)-erfc(rsmall)); - } - else { - tmp_beta=log(log(rbig)/log(rsmall))/log(rp/vrcut); - tmp_alpha=-log(rbig)/pow(rp,tmp_beta); - cut_store=(exp(-tmp_alpha*pow(r,tmp_beta))-exp(-tmp_alpha*pow(vrcut - ,tmp_beta)))/(exp(-tmp_alpha*pow(rp,tmp_beta))-exp(-tmp_alpha - *pow(vrcut,tmp_beta))); - } - return(cut_store); -} - /* ---------------------------------------------------------------------- memory usage of local atom-based arrays ------------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_bop.h b/src/MANYBODY/pair_bop.h index ea8da2844e..6c4b255d25 100644 --- a/src/MANYBODY/pair_bop.h +++ b/src/MANYBODY/pair_bop.h @@ -199,14 +199,11 @@ class PairBOP : public Pair { void setPrepul(); void setSign(); void gneigh(); - void theta(); - void theta_mod(); double sigmaBo(int, int); double PiBo(int, int); void memory_theta_create(); void memory_theta_destroy(); void memory_theta_grow(); - double cutoff(double, double, int, double); void read_table(char *); void allocate(); diff --git a/src/MANYBODY/pair_comb.cpp b/src/MANYBODY/pair_comb.cpp index 2fc4caec7b..837a1d316f 100644 --- a/src/MANYBODY/pair_comb.cpp +++ b/src/MANYBODY/pair_comb.cpp @@ -34,11 +34,13 @@ #include "math_const.h" #include "memory.h" #include "error.h" +#include "utils.h" +#include "tokenizer.h" +#include "potential_file_reader.h" using namespace LAMMPS_NS; using namespace MathConst; -#define MAXLINE 1024 #define DELTA 4 #define PGDELTA 1 #define MAXNEIGH 24 @@ -580,192 +582,148 @@ double PairComb::init_one(int i, int j) void PairComb::read_file(char *file) { - int params_per_line = 49; - char **words = new char*[params_per_line+1]; - memory->sfree(params); - params = NULL; + params = nullptr; nparams = 0; maxparam = 0; // open file on proc 0 - - FILE *fp; if (comm->me == 0) { - fp = force->open_potential(file); - if (fp == NULL) { - char str[128]; - snprintf(str,128,"Cannot open COMB potential file %s",file); - error->one(FLERR,str); - } - } + PotentialFileReader reader(lmp, file, "COMB"); + char * line; - // read each line out of file, skipping blank lines or leading '#' - // store line of params if all 3 element tags are in element list + while(line = reader.next_line(NPARAMS_PER_LINE)) { + try { + ValueTokenizer values(line," \t\n\r\f"); - int n,nwords,ielement,jelement,kelement; - char line[MAXLINE],*ptr; - int eof = 0; + std::string iname = values.next_string(); + std::string jname = values.next_string(); + std::string kname = values.next_string(); - while (1) { - if (comm->me == 0) { - ptr = fgets(line,MAXLINE,fp); - if (ptr == NULL) { - eof = 1; - fclose(fp); - } 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); + // ielement,jelement,kelement = 1st args + // if all 3 args are in element list, then parse this line + // else skip to next line + int ielement, jelement, kelement; - // strip comment, skip line if blank + for (ielement = 0; ielement < nelements; ielement++) + if (iname == elements[ielement]) break; + if (ielement == nelements) continue; + for (jelement = 0; jelement < nelements; jelement++) + if (jname == elements[jelement]) break; + if (jelement == nelements) continue; + for (kelement = 0; kelement < nelements; kelement++) + if (kname == elements[kelement]) break; + if (kelement == nelements) continue; - if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); - if (nwords == 0) continue; + // load up parameter settings and error check their values - // concatenate additional lines until have params_per_line words + if (nparams == maxparam) { + maxparam += DELTA; + params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), + "pair:params"); + } - while (nwords < params_per_line) { - n = strlen(line); - if (comm->me == 0) { - ptr = fgets(&line[n],MAXLINE-n,fp); - if (ptr == NULL) { - eof = 1; - fclose(fp); - } else n = strlen(line) + 1; + params[nparams].ielement = ielement; + params[nparams].jelement = jelement; + params[nparams].kelement = kelement; + params[nparams].powerm = values.next_double(); + params[nparams].c = values.next_double(); + params[nparams].d = values.next_double(); + params[nparams].h = values.next_double(); + params[nparams].powern = values.next_double(); + params[nparams].beta = values.next_double(); + params[nparams].lam21 = values.next_double(); + params[nparams].lam22 = values.next_double(); + params[nparams].bigb1 = values.next_double(); + params[nparams].bigb2 = values.next_double(); + params[nparams].bigr = values.next_double(); + params[nparams].bigd = values.next_double(); + params[nparams].lam11 = values.next_double(); + params[nparams].lam12 = values.next_double(); + params[nparams].biga1 = values.next_double(); + params[nparams].biga2 = values.next_double(); + params[nparams].plp1 = values.next_double(); + params[nparams].plp3 = values.next_double(); + params[nparams].plp6 = values.next_double(); + params[nparams].a123 = values.next_double(); + params[nparams].aconf = values.next_double(); + params[nparams].addrep = values.next_double(); + params[nparams].romigb = values.next_double(); + params[nparams].romigc = values.next_double(); + params[nparams].romigd = values.next_double(); + params[nparams].romiga = values.next_double(); + params[nparams].QL1 = values.next_double(); + params[nparams].QU1 = values.next_double(); + params[nparams].DL1 = values.next_double(); + params[nparams].DU1 = values.next_double(); + params[nparams].QL2 = values.next_double(); + params[nparams].QU2 = values.next_double(); + params[nparams].DL2 = values.next_double(); + params[nparams].DU2 = values.next_double(); + params[nparams].chi = values.next_double(); + params[nparams].dj = values.next_double(); + params[nparams].dk = values.next_double(); + params[nparams].dl = values.next_double(); + params[nparams].dm = values.next_double(); + params[nparams].esm1 = values.next_double(); + params[nparams].cmn1 = values.next_double(); + params[nparams].cml1 = values.next_double(); + params[nparams].cmn2 = values.next_double(); + params[nparams].cml2 = values.next_double(); + params[nparams].coulcut = values.next_double(); + params[nparams].hfocor = values.next_double(); + } catch (TokenizerException & e) { + error->one(FLERR, e.what()); } - 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); - if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + + params[nparams].powermint = int(params[nparams].powerm); + + // parameter sanity checks + + if (params[nparams].lam11 < 0.0 || params[nparams].lam12 < 0.0 || + params[nparams].c < 0.0 || params[nparams].d < 0.0 || + params[nparams].powern < 0.0 || params[nparams].beta < 0.0 || + params[nparams].lam21 < 0.0 || params[nparams].lam22 < 0.0 || + params[nparams].bigb1< 0.0 || params[nparams].bigb2< 0.0 || + params[nparams].biga1< 0.0 || params[nparams].biga2< 0.0 || + params[nparams].bigr < 0.0 || params[nparams].bigd < 0.0 || + params[nparams].bigd > params[nparams].bigr || + params[nparams].powerm - params[nparams].powermint != 0.0 || + (params[nparams].powermint != 3 && params[nparams].powermint != 1) || + params[nparams].plp1 < 0.0 || params[nparams].plp3 < 0.0 || + params[nparams].plp6 < 0.0 || + params[nparams].a123 > 360.0 || params[nparams].aconf < 0.0 || + params[nparams].addrep < 0.0 || params[nparams].romigb < 0.0 || + params[nparams].romigc < 0.0 || params[nparams].romigd < 0.0 || + params[nparams].romiga < 0.0 || + params[nparams].QL1 > 0.0 || params[nparams].QU1 < 0.0 || + params[nparams].DL1 < 0.0 || params[nparams].DU1 > 0.0 || + params[nparams].QL2 > 0.0 || params[nparams].QU2 < 0.0 || + params[nparams].DL2 < 0.0 || params[nparams].DU2 > 0.0 || + params[nparams].chi < 0.0 || + // params[nparams].dj < 0.0 || params[nparams].dk < 0.0 || + // params[nparams].dl < 0.0 || params[nparams].dm < 0.0 || + params[nparams].esm1 < 0.0) + error->one(FLERR,"Illegal COMB parameter"); + + if (params[nparams].lam11 < params[nparams].lam21 || + params[nparams].lam12 < params[nparams].lam22 || + params[nparams].biga1< params[nparams].bigb1 || + params[nparams].biga2< params[nparams].bigb2) + error->one(FLERR,"Illegal COMB parameter"); + + nparams++; } - - if (nwords != params_per_line) - error->all(FLERR,"Incorrect format in COMB potential file"); - - // words = ptrs to all words in line - - nwords = 0; - words[nwords++] = strtok(line," \t\n\r\f"); - while ((words[nwords++] = strtok(NULL," \t\n\r\f"))) continue; - - // ielement,jelement,kelement = 1st args - // if all 3 args are in element list, then parse this line - // else skip to next line - - for (ielement = 0; ielement < nelements; ielement++) - if (strcmp(words[0],elements[ielement]) == 0) break; - if (ielement == nelements) continue; - for (jelement = 0; jelement < nelements; jelement++) - if (strcmp(words[1],elements[jelement]) == 0) break; - if (jelement == nelements) continue; - for (kelement = 0; kelement < nelements; kelement++) - if (strcmp(words[2],elements[kelement]) == 0) break; - if (kelement == nelements) continue; - - // load up parameter settings and error check their values - - if (nparams == maxparam) { - maxparam += DELTA; - params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), - "pair:params"); - } - - params[nparams].ielement = ielement; - params[nparams].jelement = jelement; - params[nparams].kelement = kelement; - params[nparams].powerm = atof(words[3]); - params[nparams].c = atof(words[4]); - params[nparams].d = atof(words[5]); - params[nparams].h = atof(words[6]); - params[nparams].powern = atof(words[7]); - params[nparams].beta = atof(words[8]); - params[nparams].lam21 = atof(words[9]); - params[nparams].lam22 = atof(words[10]); - params[nparams].bigb1 = atof(words[11]); - params[nparams].bigb2 = atof(words[12]); - params[nparams].bigr = atof(words[13]); - params[nparams].bigd = atof(words[14]); - params[nparams].lam11 = atof(words[15]); - params[nparams].lam12 = atof(words[16]); - params[nparams].biga1 = atof(words[17]); - params[nparams].biga2 = atof(words[18]); - params[nparams].plp1 = atof(words[19]); - params[nparams].plp3 = atof(words[20]); - params[nparams].plp6 = atof(words[21]); - params[nparams].a123 = atof(words[22]); - params[nparams].aconf= atof(words[23]); - params[nparams].addrep = atof(words[24]); - params[nparams].romigb = atof(words[25]); - params[nparams].romigc = atof(words[26]); - params[nparams].romigd = atof(words[27]); - params[nparams].romiga = atof(words[28]); - params[nparams].QL1 = atof(words[29]); - params[nparams].QU1 = atof(words[30]); - params[nparams].DL1 = atof(words[31]); - params[nparams].DU1 = atof(words[32]); - params[nparams].QL2 = atof(words[33]); - params[nparams].QU2 = atof(words[34]); - params[nparams].DL2 = atof(words[35]); - params[nparams].DU2 = atof(words[36]); - params[nparams].chi = atof(words[37]); - params[nparams].dj = atof(words[38]); - params[nparams].dk = atof(words[39]); - params[nparams].dl = atof(words[40]); - params[nparams].dm = atof(words[41]); - params[nparams].esm1 = atof(words[42]); - params[nparams].cmn1 = atof(words[43]); - params[nparams].cml1 = atof(words[44]); - params[nparams].cmn2 = atof(words[45]); - params[nparams].cml2 = atof(words[46]); - params[nparams].coulcut = atof(words[47]); - params[nparams].hfocor = atof(words[48]); - - params[nparams].powermint = int(params[nparams].powerm); - - // parameter sanity checks - - if (params[nparams].lam11 < 0.0 || params[nparams].lam12 < 0.0 || - params[nparams].c < 0.0 || params[nparams].d < 0.0 || - params[nparams].powern < 0.0 || params[nparams].beta < 0.0 || - params[nparams].lam21 < 0.0 || params[nparams].lam22 < 0.0 || - params[nparams].bigb1< 0.0 || params[nparams].bigb2< 0.0 || - params[nparams].biga1< 0.0 || params[nparams].biga2< 0.0 || - params[nparams].bigr < 0.0 || params[nparams].bigd < 0.0 || - params[nparams].bigd > params[nparams].bigr || - params[nparams].powerm - params[nparams].powermint != 0.0 || - (params[nparams].powermint != 3 && params[nparams].powermint != 1) || - params[nparams].plp1 < 0.0 || params[nparams].plp3 < 0.0 || - params[nparams].plp6 < 0.0 || - params[nparams].a123 > 360.0 || params[nparams].aconf < 0.0 || - params[nparams].addrep < 0.0 || params[nparams].romigb < 0.0 || - params[nparams].romigc < 0.0 || params[nparams].romigd < 0.0 || - params[nparams].romiga < 0.0 || - params[nparams].QL1 > 0.0 || params[nparams].QU1 < 0.0 || - params[nparams].DL1 < 0.0 || params[nparams].DU1 > 0.0 || - params[nparams].QL2 > 0.0 || params[nparams].QU2 < 0.0 || - params[nparams].DL2 < 0.0 || params[nparams].DU2 > 0.0 || - params[nparams].chi < 0.0 || -// params[nparams].dj < 0.0 || params[nparams].dk < 0.0 || -// params[nparams].dl < 0.0 || params[nparams].dm < 0.0 || - params[nparams].esm1 < 0.0) - error->all(FLERR,"Illegal COMB parameter"); - - if (params[nparams].lam11 < params[nparams].lam21 || - params[nparams].lam12 < params[nparams].lam22 || - params[nparams].biga1< params[nparams].bigb1 || - params[nparams].biga2< params[nparams].bigb2) - error->all(FLERR,"Illegal COMB parameter"); - - nparams++; } - delete [] words; + MPI_Bcast(&nparams, 1, MPI_INT, 0, world); + MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); + + if(comm->me != 0) { + params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); + } + + MPI_Bcast(params, maxparam*sizeof(Param), MPI_BYTE, 0, world); } /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_comb.h b/src/MANYBODY/pair_comb.h index 19788dfab1..7a3d279033 100644 --- a/src/MANYBODY/pair_comb.h +++ b/src/MANYBODY/pair_comb.h @@ -38,6 +38,8 @@ class PairComb : public Pair { virtual double yasu_char(double *, int &); double enegtot; + static const int NPARAMS_PER_LINE = 49; + protected: struct Param { double lam11,lam12,lam21,lam22; diff --git a/src/MANYBODY/pair_comb3.cpp b/src/MANYBODY/pair_comb3.cpp index bf66ea550a..874503f76e 100644 --- a/src/MANYBODY/pair_comb3.cpp +++ b/src/MANYBODY/pair_comb3.cpp @@ -34,11 +34,12 @@ #include "memory.h" #include "error.h" #include "utils.h" +#include "tokenizer.h" +#include "potential_file_reader.h" using namespace LAMMPS_NS; using namespace MathConst; -#define MAXLINE 1024 #define DELTA 4 #define PGDELTA 1 #define MAXNEIGH 24 @@ -315,217 +316,208 @@ void PairComb3::read_lib() int i,j,k,l,nwords,m; int ii,jj,kk,ll,mm,iii; char s[MAXLIB]; - char **words = new char*[80]; - // open libraray file on proc 0 + // open library file on proc 0 if (comm->me == 0) { const char filename[] = "lib.comb3"; FILE *fp = force->open_potential(filename); if (fp == NULL) error->one(FLERR,"Cannot open COMB3 lib.comb3 file"); - // read and store at the same time - utils::sfgets(FLERR,s,MAXLIB,fp,filename,error); - utils::sfgets(FLERR,s,MAXLIB,fp,filename,error); - nwords = 0; - words[nwords++] = strtok(s," \t\n\r\f"); - while ((words[nwords++] = strtok(NULL," \t\n\r\f")))continue; - ccutoff[0] = atof(words[0]); - ccutoff[1] = atof(words[1]); - ccutoff[2] = atof(words[2]); - ccutoff[3] = atof(words[3]); - ccutoff[4] = atof(words[4]); - ccutoff[5] = atof(words[5]); + try { + // read and store at the same time + utils::sfgets(FLERR, s, MAXLIB, fp, filename, error); - utils::sfgets(FLERR,s,MAXLIB,fp,filename,error); - nwords = 0; - words[nwords++] = strtok(s," \t\n\r\f"); - while ((words[nwords++] = strtok(NULL," \t\n\r\f")))continue; - ch_a[0] = atof(words[0]); - ch_a[1] = atof(words[1]); - ch_a[2] = atof(words[2]); - ch_a[3] = atof(words[3]); - ch_a[4] = atof(words[4]); - ch_a[5] = atof(words[5]); - ch_a[6] = atof(words[6]); + utils::sfgets(FLERR, s, MAXLIB, fp, filename, error); + ValueTokenizer values(s, " \t\n\r\f"); - utils::sfgets(FLERR,s,MAXLIB,fp,filename,error); - nwords = 0; - words[nwords++] = strtok(s," \t\n\r\f"); - while ((words[nwords++] = strtok(NULL," \t\n\r\f")))continue; - nsplpcn = atoi(words[0]); - nsplrad = atoi(words[1]); - nspltor = atoi(words[2]); + ccutoff[0] = values.next_double(); + ccutoff[1] = values.next_double(); + ccutoff[2] = values.next_double(); + ccutoff[3] = values.next_double(); + ccutoff[4] = values.next_double(); + ccutoff[5] = values.next_double(); - utils::sfgets(FLERR,s,MAXLIB,fp,filename,error); - nwords = 0; - words[nwords++] = strtok(s," \t\n\r\f"); - while ((words[nwords++] = strtok(NULL," \t\n\r\f")))continue; - maxx = atoi(words[0]); - maxy = atoi(words[1]); - maxz = atoi(words[2]); + utils::sfgets(FLERR, s, MAXLIB, fp, filename, error); + values = ValueTokenizer(s, " \t\n\r\f"); - utils::sfgets(FLERR,s,MAXLIB,fp,filename,error); - nwords = 0; - words[nwords++] = strtok(s," \t\n\r\f"); - while ((words[nwords++] = strtok(NULL," \t\n\r\f")))continue; - maxxc = atoi(words[0]); - maxyc = atoi(words[1]); - maxconj = atoi(words[2]); + ch_a[0] = values.next_double(); + ch_a[1] = values.next_double(); + ch_a[2] = values.next_double(); + ch_a[3] = values.next_double(); + ch_a[4] = values.next_double(); + ch_a[5] = values.next_double(); + ch_a[6] = values.next_double(); + + utils::sfgets(FLERR, s, MAXLIB, fp, filename, error); + values = ValueTokenizer(s, " \t\n\r\f"); + + nsplpcn = values.next_int(); + nsplrad = values.next_int(); + nspltor = values.next_int(); + + utils::sfgets(FLERR, s, MAXLIB, fp, filename, error); + values = ValueTokenizer(s, " \t\n\r\f"); + + maxx = values.next_int(); + maxy = values.next_int(); + maxz = values.next_int(); - for (l=0; lone(FLERR, e.what()); + } } k = 0; @@ -584,211 +576,163 @@ void PairComb3::read_lib() MPI_Bcast(&iin2[0][0],32,MPI_INT,0,world); MPI_Bcast(&iin3[0][0],192,MPI_INT,0,world); - delete [] words; } /* ---------------------------------------------------------------------- */ void PairComb3::read_file(char *file) { - int params_per_line = 74; - char **words = new char*[params_per_line+1]; - - if (params) delete [] params; - params = NULL; + memory->sfree(params); + params = nullptr; nparams = 0; + maxparam = 0; // open file on proc 0 - - FILE *fp; if (comm->me == 0) { - fp = force->open_potential(file); - if (fp == NULL) { - char str[128]; - snprintf(str,128,"Cannot open COMB3 potential file %s",file); - error->one(FLERR,str); - } - } + PotentialFileReader reader(lmp, file, "COMB3"); + char * line; - // read each line out of file, skipping blank lines or leading '#' - // store line of params if all 3 element tags are in element list + while(line = reader.next_line(NPARAMS_PER_LINE)) { + try { + ValueTokenizer values(line, " \t\n\r\f"); - int n,nwords,ielement,jelement,kelement; - char line[MAXLINE],*ptr; - int eof = 0; - nwords=0; - while (1) { - if (comm->me == 0) { - ptr = fgets(line,MAXLINE,fp); - if (ptr == NULL) { - eof = 1; - fclose(fp); - } 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); + std::string iname = values.next_string(); + std::string jname = values.next_string(); + std::string kname = values.next_string(); - // strip comment, skip line if blank + // ielement,jelement,kelement = 1st args + // if all 3 args are in element list, then parse this line + // else skip to next line + int ielement, jelement, kelement; - if ((ptr = strchr(line,'#'))) *ptr = '\0'; + for (ielement = 0; ielement < nelements; ielement++) + if (iname == elements[ielement]) break; + if (ielement == nelements) continue; + for (jelement = 0; jelement < nelements; jelement++) + if (jname == elements[jelement]) break; + if (jelement == nelements) continue; + for (kelement = 0; kelement < nelements; kelement++) + if (kname == elements[kelement]) break; + if (kelement == nelements) continue; - nwords = atom->count_words(line); - if (nwords == 0) continue; + // load up parameter settings and error check their values - // concatenate additional lines until have params_per_line words + if (nparams == maxparam) { + maxparam += DELTA; + params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), + "pair:params"); + } - while (nwords < params_per_line) { - n = strlen(line); - - if (comm->me == 0) { - ptr = fgets(&line[n],MAXLINE-n,fp); - if (ptr == NULL) { - eof = 1; - fclose(fp); - } else n = strlen(line) + 1; + params[nparams].ielement = ielement; + params[nparams].jelement = jelement; + params[nparams].kelement = kelement; + params[nparams].ielementgp = values.next_int(); + params[nparams].jelementgp = values.next_int(); + params[nparams].kelementgp = values.next_int(); + params[nparams].ang_flag = values.next_int(); + params[nparams].pcn_flag = values.next_int(); + params[nparams].rad_flag = values.next_int(); + params[nparams].tor_flag = values.next_int(); + params[nparams].vdwflag = values.next_double(); + params[nparams].powerm = values.next_double(); + params[nparams].veps = values.next_double(); + params[nparams].vsig = values.next_double(); + params[nparams].paaa = values.next_double(); + params[nparams].pbbb = values.next_double(); + params[nparams].lami = values.next_double(); + params[nparams].alfi = values.next_double(); + params[nparams].powern = values.next_double(); + params[nparams].QL = values.next_double(); + params[nparams].QU = values.next_double(); + params[nparams].DL = values.next_double(); + params[nparams].DU = values.next_double(); + params[nparams].qmin = values.next_double(); + params[nparams].qmax = values.next_double(); + params[nparams].chi = values.next_double(); + params[nparams].dj = values.next_double(); + params[nparams].dk = values.next_double(); + params[nparams].dl = values.next_double(); + params[nparams].esm = values.next_double(); + params[nparams].cmn1 = values.next_double(); + params[nparams].cmn2 = values.next_double(); + params[nparams].pcmn1 = values.next_double(); + params[nparams].pcmn2 = values.next_double(); + params[nparams].coulcut = values.next_double(); + params[nparams].polz = values.next_double(); + params[nparams].curl = values.next_double(); + params[nparams].curlcut1 = values.next_double(); + params[nparams].curlcut2 = values.next_double(); + params[nparams].curl0 = values.next_double(); + params[nparams].alpha1 = values.next_double(); + params[nparams].bigB1 = values.next_double(); + params[nparams].alpha2 = values.next_double(); + params[nparams].bigB2 = values.next_double(); + params[nparams].alpha3 = values.next_double(); + params[nparams].bigB3 = values.next_double(); + params[nparams].lambda = values.next_double(); + params[nparams].bigA = values.next_double(); + params[nparams].beta = values.next_double(); + params[nparams].bigr = values.next_double(); + params[nparams].bigd = values.next_double(); + params[nparams].pcos6 = values.next_double(); + params[nparams].pcos5 = values.next_double(); + params[nparams].pcos4 = values.next_double(); + params[nparams].pcos3 = values.next_double(); + params[nparams].pcos2 = values.next_double(); + params[nparams].pcos1 = values.next_double(); + params[nparams].pcos0 = values.next_double(); + params[nparams].pcna = values.next_double(); + params[nparams].pcnb = values.next_double(); + params[nparams].pcnc = values.next_double(); + params[nparams].pcnd = values.next_double(); + params[nparams].p6p0 = values.next_double(); + params[nparams].p6p1 = values.next_double(); + params[nparams].p6p2 = values.next_double(); + params[nparams].p6p3 = values.next_double(); + params[nparams].p6p4 = values.next_double(); + params[nparams].p6p5 = values.next_double(); + params[nparams].p6p6 = values.next_double(); + params[nparams].ptork1 = values.next_double(); + params[nparams].ptork2 = values.next_double(); + params[nparams].addrepr = values.next_double(); + params[nparams].addrep = values.next_double(); + params[nparams].pcross = values.next_double(); + params[nparams].powermint = int(params[nparams].powerm); + } catch (TokenizerException & e) { + error->one(FLERR, e.what()); } - 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); - if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + + // parameter sanity checks + + if (params[nparams].lambda < 0.0 || params[nparams].powern < 0.0 || + params[nparams].beta < 0.0 || params[nparams].alpha1 < 0.0 || + params[nparams].bigB1< 0.0 || params[nparams].bigA< 0.0 || + params[nparams].bigB2< 0.0 || params[nparams].alpha2 <0.0 || + params[nparams].bigB3< 0.0 || params[nparams].alpha3 <0.0 || + params[nparams].bigr < 0.0 || params[nparams].bigd < 0.0 || + params[nparams].bigd > params[nparams].bigr || + params[nparams].powerm - params[nparams].powermint != 0.0 || + params[nparams].addrepr < 0.0 || params[nparams].powermint < 1.0 || + params[nparams].QL > 0.0 || params[nparams].QU < 0.0 || + params[nparams].DL < 0.0 || params[nparams].DU > 0.0 || + params[nparams].pcross < 0.0 || + params[nparams].esm < 0.0 || params[nparams].veps < 0.0 || + params[nparams].vsig < 0.0 || params[nparams].vdwflag < 0.0 + ) + error->one(FLERR,"Illegal COMB3 parameter"); + + nparams++; } - if (nwords != params_per_line){ - error->all(FLERR,"Incorrect format in COMB3 potential file"); -} - // words = ptrs to all words in line - - nwords = 0; - words[nwords++] = strtok(line," \t\n\r\f"); - while ((nwords <= params_per_line) - && (words[nwords++] = strtok(NULL," \t\n\r\f"))) { - continue; - } - - // ielement,jelement,kelement = 1st args - // if all 3 args are in element list, then parse this line - // else skip to next line - - for (ielement = 0; ielement < nelements; ielement++) - if (strcmp(words[0],elements[ielement]) == 0) break; - if (ielement == nelements) continue; - for (jelement = 0; jelement < nelements; jelement++) - if (strcmp(words[1],elements[jelement]) == 0) break; - if (jelement == nelements) continue; - for (kelement = 0; kelement < nelements; kelement++) - if (strcmp(words[2],elements[kelement]) == 0) break; - if (kelement == nelements) continue; - - // load up parameter settings and error check their values - - if (nparams == maxparam) { - maxparam += DELTA; - params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), - "pair:params"); - } - - params[nparams].ielement = ielement; - params[nparams].jelement = jelement; - params[nparams].kelement = kelement; - params[nparams].ielementgp = atoi(words[3]); - params[nparams].jelementgp = atoi(words[4]); - params[nparams].kelementgp = atoi(words[5]); - params[nparams].ang_flag = atoi(words[6]); - params[nparams].pcn_flag = atoi(words[7]); - params[nparams].rad_flag = atoi(words[8]); - params[nparams].tor_flag = atoi(words[9]); - params[nparams].vdwflag = atof(words[10]); - params[nparams].powerm = atof(words[11]); - params[nparams].veps = atof(words[12]); - params[nparams].vsig = atof(words[13]); - params[nparams].paaa = atof(words[14]); - params[nparams].pbbb = atof(words[15]); - params[nparams].lami = atof(words[16]); - params[nparams].alfi = atof(words[17]); - params[nparams].powern = atof(words[18]); - params[nparams].QL = atof(words[19]); - params[nparams].QU = atof(words[20]); - params[nparams].DL = atof(words[21]); - params[nparams].DU = atof(words[22]); - params[nparams].qmin = atof(words[23]); - params[nparams].qmax = atof(words[24]); - params[nparams].chi = atof(words[25]); - params[nparams].dj = atof(words[26]); - params[nparams].dk = atof(words[27]); - params[nparams].dl = atof(words[28]); - params[nparams].esm = atof(words[29]); - params[nparams].cmn1 = atof(words[30]); - params[nparams].cmn2 = atof(words[31]); - params[nparams].pcmn1 = atof(words[32]); - params[nparams].pcmn2 = atof(words[33]); - params[nparams].coulcut = atof(words[34]); - params[nparams].polz = atof(words[35]); - params[nparams].curl = atof(words[36]); - params[nparams].curlcut1 = atof(words[37]); - params[nparams].curlcut2 = atof(words[38]); - params[nparams].curl0 = atof(words[39]); - params[nparams].alpha1 = atof(words[40]); - params[nparams].bigB1 = atof(words[41]); - params[nparams].alpha2 = atof(words[42]); - params[nparams].bigB2 = atof(words[43]); - params[nparams].alpha3 = atof(words[44]); - params[nparams].bigB3 = atof(words[45]); - params[nparams].lambda = atof(words[46]); - params[nparams].bigA = atof(words[47]); - params[nparams].beta = atof(words[48]); - params[nparams].bigr = atof(words[49]); - params[nparams].bigd = atof(words[50]); - params[nparams].pcos6 = atof(words[51]); - params[nparams].pcos5 = atof(words[52]); - params[nparams].pcos4 = atof(words[53]); - params[nparams].pcos3 = atof(words[54]); - params[nparams].pcos2 = atof(words[55]); - params[nparams].pcos1 = atof(words[56]); - params[nparams].pcos0 = atof(words[57]); - params[nparams].pcna = atof(words[58]); - params[nparams].pcnb = atof(words[59]); - params[nparams].pcnc = atof(words[60]); - params[nparams].pcnd = atof(words[61]); - params[nparams].p6p0 = atof(words[62]); - params[nparams].p6p1 = atof(words[63]); - params[nparams].p6p2 = atof(words[64]); - params[nparams].p6p3 = atof(words[65]); - params[nparams].p6p4 = atof(words[66]); - params[nparams].p6p5 = atof(words[67]); - params[nparams].p6p6 = atof(words[68]); - params[nparams].ptork1=atof(words[69]); - params[nparams].ptork2=atof(words[70]); - params[nparams].addrepr=atof(words[71]); - params[nparams].addrep=atof(words[72]); - params[nparams].pcross = atof(words[73]); - params[nparams].powermint = int(params[nparams].powerm); - - // parameter sanity checks - - if (params[nparams].lambda < 0.0 || params[nparams].powern < 0.0 || - params[nparams].beta < 0.0 || params[nparams].alpha1 < 0.0 || - params[nparams].bigB1< 0.0 || params[nparams].bigA< 0.0 || - params[nparams].bigB2< 0.0 || params[nparams].alpha2 <0.0 || - params[nparams].bigB3< 0.0 || params[nparams].alpha3 <0.0 || - params[nparams].bigr < 0.0 || params[nparams].bigd < 0.0 || - params[nparams].bigd > params[nparams].bigr || - params[nparams].powerm - params[nparams].powermint != 0.0 || - params[nparams].addrepr < 0.0 || params[nparams].powermint < 1.0 || - params[nparams].QL > 0.0 || params[nparams].QU < 0.0 || - params[nparams].DL < 0.0 || params[nparams].DU > 0.0 || - params[nparams].pcross < 0.0 || - params[nparams].esm < 0.0 || params[nparams].veps < 0.0 || - params[nparams].vsig < 0.0 || params[nparams].vdwflag < 0.0 - ) - error->all(FLERR,"Illegal COMB3 parameter"); - - nparams++; } - delete [] words; + MPI_Bcast(&nparams, 1, MPI_INT, 0, world); + MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); + + if(comm->me != 0) { + params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); + } + + MPI_Bcast(params, maxparam*sizeof(Param), MPI_BYTE, 0, world); } /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_comb3.h b/src/MANYBODY/pair_comb3.h index 210f843139..567859127b 100644 --- a/src/MANYBODY/pair_comb3.h +++ b/src/MANYBODY/pair_comb3.h @@ -37,8 +37,10 @@ class PairComb3 : public Pair { virtual double combqeq(double *, int &); double enegtot; - // general potential parameters + static const int NPARAMS_PER_LINE = 74; + protected: + // general potential parameters struct Param { int ielement,jelement,kelement,powermint; int ielementgp,jelementgp,kelementgp; //element group diff --git a/src/MANYBODY/pair_eam.cpp b/src/MANYBODY/pair_eam.cpp index a1bc6e1eb4..0013a3271d 100644 --- a/src/MANYBODY/pair_eam.cpp +++ b/src/MANYBODY/pair_eam.cpp @@ -29,6 +29,8 @@ #include "error.h" #include "update.h" #include "utils.h" +#include "tokenizer.h" +#include "potential_file_reader.h" using namespace LAMMPS_NS; @@ -462,54 +464,59 @@ void PairEAM::read_file(char *filename) { Funcfl *file = &funcfl[nfuncfl-1]; - int me = comm->me; - FILE *fptr; - char line[MAXLINE]; + // read potential file + if(comm->me == 0) { + PotentialFileReader reader(lmp, filename, "EAM"); - if (me == 0) { - fptr = force->open_potential(filename); - if (fptr == NULL) { - char str[128]; - snprintf(str,128,"Cannot open EAM potential file %s",filename); - error->one(FLERR,str); + try { + char * line = nullptr; + + reader.skip_line(); + + line = reader.next_line(2); + ValueTokenizer values(line); + values.next_int(); // ignore + file->mass = values.next_double(); + + line = reader.next_line(5); + values = ValueTokenizer(line); + file->nrho = values.next_int(); + file->drho = values.next_double(); + file->nr = values.next_int(); + file->dr = values.next_double(); + file->cut = values.next_double(); + + if ((file->nrho <= 0) || (file->nr <= 0) || (file->dr <= 0.0)) + error->one(FLERR,"Invalid EAM potential file"); + + memory->create(file->frho, (file->nrho+1), "pair:frho"); + memory->create(file->rhor, (file->nr+1), "pair:rhor"); + memory->create(file->zr, (file->nr+1), "pair:zr"); + + reader.next_dvector(file->nrho, &file->frho[1]); + reader.next_dvector(file->nr, &file->zr[1]); + reader.next_dvector(file->nr, &file->rhor[1]); + } catch (TokenizerException & e) { + error->one(FLERR, e.what()); } } - int tmp,nwords; - if (me == 0) { - utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error); - utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error); - sscanf(line,"%d %lg",&tmp,&file->mass); - utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error); - nwords = sscanf(line,"%d %lg %d %lg %lg", - &file->nrho,&file->drho,&file->nr,&file->dr,&file->cut); + MPI_Bcast(&file->mass, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->nrho, 1, MPI_INT, 0, world); + MPI_Bcast(&file->drho, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->nr, 1, MPI_INT, 0, world); + MPI_Bcast(&file->dr, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->cut, 1, MPI_DOUBLE, 0, world); + + if(comm->me != 0) { + memory->create(file->frho, (file->nrho+1), "pair:frho"); + memory->create(file->rhor, (file->nr+1), "pair:rhor"); + memory->create(file->zr, (file->nr+1), "pair:zr"); } - MPI_Bcast(&nwords,1,MPI_INT,0,world); - MPI_Bcast(&file->mass,1,MPI_DOUBLE,0,world); - MPI_Bcast(&file->nrho,1,MPI_INT,0,world); - MPI_Bcast(&file->drho,1,MPI_DOUBLE,0,world); - MPI_Bcast(&file->nr,1,MPI_INT,0,world); - MPI_Bcast(&file->dr,1,MPI_DOUBLE,0,world); - MPI_Bcast(&file->cut,1,MPI_DOUBLE,0,world); - - if ((nwords != 5) || (file->nrho <= 0) || (file->nr <= 0) || (file->dr <= 0.0)) - error->all(FLERR,"Invalid EAM potential file"); - - memory->create(file->frho,(file->nrho+1),"pair:frho"); - memory->create(file->rhor,(file->nr+1),"pair:rhor"); - memory->create(file->zr,(file->nr+1),"pair:zr"); - - if (me == 0) grab(fptr,file->nrho,&file->frho[1]); - MPI_Bcast(&file->frho[1],file->nrho,MPI_DOUBLE,0,world); - - if (me == 0) grab(fptr,file->nr,&file->zr[1]); - MPI_Bcast(&file->zr[1],file->nr,MPI_DOUBLE,0,world); - - if (me == 0) grab(fptr,file->nr,&file->rhor[1]); - MPI_Bcast(&file->rhor[1],file->nr,MPI_DOUBLE,0,world); - - if (me == 0) fclose(fptr); + MPI_Bcast(&file->frho[1], file->nrho, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->zr[1], file->nr, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->rhor[1], file->nr, MPI_DOUBLE, 0, world); } /* ---------------------------------------------------------------------- @@ -782,26 +789,6 @@ void PairEAM::interpolate(int n, double delta, double *f, double **spline) } } -/* ---------------------------------------------------------------------- - grab n values from file fp and put them in list - values can be several to a line - only called by proc 0 -------------------------------------------------------------------------- */ - -void PairEAM::grab(FILE *fptr, int n, double *list) -{ - char *ptr; - char line[MAXLINE]; - - int i = 0; - while (i < n) { - utils::sfgets(FLERR,line,MAXLINE,fptr,NULL,error); - ptr = strtok(line," \t\n\r\f"); - if (ptr) list[i++] = atof(ptr); - while ((ptr = strtok(NULL," \t\n\r\f"))) list[i++] = atof(ptr); - } -} - /* ---------------------------------------------------------------------- */ double PairEAM::single(int i, int j, int itype, int jtype, diff --git a/src/MANYBODY/pair_eam.h b/src/MANYBODY/pair_eam.h index d98dba1e66..ed525a471c 100644 --- a/src/MANYBODY/pair_eam.h +++ b/src/MANYBODY/pair_eam.h @@ -107,7 +107,6 @@ class PairEAM : public Pair { virtual void allocate(); virtual void array2spline(); void interpolate(int, double, double *, double **); - void grab(FILE *, int, double *); virtual void read_file(char *); virtual void file2array(); diff --git a/src/MANYBODY/pair_eam_alloy.cpp b/src/MANYBODY/pair_eam_alloy.cpp index a9622f9e07..65ed9b7d2f 100644 --- a/src/MANYBODY/pair_eam_alloy.cpp +++ b/src/MANYBODY/pair_eam_alloy.cpp @@ -24,11 +24,11 @@ #include "memory.h" #include "error.h" #include "utils.h" +#include "tokenizer.h" +#include "potential_file_reader.h" using namespace LAMMPS_NS; -#define MAXLINE 1024 - /* ---------------------------------------------------------------------- */ PairEAMAlloy::PairEAMAlloy(LAMMPS *lmp) : PairEAM(lmp) @@ -61,7 +61,7 @@ void PairEAMAlloy::coeff(int narg, char **arg) if (setfl) { for (i = 0; i < setfl->nelements; i++) delete [] setfl->elements[i]; delete [] setfl->elements; - delete [] setfl->mass; + memory->destroy(setfl->mass); memory->destroy(setfl->frho); memory->destroy(setfl->rhor); memory->destroy(setfl->z2r); @@ -117,98 +117,112 @@ void PairEAMAlloy::read_file(char *filename) { Setfl *file = setfl; - // open potential file + // read potential file + if(comm->me == 0) { + PotentialFileReader reader(lmp, filename, "EAM"); - int me = comm->me; - FILE *fptr; - char line[MAXLINE]; + try { + char * line = nullptr; - if (me == 0) { - fptr = force->open_potential(filename); - if (fptr == NULL) { - char str[128]; - snprintf(str,128,"Cannot open EAM potential file %s",filename); - error->one(FLERR,str); + reader.skip_line(); + reader.skip_line(); + reader.skip_line(); + + // extract element names from nelements line + line = reader.next_line(1); + ValueTokenizer values(line); + file->nelements = values.next_int(); + + if (values.count() != file->nelements + 1) + error->one(FLERR,"Incorrect element names in EAM potential file"); + + file->elements = new char*[file->nelements]; + for (int i = 0; i < file->nelements; i++) { + const std::string word = values.next_string(); + const int n = word.length() + 1; + file->elements[i] = new char[n]; + strcpy(file->elements[i], word.c_str()); + } + + // + + line = reader.next_line(5); + values = ValueTokenizer(line); + file->nrho = values.next_int(); + file->drho = values.next_double(); + file->nr = values.next_int(); + file->dr = values.next_double(); + file->cut = values.next_double(); + + if ((file->nrho <= 0) || (file->nr <= 0) || (file->dr <= 0.0)) + error->one(FLERR,"Invalid EAM potential file"); + + memory->create(file->mass, file->nelements, "pair:mass"); + memory->create(file->frho, file->nelements, file->nrho + 1, "pair:frho"); + memory->create(file->rhor, file->nelements, file->nr + 1, "pair:rhor"); + memory->create(file->z2r, file->nelements, file->nelements, file->nr + 1, "pair:z2r"); + + for (int i = 0; i < file->nelements; i++) { + line = reader.next_line(2); + values = ValueTokenizer(line); + values.next_int(); // ignore + file->mass[i] = values.next_double(); + + reader.next_dvector(file->nrho, &file->frho[i][1]); + reader.next_dvector(file->nr, &file->rhor[i][1]); + } + + for (int i = 0; i < file->nelements; i++) { + for (int j = 0; j <= i; j++) { + reader.next_dvector(file->nr, &file->z2r[i][j][1]); + } + } + } catch (TokenizerException & e) { + error->one(FLERR, e.what()); } } - // read and broadcast header - // extract element names from nelements line + // broadcast potential information + MPI_Bcast(&file->nelements, 1, MPI_INT, 0, world); - int n; - if (me == 0) { - utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error); - utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error); - utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error); - utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error); - n = strlen(line) + 1; + MPI_Bcast(&file->nrho, 1, MPI_INT, 0, world); + MPI_Bcast(&file->drho, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->nr, 1, MPI_INT, 0, world); + MPI_Bcast(&file->dr, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->cut, 1, MPI_DOUBLE, 0, world); + + // allocate memory on other procs + if (comm->me != 0) { + file->elements = new char*[file->nelements]; + for (int i = 0; i < file->nelements; i++) file->elements[i] = nullptr; + memory->create(file->mass, file->nelements, "pair:mass"); + memory->create(file->frho, file->nelements, file->nrho + 1, "pair:frho"); + memory->create(file->rhor, file->nelements, file->nr + 1, "pair:rhor"); + memory->create(file->z2r, file->nelements, file->nelements, file->nr + 1, "pair:z2r"); } - MPI_Bcast(&n,1,MPI_INT,0,world); - MPI_Bcast(line,n,MPI_CHAR,0,world); - sscanf(line,"%d",&file->nelements); - int nwords = atom->count_words(line); - if (nwords != file->nelements + 1) - error->all(FLERR,"Incorrect element names in EAM potential file"); - - char **words = new char*[file->nelements+1]; - nwords = 0; - strtok(line," \t\n\r\f"); - while ((words[nwords++] = strtok(NULL," \t\n\r\f"))) continue; - - file->elements = new char*[file->nelements]; + // broadcast file->elements string array for (int i = 0; i < file->nelements; i++) { - n = strlen(words[i]) + 1; - file->elements[i] = new char[n]; - strcpy(file->elements[i],words[i]); - } - delete [] words; - - if (me == 0) { - utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error); - nwords = sscanf(line,"%d %lg %d %lg %lg", - &file->nrho,&file->drho,&file->nr,&file->dr,&file->cut); + int n; + if (comm->me == 0) n = strlen(file->elements[i]) + 1; + MPI_Bcast(&n, 1, MPI_INT, 0, world); + if (comm->me != 0) file->elements[i] = new char[n]; + MPI_Bcast(file->elements[i], n, MPI_CHAR, 0, world); } - MPI_Bcast(&nwords,1,MPI_INT,0,world); - MPI_Bcast(&file->nrho,1,MPI_INT,0,world); - MPI_Bcast(&file->drho,1,MPI_DOUBLE,0,world); - MPI_Bcast(&file->nr,1,MPI_INT,0,world); - MPI_Bcast(&file->dr,1,MPI_DOUBLE,0,world); - MPI_Bcast(&file->cut,1,MPI_DOUBLE,0,world); + // broadcast file->mass, frho, rhor + for (int i = 0; i < file->nelements; i++) { + MPI_Bcast(&file->mass[i], 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->frho[i][1], file->nrho, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->rhor[i][1], file->nr, MPI_DOUBLE, 0, world); + } - if ((nwords != 5) || (file->nrho <= 0) || (file->nr <= 0) || (file->dr <= 0.0)) - error->all(FLERR,"Invalid EAM potential file"); - - file->mass = new double[file->nelements]; - memory->create(file->frho,file->nelements,file->nrho+1,"pair:frho"); - memory->create(file->rhor,file->nelements,file->nr+1,"pair:rhor"); - memory->create(file->z2r,file->nelements,file->nelements,file->nr+1, - "pair:z2r"); - - int i,j,tmp; - for (i = 0; i < file->nelements; i++) { - if (me == 0) { - utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error); - sscanf(line,"%d %lg",&tmp,&file->mass[i]); + // broadcast file->z2r + for (int i = 0; i < file->nelements; i++) { + for (int j = 0; j <= i; j++) { + MPI_Bcast(&file->z2r[i][j][1], file->nr, MPI_DOUBLE, 0, world); } - MPI_Bcast(&file->mass[i],1,MPI_DOUBLE,0,world); - - if (me == 0) grab(fptr,file->nrho,&file->frho[i][1]); - MPI_Bcast(&file->frho[i][1],file->nrho,MPI_DOUBLE,0,world); - if (me == 0) grab(fptr,file->nr,&file->rhor[i][1]); - MPI_Bcast(&file->rhor[i][1],file->nr,MPI_DOUBLE,0,world); } - - for (i = 0; i < file->nelements; i++) - for (j = 0; j <= i; j++) { - if (me == 0) grab(fptr,file->nr,&file->z2r[i][j][1]); - MPI_Bcast(&file->z2r[i][j][1],file->nr,MPI_DOUBLE,0,world); - } - - // close the potential file - - if (me == 0) fclose(fptr); } /* ---------------------------------------------------------------------- diff --git a/src/MANYBODY/pair_eam_cd.cpp b/src/MANYBODY/pair_eam_cd.cpp index 28004eae7f..099ffd77cd 100644 --- a/src/MANYBODY/pair_eam_cd.cpp +++ b/src/MANYBODY/pair_eam_cd.cpp @@ -28,6 +28,7 @@ #include "neigh_list.h" #include "memory.h" #include "error.h" +#include "tokenizer.h" using namespace LAMMPS_NS; @@ -512,16 +513,20 @@ void PairEAMCD::read_h_coeff(char *filename) while(fgets(nextline, MAXLINE, fptr) != NULL) { strcpy(line, nextline); } - char* ptr = strtok(line, " \t\n\r\f"); - int degree = atoi(ptr); + + ValueTokenizer values(line, " \t\n\r\f"); + int degree = values.next_int(); nhcoeff = degree+1; + + if (values.count() != nhcoeff + 1 || nhcoeff < 1) + error->one(FLERR, "Failed to read h(x) function coefficients in EAM file."); + hcoeff = new double[nhcoeff]; + int i = 0; - while((ptr = strtok(NULL," \t\n\r\f")) != NULL && i < nhcoeff) { - hcoeff[i++] = atof(ptr); + while(values.has_next()) { + hcoeff[i++] = values.next_double(); } - if (i != nhcoeff || nhcoeff < 1) - error->one(FLERR,"Failed to read h(x) function coefficients from EAM file."); // Close the potential file. diff --git a/src/MANYBODY/pair_eam_fs.cpp b/src/MANYBODY/pair_eam_fs.cpp index c91e7b5298..fe4fa95268 100644 --- a/src/MANYBODY/pair_eam_fs.cpp +++ b/src/MANYBODY/pair_eam_fs.cpp @@ -24,11 +24,11 @@ #include "memory.h" #include "error.h" #include "utils.h" +#include "tokenizer.h" +#include "potential_file_reader.h" using namespace LAMMPS_NS; -#define MAXLINE 1024 - /* ---------------------------------------------------------------------- */ PairEAMFS::PairEAMFS(LAMMPS *lmp) : PairEAM(lmp) @@ -61,7 +61,7 @@ void PairEAMFS::coeff(int narg, char **arg) if (fs) { for (i = 0; i < fs->nelements; i++) delete [] fs->elements[i]; delete [] fs->elements; - delete [] fs->mass; + memory->destroy(fs->mass); memory->destroy(fs->frho); memory->destroy(fs->rhor); memory->destroy(fs->z2r); @@ -117,103 +117,118 @@ void PairEAMFS::read_file(char *filename) { Fs *file = fs; - // open potential file + // read potential file + if(comm->me == 0) { + PotentialFileReader reader(lmp, filename, "EAM"); - int me = comm->me; - FILE *fptr; - char line[MAXLINE]; + try { + char * line = nullptr; - if (me == 0) { - fptr = force->open_potential(filename); - if (fptr == NULL) { - char str[128]; - snprintf(str,128,"Cannot open EAM potential file %s",filename); - error->one(FLERR,str); + reader.skip_line(); + reader.skip_line(); + reader.skip_line(); + + // extract element names from nelements line + line = reader.next_line(1); + ValueTokenizer values(line); + file->nelements = values.next_int(); + + if (values.count() != file->nelements + 1) + error->one(FLERR,"Incorrect element names in EAM potential file"); + + file->elements = new char*[file->nelements]; + for (int i = 0; i < file->nelements; i++) { + const std::string word = values.next_string(); + const int n = word.length() + 1; + file->elements[i] = new char[n]; + strcpy(file->elements[i], word.c_str()); + } + + // + + line = reader.next_line(5); + values = ValueTokenizer(line); + file->nrho = values.next_int(); + file->drho = values.next_double(); + file->nr = values.next_int(); + file->dr = values.next_double(); + file->cut = values.next_double(); + + if ((file->nrho <= 0) || (file->nr <= 0) || (file->dr <= 0.0)) + error->one(FLERR,"Invalid EAM potential file"); + + memory->create(file->mass, file->nelements, "pair:mass"); + memory->create(file->frho, file->nelements, file->nrho + 1, "pair:frho"); + memory->create(file->rhor, file->nelements, file->nelements, file->nr + 1, "pair:rhor"); + memory->create(file->z2r, file->nelements, file->nelements, file->nr + 1, "pair:z2r"); + + for (int i = 0; i < file->nelements; i++) { + line = reader.next_line(2); + values = ValueTokenizer(line); + values.next_int(); // ignore + file->mass[i] = values.next_double(); + + reader.next_dvector(file->nrho, &file->frho[i][1]); + + for (int j = 0; j < file->nelements; j++) { + reader.next_dvector(file->nr, &file->rhor[i][j][1]); + } + } + + for (int i = 0; i < file->nelements; i++) { + for (int j = 0; j <= i; j++) { + reader.next_dvector(file->nr, &file->z2r[i][j][1]); + } + } + } catch (TokenizerException & e) { + error->one(FLERR, e.what()); } } - // read and broadcast header - // extract element names from nelements line + // broadcast potential information + MPI_Bcast(&file->nelements, 1, MPI_INT, 0, world); - int n; - if (me == 0) { - utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error); - utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error); - utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error); - utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error); - n = strlen(line) + 1; + MPI_Bcast(&file->nrho, 1, MPI_INT, 0, world); + MPI_Bcast(&file->drho, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->nr, 1, MPI_INT, 0, world); + MPI_Bcast(&file->dr, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->cut, 1, MPI_DOUBLE, 0, world); + + // allocate memory on other procs + if (comm->me != 0) { + file->elements = new char*[file->nelements]; + for (int i = 0; i < file->nelements; i++) file->elements[i] = nullptr; + memory->create(file->mass, file->nelements, "pair:mass"); + memory->create(file->frho, file->nelements, file->nrho + 1, "pair:frho"); + memory->create(file->rhor, file->nelements, file->nelements, file->nr + 1, "pair:rhor"); + memory->create(file->z2r, file->nelements, file->nelements, file->nr + 1, "pair:z2r"); } - MPI_Bcast(&n,1,MPI_INT,0,world); - MPI_Bcast(line,n,MPI_CHAR,0,world); - sscanf(line,"%d",&file->nelements); - int nwords = atom->count_words(line); - if (nwords != file->nelements + 1) - error->all(FLERR,"Incorrect element names in EAM potential file"); - - char **words = new char*[file->nelements+1]; - nwords = 0; - strtok(line," \t\n\r\f"); - while ((words[nwords++] = strtok(NULL," \t\n\r\f"))) continue; - - file->elements = new char*[file->nelements]; + // broadcast file->elements string array for (int i = 0; i < file->nelements; i++) { - n = strlen(words[i]) + 1; - file->elements[i] = new char[n]; - strcpy(file->elements[i],words[i]); - } - delete [] words; - - if (me == 0) { - utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error); - nwords = sscanf(line,"%d %lg %d %lg %lg", - &file->nrho,&file->drho,&file->nr,&file->dr,&file->cut); + int n; + if (comm->me == 0) n = strlen(file->elements[i]) + 1; + MPI_Bcast(&n, 1, MPI_INT, 0, world); + if (comm->me != 0) file->elements[i] = new char[n]; + MPI_Bcast(file->elements[i], n, MPI_CHAR, 0, world); } - MPI_Bcast(&nwords,1,MPI_INT,0,world); - MPI_Bcast(&file->nrho,1,MPI_INT,0,world); - MPI_Bcast(&file->drho,1,MPI_DOUBLE,0,world); - MPI_Bcast(&file->nr,1,MPI_INT,0,world); - MPI_Bcast(&file->dr,1,MPI_DOUBLE,0,world); - MPI_Bcast(&file->cut,1,MPI_DOUBLE,0,world); + // broadcast file->mass, frho, rhor + for (int i = 0; i < file->nelements; i++) { + MPI_Bcast(&file->mass[i], 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->frho[i][1], file->nrho, MPI_DOUBLE, 0, world); - if ((nwords != 5) || (file->nrho <= 0) || (file->nr <= 0) || (file->dr <= 0.0)) - error->all(FLERR,"Invalid EAM potential file"); - - file->mass = new double[file->nelements]; - memory->create(file->frho,file->nelements,file->nrho+1, - "pair:frho"); - memory->create(file->rhor,file->nelements,file->nelements, - file->nr+1,"pair:rhor"); - memory->create(file->z2r,file->nelements,file->nelements, - file->nr+1,"pair:z2r"); - - int i,j,tmp; - for (i = 0; i < file->nelements; i++) { - if (me == 0) { - utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error); - sscanf(line,"%d %lg",&tmp,&file->mass[i]); - } - MPI_Bcast(&file->mass[i],1,MPI_DOUBLE,0,world); - - if (me == 0) grab(fptr,file->nrho,&file->frho[i][1]); - MPI_Bcast(&file->frho[i][1],file->nrho,MPI_DOUBLE,0,world); - - for (j = 0; j < file->nelements; j++) { - if (me == 0) grab(fptr,file->nr,&file->rhor[i][j][1]); - MPI_Bcast(&file->rhor[i][j][1],file->nr,MPI_DOUBLE,0,world); + for (int j = 0; j < file->nelements; j++) { + MPI_Bcast(&file->rhor[i][j][1], file->nr, MPI_DOUBLE, 0, world); } } - for (i = 0; i < file->nelements; i++) - for (j = 0; j <= i; j++) { - if (me == 0) grab(fptr,file->nr,&file->z2r[i][j][1]); - MPI_Bcast(&file->z2r[i][j][1],file->nr,MPI_DOUBLE,0,world); + // broadcast file->z2r + for (int i = 0; i < file->nelements; i++) { + for (int j = 0; j <= i; j++) { + MPI_Bcast(&file->z2r[i][j][1], file->nr, MPI_DOUBLE, 0, world); } - - // close the potential file - - if (me == 0) fclose(fptr); + } } /* ---------------------------------------------------------------------- diff --git a/src/MANYBODY/pair_eim.cpp b/src/MANYBODY/pair_eim.cpp index dc1c7fa019..3e7dc36243 100644 --- a/src/MANYBODY/pair_eim.cpp +++ b/src/MANYBODY/pair_eim.cpp @@ -27,11 +27,11 @@ #include "memory.h" #include "error.h" #include "utils.h" +#include "tokenizer.h" +#include "potential_file_reader.h" using namespace LAMMPS_NS; -#define MAXLINE 1024 - /* ---------------------------------------------------------------------- */ PairEIM::PairEIM(LAMMPS *lmp) : Pair(lmp) @@ -451,20 +451,6 @@ double PairEIM::init_one(int i, int j) void PairEIM::read_file(char *filename) { - // open potential file - - int me = comm->me; - FILE *fptr; - - if (me == 0) { - fptr = force->open_potential(filename); - if (fptr == NULL) { - char str[128]; - snprintf(str,128,"Cannot open EIM potential file %s",filename); - error->one(FLERR,str); - } - } - int npair = nelements*(nelements+1)/2; setfl->ielement = new int[nelements]; setfl->mass = new double[nelements]; @@ -488,52 +474,55 @@ void PairEIM::read_file(char *filename) setfl->rs = new double[npair]; setfl->tp = new int[npair]; - if (me == 0) - if (!grabglobal(fptr)) - error->one(FLERR,"Could not grab global entry from EIM potential file"); - MPI_Bcast(&setfl->division,1,MPI_DOUBLE,0,world); - MPI_Bcast(&setfl->rbig,1,MPI_DOUBLE,0,world); - MPI_Bcast(&setfl->rsmall,1,MPI_DOUBLE,0,world); + // read potential file + if( comm->me == 0) { + EIMPotentialFileReader reader(lmp, filename); - for (int i = 0; i < nelements; i++) { - if (me == 0) - if (!grabsingle(fptr,i)) - error->one(FLERR,"Could not grab element entry from EIM potential file"); - MPI_Bcast(&setfl->ielement[i],1,MPI_INT,0,world); - MPI_Bcast(&setfl->mass[i],1,MPI_DOUBLE,0,world); - MPI_Bcast(&setfl->negativity[i],1,MPI_DOUBLE,0,world); - MPI_Bcast(&setfl->ra[i],1,MPI_DOUBLE,0,world); - MPI_Bcast(&setfl->ri[i],1,MPI_DOUBLE,0,world); - MPI_Bcast(&setfl->Ec[i],1,MPI_DOUBLE,0,world); - MPI_Bcast(&setfl->q0[i],1,MPI_DOUBLE,0,world); - } + reader.get_global(setfl); - for (int i = 0; i < nelements; i++) { - for (int j = i; j < nelements; j++) { - int ij; - if (i == j) ij = i; - else if (i < j) ij = nelements*(i+1) - (i+1)*(i+2)/2 + j; - else ij = nelements*(j+1) - (j+1)*(j+2)/2 + i; - if (me == 0) - if (grabpair(fptr,i,j) == 0) - error->one(FLERR,"Could not grab pair entry from EIM potential file"); - MPI_Bcast(&setfl->rcutphiA[ij],1,MPI_DOUBLE,0,world); - MPI_Bcast(&setfl->rcutphiR[ij],1,MPI_DOUBLE,0,world); - MPI_Bcast(&setfl->Eb[ij],1,MPI_DOUBLE,0,world); - MPI_Bcast(&setfl->r0[ij],1,MPI_DOUBLE,0,world); - MPI_Bcast(&setfl->alpha[ij],1,MPI_DOUBLE,0,world); - MPI_Bcast(&setfl->beta[ij],1,MPI_DOUBLE,0,world); - MPI_Bcast(&setfl->rcutq[ij],1,MPI_DOUBLE,0,world); - MPI_Bcast(&setfl->Asigma[ij],1,MPI_DOUBLE,0,world); - MPI_Bcast(&setfl->rq[ij],1,MPI_DOUBLE,0,world); - MPI_Bcast(&setfl->rcutsigma[ij],1,MPI_DOUBLE,0,world); - MPI_Bcast(&setfl->Ac[ij],1,MPI_DOUBLE,0,world); - MPI_Bcast(&setfl->zeta[ij],1,MPI_DOUBLE,0,world); - MPI_Bcast(&setfl->rs[ij],1,MPI_DOUBLE,0,world); - MPI_Bcast(&setfl->tp[ij],1,MPI_INT,0,world); + for (int i = 0; i < nelements; i++) { + reader.get_element(setfl, i, elements[i]); + } + + for (int i = 0; i < nelements; i++) { + for (int j = i; j < nelements; j++) { + int ij; + if (i == j) ij = i; + else if (i < j) ij = nelements*(i+1) - (i+1)*(i+2)/2 + j; + else ij = nelements*(j+1) - (j+1)*(j+2)/2 + i; + reader.get_pair(setfl, ij, elements[i], elements[j]); + } } } + // broadcast potential information to other procs + MPI_Bcast(&setfl->division, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&setfl->rbig, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&setfl->rsmall, 1, MPI_DOUBLE, 0, world); + + MPI_Bcast(setfl->ielement, nelements, MPI_INT, 0, world); + MPI_Bcast(setfl->mass, nelements, MPI_DOUBLE, 0, world); + MPI_Bcast(setfl->negativity, nelements, MPI_DOUBLE, 0, world); + MPI_Bcast(setfl->ra, nelements, MPI_DOUBLE, 0, world); + MPI_Bcast(setfl->ri, nelements, MPI_DOUBLE, 0, world); + MPI_Bcast(setfl->Ec, nelements, MPI_DOUBLE, 0, world); + MPI_Bcast(setfl->q0, nelements, MPI_DOUBLE, 0, world); + + MPI_Bcast(setfl->rcutphiA, npair, MPI_DOUBLE, 0, world); + MPI_Bcast(setfl->rcutphiR, npair, MPI_DOUBLE, 0, world); + MPI_Bcast(setfl->Eb, npair, MPI_DOUBLE, 0, world); + MPI_Bcast(setfl->r0, npair, MPI_DOUBLE, 0, world); + MPI_Bcast(setfl->alpha, npair, MPI_DOUBLE, 0, world); + MPI_Bcast(setfl->beta, npair, MPI_DOUBLE, 0, world); + MPI_Bcast(setfl->rcutq, npair, MPI_DOUBLE, 0, world); + MPI_Bcast(setfl->Asigma, npair, MPI_DOUBLE, 0, world); + MPI_Bcast(setfl->rq, npair, MPI_DOUBLE, 0, world); + MPI_Bcast(setfl->rcutsigma, npair, MPI_DOUBLE, 0, world); + MPI_Bcast(setfl->Ac, npair, MPI_DOUBLE, 0, world); + MPI_Bcast(setfl->zeta, npair, MPI_DOUBLE, 0, world); + MPI_Bcast(setfl->rs, npair, MPI_DOUBLE, 0, world); + MPI_Bcast(setfl->tp, npair, MPI_INT, 0, world); + setfl->nr = 5000; setfl->cut = 0.0; for (int i = 0; i < npair; i++) { @@ -602,10 +591,6 @@ void PairEIM::read_file(char *filename) } } } - - // close the potential file - - if (me == 0) fclose(fptr); } /* ---------------------------------------------------------------------- @@ -879,114 +864,6 @@ void PairEIM::interpolate(int n, double delta, double *f, } } -/* ---------------------------------------------------------------------- - grab global line from file and store info in setfl - return 0 if error -------------------------------------------------------------------------- */ - -int PairEIM::grabglobal(FILE *fptr) -{ - char line[MAXLINE]; - - char *pch = NULL, *data = NULL; - while (pch == NULL) { - if (fgets(line,MAXLINE,fptr) == NULL) break; - pch = strstr(line,"global"); - if (pch != NULL) { - data = strtok (line," \t\n\r\f"); - data = strtok (NULL,"?"); - sscanf(data,"%lg %lg %lg",&setfl->division,&setfl->rbig,&setfl->rsmall); - } - } - if (pch == NULL) return 0; - return 1; -} - -/* ---------------------------------------------------------------------- - grab elemental line from file and store info in setfl - return 0 if error -------------------------------------------------------------------------- */ - -int PairEIM::grabsingle(FILE *fptr, int i) -{ - char line[MAXLINE]; - - rewind(fptr); - - char *pch1 = NULL, *pch2 = NULL, *data = NULL; - while (pch1 == NULL || pch2 == NULL) { - if (fgets(line,MAXLINE,fptr) == NULL) break; - pch1 = strtok (line," \t\n\r\f"); - pch1 = strstr(pch1,"element:"); - if (pch1 != NULL) { - pch2 = strtok(NULL, " \t\n\r\f"); - if (pch2 != NULL) { - data = strtok (NULL, "?"); - if (strcmp(pch2,elements[i]) == 0) { - sscanf(data,"%d %lg %lg %lg %lg %lg %lg",&setfl->ielement[i], - &setfl->mass[i],&setfl->negativity[i],&setfl->ra[i], - &setfl->ri[i],&setfl->Ec[i],&setfl->q0[i]); - } else pch2 = NULL; - } - } - } - if (pch1 == NULL || pch2 == NULL) return 0; - return 1; -} - -/* ---------------------------------------------------------------------- - grab pair line from file and store info in setfl - return 0 if error -------------------------------------------------------------------------- */ - -int PairEIM::grabpair(FILE *fptr, int i, int j) -{ - char line[MAXLINE]; - - rewind(fptr); - - int ij; - if (i == j) ij = i; - else if (i < j) ij = nelements*(i+1) - (i+1)*(i+2)/2 + j; - else ij = nelements*(j+1) - (j+1)*(j+2)/2 + i; - - char *pch1 = NULL, *pch2 = NULL, *pch3 = NULL, *data = NULL; - while (pch1 == NULL || pch2 == NULL || pch3 == NULL) { - if (fgets(line,MAXLINE,fptr) == NULL) break; - pch1 = strtok (line," \t\n\r\f"); - pch1 = strstr(pch1,"pair:"); - if (pch1 != NULL) { - pch2 = strtok (NULL, " \t\n\r\f"); - if (pch2 != NULL) pch3 = strtok (NULL, " \t\n\r\f"); - if (pch3 != NULL) data = strtok (NULL, "?"); - if ((pch2 != NULL) && (pch3 != NULL)) { - if ((strcmp(pch2,elements[i]) == 0 && - strcmp(pch3,elements[j]) == 0) || - (strcmp(pch2,elements[j]) == 0 && - strcmp(pch3,elements[i]) == 0)) { - sscanf(data,"%lg %lg %lg %lg %lg", - &setfl->rcutphiA[ij],&setfl->rcutphiR[ij], - &setfl->Eb[ij],&setfl->r0[ij],&setfl->alpha[ij]); - utils::sfgets(FLERR,line,MAXLINE,fptr,NULL,error); - sscanf(line,"%lg %lg %lg %lg %lg", - &setfl->beta[ij],&setfl->rcutq[ij],&setfl->Asigma[ij], - &setfl->rq[ij],&setfl->rcutsigma[ij]); - utils::sfgets(FLERR,line,MAXLINE,fptr,NULL,error); - sscanf(line,"%lg %lg %lg %d", - &setfl->Ac[ij],&setfl->zeta[ij],&setfl->rs[ij], - &setfl->tp[ij]); - } else { - pch1 = NULL; - pch2 = NULL; - pch3 = NULL; - } - } - } - } - if (pch1 == NULL || pch2 == NULL || pch3 == NULL) return 0; - return 1; -} - /* ---------------------------------------------------------------------- cutoff function ------------------------------------------------------------------------- */ @@ -1171,3 +1048,221 @@ double PairEIM::memory_usage() bytes += 2 * nmax * sizeof(double); return bytes; } + +EIMPotentialFileReader::EIMPotentialFileReader(LAMMPS * lmp, const std::string & filename) : + Pointers(lmp), filename(filename) +{ + if (comm->me != 0) { + error->one(FLERR, "EIMPotentialFileReader should only be called by proc 0!"); + } + + FILE * fp = force->open_potential(filename.c_str()); + + if (fp == NULL) { + char str[128]; + snprintf(str, 128, "cannot open EIM potential file %s", filename.c_str()); + error->one(FLERR, str); + } + + parse(fp); + + fclose(fp); +} + +std::pair EIMPotentialFileReader::get_pair(const std::string & a, const std::string & b) { + if (a < b) { + return std::make_pair(a, b); + } + return std::make_pair(b, a); +} + +char * EIMPotentialFileReader::next_line(FILE * fp) { + // concatenate lines if they end with '&' + // strip comments after '#' + int n = 0; + int nwords = 0; + bool concat = false; + + char *ptr = fgets(line, MAXLINE, fp); + + if (ptr == nullptr) { + // EOF + return nullptr; + } + + // strip comment + if ((ptr = strchr(line, '#'))) *ptr = '\0'; + + // strip ampersand + if ((ptr = strrchr(line, '&'))) { + concat = true; + *ptr = '\0'; + } + + nwords = utils::count_words(line); + + if (nwords > 0) { + n = strlen(line); + } + + while(n == 0 || concat) { + char *ptr = fgets(&line[n], MAXLINE - n, fp); + + if (ptr == nullptr) { + // EOF + return line; + } + + // strip comment + if ((ptr = strchr(line, '#'))) *ptr = '\0'; + + // strip ampersand + if ((ptr = strrchr(line, '&'))) { + concat = true; + *ptr = '\0'; + } else { + concat = false; + } + + nwords = utils::count_words(line); + + // skip line if blank + if (nwords > 0) { + n = strlen(line); + } + } + + return line; +} + +void EIMPotentialFileReader::parse(FILE * fp) +{ + char * line = nullptr; + bool found_global = false; + + while(line = next_line(fp)) { + ValueTokenizer values(line, " \t\r\n\f"); + std::string type = values.next_string(); + + if (type == "global:") { + if (values.count() != 4) { + error->one(FLERR, "Invalid global line in EIM potential file"); + } + + division = values.next_double(); + rbig = values.next_double(); + rsmall = values.next_double(); + + found_global = true; + } else if (type == "element:") { + if (values.count() != 9) { + error->one(FLERR, "Invalid element line in EIM potential file"); + } + + std::string name = values.next_string(); + + ElementData data; + data.ielement = values.next_int(); + data.mass = values.next_double(); + data.negativity = values.next_double(); + data.ra = values.next_double(); + data.ri = values.next_double(); + data.Ec = values.next_double(); + data.q0 = values.next_double(); + + if (elements.find(name) == elements.end()) { + elements[name] = data; + } else { + error->one(FLERR, "Duplicate pair line in EIM potential file"); + } + + } else if (type == "pair:") { + if (values.count() != 17) { + error->one(FLERR, "Invalid element line in EIM potential file"); + } + + std::string elementA = values.next_string(); + std::string elementB = values.next_string(); + + PairData data; + data.rcutphiA = values.next_double(); + data.rcutphiR = values.next_double(); + data.Eb = values.next_double(); + data.r0 = values.next_double(); + data.alpha = values.next_double(); + data.beta = values.next_double(); + data.rcutq = values.next_double(); + data.Asigma = values.next_double(); + data.rq = values.next_double(); + data.rcutsigma = values.next_double(); + data.Ac = values.next_double(); + data.zeta = values.next_double(); + data.rs = values.next_double(); + + // should be next_int, but since existing potential files have 1.0000e+00 format + // we're doing this instead to keep compatibility + data.tp = (int)values.next_double(); + + auto p = get_pair(elementA, elementB); + + if (pairs.find(p) == pairs.end()) { + pairs[p] = data; + } else { + error->one(FLERR, "Duplicate pair line in EIM potential file"); + } + } + } + + if (!found_global) { + error->one(FLERR, "Missing global line in EIM potential file"); + } +} + +void EIMPotentialFileReader::get_global(PairEIM::Setfl * setfl) { + setfl->division = division; + setfl->rbig = rbig; + setfl->rsmall = rsmall; +} + +void EIMPotentialFileReader::get_element(PairEIM::Setfl * setfl, int i, const std::string & name) { + if (elements.find(name) == elements.end()) { + char str[128]; + snprintf(str, 128, "Element %s not defined in EIM potential file", name.c_str()); + error->one(FLERR, str); + } + + ElementData & data = elements[name]; + setfl->ielement[i] = data.ielement; + setfl->mass[i] = data.mass; + setfl->negativity[i] = data.negativity; + setfl->ra[i] = data.ra; + setfl->ri[i] = data.ri; + setfl->Ec[i] = data.Ec; + setfl->q0[i] = data.q0; +} + +void EIMPotentialFileReader::get_pair(PairEIM::Setfl * setfl, int ij, const std::string & elemA, const std::string & elemB) { + auto p = get_pair(elemA, elemB); + + if (pairs.find(p) == pairs.end()) { + char str[128]; + snprintf(str, 128, "Pair (%s, %s) not defined in EIM potential file", elemA.c_str(), elemB.c_str()); + error->one(FLERR, str); + } + + PairData & data = pairs[p]; + setfl->rcutphiA[ij] = data.rcutphiA; + setfl->rcutphiR[ij] = data.rcutphiR; + setfl->Eb[ij] = data.Eb; + setfl->r0[ij] = data.r0; + setfl->alpha[ij] = data.alpha; + setfl->beta[ij] = data.beta; + setfl->rcutq[ij] = data.rcutq; + setfl->Asigma[ij] = data.Asigma; + setfl->rq[ij] = data.rq; + setfl->rcutsigma[ij] = data.rcutsigma; + setfl->Ac[ij] = data.Ac; + setfl->zeta[ij] = data.zeta; + setfl->rs[ij] = data.rs; + setfl->tp[ij] = data.tp; +} diff --git a/src/MANYBODY/pair_eim.h b/src/MANYBODY/pair_eim.h index f9fb2d5a77..986db52453 100644 --- a/src/MANYBODY/pair_eim.h +++ b/src/MANYBODY/pair_eim.h @@ -21,6 +21,8 @@ PairStyle(eim,PairEIM) #define LMP_PAIR_EIM_H #include "pair.h" +#include +#include namespace LAMMPS_NS { @@ -40,16 +42,6 @@ class PairEIM : public Pair { void unpack_reverse_comm(int, int *, double *); double memory_usage(); - protected: - double **cutforcesq,cutmax; - int nmax; - double *rho,*fp; - int rhofp; - int *map; // which element each atom type maps to - - int nelements; // # of elements to read from potential file - char **elements; // element names - struct Setfl { double division,rbig,rsmall; int nr; @@ -62,6 +54,17 @@ class PairEIM : public Pair { double ***Fij,***Gij,***phiij; double **cuts; }; + + protected: + double **cutforcesq,cutmax; + int nmax; + double *rho,*fp; + int rhofp; + int *map; // which element each atom type maps to + + int nelements; // # of elements to read from potential file + char **elements; // element names + Setfl *setfl; // potentials as array data @@ -80,9 +83,6 @@ class PairEIM : public Pair { void allocate(); void array2spline(); void interpolate(int, double, double *, double **, double); - int grabglobal(FILE *); - int grabsingle(FILE *, int); - int grabpair(FILE *, int, int); double funccutoff(double, double, double); double funcphi(int, int, double); @@ -94,6 +94,59 @@ class PairEIM : public Pair { void file2array(); }; +class EIMPotentialFileReader : protected Pointers { + std::string filename; + static const int MAXLINE = 1024; + char line[MAXLINE]; + + void parse(FILE * fp); + char * next_line(FILE * fp); + std::pair get_pair(const std::string & a, const std::string & b); + +public: + EIMPotentialFileReader(class LAMMPS* lmp, const std::string & filename); + + void get_global(PairEIM::Setfl * setfl); + void get_element(PairEIM::Setfl * setfl, int i, const std::string & name); + void get_pair(PairEIM::Setfl * setfl, int ij, const std::string & elemA, const std::string & elemB); + +private: + // potential parameters + double division; + double rbig; + double rsmall; + + struct ElementData { + int ielement; + double mass; + double negativity; + double ra; + double ri; + double Ec; + double q0; + }; + + struct PairData { + double rcutphiA; + double rcutphiR; + double Eb; + double r0; + double alpha; + double beta; + double rcutq; + double Asigma; + double rq; + double rcutsigma; + double Ac; + double zeta; + double rs; + int tp; + }; + + std::map elements; + std::map, PairData> pairs; +}; + } #endif diff --git a/src/MANYBODY/pair_gw.cpp b/src/MANYBODY/pair_gw.cpp index 667311812b..7fff2503c6 100644 --- a/src/MANYBODY/pair_gw.cpp +++ b/src/MANYBODY/pair_gw.cpp @@ -29,13 +29,15 @@ #include "comm.h" #include "memory.h" #include "error.h" +#include "utils.h" +#include "tokenizer.h" +#include "potential_file_reader.h" #include "math_const.h" using namespace LAMMPS_NS; using namespace MathConst; -#define MAXLINE 1024 #define DELTA 4 /* ---------------------------------------------------------------------- */ @@ -366,138 +368,93 @@ double PairGW::init_one(int i, int j) void PairGW::read_file(char *file) { - int params_per_line = 17; - char **words = new char*[params_per_line+1]; - memory->sfree(params); params = NULL; nparams = maxparam = 0; // open file on proc 0 - FILE *fp; if (comm->me == 0) { - fp = force->open_potential(file); - if (fp == NULL) { - char str[128]; - snprintf(str,128,"Cannot open GW potential file %s",file); - error->one(FLERR,str); - } - } + PotentialFileReader reader(lmp, file, "GW"); + char * line; - // read each line out of file, skipping blank lines or leading '#' - // store line of params if all 3 element tags are in element list + while(line = reader.next_line(NPARAMS_PER_LINE)) { + try { + ValueTokenizer values(line, " \t\n\r\f"); - int n,nwords,ielement,jelement,kelement; - char line[MAXLINE],*ptr; - int eof = 0; + std::string iname = values.next_string(); + std::string jname = values.next_string(); + std::string kname = values.next_string(); - while (1) { - if (comm->me == 0) { - ptr = fgets(line,MAXLINE,fp); - if (ptr == NULL) { - eof = 1; - fclose(fp); - } 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); + // ielement,jelement,kelement = 1st args + // if all 3 args are in element list, then parse this line + // else skip to next entry in file + int ielement, jelement, kelement; - // strip comment, skip line if blank + for (ielement = 0; ielement < nelements; ielement++) + if (iname == elements[ielement]) break; + if (ielement == nelements) continue; + for (jelement = 0; jelement < nelements; jelement++) + if (jname == elements[jelement]) break; + if (jelement == nelements) continue; + for (kelement = 0; kelement < nelements; kelement++) + if (kname == elements[kelement]) break; + if (kelement == nelements) continue; - if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); - if (nwords == 0) continue; + // load up parameter settings and error check their values - // concatenate additional lines until have params_per_line words + if (nparams == maxparam) { + maxparam += DELTA; + params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), + "pair:params"); + } - while (nwords < params_per_line) { - n = strlen(line); - if (comm->me == 0) { - ptr = fgets(&line[n],MAXLINE-n,fp); - if (ptr == NULL) { - eof = 1; - fclose(fp); - } else n = strlen(line) + 1; + params[nparams].ielement = ielement; + params[nparams].jelement = jelement; + params[nparams].kelement = kelement; + params[nparams].powerm = values.next_double(); + params[nparams].gamma = values.next_double(); + params[nparams].lam3 = values.next_double(); + params[nparams].c = values.next_double(); + params[nparams].d = values.next_double(); + params[nparams].h = values.next_double(); + params[nparams].powern = values.next_double(); + params[nparams].beta = values.next_double(); + params[nparams].lam2 = values.next_double(); + params[nparams].bigb = values.next_double(); + params[nparams].bigr = values.next_double(); + params[nparams].bigd = values.next_double(); + params[nparams].lam1 = values.next_double(); + params[nparams].biga = values.next_double(); + params[nparams].powermint = int(params[nparams].powerm); + } catch (TokenizerException & e) { + error->one(FLERR, e.what()); } - 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); - if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + + // currently only allow m exponent of 1 or 3 + if (params[nparams].c < 0.0 || params[nparams].d < 0.0 || + params[nparams].powern < 0.0 || params[nparams].beta < 0.0 || + params[nparams].lam2 < 0.0 || params[nparams].bigb < 0.0 || + params[nparams].bigr < 0.0 ||params[nparams].bigd < 0.0 || + params[nparams].bigd > params[nparams].bigr || + params[nparams].lam1 < 0.0 || params[nparams].biga < 0.0 || + params[nparams].powerm - params[nparams].powermint != 0.0 || + (params[nparams].powermint != 3 && params[nparams].powermint != 1) || + params[nparams].gamma < 0.0) + error->one(FLERR,"Illegal GW parameter"); + + nparams++; } - - if (nwords != params_per_line) - error->all(FLERR,"Incorrect format in GW potential file"); - - // words = ptrs to all words in line - - nwords = 0; - words[nwords++] = strtok(line," \t\n\r\f"); - while ((words[nwords++] = strtok(NULL," \t\n\r\f"))) continue; - - // ielement,jelement,kelement = 1st args - // if all 3 args are in element list, then parse this line - // else skip to next line - - for (ielement = 0; ielement < nelements; ielement++) - if (strcmp(words[0],elements[ielement]) == 0) break; - if (ielement == nelements) continue; - for (jelement = 0; jelement < nelements; jelement++) - if (strcmp(words[1],elements[jelement]) == 0) break; - if (jelement == nelements) continue; - for (kelement = 0; kelement < nelements; kelement++) - if (strcmp(words[2],elements[kelement]) == 0) break; - if (kelement == nelements) continue; - - // load up parameter settings and error check their values - - if (nparams == maxparam) { - maxparam += DELTA; - params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), - "pair:params"); - } - - params[nparams].ielement = ielement; - params[nparams].jelement = jelement; - params[nparams].kelement = kelement; - params[nparams].powerm = atof(words[3]); - params[nparams].gamma = atof(words[4]); - params[nparams].lam3 = atof(words[5]); - params[nparams].c = atof(words[6]); - params[nparams].d = atof(words[7]); - params[nparams].h = atof(words[8]); - params[nparams].powern = atof(words[9]); - params[nparams].beta = atof(words[10]); - params[nparams].lam2 = atof(words[11]); - params[nparams].bigb = atof(words[12]); - params[nparams].bigr = atof(words[13]); - params[nparams].bigd = atof(words[14]); - params[nparams].lam1 = atof(words[15]); - params[nparams].biga = atof(words[16]); - - // currently only allow m exponent of 1 or 3 - - params[nparams].powermint = int(params[nparams].powerm); - - if (params[nparams].c < 0.0 || params[nparams].d < 0.0 || - params[nparams].powern < 0.0 || params[nparams].beta < 0.0 || - params[nparams].lam2 < 0.0 || params[nparams].bigb < 0.0 || - params[nparams].bigr < 0.0 ||params[nparams].bigd < 0.0 || - params[nparams].bigd > params[nparams].bigr || - params[nparams].lam1 < 0.0 || params[nparams].biga < 0.0 || - params[nparams].powerm - params[nparams].powermint != 0.0 || - (params[nparams].powermint != 3 && params[nparams].powermint != 1) || - params[nparams].gamma < 0.0) - error->all(FLERR,"Illegal GW parameter"); - - nparams++; } - delete [] words; + MPI_Bcast(&nparams, 1, MPI_INT, 0, world); + MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); + + if(comm->me != 0) { + params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); + } + + MPI_Bcast(params, maxparam*sizeof(Param), MPI_BYTE, 0, world); } /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_gw.h b/src/MANYBODY/pair_gw.h index ae15b7d275..77ff5c0399 100644 --- a/src/MANYBODY/pair_gw.h +++ b/src/MANYBODY/pair_gw.h @@ -34,6 +34,8 @@ class PairGW : public Pair { void init_style(); double init_one(int, int); + static const int NPARAMS_PER_LINE = 17; + protected: struct Param { double lam1,lam2,lam3; diff --git a/src/MANYBODY/pair_gw_zbl.cpp b/src/MANYBODY/pair_gw_zbl.cpp index d39bf53b99..514892d527 100644 --- a/src/MANYBODY/pair_gw_zbl.cpp +++ b/src/MANYBODY/pair_gw_zbl.cpp @@ -27,6 +27,9 @@ #include "comm.h" #include "memory.h" #include "error.h" +#include "utils.h" +#include "tokenizer.h" +#include "potential_file_reader.h" #include "math_const.h" using namespace LAMMPS_NS; @@ -60,146 +63,101 @@ PairGWZBL::PairGWZBL(LAMMPS *lmp) : PairGW(lmp) void PairGWZBL::read_file(char *file) { - int params_per_line = 21; - char **words = new char*[params_per_line+1]; - memory->sfree(params); params = NULL; nparams = maxparam = 0; // open file on proc 0 - FILE *fp; if (comm->me == 0) { - fp = force->open_potential(file); - if (fp == NULL) { - char str[128]; - snprintf(str,128,"Cannot open GW potential file %s",file); - error->one(FLERR,str); - } - } + PotentialFileReader reader(lmp, file, "GW/ZBL"); + char * line; - // read each line out of file, skipping blank lines or leading '#' - // store line of params if all 3 element tags are in element list + while(line = reader.next_line(NPARAMS_PER_LINE)) { + try { + ValueTokenizer values(line, " \t\n\r\f"); - int n,nwords,ielement,jelement,kelement; - char line[MAXLINE],*ptr; - int eof = 0; + std::string iname = values.next_string(); + std::string jname = values.next_string(); + std::string kname = values.next_string(); - while (1) { - if (comm->me == 0) { - ptr = fgets(line,MAXLINE,fp); - if (ptr == NULL) { - eof = 1; - fclose(fp); - } 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); + // ielement,jelement,kelement = 1st args + // if all 3 args are in element list, then parse this line + // else skip to next entry in file + int ielement, jelement, kelement; - // strip comment, skip line if blank + for (ielement = 0; ielement < nelements; ielement++) + if (iname == elements[ielement]) break; + if (ielement == nelements) continue; + for (jelement = 0; jelement < nelements; jelement++) + if (jname == elements[jelement]) break; + if (jelement == nelements) continue; + for (kelement = 0; kelement < nelements; kelement++) + if (kname == elements[kelement]) break; + if (kelement == nelements) continue; - if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); - if (nwords == 0) continue; + // load up parameter settings and error check their values - // concatenate additional lines until have params_per_line words + if (nparams == maxparam) { + maxparam += DELTA; + params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), + "pair:params"); + } - while (nwords < params_per_line) { - n = strlen(line); - if (comm->me == 0) { - ptr = fgets(&line[n],MAXLINE-n,fp); - if (ptr == NULL) { - eof = 1; - fclose(fp); - } else n = strlen(line) + 1; + params[nparams].ielement = ielement; + params[nparams].jelement = jelement; + params[nparams].kelement = kelement; + params[nparams].powerm = values.next_double(); + params[nparams].gamma = values.next_double(); + params[nparams].lam3 = values.next_double(); + params[nparams].c = values.next_double(); + params[nparams].d = values.next_double(); + params[nparams].h = values.next_double(); + params[nparams].powern = values.next_double(); + params[nparams].beta = values.next_double(); + params[nparams].lam2 = values.next_double(); + params[nparams].bigb = values.next_double(); + params[nparams].bigr = values.next_double(); + params[nparams].bigd = values.next_double(); + params[nparams].lam1 = values.next_double(); + params[nparams].biga = values.next_double(); + params[nparams].Z_i = values.next_double(); + params[nparams].Z_j = values.next_double(); + params[nparams].ZBLcut = values.next_double(); + params[nparams].ZBLexpscale = values.next_double(); + params[nparams].powermint = int(params[nparams].powerm); + } catch (TokenizerException & e) { + error->one(FLERR, e.what()); } - 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); - if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + + // currently only allow m exponent of 1 or 3 + if ( + params[nparams].lam3 < 0.0 || params[nparams].c < 0.0 || + params[nparams].d < 0.0 || params[nparams].powern < 0.0 || + params[nparams].beta < 0.0 || params[nparams].lam2 < 0.0 || + params[nparams].bigb < 0.0 || params[nparams].bigr < 0.0 || + params[nparams].bigd < 0.0 || + params[nparams].bigd > params[nparams].bigr || + params[nparams].lam3 < 0.0 || params[nparams].biga < 0.0 || + params[nparams].powerm - params[nparams].powermint != 0.0 || + (params[nparams].powermint != 3 && params[nparams].powermint != 1) || + params[nparams].gamma < 0.0 || + params[nparams].Z_i < 1.0 || params[nparams].Z_j < 1.0 || + params[nparams].ZBLcut < 0.0 || params[nparams].ZBLexpscale < 0.0) + error->one(FLERR,"Illegal GW parameter"); + + nparams++; } - - if (nwords != params_per_line) - error->all(FLERR,"Incorrect format in GW potential file"); - - // words = ptrs to all words in line - - nwords = 0; - words[nwords++] = strtok(line," \t\n\r\f"); - while ((words[nwords++] = strtok(NULL," \t\n\r\f"))) continue; - - // ielement,jelement,kelement = 1st args - // if all 3 args are in element list, then parse this line - // else skip to next line - - for (ielement = 0; ielement < nelements; ielement++) - if (strcmp(words[0],elements[ielement]) == 0) break; - if (ielement == nelements) continue; - for (jelement = 0; jelement < nelements; jelement++) - if (strcmp(words[1],elements[jelement]) == 0) break; - if (jelement == nelements) continue; - for (kelement = 0; kelement < nelements; kelement++) - if (strcmp(words[2],elements[kelement]) == 0) break; - if (kelement == nelements) continue; - - // load up parameter settings and error check their values - - if (nparams == maxparam) { - maxparam += DELTA; - params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), - "pair:params"); - } - - params[nparams].ielement = ielement; - params[nparams].jelement = jelement; - params[nparams].kelement = kelement; - params[nparams].powerm = atof(words[3]); - params[nparams].gamma = atof(words[4]); - params[nparams].lam3 = atof(words[5]); - params[nparams].c = atof(words[6]); - params[nparams].d = atof(words[7]); - params[nparams].h = atof(words[8]); - params[nparams].powern = atof(words[9]); - params[nparams].beta = atof(words[10]); - params[nparams].lam2 = atof(words[11]); - params[nparams].bigb = atof(words[12]); - params[nparams].bigr = atof(words[13]); - params[nparams].bigd = atof(words[14]); - params[nparams].lam1 = atof(words[15]); - params[nparams].biga = atof(words[16]); - params[nparams].Z_i = atof(words[17]); - params[nparams].Z_j = atof(words[18]); - params[nparams].ZBLcut = atof(words[19]); - params[nparams].ZBLexpscale = atof(words[20]); - - // currently only allow m exponent of 1 or 3 - - params[nparams].powermint = int(params[nparams].powerm); - - if ( - params[nparams].lam3 < 0.0 || params[nparams].c < 0.0 || - params[nparams].d < 0.0 || params[nparams].powern < 0.0 || - params[nparams].beta < 0.0 || params[nparams].lam2 < 0.0 || - params[nparams].bigb < 0.0 || params[nparams].bigr < 0.0 || - params[nparams].bigd < 0.0 || - params[nparams].bigd > params[nparams].bigr || - params[nparams].lam3 < 0.0 || params[nparams].biga < 0.0 || - params[nparams].powerm - params[nparams].powermint != 0.0 || - (params[nparams].powermint != 3 && params[nparams].powermint != 1) || - params[nparams].gamma < 0.0 || - params[nparams].Z_i < 1.0 || params[nparams].Z_j < 1.0 || - params[nparams].ZBLcut < 0.0 || params[nparams].ZBLexpscale < 0.0) - error->all(FLERR,"Illegal GW parameter"); - - nparams++; } - delete [] words; + MPI_Bcast(&nparams, 1, MPI_INT, 0, world); + MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); + + if(comm->me != 0) { + params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); + } + + MPI_Bcast(params, maxparam*sizeof(Param), MPI_BYTE, 0, world); } /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_gw_zbl.h b/src/MANYBODY/pair_gw_zbl.h index 62b3f9a43f..95129c4eb8 100644 --- a/src/MANYBODY/pair_gw_zbl.h +++ b/src/MANYBODY/pair_gw_zbl.h @@ -29,6 +29,8 @@ class PairGWZBL : public PairGW { PairGWZBL(class LAMMPS *); ~PairGWZBL() {} + static const int NPARAMS_PER_LINE = 21; + private: double global_a_0; // Bohr radius for Coulomb repulsion double global_epsilon_0; // permittivity of vacuum for Coulomb repulsion diff --git a/src/MANYBODY/pair_nb3b_harmonic.cpp b/src/MANYBODY/pair_nb3b_harmonic.cpp index 92456790cc..ba18271777 100644 --- a/src/MANYBODY/pair_nb3b_harmonic.cpp +++ b/src/MANYBODY/pair_nb3b_harmonic.cpp @@ -29,10 +29,12 @@ #include "neigh_list.h" #include "memory.h" #include "error.h" +#include "utils.h" +#include "tokenizer.h" +#include "potential_file_reader.h" using namespace LAMMPS_NS; -#define MAXLINE 1024 #define DELTA 4 #define SMALL 0.001 #define PI 3.141592653589793238462643383279 @@ -282,117 +284,73 @@ double PairNb3bHarmonic::init_one(int i, int j) void PairNb3bHarmonic::read_file(char *file) { - int params_per_line = 6; - char **words = new char*[params_per_line+1]; - memory->sfree(params); - params = NULL; + params = nullptr; nparams = maxparam = 0; // open file on proc 0 - FILE *fp = NULL; if (comm->me == 0) { - fp = force->open_potential(file); - if (fp == NULL) { - char str[128]; - snprintf(str,128,"Cannot open nb3b/harmonic potential file %s",file); - error->one(FLERR,str); - } - } + PotentialFileReader reader(lmp, file, "nb3b/harmonic"); + char * line; - // read each set of params from potential file - // one set of params can span multiple lines - // store params if all 3 element tags are in element list + while(line = reader.next_line(NPARAMS_PER_LINE)) { + try { + ValueTokenizer values(line, " \t\n\r\f"); - int n,nwords,ielement,jelement,kelement; - char line[MAXLINE],*ptr; - int eof = 0; + std::string iname = values.next_string(); + std::string jname = values.next_string(); + std::string kname = values.next_string(); - while (1) { - if (comm->me == 0) { - ptr = fgets(line,MAXLINE,fp); - if (ptr == NULL) { - eof = 1; - fclose(fp); - } 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); + // ielement,jelement,kelement = 1st args + // if all 3 args are in element list, then parse this line + // else skip to next entry in file + int ielement, jelement, kelement; - // strip comment, skip line if blank + for (ielement = 0; ielement < nelements; ielement++) + if (iname == elements[ielement]) break; + if (ielement == nelements) continue; + for (jelement = 0; jelement < nelements; jelement++) + if (jname == elements[jelement]) break; + if (jelement == nelements) continue; + for (kelement = 0; kelement < nelements; kelement++) + if (kname == elements[kelement]) break; + if (kelement == nelements) continue; - if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); - if (nwords == 0) continue; + // load up parameter settings and error check their values - // concatenate additional lines until have params_per_line words + if (nparams == maxparam) { + maxparam += DELTA; + params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), + "pair:params"); + } - while (nwords < params_per_line) { - n = strlen(line); - if (comm->me == 0) { - ptr = fgets(&line[n],MAXLINE-n,fp); - if (ptr == NULL) { - eof = 1; - fclose(fp); - } else n = strlen(line) + 1; + params[nparams].ielement = ielement; + params[nparams].jelement = jelement; + params[nparams].kelement = kelement; + params[nparams].k_theta = values.next_double(); + params[nparams].theta0 = values.next_double(); + params[nparams].cutoff = values.next_double(); + } catch (TokenizerException & e) { + error->one(FLERR, e.what()); } - 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); - if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + + if (params[nparams].k_theta < 0.0 || params[nparams].theta0 < 0.0 || + params[nparams].cutoff < 0.0) + error->one(FLERR,"Illegal nb3b/harmonic parameter"); + + nparams++; } - - if (nwords != params_per_line) - error->all(FLERR,"Incorrect format in nb3b/harmonic potential file"); - - // words = ptrs to all words in line - - nwords = 0; - words[nwords++] = strtok(line," \t\n\r\f"); - while ((words[nwords++] = strtok(NULL," \t\n\r\f"))) continue; - - // ielement,jelement,kelement = 1st args - // if all 3 args are in element list, then parse this line - // else skip to next entry in file - - for (ielement = 0; ielement < nelements; ielement++) - if (strcmp(words[0],elements[ielement]) == 0) break; - if (ielement == nelements) continue; - for (jelement = 0; jelement < nelements; jelement++) - if (strcmp(words[1],elements[jelement]) == 0) break; - if (jelement == nelements) continue; - for (kelement = 0; kelement < nelements; kelement++) - if (strcmp(words[2],elements[kelement]) == 0) break; - if (kelement == nelements) continue; - - // load up parameter settings and error check their values - - if (nparams == maxparam) { - maxparam += DELTA; - params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), - "pair:params"); - } - - params[nparams].ielement = ielement; - params[nparams].jelement = jelement; - params[nparams].kelement = kelement; - params[nparams].k_theta = atof(words[3]); - params[nparams].theta0 = atof(words[4]); - params[nparams].cutoff = atof(words[5]); - - if (params[nparams].k_theta < 0.0 || params[nparams].theta0 < 0.0 || - params[nparams].cutoff < 0.0) - error->all(FLERR,"Illegal nb3b/harmonic parameter"); - - nparams++; } - delete [] words; + MPI_Bcast(&nparams, 1, MPI_INT, 0, world); + MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); + + if(comm->me != 0) { + params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); + } + + MPI_Bcast(params, maxparam*sizeof(Param), MPI_BYTE, 0, world); } /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_nb3b_harmonic.h b/src/MANYBODY/pair_nb3b_harmonic.h index 75a378e35b..0267b6d0e2 100644 --- a/src/MANYBODY/pair_nb3b_harmonic.h +++ b/src/MANYBODY/pair_nb3b_harmonic.h @@ -34,6 +34,8 @@ class PairNb3bHarmonic : public Pair { double init_one(int, int); void init_style(); + static const int NPARAMS_PER_LINE = 6; + protected: struct Param { double k_theta, theta0, cutoff; diff --git a/src/MANYBODY/pair_polymorphic.cpp b/src/MANYBODY/pair_polymorphic.cpp index 7d4eb06d3c..8a4a169e85 100644 --- a/src/MANYBODY/pair_polymorphic.cpp +++ b/src/MANYBODY/pair_polymorphic.cpp @@ -30,6 +30,8 @@ #include "memory.h" #include "error.h" #include "utils.h" +#include "tokenizer.h" +#include "potential_file_reader.h" using namespace LAMMPS_NS; @@ -562,108 +564,101 @@ double PairPolymorphic::init_one(int i, int j) void PairPolymorphic::read_file(char *file) { - char line[MAXLINE],*ptr; - int n; + PotentialFileReader * reader = nullptr; - // open file on proc 0 - FILE *fp=NULL; + // read potential if (comm->me == 0) { - fp = force->open_potential(file); - if (fp == NULL) { - char str[128]; - snprintf(str,128,"Cannot open polymorphic potential file %s",file); - error->one(FLERR,str); - } - // move past comments to first data line - utils::sfgets(FLERR,line,MAXLINE,fp,file,error); - while (line == strchr(line,'#')) utils::sfgets(FLERR,line,MAXLINE,fp,file,error); - n = strlen(line) + 1; - } - MPI_Bcast(&n,1,MPI_INT,0,world); - MPI_Bcast(line,n,MPI_CHAR,0,world); - ptr = strtok(line," \t\n\r\f"); // 1st line, 1st token - int ntypes = atoi(ptr); - if (ntypes != nelements) - error->all(FLERR,"Incorrect number of elements in potential file"); - match = new int[nelements]; - ptr = strtok(NULL," \t\n\r\f"); // 1st line, 2nd token - eta = atoi(ptr); + try { + reader = new PotentialFileReader(lmp, file, "polymorphic"); - // map the elements in the potential file to LAMMPS atom types - for (int i = 0; i < nelements; i++) { - if (comm->me == 0) { - utils::sfgets(FLERR,line,MAXLINE,fp,file,error); - n = strlen(line) + 1; + char * line = reader->next_line(2); + ValueTokenizer values(line); + + int ntypes = values.next_int(); + + if (ntypes != nelements) + error->one(FLERR,"Incorrect number of elements in potential file"); + + eta = values.next_int(); + + // map the elements in the potential file to LAMMPS atom types + match = new int[nelements]; + + for (int i = 0; i < nelements; i++) { + line = reader->next_line(3); + values = ValueTokenizer(line); + values.next_double(); // atomic number + values.next_double(); // atomic mass + std::string name = values.next_string(); + + int j; + for (j = 0; j < nelements; j++) { + if (name == elements[j]) break; + } + if (j == nelements) error->one(FLERR,"Element not defined in potential file"); + match[i] = j; + } + + // sizes + // Note: the format of this line has changed between the + // 2015-06-06 and 2015-12-09 versions of the pair style. + line = reader->next_line(4); + try { + values = ValueTokenizer(line); + nr = ng = nx = 0; + nr = values.next_int(); + ng = values.next_int(); + nx = values.next_int(); + maxX = values.next_double(); + + if ((ng == 0) || (nr == 0) || (nx == 0)) + error->one(FLERR,"Error reading potential file header"); + } catch (TokenizerException & e) { + error->one(FLERR,"Potential file incompatible with this pair style version"); + } + + // cutoffs + npair = nelements*(nelements+1)/2; + ntriple = nelements*nelements*nelements; + pairParameters = (PairParameters*) memory->srealloc(pairParameters,npair*sizeof(PairParameters), "pair:pairParameters"); + tripletParameters = (TripletParameters*) memory->srealloc(tripletParameters,ntriple*sizeof(TripletParameters), "pair:tripletParameters"); + + for (int i = 0; i < npair; i++) { + PairParameters & p = pairParameters[i]; + line = reader->next_line(2); + values = ValueTokenizer(line); + p.cut = values.next_double(); + p.cutsq = p.cut*p.cut; + p.xi = values.next_double(); + } + } catch (TokenizerException & e) { + error->one(FLERR, e.what()); } - MPI_Bcast(&n,1,MPI_INT,0,world); - MPI_Bcast(line,n,MPI_CHAR,0,world); - ptr = strtok(line," \t\n\r\f"); // 1st token - ptr = strtok(NULL," \t\n\r\f"); // 2st token - ptr = strtok(NULL," \t\n\r\f"); // 3st token - int j; - for (j = 0; j < nelements; j++) { - if (strcmp(ptr,elements[j]) == 0) break; - } - if (j == nelements) - error->all(FLERR,"Element not defined in potential file"); - match[i] = j; - } - // sizes - if (comm->me == 0) { - utils::sfgets(FLERR,line,MAXLINE,fp,file,error); - n = strlen(line) + 1; } - // Note: the format of this line has changed between the - // 2015-06-06 and 2015-12-09 versions of the pair style. + MPI_Bcast(&nr, 1, MPI_INT, 0, world); + MPI_Bcast(&ng, 1, MPI_INT, 0, world); + MPI_Bcast(&nx, 1, MPI_INT, 0, world); + MPI_Bcast(&maxX, 1, MPI_DOUBLE, 0, world); - MPI_Bcast(&n,1,MPI_INT,0,world); - MPI_Bcast(line,n,MPI_CHAR,0,world); - nr = ng = nx = 0; - ptr = strtok(line," \t\n\r\f"); // 1st token - if (ptr) nr = atoi(ptr); - ptr = strtok(NULL," \t\n\r\f"); // 2nd token - if (ptr) ng = atoi(ptr); - ptr = strtok(NULL," \t\n\r\f"); // 3rd token - if (ptr) nx = atoi(ptr); - ptr = strtok(NULL," \t\n\r\f"); // 4th token - if (ptr) maxX = atof(ptr); - if (ptr == NULL) - error->all(FLERR,"Potential file incompatible with this pair style version"); - if ((ng == 0) || (nr == 0) || (nx == 0)) - error->all(FLERR,"Error reading potential file header"); + MPI_Bcast(&npair, 1, MPI_INT, 0, world); + MPI_Bcast(&ntriple, 1, MPI_INT, 0, world); - npair = nelements*(nelements+1)/2; - ntriple = nelements*nelements*nelements; - pairParameters = (PairParameters*) - memory->srealloc(pairParameters,npair*sizeof(PairParameters), - "pair:pairParameters"); - tripletParameters = (TripletParameters*) - memory->srealloc(tripletParameters,ntriple*sizeof(TripletParameters), - "pair:tripletParameters"); - - // cutoffs - for (int i = 0; i < npair; i++) { - PairParameters & p = pairParameters[i]; - if (comm->me == 0) { - utils::sfgets(FLERR,line,MAXLINE,fp,file,error); - n = strlen(line) + 1; - } - MPI_Bcast(&n,1,MPI_INT,0,world); - MPI_Bcast(line,n,MPI_CHAR,0,world); - ptr = strtok(line," \t\n\r\f"); // 1st token - p.cut = atof(ptr); - p.cutsq = p.cut*p.cut; - ptr = strtok(NULL," \t\n\r\f"); // 2nd token - p.xi = atof(ptr); + if(comm->me != 0) { + match = new int[nelements]; + pairParameters = (PairParameters*) memory->srealloc(pairParameters,npair*sizeof(PairParameters), "pair:pairParameters"); + tripletParameters = (TripletParameters*) memory->srealloc(tripletParameters,ntriple*sizeof(TripletParameters), "pair:tripletParameters"); } + MPI_Bcast(match, nelements, MPI_INT, 0, world); + MPI_Bcast(pairParameters, npair*sizeof(PairParameters), MPI_BYTE, 0, world); + // start reading tabular functions double * singletable = new double[nr]; for (int i = 0; i < npair; i++) { // U PairParameters & p = pairParameters[i]; if (comm->me == 0) { - grab(fp,nr,singletable); + reader->next_dvector(nr, singletable); } MPI_Bcast(singletable,nr,MPI_DOUBLE,0,world); p.U = new tabularFunction(nr,0.0,p.cut); @@ -672,7 +667,7 @@ void PairPolymorphic::read_file(char *file) for (int i = 0; i < npair; i++) { // V PairParameters & p = pairParameters[i]; if (comm->me == 0) { - grab(fp,nr,singletable); + reader->next_dvector(nr, singletable); } MPI_Bcast(singletable,nr,MPI_DOUBLE,0,world); p.V = new tabularFunction(nr,0.0,p.cut); @@ -681,7 +676,7 @@ void PairPolymorphic::read_file(char *file) for (int i = 0; i < npair; i++) { // W PairParameters & p = pairParameters[i]; if (comm->me == 0) { - grab(fp,nr,singletable); + reader->next_dvector(nr, singletable); } MPI_Bcast(singletable,nr,MPI_DOUBLE,0,world); p.W = new tabularFunction(nr,0.0,p.cut); @@ -698,7 +693,7 @@ void PairPolymorphic::read_file(char *file) if (eta != 3) { for (int j = 0; j < nelements; j++) { // P if (comm->me == 0) { - grab(fp,nr,singletable); + reader->next_dvector(nr, singletable); } MPI_Bcast(singletable,nr,MPI_DOUBLE,0,world); for (int i = 0; i < nelements; i++) { @@ -710,7 +705,7 @@ void PairPolymorphic::read_file(char *file) for (int j = 0; j < nelements-1; j++) { // P for (int k = j+1; k < nelements; k++) { if (comm->me == 0) { - grab(fp,nr,singletable); + reader->next_dvector(nr, singletable); } MPI_Bcast(singletable,nr,MPI_DOUBLE,0,world); for (int i = 0; i < nelements; i++) { @@ -728,7 +723,7 @@ void PairPolymorphic::read_file(char *file) for (int i = 0; i < ntriple; i++) { // P TripletParameters & p = tripletParameters[i]; if (comm->me == 0) { - grab(fp,nr,singletable); + reader->next_dvector(nr, singletable); } MPI_Bcast(singletable,nr,MPI_DOUBLE,0,world); p.P = new tabularFunction(nr,-cutmax,cutmax); @@ -740,7 +735,7 @@ void PairPolymorphic::read_file(char *file) for (int i = 0; i < ntriple; i++) { // G TripletParameters & p = tripletParameters[i]; if (comm->me == 0) { - grab(fp,ng,singletable); + reader->next_dvector(ng, singletable); } MPI_Bcast(singletable,ng,MPI_DOUBLE,0,world); p.G = new tabularFunction(ng,-1.0,1.0); @@ -751,7 +746,7 @@ void PairPolymorphic::read_file(char *file) for (int i = 0; i < npair; i++) { // F PairParameters & p = pairParameters[i]; if (comm->me == 0) { - grab(fp,nx,singletable); + reader->next_dvector(nx, singletable); } MPI_Bcast(singletable,nx,MPI_DOUBLE,0,world); p.F = new tabularFunction(nx,0.0,maxX); @@ -759,7 +754,7 @@ void PairPolymorphic::read_file(char *file) } delete[] singletable; if (comm->me == 0) { - fclose(fp); + delete reader; } // recalculate cutoffs of all params @@ -905,27 +900,6 @@ void PairPolymorphic::costheta_d(double *rij_hat, double rij, vec3_scale(-1.0,dri,dri); } -/* ---------------------------------------------------------------------- - * grab n values from file fp and put them in list - * values can be several to a line - * only called by proc 0 - * ------------------------------------------------------------------------- */ - -void PairPolymorphic::grab(FILE *fp, int n, double *list) -{ - char *ptr; - char line[MAXLINE]; - - int i = 0; - while (i < n) { - utils::sfgets(FLERR,line,MAXLINE,fp,NULL,error); - ptr = strtok(line," \t\n\r\f"); - list[i++] = atof(ptr); - while ((ptr = strtok(NULL," \t\n\r\f"))) - list[i++] = atof(ptr); - } -} - /* ---------------------------------------------------------------------- */ void PairPolymorphic::write_tables(int npts) diff --git a/src/MANYBODY/pair_polymorphic.h b/src/MANYBODY/pair_polymorphic.h index 744e7b402c..b4ff169b76 100644 --- a/src/MANYBODY/pair_polymorphic.h +++ b/src/MANYBODY/pair_polymorphic.h @@ -304,7 +304,6 @@ class PairPolymorphic : public Pair { int *match; void allocate(); - void grab(FILE *, int, double *); virtual void read_file(char *); void setup_params(); diff --git a/src/MANYBODY/pair_sw.cpp b/src/MANYBODY/pair_sw.cpp index f1d1a6fa9f..f79f835ad0 100644 --- a/src/MANYBODY/pair_sw.cpp +++ b/src/MANYBODY/pair_sw.cpp @@ -28,10 +28,12 @@ #include "neighbor.h" #include "neigh_list.h" #include "neigh_request.h" +#include "utils.h" +#include "tokenizer.h" +#include "potential_file_reader.h" using namespace LAMMPS_NS; -#define MAXLINE 1024 #define DELTA 4 /* ---------------------------------------------------------------------- */ @@ -346,128 +348,84 @@ double PairSW::init_one(int i, int j) void PairSW::read_file(char *file) { - int params_per_line = 14; - char **words = new char*[params_per_line+1]; - memory->sfree(params); - params = NULL; + params = nullptr; nparams = maxparam = 0; // open file on proc 0 - FILE *fp; if (comm->me == 0) { - fp = force->open_potential(file); - if (fp == NULL) { - char str[128]; - snprintf(str,128,"Cannot open Stillinger-Weber potential file %s",file); - error->one(FLERR,str); - } - } + PotentialFileReader reader(lmp, file, "Stillinger-Weber"); + char * line; - // read each set of params from potential file - // one set of params can span multiple lines - // store params if all 3 element tags are in element list + while(line = reader.next_line(NPARAMS_PER_LINE)) { + try { + ValueTokenizer values(line, " \t\n\r\f"); - int n,nwords,ielement,jelement,kelement; - char line[MAXLINE],*ptr; - int eof = 0; + std::string iname = values.next_string(); + std::string jname = values.next_string(); + std::string kname = values.next_string(); - while (1) { - if (comm->me == 0) { - ptr = fgets(line,MAXLINE,fp); - if (ptr == NULL) { - eof = 1; - fclose(fp); - } 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); + // ielement,jelement,kelement = 1st args + // if all 3 args are in element list, then parse this line + // else skip to next entry in file + int ielement, jelement, kelement; - // strip comment, skip line if blank + for (ielement = 0; ielement < nelements; ielement++) + if (iname == elements[ielement]) break; + if (ielement == nelements) continue; + for (jelement = 0; jelement < nelements; jelement++) + if (jname == elements[jelement]) break; + if (jelement == nelements) continue; + for (kelement = 0; kelement < nelements; kelement++) + if (kname == elements[kelement]) break; + if (kelement == nelements) continue; - if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); - if (nwords == 0) continue; + // load up parameter settings and error check their values - // concatenate additional lines until have params_per_line words + if (nparams == maxparam) { + maxparam += DELTA; + params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), + "pair:params"); + } - while (nwords < params_per_line) { - n = strlen(line); - if (comm->me == 0) { - ptr = fgets(&line[n],MAXLINE-n,fp); - if (ptr == NULL) { - eof = 1; - fclose(fp); - } else n = strlen(line) + 1; + params[nparams].ielement = ielement; + params[nparams].jelement = jelement; + params[nparams].kelement = kelement; + params[nparams].epsilon = values.next_double(); + params[nparams].sigma = values.next_double(); + params[nparams].littlea = values.next_double(); + params[nparams].lambda = values.next_double(); + params[nparams].gamma = values.next_double(); + params[nparams].costheta = values.next_double(); + params[nparams].biga = values.next_double(); + params[nparams].bigb = values.next_double(); + params[nparams].powerp = values.next_double(); + params[nparams].powerq = values.next_double(); + params[nparams].tol = values.next_double(); + } catch (TokenizerException & e) { + error->one(FLERR, e.what()); } - 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); - if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + + if (params[nparams].epsilon < 0.0 || params[nparams].sigma < 0.0 || + params[nparams].littlea < 0.0 || params[nparams].lambda < 0.0 || + params[nparams].gamma < 0.0 || params[nparams].biga < 0.0 || + params[nparams].bigb < 0.0 || params[nparams].powerp < 0.0 || + params[nparams].powerq < 0.0 || params[nparams].tol < 0.0) + error->one(FLERR,"Illegal Stillinger-Weber parameter"); + + nparams++; } - - if (nwords != params_per_line) - error->all(FLERR,"Incorrect format in Stillinger-Weber potential file"); - - // words = ptrs to all words in line - - nwords = 0; - words[nwords++] = strtok(line," \t\n\r\f"); - while ((words[nwords++] = strtok(NULL," \t\n\r\f"))) continue; - - // ielement,jelement,kelement = 1st args - // if all 3 args are in element list, then parse this line - // else skip to next entry in file - - for (ielement = 0; ielement < nelements; ielement++) - if (strcmp(words[0],elements[ielement]) == 0) break; - if (ielement == nelements) continue; - for (jelement = 0; jelement < nelements; jelement++) - if (strcmp(words[1],elements[jelement]) == 0) break; - if (jelement == nelements) continue; - for (kelement = 0; kelement < nelements; kelement++) - if (strcmp(words[2],elements[kelement]) == 0) break; - if (kelement == nelements) continue; - - // load up parameter settings and error check their values - - if (nparams == maxparam) { - maxparam += DELTA; - params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), - "pair:params"); - } - - params[nparams].ielement = ielement; - params[nparams].jelement = jelement; - params[nparams].kelement = kelement; - params[nparams].epsilon = atof(words[3]); - params[nparams].sigma = atof(words[4]); - params[nparams].littlea = atof(words[5]); - params[nparams].lambda = atof(words[6]); - params[nparams].gamma = atof(words[7]); - params[nparams].costheta = atof(words[8]); - params[nparams].biga = atof(words[9]); - params[nparams].bigb = atof(words[10]); - params[nparams].powerp = atof(words[11]); - params[nparams].powerq = atof(words[12]); - params[nparams].tol = atof(words[13]); - - if (params[nparams].epsilon < 0.0 || params[nparams].sigma < 0.0 || - params[nparams].littlea < 0.0 || params[nparams].lambda < 0.0 || - params[nparams].gamma < 0.0 || params[nparams].biga < 0.0 || - params[nparams].bigb < 0.0 || params[nparams].powerp < 0.0 || - params[nparams].powerq < 0.0 || params[nparams].tol < 0.0) - error->all(FLERR,"Illegal Stillinger-Weber parameter"); - - nparams++; } - delete [] words; + MPI_Bcast(&nparams, 1, MPI_INT, 0, world); + MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); + + if(comm->me != 0) { + params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); + } + + MPI_Bcast(params, maxparam*sizeof(Param), MPI_BYTE, 0, world); } /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_sw.h b/src/MANYBODY/pair_sw.h index 8d921a26e8..b3ecebe3b9 100644 --- a/src/MANYBODY/pair_sw.h +++ b/src/MANYBODY/pair_sw.h @@ -34,6 +34,9 @@ class PairSW : public Pair { virtual double init_one(int, int); virtual void init_style(); + static const int NPARAMS_PER_LINE = 14; + + protected: struct Param { double epsilon,sigma; double littlea,lambda,gamma,costheta; @@ -46,7 +49,6 @@ class PairSW : public Pair { int ielement,jelement,kelement; }; - protected: double cutmax; // max cutoff for all elements int nelements; // # of unique elements char **elements; // names of unique elements diff --git a/src/MANYBODY/pair_tersoff.cpp b/src/MANYBODY/pair_tersoff.cpp index 5f53760e71..91a6645588 100644 --- a/src/MANYBODY/pair_tersoff.cpp +++ b/src/MANYBODY/pair_tersoff.cpp @@ -28,6 +28,9 @@ #include "comm.h" #include "memory.h" #include "error.h" +#include "utils.h" +#include "tokenizer.h" +#include "potential_file_reader.h" #include "math_const.h" #include "math_special.h" @@ -36,7 +39,6 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define MAXLINE 1024 #define DELTA 4 /* ---------------------------------------------------------------------- */ @@ -391,144 +393,100 @@ double PairTersoff::init_one(int i, int j) void PairTersoff::read_file(char *file) { - int params_per_line = 17; - char **words = new char*[params_per_line+1]; - memory->sfree(params); - params = NULL; + params = nullptr; nparams = maxparam = 0; // open file on proc 0 - FILE *fp; if (comm->me == 0) { - fp = force->open_potential(file); - if (fp == NULL) { - char str[128]; - snprintf(str,128,"Cannot open Tersoff potential file %s",file); - error->one(FLERR,str); - } - } + PotentialFileReader reader(lmp, file, "Tersoff"); + char * line; - // read each line out of file, skipping blank lines or leading '#' - // store line of params if all 3 element tags are in element list + while(line = reader.next_line(NPARAMS_PER_LINE)) { + try { + ValueTokenizer values(line, " \t\n\r\f"); - int n,nwords,ielement,jelement,kelement; - char line[MAXLINE],*ptr; - int eof = 0; + std::string iname = values.next_string(); + std::string jname = values.next_string(); + std::string kname = values.next_string(); - while (1) { - if (comm->me == 0) { - ptr = fgets(line,MAXLINE,fp); - if (ptr == NULL) { - eof = 1; - fclose(fp); - } 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); + // ielement,jelement,kelement = 1st args + // if all 3 args are in element list, then parse this line + // else skip to next entry in file + int ielement, jelement, kelement; - // strip comment, skip line if blank + for (ielement = 0; ielement < nelements; ielement++) + if (iname == elements[ielement]) break; + if (ielement == nelements) continue; + for (jelement = 0; jelement < nelements; jelement++) + if (jname == elements[jelement]) break; + if (jelement == nelements) continue; + for (kelement = 0; kelement < nelements; kelement++) + if (kname == elements[kelement]) break; + if (kelement == nelements) continue; - if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); - if (nwords == 0) continue; - // concatenate additional lines until have params_per_line words + // load up parameter settings and error check their values - while (nwords < params_per_line) { - n = strlen(line); - if (comm->me == 0) { - ptr = fgets(&line[n],MAXLINE-n,fp); - if (ptr == NULL) { - eof = 1; - fclose(fp); - } else n = strlen(line) + 1; + if (nparams == maxparam) { + maxparam += DELTA; + params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), + "pair:params"); + } + + params[nparams].ielement = ielement; + params[nparams].jelement = jelement; + params[nparams].kelement = kelement; + params[nparams].powerm = values.next_double(); + params[nparams].gamma = values.next_double(); + params[nparams].lam3 = values.next_double(); + params[nparams].c = values.next_double(); + params[nparams].d = values.next_double(); + params[nparams].h = values.next_double(); + params[nparams].powern = values.next_double(); + params[nparams].beta = values.next_double(); + params[nparams].lam2 = values.next_double(); + params[nparams].bigb = values.next_double(); + params[nparams].bigr = values.next_double(); + params[nparams].bigd = values.next_double(); + params[nparams].lam1 = values.next_double(); + params[nparams].biga = values.next_double(); + params[nparams].powermint = int(params[nparams].powerm); + } catch (TokenizerException & e) { + error->one(FLERR, e.what()); } - 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); - if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + + // currently only allow m exponent of 1 or 3 + if (params[nparams].c < 0.0 || + params[nparams].d < 0.0 || + params[nparams].powern < 0.0 || + params[nparams].beta < 0.0 || + params[nparams].lam2 < 0.0 || + params[nparams].bigb < 0.0 || + params[nparams].bigr < 0.0 || + params[nparams].bigd < 0.0 || + params[nparams].bigd > params[nparams].bigr || + params[nparams].lam1 < 0.0 || + params[nparams].biga < 0.0 || + params[nparams].powerm - params[nparams].powermint != 0.0 || + (params[nparams].powermint != 3 && + params[nparams].powermint != 1) || + params[nparams].gamma < 0.0) + error->one(FLERR,"Illegal Tersoff parameter"); + + nparams++; } - - if (nwords != params_per_line) - error->all(FLERR,"Incorrect format in Tersoff potential file"); - - // words = ptrs to all words in line - - nwords = 0; - words[nwords++] = strtok(line," \t\n\r\f"); - while ((words[nwords++] = strtok(NULL," \t\n\r\f"))) continue; - - // ielement,jelement,kelement = 1st args - // if all 3 args are in element list, then parse this line - // else skip to next line - - for (ielement = 0; ielement < nelements; ielement++) - if (strcmp(words[0],elements[ielement]) == 0) break; - if (ielement == nelements) continue; - for (jelement = 0; jelement < nelements; jelement++) - if (strcmp(words[1],elements[jelement]) == 0) break; - if (jelement == nelements) continue; - for (kelement = 0; kelement < nelements; kelement++) - if (strcmp(words[2],elements[kelement]) == 0) break; - if (kelement == nelements) continue; - - // load up parameter settings and error check their values - - if (nparams == maxparam) { - maxparam += DELTA; - params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), - "pair:params"); - } - - params[nparams].ielement = ielement; - params[nparams].jelement = jelement; - params[nparams].kelement = kelement; - params[nparams].powerm = atof(words[3]); - params[nparams].gamma = atof(words[4]); - params[nparams].lam3 = atof(words[5]); - params[nparams].c = atof(words[6]); - params[nparams].d = atof(words[7]); - params[nparams].h = atof(words[8]); - params[nparams].powern = atof(words[9]); - params[nparams].beta = atof(words[10]); - params[nparams].lam2 = atof(words[11]); - params[nparams].bigb = atof(words[12]); - params[nparams].bigr = atof(words[13]); - params[nparams].bigd = atof(words[14]); - params[nparams].lam1 = atof(words[15]); - params[nparams].biga = atof(words[16]); - - // currently only allow m exponent of 1 or 3 - - params[nparams].powermint = int(params[nparams].powerm); - - if (params[nparams].c < 0.0 || - params[nparams].d < 0.0 || - params[nparams].powern < 0.0 || - params[nparams].beta < 0.0 || - params[nparams].lam2 < 0.0 || - params[nparams].bigb < 0.0 || - params[nparams].bigr < 0.0 || - params[nparams].bigd < 0.0 || - params[nparams].bigd > params[nparams].bigr || - params[nparams].lam1 < 0.0 || - params[nparams].biga < 0.0 || - params[nparams].powerm - params[nparams].powermint != 0.0 || - (params[nparams].powermint != 3 && - params[nparams].powermint != 1) || - params[nparams].gamma < 0.0) - error->all(FLERR,"Illegal Tersoff parameter"); - - nparams++; } - delete [] words; + MPI_Bcast(&nparams, 1, MPI_INT, 0, world); + MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); + + if(comm->me != 0) { + params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); + } + + MPI_Bcast(params, maxparam*sizeof(Param), MPI_BYTE, 0, world); } /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_tersoff.h b/src/MANYBODY/pair_tersoff.h index 83ac73d5b8..8ebbc83544 100644 --- a/src/MANYBODY/pair_tersoff.h +++ b/src/MANYBODY/pair_tersoff.h @@ -34,7 +34,10 @@ class PairTersoff : public Pair { virtual void init_style(); double init_one(int, int); + static const int NPARAMS_PER_LINE = 17; + protected: + struct Param { double lam1,lam2,lam3; double c,d,h; diff --git a/src/MANYBODY/pair_tersoff_mod.cpp b/src/MANYBODY/pair_tersoff_mod.cpp index 9d4bdb7fd0..c5aba27a28 100644 --- a/src/MANYBODY/pair_tersoff_mod.cpp +++ b/src/MANYBODY/pair_tersoff_mod.cpp @@ -28,12 +28,14 @@ #include "math_special.h" #include "memory.h" #include "error.h" +#include "utils.h" +#include "tokenizer.h" +#include "potential_file_reader.h" using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define MAXLINE 1024 #define DELTA 4 /* ---------------------------------------------------------------------- */ @@ -44,145 +46,101 @@ PairTersoffMOD::PairTersoffMOD(LAMMPS *lmp) : PairTersoff(lmp) {} void PairTersoffMOD::read_file(char *file) { - int params_per_line = 20; - char **words = new char*[params_per_line+1]; - memory->sfree(params); - params = NULL; + params = nullptr; nparams = maxparam = 0; // open file on proc 0 - FILE *fp; if (comm->me == 0) { - fp = force->open_potential(file); - if (fp == NULL) { - char str[128]; - snprintf(str,128,"Cannot open Tersoff potential file %s",file); - error->one(FLERR,str); - } - } + PotentialFileReader reader(lmp, file, "Tersoff"); + char * line; - // read each line out of file, skipping blank lines or leading '#' - // store line of params if all 3 element tags are in element list + while(line = reader.next_line(NPARAMS_PER_LINE)) { + try { + ValueTokenizer values(line, " \t\n\r\f"); - int n,nwords,ielement,jelement,kelement; - char line[MAXLINE],*ptr; - int eof = 0; + std::string iname = values.next_string(); + std::string jname = values.next_string(); + std::string kname = values.next_string(); - while (1) { - if (comm->me == 0) { - ptr = fgets(line,MAXLINE,fp); - if (ptr == NULL) { - eof = 1; - fclose(fp); - } 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); + // ielement,jelement,kelement = 1st args + // if all 3 args are in element list, then parse this line + // else skip to next entry in file + int ielement, jelement, kelement; - // strip comment, skip line if blank + for (ielement = 0; ielement < nelements; ielement++) + if (iname == elements[ielement]) break; + if (ielement == nelements) continue; + for (jelement = 0; jelement < nelements; jelement++) + if (jname == elements[jelement]) break; + if (jelement == nelements) continue; + for (kelement = 0; kelement < nelements; kelement++) + if (kname == elements[kelement]) break; + if (kelement == nelements) continue; - if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); - if (nwords == 0) continue; - // concatenate additional lines until have params_per_line words + // load up parameter settings and error check their values - while (nwords < params_per_line) { - n = strlen(line); - if (comm->me == 0) { - ptr = fgets(&line[n],MAXLINE-n,fp); - if (ptr == NULL) { - eof = 1; - fclose(fp); - } else n = strlen(line) + 1; + if (nparams == maxparam) { + maxparam += DELTA; + params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), + "pair:params"); + } + + params[nparams].ielement = ielement; + params[nparams].jelement = jelement; + params[nparams].kelement = kelement; + params[nparams].powerm = values.next_double(); + params[nparams].lam3 = values.next_double(); + params[nparams].h = values.next_double(); + params[nparams].powern = values.next_double(); + params[nparams].beta = values.next_double(); + params[nparams].lam2 = values.next_double(); + params[nparams].bigb = values.next_double(); + params[nparams].bigr = values.next_double(); + params[nparams].bigd = values.next_double(); + params[nparams].lam1 = values.next_double(); + params[nparams].biga = values.next_double(); + params[nparams].powern_del = values.next_double(); + params[nparams].c1 = values.next_double(); + params[nparams].c2 = values.next_double(); + params[nparams].c3 = values.next_double(); + params[nparams].c4 = values.next_double(); + params[nparams].c5 = values.next_double(); + params[nparams].powermint = int(params[nparams].powerm); + } catch (TokenizerException & e) { + error->one(FLERR, e.what()); } - 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); - if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + + // currently only allow m exponent of 1 or 3 + if (params[nparams].powern < 0.0 || + params[nparams].beta < 0.0 || + params[nparams].lam2 < 0.0 || + params[nparams].bigb < 0.0 || + params[nparams].bigr < 0.0 || + params[nparams].bigd < 0.0 || + params[nparams].bigd > params[nparams].bigr || + params[nparams].lam1 < 0.0 || + params[nparams].biga < 0.0 || + params[nparams].powerm - params[nparams].powermint != 0.0 || + (params[nparams].powermint != 3 && + params[nparams].powermint != 1) + ) + error->one(FLERR,"Illegal Tersoff parameter"); + + nparams++; } - - if (nwords != params_per_line) - error->all(FLERR,"Incorrect format in Tersoff potential file"); - - // words = ptrs to all words in line - - nwords = 0; - words[nwords++] = strtok(line," \t\n\r\f"); - while ((words[nwords++] = strtok(NULL," \t\n\r\f"))) continue; - - // ielement,jelement,kelement = 1st args - // if all 3 args are in element list, then parse this line - // else skip to next line - - for (ielement = 0; ielement < nelements; ielement++) - if (strcmp(words[0],elements[ielement]) == 0) break; - if (ielement == nelements) continue; - for (jelement = 0; jelement < nelements; jelement++) - if (strcmp(words[1],elements[jelement]) == 0) break; - if (jelement == nelements) continue; - for (kelement = 0; kelement < nelements; kelement++) - if (strcmp(words[2],elements[kelement]) == 0) break; - if (kelement == nelements) continue; - - // load up parameter settings and error check their values - - if (nparams == maxparam) { - maxparam += DELTA; - params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), - "pair:params"); - } - - params[nparams].ielement = ielement; - params[nparams].jelement = jelement; - params[nparams].kelement = kelement; - params[nparams].powerm = atof(words[3]); - params[nparams].lam3 = atof(words[4]); - params[nparams].h = atof(words[5]); - params[nparams].powern = atof(words[6]); - params[nparams].beta = atof(words[7]); - params[nparams].lam2 = atof(words[8]); - params[nparams].bigb = atof(words[9]); - params[nparams].bigr = atof(words[10]); - params[nparams].bigd = atof(words[11]); - params[nparams].lam1 = atof(words[12]); - params[nparams].biga = atof(words[13]); - params[nparams].powern_del = atof(words[14]); - params[nparams].c1 = atof(words[15]); - params[nparams].c2 = atof(words[16]); - params[nparams].c3 = atof(words[17]); - params[nparams].c4 = atof(words[18]); - params[nparams].c5 = atof(words[19]); - - // currently only allow m exponent of 1 or 3 - - params[nparams].powermint = int(params[nparams].powerm); - - if (params[nparams].powern < 0.0 || - params[nparams].beta < 0.0 || - params[nparams].lam2 < 0.0 || - params[nparams].bigb < 0.0 || - params[nparams].bigr < 0.0 || - params[nparams].bigd < 0.0 || - params[nparams].bigd > params[nparams].bigr || - params[nparams].lam1 < 0.0 || - params[nparams].biga < 0.0 || - params[nparams].powerm - params[nparams].powermint != 0.0 || - (params[nparams].powermint != 3 && - params[nparams].powermint != 1) - ) - error->all(FLERR,"Illegal Tersoff parameter"); - - nparams++; } - delete [] words; + MPI_Bcast(&nparams, 1, MPI_INT, 0, world); + MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); + + if(comm->me != 0) { + params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); + } + + MPI_Bcast(params, maxparam*sizeof(Param), MPI_BYTE, 0, world); } /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_tersoff_mod.h b/src/MANYBODY/pair_tersoff_mod.h index 162603bc5c..2cdbae9518 100644 --- a/src/MANYBODY/pair_tersoff_mod.h +++ b/src/MANYBODY/pair_tersoff_mod.h @@ -30,6 +30,8 @@ class PairTersoffMOD : public PairTersoff { PairTersoffMOD(class LAMMPS *); ~PairTersoffMOD() {} + static const int NPARAMS_PER_LINE = 20; + protected: virtual void read_file(char *); virtual void setup_params(); diff --git a/src/MANYBODY/pair_tersoff_mod_c.cpp b/src/MANYBODY/pair_tersoff_mod_c.cpp index 6c2c4f4e7a..19b0cd5ccf 100644 --- a/src/MANYBODY/pair_tersoff_mod_c.cpp +++ b/src/MANYBODY/pair_tersoff_mod_c.cpp @@ -25,157 +25,115 @@ #include "comm.h" #include "memory.h" #include "error.h" +#include "utils.h" +#include "tokenizer.h" +#include "potential_file_reader.h" using namespace LAMMPS_NS; -#define MAXLINE 1024 #define DELTA 4 /* ---------------------------------------------------------------------- */ void PairTersoffMODC::read_file(char *file) { - int params_per_line = 21; - char **words = new char*[params_per_line+1]; - memory->sfree(params); - params = NULL; + params = nullptr; nparams = maxparam = 0; // open file on proc 0 - FILE *fp; if (comm->me == 0) { - fp = force->open_potential(file); - if (fp == NULL) { - char str[128]; - snprintf(str,128,"Cannot open Tersoff potential file %s",file); - error->one(FLERR,str); - } - } + PotentialFileReader reader(lmp, file, "Tersoff"); + char * line; - // read each line out of file, skipping blank lines or leading '#' - // store line of params if all 3 element tags are in element list + while(line = reader.next_line(NPARAMS_PER_LINE)) { + try { + ValueTokenizer values(line, " \t\n\r\f"); - int n,nwords,ielement,jelement,kelement; - char line[MAXLINE],*ptr; - int eof = 0; + std::string iname = values.next_string(); + std::string jname = values.next_string(); + std::string kname = values.next_string(); - while (1) { - if (comm->me == 0) { - ptr = fgets(line,MAXLINE,fp); - if (ptr == NULL) { - eof = 1; - fclose(fp); - } 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); + // ielement,jelement,kelement = 1st args + // if all 3 args are in element list, then parse this line + // else skip to next entry in file + int ielement, jelement, kelement; - // strip comment, skip line if blank + for (ielement = 0; ielement < nelements; ielement++) + if (iname == elements[ielement]) break; + if (ielement == nelements) continue; + for (jelement = 0; jelement < nelements; jelement++) + if (jname == elements[jelement]) break; + if (jelement == nelements) continue; + for (kelement = 0; kelement < nelements; kelement++) + if (kname == elements[kelement]) break; + if (kelement == nelements) continue; - if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); - if (nwords == 0) continue; - // concatenate additional lines until have params_per_line words + // load up parameter settings and error check their values - while (nwords < params_per_line) { - n = strlen(line); - if (comm->me == 0) { - ptr = fgets(&line[n],MAXLINE-n,fp); - if (ptr == NULL) { - eof = 1; - fclose(fp); - } else n = strlen(line) + 1; + if (nparams == maxparam) { + maxparam += DELTA; + params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), + "pair:params"); + } + + params[nparams].ielement = ielement; + params[nparams].jelement = jelement; + params[nparams].kelement = kelement; + params[nparams].powerm = values.next_double(); + params[nparams].lam3 = values.next_double(); + params[nparams].h = values.next_double(); + params[nparams].powern = values.next_double(); + params[nparams].beta = values.next_double(); + params[nparams].lam2 = values.next_double(); + params[nparams].bigb = values.next_double(); + params[nparams].bigr = values.next_double(); + params[nparams].bigd = values.next_double(); + params[nparams].lam1 = values.next_double(); + params[nparams].biga = values.next_double(); + params[nparams].powern_del = values.next_double(); + params[nparams].c1 = values.next_double(); + params[nparams].c2 = values.next_double(); + params[nparams].c3 = values.next_double(); + params[nparams].c4 = values.next_double(); + params[nparams].c5 = values.next_double(); + params[nparams].c0 = values.next_double(); + params[nparams].powermint = int(params[nparams].powerm); + } catch (TokenizerException & e) { + error->one(FLERR, e.what()); } - 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); - if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + + // currently only allow m exponent of 1 or 3 + if ( + params[nparams].powern < 0.0 || + params[nparams].beta < 0.0 || + params[nparams].lam2 < 0.0 || + params[nparams].bigb < 0.0 || + params[nparams].bigr < 0.0 || + params[nparams].bigd < 0.0 || + params[nparams].bigd > params[nparams].bigr || + params[nparams].lam1 < 0.0 || + params[nparams].biga < 0.0 || + params[nparams].powerm - params[nparams].powermint != 0.0 || + (params[nparams].powermint != 3 && + params[nparams].powermint != 1) + ) + error->one(FLERR,"Illegal Tersoff parameter"); + + nparams++; } - - if (nwords != params_per_line) - error->all(FLERR,"Incorrect format in Tersoff potential file"); - - // words = ptrs to all words in line - - nwords = 0; - words[nwords++] = strtok(line," \t\n\r\f"); - while ((words[nwords++] = strtok(NULL," \t\n\r\f"))) continue; - - // ielement,jelement,kelement = 1st args - // if all 3 args are in element list, then parse this line - // else skip to next line - - for (ielement = 0; ielement < nelements; ielement++) - if (strcmp(words[0],elements[ielement]) == 0) break; - if (ielement == nelements) continue; - for (jelement = 0; jelement < nelements; jelement++) - if (strcmp(words[1],elements[jelement]) == 0) break; - if (jelement == nelements) continue; - for (kelement = 0; kelement < nelements; kelement++) - if (strcmp(words[2],elements[kelement]) == 0) break; - if (kelement == nelements) continue; - - // load up parameter settings and error check their values - - if (nparams == maxparam) { - maxparam += DELTA; - params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), - "pair:params"); - } - - params[nparams].ielement = ielement; - params[nparams].jelement = jelement; - params[nparams].kelement = kelement; - params[nparams].powerm = atof(words[3]); - params[nparams].lam3 = atof(words[4]); - params[nparams].h = atof(words[5]); - params[nparams].powern = atof(words[6]); - params[nparams].beta = atof(words[7]); - params[nparams].lam2 = atof(words[8]); - params[nparams].bigb = atof(words[9]); - params[nparams].bigr = atof(words[10]); - params[nparams].bigd = atof(words[11]); - params[nparams].lam1 = atof(words[12]); - params[nparams].biga = atof(words[13]); - params[nparams].powern_del = atof(words[14]); - params[nparams].c1 = atof(words[15]); - params[nparams].c2 = atof(words[16]); - params[nparams].c3 = atof(words[17]); - params[nparams].c4 = atof(words[18]); - params[nparams].c5 = atof(words[19]); - params[nparams].c0 = atof(words[20]); - - // currently only allow m exponent of 1 or 3 - - params[nparams].powermint = int(params[nparams].powerm); - - if ( - params[nparams].powern < 0.0 || - params[nparams].beta < 0.0 || - params[nparams].lam2 < 0.0 || - params[nparams].bigb < 0.0 || - params[nparams].bigr < 0.0 || - params[nparams].bigd < 0.0 || - params[nparams].bigd > params[nparams].bigr || - params[nparams].lam1 < 0.0 || - params[nparams].biga < 0.0 || - params[nparams].powerm - params[nparams].powermint != 0.0 || - (params[nparams].powermint != 3 && - params[nparams].powermint != 1) - ) - error->all(FLERR,"Illegal Tersoff parameter"); - - nparams++; } - delete [] words; + MPI_Bcast(&nparams, 1, MPI_INT, 0, world); + MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); + + if(comm->me != 0) { + params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); + } + + MPI_Bcast(params, maxparam*sizeof(Param), MPI_BYTE, 0, world); } /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_tersoff_mod_c.h b/src/MANYBODY/pair_tersoff_mod_c.h index e7e32a0a66..bad5f988be 100644 --- a/src/MANYBODY/pair_tersoff_mod_c.h +++ b/src/MANYBODY/pair_tersoff_mod_c.h @@ -29,6 +29,8 @@ class PairTersoffMODC : public PairTersoffMOD { PairTersoffMODC(class LAMMPS *lmp) : PairTersoffMOD(lmp) {}; ~PairTersoffMODC() {} + static const int NPARAMS_PER_LINE = 21; + protected: void read_file(char *); void repulsive(Param *, double, double &, int, double &); diff --git a/src/MANYBODY/pair_tersoff_zbl.cpp b/src/MANYBODY/pair_tersoff_zbl.cpp index d5e3fb1b0f..cc589b1efa 100644 --- a/src/MANYBODY/pair_tersoff_zbl.cpp +++ b/src/MANYBODY/pair_tersoff_zbl.cpp @@ -29,12 +29,14 @@ #include "error.h" #include "math_const.h" #include "math_special.h" +#include "utils.h" +#include "tokenizer.h" +#include "potential_file_reader.h" using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define MAXLINE 1024 #define DELTA 4 /* ---------------------------------------------------------------------- */ @@ -62,152 +64,108 @@ PairTersoffZBL::PairTersoffZBL(LAMMPS *lmp) : PairTersoff(lmp) void PairTersoffZBL::read_file(char *file) { - int params_per_line = 21; - char **words = new char*[params_per_line+1]; - memory->sfree(params); - params = NULL; + params = nullptr; nparams = maxparam = 0; // open file on proc 0 - FILE *fp; if (comm->me == 0) { - fp = force->open_potential(file); - if (fp == NULL) { - char str[128]; - snprintf(str,128,"Cannot open Tersoff potential file %s",file); - error->one(FLERR,str); - } - } + PotentialFileReader reader(lmp, file, "Tersoff"); + char * line; - // read each line out of file, skipping blank lines or leading '#' - // store line of params if all 3 element tags are in element list + while(line = reader.next_line(NPARAMS_PER_LINE)) { + try { + ValueTokenizer values(line, " \t\n\r\f"); - int n,nwords,ielement,jelement,kelement; - char line[MAXLINE],*ptr; - int eof = 0; + std::string iname = values.next_string(); + std::string jname = values.next_string(); + std::string kname = values.next_string(); - while (1) { - if (comm->me == 0) { - ptr = fgets(line,MAXLINE,fp); - if (ptr == NULL) { - eof = 1; - fclose(fp); - } 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); + // ielement,jelement,kelement = 1st args + // if all 3 args are in element list, then parse this line + // else skip to next entry in file + int ielement, jelement, kelement; - // strip comment, skip line if blank + for (ielement = 0; ielement < nelements; ielement++) + if (iname == elements[ielement]) break; + if (ielement == nelements) continue; + for (jelement = 0; jelement < nelements; jelement++) + if (jname == elements[jelement]) break; + if (jelement == nelements) continue; + for (kelement = 0; kelement < nelements; kelement++) + if (kname == elements[kelement]) break; + if (kelement == nelements) continue; - if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); - if (nwords == 0) continue; - // concatenate additional lines until have params_per_line words + // load up parameter settings and error check their values - while (nwords < params_per_line) { - n = strlen(line); - if (comm->me == 0) { - ptr = fgets(&line[n],MAXLINE-n,fp); - if (ptr == NULL) { - eof = 1; - fclose(fp); - } else n = strlen(line) + 1; + if (nparams == maxparam) { + maxparam += DELTA; + params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), + "pair:params"); + } + + params[nparams].ielement = ielement; + params[nparams].jelement = jelement; + params[nparams].kelement = kelement; + params[nparams].powerm = values.next_double(); + params[nparams].gamma = values.next_double(); + params[nparams].lam3 = values.next_double(); + params[nparams].c = values.next_double(); + params[nparams].d = values.next_double(); + params[nparams].h = values.next_double(); + params[nparams].powern = values.next_double(); + params[nparams].beta = values.next_double(); + params[nparams].lam2 = values.next_double(); + params[nparams].bigb = values.next_double(); + params[nparams].bigr = values.next_double(); + params[nparams].bigd = values.next_double(); + params[nparams].lam1 = values.next_double(); + params[nparams].biga = values.next_double(); + params[nparams].Z_i = values.next_double(); + params[nparams].Z_j = values.next_double(); + params[nparams].ZBLcut = values.next_double(); + params[nparams].ZBLexpscale = values.next_double(); + params[nparams].powermint = int(params[nparams].powerm); + } catch (TokenizerException & e) { + error->one(FLERR, e.what()); } - 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); - if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + + // currently only allow m exponent of 1 or 3 + if (params[nparams].c < 0.0 || + params[nparams].d < 0.0 || + params[nparams].powern < 0.0 || + params[nparams].beta < 0.0 || + params[nparams].lam2 < 0.0 || + params[nparams].bigb < 0.0 || + params[nparams].bigr < 0.0 || + params[nparams].bigd < 0.0 || + params[nparams].bigd > params[nparams].bigr || + params[nparams].lam1 < 0.0 || + params[nparams].biga < 0.0 || + params[nparams].powerm - params[nparams].powermint != 0.0 || + (params[nparams].powermint != 3 && + params[nparams].powermint != 1) || + params[nparams].gamma < 0.0 || + params[nparams].Z_i < 1.0 || + params[nparams].Z_j < 1.0 || + params[nparams].ZBLcut < 0.0 || + params[nparams].ZBLexpscale < 0.0) + error->one(FLERR,"Illegal Tersoff parameter"); + + nparams++; } - - if (nwords != params_per_line) - error->all(FLERR,"Incorrect format in Tersoff potential file"); - - // words = ptrs to all words in line - - nwords = 0; - words[nwords++] = strtok(line," \t\n\r\f"); - while ((words[nwords++] = strtok(NULL," \t\n\r\f"))) continue; - - // ielement,jelement,kelement = 1st args - // if all 3 args are in element list, then parse this line - // else skip to next line - - for (ielement = 0; ielement < nelements; ielement++) - if (strcmp(words[0],elements[ielement]) == 0) break; - if (ielement == nelements) continue; - for (jelement = 0; jelement < nelements; jelement++) - if (strcmp(words[1],elements[jelement]) == 0) break; - if (jelement == nelements) continue; - for (kelement = 0; kelement < nelements; kelement++) - if (strcmp(words[2],elements[kelement]) == 0) break; - if (kelement == nelements) continue; - - // load up parameter settings and error check their values - - if (nparams == maxparam) { - maxparam += DELTA; - params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), - "pair:params"); - } - - params[nparams].ielement = ielement; - params[nparams].jelement = jelement; - params[nparams].kelement = kelement; - params[nparams].powerm = atof(words[3]); - params[nparams].gamma = atof(words[4]); - params[nparams].lam3 = atof(words[5]); - params[nparams].c = atof(words[6]); - params[nparams].d = atof(words[7]); - params[nparams].h = atof(words[8]); - params[nparams].powern = atof(words[9]); - params[nparams].beta = atof(words[10]); - params[nparams].lam2 = atof(words[11]); - params[nparams].bigb = atof(words[12]); - params[nparams].bigr = atof(words[13]); - params[nparams].bigd = atof(words[14]); - params[nparams].lam1 = atof(words[15]); - params[nparams].biga = atof(words[16]); - params[nparams].Z_i = atof(words[17]); - params[nparams].Z_j = atof(words[18]); - params[nparams].ZBLcut = atof(words[19]); - params[nparams].ZBLexpscale = atof(words[20]); - - // currently only allow m exponent of 1 or 3 - - params[nparams].powermint = int(params[nparams].powerm); - - if (params[nparams].c < 0.0 || - params[nparams].d < 0.0 || - params[nparams].powern < 0.0 || - params[nparams].beta < 0.0 || - params[nparams].lam2 < 0.0 || - params[nparams].bigb < 0.0 || - params[nparams].bigr < 0.0 || - params[nparams].bigd < 0.0 || - params[nparams].bigd > params[nparams].bigr || - params[nparams].lam1 < 0.0 || - params[nparams].biga < 0.0 || - params[nparams].powerm - params[nparams].powermint != 0.0 || - (params[nparams].powermint != 3 && - params[nparams].powermint != 1) || - params[nparams].gamma < 0.0 || - params[nparams].Z_i < 1.0 || - params[nparams].Z_j < 1.0 || - params[nparams].ZBLcut < 0.0 || - params[nparams].ZBLexpscale < 0.0) - error->all(FLERR,"Illegal Tersoff parameter"); - - nparams++; } - delete [] words; + MPI_Bcast(&nparams, 1, MPI_INT, 0, world); + MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); + + if(comm->me != 0) { + params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); + } + + MPI_Bcast(params, maxparam*sizeof(Param), MPI_BYTE, 0, world); } /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_tersoff_zbl.h b/src/MANYBODY/pair_tersoff_zbl.h index 34bec05195..be3f496b62 100644 --- a/src/MANYBODY/pair_tersoff_zbl.h +++ b/src/MANYBODY/pair_tersoff_zbl.h @@ -29,6 +29,8 @@ class PairTersoffZBL : public PairTersoff { PairTersoffZBL(class LAMMPS *); ~PairTersoffZBL() {} + static const int NPARAMS_PER_LINE = 21; + protected: double global_a_0; // Bohr radius for Coulomb repulsion double global_epsilon_0; // permittivity of vacuum for Coulomb repulsion diff --git a/src/MANYBODY/pair_vashishta.cpp b/src/MANYBODY/pair_vashishta.cpp index 13b44c58a4..a1f9fc3dc5 100644 --- a/src/MANYBODY/pair_vashishta.cpp +++ b/src/MANYBODY/pair_vashishta.cpp @@ -29,10 +29,12 @@ #include "neighbor.h" #include "neigh_list.h" #include "neigh_request.h" +#include "utils.h" +#include "tokenizer.h" +#include "potential_file_reader.h" using namespace LAMMPS_NS; -#define MAXLINE 1024 #define DELTA 4 /* ---------------------------------------------------------------------- */ @@ -352,132 +354,88 @@ double PairVashishta::init_one(int i, int j) void PairVashishta::read_file(char *file) { - int params_per_line = 17; - char **words = new char*[params_per_line+1]; - memory->sfree(params); - params = NULL; + params = nullptr; nparams = maxparam = 0; // open file on proc 0 - FILE *fp; if (comm->me == 0) { - fp = force->open_potential(file); - if (fp == NULL) { - char str[128]; - snprintf(str,128,"Cannot open Vashishta potential file %s",file); - error->one(FLERR,str); - } - } + PotentialFileReader reader(lmp, file, "Vashishta"); + char * line; - // read each set of params from potential file - // one set of params can span multiple lines - // store params if all 3 element tags are in element list + while(line = reader.next_line(NPARAMS_PER_LINE)) { + try { + ValueTokenizer values(line, " \t\n\r\f"); - int n,nwords,ielement,jelement,kelement; - char line[MAXLINE],*ptr; - int eof = 0; + std::string iname = values.next_string(); + std::string jname = values.next_string(); + std::string kname = values.next_string(); - while (1) { - if (comm->me == 0) { - ptr = fgets(line,MAXLINE,fp); - if (ptr == NULL) { - eof = 1; - fclose(fp); - } 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); + // ielement,jelement,kelement = 1st args + // if all 3 args are in element list, then parse this line + // else skip to next entry in file + int ielement, jelement, kelement; - // strip comment, skip line if blank + for (ielement = 0; ielement < nelements; ielement++) + if (iname == elements[ielement]) break; + if (ielement == nelements) continue; + for (jelement = 0; jelement < nelements; jelement++) + if (jname == elements[jelement]) break; + if (jelement == nelements) continue; + for (kelement = 0; kelement < nelements; kelement++) + if (kname == elements[kelement]) break; + if (kelement == nelements) continue; - if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); - if (nwords == 0) continue; + // load up parameter settings and error check their values - // concatenate additional lines until have params_per_line words + if (nparams == maxparam) { + maxparam += DELTA; + params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), + "pair:params"); + } - while (nwords < params_per_line) { - n = strlen(line); - if (comm->me == 0) { - ptr = fgets(&line[n],MAXLINE-n,fp); - if (ptr == NULL) { - eof = 1; - fclose(fp); - } else n = strlen(line) + 1; + params[nparams].ielement = ielement; + params[nparams].jelement = jelement; + params[nparams].kelement = kelement; + params[nparams].bigh = values.next_double(); + params[nparams].eta = values.next_double(); + params[nparams].zi = values.next_double(); + params[nparams].zj = values.next_double(); + params[nparams].lambda1 = values.next_double(); + params[nparams].bigd = values.next_double(); + params[nparams].lambda4 = values.next_double(); + params[nparams].bigw = values.next_double(); + params[nparams].cut = values.next_double(); + params[nparams].bigb = values.next_double(); + params[nparams].gamma = values.next_double(); + params[nparams].r0 = values.next_double(); + params[nparams].bigc = values.next_double(); + params[nparams].costheta = values.next_double(); + } catch (TokenizerException & e) { + error->one(FLERR, e.what()); } - 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); - if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + + if (params[nparams].bigb < 0.0 || params[nparams].gamma < 0.0 || + params[nparams].r0 < 0.0 || params[nparams].bigc < 0.0 || + params[nparams].bigh < 0.0 || params[nparams].eta < 0.0 || + params[nparams].lambda1 < 0.0 || params[nparams].bigd < 0.0 || + params[nparams].lambda4 < 0.0 || params[nparams].bigw < 0.0 || + params[nparams].cut < 0.0) + error->one(FLERR,"Illegal Vashishta parameter"); + + nparams++; } - - if (nwords != params_per_line) - error->all(FLERR,"Incorrect format in Vashishta potential file"); - - // words = ptrs to all words in line - - nwords = 0; - words[nwords++] = strtok(line," \t\n\r\f"); - while ((words[nwords++] = strtok(NULL," \t\n\r\f"))) continue; - - // ielement,jelement,kelement = 1st args - // if all 3 args are in element list, then parse this line - // else skip to next entry in file - - for (ielement = 0; ielement < nelements; ielement++) - if (strcmp(words[0],elements[ielement]) == 0) break; - if (ielement == nelements) continue; - for (jelement = 0; jelement < nelements; jelement++) - if (strcmp(words[1],elements[jelement]) == 0) break; - if (jelement == nelements) continue; - for (kelement = 0; kelement < nelements; kelement++) - if (strcmp(words[2],elements[kelement]) == 0) break; - if (kelement == nelements) continue; - - // load up parameter settings and error check their values - - if (nparams == maxparam) { - maxparam += DELTA; - params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), - "pair:params"); - } - - params[nparams].ielement = ielement; - params[nparams].jelement = jelement; - params[nparams].kelement = kelement; - params[nparams].bigh = atof(words[3]); - params[nparams].eta = atof(words[4]); - params[nparams].zi = atof(words[5]); - params[nparams].zj = atof(words[6]); - params[nparams].lambda1 = atof(words[7]); - params[nparams].bigd = atof(words[8]); - params[nparams].lambda4 = atof(words[9]); - params[nparams].bigw = atof(words[10]); - params[nparams].cut = atof(words[11]); - params[nparams].bigb = atof(words[12]); - params[nparams].gamma = atof(words[13]); - params[nparams].r0 = atof(words[14]); - params[nparams].bigc = atof(words[15]); - params[nparams].costheta = atof(words[16]); - - if (params[nparams].bigb < 0.0 || params[nparams].gamma < 0.0 || - params[nparams].r0 < 0.0 || params[nparams].bigc < 0.0 || - params[nparams].bigh < 0.0 || params[nparams].eta < 0.0 || - params[nparams].lambda1 < 0.0 || params[nparams].bigd < 0.0 || - params[nparams].lambda4 < 0.0 || params[nparams].bigw < 0.0 || - params[nparams].cut < 0.0) - error->all(FLERR,"Illegal Vashishta parameter"); - - nparams++; } - delete [] words; + MPI_Bcast(&nparams, 1, MPI_INT, 0, world); + MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); + + if(comm->me != 0) { + params = (Param *) memory->srealloc(params,maxparam*sizeof(Param), "pair:params"); + } + + MPI_Bcast(params, maxparam*sizeof(Param), MPI_BYTE, 0, world); } /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_vashishta.h b/src/MANYBODY/pair_vashishta.h index 5ec47cf92d..bd250d328a 100644 --- a/src/MANYBODY/pair_vashishta.h +++ b/src/MANYBODY/pair_vashishta.h @@ -34,6 +34,8 @@ class PairVashishta : public Pair { double init_one(int, int); void init_style(); + static const int NPARAMS_PER_LINE = 17; + struct Param { double bigb,gamma,r0,bigc,costheta; double bigh,eta,zi,zj; diff --git a/src/MOLECULE/fix_cmap.cpp b/src/MOLECULE/fix_cmap.cpp index fb0a550898..a1b4d23b05 100644 --- a/src/MOLECULE/fix_cmap.cpp +++ b/src/MOLECULE/fix_cmap.cpp @@ -41,6 +41,7 @@ #include "math_const.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; using namespace FixConst; @@ -1066,7 +1067,7 @@ void FixCMAP::read_data_section(char *keyword, int n, char *buf, next = strchr(buf,'\n'); *next = '\0'; - int nwords = atom->count_words(buf); + int nwords = utils::count_words(utils::trim_comment(buf)); *next = '\n'; if (nwords != 7) { diff --git a/src/QEQ/fix_qeq.cpp b/src/QEQ/fix_qeq.cpp index 84ba33e28a..63fa3caefe 100644 --- a/src/QEQ/fix_qeq.cpp +++ b/src/QEQ/fix_qeq.cpp @@ -27,6 +27,7 @@ #include "force.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; using namespace FixConst; @@ -738,7 +739,7 @@ void FixQEq::read_file(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // must have 6 parameters per line. diff --git a/src/REPLICA/neb.cpp b/src/REPLICA/neb.cpp index dafc0c0875..5a1f942815 100644 --- a/src/REPLICA/neb.cpp +++ b/src/REPLICA/neb.cpp @@ -33,6 +33,7 @@ #include "error.h" #include "force.h" #include "math_const.h" +#include "utils.h" using namespace LAMMPS_NS; using namespace MathConst; @@ -447,7 +448,7 @@ void NEB::readfile(char *file, int flag) buf = buffer; next = strchr(buf,'\n'); *next = '\0'; - int nwords = atom->count_words(buf); + int nwords = utils::count_words(utils::trim_comment(buf)); *next = '\n'; if (nwords != ATTRIBUTE_PERLINE) diff --git a/src/RIGID/fix_rigid.cpp b/src/RIGID/fix_rigid.cpp index d77bf988a6..28a348e58b 100644 --- a/src/RIGID/fix_rigid.cpp +++ b/src/RIGID/fix_rigid.cpp @@ -35,6 +35,7 @@ #include "memory.h" #include "error.h" #include "rigid_const.h" +#include "utils.h" using namespace LAMMPS_NS; using namespace FixConst; @@ -2330,7 +2331,7 @@ void FixRigid::readfile(int which, double *vec, buf = buffer; next = strchr(buf,'\n'); *next = '\0'; - int nwords = atom->count_words(buf); + int nwords = utils::count_words(utils::trim_comment(buf)); *next = '\n'; if (nwords != ATTRIBUTE_PERBODY) diff --git a/src/RIGID/fix_rigid_small.cpp b/src/RIGID/fix_rigid_small.cpp index 9974a7f888..89fa3add4b 100644 --- a/src/RIGID/fix_rigid_small.cpp +++ b/src/RIGID/fix_rigid_small.cpp @@ -39,6 +39,7 @@ #include "memory.h" #include "error.h" #include "rigid_const.h" +#include "utils.h" #include @@ -2488,7 +2489,7 @@ void FixRigidSmall::readfile(int which, double **array, int *inbody) buf = buffer; next = strchr(buf,'\n'); *next = '\0'; - int nwords = atom->count_words(buf); + int nwords = utils::count_words(buf); *next = '\n'; if (nwords != ATTRIBUTE_PERBODY) diff --git a/src/SNAP/compute_snap.cpp b/src/SNAP/compute_snap.cpp index 43b6a419da..17127107ac 100644 --- a/src/SNAP/compute_snap.cpp +++ b/src/SNAP/compute_snap.cpp @@ -33,7 +33,8 @@ enum{SCALAR,VECTOR,ARRAY}; ComputeSnap::ComputeSnap(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg), cutsq(NULL), list(NULL), snap(NULL), - radelem(NULL), wjelem(NULL), snap_peratom(NULL), snapall(NULL) + snapall(NULL), snap_peratom(NULL), radelem(NULL), wjelem(NULL), + snaptr(NULL) { array_flag = 1; @@ -41,9 +42,6 @@ ComputeSnap::ComputeSnap(LAMMPS *lmp, int narg, char **arg) : double rfac0, rmin0; int twojmax, switchflag, bzeroflag; - radelem = NULL; - wjelem = NULL; - int ntypes = atom->ntypes; int nargmin = 6+2*ntypes; @@ -413,7 +411,6 @@ void ComputeSnap::compute_array() const int typeoffset_local = ndims_peratom*nperdim*itype; const int typeoffset_global = nperdim*itype; for (int icoeff = 0; icoeff < nperdim; icoeff++) { - int irow = 1; for (int i = 0; i < ntotal; i++) { double *snadi = snap_peratom[i]+typeoffset_local; int iglobal = atom->tag[i]; diff --git a/src/SNAP/pair_snap.cpp b/src/SNAP/pair_snap.cpp index 8c252cca1d..7108e62142 100644 --- a/src/SNAP/pair_snap.cpp +++ b/src/SNAP/pair_snap.cpp @@ -25,6 +25,7 @@ #include "sna.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -526,7 +527,7 @@ void PairSNAP::read_files(char *coefffilename, char *paramfilename) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != 2) error->all(FLERR,"Incorrect format in SNAP coefficient file"); @@ -567,7 +568,7 @@ void PairSNAP::read_files(char *coefffilename, char *paramfilename) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords != 3) error->all(FLERR,"Incorrect format in SNAP coefficient file"); @@ -609,7 +610,7 @@ void PairSNAP::read_files(char *coefffilename, char *paramfilename) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords != 1) error->all(FLERR,"Incorrect format in SNAP coefficient file"); @@ -666,7 +667,7 @@ void PairSNAP::read_files(char *coefffilename, char *paramfilename) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; if (nwords != 2) diff --git a/src/SPIN/neb_spin.cpp b/src/SPIN/neb_spin.cpp index 075850d1af..5d58a22567 100644 --- a/src/SPIN/neb_spin.cpp +++ b/src/SPIN/neb_spin.cpp @@ -441,7 +441,7 @@ void NEBSpin::readfile(char *file, int flag) buf = buffer; next = strchr(buf,'\n'); *next = '\0'; - int nwords = atom->count_words(buf); + int nwords = utils::count_words(buf); *next = '\n'; if (nwords != ATTRIBUTE_PERLINE) diff --git a/src/USER-CGDNA/pair_oxrna2_xstk.cpp b/src/USER-CGDNA/pair_oxrna2_xstk.cpp index f5207c53e7..73a73c1ea0 100644 --- a/src/USER-CGDNA/pair_oxrna2_xstk.cpp +++ b/src/USER-CGDNA/pair_oxrna2_xstk.cpp @@ -112,7 +112,6 @@ void PairOxrna2Xstk::compute(int eflag, int vflag) double theta1,t1dir[3],cost1; double theta2,t2dir[3],cost2; double theta3,t3dir[3],cost3; - double theta4,theta4p,t4dir[3],cost4; double theta7,theta7p,t7dir[3],cost7; double theta8,theta8p,t8dir[3],cost8; diff --git a/src/USER-DPD/fix_eos_table_rx.cpp b/src/USER-DPD/fix_eos_table_rx.cpp index 3fe2f479bf..d9641f2aab 100644 --- a/src/USER-DPD/fix_eos_table_rx.cpp +++ b/src/USER-DPD/fix_eos_table_rx.cpp @@ -337,7 +337,7 @@ void FixEOStableRX::read_file(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -356,7 +356,7 @@ void FixEOStableRX::read_file(char *file) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != min_params_per_line && nwords != max_params_per_line) @@ -475,7 +475,7 @@ void FixEOStableRX::read_table(Table *tb, Table *tb2, char *file, char *keyword) for (int i = 0; i < ninputs; i++) { utils::sfgets(FLERR,line,MAXLINE,fp,file,error); - nwords = atom->count_words(line); + nwords = utils::count_words(utils::trim_comment(line)); if(nwords != nspecies+2){ printf("nwords=%d nspecies=%d\n",nwords,nspecies); error->all(FLERR,"Illegal fix eos/table/rx command"); diff --git a/src/USER-DPD/fix_rx.cpp b/src/USER-DPD/fix_rx.cpp index 3d870cc902..07e56d9db8 100644 --- a/src/USER-DPD/fix_rx.cpp +++ b/src/USER-DPD/fix_rx.cpp @@ -31,6 +31,7 @@ #include "neigh_request.h" #include "math_special.h" #include "pair_dpd_fdt_energy.h" +#include "utils.h" #include // std::vector<> #include // std::max @@ -296,7 +297,7 @@ void FixRX::post_constructor() // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // words = ptrs to all words in line @@ -884,7 +885,7 @@ void FixRX::read_file(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; nreactions++; @@ -938,7 +939,7 @@ void FixRX::read_file(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // words = ptrs to all words in line diff --git a/src/USER-DPD/pair_exp6_rx.cpp b/src/USER-DPD/pair_exp6_rx.cpp index 4aee497b64..f13f911326 100644 --- a/src/USER-DPD/pair_exp6_rx.cpp +++ b/src/USER-DPD/pair_exp6_rx.cpp @@ -756,7 +756,7 @@ void PairExp6rx::read_file(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -775,7 +775,7 @@ void PairExp6rx::read_file(char *file) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) @@ -865,7 +865,7 @@ void PairExp6rx::read_file2(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -884,7 +884,7 @@ void PairExp6rx::read_file2(char *file) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) diff --git a/src/USER-INTEL/pair_eam_alloy_intel.cpp b/src/USER-INTEL/pair_eam_alloy_intel.cpp index da8a180fff..4a7a8b801d 100644 --- a/src/USER-INTEL/pair_eam_alloy_intel.cpp +++ b/src/USER-INTEL/pair_eam_alloy_intel.cpp @@ -24,11 +24,12 @@ #include "force.h" #include "memory.h" #include "error.h" +#include "utils.h" +#include "tokenizer.h" +#include "potential_file_reader.h" using namespace LAMMPS_NS; -#define MAXLINE 1024 - /* ---------------------------------------------------------------------- */ PairEAMAlloyIntel::PairEAMAlloyIntel(LAMMPS *lmp) : PairEAMIntel(lmp) @@ -116,94 +117,112 @@ void PairEAMAlloyIntel::read_file(char *filename) { Setfl *file = setfl; - // open potential file + // read potential file + if(comm->me == 0) { + PotentialFileReader reader(lmp, filename, "EAM"); - int me = comm->me; - FILE *fptr; - char line[MAXLINE]; + try { + char * line = nullptr; - if (me == 0) { - fptr = force->open_potential(filename); - if (fptr == NULL) { - char str[128]; - snprintf(str,128,"Cannot open EAM potential file %s",filename); - error->one(FLERR,str); + reader.skip_line(); + reader.skip_line(); + reader.skip_line(); + + // extract element names from nelements line + line = reader.next_line(1); + ValueTokenizer values(line); + file->nelements = values.next_int(); + + if (values.count() != file->nelements + 1) + error->one(FLERR,"Incorrect element names in EAM potential file"); + + file->elements = new char*[file->nelements]; + for (int i = 0; i < file->nelements; i++) { + const std::string word = values.next_string(); + const int n = word.length() + 1; + file->elements[i] = new char[n]; + strcpy(file->elements[i], word.c_str()); + } + + // + + line = reader.next_line(5); + values = ValueTokenizer(line); + file->nrho = values.next_int(); + file->drho = values.next_double(); + file->nr = values.next_int(); + file->dr = values.next_double(); + file->cut = values.next_double(); + + if ((file->nrho <= 0) || (file->nr <= 0) || (file->dr <= 0.0)) + error->one(FLERR,"Invalid EAM potential file"); + + memory->create(file->mass, file->nelements, "pair:mass"); + memory->create(file->frho, file->nelements, file->nrho + 1, "pair:frho"); + memory->create(file->rhor, file->nelements, file->nr + 1, "pair:rhor"); + memory->create(file->z2r, file->nelements, file->nelements, file->nr + 1, "pair:z2r"); + + for (int i = 0; i < file->nelements; i++) { + line = reader.next_line(2); + values = ValueTokenizer(line); + values.next_int(); // ignore + file->mass[i] = values.next_double(); + + reader.next_dvector(file->nrho, &file->frho[i][1]); + reader.next_dvector(file->nr, &file->rhor[i][1]); + } + + for (int i = 0; i < file->nelements; i++) { + for (int j = 0; j <= i; j++) { + reader.next_dvector(file->nr, &file->z2r[i][j][1]); + } + } + } catch (TokenizerException & e) { + error->one(FLERR, e.what()); } } - // read and broadcast header - // extract element names from nelements line + // broadcast potential information + MPI_Bcast(&file->nelements, 1, MPI_INT, 0, world); - int n; - if (me == 0) { - fgets(line,MAXLINE,fptr); - fgets(line,MAXLINE,fptr); - fgets(line,MAXLINE,fptr); - fgets(line,MAXLINE,fptr); - n = strlen(line) + 1; + MPI_Bcast(&file->nrho, 1, MPI_INT, 0, world); + MPI_Bcast(&file->drho, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->nr, 1, MPI_INT, 0, world); + MPI_Bcast(&file->dr, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->cut, 1, MPI_DOUBLE, 0, world); + + // allocate memory on other procs + if (comm->me != 0) { + file->elements = new char*[file->nelements]; + for (int i = 0; i < file->nelements; i++) file->elements[i] = nullptr; + memory->create(file->mass, file->nelements, "pair:mass"); + memory->create(file->frho, file->nelements, file->nrho + 1, "pair:frho"); + memory->create(file->rhor, file->nelements, file->nr + 1, "pair:rhor"); + memory->create(file->z2r, file->nelements, file->nelements, file->nr + 1, "pair:z2r"); } - MPI_Bcast(&n,1,MPI_INT,0,world); - MPI_Bcast(line,n,MPI_CHAR,0,world); - sscanf(line,"%d",&file->nelements); - int nwords = atom->count_words(line); - if (nwords != file->nelements + 1) - error->all(FLERR,"Incorrect element names in EAM potential file"); - - char **words = new char*[file->nelements+1]; - nwords = 0; - strtok(line," \t\n\r\f"); - while ((words[nwords++] = strtok(NULL," \t\n\r\f"))) continue; - - file->elements = new char*[file->nelements]; + // broadcast file->elements string array for (int i = 0; i < file->nelements; i++) { - n = strlen(words[i]) + 1; - file->elements[i] = new char[n]; - strcpy(file->elements[i],words[i]); - } - delete [] words; - - if (me == 0) { - fgets(line,MAXLINE,fptr); - sscanf(line,"%d %lg %d %lg %lg", - &file->nrho,&file->drho,&file->nr,&file->dr,&file->cut); + int n; + if (comm->me == 0) n = strlen(file->elements[i]) + 1; + MPI_Bcast(&n, 1, MPI_INT, 0, world); + if (comm->me != 0) file->elements[i] = new char[n]; + MPI_Bcast(file->elements[i], n, MPI_CHAR, 0, world); } - MPI_Bcast(&file->nrho,1,MPI_INT,0,world); - MPI_Bcast(&file->drho,1,MPI_DOUBLE,0,world); - MPI_Bcast(&file->nr,1,MPI_INT,0,world); - MPI_Bcast(&file->dr,1,MPI_DOUBLE,0,world); - MPI_Bcast(&file->cut,1,MPI_DOUBLE,0,world); + // broadcast file->mass, frho, rhor + for (int i = 0; i < file->nelements; i++) { + MPI_Bcast(&file->mass[i], 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->frho[i][1], file->nrho, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->rhor[i][1], file->nr, MPI_DOUBLE, 0, world); + } - file->mass = new double[file->nelements]; - memory->create(file->frho,file->nelements,file->nrho+1,"pair:frho"); - memory->create(file->rhor,file->nelements,file->nr+1,"pair:rhor"); - memory->create(file->z2r,file->nelements,file->nelements,file->nr+1, - "pair:z2r"); - - int i,j,tmp; - for (i = 0; i < file->nelements; i++) { - if (me == 0) { - fgets(line,MAXLINE,fptr); - sscanf(line,"%d %lg",&tmp,&file->mass[i]); + // broadcast file->z2r + for (int i = 0; i < file->nelements; i++) { + for (int j = 0; j <= i; j++) { + MPI_Bcast(&file->z2r[i][j][1], file->nr, MPI_DOUBLE, 0, world); } - MPI_Bcast(&file->mass[i],1,MPI_DOUBLE,0,world); - - if (me == 0) grab(fptr,file->nrho,&file->frho[i][1]); - MPI_Bcast(&file->frho[i][1],file->nrho,MPI_DOUBLE,0,world); - if (me == 0) grab(fptr,file->nr,&file->rhor[i][1]); - MPI_Bcast(&file->rhor[i][1],file->nr,MPI_DOUBLE,0,world); } - - for (i = 0; i < file->nelements; i++) - for (j = 0; j <= i; j++) { - if (me == 0) grab(fptr,file->nr,&file->z2r[i][j][1]); - MPI_Bcast(&file->z2r[i][j][1],file->nr,MPI_DOUBLE,0,world); - } - - // close the potential file - - if (me == 0) fclose(fptr); } /* ---------------------------------------------------------------------- diff --git a/src/USER-INTEL/pair_eam_fs_intel.cpp b/src/USER-INTEL/pair_eam_fs_intel.cpp index 043f77db3e..0d4cb5e3ae 100644 --- a/src/USER-INTEL/pair_eam_fs_intel.cpp +++ b/src/USER-INTEL/pair_eam_fs_intel.cpp @@ -24,11 +24,12 @@ #include "force.h" #include "memory.h" #include "error.h" +#include "utils.h" +#include "tokenizer.h" +#include "potential_file_reader.h" using namespace LAMMPS_NS; -#define MAXLINE 1024 - /* ---------------------------------------------------------------------- */ PairEAMFSIntel::PairEAMFSIntel(LAMMPS *lmp) : PairEAMIntel(lmp) @@ -116,99 +117,118 @@ void PairEAMFSIntel::read_file(char *filename) { Fs *file = fs; - // open potential file + // read potential file + if(comm->me == 0) { + PotentialFileReader reader(lmp, filename, "EAM"); - int me = comm->me; - FILE *fptr; - char line[MAXLINE]; + try { + char * line = nullptr; - if (me == 0) { - fptr = force->open_potential(filename); - if (fptr == NULL) { - char str[128]; - snprintf(str,128,"Cannot open EAM potential file %s",filename); - error->one(FLERR,str); + reader.skip_line(); + reader.skip_line(); + reader.skip_line(); + + // extract element names from nelements line + line = reader.next_line(1); + ValueTokenizer values(line); + file->nelements = values.next_int(); + + if (values.count() != file->nelements + 1) + error->one(FLERR,"Incorrect element names in EAM potential file"); + + file->elements = new char*[file->nelements]; + for (int i = 0; i < file->nelements; i++) { + const std::string word = values.next_string(); + const int n = word.length() + 1; + file->elements[i] = new char[n]; + strcpy(file->elements[i], word.c_str()); + } + + // + + line = reader.next_line(5); + values = ValueTokenizer(line); + file->nrho = values.next_int(); + file->drho = values.next_double(); + file->nr = values.next_int(); + file->dr = values.next_double(); + file->cut = values.next_double(); + + if ((file->nrho <= 0) || (file->nr <= 0) || (file->dr <= 0.0)) + error->one(FLERR,"Invalid EAM potential file"); + + memory->create(file->mass, file->nelements, "pair:mass"); + memory->create(file->frho, file->nelements, file->nrho + 1, "pair:frho"); + memory->create(file->rhor, file->nelements, file->nelements, file->nr + 1, "pair:rhor"); + memory->create(file->z2r, file->nelements, file->nelements, file->nr + 1, "pair:z2r"); + + for (int i = 0; i < file->nelements; i++) { + line = reader.next_line(2); + values = ValueTokenizer(line); + values.next_int(); // ignore + file->mass[i] = values.next_double(); + + reader.next_dvector(file->nrho, &file->frho[i][1]); + + for (int j = 0; j < file->nelements; j++) { + reader.next_dvector(file->nr, &file->rhor[i][j][1]); + } + } + + for (int i = 0; i < file->nelements; i++) { + for (int j = 0; j <= i; j++) { + reader.next_dvector(file->nr, &file->z2r[i][j][1]); + } + } + } catch (TokenizerException & e) { + error->one(FLERR, e.what()); } } - // read and broadcast header - // extract element names from nelements line + // broadcast potential information + MPI_Bcast(&file->nelements, 1, MPI_INT, 0, world); - int n; - if (me == 0) { - fgets(line,MAXLINE,fptr); - fgets(line,MAXLINE,fptr); - fgets(line,MAXLINE,fptr); - fgets(line,MAXLINE,fptr); - n = strlen(line) + 1; + MPI_Bcast(&file->nrho, 1, MPI_INT, 0, world); + MPI_Bcast(&file->drho, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->nr, 1, MPI_INT, 0, world); + MPI_Bcast(&file->dr, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->cut, 1, MPI_DOUBLE, 0, world); + + // allocate memory on other procs + if (comm->me != 0) { + file->elements = new char*[file->nelements]; + for (int i = 0; i < file->nelements; i++) file->elements[i] = nullptr; + memory->create(file->mass, file->nelements, "pair:mass"); + memory->create(file->frho, file->nelements, file->nrho + 1, "pair:frho"); + memory->create(file->rhor, file->nelements, file->nelements, file->nr + 1, "pair:rhor"); + memory->create(file->z2r, file->nelements, file->nelements, file->nr + 1, "pair:z2r"); } - MPI_Bcast(&n,1,MPI_INT,0,world); - MPI_Bcast(line,n,MPI_CHAR,0,world); - sscanf(line,"%d",&file->nelements); - int nwords = atom->count_words(line); - if (nwords != file->nelements + 1) - error->all(FLERR,"Incorrect element names in EAM potential file"); - - char **words = new char*[file->nelements+1]; - nwords = 0; - strtok(line," \t\n\r\f"); - while ((words[nwords++] = strtok(NULL," \t\n\r\f"))) continue; - - file->elements = new char*[file->nelements]; + // broadcast file->elements string array for (int i = 0; i < file->nelements; i++) { - n = strlen(words[i]) + 1; - file->elements[i] = new char[n]; - strcpy(file->elements[i],words[i]); - } - delete [] words; - - if (me == 0) { - fgets(line,MAXLINE,fptr); - sscanf(line,"%d %lg %d %lg %lg", - &file->nrho,&file->drho,&file->nr,&file->dr,&file->cut); + int n; + if (comm->me == 0) n = strlen(file->elements[i]) + 1; + MPI_Bcast(&n, 1, MPI_INT, 0, world); + if (comm->me != 0) file->elements[i] = new char[n]; + MPI_Bcast(file->elements[i], n, MPI_CHAR, 0, world); } - MPI_Bcast(&file->nrho,1,MPI_INT,0,world); - MPI_Bcast(&file->drho,1,MPI_DOUBLE,0,world); - MPI_Bcast(&file->nr,1,MPI_INT,0,world); - MPI_Bcast(&file->dr,1,MPI_DOUBLE,0,world); - MPI_Bcast(&file->cut,1,MPI_DOUBLE,0,world); + // broadcast file->mass, frho, rhor + for (int i = 0; i < file->nelements; i++) { + MPI_Bcast(&file->mass[i], 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->frho[i][1], file->nrho, MPI_DOUBLE, 0, world); - file->mass = new double[file->nelements]; - memory->create(file->frho,file->nelements,file->nrho+1, - "pair:frho"); - memory->create(file->rhor,file->nelements,file->nelements, - file->nr+1,"pair:rhor"); - memory->create(file->z2r,file->nelements,file->nelements, - file->nr+1,"pair:z2r"); - - int i,j,tmp; - for (i = 0; i < file->nelements; i++) { - if (me == 0) { - fgets(line,MAXLINE,fptr); - sscanf(line,"%d %lg",&tmp,&file->mass[i]); - } - MPI_Bcast(&file->mass[i],1,MPI_DOUBLE,0,world); - - if (me == 0) grab(fptr,file->nrho,&file->frho[i][1]); - MPI_Bcast(&file->frho[i][1],file->nrho,MPI_DOUBLE,0,world); - - for (j = 0; j < file->nelements; j++) { - if (me == 0) grab(fptr,file->nr,&file->rhor[i][j][1]); - MPI_Bcast(&file->rhor[i][j][1],file->nr,MPI_DOUBLE,0,world); + for (int j = 0; j < file->nelements; j++) { + MPI_Bcast(&file->rhor[i][j][1], file->nr, MPI_DOUBLE, 0, world); } } - for (i = 0; i < file->nelements; i++) - for (j = 0; j <= i; j++) { - if (me == 0) grab(fptr,file->nr,&file->z2r[i][j][1]); - MPI_Bcast(&file->z2r[i][j][1],file->nr,MPI_DOUBLE,0,world); + // broadcast file->z2r + for (int i = 0; i < file->nelements; i++) { + for (int j = 0; j <= i; j++) { + MPI_Bcast(&file->z2r[i][j][1], file->nr, MPI_DOUBLE, 0, world); } - - // close the potential file - - if (me == 0) fclose(fptr); + } } /* ---------------------------------------------------------------------- diff --git a/src/USER-MEAMC/pair_meamc.cpp b/src/USER-MEAMC/pair_meamc.cpp index c49b5abf0b..6cd8ec6136 100644 --- a/src/USER-MEAMC/pair_meamc.cpp +++ b/src/USER-MEAMC/pair_meamc.cpp @@ -28,6 +28,7 @@ #include "neigh_request.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -383,7 +384,7 @@ void PairMEAMC::read_files(char *globalfile, char *userfile) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - int nwords = atom->count_words(line); + int nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -396,7 +397,7 @@ void PairMEAMC::read_files(char *globalfile, char *userfile) break; } if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) @@ -561,7 +562,7 @@ void PairMEAMC::read_files(char *globalfile, char *userfile) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - if (atom->count_words(line) == 0) continue; + if (utils::count_words(line) == 0) continue; // params = ptrs to all fields in line diff --git a/src/USER-MISC/compute_viscosity_cos.cpp b/src/USER-MISC/compute_viscosity_cos.cpp index 64103d2653..7311f991cc 100644 --- a/src/USER-MISC/compute_viscosity_cos.cpp +++ b/src/USER-MISC/compute_viscosity_cos.cpp @@ -256,7 +256,7 @@ void ComputeViscosityCos::remove_bias_all() { assume remove_bias() was previously called ------------------------------------------------------------------------- */ -void ComputeViscosityCos::restore_bias(int i, double *v) { +void ComputeViscosityCos::restore_bias(int /* i */, double *v) { v[0] += vbias[0]; v[1] += vbias[1]; v[2] += vbias[2]; @@ -267,7 +267,7 @@ void ComputeViscosityCos::restore_bias(int i, double *v) { assume remove_bias_thr() was previously called with the same buffer b ------------------------------------------------------------------------- */ -void ComputeViscosityCos::restore_bias_thr(int i, double *v, double *b) { +void ComputeViscosityCos::restore_bias_thr(int /* i */, double *v, double *b) { v[0] += b[0]; v[1] += b[1]; v[2] += b[2]; diff --git a/src/USER-MISC/dihedral_nharmonic.cpp b/src/USER-MISC/dihedral_nharmonic.cpp index 238c17d812..81010a040e 100644 --- a/src/USER-MISC/dihedral_nharmonic.cpp +++ b/src/USER-MISC/dihedral_nharmonic.cpp @@ -47,7 +47,7 @@ DihedralNHarmonic::~DihedralNHarmonic() if (allocated) { memory->destroy(setflag); for (int i = 1; i <= atom->ndihedraltypes; i++) - delete [] a[i]; + if ( a[i] ) delete [] a[i]; delete [] a; delete [] nterms; } @@ -263,6 +263,7 @@ void DihedralNHarmonic::allocate() nterms = new int[n+1]; a = new double *[n+1]; + for (int i = 1; i <= n; i++) a[i] = 0; memory->create(setflag,n+1,"dihedral:setflag"); for (int i = 1; i <= n; i++) setflag[i] = 0; diff --git a/src/USER-MISC/fix_accelerate_cos.cpp b/src/USER-MISC/fix_accelerate_cos.cpp index 0d3b66d3f5..88e33023fd 100644 --- a/src/USER-MISC/fix_accelerate_cos.cpp +++ b/src/USER-MISC/fix_accelerate_cos.cpp @@ -58,7 +58,7 @@ void FixAccelerateCos::setup(int vflag) { /* ---------------------------------------------------------------------- */ -void FixAccelerateCos::post_force(int vflag) { +void FixAccelerateCos::post_force(int /* vflag */) { double **x = atom->x; double **f = atom->f; int *type = atom->type; diff --git a/src/USER-MISC/fix_gle.cpp b/src/USER-MISC/fix_gle.cpp index b8bdc66d08..a1cf1ac2e9 100644 --- a/src/USER-MISC/fix_gle.cpp +++ b/src/USER-MISC/fix_gle.cpp @@ -29,6 +29,7 @@ #include "random_mars.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; using namespace FixConst; @@ -251,7 +252,7 @@ FixGLE::FixGLE(LAMMPS *lmp, int narg, char **arg) : if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; ptr = strtok(line," \t\n\r\f"); @@ -323,7 +324,7 @@ FixGLE::FixGLE(LAMMPS *lmp, int narg, char **arg) : if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; ptr = strtok(line," \t\n\r\f"); diff --git a/src/USER-MISC/pair_agni.cpp b/src/USER-MISC/pair_agni.cpp index a03e24ed35..4941f2c7b3 100644 --- a/src/USER-MISC/pair_agni.cpp +++ b/src/USER-MISC/pair_agni.cpp @@ -31,6 +31,7 @@ #include "citeme.h" #include "math_special.h" #include "math_const.h" +#include "utils.h" using namespace LAMMPS_NS; using namespace MathSpecial; @@ -387,7 +388,7 @@ void PairAGNI::read_file(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; if (nwords > MAXWORD) diff --git a/src/USER-MISC/pair_drip.cpp b/src/USER-MISC/pair_drip.cpp index bb28d056ac..e6b0e5acc6 100644 --- a/src/USER-MISC/pair_drip.cpp +++ b/src/USER-MISC/pair_drip.cpp @@ -254,7 +254,7 @@ void PairDRIP::read_file(char *filename) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -273,7 +273,7 @@ void PairDRIP::read_file(char *filename) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) diff --git a/src/USER-MISC/pair_edip.cpp b/src/USER-MISC/pair_edip.cpp index 8dee4a606b..d873a04c39 100644 --- a/src/USER-MISC/pair_edip.cpp +++ b/src/USER-MISC/pair_edip.cpp @@ -35,6 +35,7 @@ #include "comm.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -905,7 +906,7 @@ void PairEDIP::read_file(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -924,7 +925,7 @@ void PairEDIP::read_file(char *file) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) diff --git a/src/USER-MISC/pair_edip_multi.cpp b/src/USER-MISC/pair_edip_multi.cpp index 9f953610de..cfda5c1a7c 100644 --- a/src/USER-MISC/pair_edip_multi.cpp +++ b/src/USER-MISC/pair_edip_multi.cpp @@ -31,6 +31,7 @@ #include "memory.h" #include "error.h" #include "citeme.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -671,7 +672,7 @@ void PairEDIPMulti::read_file(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -690,7 +691,7 @@ void PairEDIPMulti::read_file(char *file) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) diff --git a/src/USER-MISC/pair_extep.cpp b/src/USER-MISC/pair_extep.cpp index 62ef24da85..2036df7add 100644 --- a/src/USER-MISC/pair_extep.cpp +++ b/src/USER-MISC/pair_extep.cpp @@ -30,6 +30,7 @@ #include "comm.h" #include "memory.h" #include "error.h" +#include "utils.h" #include "math_const.h" @@ -619,7 +620,7 @@ void PairExTeP::read_file(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -638,7 +639,7 @@ void PairExTeP::read_file(char *file) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) @@ -744,7 +745,7 @@ void PairExTeP::read_file(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // words = ptrs to all words in line diff --git a/src/USER-MISC/pair_ilp_graphene_hbn.cpp b/src/USER-MISC/pair_ilp_graphene_hbn.cpp index cf77f7e1ee..32689307c0 100644 --- a/src/USER-MISC/pair_ilp_graphene_hbn.cpp +++ b/src/USER-MISC/pair_ilp_graphene_hbn.cpp @@ -34,6 +34,7 @@ #include "my_page.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -286,7 +287,7 @@ void PairILPGrapheneHBN::read_file(char *filename) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -305,7 +306,7 @@ void PairILPGrapheneHBN::read_file(char *filename) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) diff --git a/src/USER-MISC/pair_kolmogorov_crespi_full.cpp b/src/USER-MISC/pair_kolmogorov_crespi_full.cpp index 3f624fc785..f5f2a6ca01 100644 --- a/src/USER-MISC/pair_kolmogorov_crespi_full.cpp +++ b/src/USER-MISC/pair_kolmogorov_crespi_full.cpp @@ -34,6 +34,7 @@ #include "my_page.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -287,7 +288,7 @@ void PairKolmogorovCrespiFull::read_file(char *filename) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -306,7 +307,7 @@ void PairKolmogorovCrespiFull::read_file(char *filename) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) diff --git a/src/USER-MISC/pair_kolmogorov_crespi_z.cpp b/src/USER-MISC/pair_kolmogorov_crespi_z.cpp index 61c326ac87..07f0a766e4 100644 --- a/src/USER-MISC/pair_kolmogorov_crespi_z.cpp +++ b/src/USER-MISC/pair_kolmogorov_crespi_z.cpp @@ -32,6 +32,7 @@ #include "neigh_list.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -345,7 +346,7 @@ void PairKolmogorovCrespiZ::read_file(char *filename) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -364,7 +365,7 @@ void PairKolmogorovCrespiZ::read_file(char *filename) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) diff --git a/src/USER-MISC/pair_lebedeva_z.cpp b/src/USER-MISC/pair_lebedeva_z.cpp index 8930042cef..f6464153e5 100644 --- a/src/USER-MISC/pair_lebedeva_z.cpp +++ b/src/USER-MISC/pair_lebedeva_z.cpp @@ -33,6 +33,7 @@ #include "neigh_list.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -341,7 +342,7 @@ void PairLebedevaZ::read_file(char *filename) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -360,7 +361,7 @@ void PairLebedevaZ::read_file(char *filename) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) diff --git a/src/USER-MISC/pair_tersoff_table.cpp b/src/USER-MISC/pair_tersoff_table.cpp index 5c4f60f354..57c897bdfc 100644 --- a/src/USER-MISC/pair_tersoff_table.cpp +++ b/src/USER-MISC/pair_tersoff_table.cpp @@ -32,6 +32,7 @@ #include "force.h" #include "comm.h" #include "memory.h" +#include "utils.h" #include "error.h" @@ -873,7 +874,7 @@ void PairTersoffTable::read_file(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -892,7 +893,7 @@ void PairTersoffTable::read_file(char *file) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) diff --git a/src/USER-OMP/pair_eam_alloy_omp.cpp b/src/USER-OMP/pair_eam_alloy_omp.cpp index d36574713f..2f6b4919f1 100644 --- a/src/USER-OMP/pair_eam_alloy_omp.cpp +++ b/src/USER-OMP/pair_eam_alloy_omp.cpp @@ -25,11 +25,11 @@ #include "memory.h" #include "error.h" #include "utils.h" +#include "tokenizer.h" +#include "potential_file_reader.h" using namespace LAMMPS_NS; -#define MAXLINE 1024 - /* ---------------------------------------------------------------------- */ PairEAMAlloyOMP::PairEAMAlloyOMP(LAMMPS *lmp) : PairEAMOMP(lmp) @@ -117,94 +117,112 @@ void PairEAMAlloyOMP::read_file(char *filename) { Setfl *file = setfl; - // open potential file + // read potential file + if(comm->me == 0) { + PotentialFileReader reader(PairEAM::lmp, filename, "EAM"); - int me = comm->me; - FILE *fptr; - char line[MAXLINE]; + try { + char * line = nullptr; - if (me == 0) { - fptr = force->open_potential(filename); - if (fptr == NULL) { - char str[128]; - snprintf(str,128,"Cannot open EAM potential file %s",filename); - error->one(FLERR,str); + reader.skip_line(); + reader.skip_line(); + reader.skip_line(); + + // extract element names from nelements line + line = reader.next_line(1); + ValueTokenizer values(line); + file->nelements = values.next_int(); + + if (values.count() != file->nelements + 1) + error->one(FLERR,"Incorrect element names in EAM potential file"); + + file->elements = new char*[file->nelements]; + for (int i = 0; i < file->nelements; i++) { + const std::string word = values.next_string(); + const int n = word.length() + 1; + file->elements[i] = new char[n]; + strcpy(file->elements[i], word.c_str()); + } + + // + + line = reader.next_line(5); + values = ValueTokenizer(line); + file->nrho = values.next_int(); + file->drho = values.next_double(); + file->nr = values.next_int(); + file->dr = values.next_double(); + file->cut = values.next_double(); + + if ((file->nrho <= 0) || (file->nr <= 0) || (file->dr <= 0.0)) + error->one(FLERR,"Invalid EAM potential file"); + + memory->create(file->mass, file->nelements, "pair:mass"); + memory->create(file->frho, file->nelements, file->nrho + 1, "pair:frho"); + memory->create(file->rhor, file->nelements, file->nr + 1, "pair:rhor"); + memory->create(file->z2r, file->nelements, file->nelements, file->nr + 1, "pair:z2r"); + + for (int i = 0; i < file->nelements; i++) { + line = reader.next_line(2); + values = ValueTokenizer(line); + values.next_int(); // ignore + file->mass[i] = values.next_double(); + + reader.next_dvector(file->nrho, &file->frho[i][1]); + reader.next_dvector(file->nr, &file->rhor[i][1]); + } + + for (int i = 0; i < file->nelements; i++) { + for (int j = 0; j <= i; j++) { + reader.next_dvector(file->nr, &file->z2r[i][j][1]); + } + } + } catch (TokenizerException & e) { + error->one(FLERR, e.what()); } } - // read and broadcast header - // extract element names from nelements line + // broadcast potential information + MPI_Bcast(&file->nelements, 1, MPI_INT, 0, world); - int n; - if (me == 0) { - utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error); - utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error); - utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error); - utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error); - n = strlen(line) + 1; + MPI_Bcast(&file->nrho, 1, MPI_INT, 0, world); + MPI_Bcast(&file->drho, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->nr, 1, MPI_INT, 0, world); + MPI_Bcast(&file->dr, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->cut, 1, MPI_DOUBLE, 0, world); + + // allocate memory on other procs + if (comm->me != 0) { + file->elements = new char*[file->nelements]; + for (int i = 0; i < file->nelements; i++) file->elements[i] = nullptr; + memory->create(file->mass, file->nelements, "pair:mass"); + memory->create(file->frho, file->nelements, file->nrho + 1, "pair:frho"); + memory->create(file->rhor, file->nelements, file->nr + 1, "pair:rhor"); + memory->create(file->z2r, file->nelements, file->nelements, file->nr + 1, "pair:z2r"); } - MPI_Bcast(&n,1,MPI_INT,0,world); - MPI_Bcast(line,n,MPI_CHAR,0,world); - sscanf(line,"%d",&file->nelements); - int nwords = atom->count_words(line); - if (nwords != file->nelements + 1) - error->all(FLERR,"Incorrect element names in EAM potential file"); - - char **words = new char*[file->nelements+1]; - nwords = 0; - strtok(line," \t\n\r\f"); - while ((words[nwords++] = strtok(NULL," \t\n\r\f"))) continue; - - file->elements = new char*[file->nelements]; + // broadcast file->elements string array for (int i = 0; i < file->nelements; i++) { - n = strlen(words[i]) + 1; - file->elements[i] = new char[n]; - strcpy(file->elements[i],words[i]); - } - delete [] words; - - if (me == 0) { - utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error); - sscanf(line,"%d %lg %d %lg %lg", - &file->nrho,&file->drho,&file->nr,&file->dr,&file->cut); + int n; + if (comm->me == 0) n = strlen(file->elements[i]) + 1; + MPI_Bcast(&n, 1, MPI_INT, 0, world); + if (comm->me != 0) file->elements[i] = new char[n]; + MPI_Bcast(file->elements[i], n, MPI_CHAR, 0, world); } - MPI_Bcast(&file->nrho,1,MPI_INT,0,world); - MPI_Bcast(&file->drho,1,MPI_DOUBLE,0,world); - MPI_Bcast(&file->nr,1,MPI_INT,0,world); - MPI_Bcast(&file->dr,1,MPI_DOUBLE,0,world); - MPI_Bcast(&file->cut,1,MPI_DOUBLE,0,world); + // broadcast file->mass, frho, rhor + for (int i = 0; i < file->nelements; i++) { + MPI_Bcast(&file->mass[i], 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->frho[i][1], file->nrho, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->rhor[i][1], file->nr, MPI_DOUBLE, 0, world); + } - file->mass = new double[file->nelements]; - memory->create(file->frho,file->nelements,file->nrho+1,"pair:frho"); - memory->create(file->rhor,file->nelements,file->nr+1,"pair:rhor"); - memory->create(file->z2r,file->nelements,file->nelements,file->nr+1, - "pair:z2r"); - - int i,j,tmp; - for (i = 0; i < file->nelements; i++) { - if (me == 0) { - utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error); - sscanf(line,"%d %lg",&tmp,&file->mass[i]); + // broadcast file->z2r + for (int i = 0; i < file->nelements; i++) { + for (int j = 0; j <= i; j++) { + MPI_Bcast(&file->z2r[i][j][1], file->nr, MPI_DOUBLE, 0, world); } - MPI_Bcast(&file->mass[i],1,MPI_DOUBLE,0,world); - - if (me == 0) grab(fptr,file->nrho,&file->frho[i][1]); - MPI_Bcast(&file->frho[i][1],file->nrho,MPI_DOUBLE,0,world); - if (me == 0) grab(fptr,file->nr,&file->rhor[i][1]); - MPI_Bcast(&file->rhor[i][1],file->nr,MPI_DOUBLE,0,world); } - - for (i = 0; i < file->nelements; i++) - for (j = 0; j <= i; j++) { - if (me == 0) grab(fptr,file->nr,&file->z2r[i][j][1]); - MPI_Bcast(&file->z2r[i][j][1],file->nr,MPI_DOUBLE,0,world); - } - - // close the potential file - - if (me == 0) fclose(fptr); } /* ---------------------------------------------------------------------- diff --git a/src/USER-OMP/pair_eam_cd_omp.cpp b/src/USER-OMP/pair_eam_cd_omp.cpp deleted file mode 100644 index 874a2fa252..0000000000 --- a/src/USER-OMP/pair_eam_cd_omp.cpp +++ /dev/null @@ -1,542 +0,0 @@ -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - This software is distributed under the GNU General Public License. - - See the README file in the top-level LAMMPS directory. -------------------------------------------------------------------------- */ - -/* ---------------------------------------------------------------------- - Contributing author: Axel Kohlmeyer (Temple U) -------------------------------------------------------------------------- */ - -#include "omp_compat.h" -#include -#include - -#include "pair_eam_cd_omp.h" -#include "atom.h" -#include "comm.h" -#include "error.h" -#include "force.h" -#include "memory.h" -#include "neighbor.h" -#include "neigh_list.h" - -#include "suffix.h" -using namespace LAMMPS_NS; - -// This is for debugging purposes. The ASSERT() macro is used in the code to check -// if everything runs as expected. Change this to #if 0 if you don't need the checking. -#if 0 - #define ASSERT(cond) ((!(cond)) ? my_failure(error,__FILE__,__LINE__) : my_noop()) - - inline void my_noop() {} - inline void my_failure(Error* error, const char* file, int line) { - char str[1024]; - sprintf(str,"Assertion failure: File %s, line %i", file, line); - error->one(FLERR,str); - } -#else - #define ASSERT(cond) -#endif - -/* ---------------------------------------------------------------------- */ - -PairEAMCDOMP::PairEAMCDOMP(LAMMPS *lmp, int _cdeamVersion) : - PairEAM(lmp), PairEAMCD(lmp,_cdeamVersion), ThrOMP(lmp, THR_PAIR) -{ - suffix_flag |= Suffix::OMP; - respa_enable = 0; -} - -/* ---------------------------------------------------------------------- */ - -void PairEAMCDOMP::compute(int eflag, int vflag) -{ - ev_init(eflag,vflag); - - const int nall = atom->nlocal + atom->nghost; - const int nthreads = comm->nthreads; - const int inum = list->inum; - - // grow energy and fp arrays if necessary - // need to be atom->nmax in length - - if (atom->nmax > nmax) { - memory->destroy(rho); - memory->destroy(rhoB); - memory->destroy(D_values); - memory->destroy(fp); - nmax = atom->nmax; - memory->create(rho,nthreads*nmax,"pair:rho"); - memory->create(rhoB,nthreads*nmax,"pair:mu"); - memory->create(D_values,nthreads*nmax,"pair:D_values"); - memory->create(fp,nmax,"pair:fp"); - } - -#if defined(_OPENMP) -#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(eflag,vflag) -#endif - { - int ifrom, ito, tid; - - loop_setup_thr(ifrom, ito, tid, inum, nthreads); - ThrData *thr = fix->get_thr(tid); - thr->timer(Timer::START); - ev_setup_thr(eflag, vflag, nall, eatom, vatom, NULL, thr); - - if (force->newton_pair) - thr->init_cdeam(nall, rho, rhoB, D_values); - else - thr->init_cdeam(atom->nlocal, rho, rhoB, D_values); - - switch (cdeamVersion) { - - case 1: - - if (evflag) { - if (eflag) { - if (force->newton_pair) eval<1,1,1,1>(ifrom, ito, thr); - else eval<1,1,0,1>(ifrom, ito, thr); - } else { - if (force->newton_pair) eval<1,0,1,1>(ifrom, ito, thr); - else eval<1,0,0,1>(ifrom, ito, thr); - } - } else { - if (force->newton_pair) eval<0,0,1,1>(ifrom, ito, thr); - else eval<0,0,0,1>(ifrom, ito, thr); - } - break; - - case 2: - - if (evflag) { - if (eflag) { - if (force->newton_pair) eval<1,1,1,2>(ifrom, ito, thr); - else eval<1,1,0,2>(ifrom, ito, thr); - } else { - if (force->newton_pair) eval<1,0,1,2>(ifrom, ito, thr); - else eval<1,0,0,2>(ifrom, ito, thr); - } - } else { - if (force->newton_pair) eval<0,0,1,2>(ifrom, ito, thr); - else eval<0,0,0,2>(ifrom, ito, thr); - } - break; - - default: - { -#if defined(_OPENMP) -#pragma omp master -#endif - error->all(FLERR,"unsupported eam/cd pair style variant"); - } - } - - thr->timer(Timer::PAIR); - reduce_thr(this, eflag, vflag, thr); - } // end of omp parallel region -} - -template -void PairEAMCDOMP::eval(int iifrom, int iito, ThrData * const thr) -{ - int i,j,ii,jj,jnum,itype,jtype; - double xtmp,ytmp,ztmp,delx,dely,delz,evdwl,fpair; - double rsq,rhoip,rhojp,recip,phi; - int *ilist,*jlist,*numneigh,**firstneigh; - - evdwl = 0.0; - - const dbl3_t * _noalias const x = (dbl3_t *) atom->x[0]; - dbl3_t * _noalias const f = (dbl3_t *) thr->get_f()[0]; - double * const rho_t = thr->get_rho(); - double * const rhoB_t = thr->get_rhoB(); - double * const D_values_t = thr->get_D_values(); - const int tid = thr->get_tid(); - const int nthreads = comm->nthreads; - - const int * _noalias const type = atom->type; - const int nlocal = atom->nlocal; - const int nall = nlocal + atom->nghost; - - double fxtmp,fytmp,fztmp; - - ilist = list->ilist; - numneigh = list->numneigh; - firstneigh = list->firstneigh; - - // Stage I - - // Compute rho and rhoB at each local atom site. - // Additionally calculate the D_i values here if we are using the one-site formulation. - // For the two-site formulation we have to calculate the D values in an extra loop (Stage II). - - for (ii = iifrom; ii < iito; ii++) { - i = ilist[ii]; - xtmp = x[i].x; - ytmp = x[i].y; - ztmp = x[i].z; - itype = type[i]; - jlist = firstneigh[i]; - jnum = numneigh[i]; - - for (jj = 0; jj < jnum; jj++) { - j = jlist[jj]; - j &= NEIGHMASK; - - delx = xtmp - x[j].x; - dely = ytmp - x[j].y; - delz = ztmp - x[j].z; - rsq = delx*delx + dely*dely + delz*delz; - - if(rsq < cutforcesq) { - jtype = type[j]; - double r = sqrt(rsq); - const EAMTableIndex index = radiusToTableIndex(r); - double localrho = RhoOfR(index, jtype, itype); - rho_t[i] += localrho; - if(jtype == speciesB) rhoB_t[i] += localrho; - if(NEWTON_PAIR || j < nlocal) { - localrho = RhoOfR(index, itype, jtype); - rho_t[j] += localrho; - if(itype == speciesB) rhoB_t[j] += localrho; - } - - if(CDEAMVERSION == 1 && itype != jtype) { - // Note: if the i-j interaction is not concentration dependent (because either - // i or j are not species A or B) then its contribution to D_i and D_j should - // be ignored. - // This if-clause is only required for a ternary. - if((itype == speciesA && jtype == speciesB) - || (jtype == speciesA && itype == speciesB)) { - double Phi_AB = PhiOfR(index, itype, jtype, 1.0 / r); - D_values_t[i] += Phi_AB; - if(NEWTON_PAIR || j < nlocal) - D_values_t[j] += Phi_AB; - } - } - } - } - } - - // wait until all threads are done with computation - sync_threads(); - - // communicate and sum densities - - if (NEWTON_PAIR) { - // reduce per thread density - thr->timer(Timer::PAIR); - data_reduce_thr(rho, nall, nthreads, 1, tid); - data_reduce_thr(rhoB, nall, nthreads, 1, tid); - if (CDEAMVERSION==1) - data_reduce_thr(D_values, nall, nthreads, 1, tid); - - // wait until reduction is complete - sync_threads(); - -#if defined(_OPENMP) -#pragma omp master -#endif - { communicationStage = 1; - comm->reverse_comm_pair(this); } - - // wait until master thread is done with communication - sync_threads(); - - } else { - // reduce per thread density - thr->timer(Timer::PAIR); - data_reduce_thr(rho, nlocal, nthreads, 1, tid); - data_reduce_thr(rhoB, nlocal, nthreads, 1, tid); - if (CDEAMVERSION==1) - data_reduce_thr(D_values, nlocal, nthreads, 1, tid); - - // wait until reduction is complete - sync_threads(); - } - - // fp = derivative of embedding energy at each atom - // phi = embedding energy at each atom - - for (ii = iifrom; ii < iito; ii++) { - i = ilist[ii]; - EAMTableIndex index = rhoToTableIndex(rho[i]); - fp[i] = FPrimeOfRho(index, type[i]); - if(EFLAG) { - phi = FofRho(index, type[i]); - e_tally_thr(this, i, i, nlocal, NEWTON_PAIR, phi, 0.0, thr); - } - } - - // wait until all theads are done with computation - sync_threads(); - - // Communicate derivative of embedding function and densities - // and D_values (this for one-site formulation only). -#if defined(_OPENMP) -#pragma omp master -#endif - { communicationStage = 2; - comm->forward_comm_pair(this); } - - // wait until master thread is done with communication - sync_threads(); - - - // The electron densities may not drop to zero because then the concentration would no longer be defined. - // But the concentration is not needed anyway if there is no interaction with another atom, which is the case - // if the electron density is exactly zero. That's why the following lines have been commented out. - // - //for(i = 0; i < nlocal + atom->nghost; i++) { - // if(rho[i] == 0 && (type[i] == speciesA || type[i] == speciesB)) - // error->one(FLERR,"CD-EAM potential routine: Detected atom with zero electron density."); - //} - - // Stage II - // This is only required for the original two-site formulation of the CD-EAM potential. - - if(CDEAMVERSION == 2) { - // Compute intermediate value D_i for each atom. - for (ii = iifrom; ii < iito; ii++) { - i = ilist[ii]; - xtmp = x[i].x; - ytmp = x[i].y; - ztmp = x[i].z; - itype = type[i]; - jlist = firstneigh[i]; - jnum = numneigh[i]; - - // This code line is required for ternary alloys. - if(itype != speciesA && itype != speciesB) continue; - - double x_i = rhoB[i] / rho[i]; // Concentration at atom i. - - for(jj = 0; jj < jnum; jj++) { - j = jlist[jj]; - j &= NEIGHMASK; - jtype = type[j]; - if(itype == jtype) continue; - - // This code line is required for ternary alloys. - if(jtype != speciesA && jtype != speciesB) continue; - - delx = xtmp - x[j].x; - dely = ytmp - x[j].y; - delz = ztmp - x[j].z; - rsq = delx*delx + dely*dely + delz*delz; - - if(rsq < cutforcesq) { - double r = sqrt(rsq); - const EAMTableIndex index = radiusToTableIndex(r); - - // The concentration independent part of the cross pair potential. - double Phi_AB = PhiOfR(index, itype, jtype, 1.0 / r); - - // Average concentration of two sites - double x_ij = 0.5 * (x_i + rhoB[j]/rho[j]); - - // Calculate derivative of h(x_ij) polynomial function. - double h_prime = evalHprime(x_ij); - - D_values_t[i] += h_prime * Phi_AB / (2.0 * rho[i] * rho[i]); - if(NEWTON_PAIR || j < nlocal) - D_values_t[j] += h_prime * Phi_AB / (2.0 * rho[j] * rho[j]); - } - } - } - - if (NEWTON_PAIR) { - thr->timer(Timer::PAIR); - data_reduce_thr(D_values, nall, nthreads, 1, tid); - - // wait until reduction is complete - sync_threads(); - -#if defined(_OPENMP) -#pragma omp master -#endif - { communicationStage = 3; - comm->reverse_comm_pair(this); } - - // wait until master thread is done with communication - sync_threads(); - - } else { - thr->timer(Timer::PAIR); - data_reduce_thr(D_values, nlocal, nthreads, 1, tid); - - // wait until reduction is complete - sync_threads(); - } - -#if defined(_OPENMP) -#pragma omp master -#endif - { communicationStage = 4; - comm->forward_comm_pair(this); } - - // wait until master thread is done with communication - sync_threads(); - } - - // Stage III - - // Compute force acting on each atom. - for (ii = iifrom; ii < iito; ii++) { - i = ilist[ii]; - xtmp = x[i].x; - ytmp = x[i].y; - ztmp = x[i].z; - itype = type[i]; - fxtmp = fytmp = fztmp = 0.0; - - jlist = firstneigh[i]; - jnum = numneigh[i]; - - // Concentration at site i - double x_i = -1.0; // The value -1 indicates: no concentration dependence for all interactions of atom i. - // It will be replaced by the concentration at site i if atom i is either A or B. - - double D_i, h_prime_i; - - // This if-clause is only required for ternary alloys. - if((itype == speciesA || itype == speciesB) && rho[i] != 0.0) { - - // Compute local concentration at site i. - x_i = rhoB[i]/rho[i]; - ASSERT(x_i >= 0 && x_i<=1.0); - - if(CDEAMVERSION == 1) { - // Calculate derivative of h(x_i) polynomial function. - h_prime_i = evalHprime(x_i); - D_i = D_values[i] * h_prime_i / (2.0 * rho[i] * rho[i]); - } else if(CDEAMVERSION == 2) { - D_i = D_values[i]; - } else { - ASSERT(false); - } - } - - for(jj = 0; jj < jnum; jj++) { - j = jlist[jj]; - j &= NEIGHMASK; - - delx = xtmp - x[j].x; - dely = ytmp - x[j].y; - delz = ztmp - x[j].z; - rsq = delx*delx + dely*dely + delz*delz; - - if(rsq < cutforcesq) { - jtype = type[j]; - double r = sqrt(rsq); - const EAMTableIndex index = radiusToTableIndex(r); - - // rhoip = derivative of (density at atom j due to atom i) - // rhojp = derivative of (density at atom i due to atom j) - // psip needs both fp[i] and fp[j] terms since r_ij appears in two - // terms of embed eng: Fi(sum rho_ij) and Fj(sum rho_ji) - // hence embed' = Fi(sum rho_ij) rhojp + Fj(sum rho_ji) rhoip - rhoip = RhoPrimeOfR(index, itype, jtype); - rhojp = RhoPrimeOfR(index, jtype, itype); - fpair = fp[i]*rhojp + fp[j]*rhoip; - recip = 1.0/r; - - double x_j = -1; // The value -1 indicates: no concentration dependence for this i-j pair - // because atom j is not of species A nor B. - - // This code line is required for ternary alloy. - if(jtype == speciesA || jtype == speciesB) { - ASSERT(rho[i] != 0.0); - ASSERT(rho[j] != 0.0); - - // Compute local concentration at site j. - x_j = rhoB[j]/rho[j]; - ASSERT(x_j >= 0 && x_j<=1.0); - - double D_j; - if(CDEAMVERSION == 1) { - // Calculate derivative of h(x_j) polynomial function. - double h_prime_j = evalHprime(x_j); - D_j = D_values[j] * h_prime_j / (2.0 * rho[j] * rho[j]); - } else if(CDEAMVERSION == 2) { - D_j = D_values[j]; - } else { - ASSERT(false); - } - double t2 = -rhoB[j]; - if(itype == speciesB) t2 += rho[j]; - fpair += D_j * rhoip * t2; - } - - // This if-clause is only required for a ternary alloy. - // Actually we don't need it at all because D_i should be zero anyway if - // atom i has no concentration dependent interactions (because it is not species A or B). - if(x_i != -1.0) { - double t1 = -rhoB[i]; - if(jtype == speciesB) t1 += rho[i]; - fpair += D_i * rhojp * t1; - } - - double phip; - double phi = PhiOfR(index, itype, jtype, recip, phip); - if(itype == jtype || x_i == -1.0 || x_j == -1.0) { - // Case of no concentration dependence. - fpair += phip; - } else { - // We have a concentration dependence for the i-j interaction. - double h; - if(CDEAMVERSION == 1) { - // Calculate h(x_i) polynomial function. - double h_i = evalH(x_i); - // Calculate h(x_j) polynomial function. - double h_j = evalH(x_j); - h = 0.5 * (h_i + h_j); - } else if(CDEAMVERSION == 2) { - // Average concentration. - double x_ij = 0.5 * (x_i + x_j); - // Calculate h(x_ij) polynomial function. - h = evalH(x_ij); - } else { - ASSERT(false); - } - fpair += h * phip; - phi *= h; - } - - // Divide by r_ij and negate to get forces from gradient. - fpair /= -r; - - fxtmp += delx*fpair; - fytmp += dely*fpair; - fztmp += delz*fpair; - if(NEWTON_PAIR || j < nlocal) { - f[j].x -= delx*fpair; - f[j].y -= dely*fpair; - f[j].z -= delz*fpair; - } - - if(EFLAG) evdwl = phi; - if(EVFLAG) ev_tally_thr(this,i,j,nlocal,NEWTON_PAIR,evdwl,0.0, - fpair,delx,dely,delz,thr); - } - } - f[i].x += fxtmp; - f[i].y += fytmp; - f[i].z += fztmp; - } -} - -/* ---------------------------------------------------------------------- */ - -double PairEAMCDOMP::memory_usage() -{ - double bytes = memory_usage_thr(); - bytes += PairEAMCD::memory_usage(); - - return bytes; -} diff --git a/src/USER-OMP/pair_eam_cd_omp.h b/src/USER-OMP/pair_eam_cd_omp.h deleted file mode 100644 index d46a5383f5..0000000000 --- a/src/USER-OMP/pair_eam_cd_omp.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - http://lammps.sandia.gov, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - Copyright (2003) Sandia Corporation. Under the terms of Contract - DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under - the GNU General Public License. - - See the README file in the top-level LAMMPS directory. -------------------------------------------------------------------------- */ - -/* ---------------------------------------------------------------------- - Contributing author: Axel Kohlmeyer (Temple U) -------------------------------------------------------------------------- */ - -#ifdef PAIR_CLASS - -PairStyle(eam/cd/omp,PairEAMCD_OneSiteOMP) -PairStyle(eam/cd/old/omp,PairEAMCD_TwoSiteOMP) - -#else - -#ifndef LMP_PAIR_EAM_CD_OMP_H -#define LMP_PAIR_EAM_CD_OMP_H - -#include "pair_eam_cd.h" -#include "thr_omp.h" - -namespace LAMMPS_NS { - -class PairEAMCDOMP : public PairEAMCD, public ThrOMP { - - public: - PairEAMCDOMP(class LAMMPS *, int); - - virtual void compute(int, int); - virtual double memory_usage(); - - private: - template - void eval(int iifrom, int iito, ThrData * const thr); -}; - - /// The one-site concentration formulation of CD-EAM. - class PairEAMCD_OneSiteOMP : public PairEAMCDOMP - { - public: - /// Constructor. - PairEAMCD_OneSiteOMP(class LAMMPS* lmp) : PairEAM(lmp), PairEAMCDOMP(lmp, 1) {} - }; - - /// The two-site concentration formulation of CD-EAM. - class PairEAMCD_TwoSiteOMP : public PairEAMCDOMP - { - public: - /// Constructor. - PairEAMCD_TwoSiteOMP(class LAMMPS* lmp) : PairEAM(lmp), PairEAMCDOMP(lmp, 2) {} - }; - -} - -#endif -#endif diff --git a/src/USER-OMP/pair_eam_fs_omp.cpp b/src/USER-OMP/pair_eam_fs_omp.cpp index d1014c5a14..e16f28cd31 100644 --- a/src/USER-OMP/pair_eam_fs_omp.cpp +++ b/src/USER-OMP/pair_eam_fs_omp.cpp @@ -25,11 +25,11 @@ #include "memory.h" #include "error.h" #include "utils.h" +#include "tokenizer.h" +#include "potential_file_reader.h" using namespace LAMMPS_NS; -#define MAXLINE 1024 - /* ---------------------------------------------------------------------- */ PairEAMFSOMP::PairEAMFSOMP(LAMMPS *lmp) : PairEAMOMP(lmp) @@ -117,99 +117,118 @@ void PairEAMFSOMP::read_file(char *filename) { Fs *file = fs; - // open potential file + // read potential file + if(comm->me == 0) { + PotentialFileReader reader(PairEAM::lmp, filename, "EAM"); - int me = comm->me; - FILE *fptr; - char line[MAXLINE]; + try { + char * line = nullptr; - if (me == 0) { - fptr = force->open_potential(filename); - if (fptr == NULL) { - char str[128]; - snprintf(str,128,"Cannot open EAM potential file %s",filename); - error->one(FLERR,str); + reader.skip_line(); + reader.skip_line(); + reader.skip_line(); + + // extract element names from nelements line + line = reader.next_line(1); + ValueTokenizer values(line); + file->nelements = values.next_int(); + + if (values.count() != file->nelements + 1) + error->one(FLERR,"Incorrect element names in EAM potential file"); + + file->elements = new char*[file->nelements]; + for (int i = 0; i < file->nelements; i++) { + const std::string word = values.next_string(); + const int n = word.length() + 1; + file->elements[i] = new char[n]; + strcpy(file->elements[i], word.c_str()); + } + + // + + line = reader.next_line(5); + values = ValueTokenizer(line); + file->nrho = values.next_int(); + file->drho = values.next_double(); + file->nr = values.next_int(); + file->dr = values.next_double(); + file->cut = values.next_double(); + + if ((file->nrho <= 0) || (file->nr <= 0) || (file->dr <= 0.0)) + error->one(FLERR,"Invalid EAM potential file"); + + memory->create(file->mass, file->nelements, "pair:mass"); + memory->create(file->frho, file->nelements, file->nrho + 1, "pair:frho"); + memory->create(file->rhor, file->nelements, file->nelements, file->nr + 1, "pair:rhor"); + memory->create(file->z2r, file->nelements, file->nelements, file->nr + 1, "pair:z2r"); + + for (int i = 0; i < file->nelements; i++) { + line = reader.next_line(2); + values = ValueTokenizer(line); + values.next_int(); // ignore + file->mass[i] = values.next_double(); + + reader.next_dvector(file->nrho, &file->frho[i][1]); + + for (int j = 0; j < file->nelements; j++) { + reader.next_dvector(file->nr, &file->rhor[i][j][1]); + } + } + + for (int i = 0; i < file->nelements; i++) { + for (int j = 0; j <= i; j++) { + reader.next_dvector(file->nr, &file->z2r[i][j][1]); + } + } + } catch (TokenizerException & e) { + error->one(FLERR, e.what()); } } - // read and broadcast header - // extract element names from nelements line + // broadcast potential information + MPI_Bcast(&file->nelements, 1, MPI_INT, 0, world); - int n; - if (me == 0) { - utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error); - utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error); - utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error); - utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error); - n = strlen(line) + 1; + MPI_Bcast(&file->nrho, 1, MPI_INT, 0, world); + MPI_Bcast(&file->drho, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->nr, 1, MPI_INT, 0, world); + MPI_Bcast(&file->dr, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->cut, 1, MPI_DOUBLE, 0, world); + + // allocate memory on other procs + if (comm->me != 0) { + file->elements = new char*[file->nelements]; + for (int i = 0; i < file->nelements; i++) file->elements[i] = nullptr; + memory->create(file->mass, file->nelements, "pair:mass"); + memory->create(file->frho, file->nelements, file->nrho + 1, "pair:frho"); + memory->create(file->rhor, file->nelements, file->nelements, file->nr + 1, "pair:rhor"); + memory->create(file->z2r, file->nelements, file->nelements, file->nr + 1, "pair:z2r"); } - MPI_Bcast(&n,1,MPI_INT,0,world); - MPI_Bcast(line,n,MPI_CHAR,0,world); - sscanf(line,"%d",&file->nelements); - int nwords = atom->count_words(line); - if (nwords != file->nelements + 1) - error->all(FLERR,"Incorrect element names in EAM potential file"); - - char **words = new char*[file->nelements+1]; - nwords = 0; - strtok(line," \t\n\r\f"); - while ((words[nwords++] = strtok(NULL," \t\n\r\f"))) continue; - - file->elements = new char*[file->nelements]; + // broadcast file->elements string array for (int i = 0; i < file->nelements; i++) { - n = strlen(words[i]) + 1; - file->elements[i] = new char[n]; - strcpy(file->elements[i],words[i]); - } - delete [] words; - - if (me == 0) { - utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error); - sscanf(line,"%d %lg %d %lg %lg", - &file->nrho,&file->drho,&file->nr,&file->dr,&file->cut); + int n; + if (comm->me == 0) n = strlen(file->elements[i]) + 1; + MPI_Bcast(&n, 1, MPI_INT, 0, world); + if (comm->me != 0) file->elements[i] = new char[n]; + MPI_Bcast(file->elements[i], n, MPI_CHAR, 0, world); } - MPI_Bcast(&file->nrho,1,MPI_INT,0,world); - MPI_Bcast(&file->drho,1,MPI_DOUBLE,0,world); - MPI_Bcast(&file->nr,1,MPI_INT,0,world); - MPI_Bcast(&file->dr,1,MPI_DOUBLE,0,world); - MPI_Bcast(&file->cut,1,MPI_DOUBLE,0,world); + // broadcast file->mass, frho, rhor + for (int i = 0; i < file->nelements; i++) { + MPI_Bcast(&file->mass[i], 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&file->frho[i][1], file->nrho, MPI_DOUBLE, 0, world); - file->mass = new double[file->nelements]; - memory->create(file->frho,file->nelements,file->nrho+1, - "pair:frho"); - memory->create(file->rhor,file->nelements,file->nelements, - file->nr+1,"pair:rhor"); - memory->create(file->z2r,file->nelements,file->nelements, - file->nr+1,"pair:z2r"); - - int i,j,tmp; - for (i = 0; i < file->nelements; i++) { - if (me == 0) { - utils::sfgets(FLERR,line,MAXLINE,fptr,filename,error); - sscanf(line,"%d %lg",&tmp,&file->mass[i]); - } - MPI_Bcast(&file->mass[i],1,MPI_DOUBLE,0,world); - - if (me == 0) grab(fptr,file->nrho,&file->frho[i][1]); - MPI_Bcast(&file->frho[i][1],file->nrho,MPI_DOUBLE,0,world); - - for (j = 0; j < file->nelements; j++) { - if (me == 0) grab(fptr,file->nr,&file->rhor[i][j][1]); - MPI_Bcast(&file->rhor[i][j][1],file->nr,MPI_DOUBLE,0,world); + for (int j = 0; j < file->nelements; j++) { + MPI_Bcast(&file->rhor[i][j][1], file->nr, MPI_DOUBLE, 0, world); } } - for (i = 0; i < file->nelements; i++) - for (j = 0; j <= i; j++) { - if (me == 0) grab(fptr,file->nr,&file->z2r[i][j][1]); - MPI_Bcast(&file->z2r[i][j][1],file->nr,MPI_DOUBLE,0,world); + // broadcast file->z2r + for (int i = 0; i < file->nelements; i++) { + for (int j = 0; j <= i; j++) { + MPI_Bcast(&file->z2r[i][j][1], file->nr, MPI_DOUBLE, 0, world); } - - // close the potential file - - if (me == 0) fclose(fptr); + } } /* ---------------------------------------------------------------------- diff --git a/src/USER-OMP/pair_tersoff_zbl_omp.cpp b/src/USER-OMP/pair_tersoff_zbl_omp.cpp index 096a42b1a8..0e9bc5c24a 100644 --- a/src/USER-OMP/pair_tersoff_zbl_omp.cpp +++ b/src/USER-OMP/pair_tersoff_zbl_omp.cpp @@ -30,6 +30,7 @@ #include "comm.h" #include "memory.h" #include "error.h" +#include "utils.h" #include "math_const.h" #include "math_special.h" @@ -88,7 +89,7 @@ void PairTersoffZBLOMP::read_file(char *file) memory->sfree(params); params = NULL; - nparams = 0; + nparams = maxparam = 0; // open file on proc 0 @@ -125,7 +126,7 @@ void PairTersoffZBLOMP::read_file(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -144,7 +145,7 @@ void PairTersoffZBLOMP::read_file(char *file) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) @@ -204,8 +205,7 @@ void PairTersoffZBLOMP::read_file(char *file) params[nparams].powermint = int(params[nparams].powerm); - if ( - params[nparams].c < 0.0 || + if (params[nparams].c < 0.0 || params[nparams].d < 0.0 || params[nparams].powern < 0.0 || params[nparams].beta < 0.0 || @@ -214,6 +214,7 @@ void PairTersoffZBLOMP::read_file(char *file) params[nparams].bigr < 0.0 || params[nparams].bigd < 0.0 || params[nparams].bigd > params[nparams].bigr || + params[nparams].lam1 < 0.0 || params[nparams].biga < 0.0 || params[nparams].powerm - params[nparams].powermint != 0.0 || (params[nparams].powermint != 3 && @@ -287,8 +288,8 @@ void PairTersoffZBLOMP::repulsive(Param *param, double rsq, double &fforce, 0.9423*0.5099*exp(-0.9423*r_ov_a) - 0.4029*0.2802*exp(-0.4029*r_ov_a) - 0.2016*0.02817*exp(-0.2016*r_ov_a)); - double fforce_ZBL = premult*-rsq* phi + premult/r*dphi; - double eng_ZBL = premult/r*phi; + double fforce_ZBL = premult*-phi/rsq + premult*dphi/r; + double eng_ZBL = premult*(1.0/r)*phi; // combine two parts with smoothing by Fermi-like function diff --git a/src/atom.cpp b/src/atom.cpp index 1ed28507ad..134def74a3 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -1031,56 +1031,6 @@ void Atom::bonus_check() "atoms with enabled body flags"); } -/* ---------------------------------------------------------------------- - count and return words in a single line - make copy of line before using strtok so as not to change line - trim anything from '#' onward -------------------------------------------------------------------------- */ - -int Atom::count_words(const char *line) -{ - int n = strlen(line) + 1; - char *copy; - memory->create(copy,n,"atom:copy"); - strcpy(copy,line); - - char *ptr; - if ((ptr = strchr(copy,'#'))) *ptr = '\0'; - - if (strtok(copy," \t\n\r\f") == NULL) { - memory->destroy(copy); - return 0; - } - n = 1; - while (strtok(NULL," \t\n\r\f")) n++; - - memory->destroy(copy); - return n; -} - -/* ---------------------------------------------------------------------- - count and return words in a single line using provided copy buf - make copy of line before using strtok so as not to change line - trim anything from '#' onward -------------------------------------------------------------------------- */ - -int Atom::count_words(const char *line, char *copy) -{ - strcpy(copy,line); - - char *ptr; - if ((ptr = strchr(copy,'#'))) *ptr = '\0'; - - if (strtok(copy," \t\n\r\f") == NULL) { - memory->destroy(copy); - return 0; - } - int n = 1; - while (strtok(NULL," \t\n\r\f")) n++; - - return n; -} - /* ---------------------------------------------------------------------- deallocate molecular topology arrays done before realloc with (possibly) new 2nd dimension set to @@ -1139,7 +1089,7 @@ void Atom::data_atoms(int n, char *buf, tagint id_offset, tagint mol_offset, next = strchr(buf,'\n'); *next = '\0'; - int nwords = count_words(buf); + int nwords = utils::count_words(buf); *next = '\n'; if (nwords != avec->size_data_atom && nwords != avec->size_data_atom + 3) @@ -1289,7 +1239,7 @@ void Atom::data_vels(int n, char *buf, tagint id_offset) next = strchr(buf,'\n'); *next = '\0'; - int nwords = count_words(buf); + int nwords = utils::count_words(buf); *next = '\n'; if (nwords != avec->size_data_vel) @@ -1641,7 +1591,7 @@ void Atom::data_bonus(int n, char *buf, AtomVec *avec_bonus, tagint id_offset) next = strchr(buf,'\n'); *next = '\0'; - int nwords = count_words(buf); + int nwords = utils::count_words(buf); *next = '\n'; if (nwords != avec_bonus->size_data_bonus) diff --git a/src/atom.h b/src/atom.h index c55821eea2..b94189e6e1 100644 --- a/src/atom.h +++ b/src/atom.h @@ -277,8 +277,6 @@ class Atom : protected Pointers { void bonus_check(); int parse_data(const char *); - int count_words(const char *); - int count_words(const char *, char *); void deallocate_topology(); diff --git a/src/atom_vec.cpp b/src/atom_vec.cpp index ef276bcf6a..fc9c3646cf 100644 --- a/src/atom_vec.cpp +++ b/src/atom_vec.cpp @@ -24,6 +24,7 @@ #include "memory.h" #include "error.h" #include "utils.h" +#include "tokenizer.h" using namespace LAMMPS_NS; using namespace MathConst; @@ -1834,7 +1835,6 @@ void AtomVec::pack_data(double **buf) void AtomVec::write_data(FILE *fp, int n, double **buf) { int i,j,m,nn,datatype,cols; - void *pdata; for (i = 0; i < n; i++) { fprintf(fp,TAGINT_FORMAT,(tagint) ubuf(buf[i][0]).i); @@ -1983,40 +1983,32 @@ void AtomVec::pack_vel(double **buf) void AtomVec::write_vel(FILE *fp, int n, double **buf) { int i,j,m,nn,datatype,cols; - void *pdata; for (i = 0; i < n; i++) { fprintf(fp,TAGINT_FORMAT,(tagint) ubuf(buf[i][0]).i); j = 1; for (nn = 1; nn < ndata_vel; nn++) { - pdata = mdata_vel.pdata[nn]; datatype = mdata_vel.datatype[nn]; cols = mdata_vel.cols[nn]; if (datatype == DOUBLE) { if (cols == 0) { - double *vec = *((double **) pdata); fprintf(fp," %-1.16e",buf[i][j++]); } else { - double **array = *((double ***) pdata); for (m = 0; m < cols; m++) fprintf(fp," %-1.16e",buf[i][j++]); } } else if (datatype == INT) { if (cols == 0) { - int *vec = *((int **) pdata); fprintf(fp," %d",(int) ubuf(buf[i][j++]).i); } else { - int **array = *((int ***) pdata); for (m = 0; m < cols; m++) fprintf(fp," %d",(int) ubuf(buf[i][j++]).i); } } else if (datatype == BIGINT) { if (cols == 0) { - bigint *vec = *((bigint **) pdata); fprintf(fp," " BIGINT_FORMAT,(bigint) ubuf(buf[i][j++]).i); } else { - bigint **array = *((bigint ***) pdata); for (m = 0; m < cols; m++) fprintf(fp," " BIGINT_FORMAT,(bigint) ubuf(buf[i][j++]).i); } @@ -2457,11 +2449,11 @@ int AtomVec::process_fields(char *str, const char *default_str, Method *method) } // tokenize words in both strings + Tokenizer words(str, " "); + Tokenizer def_words(default_str, " "); - char *copy1,*copy2; - char **words,**defwords; - int nfield = tokenize(str,words,copy1); - int ndef = tokenize((char *) default_str,defwords,copy2); + int nfield = words.count(); + int ndef = def_words.count(); // process fields one by one, add to index vector @@ -2472,14 +2464,15 @@ int AtomVec::process_fields(char *str, const char *default_str, Method *method) int match; for (int i = 0; i < nfield; i++) { + const char * field = words[i].c_str(); // find field in master Atom::peratom list for (match = 0; match < nperatom; match++) - if (strcmp(words[i],peratom[match].name) == 0) break; + if (strcmp(field, peratom[match].name) == 0) break; if (match == nperatom) { char str[128]; - sprintf(str,"Peratom field %s not recognized",words[i]); + sprintf(str,"Peratom field %s not recognized", field); error->all(FLERR,str); } index[i] = match; @@ -2489,56 +2482,25 @@ int AtomVec::process_fields(char *str, const char *default_str, Method *method) for (match = 0; match < i; match++) if (index[i] == index[match]) { char str[128]; - sprintf(str,"Peratom field %s is repeated",words[i]); + sprintf(str,"Peratom field %s is repeated", field); error->all(FLERR,str); } // error if field is in default str for (match = 0; match < ndef; match++) - if (strcmp(words[i],defwords[match]) == 0) { + if (strcmp(field, def_words[match].c_str()) == 0) { char str[128]; - sprintf(str,"Peratom field %s is a default",words[i]); + sprintf(str,"Peratom field %s is a default", field); error->all(FLERR,str); } } - delete [] copy1; - delete [] copy2; - delete [] words; - delete [] defwords; - method->index = index; return nfield; } -/* ---------------------------------------------------------------------- - tokenize str into white-space separated words - return nwords = number of words - return words = vector of ptrs to each word - also return copystr since words points into it, caller will delete copystr -------------------------------------------------------------------------- */ - -int AtomVec::tokenize(char *str, char **&words, char *©str) -{ - int n = strlen(str) + 1; - copystr = new char[n]; - strcpy(copystr,str); - - int nword = atom->count_words(copystr); - words = new char*[nword]; - - nword = 0; - char *word = strtok(copystr," "); - while (word) { - words[nword++] = word; - word = strtok(NULL," "); - } - - return nword; -} - /* ---------------------------------------------------------------------- create a method data structs for processing fields ------------------------------------------------------------------------- */ diff --git a/src/atom_vec.h b/src/atom_vec.h index 46a241becb..eaff9b888a 100644 --- a/src/atom_vec.h +++ b/src/atom_vec.h @@ -234,7 +234,6 @@ class AtomVec : protected Pointers { int grow_nmax_bonus(int); void setup_fields(); int process_fields(char *, const char *, Method *); - int tokenize(char *, char **&, char *&); void create_method(int, Method *); void init_method(Method *); void destroy_method(Method *); diff --git a/src/atom_vec_hybrid.cpp b/src/atom_vec_hybrid.cpp index 2f40e10fe3..7e599863c0 100644 --- a/src/atom_vec_hybrid.cpp +++ b/src/atom_vec_hybrid.cpp @@ -17,6 +17,7 @@ #include "comm.h" #include "memory.h" #include "error.h" +#include "tokenizer.h" using namespace LAMMPS_NS; @@ -513,15 +514,15 @@ char *AtomVecHybrid::merge_fields(int inum, char *root, // identify unique words in concatenated string - char *copystr; - char **words; - int nwords = tokenize(concat,words,copystr); + Tokenizer words(concat, " "); + int nwords = words.count(); + int *unique = new int[nwords]; for (int i = 0; i < nwords; i++) { unique[i] = 1; for (int j = 0; j < i; j++) - if (strcmp(words[i],words[j]) == 0) unique[i] = 0; + if (words[i] == words[j]) unique[i] = 0; } // construct a new deduped string @@ -531,7 +532,7 @@ char *AtomVecHybrid::merge_fields(int inum, char *root, for (int i = 0; i < nwords; i++) { if (!unique[i]) continue; - strcat(dedup,words[i]); + strcat(dedup,words[i].c_str()); if (i < nwords-1) strcat(dedup," "); } @@ -542,8 +543,6 @@ char *AtomVecHybrid::merge_fields(int inum, char *root, // clean up - delete [] copystr; - delete [] words; delete [] unique; // return final concatenated, deduped string diff --git a/src/fix_property_atom.cpp b/src/fix_property_atom.cpp index 555114e4f9..5fb17ca636 100644 --- a/src/fix_property_atom.cpp +++ b/src/fix_property_atom.cpp @@ -18,6 +18,7 @@ #include "comm.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; using namespace FixConst; @@ -217,7 +218,7 @@ void FixPropertyAtom::read_data_section(char *keyword, int n, char *buf, next = strchr(buf,'\n'); *next = '\0'; - int nwords = atom->count_words(buf); + int nwords = utils::count_words(buf); *next = '\n'; if (nwords != nvalue+1) { diff --git a/src/fix_tmd.cpp b/src/fix_tmd.cpp index 604660e7c4..182da8ecaa 100644 --- a/src/fix_tmd.cpp +++ b/src/fix_tmd.cpp @@ -447,12 +447,12 @@ void FixTMD::readfile(char *file) zprd = hi - lo; bufptr = next + 1; continue; - } else if (atom->count_words(bufptr) == 4) { + } else if (utils::count_words(bufptr) == 4) { if (xprd >= 0.0 || yprd >= 0.0 || zprd >= 0.0) error->all(FLERR,"Incorrect format in TMD target file"); imageflag = 0; firstline = 0; - } else if (atom->count_words(bufptr) == 7) { + } else if (utils::count_words(bufptr) == 7) { if (xprd < 0.0 || yprd < 0.0 || zprd < 0.0) error->all(FLERR,"Incorrect format in TMD target file"); imageflag = 1; diff --git a/src/math_extra.cpp b/src/math_extra.cpp index 797d210d0e..749736ef27 100644 --- a/src/math_extra.cpp +++ b/src/math_extra.cpp @@ -258,7 +258,7 @@ void no_squish_rotate(int k, double *p, double *q, double *inertia, // obtain phi, cosines and sines phi = p[0]*kq[0] + p[1]*kq[1] + p[2]*kq[2] + p[3]*kq[3]; - if (fabs(inertia[k-1]) < 1e-6) phi *= 0.0; + if (inertia[k-1] == 0.0) phi = 0.0; else phi /= 4.0 * inertia[k-1]; c_phi = cos(dt * phi); s_phi = sin(dt * phi); diff --git a/src/molecule.cpp b/src/molecule.cpp index 15b2385436..1f0a9e1601 100644 --- a/src/molecule.cpp +++ b/src/molecule.cpp @@ -25,6 +25,7 @@ #include "math_extra.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; @@ -1400,7 +1401,7 @@ void Molecule::body(int flag, int pflag, char *line) while (nword < nparam) { readline(line); - ncount = atom->count_words(line); + ncount = utils::count_words(line); if (ncount == 0) error->one(FLERR,"Too few values in body section of molecule file"); if (nword+ncount > nparam) diff --git a/src/pair_coul_streitz.cpp b/src/pair_coul_streitz.cpp index 628f6a6b36..4511b34c24 100644 --- a/src/pair_coul_streitz.cpp +++ b/src/pair_coul_streitz.cpp @@ -30,6 +30,7 @@ #include "math_const.h" #include "memory.h" #include "error.h" +#include "utils.h" using namespace LAMMPS_NS; using namespace MathConst; @@ -278,7 +279,7 @@ void PairCoulStreitz::read_file(char *file) // strip comment, skip line if blank if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); if (nwords == 0) continue; // concatenate additional lines until have params_per_line words @@ -297,7 +298,7 @@ void PairCoulStreitz::read_file(char *file) MPI_Bcast(&n,1,MPI_INT,0,world); MPI_Bcast(line,n,MPI_CHAR,0,world); if ((ptr = strchr(line,'#'))) *ptr = '\0'; - nwords = atom->count_words(line); + nwords = utils::count_words(line); } if (nwords != params_per_line) diff --git a/src/pair_hybrid.cpp b/src/pair_hybrid.cpp index bbaa311819..6e2cbf75d7 100644 --- a/src/pair_hybrid.cpp +++ b/src/pair_hybrid.cpp @@ -313,7 +313,7 @@ void PairHybrid::settings(int narg, char **arg) iarg = 0; nstyles = 0; while (iarg < narg) { - if (strncmp(arg[iarg],"hybrid",6) == 0) + if (utils::strmatch(arg[iarg],"^hybrid")) error->all(FLERR,"Pair style hybrid cannot have hybrid as an argument"); if (strcmp(arg[iarg],"none") == 0) error->all(FLERR,"Pair style hybrid cannot have none as an argument"); @@ -323,8 +323,14 @@ void PairHybrid::settings(int narg, char **arg) special_lj[nstyles] = special_coul[nstyles] = NULL; compute_tally[nstyles] = 1; + // determine list of arguments for pair style settings + // by looking for the next known pair style name. + jarg = iarg + 1; - while (jarg < narg && !force->pair_map->count(arg[jarg])) jarg++; + while ((jarg < narg) + && !force->pair_map->count(arg[jarg]) + && !lmp->match_style("pair",arg[jarg])) jarg++; + styles[nstyles]->settings(jarg-iarg-1,&arg[iarg+1]); iarg = jarg; nstyles++; diff --git a/src/potential_file_reader.cpp b/src/potential_file_reader.cpp new file mode 100644 index 0000000000..bf886c5f97 --- /dev/null +++ b/src/potential_file_reader.cpp @@ -0,0 +1,129 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing authors: Richard Berger (Temple U) +------------------------------------------------------------------------- */ + +#include "lammps.h" +#include "force.h" +#include "error.h" +#include "comm.h" +#include "potential_file_reader.h" +#include "utils.h" +#include "tokenizer.h" + +#include + +using namespace LAMMPS_NS; + +PotentialFileReader::PotentialFileReader(LAMMPS *lmp, + const std::string &filename, + const std::string &potential_name) : Pointers(lmp), filename(filename) { + if (comm->me != 0) { + error->one(FLERR, "PotentialFileReader should only be called by proc 0!"); + } + + fp = force->open_potential(filename.c_str()); + + if (fp == NULL) { + char str[128]; + snprintf(str, 128, "cannot open %s potential file %s", potential_name.c_str(), filename.c_str()); + error->one(FLERR, str); + } +} + +PotentialFileReader::~PotentialFileReader() { + fclose(fp); +} + +void PotentialFileReader::skip_line() { + char *ptr = fgets(line, MAXLINE, fp); + if (ptr == nullptr) { + // EOF + char str[128]; + snprintf(str, 128, "Missing line in %s potential file!", potential_name.c_str()); + error->one(FLERR, str); + } +} + +char *PotentialFileReader::next_line(int nparams) { + // concatenate lines until have nparams words + int n = 0; + int nwords = 0; + + char *ptr = fgets(line, MAXLINE, fp); + + if (ptr == nullptr) { + // EOF + return nullptr; + } + + // strip comment + if ((ptr = strchr(line, '#'))) *ptr = '\0'; + + nwords = utils::count_words(line); + + if (nwords > 0) { + n = strlen(line); + } + + while(nwords < nparams) { + char *ptr = fgets(&line[n], MAXLINE - n, fp); + + if (ptr == nullptr) { + // EOF + if (nwords > 0 && nwords < nparams) { + char str[128]; + snprintf(str, 128, "Incorrect format in %s potential file! %d/%d parameters", potential_name.c_str(), nwords, nparams); + error->one(FLERR, str); + } + + return nullptr; + } + + + // strip comment + if ((ptr = strchr(line, '#'))) *ptr = '\0'; + + nwords = utils::count_words(line); + + // skip line if blank + if (nwords > 0) { + n = strlen(line); + } + } + + return line; +} + +void PotentialFileReader::next_dvector(int n, double * list) { + int i = 0; + while (i < n) { + char *ptr = fgets(line, MAXLINE, fp); + + if (ptr == nullptr) { + // EOF + if (i < n) { + char str[128]; + snprintf(str, 128, "Incorrect format in %s potential file! %d/%d values", potential_name.c_str(), i, n); + error->one(FLERR, str); + } + } + + ValueTokenizer values(line); + while(values.has_next()) { + list[i++] = values.next_double(); + } + } +} diff --git a/src/potential_file_reader.h b/src/potential_file_reader.h new file mode 100644 index 0000000000..b18d3841c3 --- /dev/null +++ b/src/potential_file_reader.h @@ -0,0 +1,45 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing authors: Richard Berger (Temple U) +------------------------------------------------------------------------- */ + +#ifndef LMP_POTENTIAL_FILE_READER_H +#define LMP_POTENTIAL_FILE_READER_H + +#include + +#include "pointers.h" + +namespace LAMMPS_NS +{ + class PotentialFileReader : protected Pointers { + std::string potential_name; + std::string filename; + static const int MAXLINE = 1024; + char line[MAXLINE]; + FILE *fp; + + public: + PotentialFileReader(class LAMMPS *lmp, const std::string &filename, const std::string &potential_name); + ~PotentialFileReader(); + + void skip_line(); + char * next_line(int nparams); + void next_dvector(int n, double * list); + }; + +} // namespace LAMMPS_NS + +#endif diff --git a/src/read_data.cpp b/src/read_data.cpp index c9bf86fb2b..edeb6398b8 100644 --- a/src/read_data.cpp +++ b/src/read_data.cpp @@ -70,7 +70,6 @@ ReadData::ReadData(LAMMPS *lmp) : Pointers(lmp) { MPI_Comm_rank(world,&me); line = new char[MAXLINE]; - copy = new char[MAXLINE]; keyword = new char[MAXLINE]; style = new char[MAXLINE]; buffer = new char[CHUNK*MAXLINE]; @@ -96,7 +95,6 @@ ReadData::ReadData(LAMMPS *lmp) : Pointers(lmp) ReadData::~ReadData() { delete [] line; - delete [] copy; delete [] keyword; delete [] style; delete [] buffer; @@ -1736,7 +1734,7 @@ void ReadData::bodies(int firstpass, AtomVec *ptr) while (nword < ninteger) { eof = fgets(&buffer[m],MAXLINE,fp); if (eof == NULL) error->one(FLERR,"Unexpected end of data file"); - ncount = atom->count_words(&buffer[m],copy); + ncount = utils::count_words(&buffer[m]); if (ncount == 0) error->one(FLERR,"Too few values in body lines in data file"); nword += ncount; @@ -1750,7 +1748,7 @@ void ReadData::bodies(int firstpass, AtomVec *ptr) while (nword < ndouble) { eof = fgets(&buffer[m],MAXLINE,fp); if (eof == NULL) error->one(FLERR,"Unexpected end of data file"); - ncount = atom->count_words(&buffer[m],copy); + ncount = utils::count_words(&buffer[m]); if (ncount == 0) error->one(FLERR,"Too few values in body lines in data file"); nword += ncount; diff --git a/src/read_data.h b/src/read_data.h index aee54ef3ed..84c098635a 100644 --- a/src/read_data.h +++ b/src/read_data.h @@ -32,7 +32,7 @@ class ReadData : protected Pointers { private: int me,compressed; - char *line,*copy,*keyword,*buffer,*style; + char *line,*keyword,*buffer,*style; FILE *fp; char **arg; int narg,maxarg; diff --git a/src/reader_native.cpp b/src/reader_native.cpp index 26cb45a686..6cb8096d9c 100644 --- a/src/reader_native.cpp +++ b/src/reader_native.cpp @@ -162,7 +162,7 @@ bigint ReaderNative::read_header(double box[3][3], int &boxinfo, int &triclinic, char *labelline = &line[strlen("ITEM: ATOMS ")]; - nwords = atom->count_words(labelline); + nwords = utils::count_words(labelline); char **labels = new char*[nwords]; labels[0] = strtok(labelline," \t\n\r\f"); if (labels[0] == NULL) { diff --git a/src/thermo.cpp b/src/thermo.cpp index 3748ee77fe..73c915da4a 100644 --- a/src/thermo.cpp +++ b/src/thermo.cpp @@ -44,6 +44,7 @@ #include "memory.h" #include "error.h" #include "math_const.h" +#include "utils.h" using namespace LAMMPS_NS; using namespace MathConst; @@ -159,7 +160,7 @@ Thermo::Thermo(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) // allocate per-field memory // process line of keywords - nfield_initial = atom->count_words(line); + nfield_initial = utils::count_words(line); allocate(); parse_fields(line); diff --git a/src/tokenizer.cpp b/src/tokenizer.cpp new file mode 100644 index 0000000000..4e2bcae414 --- /dev/null +++ b/src/tokenizer.cpp @@ -0,0 +1,137 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing author: Richard Berger (Temple U) +------------------------------------------------------------------------- */ + +#include "tokenizer.h" +#include "utils.h" + +using namespace LAMMPS_NS; + +Tokenizer::Tokenizer(const std::string & str, const std::string & seperators) { + size_t end = -1; + + do { + size_t start = str.find_first_not_of(seperators, end + 1); + if(start == std::string::npos) break; + + end = str.find_first_of(seperators, start); + + if(end == std::string::npos) { + tokens.push_back(str.substr(start)); + } else { + tokens.push_back(str.substr(start, end-start)); + } + } while(end != std::string::npos); +} + +Tokenizer::iterator Tokenizer::begin() { + return tokens.begin(); +} + +Tokenizer::iterator Tokenizer::end() { + return tokens.end(); +} + +Tokenizer::const_iterator Tokenizer::cbegin() const { + return tokens.cbegin(); +} + +Tokenizer::const_iterator Tokenizer::cend() const { + return tokens.cend(); +} + +const std::string & Tokenizer::operator[](size_t index) { + return tokens[index]; +} + +const size_t Tokenizer::count() const { + return tokens.size(); +} + + +ValueTokenizer::ValueTokenizer(const std::string & str, const std::string & seperators) : tokens(str, seperators) { + current = tokens.begin(); +} + +bool ValueTokenizer::has_next() const { + return current != tokens.cend(); +} + +std::string ValueTokenizer::next_string() { + if (has_next()) { + std::string value = *current; + ++current; + return value; + } + return ""; +} + +int ValueTokenizer::next_int() { + if (has_next()) { + if(!utils::is_integer(*current)) { + throw InvalidIntegerException(*current); + } + int value = atoi(current->c_str()); + ++current; + return value; + } + return 0; +} + +bigint ValueTokenizer::next_bigint() { + if (has_next()) { + if(!utils::is_integer(*current)) { + throw InvalidIntegerException(*current); + } + bigint value = ATOBIGINT(current->c_str()); + ++current; + return value; + } + return 0; +} + +tagint ValueTokenizer::next_tagint() { + if (current != tokens.end()) { + if(!utils::is_integer(*current)) { + throw InvalidIntegerException(*current); + } + tagint value = ATOTAGINT(current->c_str()); + ++current; + return value; + } + return 0; +} + +double ValueTokenizer::next_double() { + if (current != tokens.end()) { + if(!utils::is_double(*current)) { + throw InvalidFloatException(*current); + } + + double value = atof(current->c_str()); + ++current; + return value; + } + return 0.0; +} + +void ValueTokenizer::skip(int ntokens) { + current = std::next(current, ntokens); +} + +const size_t ValueTokenizer::count() const { + return tokens.count(); +} diff --git a/src/tokenizer.h b/src/tokenizer.h new file mode 100644 index 0000000000..5c0afe7c8d --- /dev/null +++ b/src/tokenizer.h @@ -0,0 +1,92 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + http://lammps.sandia.gov, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing author: Richard Berger (Temple U) +------------------------------------------------------------------------- */ + +#ifndef LMP_TOKENIZER_H +#define LMP_TOKENIZER_H + +#include +#include +#include "lmptype.h" +#include + +namespace LAMMPS_NS { + +class Tokenizer { + std::vector tokens; +public: + typedef std::vector::iterator iterator; + typedef std::vector::const_iterator const_iterator; + + Tokenizer(const std::string & str, const std::string & seperators = " \t\r\n\f"); + + iterator begin(); + iterator end(); + const_iterator cbegin() const; + const_iterator cend() const; + + const std::string & operator[](size_t index); + const size_t count() const; +}; + +class TokenizerException : public std::exception { + std::string message; +public: + TokenizerException(const std::string & msg, const std::string & token) : message(msg + ": '" + token + "'") { + } + + ~TokenizerException() throw() { + } + + virtual const char * what() const throw() { + return message.c_str(); + } +}; + +class InvalidIntegerException : public TokenizerException { +public: + InvalidIntegerException(const std::string & token) : TokenizerException("Not a valid integer number", token) { + } +}; + +class InvalidFloatException : public TokenizerException { +public: + InvalidFloatException(const std::string & token) : TokenizerException("Not a valid floating-point number", token) { + } +}; + +class ValueTokenizer { + Tokenizer tokens; + Tokenizer::const_iterator current; +public: + ValueTokenizer(const std::string & str, const std::string & seperators = " \t\r\n\f"); + + std::string next_string(); + tagint next_tagint(); + bigint next_bigint(); + int next_int(); + double next_double(); + + bool has_next() const; + void skip(int ntokens); + + const size_t count() const; +}; + + +} + +#endif diff --git a/src/utils.cpp b/src/utils.cpp index b28bb50e69..36675f2bd0 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -16,6 +16,7 @@ #include #include "lammps.h" #include "error.h" +#include "tokenizer.h" #include "fmt/format.h" #if defined(__linux__) @@ -341,6 +342,60 @@ tagint utils::tnumeric(const char *file, int line, const char *str, return ATOTAGINT(str); } +/* ---------------------------------------------------------------------- + Return string without trailing # comment +------------------------------------------------------------------------- */ + +std::string utils::trim_comment(const std::string & line) { + auto end = line.find_first_of("#"); + if (end != std::string::npos) { + return line.substr(0, end); + } + return std::string(line); +} + +/* ---------------------------------------------------------------------- + Trim comment from string and return number of words +------------------------------------------------------------------------- */ + +size_t utils::count_words(const std::string & text, const std::string & seperators) { + Tokenizer words(utils::trim_comment(text), seperators); + return words.count(); +} + +/* ---------------------------------------------------------------------- + Return whether string is a valid integer number +------------------------------------------------------------------------- */ + +bool utils::is_integer(const std::string & str) { + if (str.size() == 0) { + return false; + } + + for (auto c : str) { + if (isdigit(c) || c == '-' || c == '+') continue; + return false; + } + return true; +} + +/* ---------------------------------------------------------------------- + Return whether string is a valid floating-point number +------------------------------------------------------------------------- */ + +bool utils::is_double(const std::string & str) { + if (str.size() == 0) { + return false; + } + + for (auto c : str) { + if (isdigit(c)) continue; + if (c == '-' || c == '+' || c == '.') continue; + if (c == 'e' || c == 'E') continue; + return false; + } + return true; +} /* ------------------------------------------------------------------ */ @@ -683,4 +738,5 @@ extern "C" { return 0; } + } diff --git a/src/utils.h b/src/utils.h index 9f9b5fbf0c..37991648a6 100644 --- a/src/utils.h +++ b/src/utils.h @@ -133,6 +133,36 @@ namespace LAMMPS_NS { */ tagint tnumeric(const char *file, int line, const char *str, bool do_abort, LAMMPS *lmp); + + + /** + * \brief Trim anything from '#' onward + * \param line string that should be trimmed + * \return new string without comment (string) + */ + std::string trim_comment(const std::string & line); + + /** + * \brief Count words in a single line, trim anything from '#' onward + * \param text string that should be trimmed and searched + * \param seperators string containing characters that will be treated as whitespace + * \return number of words found + */ + size_t count_words(const std::string & text, const std::string & seperators = " \t\r\n\f"); + + /** + * \brief Check if string can be converted to valid integer + * \param text string that should be checked + * \return true, if string contains valid integer, false otherwise + */ + bool is_integer(const std::string & str); + + /** + * \brief Check if string can be converted to valid floating-point number + * \param text string that should be checked + * \return true, if string contains valid floating-point number, false otherwise + */ + bool is_double(const std::string & str); } } diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt index 2fb6500a9f..531e943f6c 100644 --- a/unittest/CMakeLists.txt +++ b/unittest/CMakeLists.txt @@ -1,3 +1,7 @@ include(GTest) add_subdirectory(force-styles) + +add_subdirectory(utils) + +add_subdirectory(formats) diff --git a/unittest/force-styles/CMakeLists.txt b/unittest/force-styles/CMakeLists.txt index e3ca515d09..1cb40038a7 100644 --- a/unittest/force-styles/CMakeLists.txt +++ b/unittest/force-styles/CMakeLists.txt @@ -8,7 +8,12 @@ endif() set(TEST_INPUT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/tests) add_library(style_tests STATIC yaml_writer.cpp error_stats.cpp test_config_reader.cpp test_main.cpp) target_compile_definitions(style_tests PRIVATE TEST_INPUT_FOLDER=${TEST_INPUT_FOLDER}) -target_link_libraries(style_tests PUBLIC GTest::GTest GTest::GMock MPI::MPI_CXX Yaml::Yaml) +target_link_libraries(style_tests PUBLIC GTest::GTest GTest::GMock Yaml::Yaml) +if(BUILD_MPI) + target_link_libraries(style_tests PUBLIC MPI::MPI_CXX) +else() + target_link_libraries(style_tests PUBLIC mpi_stubs) +endif() # pair style tester add_executable(pair_style pair_style.cpp) @@ -22,7 +27,7 @@ foreach(TEST ${MOL_PAIR_TESTS}) WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) endforeach() -# tests for atomic systems and related pair styles +# tests for metal-like atomic systems and related pair styles file(GLOB ATOMIC_PAIR_TESTS LIST_DIRECTORIES false ${TEST_INPUT_FOLDER}/atomic-pair-*.yaml) foreach(TEST ${ATOMIC_PAIR_TESTS}) string(REGEX REPLACE "^.*atomic-pair-(.*)\.yaml" "AtomicPairStyle:\\1" TNAME ${TEST}) @@ -31,6 +36,15 @@ foreach(TEST ${ATOMIC_PAIR_TESTS}) set_tests_properties(${TNAME} PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR}") endforeach() +# tests for Si-like manybody systems and related pair styles +file(GLOB MANYBODY_PAIR_TESTS LIST_DIRECTORIES false ${TEST_INPUT_FOLDER}/manybody-pair-*.yaml) +foreach(TEST ${MANYBODY_PAIR_TESTS}) + string(REGEX REPLACE "^.*manybody-pair-(.*)\.yaml" "ManybodyPairStyle:\\1" TNAME ${TEST}) + add_test(NAME ${TNAME} COMMAND pair_style ${TEST} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + set_tests_properties(${TNAME} PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR}") +endforeach() + # bond style tester add_executable(bond_style bond_style.cpp) target_link_libraries(bond_style PRIVATE lammps style_tests) diff --git a/unittest/force-styles/angle_style.cpp b/unittest/force-styles/angle_style.cpp index 59ca6a1c5a..e7568651af 100644 --- a/unittest/force-styles/angle_style.cpp +++ b/unittest/force-styles/angle_style.cpp @@ -207,15 +207,12 @@ void data_lammps(LAMMPS *lmp, const TestConfig &cfg) for (auto& angle_coeff : cfg.angle_coeff) { command("angle_coeff " + angle_coeff); } - for (auto& post_command : cfg.post_commands) { command(post_command); } - command("run 0 post no"); } - // re-generate yaml file with current settings. void generate_yaml_file(const char *outfile, const TestConfig &config) @@ -288,6 +285,14 @@ void generate_yaml_file(const char *outfile, const TestConfig &config) } writer.emit_block("angle_coeff", block); + // equilibrium angle + std::stringstream eqstr; + eqstr << lmp->force->angle->equilibrium_angle(1); + for (std::size_t i=1; i < config.angle_coeff.size(); ++i) { + eqstr << " " << lmp->force->angle->equilibrium_angle(i+1); + } + writer.emit("equilibrium", eqstr.str()); + // extract block.clear(); std::stringstream outstr; @@ -445,67 +450,71 @@ TEST(AngleStyle, plain) { lmp = init_lammps(argc,argv,test_config,false); if (!verbose) ::testing::internal::GetCapturedStdout(); - f=lmp->atom->f; - tag=lmp->atom->tag; - stats.reset(); - for (int i=0; i < nlocal; ++i) { - EXPECT_FP_LE_WITH_EPS(f[i][0], f_ref[tag[i]].x, epsilon); - EXPECT_FP_LE_WITH_EPS(f[i][1], f_ref[tag[i]].y, epsilon); - EXPECT_FP_LE_WITH_EPS(f[i][2], f_ref[tag[i]].z, epsilon); + // skip over these tests if newton bond is forced to be on + if (lmp->force->newton_bond == 0) { + + f=lmp->atom->f; + tag=lmp->atom->tag; + stats.reset(); + for (int i=0; i < nlocal; ++i) { + EXPECT_FP_LE_WITH_EPS(f[i][0], f_ref[tag[i]].x, epsilon); + EXPECT_FP_LE_WITH_EPS(f[i][1], f_ref[tag[i]].y, epsilon); + EXPECT_FP_LE_WITH_EPS(f[i][2], f_ref[tag[i]].z, epsilon); + } + if (print_stats) + std::cerr << "init_forces stats, newton off:" << stats << std::endl; + + angle = lmp->force->angle; + stress = angle->virial; + stats.reset(); + EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 2*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 2*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 2*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 2*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 2*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 2*epsilon); + if (print_stats) + std::cerr << "init_stress stats, newton off:" << stats << std::endl; + + stats.reset(); + EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.init_energy, epsilon); + if (print_stats) + std::cerr << "init_energy stats, newton off:" << stats << std::endl; + + if (!verbose) ::testing::internal::CaptureStdout(); + run_lammps(lmp); + if (!verbose) ::testing::internal::GetCapturedStdout(); + + f = lmp->atom->f; + stress = angle->virial; + stats.reset(); + for (int i=0; i < nlocal; ++i) { + EXPECT_FP_LE_WITH_EPS(f[i][0], f_run[tag[i]].x, 10*epsilon); + EXPECT_FP_LE_WITH_EPS(f[i][1], f_run[tag[i]].y, 10*epsilon); + EXPECT_FP_LE_WITH_EPS(f[i][2], f_run[tag[i]].z, 10*epsilon); + } + if (print_stats) + std::cerr << "run_forces stats, newton off:" << stats << std::endl; + + stress = angle->virial; + stats.reset(); + EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, epsilon); + EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, epsilon); + EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, epsilon); + EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, epsilon); + EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, epsilon); + EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, epsilon); + if (print_stats) + std::cerr << "run_stress stats, newton off:" << stats << std::endl; + + stats.reset(); + id = lmp->modify->find_compute("sum"); + energy = lmp->modify->compute[id]->compute_scalar(); + EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.run_energy, epsilon); + EXPECT_FP_LE_WITH_EPS(angle->energy, energy, epsilon); + if (print_stats) + std::cerr << "run_energy stats, newton off:" << stats << std::endl; } - if (print_stats) - std::cerr << "init_forces stats, newton off:" << stats << std::endl; - - angle = lmp->force->angle; - stress = angle->virial; - stats.reset(); - EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 2*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 2*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 2*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 2*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 2*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 2*epsilon); - if (print_stats) - std::cerr << "init_stress stats, newton off:" << stats << std::endl; - - stats.reset(); - EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.init_energy, epsilon); - if (print_stats) - std::cerr << "init_energy stats, newton off:" << stats << std::endl; - - if (!verbose) ::testing::internal::CaptureStdout(); - run_lammps(lmp); - if (!verbose) ::testing::internal::GetCapturedStdout(); - - f = lmp->atom->f; - stress = angle->virial; - stats.reset(); - for (int i=0; i < nlocal; ++i) { - EXPECT_FP_LE_WITH_EPS(f[i][0], f_run[tag[i]].x, 10*epsilon); - EXPECT_FP_LE_WITH_EPS(f[i][1], f_run[tag[i]].y, 10*epsilon); - EXPECT_FP_LE_WITH_EPS(f[i][2], f_run[tag[i]].z, 10*epsilon); - } - if (print_stats) - std::cerr << "run_forces stats, newton off:" << stats << std::endl; - - stress = angle->virial; - stats.reset(); - EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, epsilon); - EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, epsilon); - EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, epsilon); - EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, epsilon); - EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, epsilon); - EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, epsilon); - if (print_stats) - std::cerr << "run_stress stats, newton off:" << stats << std::endl; - - stats.reset(); - id = lmp->modify->find_compute("sum"); - energy = lmp->modify->compute[id]->compute_scalar(); - EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.run_energy, epsilon); - EXPECT_FP_LE_WITH_EPS(angle->energy, energy, epsilon); - if (print_stats) - std::cerr << "run_energy stats, newton off:" << stats << std::endl; if (!verbose) ::testing::internal::CaptureStdout(); restart_lammps(lmp, test_config); @@ -588,6 +597,7 @@ TEST(AngleStyle, omp) { ::testing::internal::CaptureStdout(); LAMMPS *lmp = init_lammps(argc,argv,test_config,true); std::string output = ::testing::internal::GetCapturedStdout(); + if (verbose) std::cout << output; if (!lmp) { std::cerr << "One or more prerequisite styles with /omp suffix\n" @@ -683,72 +693,225 @@ TEST(AngleStyle, omp) { lmp = init_lammps(argc,argv,test_config,false); if (!verbose) ::testing::internal::GetCapturedStdout(); - f=lmp->atom->f; - tag=lmp->atom->tag; - stats.reset(); - for (int i=0; i < nlocal; ++i) { - EXPECT_FP_LE_WITH_EPS(f[i][0], f_ref[tag[i]].x, epsilon); - EXPECT_FP_LE_WITH_EPS(f[i][1], f_ref[tag[i]].y, epsilon); - EXPECT_FP_LE_WITH_EPS(f[i][2], f_ref[tag[i]].z, epsilon); + // skip over these tests if newton bond is forced to be on + if (lmp->force->newton_bond == 0) { + + f=lmp->atom->f; + tag=lmp->atom->tag; + stats.reset(); + for (int i=0; i < nlocal; ++i) { + EXPECT_FP_LE_WITH_EPS(f[i][0], f_ref[tag[i]].x, epsilon); + EXPECT_FP_LE_WITH_EPS(f[i][1], f_ref[tag[i]].y, epsilon); + EXPECT_FP_LE_WITH_EPS(f[i][2], f_ref[tag[i]].z, epsilon); + } + if (print_stats) + std::cerr << "init_forces stats, newton off:" << stats << std::endl; + + angle = lmp->force->angle; + stress = angle->virial; + stats.reset(); + EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 10*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 10*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 10*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 10*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 10*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 10*epsilon); + if (print_stats) + std::cerr << "init_stress stats, newton off:" << stats << std::endl; + + stats.reset(); + EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.init_energy, epsilon); + if (print_stats) + std::cerr << "init_energy stats, newton off:" << stats << std::endl; + + if (!verbose) ::testing::internal::CaptureStdout(); + run_lammps(lmp); + if (!verbose) ::testing::internal::GetCapturedStdout(); + + f = lmp->atom->f; + stats.reset(); + for (int i=0; i < nlocal; ++i) { + EXPECT_FP_LE_WITH_EPS(f[i][0], f_run[tag[i]].x, 10*epsilon); + EXPECT_FP_LE_WITH_EPS(f[i][1], f_run[tag[i]].y, 10*epsilon); + EXPECT_FP_LE_WITH_EPS(f[i][2], f_run[tag[i]].z, 10*epsilon); + } + if (print_stats) + std::cerr << "run_forces stats, newton off:" << stats << std::endl; + + stress = angle->virial; + stats.reset(); + EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, 10*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, 10*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, 10*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 10*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 10*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 10*epsilon); + if (print_stats) + std::cerr << "run_stress stats, newton off:" << stats << std::endl; + + stats.reset(); + id = lmp->modify->find_compute("sum"); + energy = lmp->modify->compute[id]->compute_scalar(); + EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.run_energy, epsilon); + // TODO: this is currently broken for USER-OMP with angle style hybrid + // needs to be fixed in the main code somewhere. Not sure where, though. + if (test_config.angle_style.substr(0,6) != "hybrid") + EXPECT_FP_LE_WITH_EPS(angle->energy, energy, epsilon); + if (print_stats) + std::cerr << "run_energy stats, newton off:" << stats << std::endl; } - if (print_stats) - std::cerr << "init_forces stats, newton off:" << stats << std::endl; - - angle = lmp->force->angle; - stress = angle->virial; - stats.reset(); - EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 10*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 10*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 10*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 10*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 10*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 10*epsilon); - if (print_stats) - std::cerr << "init_stress stats, newton off:" << stats << std::endl; - - stats.reset(); - EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.init_energy, epsilon); - if (print_stats) - std::cerr << "init_energy stats, newton off:" << stats << std::endl; - - if (!verbose) ::testing::internal::CaptureStdout(); - run_lammps(lmp); - if (!verbose) ::testing::internal::GetCapturedStdout(); - - f = lmp->atom->f; - stats.reset(); - for (int i=0; i < nlocal; ++i) { - EXPECT_FP_LE_WITH_EPS(f[i][0], f_run[tag[i]].x, 10*epsilon); - EXPECT_FP_LE_WITH_EPS(f[i][1], f_run[tag[i]].y, 10*epsilon); - EXPECT_FP_LE_WITH_EPS(f[i][2], f_run[tag[i]].z, 10*epsilon); - } - if (print_stats) - std::cerr << "run_forces stats, newton off:" << stats << std::endl; - - stress = angle->virial; - stats.reset(); - EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, 10*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, 10*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, 10*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 10*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 10*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 10*epsilon); - if (print_stats) - std::cerr << "run_stress stats, newton off:" << stats << std::endl; - - stats.reset(); - id = lmp->modify->find_compute("sum"); - energy = lmp->modify->compute[id]->compute_scalar(); - EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.run_energy, epsilon); - // TODO: this is currently broken for USER-OMP with angle style hybrid - // needs to be fixed in the main code somewhere. Not sure where, though. - if (test_config.angle_style.substr(0,6) != "hybrid") - EXPECT_FP_LE_WITH_EPS(angle->energy, energy, epsilon); - if (print_stats) - std::cerr << "run_energy stats, newton off:" << stats << std::endl; if (!verbose) ::testing::internal::CaptureStdout(); cleanup_lammps(lmp,test_config); if (!verbose) ::testing::internal::GetCapturedStdout(); }; +TEST(AngleStyle, single) { + const char *args[] = {"AngleStyle", "-log", "none", "-echo", "screen", "-nocite" }; + char **argv = (char **)args; + int argc = sizeof(args)/sizeof(char *); + + // create a LAMMPS instance with standard settings to detect the number of atom types + if (!verbose) ::testing::internal::CaptureStdout(); + LAMMPS *lmp = init_lammps(argc,argv,test_config); + if (!verbose) ::testing::internal::GetCapturedStdout(); + + if (!lmp) { + std::cerr << "One or more prerequisite styles are not available " + "in this LAMMPS configuration:\n"; + for (auto& prerequisite : test_config.prerequisites) { + std::cerr << prerequisite.first << "_style " + << prerequisite.second << "\n"; + } + GTEST_SKIP(); + } + + // gather some information and skip if unsupported + int nangletypes = lmp->atom->nangletypes; + int molecular = lmp->atom->molecular; + if (molecular != 1) { + std::cerr << "Only simple molecular atom styles are supported\n"; + if (!verbose) ::testing::internal::CaptureStdout(); + cleanup_lammps(lmp,test_config); + if (!verbose) ::testing::internal::GetCapturedStdout(); + GTEST_SKIP(); + } + + // utility lambda to improve readability + auto command = [&](const std::string & line) { + lmp->input->one(line.c_str()); + }; + + // now start over + if (!verbose) ::testing::internal::CaptureStdout(); + command("clear"); + command("variable newton_bond delete"); + command("variable newton_bond index on"); + + command("variable input_dir index " + INPUT_FOLDER); + + for (auto& pre_command : test_config.pre_commands) { + command(pre_command); + } + + command("atom_style molecular"); + command("units ${units}"); + command("boundary p p p"); + command("newton ${newton_pair} ${newton_bond}"); + command("special_bonds lj/coul " + "${bond_factor} ${angle_factor} ${dihedral_factor}"); + + command("atom_modify map array"); + command("region box block -10.0 10.0 -10.0 10.0 -10.0 10.0 units box"); + + char buf[10]; + std::string cmd("create_box 1 box"); + cmd += " angle/types "; + snprintf(buf,10,"%d",nangletypes); + cmd += buf; + cmd += " extra/angle/per/atom 2"; + cmd += " extra/special/per/atom 2"; + command(cmd); + + command("pair_style zero 8.0"); + command("pair_coeff * *"); + + command("angle_style " + test_config.angle_style); + Angle *angle = lmp->force->angle; + + for (auto& angle_coeff : test_config.angle_coeff) { + command("angle_coeff " + angle_coeff); + } + + // create (only) three atoms and one angle + command("mass * 1.0"); + command("create_atoms 1 single 5.0 -0.75 0.4 units box"); + command("create_atoms 1 single 5.5 0.25 -0.1 units box"); + command("create_atoms 1 single 5.0 0.75 0.4 units box"); + command("create_bonds single/angle 1 1 2 3"); + + for (auto& post_command : test_config.post_commands) { + command(post_command); + } + + command("run 0 post no"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + + int idx1 = lmp->atom->map(1); + int idx2 = lmp->atom->map(2); + int idx3 = lmp->atom->map(3); + double epsilon = test_config.epsilon; + double eangle[4], esingle[4]; + + eangle[0] = angle->energy; + esingle[0] = angle->single(1, idx1, idx2, idx3); + + if (!verbose) ::testing::internal::CaptureStdout(); + command("displace_atoms all random 0.5 0.5 0.5 23456"); + command("run 0 post no"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + + idx1 = lmp->atom->map(1); + idx2 = lmp->atom->map(2); + idx3 = lmp->atom->map(3); + eangle[1] = angle->energy; + esingle[1] = angle->single(1, idx1, idx2, idx3); + + if (!verbose) ::testing::internal::CaptureStdout(); + command("displace_atoms all random 0.5 0.5 0.5 456963"); + command("run 0 post no"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + + idx1 = lmp->atom->map(1); + idx2 = lmp->atom->map(2); + idx3 = lmp->atom->map(3); + eangle[2] = angle->energy; + esingle[2] = angle->single(1, idx1, idx2, idx3); + + if (!verbose) ::testing::internal::CaptureStdout(); + command("displace_atoms all random 0.5 0.5 0.5 9726532"); + command("run 0 post no"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + + idx1 = lmp->atom->map(1); + idx2 = lmp->atom->map(2); + idx3 = lmp->atom->map(3); + eangle[3] = angle->energy; + esingle[3] = angle->single(1, idx1, idx2, idx3); + + ErrorStats stats; + EXPECT_FP_LE_WITH_EPS(eangle[0], esingle[0], epsilon); + EXPECT_FP_LE_WITH_EPS(eangle[1], esingle[1], epsilon); + EXPECT_FP_LE_WITH_EPS(eangle[2], esingle[2], epsilon); + EXPECT_FP_LE_WITH_EPS(eangle[3], esingle[3], epsilon); + if (print_stats) + std::cerr << "single_energy stats:" << stats << std::endl; + + int i = 0; + for (auto &dist : test_config.equilibrium) + EXPECT_NEAR(dist,angle->equilibrium_angle(++i),0.00001); + + if (!verbose) ::testing::internal::CaptureStdout(); + cleanup_lammps(lmp,test_config); + if (!verbose) ::testing::internal::GetCapturedStdout(); +} diff --git a/unittest/force-styles/bond_style.cpp b/unittest/force-styles/bond_style.cpp index 07e44a096e..4b3cfe9a58 100644 --- a/unittest/force-styles/bond_style.cpp +++ b/unittest/force-styles/bond_style.cpp @@ -74,7 +74,7 @@ LAMMPS *init_lammps(int argc, char **argv, // check if prerequisite styles are available Info *info = new Info(lmp); int nfail = 0; - for (auto prerequisite : cfg.prerequisites) { + for (auto& prerequisite : cfg.prerequisites) { std::string style = prerequisite.second; // this is a test for bond styles, so if the suffixed @@ -207,11 +207,9 @@ void data_lammps(LAMMPS *lmp, const TestConfig &cfg) for (auto& bond_coeff : cfg.bond_coeff) { command("bond_coeff " + bond_coeff); } - for (auto& post_command : cfg.post_commands) { command(post_command); } - command("run 0 post no"); } @@ -227,7 +225,7 @@ void generate_yaml_file(const char *outfile, const TestConfig &config) if (!lmp) { std::cerr << "One or more prerequisite styles are not available " "in this LAMMPS configuration:\n"; - for (auto prerequisite : config.prerequisites) { + for (auto& prerequisite : config.prerequisites) { std::cerr << prerequisite.first << "_style " << prerequisite.second << "\n"; } @@ -255,21 +253,21 @@ void generate_yaml_file(const char *outfile, const TestConfig &config) // prerequisites block.clear(); - for (auto prerequisite : config.prerequisites) { + for (auto& prerequisite : config.prerequisites) { block += prerequisite.first + " " + prerequisite.second + "\n"; } writer.emit_block("prerequisites", block); // pre_commands block.clear(); - for (auto command : config.pre_commands) { + for (auto& command : config.pre_commands) { block += command + "\n"; } writer.emit_block("pre_commands", block); // post_commands block.clear(); - for (auto command : config.post_commands) { + for (auto& command : config.post_commands) { block += command + "\n"; } writer.emit_block("post_commands", block); @@ -282,15 +280,23 @@ void generate_yaml_file(const char *outfile, const TestConfig &config) // bond_coeff block.clear(); - for (auto bond_coeff : config.bond_coeff) { + for (auto& bond_coeff : config.bond_coeff) { block += bond_coeff + "\n"; } writer.emit_block("bond_coeff", block); + // equilibrium distance + std::stringstream eqstr; + eqstr << lmp->force->bond->equilibrium_distance(1); + for (std::size_t i=1; i < config.bond_coeff.size(); ++i) { + eqstr << " " << lmp->force->bond->equilibrium_distance(i+1); + } + writer.emit("equilibrium", eqstr.str()); + // extract block.clear(); std::stringstream outstr; - for (auto data : config.extract) { + for (auto& data : config.extract) { outstr << data.first << " " << data.second << std::endl; } writer.emit_block("extract", outstr.str()); @@ -357,7 +363,7 @@ TEST(BondStyle, plain) { if (!lmp) { std::cerr << "One or more prerequisite styles are not available " "in this LAMMPS configuration:\n"; - for (auto prerequisite : test_config.prerequisites) { + for (auto& prerequisite : test_config.prerequisites) { std::cerr << prerequisite.first << "_style " << prerequisite.second << "\n"; } @@ -444,67 +450,71 @@ TEST(BondStyle, plain) { lmp = init_lammps(argc,argv,test_config,false); if (!verbose) ::testing::internal::GetCapturedStdout(); - f=lmp->atom->f; - tag=lmp->atom->tag; - stats.reset(); - for (int i=0; i < nlocal; ++i) { - EXPECT_FP_LE_WITH_EPS(f[i][0], f_ref[tag[i]].x, epsilon); - EXPECT_FP_LE_WITH_EPS(f[i][1], f_ref[tag[i]].y, epsilon); - EXPECT_FP_LE_WITH_EPS(f[i][2], f_ref[tag[i]].z, epsilon); + // skip over these tests if newton bond is forced to be on + if (lmp->force->newton_bond == 0) { + + f=lmp->atom->f; + tag=lmp->atom->tag; + stats.reset(); + for (int i=0; i < nlocal; ++i) { + EXPECT_FP_LE_WITH_EPS(f[i][0], f_ref[tag[i]].x, epsilon); + EXPECT_FP_LE_WITH_EPS(f[i][1], f_ref[tag[i]].y, epsilon); + EXPECT_FP_LE_WITH_EPS(f[i][2], f_ref[tag[i]].z, epsilon); + } + if (print_stats) + std::cerr << "init_forces stats, newton off:" << stats << std::endl; + + bond = lmp->force->bond; + stress = bond->virial; + stats.reset(); + EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 2*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 2*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 2*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 2*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 2*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 2*epsilon); + if (print_stats) + std::cerr << "init_stress stats, newton off:" << stats << std::endl; + + stats.reset(); + EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.init_energy, epsilon); + if (print_stats) + std::cerr << "init_energy stats, newton off:" << stats << std::endl; + + if (!verbose) ::testing::internal::CaptureStdout(); + run_lammps(lmp); + if (!verbose) ::testing::internal::GetCapturedStdout(); + + f = lmp->atom->f; + stress = bond->virial; + stats.reset(); + for (int i=0; i < nlocal; ++i) { + EXPECT_FP_LE_WITH_EPS(f[i][0], f_run[tag[i]].x, 10*epsilon); + EXPECT_FP_LE_WITH_EPS(f[i][1], f_run[tag[i]].y, 10*epsilon); + EXPECT_FP_LE_WITH_EPS(f[i][2], f_run[tag[i]].z, 10*epsilon); + } + if (print_stats) + std::cerr << "run_forces stats, newton off:" << stats << std::endl; + + stress = bond->virial; + stats.reset(); + EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, epsilon); + EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, epsilon); + EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, epsilon); + EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, epsilon); + EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, epsilon); + EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, epsilon); + if (print_stats) + std::cerr << "run_stress stats, newton off:" << stats << std::endl; + + stats.reset(); + id = lmp->modify->find_compute("sum"); + energy = lmp->modify->compute[id]->compute_scalar(); + EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.run_energy, epsilon); + EXPECT_FP_LE_WITH_EPS(bond->energy, energy, epsilon); + if (print_stats) + std::cerr << "run_energy stats, newton off:" << stats << std::endl; } - if (print_stats) - std::cerr << "init_forces stats, newton off:" << stats << std::endl; - - bond = lmp->force->bond; - stress = bond->virial; - stats.reset(); - EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 2*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 2*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 2*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 2*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 2*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 2*epsilon); - if (print_stats) - std::cerr << "init_stress stats, newton off:" << stats << std::endl; - - stats.reset(); - EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.init_energy, epsilon); - if (print_stats) - std::cerr << "init_energy stats, newton off:" << stats << std::endl; - - if (!verbose) ::testing::internal::CaptureStdout(); - run_lammps(lmp); - if (!verbose) ::testing::internal::GetCapturedStdout(); - - f = lmp->atom->f; - stress = bond->virial; - stats.reset(); - for (int i=0; i < nlocal; ++i) { - EXPECT_FP_LE_WITH_EPS(f[i][0], f_run[tag[i]].x, 10*epsilon); - EXPECT_FP_LE_WITH_EPS(f[i][1], f_run[tag[i]].y, 10*epsilon); - EXPECT_FP_LE_WITH_EPS(f[i][2], f_run[tag[i]].z, 10*epsilon); - } - if (print_stats) - std::cerr << "run_forces stats, newton off:" << stats << std::endl; - - stress = bond->virial; - stats.reset(); - EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, epsilon); - EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, epsilon); - EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, epsilon); - EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, epsilon); - EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, epsilon); - EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, epsilon); - if (print_stats) - std::cerr << "run_stress stats, newton off:" << stats << std::endl; - - stats.reset(); - id = lmp->modify->find_compute("sum"); - energy = lmp->modify->compute[id]->compute_scalar(); - EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.run_energy, epsilon); - EXPECT_FP_LE_WITH_EPS(bond->energy, energy, epsilon); - if (print_stats) - std::cerr << "run_energy stats, newton off:" << stats << std::endl; if (!verbose) ::testing::internal::CaptureStdout(); restart_lammps(lmp, test_config); @@ -587,11 +597,12 @@ TEST(BondStyle, omp) { ::testing::internal::CaptureStdout(); LAMMPS *lmp = init_lammps(argc,argv,test_config,true); std::string output = ::testing::internal::GetCapturedStdout(); + if (verbose) std::cout << output; if (!lmp) { std::cerr << "One or more prerequisite styles with /omp suffix\n" "are not available in this LAMMPS configuration:\n"; - for (auto prerequisite : test_config.prerequisites) { + for (auto& prerequisite : test_config.prerequisites) { std::cerr << prerequisite.first << "_style " << prerequisite.second << "\n"; } @@ -622,7 +633,6 @@ TEST(BondStyle, omp) { Bond *bond = lmp->force->bond; double *stress = bond->virial; - stats.reset(); EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 10*epsilon); EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 10*epsilon); @@ -682,69 +692,73 @@ TEST(BondStyle, omp) { lmp = init_lammps(argc,argv,test_config,false); if (!verbose) ::testing::internal::GetCapturedStdout(); - f=lmp->atom->f; - tag=lmp->atom->tag; - stats.reset(); - for (int i=0; i < nlocal; ++i) { - EXPECT_FP_LE_WITH_EPS(f[i][0], f_ref[tag[i]].x, epsilon); - EXPECT_FP_LE_WITH_EPS(f[i][1], f_ref[tag[i]].y, epsilon); - EXPECT_FP_LE_WITH_EPS(f[i][2], f_ref[tag[i]].z, epsilon); + // skip over these tests if newton bond is forced to be on + if (lmp->force->newton_bond == 0) { + + f=lmp->atom->f; + tag=lmp->atom->tag; + stats.reset(); + for (int i=0; i < nlocal; ++i) { + EXPECT_FP_LE_WITH_EPS(f[i][0], f_ref[tag[i]].x, epsilon); + EXPECT_FP_LE_WITH_EPS(f[i][1], f_ref[tag[i]].y, epsilon); + EXPECT_FP_LE_WITH_EPS(f[i][2], f_ref[tag[i]].z, epsilon); + } + if (print_stats) + std::cerr << "init_forces stats, newton off:" << stats << std::endl; + + bond = lmp->force->bond; + stress = bond->virial; + stats.reset(); + EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 10*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 10*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 10*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 10*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 10*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 10*epsilon); + if (print_stats) + std::cerr << "init_stress stats, newton off:" << stats << std::endl; + + stats.reset(); + EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.init_energy, epsilon); + if (print_stats) + std::cerr << "init_energy stats, newton off:" << stats << std::endl; + + if (!verbose) ::testing::internal::CaptureStdout(); + run_lammps(lmp); + if (!verbose) ::testing::internal::GetCapturedStdout(); + + f = lmp->atom->f; + stats.reset(); + for (int i=0; i < nlocal; ++i) { + EXPECT_FP_LE_WITH_EPS(f[i][0], f_run[tag[i]].x, 10*epsilon); + EXPECT_FP_LE_WITH_EPS(f[i][1], f_run[tag[i]].y, 10*epsilon); + EXPECT_FP_LE_WITH_EPS(f[i][2], f_run[tag[i]].z, 10*epsilon); + } + if (print_stats) + std::cerr << "run_forces stats, newton off:" << stats << std::endl; + + stress = bond->virial; + stats.reset(); + EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, 10*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, 10*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, 10*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 10*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 10*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 10*epsilon); + if (print_stats) + std::cerr << "run_stress stats, newton off:" << stats << std::endl; + + stats.reset(); + id = lmp->modify->find_compute("sum"); + energy = lmp->modify->compute[id]->compute_scalar(); + EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.run_energy, epsilon); + // TODO: this is currently broken for USER-OMP with bond style hybrid + // needs to be fixed in the main code somewhere. Not sure where, though. + if (test_config.bond_style.substr(0,6) != "hybrid") + EXPECT_FP_LE_WITH_EPS(bond->energy, energy, epsilon); + if (print_stats) + std::cerr << "run_energy stats, newton off:" << stats << std::endl; } - if (print_stats) - std::cerr << "init_forces stats, newton off:" << stats << std::endl; - - bond = lmp->force->bond; - stress = bond->virial; - stats.reset(); - EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 10*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 10*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 10*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 10*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 10*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 10*epsilon); - if (print_stats) - std::cerr << "init_stress stats, newton off:" << stats << std::endl; - - stats.reset(); - EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.init_energy, epsilon); - if (print_stats) - std::cerr << "init_energy stats, newton off:" << stats << std::endl; - - if (!verbose) ::testing::internal::CaptureStdout(); - run_lammps(lmp); - if (!verbose) ::testing::internal::GetCapturedStdout(); - - f = lmp->atom->f; - stats.reset(); - for (int i=0; i < nlocal; ++i) { - EXPECT_FP_LE_WITH_EPS(f[i][0], f_run[tag[i]].x, 10*epsilon); - EXPECT_FP_LE_WITH_EPS(f[i][1], f_run[tag[i]].y, 10*epsilon); - EXPECT_FP_LE_WITH_EPS(f[i][2], f_run[tag[i]].z, 10*epsilon); - } - if (print_stats) - std::cerr << "run_forces stats, newton off:" << stats << std::endl; - - stress = bond->virial; - stats.reset(); - EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, 10*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, 10*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, 10*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 10*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 10*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 10*epsilon); - if (print_stats) - std::cerr << "run_stress stats, newton off:" << stats << std::endl; - - stats.reset(); - id = lmp->modify->find_compute("sum"); - energy = lmp->modify->compute[id]->compute_scalar(); - EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.run_energy, epsilon); - // TODO: this is currently broken for USER-OMP with bond style hybrid - // needs to be fixed in the main code somewhere. Not sure where, though. - if (test_config.bond_style.substr(0,6) != "hybrid") - EXPECT_FP_LE_WITH_EPS(bond->energy, energy, epsilon); - if (print_stats) - std::cerr << "run_energy stats, newton off:" << stats << std::endl; if (!verbose) ::testing::internal::CaptureStdout(); cleanup_lammps(lmp,test_config); @@ -760,10 +774,11 @@ TEST(BondStyle, single) { if (!verbose) ::testing::internal::CaptureStdout(); LAMMPS *lmp = init_lammps(argc,argv,test_config); if (!verbose) ::testing::internal::GetCapturedStdout(); + if (!lmp) { std::cerr << "One or more prerequisite styles are not available " "in this LAMMPS configuration:\n"; - for (auto prerequisite : test_config.prerequisites) { + for (auto& prerequisite : test_config.prerequisites) { std::cerr << prerequisite.first << "_style " << prerequisite.second << "\n"; } @@ -771,7 +786,6 @@ TEST(BondStyle, single) { } // gather some information and skip if unsupported - int ntypes = lmp->atom->ntypes; int nbondtypes = lmp->atom->nbondtypes; int molecular = lmp->atom->molecular; if (molecular != 1) { @@ -787,8 +801,6 @@ TEST(BondStyle, single) { lmp->input->one(line.c_str()); }; - Bond *bond = lmp->force->bond; - // now start over if (!verbose) ::testing::internal::CaptureStdout(); command("clear"); @@ -824,9 +836,9 @@ TEST(BondStyle, single) { command("pair_coeff * *"); command("bond_style " + test_config.bond_style); - bond = lmp->force->bond; + Bond *bond = lmp->force->bond; - for (auto bond_coeff : test_config.bond_coeff) { + for (auto& bond_coeff : test_config.bond_coeff) { command("bond_coeff " + bond_coeff); } @@ -1006,6 +1018,10 @@ TEST(BondStyle, single) { if (print_stats) std::cerr << "single_energy stats:" << stats << std::endl; + int i = 0; + for (auto &dist : test_config.equilibrium) + EXPECT_NEAR(dist,bond->equilibrium_distance(++i),0.00001); + if (!verbose) ::testing::internal::CaptureStdout(); cleanup_lammps(lmp,test_config); if (!verbose) ::testing::internal::GetCapturedStdout(); diff --git a/unittest/force-styles/pair_style.cpp b/unittest/force-styles/pair_style.cpp index 90bd646fc7..7849fb593f 100644 --- a/unittest/force-styles/pair_style.cpp +++ b/unittest/force-styles/pair_style.cpp @@ -449,69 +449,73 @@ TEST(PairStyle, plain) { lmp = init_lammps(argc,argv,test_config,false); if (!verbose) ::testing::internal::GetCapturedStdout(); - f=lmp->atom->f; - tag=lmp->atom->tag; - stats.reset(); - for (int i=0; i < nlocal; ++i) { - EXPECT_FP_LE_WITH_EPS(f[i][0], f_ref[tag[i]].x, epsilon); - EXPECT_FP_LE_WITH_EPS(f[i][1], f_ref[tag[i]].y, epsilon); - EXPECT_FP_LE_WITH_EPS(f[i][2], f_ref[tag[i]].z, epsilon); + // skip over these tests if newton pair is forced to be on + if (lmp->force->newton_pair == 0) { + + f=lmp->atom->f; + tag=lmp->atom->tag; + stats.reset(); + for (int i=0; i < nlocal; ++i) { + EXPECT_FP_LE_WITH_EPS(f[i][0], f_ref[tag[i]].x, epsilon); + EXPECT_FP_LE_WITH_EPS(f[i][1], f_ref[tag[i]].y, epsilon); + EXPECT_FP_LE_WITH_EPS(f[i][2], f_ref[tag[i]].z, epsilon); + } + if (print_stats) + std::cerr << "init_forces stats, newton off:" << stats << std::endl; + + pair = lmp->force->pair; + stress = pair->virial; + stats.reset(); + EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 3*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 3*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 3*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 3*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 3*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 3*epsilon); + if (print_stats) + std::cerr << "init_stress stats, newton off:" << stats << std::endl; + + stats.reset(); + EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon); + EXPECT_FP_LE_WITH_EPS(pair->eng_coul, test_config.init_coul, epsilon); + if (print_stats) + std::cerr << "init_energy stats, newton off:" << stats << std::endl; + + if (!verbose) ::testing::internal::CaptureStdout(); + run_lammps(lmp); + if (!verbose) ::testing::internal::GetCapturedStdout(); + + f = lmp->atom->f; + stress = pair->virial; + stats.reset(); + for (int i=0; i < nlocal; ++i) { + EXPECT_FP_LE_WITH_EPS(f[i][0], f_run[tag[i]].x, 5*epsilon); + EXPECT_FP_LE_WITH_EPS(f[i][1], f_run[tag[i]].y, 5*epsilon); + EXPECT_FP_LE_WITH_EPS(f[i][2], f_run[tag[i]].z, 5*epsilon); + } + if (print_stats) + std::cerr << "run_forces stats, newton off:" << stats << std::endl; + + stress = pair->virial; + stats.reset(); + EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, epsilon); + EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, epsilon); + EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, epsilon); + EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, epsilon); + EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, epsilon); + EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, epsilon); + if (print_stats) + std::cerr << "run_stress stats, newton off:" << stats << std::endl; + + stats.reset(); + id = lmp->modify->find_compute("sum"); + energy = lmp->modify->compute[id]->compute_scalar(); + EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.run_vdwl, epsilon); + EXPECT_FP_LE_WITH_EPS(pair->eng_coul, test_config.run_coul, epsilon); + EXPECT_FP_LE_WITH_EPS((pair->eng_vdwl+pair->eng_coul),energy, epsilon); + if (print_stats) + std::cerr << "run_energy stats, newton off:" << stats << std::endl; } - if (print_stats) - std::cerr << "init_forces stats, newton off:" << stats << std::endl; - - pair = lmp->force->pair; - stress = pair->virial; - stats.reset(); - EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 3*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 3*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 3*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 3*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 3*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 3*epsilon); - if (print_stats) - std::cerr << "init_stress stats, newton off:" << stats << std::endl; - - stats.reset(); - EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon); - EXPECT_FP_LE_WITH_EPS(pair->eng_coul, test_config.init_coul, epsilon); - if (print_stats) - std::cerr << "init_energy stats, newton off:" << stats << std::endl; - - if (!verbose) ::testing::internal::CaptureStdout(); - run_lammps(lmp); - if (!verbose) ::testing::internal::GetCapturedStdout(); - - f = lmp->atom->f; - stress = pair->virial; - stats.reset(); - for (int i=0; i < nlocal; ++i) { - EXPECT_FP_LE_WITH_EPS(f[i][0], f_run[tag[i]].x, 5*epsilon); - EXPECT_FP_LE_WITH_EPS(f[i][1], f_run[tag[i]].y, 5*epsilon); - EXPECT_FP_LE_WITH_EPS(f[i][2], f_run[tag[i]].z, 5*epsilon); - } - if (print_stats) - std::cerr << "run_forces stats, newton off:" << stats << std::endl; - - stress = pair->virial; - stats.reset(); - EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, epsilon); - EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, epsilon); - EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, epsilon); - EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, epsilon); - EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, epsilon); - EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, epsilon); - if (print_stats) - std::cerr << "run_stress stats, newton off:" << stats << std::endl; - - stats.reset(); - id = lmp->modify->find_compute("sum"); - energy = lmp->modify->compute[id]->compute_scalar(); - EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.run_vdwl, epsilon); - EXPECT_FP_LE_WITH_EPS(pair->eng_coul, test_config.run_coul, epsilon); - EXPECT_FP_LE_WITH_EPS((pair->eng_vdwl+pair->eng_coul),energy, epsilon); - if (print_stats) - std::cerr << "run_energy stats, newton off:" << stats << std::endl; if (!verbose) ::testing::internal::CaptureStdout(); restart_lammps(lmp, test_config); @@ -641,6 +645,7 @@ TEST(PairStyle, omp) { ::testing::internal::CaptureStdout(); LAMMPS *lmp = init_lammps(argc,argv,test_config,true); std::string output = ::testing::internal::GetCapturedStdout(); + if (verbose) std::cout << output; if (!lmp) { std::cerr << "One or more prerequisite styles with /omp suffix\n" @@ -734,69 +739,72 @@ TEST(PairStyle, omp) { lmp = init_lammps(argc,argv,test_config,false); if (!verbose) ::testing::internal::GetCapturedStdout(); - f=lmp->atom->f; - tag=lmp->atom->tag; - stats.reset(); - for (int i=0; i < nlocal; ++i) { - EXPECT_FP_LE_WITH_EPS(f[i][0], f_ref[tag[i]].x, epsilon); - EXPECT_FP_LE_WITH_EPS(f[i][1], f_ref[tag[i]].y, epsilon); - EXPECT_FP_LE_WITH_EPS(f[i][2], f_ref[tag[i]].z, epsilon); + // skip over these tests if newton pair is forced to be on + if (lmp->force->newton_pair == 0) { + + f=lmp->atom->f; + tag=lmp->atom->tag; + stats.reset(); + for (int i=0; i < nlocal; ++i) { + EXPECT_FP_LE_WITH_EPS(f[i][0], f_ref[tag[i]].x, epsilon); + EXPECT_FP_LE_WITH_EPS(f[i][1], f_ref[tag[i]].y, epsilon); + EXPECT_FP_LE_WITH_EPS(f[i][2], f_ref[tag[i]].z, epsilon); + } + if (print_stats) + std::cerr << "init_forces stats, newton off:" << stats << std::endl; + + pair = lmp->force->pair; + stress = pair->virial; + stats.reset(); + EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 10*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 10*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 10*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 10*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 10*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 10*epsilon); + if (print_stats) + std::cerr << "init_stress stats, newton off:" << stats << std::endl; + + stats.reset(); + EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon); + EXPECT_FP_LE_WITH_EPS(pair->eng_coul, test_config.init_coul, epsilon); + if (print_stats) + std::cerr << "init_energy stats, newton off:" << stats << std::endl; + + if (!verbose) ::testing::internal::CaptureStdout(); + run_lammps(lmp); + if (!verbose) ::testing::internal::GetCapturedStdout(); + + f = lmp->atom->f; + stats.reset(); + for (int i=0; i < nlocal; ++i) { + EXPECT_FP_LE_WITH_EPS(f[i][0], f_run[tag[i]].x, 5*epsilon); + EXPECT_FP_LE_WITH_EPS(f[i][1], f_run[tag[i]].y, 5*epsilon); + EXPECT_FP_LE_WITH_EPS(f[i][2], f_run[tag[i]].z, 5*epsilon); + } + if (print_stats) + std::cerr << "run_forces stats, newton off:" << stats << std::endl; + + stress = pair->virial; + stats.reset(); + EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, 10*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, 10*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, 10*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 10*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 10*epsilon); + EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 10*epsilon); + if (print_stats) + std::cerr << "run_stress stats, newton off:" << stats << std::endl; + + stats.reset(); + id = lmp->modify->find_compute("sum"); + energy = lmp->modify->compute[id]->compute_scalar(); + EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.run_vdwl, epsilon); + EXPECT_FP_LE_WITH_EPS(pair->eng_coul, test_config.run_coul, epsilon); + EXPECT_FP_LE_WITH_EPS((pair->eng_vdwl+pair->eng_coul),energy, epsilon); + if (print_stats) + std::cerr << "run_energy stats, newton off:" << stats << std::endl; } - if (print_stats) - std::cerr << "init_forces stats, newton off:" << stats << std::endl; - - pair = lmp->force->pair; - stress = pair->virial; - stats.reset(); - EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 10*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 10*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 10*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 10*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 10*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 10*epsilon); - if (print_stats) - std::cerr << "init_stress stats, newton off:" << stats << std::endl; - - stats.reset(); - EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon); - EXPECT_FP_LE_WITH_EPS(pair->eng_coul, test_config.init_coul, epsilon); - if (print_stats) - std::cerr << "init_energy stats, newton off:" << stats << std::endl; - - if (!verbose) ::testing::internal::CaptureStdout(); - run_lammps(lmp); - if (!verbose) ::testing::internal::GetCapturedStdout(); - - f = lmp->atom->f; - stats.reset(); - for (int i=0; i < nlocal; ++i) { - EXPECT_FP_LE_WITH_EPS(f[i][0], f_run[tag[i]].x, 5*epsilon); - EXPECT_FP_LE_WITH_EPS(f[i][1], f_run[tag[i]].y, 5*epsilon); - EXPECT_FP_LE_WITH_EPS(f[i][2], f_run[tag[i]].z, 5*epsilon); - } - if (print_stats) - std::cerr << "run_forces stats, newton off:" << stats << std::endl; - - stress = pair->virial; - stats.reset(); - EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, 10*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, 10*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, 10*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 10*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 10*epsilon); - EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 10*epsilon); - if (print_stats) - std::cerr << "run_stress stats, newton off:" << stats << std::endl; - - stats.reset(); - id = lmp->modify->find_compute("sum"); - energy = lmp->modify->compute[id]->compute_scalar(); - EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.run_vdwl, epsilon); - EXPECT_FP_LE_WITH_EPS(pair->eng_coul, test_config.run_coul, epsilon); - EXPECT_FP_LE_WITH_EPS((pair->eng_vdwl+pair->eng_coul),energy, epsilon); - if (print_stats) - std::cerr << "run_energy stats, newton off:" << stats << std::endl; - if (!verbose) ::testing::internal::CaptureStdout(); cleanup_lammps(lmp,test_config); if (!verbose) ::testing::internal::GetCapturedStdout(); @@ -810,10 +818,10 @@ TEST(PairStyle, intel) { char **argv = (char **)args; int argc = sizeof(args)/sizeof(char *); - if (!verbose) ::testing::internal::CaptureStdout(); + ::testing::internal::CaptureStdout(); LAMMPS *lmp = init_lammps(argc,argv,test_config); - std::string output; - if (!verbose) output = ::testing::internal::GetCapturedStdout(); + std::string output = ::testing::internal::GetCapturedStdout(); + if (verbose) std::cout << output; if (!lmp) { std::cerr << "One or more prerequisite styles with /intel suffix\n" @@ -825,8 +833,16 @@ TEST(PairStyle, intel) { GTEST_SKIP(); } + if (test_config.pair_style == "rebo") { + if (!verbose) ::testing::internal::CaptureStdout(); + cleanup_lammps(lmp,test_config); + if (!verbose) ::testing::internal::GetCapturedStdout(); + std::cerr << "Skipping pair style rebo/intel\n"; + GTEST_SKIP(); + } + // relax error a bit for USER-INTEL package - double epsilon = 5.0*test_config.epsilon; + double epsilon = 7.5*test_config.epsilon; // we need to relax the epsilon a LOT for tests using long-range // coulomb with tabulation. seems more like mixed precision or a bug @@ -908,6 +924,11 @@ TEST(PairStyle, intel) { double energy = lmp->modify->compute[id]->compute_scalar(); EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.run_vdwl, epsilon); EXPECT_FP_LE_WITH_EPS(pair->eng_coul, test_config.run_coul, epsilon); + + // rebo family of pair styles will have a large error in per-atom energy for USER-INTEL + if (test_config.pair_style.find("rebo") != std::string::npos) + epsilon *= 100000.0; + EXPECT_FP_LE_WITH_EPS((pair->eng_vdwl+pair->eng_coul),energy, epsilon); if (print_stats) std::cerr << "run_energy stats:" << stats << std::endl; @@ -1029,7 +1050,7 @@ TEST(PairStyle, single) { // create a LAMMPS instance with standard settings to detect the number of atom types if (!verbose) ::testing::internal::CaptureStdout(); LAMMPS *lmp = init_lammps(argc,argv,test_config); - if (!verbose) ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); if (!lmp) { std::cerr << "One or more prerequisite styles are not available " diff --git a/unittest/force-styles/test_config.h b/unittest/force-styles/test_config.h index 350c3354a0..e808a0301c 100644 --- a/unittest/force-styles/test_config.h +++ b/unittest/force-styles/test_config.h @@ -47,6 +47,7 @@ public: std::vector angle_coeff; std::vector dihedral_coeff; std::vector improper_coeff; + std::vector equilibrium; std::vector> extract; int natoms; double init_energy; diff --git a/unittest/force-styles/test_config_reader.cpp b/unittest/force-styles/test_config_reader.cpp index 9bab078002..0bfe33b4ff 100644 --- a/unittest/force-styles/test_config_reader.cpp +++ b/unittest/force-styles/test_config_reader.cpp @@ -50,31 +50,21 @@ TestConfigReader::TestConfigReader(TestConfig & config) consumers["bond_style"] = &TestConfigReader::bond_style; consumers["bond_coeff"] = &TestConfigReader::bond_coeff; - consumers["init_energy"] = &TestConfigReader::init_energy; - consumers["run_energy"] = &TestConfigReader::run_energy; - consumers["angle_style"] = &TestConfigReader::angle_style; consumers["angle_coeff"] = &TestConfigReader::angle_coeff; consumers["init_energy"] = &TestConfigReader::init_energy; consumers["run_energy"] = &TestConfigReader::run_energy; + consumers["equilibrium"] = &TestConfigReader::equilibrium; } void TestConfigReader::prerequisites(const yaml_event_t & event) { config.prerequisites.clear(); std::stringstream data((char *)event.data.scalar.value); - std::string line; + std::string key, value; - while(std::getline(data, line, '\n')) { - std::size_t found = line.find_first_of(" \t"); - std::string key = line.substr(0,found); - found = line.find_first_not_of(" \t",found); - // skip invalid data - if (found == std::string::npos) { - std::cerr << "Skipping invalid prerequisite line:\n" - << line << std::endl; - continue; - } - std::string value = line.substr(found,line.find_first_of(" \t",found)); + while(1) { + data >> key >> value; + if (data.eof()) break; config.prerequisites.push_back(std::make_pair(key,value)); } } @@ -118,12 +108,11 @@ void TestConfigReader::input_file(const yaml_event_t & event) { void TestConfigReader::extract(const yaml_event_t & event) { config.extract.clear(); std::stringstream data((char *)event.data.scalar.value); - std::string line; - - while (std::getline(data, line, '\n')) { - std::size_t found = line.find_first_of(" \t"); - std::string name = line.substr(0,found); - int value = atoi(line.substr(found).c_str()); + std::string name; + int value; + while(1) { + data >> name >> value; + if (data.eof()) break; config.extract.push_back(make_pair(name, value)); } } @@ -220,6 +209,17 @@ void TestConfigReader::angle_coeff(const yaml_event_t & event) { } } +void TestConfigReader::equilibrium(const yaml_event_t & event) { + std::stringstream data((char *)event.data.scalar.value); + config.equilibrium.clear(); + double value; + while (1) { + data >> value; + if (data.eof()) break; + config.equilibrium.push_back(value); + } +} + void TestConfigReader::init_vdwl(const yaml_event_t & event) { config.init_vdwl = atof((char *)event.data.scalar.value); } diff --git a/unittest/force-styles/test_config_reader.h b/unittest/force-styles/test_config_reader.h index ee1c3fa808..de960c81c6 100644 --- a/unittest/force-styles/test_config_reader.h +++ b/unittest/force-styles/test_config_reader.h @@ -41,6 +41,7 @@ public: void bond_coeff(const yaml_event_t & event); void angle_style(const yaml_event_t & event); void angle_coeff(const yaml_event_t & event); + void equilibrium(const yaml_event_t & event); void init_vdwl(const yaml_event_t & event); void init_coul(const yaml_event_t & event); void run_vdwl(const yaml_event_t & event); diff --git a/unittest/force-styles/tests/angle-charmm.yaml b/unittest/force-styles/tests/angle-charmm.yaml index 46af85bb82..d42f5e5fdc 100644 --- a/unittest/force-styles/tests/angle-charmm.yaml +++ b/unittest/force-styles/tests/angle-charmm.yaml @@ -1,6 +1,6 @@ --- lammps_version: 5 May 2020 -date_generated: Tue May 19 19:19:41 202 +date_generated: Thu May 28 22:02:50 202 epsilon: 2.5e-13 prerequisites: ! | atom full @@ -14,6 +14,7 @@ angle_coeff: ! | 2 46.1 111.3 0.0 0.000 3 40.0 120.0 35.0 2.410 4 33.0 108.5 30.0 2.163 +equilibrium: 1.92161 1.94255 2.0944 1.89368 extract: ! "" natoms: 29 init_energy: 85.4248638845977 diff --git a/unittest/force-styles/tests/angle-harmonic.yaml b/unittest/force-styles/tests/angle-harmonic.yaml index 22d7830efa..61ccebf191 100644 --- a/unittest/force-styles/tests/angle-harmonic.yaml +++ b/unittest/force-styles/tests/angle-harmonic.yaml @@ -1,6 +1,6 @@ --- lammps_version: 5 May 2020 -date_generated: Tue May 19 19:00:35 202 +date_generated: Thu May 28 22:02:43 202 epsilon: 2.5e-13 prerequisites: ! | atom full @@ -14,6 +14,7 @@ angle_coeff: ! | 2 45.0 111.0 3 50.0 120.0 4 100.0 108.5 +equilibrium: 1.92161 1.93732 2.0944 1.89368 extract: ! "" natoms: 29 init_energy: 41.530817896491 diff --git a/unittest/force-styles/tests/angle-zero.yaml b/unittest/force-styles/tests/angle-zero.yaml index 4cee04a4cb..d49f2a6d35 100644 --- a/unittest/force-styles/tests/angle-zero.yaml +++ b/unittest/force-styles/tests/angle-zero.yaml @@ -1,6 +1,6 @@ --- lammps_version: 5 May 2020 -date_generated: Mon May 18 18:18:26 202 +date_generated: Thu May 28 22:02:55 202 epsilon: 1e-14 prerequisites: ! | atom full @@ -14,6 +14,7 @@ angle_coeff: ! | 2 111 3 120 4 108.5 +equilibrium: 1.92161 1.93732 2.0944 1.89368 extract: ! "" natoms: 29 init_energy: 0 diff --git a/unittest/force-styles/tests/atomic-pair-adp.yaml b/unittest/force-styles/tests/atomic-pair-adp.yaml new file mode 100644 index 0000000000..f81c804892 --- /dev/null +++ b/unittest/force-styles/tests/atomic-pair-adp.yaml @@ -0,0 +1,89 @@ +--- +lammps_version: 5 May 2020 +date_generated: Tue May 26 18:05:10 202 +epsilon: 5.0e-13 +prerequisites: ! | + pair adp +pre_commands: ! "" +post_commands: ! "" +input_file: in.metal +pair_style: adp +pair_coeff: ! | + * * AlCu.adp Al Cu +extract: ! "" +natoms: 32 +init_vdwl: -96.3621905354495 +init_coul: 0 +init_stress: ! |2- + 1.0950940963019309e+02 9.8793143617200286e+01 8.2868514028589203e+01 4.4674243524583641e+00 -1.6359979177752422e+00 3.1824061950082316e+00 +init_forces: ! |2 + 1 2.6418556012240524e+00 3.0791110120727834e+00 -4.3456214378906044e-01 + 2 -1.2141845894013787e+00 -1.6357864402684945e+00 9.8797759298830901e-01 + 3 -2.5754585792526252e-01 1.9004324101935111e+00 -5.7788457649458524e-01 + 4 1.2215481704788278e-01 -4.8576918398407010e-01 -1.9299014100870855e+00 + 5 -8.1727258278999071e-01 4.5832448973069297e+00 1.2611240957594481e+00 + 6 1.4635484515168800e+00 3.3535268222650072e+00 1.2576763798236709e-01 + 7 -1.4488054805439372e+00 2.9651178960391880e+00 6.4858435580248630e-01 + 8 -1.3770073607813824e+00 -1.5703153898762934e+00 3.3102239898170727e-01 + 9 -1.3697614207094917e+00 -2.2764220743553989e+00 -2.0310472165159137e+00 + 10 -4.9802855878506413e-01 -7.6763046573537241e-01 -2.9361965034325213e+00 + 11 -1.4230052677849754e+00 -5.0334859786147721e+00 2.8633312080499653e+00 + 12 -1.2106526197639287e+00 -3.0856321145554388e+00 5.1256612481593822e-01 + 13 7.8581642020687426e-01 1.0242142380756333e-01 -1.0380200691043213e+00 + 14 1.4047063541049598e+00 2.4026617055765678e-01 1.2109818633912310e+00 + 15 -1.1690767391691688e+00 9.4066356394858985e-01 -1.5653707286463201e+00 + 16 4.2254765660007410e+00 -3.4672026225176471e+00 1.6342523174158279e+00 + 17 2.1343541245137030e+00 4.9430135580079071e+00 1.1900581236812249e+00 + 18 -4.2337122974188954e+00 -1.3525510756568251e+00 -1.5575745101497862e+00 + 19 -3.1543746354852455e+00 -2.5620907532907506e+00 3.6408570868350071e-01 + 20 3.8637992201883486e-01 1.0619428905966560e-01 -8.0546718010180995e-01 + 21 2.7369023483518196e+00 3.0915007072198715e+00 9.1269055562841117e-01 + 22 1.6989958841939415e-01 -2.8093680327172268e+00 -8.3168495193076331e-01 + 23 1.2348249856632112e+00 1.2864017252777045e+00 -2.8129726341997441e+00 + 24 3.3579423586745953e+00 2.1120501164465693e+00 2.5290197681570179e+00 + 25 2.6074130223214920e+00 5.3982471417457190e-01 -1.5085445988708297e+00 + 26 -1.2888296180198777e+00 -2.4575650778301750e+00 3.2508326993677845e+00 + 27 -5.9891527786658016e-01 -1.9133108276730251e+00 -1.6067572074939560e+00 + 28 8.5820468629457602e-01 1.5139451363119676e+00 1.9835666715849922e+00 + 29 5.0935904713279445e-01 3.5669579148382082e+00 -7.4244727417423911e-02 + 30 -1.0514674962209756e+00 4.6022227597482734e-01 -1.6698279858900587e+00 + 31 -1.4488194920959718e+00 -3.1789190528067137e+00 2.9594105842256515e+00 + 32 -2.0773789987296838e+00 -2.1888455436203138e+00 -1.3852152623916831e+00 +run_vdwl: -97.2840335101252 +run_coul: 0 +run_stress: ! |2- + 1.0925403884890126e+02 1.0018439642388212e+02 8.3068253121729811e+01 4.5993272946160433e+00 -1.7799394161194859e+00 2.9390998409508358e+00 +run_forces: ! |2 + 1 2.4064978281383116e+00 2.8310326936438877e+00 -3.5810016705697367e-01 + 2 -1.1261310132338069e+00 -1.5312320923043055e+00 9.6952704543098811e-01 + 3 -2.4650555117225181e-01 1.8315233906328920e+00 -5.7634113367450002e-01 + 4 1.2242282478350608e-01 -4.3211338579366498e-01 -1.8416879128899488e+00 + 5 -7.0953596594993995e-01 4.3872501528819772e+00 1.2198764107921147e+00 + 6 1.4355778194846196e+00 3.1230427942640886e+00 1.0460063095047266e-01 + 7 -1.3416390203108872e+00 2.8948917966566108e+00 5.2646849990322797e-01 + 8 -1.4007930720394097e+00 -1.5230294132832771e+00 3.4579502678166296e-01 + 9 -1.2622837538049017e+00 -2.2231298677487961e+00 -2.0045399334221412e+00 + 10 -4.3913922697311669e-01 -9.0840973588166463e-01 -2.8218327626483251e+00 + 11 -1.3147642860228517e+00 -4.8236401147771337e+00 2.6871309117513680e+00 + 12 -1.0957379311264326e+00 -2.9278906379066498e+00 4.6929334188560934e-01 + 13 6.7249226506672344e-01 1.1483409210433106e-01 -9.6784482414126272e-01 + 14 1.4106438235859298e+00 3.6819359106125810e-01 1.1836433781724227e+00 + 15 -1.0871174078364445e+00 8.4370127310773335e-01 -1.4801691474240857e+00 + 16 3.8907862703737037e+00 -3.3139955888245916e+00 1.5672229237406345e+00 + 17 2.1444955824270222e+00 4.8533155990282646e+00 1.0545502443590111e+00 + 18 -4.0554294388745866e+00 -1.3079577852355624e+00 -1.5174362521234366e+00 + 19 -3.0072194753444514e+00 -2.4667032104263260e+00 3.5614927986445716e-01 + 20 3.5586969111907174e-01 1.4473797586761281e-01 -8.3789376744459909e-01 + 21 2.6413106532436315e+00 2.9469445429824588e+00 8.5617991697448781e-01 + 22 2.2100391009224801e-01 -2.6566634187479758e+00 -8.0101369565518421e-01 + 23 1.1776903128486964e+00 1.3203050720866989e+00 -2.6493524059502667e+00 + 24 3.1945792941270805e+00 2.0791083868152311e+00 2.4754363069038008e+00 + 25 2.4537864834143148e+00 5.5354561408985292e-01 -1.4374704915688303e+00 + 26 -1.2204586684158216e+00 -2.3600757011587330e+00 3.1427413394695853e+00 + 27 -5.5338014379062539e-01 -1.9087190309620143e+00 -1.5736095755530599e+00 + 28 7.8017213821606735e-01 1.4703377685237793e+00 1.9909979967943472e+00 + 29 4.4948816191724444e-01 3.3942012039423943e+00 3.4685365598763132e-03 + 30 -1.0472698350323018e+00 4.0806056721724765e-01 -1.6032550490562876e+00 + 31 -1.4002064035600614e+00 -3.0959067091238390e+00 2.8187227270565738e+00 + 32 -2.0492058653502760e+00 -2.0855598227317866e+00 -1.3012573987817382e+00 +... diff --git a/unittest/force-styles/tests/atomic-pair-atm.yaml b/unittest/force-styles/tests/atomic-pair-atm.yaml new file mode 100644 index 0000000000..051b37f9a6 --- /dev/null +++ b/unittest/force-styles/tests/atomic-pair-atm.yaml @@ -0,0 +1,91 @@ +--- +lammps_version: 5 May 2020 +date_generated: Tue May 26 18:19:54 202 +epsilon: 5.0e-12 +prerequisites: ! | + pair atm +pre_commands: ! | + variable newton_pair delete + variable newton_pair index on +post_commands: ! "" +input_file: in.metal +pair_style: atm 12.0 5.0 +pair_coeff: ! | + * * * 25.0 +extract: ! "" +natoms: 32 +init_vdwl: 4.29790007480121 +init_coul: 0 +init_stress: ! |2- + 1.2907320878711678e+01 1.2784310537300177e+01 1.2989469257199106e+01 3.2388109042463260e-02 4.8727763023580862e-03 -4.0982848248419549e-03 +init_forces: ! |2 + 1 3.5581409515979601e-02 6.6170603930536254e-02 -1.9657602591644043e-02 + 2 -4.0181790045265731e-02 -2.0892933124588189e-02 4.3515647665365753e-02 + 3 -5.2873801996566078e-02 1.9415917918634595e-01 -3.9730705882249660e-02 + 4 4.3221201173691610e-02 -5.3912532143246582e-03 -3.2281153069682836e-02 + 5 -1.8387318177822624e-02 8.7317610234375787e-02 2.7969018153540259e-02 + 6 2.6185663882376260e-02 3.5171102644862277e-02 -5.1219375613743021e-03 + 7 -3.1490819881942640e-02 6.5956101386308016e-02 6.8677867158615392e-03 + 8 -1.9771689987523610e-02 -3.7594921850371769e-02 -8.4307495282797650e-03 + 9 4.7919820371530121e-04 -5.9529779739449271e-02 4.5230340595518318e-03 + 10 -3.8804555986763328e-02 -4.6922196051675163e-02 -1.0797129016352182e-01 + 11 -3.2826076903999080e-02 -7.5503308259920576e-02 1.1970705076231533e-02 + 12 -2.4613812864747092e-02 -6.7239447290304469e-02 -9.0121820237178494e-03 + 13 2.7089300794964806e-03 -1.4528071587921704e-02 -2.7347662355917620e-02 + 14 2.7986260739369110e-02 -6.5461527447112561e-02 7.5534446982419956e-02 + 15 1.9271005231787620e-03 7.2359472904105380e-03 -3.0781693569678650e-02 + 16 1.1687070682628822e-01 -6.4312104712192772e-02 2.1309553149323875e-02 + 17 1.0888534531464095e-02 1.0454723570267324e-01 3.5614863964300483e-02 + 18 -9.1983745551187018e-02 3.5982768868181726e-02 -6.5770192983863413e-02 + 19 -9.7745812634025681e-02 -2.8662838433594975e-02 4.2884191392092347e-02 + 20 6.6929579981924369e-03 -1.1324028905164241e-03 1.4621781626674010e-02 + 21 9.8648813214533046e-02 3.7753727846415210e-02 -2.4132398124233179e-02 + 22 7.8439198831445310e-03 -6.0335873260805896e-02 1.9437161621838246e-02 + 23 4.6614292744932499e-02 1.1857041206603151e-01 -3.3964248081929875e-02 + 24 7.7454114924576462e-02 5.7378617647303773e-02 5.6931300289059149e-02 + 25 6.9887613104710547e-02 -4.2398102358800677e-02 -3.5028752068428398e-02 + 26 -1.6224830127918644e-02 -1.1761564791910283e-01 1.0092892057253366e-01 + 27 1.4972600768275168e-02 2.8960710760345877e-02 1.1372156522297028e-02 + 28 8.8185313442822003e-02 2.8854403352889186e-03 4.1475457222057879e-02 + 29 -1.5664166042089471e-02 4.4232213894541059e-02 -5.4316410243832438e-03 + 30 -5.4737231063771909e-02 -7.4768574267284921e-04 -7.9319198647640782e-02 + 31 -1.6935816002065361e-02 -1.0547543496314456e-01 5.0982604012348082e-02 + 32 -1.2390716429105794e-01 -7.2578142947119742e-02 -4.1957221348949782e-02 +run_vdwl: 4.29678520905175 +run_coul: 0 +run_stress: ! |2- + 1.2902501676629520e+01 1.2783007042632454e+01 1.2985558162203775e+01 3.1902451318206584e-02 4.9692682027741341e-03 -4.5841675964141118e-03 +run_forces: ! |2 + 1 3.3734691997181203e-02 6.5926666157357816e-02 -2.0212661794738487e-02 + 2 -4.0243038944484999e-02 -2.0489733787140557e-02 4.3944476008022572e-02 + 3 -5.2124466923619217e-02 1.9244290660437285e-01 -4.0102595899321400e-02 + 4 4.3912830867371563e-02 -5.0564625615345709e-03 -3.2091995790436166e-02 + 5 -1.8276949365810320e-02 8.6512717045277576e-02 2.8791766737910139e-02 + 6 2.6660132934969657e-02 3.4027933791671121e-02 -6.0675731973441971e-03 + 7 -3.1808400382727343e-02 6.6249693662560338e-02 5.5345909483010495e-03 + 8 -2.0612413489651919e-02 -3.7877790722024657e-02 -8.5691734712158591e-03 + 9 1.2263382774671270e-03 -5.9895799055484623e-02 4.0588659240649401e-03 + 10 -3.7440753216426176e-02 -4.6456691559416383e-02 -1.0636399332268090e-01 + 11 -3.2661856092849051e-02 -7.5500387920977463e-02 1.1885632033435473e-02 + 12 -2.3166162640220526e-02 -6.6740696046220585e-02 -9.2808128163209339e-03 + 13 1.7535325333773860e-03 -1.4604621599631754e-02 -2.7610891988407594e-02 + 14 2.8149735580433134e-02 -6.3563214206855748e-02 7.4492378499084966e-02 + 15 2.4305838534998442e-03 7.1135700954773600e-03 -3.0207324091680986e-02 + 16 1.1449426216077799e-01 -6.3461697505436884e-02 2.0756074304336219e-02 + 17 1.1714556130218040e-02 1.0446430266193403e-01 3.6365861543390894e-02 + 18 -9.2367659037495664e-02 3.6774544203677408e-02 -6.6049192627083544e-02 + 19 -9.7706710589851697e-02 -2.9443191787610248e-02 4.2123682373641815e-02 + 20 5.8042341223428712e-03 -1.2104389541143005e-03 1.4565283993158821e-02 + 21 9.7577971934171351e-02 3.6678603760412057e-02 -2.4126944368435588e-02 + 22 8.4457546203480730e-03 -5.9921078808321059e-02 2.0335050625926256e-02 + 23 4.7688299465539027e-02 1.1877198168582574e-01 -3.2379193036300082e-02 + 24 7.7970150423267132e-02 5.7667199610007810e-02 5.7146883072702444e-02 + 25 7.0271860854181273e-02 -4.2706597092193072e-02 -3.4975460737548668e-02 + 26 -1.5841314381102450e-02 -1.1690659586025803e-01 1.0077570722559201e-01 + 27 1.5231359666175337e-02 2.9284322474196281e-02 1.0711563735310445e-02 + 28 8.8436437677884325e-02 3.5038915629166797e-03 4.1361615934702271e-02 + 29 -1.6414684901000294e-02 4.4551861225322273e-02 -4.6093104191993100e-03 + 30 -5.5028163808135369e-02 -1.3942838232525647e-03 -7.8635287340677290e-02 + 31 -1.7126389022898446e-02 -1.0598042766439184e-01 5.0743125098716896e-02 + 32 -1.2468377030293323e-01 -7.2760485586144660e-02 -4.2310147156906106e-02 +... diff --git a/unittest/force-styles/tests/atomic-pair-eam_cd.yaml b/unittest/force-styles/tests/atomic-pair-eam_cd.yaml new file mode 100644 index 0000000000..963d167183 --- /dev/null +++ b/unittest/force-styles/tests/atomic-pair-eam_cd.yaml @@ -0,0 +1,90 @@ +--- +lammps_version: 5 May 2020 +date_generated: Tue May 26 20:03:05 202 +epsilon: 5e-12 +prerequisites: ! | + pair eam/cd +pre_commands: ! "" +post_commands: ! | + change_box all x final 0 10 y final 0 10 z final 0 10 +input_file: in.metal +pair_style: eam/cd +pair_coeff: ! | + * * FeCr.cdeam Fe Cr +extract: ! "" +natoms: 32 +init_vdwl: -77.4194811493259 +init_coul: 0 +init_stress: ! |2- + 2.9506366554526057e+01 2.9183156291462467e+01 2.2317338076293908e+01 7.8583791220531909e+00 -9.3405164902515037e-01 8.4666514895851674e-01 +init_forces: ! |2 + 8 -2.4869435740552553e-01 -1.5298234036351193e+00 -5.6136782868493929e-01 + 11 -7.8479707378783470e-01 -6.2993144003952650e-01 6.3942912806742538e-02 + 13 5.1991737344816569e-01 6.7753655352037012e-01 -4.2253607965493278e-01 + 18 -3.9298044850749392e+00 -1.5616705686457237e+00 -1.9169690454319406e+00 + 29 1.4880693724627443e+00 3.4962901394738459e+00 -3.6870129713529731e-01 + 4 4.2543046025430409e-01 -9.7237717899675247e-01 -9.7112607187150968e-01 + 9 -4.2108161421119106e-01 -2.9949246698097637e-01 -9.3932212660285425e-02 + 15 -7.7157402671072195e-01 1.5433523699023526e+00 -1.1154686038399619e+00 + 22 -2.8479665623063127e-01 -2.0662756239881088e+00 8.5531412410115235e-02 + 25 2.5703560958845761e+00 1.5017045624035867e+00 -1.2891287546837082e-01 + 3 -9.4232987410053415e-01 1.1082132149610051e+00 -6.0528613124462960e-01 + 10 -2.8152383871264947e-01 -1.1137434307914110e-01 -7.1867606993919331e-01 + 16 2.3792194263108479e+00 -1.1517250843115308e+00 -8.5608007405620912e-01 + 21 1.5557741490667962e+00 1.8190718432784665e+00 1.1512890981095971e+00 + 26 -1.5195238476052606e+00 -1.6777841889809055e+00 1.0403478088066254e+00 + 7 -1.1000745798633114e+00 1.2927057431364277e+00 -5.4805856173194900e-01 + 12 1.6023499560633787e+00 -9.5043452748253199e-01 -5.8226183937413556e-01 + 17 4.6467342830101427e-01 1.9805101621906501e-01 9.4641157980653201e-01 + 30 -4.8386802956274799e-01 6.7845093285518510e-01 -7.2822185494105651e-01 + 2 -9.3562102233278960e-02 -2.0977652324515267e-01 5.1464533928502443e-01 + 19 -2.4665950272560591e+00 -3.1433327291758499e+00 3.7009700107251525e-01 + 24 4.6118802386737405e+00 2.0928298665322882e+00 2.3386437310926214e+00 + 27 1.9709040039987280e-01 3.7130939148074776e-01 7.8317006742477602e-02 + 6 -5.6200074403259270e-01 6.4688841767185601e-01 -5.0452500733301775e-01 + 20 5.4305126854535335e-01 -4.8099876642087785e-01 3.1812577373055106e-01 + 31 -8.5629870279800413e-01 -1.3626475979016444e+00 2.4555267483126282e+00 + 5 -7.4535085385239097e-01 5.6462642558947163e-01 5.0796479526966876e-01 + 28 -3.6511047426411991e-01 2.5754364039640887e-01 1.2582168570354349e-01 + 32 -2.6135587355983043e+00 -1.5330500443455732e+00 -6.7557011932914857e-01 + 1 3.7884586394600017e-01 -1.7372479601338930e-02 -2.2874857959711478e-01 + 14 4.9549568226318896e-01 -4.1181460409607018e-01 1.3866568249615758e+00 + 23 1.2383913076801136e+00 1.8613074535057481e+00 -3.5687946581652624e-01 +run_vdwl: -77.65496555698 +run_coul: 0 +run_stress: ! |2- + 2.8585743222299783e+01 2.8300763599883620e+01 2.1800410375921810e+01 7.4500400291680950e+00 -1.0636039604288940e+00 8.4740666819864296e-01 +run_forces: ! |2 + 8 -2.7151053004591208e-01 -1.5287399675025755e+00 -5.4534089864381885e-01 + 11 -7.6679766845686814e-01 -6.3322365651311130e-01 4.7728049772552503e-02 + 13 5.0939531182086928e-01 6.8413494991310242e-01 -4.2098815476105311e-01 + 18 -3.6892936686513820e+00 -1.4556828938869788e+00 -1.8103278324839420e+00 + 29 1.3407876110200074e+00 3.3111406589372017e+00 -3.3732975630652123e-01 + 4 4.0807816914053147e-01 -9.4566550283660311e-01 -9.5348608946481239e-01 + 9 -4.1823699825935307e-01 -3.0754071802614963e-01 -1.1183696132595670e-01 + 15 -7.2508155408548902e-01 1.5144677531296626e+00 -1.0864955300224399e+00 + 22 -2.2054525313872317e-01 -1.9984312218234146e+00 7.1900794989121525e-02 + 25 2.4910528464915269e+00 1.4658890698067975e+00 -1.3869148162687062e-01 + 3 -9.4063283702315814e-01 1.0775755551349597e+00 -5.9775647301115542e-01 + 10 -2.5002184738752448e-01 -1.0198477234944650e-01 -6.6684588027858072e-01 + 16 2.2898405388879040e+00 -1.1378953314614961e+00 -8.4272711131861044e-01 + 21 1.4790878931837190e+00 1.7136887929621036e+00 1.1269633038157936e+00 + 26 -1.4106451720861932e+00 -1.5618537601149505e+00 9.7574227521752288e-01 + 7 -1.0741108869644040e+00 1.2831430885766124e+00 -5.4667017037232546e-01 + 12 1.5816856488010231e+00 -9.1902882640923744e-01 -5.6535909175480059e-01 + 17 4.7161383076462332e-01 1.9565174525684229e-01 9.3819195032752134e-01 + 30 -4.5762456300468696e-01 6.6407205464735841e-01 -6.9428727830465098e-01 + 2 -8.5490517434075847e-02 -2.1659172685616215e-01 5.0142370520318835e-01 + 19 -2.3085159711941969e+00 -2.9612141261464395e+00 3.7188702337674601e-01 + 24 4.2941840668820070e+00 1.9468832898802828e+00 2.2380972699887196e+00 + 27 2.0890840531702448e-01 3.5786474239715432e-01 6.2130307644364287e-02 + 6 -5.5245666180980457e-01 6.4138882034278044e-01 -4.8007835354561723e-01 + 20 5.3179718158105560e-01 -4.7602396117212981e-01 3.0623145836571120e-01 + 31 -8.1236514734795273e-01 -1.3407493053805772e+00 2.3754011704155875e+00 + 5 -7.2493198432645400e-01 5.4807444983935638e-01 4.8889246609771136e-01 + 28 -3.7176754911744125e-01 2.5654240520686689e-01 1.3306741973778954e-01 + 32 -2.5983287754819857e+00 -1.4915067587850344e+00 -6.6646013114343972e-01 + 1 3.4169448683529990e-01 -3.1004791972686529e-02 -2.4769580345365880e-01 + 14 5.0573882893138455e-01 -3.8622187936633440e-01 1.3985322998607304e+00 + 23 1.2244927661586273e+00 1.8328418245722449e+00 -3.2381249699480508e-01 +... diff --git a/unittest/force-styles/tests/atomic-pair-eam_cd_old.yaml b/unittest/force-styles/tests/atomic-pair-eam_cd_old.yaml new file mode 100644 index 0000000000..caaf7a2567 --- /dev/null +++ b/unittest/force-styles/tests/atomic-pair-eam_cd_old.yaml @@ -0,0 +1,90 @@ +--- +lammps_version: 5 May 2020 +date_generated: Thu May 28 06:23:01 202 +epsilon: 5e-12 +prerequisites: ! | + pair eam/cd/old +pre_commands: ! "" +post_commands: ! | + change_box all x final 0 10 y final 0 10 z final 0 10 +input_file: in.metal +pair_style: eam/cd/old +pair_coeff: ! | + * * FeCr.cdeam Fe Cr +extract: ! "" +natoms: 32 +init_vdwl: -77.3566448928927 +init_coul: 0 +init_stress: ! |2- + 2.9405509133096274e+01 2.9077568336065784e+01 2.2113739361139935e+01 7.8904933627522267e+00 -9.3663625990408816e-01 8.1130320719355153e-01 +init_forces: ! |2 + 8 -2.4395655011794004e-01 -1.5333218084741596e+00 -5.5245484545491697e-01 + 11 -7.8706069939087697e-01 -6.3256079782490671e-01 5.4125643283892681e-02 + 13 5.1518155226706963e-01 6.8274677994766197e-01 -4.2850986846545980e-01 + 18 -3.9256582801572564e+00 -1.5618588551742114e+00 -1.9139821131009855e+00 + 29 1.4999378064208269e+00 3.4792718713414832e+00 -3.6648974322266664e-01 + 4 4.2464232689549453e-01 -9.7164204677538535e-01 -9.7219077261848585e-01 + 9 -4.1883835783416828e-01 -2.9640623407730660e-01 -9.3659089760684641e-02 + 15 -7.7638636434137465e-01 1.5329378947070542e+00 -1.1035208637789840e+00 + 22 -2.8700086895519467e-01 -2.0643765194685284e+00 8.5229634089584366e-02 + 25 2.5743829864820831e+00 1.5066523137107746e+00 -1.2624906599123387e-01 + 3 -9.0726681299683187e-01 1.0619426753822845e+00 -5.8362819906686325e-01 + 10 -2.7746664677947930e-01 -9.9414875982860917e-02 -6.9345163681304967e-01 + 16 2.3481539742343385e+00 -1.1310953819765714e+00 -8.5356283146096967e-01 + 21 1.5363256394734701e+00 1.8113878750853332e+00 1.1372797726733304e+00 + 26 -1.5263877243918971e+00 -1.6426898707601700e+00 1.0185360426954311e+00 + 7 -1.0984506174307791e+00 1.2895286552767053e+00 -5.4447897480978547e-01 + 12 1.6057913185256654e+00 -9.4698230673325845e-01 -5.8571244556639712e-01 + 17 4.6309553650227248e-01 1.9577141871283613e-01 9.4588389196297584e-01 + 30 -4.8103274177570204e-01 6.7765823339012321e-01 -7.2776907743413610e-01 + 2 -9.6746966328518896e-02 -2.0660058647238458e-01 5.1376678118360786e-01 + 19 -2.4660378601709181e+00 -3.1428997639171015e+00 3.6929505266594292e-01 + 24 4.6125255774631988e+00 2.0934708458658551e+00 2.3354130173781136e+00 + 27 1.6537006967519022e-01 4.0030582114974539e-01 7.6202897807556333e-02 + 6 -5.5673454781795384e-01 6.4352466176927337e-01 -5.0416324732898266e-01 + 20 5.3753132262499415e-01 -4.8016263425435718e-01 3.2102890572308612e-01 + 31 -8.5335875768564051e-01 -1.3518208677019026e+00 2.4663641279666662e+00 + 5 -7.4639221870381012e-01 5.6748273743689703e-01 5.0398965766459269e-01 + 28 -3.3427836201448913e-01 2.2430792656431101e-01 1.1564659047727996e-01 + 32 -2.6142628689137353e+00 -1.5189868845729886e+00 -6.7390297673000232e-01 + 1 3.7750702521380647e-01 -1.2775122604877289e-02 -2.3192012230744505e-01 + 14 4.9905260884493080e-01 -4.3548863736972288e-01 1.3704420563876023e+00 + 23 1.2378195011832249e+00 1.8620934838003551e+00 -3.5755819804861416e-01 +run_vdwl: -77.5908146669562 +run_coul: 0 +run_stress: ! |2- + 2.8485191578893058e+01 2.8198695634641155e+01 2.1600480977108983e+01 7.4831961344053015e+00 -1.0657036014691093e+00 8.1083296213634959e-01 +run_forces: ! |2 + 8 -2.6687662328951439e-01 -1.5323983128806480e+00 -5.3650003340444363e-01 + 11 -7.6894416406912669e-01 -6.3558503412677736e-01 3.8197957557271150e-02 + 13 5.0470405196269419e-01 6.8947168162484451e-01 -4.2691120946149397e-01 + 18 -3.6854522670425158e+00 -1.4559988082140753e+00 -1.8074005610504837e+00 + 29 1.3524738452403593e+00 3.2946498298818288e+00 -3.3499173170850133e-01 + 4 4.0729758180114273e-01 -9.4491662268062182e-01 -9.5450134374689677e-01 + 9 -4.1599974909284382e-01 -3.0446259231679634e-01 -1.1153295601432243e-01 + 15 -7.2971570976124900e-01 1.5042763436302977e+00 -1.0747802112135652e+00 + 22 -2.2250198294686541e-01 -1.9965841181629400e+00 7.1747050733221227e-02 + 25 2.4950084662696983e+00 1.4707797579395552e+00 -1.3594695871930362e-01 + 3 -9.0534014592010392e-01 1.0332760987936294e+00 -5.7650969402625052e-01 + 10 -2.4598170004171149e-01 -9.1061063106574108e-02 -6.4286211566594620e-01 + 16 2.2585093380006076e+00 -1.1168061549089283e+00 -8.4057202310250323e-01 + 21 1.4601582272558056e+00 1.7066533856947079e+00 1.1129911037189397e+00 + 26 -1.4181737451422176e+00 -1.5291168458460618e+00 9.5602794273735947e-01 + 7 -1.0726809843117340e+00 1.2799606830754382e+00 -5.4314026901401546e-01 + 12 1.5850988167998827e+00 -9.1572194416915975e-01 -5.6882585734207169e-01 + 17 4.7006057082843539e-01 1.9337850521959463e-01 9.3772077301591306e-01 + 30 -4.5467752591799759e-01 6.6316947806197213e-01 -6.9376708110580343e-01 + 2 -8.8659229971455075e-02 -2.1347769705954714e-01 5.0057777700323369e-01 + 19 -2.3079714228833410e+00 -2.9608093698018987e+00 3.7108228042443869e-01 + 24 4.2950019630782688e+00 1.9475688188592346e+00 2.2351682655037335e+00 + 27 1.7749931668796490e-01 3.8675424964670363e-01 5.9748810010048489e-02 + 6 -5.4727635910881256e-01 6.3807859667675315e-01 -4.7985870047603307e-01 + 20 5.2623598439294483e-01 -4.7516744794791216e-01 3.0914307217963943e-01 + 31 -8.0935941564949265e-01 -1.3301958218136074e+00 2.3859777045237114e+00 + 5 -7.2603632278983410e-01 5.5101408460680934e-01 4.8498734148834588e-01 + 28 -3.4089135725955205e-01 2.2341523534112284e-01 1.2257324449666285e-01 + 32 -2.5991916652162788e+00 -1.4776784092373672e+00 -6.6499163713851406e-01 + 1 3.4051925606376454e-01 -2.6258862226114895e-02 -2.5087755767694686e-01 + 14 5.0915603335540283e-01 -4.0999165632064422e-01 1.3825486730786496e+00 + 23 1.2240069186776739e+00 1.8337840117671826e+00 -3.2452205560407349e-01 +... diff --git a/unittest/force-styles/tests/atomic-pair-eim.yaml b/unittest/force-styles/tests/atomic-pair-eim.yaml new file mode 100644 index 0000000000..c3469c753a --- /dev/null +++ b/unittest/force-styles/tests/atomic-pair-eim.yaml @@ -0,0 +1,90 @@ +--- +lammps_version: 5 May 2020 +date_generated: Tue May 26 21:02:07 202 +epsilon: 5.0e-12 +prerequisites: ! | + pair eim +pre_commands: ! "" +post_commands: ! | + change_box all x final 0 12 y final 0 12 z final 0 12 +input_file: in.metal +pair_style: eim +pair_coeff: ! | + * * Na Li ffield.eim Li Na +extract: ! "" +natoms: 32 +init_vdwl: 156.973813987572 +init_coul: 0 +init_stress: ! |2- + 3.9849889936779880e+02 3.9964339700077471e+02 4.2394135449088486e+02 1.1463564258428973e+00 -1.0274413432821488e+01 -1.2970065269285907e+01 +init_forces: ! |2 + 8 -2.8632005169579426e+00 -1.6766282379761009e+01 -8.1471344951824900e+00 + 10 -4.8546946398502202e+00 -1.3790722326676514e+00 -1.3182700977635438e+01 + 11 -1.0981906235035666e+01 -5.1015254568696760e+00 -2.5796201204013713e+00 + 13 1.5877127067226078e+00 1.9219788099814936e+00 -1.1898492474856633e+01 + 15 -2.6043922776971544e+00 5.3413920818526606e+00 -1.0199039019525202e+01 + 16 9.7874817215382581e+00 -1.5640930463156417e+00 -6.6704345097904190e+00 + 18 -1.8781447727003574e+01 -6.6630071844661121e+00 -1.0192218659089560e+01 + 19 -8.3573166826006791e+00 -1.7180346896228524e+01 1.1259223718469038e+00 + 22 1.3536487384998078e-01 -1.8377174710391476e+01 -3.4375187701989057e-01 + 24 1.1702112629407399e+01 -2.4848776724901764e+00 8.8024800077902068e+00 + 26 -8.1949807620733015e+00 -4.8970960289285559e+00 7.5536629924560534e+00 + 27 -8.4464677543434741e-01 2.7187496116070875e+00 4.1344397017621617e+00 + 28 -8.6900542631052939e+00 4.9817111409224157e+00 2.1532978415328961e+00 + 29 -9.2375710858498161e-01 9.8618185495357658e+00 -1.1746348549053547e-01 + 30 -4.4268691057672088e-01 1.8614184084637593e+00 -3.0635131466682086e+00 + 31 3.1796191004214864e+00 -2.9038638862283421e+00 1.3534160908852291e+01 + 32 -1.5023162437974118e+01 -1.0281185077172976e+00 1.4167924044403386e+00 + 4 9.3349085217471437e+00 -1.2787267197039046e+01 -7.6473646661322343e+00 + 9 3.4234677991506528e+00 -2.2025093327039980e-01 -9.0172545500186239e+00 + 12 1.1263174501949301e+01 1.3836384497831720e+00 -6.2834767763588353e+00 + 20 1.1686413089339482e+01 -6.7833853951212770e+00 5.1663329889591179e+00 + 25 2.0519654777845975e+01 7.3223829469595536e+00 3.2684335271918572e+00 + 3 -1.1101970578199474e+01 1.6991567119823866e+01 -4.2931181929953039e+00 + 7 -2.1987726630646489e+00 1.0711163729951210e+01 -8.9882820833406658e+00 + 21 3.8229744792438023e+00 1.2903312167530217e+01 7.6107607924495237e+00 + 23 2.9632226502433872e+00 1.4845062813941942e+01 -3.6524486544817436e+00 + 17 1.0466913935945506e+01 8.1533909235111164e+00 4.0039456239232676e+00 + 2 -4.6058350759501634e+00 -1.7696222429563585e-01 1.2835247737947871e+01 + 6 -1.9817602093898685e+00 -1.4698920165672564e+00 8.3864236036495630e+00 + 14 3.3772891513336045e+00 -9.2509023857225525e+00 1.7056604095516764e+01 + 5 -8.8100786145124399e+00 6.8938393850433055e+00 5.7845676003837783e+00 + 1 8.0103535392720087e+00 3.1426920151730635e+00 3.4432414902845636e+00 +run_vdwl: 122.202735196696 +run_coul: 0 +run_stress: ! |2- + 3.4380556379381511e+02 3.4108042955292865e+02 3.6400846317693936e+02 4.9614126800758174e-01 -9.9439839758416682e+00 -1.1841677419289216e+01 +run_forces: ! |2 + 8 -2.7659955642929752e+00 -1.3971135305951176e+01 -7.8342515967184339e+00 + 10 -3.3257144845831861e+00 -5.8510594418036477e-01 -9.2686733430468120e+00 + 11 -8.3892766023939860e+00 -3.0246878402629132e+00 -2.9027093347714379e+00 + 13 9.0226620749142450e-01 1.0044404705860035e+00 -9.4069063946105551e+00 + 15 -1.0208202060412843e+00 4.1422863614573080e+00 -9.0440067304128231e+00 + 16 4.0045475207907701e+00 -1.6120893712409301e-01 -4.7527492142657453e+00 + 18 -1.5811894747868804e+01 -5.7642264133192471e+00 -7.6690034686865598e+00 + 19 -6.9307071966841525e+00 -1.4663516993961514e+01 1.0223899016280067e+00 + 22 1.0600019847250368e+00 -1.5642060404695211e+01 -1.0267971561794753e+00 + 24 8.2900528878653095e+00 -2.5851699687669250e+00 7.4423513246948509e+00 + 26 -4.5801163729457857e+00 -1.3117973025687979e+00 1.8620718510196819e+00 + 27 -1.0168776045802588e+00 5.7619619612797357e-01 4.0239087026639924e+00 + 28 -9.5036762856329151e+00 4.7848406477520644e+00 2.8493906400405771e+00 + 29 -1.3627559888275171e+00 7.3299392964025669e+00 -9.1918490541258902e-01 + 30 7.3706368544374035e-01 3.7909839787461745e+00 -2.0812605330187393e+00 + 31 2.5225616441946235e+00 -1.6842946688758833e+00 1.1333524346595516e+01 + 32 -8.4661754089193586e+00 1.4669428094812473e+00 2.6279654608994747e+00 + 4 8.1080116696133544e+00 -1.0789261354289245e+01 -6.7556421479437878e+00 + 9 2.6889982519418596e+00 -4.7827118680275160e-01 -7.7051710490703158e+00 + 12 8.4999192896356810e+00 2.4240920506421961e+00 -4.3101637900279632e+00 + 20 1.0207174804826836e+01 -6.3154531879982176e+00 5.0243823168161867e+00 + 25 1.7486205632839102e+01 6.2967785926326680e+00 2.4007943747602485e+00 + 3 -7.8053297493962726e+00 1.1887214267198683e+01 -3.2460992289834332e+00 + 7 -2.8549810374112694e-01 8.2282626857675218e+00 -6.4305323521837856e+00 + 21 1.3382393279924647e+00 9.1670844574857036e+00 4.6483601255583356e+00 + 23 5.9734107032207051e-01 1.0202156536638823e+01 -1.1235706443984697e+00 + 17 7.9617411834294964e+00 5.6302197041026689e+00 2.0734601036697562e+00 + 2 -4.1577550735915674e+00 -5.7865744963177157e-01 1.1523121453859590e+01 + 6 -1.1774871337125217e+00 -1.2770796219367506e+00 7.4518654076934867e+00 + 14 2.1079055275251330e+00 -5.3042488908894585e+00 1.3182185305943696e+01 + 5 -5.9977109572586702e+00 5.0829170695584294e+00 4.3252899456557543e+00 + 1 6.0857607918334917e+00 2.1218203466742889e+00 2.6856606282317652e+00 +... diff --git a/unittest/force-styles/tests/atomic-pair-hybrid-eam.yaml b/unittest/force-styles/tests/atomic-pair-hybrid-eam.yaml index 3ccf14e304..8378d55517 100644 --- a/unittest/force-styles/tests/atomic-pair-hybrid-eam.yaml +++ b/unittest/force-styles/tests/atomic-pair-hybrid-eam.yaml @@ -1,7 +1,7 @@ --- lammps_version: 5 May 2020 date_generated: Mon May 18 14:22:49 202 -epsilon: 5e-12 +epsilon: 5.0e-12 prerequisites: ! | pair eam/fs pre_commands: ! "" diff --git a/unittest/force-styles/tests/atomic-pair-hybrid-eam_fs.yaml b/unittest/force-styles/tests/atomic-pair-hybrid-eam_fs.yaml index af0d4a29ad..29794bc9ed 100644 --- a/unittest/force-styles/tests/atomic-pair-hybrid-eam_fs.yaml +++ b/unittest/force-styles/tests/atomic-pair-hybrid-eam_fs.yaml @@ -1,7 +1,7 @@ --- lammps_version: 5 May 2020 date_generated: Mon May 18 14:23:15 202 -epsilon: 5e-12 +epsilon: 5.0e-12 prerequisites: ! | pair eam/fs pre_commands: ! "" diff --git a/unittest/force-styles/tests/atomic-pair-polymorphic_eam.yaml b/unittest/force-styles/tests/atomic-pair-polymorphic_eam.yaml new file mode 100644 index 0000000000..4edd1ac426 --- /dev/null +++ b/unittest/force-styles/tests/atomic-pair-polymorphic_eam.yaml @@ -0,0 +1,92 @@ +--- +lammps_version: 5 May 2020 +date_generated: Thu May 28 20:40:34 202 +epsilon: 1e-12 +prerequisites: ! | + pair polymorphic +pre_commands: ! | + variable newton_pair delete + variable newton_pair index on +post_commands: ! | + change_box all x final 0 18 y final 0 18 z final 0 18 +input_file: in.metal +pair_style: polymorphic +pair_coeff: ! | + * * CuTa_eam.poly Cu Ta +extract: ! "" +natoms: 32 +init_vdwl: -112.540387935517 +init_coul: 0 +init_stress: ! |2- + 1.3377418322776046e+02 1.3013604387391047e+02 1.3325935858051224e+02 1.3759975178496845e+01 -5.1138734367336625e-01 -8.4676793711767679e+00 +init_forces: ! |2 + 8 -2.2428945755373189e+00 -7.4033009258893054e+00 -3.3569122605412978e+00 + 11 -2.2492158743627382e+00 -5.3145999197784999e-01 -5.8021531673742044e-01 + 13 9.4024341587392729e-02 1.9430385765330092e+00 -2.7217771787755627e+00 + 18 -1.3683111266194363e+01 -4.0310939154243384e+00 -6.2567972447127955e+00 + 29 -3.2705040788228013e-01 1.1755074200588027e+01 -3.6942877850791345e-01 + 4 3.5920251384794515e+00 -4.8543560492093514e+00 -3.7098310564003221e+00 + 9 6.5278902431052910e-01 -4.1080503436516247e-01 -1.0739465989669055e+00 + 15 -1.6631012866658601e+00 5.5259707118640575e+00 -8.0378281678873051e+00 + 22 9.2028590714961545e-01 -1.1767883482997037e+01 -6.5352089706661676e-01 + 25 1.2100772285199820e+01 5.0819826435384030e+00 5.5995850889647503e-01 + 3 -3.3993960060133306e+00 5.7675320200190585e+00 -1.7749442267251097e+00 + 10 -7.6151995305441378e-01 -1.4898183719318012e+00 -3.5737578367712590e+00 + 16 3.5771820542441142e+00 -1.7610223782546945e+00 -1.5158002704977778e+00 + 21 2.5627124726293382e+00 2.6408685673275389e+00 2.9796448634533559e+00 + 26 -2.1607424352570717e+00 -3.9509308569028003e+00 4.1556311798004941e+00 + 7 -1.6524529987381311e+00 2.7289756091934927e+00 -2.1027161735874915e+00 + 12 3.6087174128798059e+00 -2.9258088984474795e-01 -1.8569680714945807e+00 + 17 2.8955979016474900e+00 2.1397954911122525e+00 1.3436060182985605e+00 + 30 -1.1772953098090733e+00 3.5197586410261525e+00 -3.5507225884796605e+00 + 2 -1.1774259881259390e+00 -7.3896307522828297e-01 1.9491558173232677e+00 + 19 -6.3293342539461976e+00 -8.1592946406166362e+00 1.6334019789853360e+00 + 24 9.8387195546733075e+00 2.0725630779782303e+00 8.7607267623043388e+00 + 27 1.0911673619729612e+00 8.6522540377444346e-01 5.7785580453669882e-01 + 6 -1.4997571913295353e+00 4.6207158121952879e-01 1.7915790651672241e+00 + 20 3.5440271077062615e+00 -2.1308387118890439e+00 1.2532128862707759e+00 + 31 6.9641430977980212e-01 -2.4233846293906267e+00 1.1255702676228792e+01 + 5 -1.3985000009486332e+00 9.0401150178608247e-01 5.1497955825116704e-01 + 28 -9.3144848273222586e-02 1.0519539666581097e+00 -7.2011907825660215e-01 + 32 -8.7713084366180301e+00 3.3637284067716072e-01 5.2446663030603202e-01 + 1 5.1104047916067052e-01 -2.1939944684027357e-01 8.4576032874873946e-02 + 14 1.6060668602637211e+00 -2.1413705272557282e+00 5.9289753074458167e+00 + 23 1.2947086210718493e+00 5.5113080947221302e+00 -1.4581873447345914e+00 +run_vdwl: -114.579218859094 +run_coul: 0 +run_stress: ! |2- + 1.2682783976501629e+02 1.2273466726841482e+02 1.2679647640259789e+02 1.2775833963287322e+01 -1.1864416554153783e+00 -7.7826768849259231e+00 +run_forces: ! |2 + 8 -2.2254562718397524e+00 -7.0577940840175080e+00 -3.0962690738540943e+00 + 11 -2.1929239154433446e+00 -5.3928826149999021e-01 -6.0654499237996318e-01 + 13 5.3833905841821170e-02 1.8745491522866751e+00 -2.6359286367580852e+00 + 18 -1.2358313574771616e+01 -3.6529012493973747e+00 -5.5079972779843223e+00 + 29 -5.1151379646253270e-01 1.0538375334834587e+01 -2.8672542718355953e-01 + 4 3.3538324650551039e+00 -4.4992140684738446e+00 -3.4606966129033019e+00 + 9 7.1590051950955458e-01 -4.2103946884691956e-01 -1.1456141506066282e+00 + 15 -1.4629310401742095e+00 5.0304022223617570e+00 -7.3851813747064234e+00 + 22 1.0896911108801459e+00 -1.0787930676808893e+01 -8.1418001542183371e-01 + 25 1.1168485829416628e+01 4.7097483866175471e+00 4.4664623989799684e-01 + 3 -3.1621474806768193e+00 5.2930284092497768e+00 -1.7015133774218951e+00 + 10 -7.0101615323216615e-01 -1.3515941554175164e+00 -3.3293577876623597e+00 + 16 3.2520318780195163e+00 -1.5996393571100542e+00 -1.5067493862673176e+00 + 21 2.4145324622622071e+00 2.5215587904387955e+00 2.8706167158401157e+00 + 26 -2.0718724043183725e+00 -3.5926178393787467e+00 3.8320270066646733e+00 + 7 -1.5987451653319409e+00 2.7413942248593166e+00 -2.1168147897998852e+00 + 12 3.5731246168602149e+00 -2.3462802672495844e-01 -1.8060184232978318e+00 + 17 2.8445091823292974e+00 2.0789765810758944e+00 1.3134516493575699e+00 + 30 -1.0980785799734369e+00 3.1399692933387495e+00 -3.0791049438024598e+00 + 2 -1.1289422736647199e+00 -8.0921577037559367e-01 1.8152658202464940e+00 + 19 -5.7274233665183294e+00 -7.3163054105423857e+00 1.5641743686962271e+00 + 24 8.5071019627289477e+00 1.8102333582834893e+00 7.9697162151700791e+00 + 27 1.1087347847647036e+00 7.6622506480526842e-01 5.3675592400142980e-01 + 6 -1.3876886373523303e+00 4.5387290626449639e-01 1.8317734815991413e+00 + 20 3.4092304692375435e+00 -2.0427196989538072e+00 1.1275332681388128e+00 + 31 7.4624042429388004e-01 -2.3900962747552450e+00 1.0373889218509238e+01 + 5 -1.3177311901465094e+00 8.5257263853703158e-01 5.0228895435624199e-01 + 28 -1.1362727186873163e-01 1.0342403636003235e+00 -6.9515254620422950e-01 + 32 -8.3353220233959657e+00 3.2428940106811888e-01 5.7637395907890621e-01 + 1 4.3104820933110216e-01 -2.6368885400461839e-01 6.0881198145076927e-02 + 14 1.4992490201053872e+00 -1.8390091571631242e+00 5.6335813085637065e+00 + 23 1.2261863045347119e+00 5.2282462258487570e+00 -1.2811265120115127e+00 +... diff --git a/unittest/force-styles/tests/bond-class2.yaml b/unittest/force-styles/tests/bond-class2.yaml index 88e4e33f39..58045c4c60 100644 --- a/unittest/force-styles/tests/bond-class2.yaml +++ b/unittest/force-styles/tests/bond-class2.yaml @@ -1,6 +1,6 @@ --- lammps_version: 5 May 2020 -date_generated: Mon May 18 18:18:26 202 +date_generated: Thu May 28 22:04:42 202 epsilon: 1e-13 prerequisites: ! | atom full @@ -15,6 +15,7 @@ bond_coeff: ! | 3 1.3 299.67 -501.77 679.81 4 1.2 345.00 -691.89 844.60 5 0.97 532.50 -1282.90 2004.76 +equilibrium: 1.42 1.1 1.3 1.2 0.97 extract: ! | r0 1 natoms: 29 diff --git a/unittest/force-styles/tests/bond-harmonic.yaml b/unittest/force-styles/tests/bond-harmonic.yaml index c141133470..17aa5fa69f 100644 --- a/unittest/force-styles/tests/bond-harmonic.yaml +++ b/unittest/force-styles/tests/bond-harmonic.yaml @@ -1,6 +1,6 @@ --- lammps_version: 5 May 2020 -date_generated: Mon May 18 18:18:26 202 +date_generated: Thu May 28 22:04:14 202 epsilon: 2.5e-13 prerequisites: ! | atom full @@ -15,7 +15,8 @@ bond_coeff: ! | 3 350.0 1.3 4 650.0 1.2 5 450.0 1.0 -extract: ! +equilibrium: 1.5 1.1 1.3 1.2 1 +extract: ! | kappa 1 r0 1 natoms: 29 diff --git a/unittest/force-styles/tests/bond-hybrid.yaml b/unittest/force-styles/tests/bond-hybrid.yaml index 7f70d1d8df..5ed4aaa871 100644 --- a/unittest/force-styles/tests/bond-hybrid.yaml +++ b/unittest/force-styles/tests/bond-hybrid.yaml @@ -1,6 +1,6 @@ --- lammps_version: 5 May 2020 -date_generated: Mon May 18 18:18:26 202 +date_generated: Thu May 28 22:04:30 202 epsilon: 2.5e-13 prerequisites: ! | atom full @@ -16,6 +16,7 @@ bond_coeff: ! | 3 morse 7000.0 0.2 1.3 4 harmonic 650.0 1.2 5 harmonic 450.0 1.0 +equilibrium: 1.5 1.1 1.3 1.2 1 extract: ! "" natoms: 29 init_energy: 4.63957309438403 diff --git a/unittest/force-styles/tests/bond-morse.yaml b/unittest/force-styles/tests/bond-morse.yaml index 090e3e3536..ced5851855 100644 --- a/unittest/force-styles/tests/bond-morse.yaml +++ b/unittest/force-styles/tests/bond-morse.yaml @@ -1,6 +1,6 @@ --- lammps_version: 5 May 2020 -date_generated: Mon May 18 18:18:26 202 +date_generated: Thu May 28 22:04:25 202 epsilon: 2.5e-13 prerequisites: ! | atom full @@ -15,6 +15,7 @@ bond_coeff: ! | 3 7000.0 0.2 1.3 4 7500.0 0.4 1.2 5 7000.0 0.3 1.0 +equilibrium: 1.5 1.1 1.3 1.2 1 extract: ! | r0 1 natoms: 29 diff --git a/unittest/force-styles/tests/bond-zero.yaml b/unittest/force-styles/tests/bond-zero.yaml index 12bedc6071..7f9b55aa38 100644 --- a/unittest/force-styles/tests/bond-zero.yaml +++ b/unittest/force-styles/tests/bond-zero.yaml @@ -1,6 +1,6 @@ --- lammps_version: 5 May 2020 -date_generated: Mon May 18 18:18:26 202 +date_generated: Thu May 28 22:03:25 202 epsilon: 1e-14 prerequisites: ! | atom full @@ -15,6 +15,7 @@ bond_coeff: ! | 3 1.3 4 1.2 5 1.0 +equilibrium: 1.5 1.1 1.3 1.2 1 extract: ! | r0 1 natoms: 29 diff --git a/unittest/force-styles/tests/data.airebo b/unittest/force-styles/tests/data.airebo new file mode 100644 index 0000000000..e6810b288b --- /dev/null +++ b/unittest/force-styles/tests/data.airebo @@ -0,0 +1,115 @@ +LAMMPS data file via write_data, version 5 May 2020, timestep = 100 + +48 atoms +2 atom types + +-2.4861156578082535e+00 8.9861156578082539e+00 xlo xhi +-2.4819903352214698e+00 8.9819903352214627e+00 ylo yhi +-4.3054203125591495e-02 5.1588542031255695e+00 zlo zhi + +Masses + +1 12.01 +2 1.00794 + +Atoms # atomic + +1 1 -2.4341520800875485e-01 -1.7599524940425884e-01 1.7253026363065874e-02 0 0 0 +2 2 6.2959178506621150e-01 -8.1199640633841275e-01 5.0650728892557169e+00 0 0 -1 +3 2 -1.1121054450754664e+00 -8.3279707540106163e-01 7.2096452612715661e-02 0 0 0 +4 1 -7.5984840129235773e-02 5.7591620256483522e-01 1.3343679301805187e+00 0 0 0 +5 2 8.5789395758423881e-01 1.1360995499761726e+00 1.3392878065261780e+00 0 0 0 +6 2 -8.9514139407768334e-01 1.2810979866887890e+00 1.4672917222565367e+00 0 0 0 +7 1 -7.8922730413067493e-02 -4.7479369963754220e-01 2.5185123359600543e+00 0 0 0 +8 2 6.9190595505201324e-01 -1.2323705910769223e+00 2.4967645244437549e+00 0 0 0 +9 2 -1.0542989182028326e+00 -8.6670850317437531e-01 2.7742498749957547e+00 0 0 0 +10 1 -3.9293923764317451e-01 7.9768136737711803e-01 4.0780146018561370e+00 0 0 0 +11 2 2.6489159244845972e-01 6.3268071552307958e-01 3.1065632452221319e+00 0 0 0 +12 2 -1.1276632977587033e+00 1.6002955633500584e+00 4.0362106311025991e+00 0 0 0 +25 1 2.8193998846172103e-01 4.9716388907291211e+00 1.2606338151319968e-01 0 0 0 +26 2 6.3688650225373622e-01 3.9416691414211957e+00 8.4663335521264788e-02 0 0 0 +27 2 -2.0208077533780515e+00 2.5949325118859128e+00 5.0202232238943560e+00 0 0 -1 +28 1 -7.4168338315013638e-01 5.2218024150822453e+00 1.2248307190256451e+00 0 0 0 +29 2 -4.8179493715117638e-01 6.1236479529318952e+00 1.7794910195025608e+00 0 0 0 +30 2 -1.7176232502059992e+00 5.3891340038772491e+00 7.6757849370604592e-01 0 0 0 +31 1 -8.2930357027190393e-01 4.0508256977629209e+00 2.1889173835557001e+00 0 0 0 +32 2 6.0059642714797988e-02 3.5652543084424897e+00 2.5883670569486474e+00 0 0 0 +33 2 -1.7771933013123182e+00 3.7284700023378750e+00 2.6194240236976913e+00 0 0 0 +34 1 7.0934043141810477e-01 5.8634734699961584e+00 4.4708075530959954e+00 0 0 0 +35 2 1.4298800972607446e+00 5.6733729534659272e+00 3.6739058245879264e+00 0 0 0 +36 2 3.8569508794682422e-01 6.9038536556618695e+00 4.4511164881858134e+00 0 0 0 +13 1 5.3833228071964809e+00 -7.9766421392727882e-01 4.9067271264856016e+00 0 0 -1 +14 2 6.1381564762115239e+00 -7.8202480607143987e-01 4.9424348568586329e-01 0 0 0 +15 2 4.9519600117886347e+00 -1.7940020475946012e+00 4.8110945764576156e+00 0 0 -1 +16 1 4.2645777622126220e+00 1.3426567813575572e+00 1.9093414401493067e+00 0 0 0 +17 2 5.2992823900063506e+00 1.6374691057747635e+00 1.7460953493055651e+00 0 0 0 +18 2 3.5099850408886284e+00 1.8099079050100266e+00 1.2774250930764246e+00 0 0 0 +19 1 3.8688841475335543e+00 2.3194408557219204e-01 2.9625536035071800e+00 0 0 0 +20 2 4.4341357385042519e+00 -7.1331393747926441e-01 2.5617272090593692e+00 0 0 0 +21 2 2.8376541614717623e+00 -2.2192921113968814e-01 2.5457530111814437e+00 0 0 0 +22 1 5.0378949110324136e+00 2.3252709541752614e-01 4.1826607654379533e+00 0 0 0 +23 2 5.4732646659003770e+00 1.2253893824970703e+00 4.3037885157885949e+00 0 0 0 +24 2 3.2481280364389118e+00 8.2567333665575415e-01 3.7760702420134979e+00 0 0 0 +37 1 4.1662535153421656e+00 4.5773898294151056e+00 -1.0050993206243145e-02 0 0 0 +38 2 4.9392137394956936e+00 3.8125893258627546e+00 5.2693482707363397e-02 0 0 0 +39 2 3.1995812686514005e+00 4.0802938177597321e+00 5.1370804386657056e+00 0 0 -1 +40 1 4.2110798207275053e+00 5.4794783309775354e+00 1.2640511411782265e+00 0 0 0 +41 2 5.1714048300399131e+00 5.9965367483183840e+00 1.2752754545998148e+00 0 0 0 +42 2 3.4278850616533649e+00 6.2349719582368124e+00 1.1809837259994789e+00 0 0 0 +43 1 4.0344354881156264e+00 4.7341737056781810e+00 2.5920156833691146e+00 0 0 0 +44 2 5.9018244698732047e+00 2.9062392498170997e+00 2.6599377379111933e+00 0 0 0 +45 2 3.3647742541156997e+00 3.8770609870643540e+00 2.6263801261664406e+00 0 0 0 +46 1 4.3864129291324065e+00 5.4385557345189968e+00 3.9068248851528278e+00 0 0 0 +47 2 5.4322503572891048e+00 5.7470767535646932e+00 3.8793919420623091e+00 0 0 0 +48 2 3.7782712922559569e+00 6.3393431995123084e+00 3.9888830689083061e+00 0 0 0 + +Velocities + +1 -1.0894444084053871e+00 1.2179758936956877e+00 1.1079806495668135e-01 +2 1.6877845887054355e+00 1.3056535723402372e+00 2.6561381291171191e+00 +3 -3.1125663897940310e+00 1.6529463325047355e+00 -4.0034715419532665e+00 +4 -1.1557050859943641e+00 -1.1836562561048363e+00 -1.2552320014721685e+00 +5 3.9983598869475645e+00 1.0340503455549954e+00 2.8100380170215185e+00 +6 5.1092451702327493e+00 -3.9141586462940986e-01 6.2633396565144273e-01 +7 1.0307982395927142e+00 -1.2606300928185629e-01 -2.8206938844989836e-02 +8 -6.1963844586525672e-02 1.5367728661944744e+00 -1.6165066090802973e+00 +9 5.9246559865739123e-01 1.7618681246069584e-01 -1.7712296302906054e+00 +10 2.2580329076027261e-02 -1.1064033888047093e+00 -8.4543250413064619e-01 +11 2.7527292315030985e+00 -8.4549696409899500e-01 -1.6649408346851993e+00 +12 2.2551594965037169e-01 4.0427187315766098e+00 -4.6646230929080152e+00 +25 -3.4216979727798102e-01 2.6515660067898694e-01 -4.1153207161407163e-01 +26 4.8780948317346393e+00 3.3594615440046387e+00 -1.7251088924872291e+00 +27 3.4230423525981633e+00 5.7326721971736438e-01 4.1159603478846511e+00 +28 -1.2430127296124194e+00 8.4712600153098727e-01 -1.4444463305442226e-02 +29 -4.7244436356582273e+00 4.8891316822495341e+00 -2.3254053488248032e+00 +30 -4.7413901140247372e+00 5.3815030555326331e+00 -1.0828996770519246e+00 +31 -6.2008075007494567e-01 9.1617269551362390e-01 2.3142026319364109e-01 +32 4.2266796565992841e+00 2.5453270169936268e+00 -4.8321190043502371e-01 +33 -4.6135662901311782e+00 -1.9728957639302671e+00 -3.0374188716470223e+00 +34 4.0114701075701914e-01 1.4151504196514619e-01 1.4817950597700830e-01 +35 4.1358822022551971e+00 -1.8243773216029848e+00 -7.2472363609030288e-01 +36 4.6340930144944625e+00 2.4576344600576472e+00 5.0626747539766868e+00 +13 1.8278069366103494e-01 5.2342341602105624e-01 -6.0423794796060226e-01 +14 4.9390070605030276e+00 2.1021116363725221e+00 2.0486606910290217e-01 +15 -4.9993254261382736e-01 -4.6980992366373302e+00 2.8677140594068162e+00 +16 7.8343591908967891e-01 -3.3780594158195848e-01 1.4671535586247206e+00 +17 -1.8418238503512363e+00 2.9037305513734619e+00 -4.4823250896128389e-02 +18 -1.8876740682082613e+00 3.6977793758646254e+00 -7.1976453348094083e-01 +19 1.1160256125335217e+00 -3.8469582576856409e-01 1.3566081850646794e-01 +20 -3.5794369426869292e+00 -4.2485734281342564e+00 2.5679481394581951e+00 +21 4.6400734263468575e+00 -2.7006328994236486e+00 2.5920610885986042e+00 +22 -5.2238413509963677e-01 -9.9964685063253012e-01 -4.9342929458022622e-01 +23 -1.8036726500469569e+00 -4.8244704690808271e-01 2.8954691667568189e+00 +24 3.8243074390853242e+00 2.8226264709240891e+00 -4.5665850315188749e-03 +37 1.0560596585528772e+00 -1.0741413123517354e+00 -4.6177958544062769e-01 +38 -4.3048610332410373e+00 -2.0121669185838891e+00 2.6598958497710523e+00 +39 -3.3591849767473567e+00 -9.6050957527058711e-01 -9.0169345872103590e-01 +40 1.9193383706614244e-02 1.3336541742820790e-01 9.3466008986781524e-01 +41 3.4751244640977843e+00 -1.1523945163243521e+00 -2.9448921878292245e+00 +42 2.7087738982055294e+00 9.4561842351091427e-02 8.1539452331144333e-02 +43 -4.8968596347171067e-01 5.9091455453317410e-01 1.0488500207673568e+00 +44 2.6912081704725952e+00 7.4631405042237164e-01 -4.0069184028303733e+00 +45 1.0744157293309868e+00 -4.6574530734219959e+00 -8.5404163785692366e-01 +46 -6.2272628902830041e-01 -6.8959866091615207e-01 2.0230104819190772e-01 +47 -4.9707138179571322e+00 -2.4357921349417890e+00 5.0196115666859775e+00 +48 -1.9619565986884380e+00 2.1496720750712592e+00 -3.5468158775431577e+00 diff --git a/unittest/force-styles/tests/data.manybody b/unittest/force-styles/tests/data.manybody new file mode 100644 index 0000000000..aa077ac0cf --- /dev/null +++ b/unittest/force-styles/tests/data.manybody @@ -0,0 +1,164 @@ +LAMMPS data file via write_data, version 5 May 2020, timestep = 0 + +64 atoms +8 atom types + +0.0000000000000000e+00 1.0862000000000000e+01 xlo xhi +0.0000000000000000e+00 1.0862000000000000e+01 ylo yhi +0.0000000000000000e+00 1.0862000000000000e+01 zlo zhi + +Masses + +1 28.06 +2 28.06 +3 28.06 +4 28.06 +5 28.06 +6 28.06 +7 28.06 +8 28.06 + +Pair Coeffs # zero + +1 +2 +3 +4 +5 +6 +7 +8 + +Atoms # atomic + +1 1 1.0821582679234250e+01 1.0768089890052606e+01 5.2782114154092112e-02 -1 -1 0 +2 2 1.2644623589070805e-01 2.6973866151300663e+00 2.6838404910230733e+00 0 0 0 +3 3 2.6886015615971299e+00 1.0779945762964871e+01 2.8299381505970089e+00 0 -1 0 +4 4 2.8329007005604918e+00 2.6690743201866627e+00 1.2359937723893642e-01 0 0 0 +5 5 1.5213921972716424e+00 1.2921595444932625e+00 1.3789642982618950e+00 0 0 0 +6 6 1.4860425041058531e+00 3.8853665070739183e+00 3.9153843913498028e+00 0 0 0 +7 7 4.1419871594220101e+00 1.4231884057342254e+00 3.8965351751257127e+00 0 0 0 +8 8 4.0916002382684269e+00 4.0857045774480580e+00 1.4818331695143521e+00 0 0 0 +9 1 5.4332483929070872e+00 1.8873958941024710e-01 1.4627921802284161e-01 0 0 0 +10 2 5.4368414340977749e+00 2.8924828813043342e+00 2.8667860819470539e+00 0 0 0 +11 3 8.1119493800203539e+00 1.0773000209952240e-01 2.5336452866728161e+00 0 0 0 +12 4 8.2955426243976884e+00 2.8748882519562673e+00 3.8350628986186623e-02 0 0 0 +13 5 6.7320798601505025e+00 1.3027095494870840e+00 1.4928982294197886e+00 0 0 0 +14 6 6.8742317689794499e+00 3.9653412376102484e+00 4.0506805154464347e+00 0 0 0 +15 7 9.6779045786138891e+00 1.1702527636124300e+00 4.0071980341104547e+00 0 0 0 +16 8 9.4540589455765716e+00 4.1121983054349887e+00 1.1619194458593471e+00 0 0 0 +17 1 1.0803705461284940e+01 5.2746878159845654e+00 6.1123252595366578e-02 -1 0 0 +18 2 1.4726683047938480e-01 8.0601198670201093e+00 2.5246050069821555e+00 0 0 0 +19 3 2.7558004708887545e+00 5.5610142272980951e+00 2.6646181990826121e+00 0 0 0 +20 4 2.9144739608014811e+00 8.3018591904953851e+00 1.0783914655958263e+01 0 0 -1 +21 5 1.2910071356246513e+00 6.6414284435159896e+00 1.3243501732305625e+00 0 0 0 +22 6 1.4393274075135483e+00 9.3757380802070216e+00 4.1734140393865129e+00 0 0 0 +23 7 3.8748234996653967e+00 6.6345588763271506e+00 4.1830344304096814e+00 0 0 0 +24 8 4.0077815606028455e+00 9.5761890520229667e+00 1.2373973499758391e+00 0 0 0 +25 1 5.3669071758277278e+00 5.4229041366278681e+00 1.0794824304575485e+01 0 0 -1 +26 2 5.4196958007648099e+00 8.1568234541650497e+00 2.6217941520038499e+00 0 0 0 +27 3 8.1026284023132771e+00 5.2810576792517949e+00 2.6349151849110681e+00 0 0 0 +28 4 8.1262346520143254e+00 7.9467964047716446e+00 1.0843674997034331e+01 0 0 -1 +29 5 6.9361807905637809e+00 6.6580470054546828e+00 1.4325206768451122e+00 0 0 0 +30 6 6.9233840741657815e+00 9.4991345042823276e+00 4.0971134730800349e+00 0 0 0 +31 7 9.6892812976096909e+00 6.6097689260640271e+00 3.9383403581013390e+00 0 0 0 +32 8 9.6562735184356683e+00 9.3635243482716728e+00 1.3817214020043478e+00 0 0 0 +33 1 1.0700092384318864e+01 1.8703247149802406e-02 5.3764748467288328e+00 -1 0 0 +34 2 1.0698092821152924e+01 2.7275451171938538e+00 8.1887846771042252e+00 -1 0 0 +35 3 2.5595904516932046e+00 2.8221607687054950e-02 8.0670603963325540e+00 0 0 0 +36 4 2.8214419517898661e+00 2.8818837322808726e+00 5.4423884446264195e+00 0 0 0 +37 5 1.3722461913183779e+00 1.3952374879780634e+00 6.8409604473096373e+00 0 0 0 +38 6 1.4876249878676027e+00 4.0821710907970186e+00 9.4410230254944292e+00 0 0 0 +39 7 3.9110806914297074e+00 1.3781808590946862e+00 9.6856988043922243e+00 0 0 0 +40 8 3.9440249581294013e+00 4.1879712808554626e+00 6.9093173377591039e+00 0 0 0 +41 1 5.5141663269005559e+00 1.7645621764308600e-01 5.5306499273458725e+00 0 0 0 +42 2 5.5985780491752450e+00 2.7997724883389998e+00 8.1142115135675805e+00 0 0 0 +43 3 8.0688992871690530e+00 1.6481945028752995e-01 8.2670009825157464e+00 0 0 0 +44 4 8.0871061461850093e+00 2.8829989314598494e+00 5.3855410456855504e+00 0 0 0 +45 5 6.9864811057959368e+00 1.4244451123004291e+00 6.9335024333115447e+00 0 0 0 +46 6 6.7189272164787059e+00 4.1617273576112819e+00 9.3431993728237934e+00 0 0 0 +47 7 9.3396936544866520e+00 1.2592509571339474e+00 9.6308365502537168e+00 0 0 0 +48 8 9.3844506274835222e+00 4.2051961155365900e+00 6.8071138234708295e+00 0 0 0 +49 1 1.7248042280435583e-01 5.5094660728082365e+00 5.4102856880367201e+00 0 0 0 +50 2 3.7450733705167986e-02 7.9809813827585803e+00 8.2751000234673722e+00 0 0 0 +51 3 2.7655331604154934e+00 5.5383271031991237e+00 7.9931234676757006e+00 0 0 0 +52 4 2.5155467702746610e+00 8.3325680062258929e+00 5.4759806385883039e+00 0 0 0 +53 5 1.1807952451962258e+00 6.7101860129653650e+00 6.7638199088792641e+00 0 0 0 +54 6 1.1959471910773762e+00 9.6844404374641329e+00 9.5649324596695067e+00 0 0 0 +55 7 4.1090326500366361e+00 6.9877491657431232e+00 9.6832286446741698e+00 0 0 0 +56 8 4.0458419253065214e+00 9.6567386267038486e+00 6.8650990115647899e+00 0 0 0 +57 1 5.4797685959081948e+00 5.4847914290343374e+00 5.5035477801042365e+00 0 0 0 +58 2 5.2795203845652381e+00 8.2286033879565554e+00 8.0581413858307709e+00 0 0 0 +59 3 8.0498475764577027e+00 5.3937175246191762e+00 8.3399362744881937e+00 0 0 0 +60 4 8.3304289868175641e+00 8.2409814428195727e+00 5.3806094685744537e+00 0 0 0 +61 5 6.9330690971130133e+00 6.7598151784069209e+00 6.8812034851184363e+00 0 0 0 +62 6 6.9458643451878403e+00 9.3250495720304549e+00 9.6826571158517201e+00 0 0 0 +63 7 9.3283809458502258e+00 6.9575569047261068e+00 9.4418977316662893e+00 0 0 0 +64 8 9.4282304328065276e+00 9.4433841793067455e+00 6.6169016084578596e+00 0 0 0 + +Velocities + +1 -7.6695811444905315e-01 8.8776500375415912e-01 -4.6748679865524317e-01 +2 -4.2174334498042004e-01 2.6596349461961127e-01 -1.1334804338647457e+00 +3 3.1092663150899669e+00 -3.2607896569135373e+00 -4.5472992935642453e-01 +4 -1.0033967676892164e+00 -4.0701495139485546e+00 3.0519108521711837e+00 +5 2.1876978647560312e+00 -1.8528542484907762e+00 5.5868611584263783e-01 +6 -5.8915345282488856e+00 -1.2670766284310366e+00 -1.4548236578657073e-01 +7 -7.4671607451840827e-01 -2.3224748454458921e+00 2.9040191974877243e+00 +8 8.8344717384787486e-01 2.1131388234004187e+00 -2.6319923612777498e+00 +9 -1.4945940737308610e+00 2.4036759792415352e+00 2.9873898113274451e+00 +10 -2.3062527275180000e-02 6.3069649849804210e-01 -4.6199114681815372e+00 +11 3.8719801571165269e-01 -2.6757201256087666e+00 -2.8351493398548979e+00 +12 3.1622414879535530e+00 1.1788951785955282e-01 -1.6811026088924106e+00 +13 -4.9777200700829107e+00 1.0067220620999075e-01 -1.1749631996478570e-01 +14 1.6098573779552736e+00 -1.4257777445753939e+00 9.3729752744584949e-01 +15 -1.9671428383911080e-01 -1.1467725283686230e+00 -7.1090487650568090e-01 +16 2.4293095169865944e+00 -2.2853507053089284e+00 3.6552591604907518e+00 +17 2.1486682069514684e-01 6.5398679889262946e-03 -7.8674906209013318e-01 +18 -5.9695750825985816e-01 -3.8903164843963536e+00 7.0106707544958913e-01 +19 1.8513305622305032e+00 2.7457421924307135e+00 -2.6843196517815027e-01 +20 4.6472920038025278e-02 3.3363247063995392e+00 -7.5654131995610463e-01 +21 2.0461345318527768e+00 6.5187960424485167e+00 2.2781592760522332e-01 +22 -3.2896669679401891e-01 -4.6935568644796639e+00 2.6343294291762615e-01 +23 -2.0431037382403300e-01 -1.1908279321425959e+00 -2.1024589473753172e+00 +24 -6.1675703823018013e+00 3.7268908602022122e+00 2.2946207883205223e+00 +25 9.8131185739798532e-01 1.0773612880108889e-01 1.7659001559413789e+00 +26 2.5123700267960087e+00 -9.7029098941340775e-01 -3.7611190518657027e+00 +27 -2.8065233782242118e+00 2.7735023884863090e+00 -5.7440441416815013e-01 +28 -2.8351435666922815e+00 -2.4736491871242201e+00 -2.7770228999188280e+00 +29 -6.1233333948487512e-01 -1.4612515482031314e+00 -2.1246997373192005e+00 +30 -1.6587500360685015e+00 1.2439126820981170e+00 4.6333319512528819e+00 +31 -1.6739126871847136e+00 -4.0135139175283019e+00 2.4388454178990426e+00 +32 -1.1634332347436640e+00 -7.7629078403429219e-01 1.2067789175483656e+00 +33 2.8857524470408986e+00 -1.7030276362003458e+00 -2.0845880086526334e+00 +34 3.6831626165197040e+00 -3.5993774010234549e-02 -8.0961124509532045e-01 +35 -2.8770388338755111e+00 3.9112196797609061e-01 -2.6842134469568530e+00 +36 2.3476192919341012e+00 -1.4869539504293825e+00 2.6805229608818411e+00 +37 -1.9857985903088504e+00 3.6532965667626152e+00 7.6783019003634334e-01 +38 -8.6498749460025504e-05 -1.2786473611543103e+00 -2.5574004902042100e+00 +39 3.2183147762059252e+00 2.1412145724457892e+00 -1.3379757716793121e+00 +40 -3.3194222393529000e+00 8.6217442393646981e-01 -9.7775722554209368e-02 +41 -2.4363036081885721e+00 -2.5050089095178842e+00 -1.7152684549177144e+00 +42 -1.8123025300125442e+00 4.1040607170758863e+00 1.8113434768789887e+00 +43 8.2116299357978972e-01 -1.4091949665194181e+00 1.5546533259848685e+00 +44 -1.5106466229056412e+00 -3.7176405569288479e-01 2.9687407194461857e+00 +45 2.0036640890479163e+00 3.4558719013661352e+00 2.4761488653104236e+00 +46 1.1557532358053453e-05 6.8233360706012713e-02 -8.1988351060085085e-01 +47 2.0610372874209806e+00 2.9250619947397714e+00 -4.6246198532284426e+00 +48 3.7769045376898491e+00 -6.2124369701718694e+00 6.5274567582735055e-01 +49 4.6074991208714851e+00 8.2503257645594730e-01 8.5565348020904775e-01 +50 8.5045797019446467e-01 1.5642419476572114e+00 3.4414259937041352e+00 +51 3.0951672150001852e+00 6.4364948036249203e-01 -2.5200572359688507e+00 +52 -3.4329134343428513e-01 -3.5864072102511093e+00 -1.3092330149470974e+00 +53 -4.3836593017980983e+00 -3.3032188251492345e-01 -4.2201800726103427e+00 +54 1.0067907201962536e+00 3.3833856103070516e+00 -4.2244492140600592e-01 +55 1.3872579123070348e+00 8.7826766277411539e-01 -9.4887528280134281e-01 +56 6.9357081915378493e-01 3.8110270186753179e+00 1.4629354931293179e-01 +57 6.6962746178223931e-01 6.6943282268523383e+00 9.9362589535207779e-01 +58 -1.7296381154890770e+00 -5.5052794989092768e-01 2.7151993562471821e+00 +59 1.1683811118902456e+00 -5.6097747254105945e+00 -1.3465121907588353e+00 +60 4.2289642990542493e+00 -5.3831728480380980e-01 3.0410178504652357e+00 +61 8.1393552020156468e-01 -8.8749030091659420e-01 2.4504472860529236e+00 +62 -2.4947166250287984e+00 2.8424666276480779e+00 1.1665977930274425e+00 +63 -8.7979164195267434e-01 2.3389132899677176e+00 3.8359678050967816e-01 +64 -3.3977492794459896e+00 -1.2790636562498856e+00 -2.8439591835333616e-01 diff --git a/unittest/force-styles/tests/data.manybody-charge b/unittest/force-styles/tests/data.manybody-charge new file mode 100644 index 0000000000..fe01164e68 --- /dev/null +++ b/unittest/force-styles/tests/data.manybody-charge @@ -0,0 +1,104 @@ +LAMMPS data file. CGCMM style. atom_style charge generated by VMD/TopoTools v1.8 on Tue May 26 19:18:49 EDT 2020 + 64 atoms + 0 bonds + 0 angles + 0 dihedrals + 0 impropers + 8 atom types + 0 bond types + 0 angle types + 0 dihedral types + 0 improper types + -0.668313 10.193687 xlo xhi + -0.635735 10.226265 ylo yhi + -0.627193 10.234807 zlo zhi + +# Pair Coeffs +# +# 1 1 +# 2 2 +# 3 3 +# 4 4 +# 5 5 +# 6 6 +# 7 7 +# 8 8 + + Masses + + 1 28.059999 # 1 + 2 28.059999 # 2 + 3 28.059999 # 3 + 4 28.059999 # 4 + 5 28.059999 # 5 + 6 28.059999 # 6 + 7 28.059999 # 7 + 8 28.059999 # 8 + + Atoms # charge + +1 1 0.000000 -0.040417 -0.093910 0.052782 # 1 +2 2 0.000000 0.126446 2.697387 2.683841 # 2 +3 3 0.000000 2.688601 -0.082054 2.829938 # 3 +4 4 0.000000 2.832901 2.669074 0.123599 # 4 +5 5 0.000000 1.521392 1.292160 1.378964 # 5 +6 6 0.000000 1.486042 3.885366 3.915384 # 6 +7 7 0.000000 4.141987 1.423188 3.896535 # 7 +8 8 0.000000 4.091600 4.085705 1.481833 # 8 +9 1 0.000000 5.433249 0.188740 0.146279 # 1 +10 2 0.000000 5.436841 2.892483 2.866786 # 2 +11 3 0.000000 8.111949 0.107730 2.533645 # 3 +12 4 0.000000 8.295543 2.874888 0.038351 # 4 +13 5 0.000000 6.732080 1.302710 1.492898 # 5 +14 6 0.000000 6.874232 3.965341 4.050681 # 6 +15 7 0.000000 9.677904 1.170253 4.007198 # 7 +16 8 0.000000 9.454059 4.112198 1.161919 # 8 +17 1 0.000000 -0.058295 5.274688 0.061123 # 1 +18 2 0.000000 0.147267 8.060120 2.524605 # 2 +19 3 0.000000 2.755800 5.561014 2.664618 # 3 +20 4 0.000000 2.914474 8.301859 -0.078085 # 4 +21 5 0.000000 1.291007 6.641428 1.324350 # 5 +22 6 0.000000 1.439327 9.375738 4.173414 # 6 +23 7 0.000000 3.874824 6.634559 4.183034 # 7 +24 8 0.000000 4.007782 9.576189 1.237397 # 8 +25 1 0.000000 5.366907 5.422904 -0.067176 # 1 +26 2 0.000000 5.419696 8.156823 2.621794 # 2 +27 3 0.000000 8.102629 5.281058 2.634915 # 3 +28 4 0.000000 8.126235 7.946796 -0.018325 # 4 +29 5 0.000000 6.936181 6.658047 1.432521 # 5 +30 6 0.000000 6.923384 9.499134 4.097114 # 6 +31 7 0.000000 9.689281 6.609769 3.938340 # 7 +32 8 0.000000 9.656274 9.363524 1.381721 # 8 +33 1 0.000000 -0.161908 0.018703 5.376475 # 1 +34 2 0.000000 -0.163907 2.727545 8.188785 # 2 +35 3 0.000000 2.559590 0.028222 8.067060 # 3 +36 4 0.000000 2.821442 2.881884 5.442389 # 4 +37 5 0.000000 1.372246 1.395237 6.840961 # 5 +38 6 0.000000 1.487625 4.082171 9.441023 # 6 +39 7 0.000000 3.911081 1.378181 9.685699 # 7 +40 8 0.000000 3.944025 4.187971 6.909317 # 8 +41 1 0.000000 5.514166 0.176456 5.530650 # 1 +42 2 0.000000 5.598578 2.799773 8.114211 # 2 +43 3 0.000000 8.068899 0.164819 8.267001 # 3 +44 4 0.000000 8.087106 2.882999 5.385541 # 4 +45 5 0.000000 6.986481 1.424445 6.933502 # 5 +46 6 0.000000 6.718927 4.161727 9.343200 # 6 +47 7 0.000000 9.339694 1.259251 9.630836 # 7 +48 8 0.000000 9.384451 4.205196 6.807114 # 8 +49 1 0.000000 0.172480 5.509466 5.410285 # 1 +50 2 0.000000 0.037451 7.980981 8.275100 # 2 +51 3 0.000000 2.765533 5.538327 7.993124 # 3 +52 4 0.000000 2.515547 8.332568 5.475981 # 4 +53 5 0.000000 1.180795 6.710186 6.763820 # 5 +54 6 0.000000 1.195947 9.684441 9.564933 # 6 +55 7 0.000000 4.109033 6.987749 9.683228 # 7 +56 8 0.000000 4.045842 9.656738 6.865099 # 8 +57 1 0.000000 5.479769 5.484791 5.503548 # 1 +58 2 0.000000 5.279521 8.228603 8.058142 # 2 +59 3 0.000000 8.049848 5.393717 8.339936 # 3 +60 4 0.000000 8.330429 8.240981 5.380610 # 4 +61 5 0.000000 6.933069 6.759815 6.881204 # 5 +62 6 0.000000 6.945864 9.325049 9.682657 # 6 +63 7 0.000000 9.328381 6.957557 9.441897 # 7 +64 8 0.000000 9.428230 9.443384 6.616901 # 8 + diff --git a/unittest/force-styles/tests/in.airebo b/unittest/force-styles/tests/in.airebo new file mode 100644 index 0000000000..d7d6f86f96 --- /dev/null +++ b/unittest/force-styles/tests/in.airebo @@ -0,0 +1,16 @@ +variable newton_pair index on +variable newton_bond index on +variable units index metal +variable input_dir index . +variable data_file index ${input_dir}/data.airebo +variable pair_style index 'zero 8.0' + +atom_style atomic +atom_modify map array +neigh_modify delay 2 every 2 check no +timestep 0.0005 +units ${units} +newton ${newton_pair} ${newton_bond} + +pair_style ${pair_style} +read_data ${data_file} diff --git a/unittest/force-styles/tests/in.manybody b/unittest/force-styles/tests/in.manybody new file mode 100644 index 0000000000..b26936784b --- /dev/null +++ b/unittest/force-styles/tests/in.manybody @@ -0,0 +1,16 @@ +variable newton_pair index on +variable newton_bond index on +variable units index metal +variable input_dir index . +variable data_file index ${input_dir}/data.manybody +variable pair_style index 'zero 8.0' + +atom_style atomic +atom_modify map array +neigh_modify delay 2 every 2 check no +timestep 0.0001 +units ${units} +newton ${newton_pair} ${newton_bond} + +pair_style ${pair_style} +read_data ${data_file} diff --git a/unittest/force-styles/tests/in.manybody-charge b/unittest/force-styles/tests/in.manybody-charge new file mode 100644 index 0000000000..f9ca8816f0 --- /dev/null +++ b/unittest/force-styles/tests/in.manybody-charge @@ -0,0 +1,16 @@ +variable newton_pair index on +variable newton_bond index on +variable units index metal +variable input_dir index . +variable data_file index ${input_dir}/data.manybody-charge +variable pair_style index 'zero 8.0' + +atom_style charge +atom_modify map array +neigh_modify delay 2 every 2 check no +timestep 0.0001 +units ${units} +newton ${newton_pair} ${newton_bond} + +pair_style ${pair_style} +read_data ${data_file} diff --git a/unittest/force-styles/tests/manybody-pair-airebo.yaml b/unittest/force-styles/tests/manybody-pair-airebo.yaml new file mode 100644 index 0000000000..5c0da81381 --- /dev/null +++ b/unittest/force-styles/tests/manybody-pair-airebo.yaml @@ -0,0 +1,123 @@ +--- +lammps_version: 5 May 2020 +date_generated: Wed May 27 16:13:46 202 +epsilon: 2e-7 +prerequisites: ! | + pair airebo +pre_commands: ! | + variable newton_pair delete + variable newton_pair index on +post_commands: ! "" +input_file: in.airebo +pair_style: airebo 3.0 1 1 +pair_coeff: ! | + * * CH.airebo C H +extract: ! "" +natoms: 48 +init_vdwl: -184.951215338583 +init_coul: 0 +init_stress: ! |2- + 9.0890487540552234e-02 5.6086429553227568e-01 2.1197563114732207e-01 1.4104429996380902e-01 1.4152302642812123e-01 9.2650318538687204e-01 +init_forces: ! |2 + 1 8.0445098702263997e-03 8.8637342321642477e-03 7.9370914431606456e-03 + 2 7.3942077145426480e-04 -1.5836483503449159e-02 1.4455583179877503e-02 + 3 -1.8733284429445950e-02 3.0633584100819723e-02 -4.8704635212019239e-03 + 4 5.5107808376383179e-03 -9.3517479290550678e-03 5.4116855126747517e-05 + 5 1.7335625961861563e-02 -1.3790958304619322e-02 1.7759552343702956e-02 + 6 -2.0462842106868809e-03 -1.2419421765559397e-02 1.0506397047082559e-02 + 7 -1.5825368937762482e-01 -4.7929841314322691e-01 -2.7555752286490282e-01 + 8 7.2556741066172872e-03 -6.2665679124310524e-03 -1.3275912983560631e-02 + 9 -1.9888402254035150e-02 -2.4174414683628364e-02 -3.3455936336250644e-02 + 10 2.7135056702712605e-02 3.5419388439985759e-02 3.6881290892835900e-02 + 11 5.2786515239602615e-02 4.5232747763254749e-01 2.0143778501318141e-01 + 12 -1.3587311593963690e-02 5.2747472177613443e-03 7.8730106343171277e-02 + 25 -1.4236876677876844e-02 -8.7145855177811534e-03 1.4530082980973478e-02 + 26 -6.9353447717636378e-03 -5.4658022818302411e-03 1.0919180432182594e-02 + 27 2.8680768312074813e-02 -4.2389957664550303e-02 -4.4718283685937998e-02 + 28 1.5505654369865249e-03 2.0311951864006410e-03 -1.3111838688803234e-02 + 29 2.3095293880332123e-02 1.4302833135070145e-02 -5.3918365556458230e-02 + 30 -1.8081699216798707e-02 -1.9212566259036515e-03 3.1153446323732618e-02 + 31 1.4356001380203071e-02 -2.6069899525343415e-04 -4.3953834348586657e-02 + 32 1.7903711503520440e-02 1.7912670869351718e-02 -3.0587054548599956e-02 + 33 1.3917567086515524e-03 2.6393313057161052e-02 -5.2132293141950378e-02 + 34 -3.1771367322591573e-02 1.4793725813198566e-02 4.0350312463455995e-02 + 35 -4.3104368125507213e-02 -3.3015130699775644e-02 6.5548374282321131e-02 + 36 -9.8548912590153710e-03 2.3913427800464713e-02 2.6810099505576258e-02 + 13 -1.2507751483945622e-02 -1.6077922930149865e-02 -4.0766638666415417e-02 + 14 -1.8541175418693236e-02 2.8024212503724114e-02 -5.4408810588732683e-02 + 15 1.4778056088016463e-02 -3.4284884444071559e-02 -2.6926360961490533e-02 + 16 1.1682520558454540e-02 -3.4803375161147959e-03 3.7313458006501619e-02 + 17 1.4492245755486710e-02 -1.3845110766828260e-02 1.6103567776786176e-02 + 18 -7.1763609843851842e-03 -3.0161738206889381e-02 4.9477423111201957e-02 + 19 1.3278263169619262e-02 -2.1923284934318751e-03 9.8503521559582616e-03 + 20 3.6694164712439539e-02 -3.0742875397548356e-03 3.6928879888744472e-02 + 21 1.0532660003247417e-02 -2.8766223079886910e-02 2.7300164664698715e-02 + 22 -1.9759228194633697e-03 2.1833972167343554e-03 -1.9189541028449969e-02 + 23 -6.0033660801034859e-03 4.6415206482854797e-03 -1.2173650358869588e-02 + 24 1.8289297203356290e-02 3.2292794912946468e-02 -3.1779548830552028e-02 + 37 -5.3749623436340540e-03 2.9367809115355761e-03 1.1488795653112617e-04 + 38 3.0850541467722834e-03 -4.0744480202252169e-03 -1.6187312210134541e-02 + 39 -2.0711633525865154e-02 9.9351890468012821e-03 6.1417342933701461e-03 + 40 1.1118517806702732e-02 1.8481525198274576e-03 4.1777838880835427e-04 + 41 3.1170233998653759e-02 -1.5448707079099688e-02 -1.1973868526731797e-02 + 42 3.3575265992803185e-03 4.8849463883252463e-03 1.6770888985230834e-03 + 43 5.5073880031353672e-03 2.8635891324946736e-02 6.2957963487790831e-03 + 44 5.2278697709017604e-03 -5.9205396052392717e-03 -1.1641028263524280e-02 + 45 8.2446804237109976e-03 2.2000009725752060e-02 8.2390814628951456e-07 + 46 -6.4059561000704031e-04 1.5796469864722801e-02 8.7781880557686095e-03 + 47 1.5239882999050557e-02 -3.1268760745643753e-03 1.8994686979097005e-02 + 48 9.4124555469617685e-04 2.8313380234794853e-02 1.4160015571855478e-02 +run_vdwl: -184.686733268654 +run_coul: 0 +run_stress: ! |- + -8.3410051971885424e-01 1.3625323642932721e+00 4.1461501508495013e+00 8.6688227256219996e-01 1.5565717748380517e-01 1.4790555833058188e+00 +run_forces: ! |2 + 1 -2.7566525107809318e-02 -1.8961404924034975e-01 5.5232231950330789e-03 + 2 -1.2758309231200282e-01 -1.9769482352839155e-02 -6.3019726921142868e-02 + 3 7.6250703896397640e-02 -8.9398464495202608e-03 1.1147884265844542e-01 + 4 2.3085246545061733e-01 3.1284937254363476e-01 -7.3585264863498745e-01 + 5 -1.9144857312851615e-01 -1.2515355098923714e-01 -1.5959719844577522e-01 + 6 -1.9647387066787372e-01 5.8583959861360932e-02 -5.5802890003857034e-02 + 7 -7.4393491306453985e-01 -2.1031898155941424e+00 -1.3179845766973441e+00 + 8 1.4451248841145776e-02 -7.5094603421028893e-03 5.1335942947151741e-03 + 9 6.3511525939309199e-02 2.9090392490561837e-02 1.3303386864174215e-02 + 10 -1.9672634807891523e-01 1.8083728118630801e-01 4.5651093638569429e-01 + 11 8.4872388548445898e-01 1.9358940575890571e+00 1.7628952060030210e+00 + 12 1.5987186106095264e-01 -9.8208391350393887e-02 1.2853301921141560e-02 + 25 -6.4229350400654264e-02 6.5121223305082257e-02 1.0056877607918861e-01 + 26 -1.7220602843542449e-01 -1.1015144383642610e-01 3.6631722097947343e-02 + 27 2.1703726611672525e-02 -3.5813737565299292e-02 -3.8490244907288140e-02 + 28 -7.9119032244579168e-02 1.3730457326547163e-01 -1.8741773388952015e-01 + 29 1.0488978251101254e-01 -1.1909435018113117e-01 3.7305458437005917e-02 + 30 1.5288232489842238e-01 -1.7372783419202745e-01 5.5596050035545151e-02 + 31 2.7049702020580869e-02 8.7269359923485251e-02 -8.0188955708864224e-02 + 32 -1.5669855197695848e-01 2.6784824182432453e-02 -1.4149188090162742e-02 + 33 1.4491176754189819e-01 5.7431352138432642e-03 -3.3994471687721864e-02 + 34 1.4553829964664816e-01 1.6556081633947264e-01 1.3970048432616899e-01 + 35 -1.0616681119412462e-01 4.6690438466217482e-02 7.4629391229118824e-02 + 36 -7.4068565095854799e-02 -8.2089870709701862e-02 -1.3462256268225453e-01 + 13 8.2379101312774386e-02 -3.7742159339381581e-01 7.7965598133185904e-02 + 14 -1.5216836068437717e-01 2.2238518425134669e-02 -6.8256075141941222e-02 + 15 1.3519830621083784e-01 1.8694222750179545e-01 -4.5760020752184015e-02 + 16 -9.4122812277554868e-02 3.7460162964963219e-02 -1.8223514295685489e-01 + 17 6.3613595149790536e-02 -3.9090346770006286e-02 3.5671486224074810e-02 + 18 7.8916322295767963e-02 -1.2892708246196263e-01 1.4769704074590567e-01 + 19 -8.3810673528647555e-03 -8.5441646265745450e-02 5.3647900953469149e-02 + 20 -1.6539114897139909e-01 2.1397130301406403e-01 -1.0949816014942894e-02 + 21 1.3818067438426573e-01 -6.8993959043769607e-02 -2.1299386806295124e-02 + 22 -1.5856475763177083e-03 1.5748026932167003e-01 7.4938732730195579e-02 + 23 3.9340145378663122e-02 -1.4061855355790968e-02 -9.4604853769769570e-02 + 24 -4.0312184075427006e-02 1.5211975019366620e-02 2.0132865843451725e-02 + 37 -5.7540799130195752e-01 5.0058614364608629e-02 1.7327763650198574e-01 + 38 1.3880800864979662e-01 -1.1430713799896731e-02 -9.5273453741880343e-02 + 39 1.3583699403986030e-01 7.1359222213997292e-02 3.6415542956628806e-02 + 40 2.4826377557322687e-01 -8.7545078947765323e-02 -1.6810450734482277e-01 + 41 -9.9940408667160155e-02 -4.7990932334050156e-02 9.9884783379563344e-02 + 42 -5.1291223401165813e-02 4.7496283547191202e-02 -9.4577003424099033e-04 + 43 3.2988332629179412e-02 -1.0775544344105276e-01 -1.4421909297187224e-01 + 44 7.4156020575267502e-03 -1.6440936142548804e-03 -6.8207536960046720e-03 + 45 6.0379992226191302e-02 1.2659562736103339e-01 2.3394684516017537e-02 + 46 -9.9942524249085951e-02 1.1237800722245612e-01 1.0203699454103866e-01 + 47 1.9442848972770918e-01 6.9497639530798572e-02 -1.3132256701126685e-01 + 48 7.8378396725857863e-02 -1.1885470662272486e-01 1.3371799785827665e-01 +... diff --git a/unittest/force-styles/tests/manybody-pair-airebo_00.yaml b/unittest/force-styles/tests/manybody-pair-airebo_00.yaml new file mode 100644 index 0000000000..d88a222305 --- /dev/null +++ b/unittest/force-styles/tests/manybody-pair-airebo_00.yaml @@ -0,0 +1,123 @@ +--- +lammps_version: 5 May 2020 +date_generated: Wed May 27 16:28:51 202 +epsilon: 1e-07 +prerequisites: ! | + pair airebo +pre_commands: ! | + variable newton_pair delete + variable newton_pair index on +post_commands: ! "" +input_file: in.airebo +pair_style: airebo 3.0 0 0 +pair_coeff: ! | + * * CH.airebo C H +extract: ! "" +natoms: 48 +init_vdwl: -184.961290756177 +init_coul: 0 +init_stress: ! |- + -1.5991107880755417e-02 1.7140062289608402e+00 -1.0794915656416637e+00 4.8928377143354418e-01 1.4299757801250498e-01 9.1729270327881118e-01 +init_forces: ! |2 + 1 1.3152583785902394e-01 4.8753765297722407e-02 -1.5563723988713196e-01 + 2 -6.4677574125421855e-02 -3.6433365193474787e-02 -1.3515634466513748e-01 + 3 1.6366540055346573e-03 1.6053102235330685e-02 -1.4025763253580847e-02 + 4 -8.7465878593573243e-02 -4.5665446908147445e-02 6.9471852842624970e-02 + 5 1.3196006750610195e-02 -8.8650251156534021e-03 4.7800865230702150e-02 + 6 1.9299301808352459e-02 3.2589957088717370e-02 9.4282242729599730e-02 + 7 -3.4087548212679419e-01 -1.2294752667452695e+00 -5.1904944997164693e-01 + 8 6.0078617802455783e-02 2.0498628992936883e-02 -9.3398597244978704e-03 + 9 1.2467192886648326e-02 3.8099500610843495e-02 1.4081370285705760e-01 + 10 -1.2918644768262050e-01 -2.1668533156799785e-02 -1.3804629901508914e-01 + 11 3.2262037268716748e-01 1.1759176707599115e+00 5.8980717273254846e-01 + 12 1.4376037289299093e-02 6.2603438310488174e-02 8.4228698980900824e-02 + 27 4.7005361439318077e-02 -5.2408426176605377e-02 -5.5149578856349829e-02 + 21 -5.0710356947559279e-02 -1.4285676294952748e-01 -3.0103912730198391e-02 + 24 7.8265517181488331e-03 4.3251923864515054e-02 -5.8933854751528125e-02 + 13 -3.5716712652627103e-02 1.3735681410832867e-02 1.4393711826134470e-02 + 14 -2.7941716820501609e-02 3.1552257494521507e-02 -4.2877340897456456e-02 + 15 1.5196317529582337e-02 -2.4839376668334828e-02 -5.3559475071731644e-02 + 16 7.3420523773577977e-03 3.7613136334306359e-02 -2.8703713987937803e-02 + 17 1.5584476459449964e-02 9.8879114554081271e-03 5.0428356540854230e-02 + 18 -1.1905338802559173e-04 6.3435717951509374e-03 3.8589803704210474e-02 + 19 -3.6317481447328021e-02 1.5667256621317516e-01 5.7218527576755107e-02 + 20 4.5103361944769826e-02 -5.6143964618761297e-02 1.1055811359300005e-01 + 22 2.1264619496304038e-02 -5.8783062697015775e-02 5.6556265461199795e-03 + 23 4.1238140118919062e-02 -9.3062149465309579e-03 -5.7265617948053335e-02 + 44 -2.7501983884904435e-03 -7.1276666877394812e-03 -5.4002244001689348e-03 + 25 -9.4094738859907934e-02 7.9609978294326034e-04 -7.8044314532108583e-02 + 26 4.4149651971254422e-02 1.1780662578757373e-02 5.7158432441624774e-02 + 28 3.4569663809708134e-02 -2.0908322434320625e-01 -2.7708578780154147e-02 + 29 5.2910800566559682e-04 6.4293440655586787e-02 -9.5734647942841478e-02 + 30 -2.5656282692781196e-02 8.9866518259576811e-02 7.6113053684404353e-02 + 31 3.4736314391823564e-02 1.0807969068365202e-01 1.4868993579665887e-01 + 32 1.7988755611627966e-02 -3.0751094993370962e-02 -8.7482941885915211e-02 + 33 -9.3425588225226341e-03 -2.1584491055374688e-02 -9.3877008553606200e-02 + 34 -1.5684631199890900e-02 1.5044628958073569e-03 1.4853366946912826e-02 + 35 3.1768878922333800e-02 -3.8885849858596389e-02 5.5946517738598732e-02 + 36 -1.8964161137310365e-02 2.3983785394224535e-02 3.0086185086425243e-02 + 39 -1.9729521703836572e-02 -6.3932341883306376e-02 -3.2518573786006422e-02 + 37 -1.3157059382780328e-01 1.5168014676918418e-01 4.1142179440578630e-04 + 38 -1.5988753846897796e-03 -2.5960455382179282e-02 2.0267750800645690e-02 + 40 1.6488495970003630e-01 -2.1535919097797926e-01 -3.0400741445342494e-02 + 41 -2.3107048489258319e-02 9.3912679031607021e-02 7.4598236747208668e-03 + 42 5.2864856296723328e-02 4.7976966093041584e-02 -5.4878418640677884e-02 + 43 -3.4984194842396499e-01 2.7616124926611707e-01 3.3585356232387786e-02 + 45 1.8178724152826475e-01 -1.8028798863029671e-01 -3.3398498292016243e-02 + 46 7.6023397517703095e-02 -2.2544487533539470e-01 4.2072193193403246e-02 + 47 -7.6877574240748030e-04 5.5783708545097566e-02 -2.0995954025529923e-02 + 48 5.1056308529232042e-02 8.5470102504109025e-02 6.8395640494008869e-02 +run_vdwl: -185.084340567887 +run_coul: 0 +run_stress: ! |- + -1.3323153386673774e+00 6.5009894327154760e-02 -1.7326291586383442e+00 4.9671868735735564e-01 2.8136179703319608e-02 5.7806981457586715e-01 +run_forces: ! |2 + 1 6.8355528493844298e-02 -1.1944451443270802e-01 -4.4125204825235098e-01 + 2 -1.2861924608968991e-01 -4.4137097431923344e-02 -1.2751824466012474e-01 + 3 8.1494435661480014e-02 -3.6920590518428054e-03 1.0040642950505263e-01 + 4 3.7527017608456914e-01 6.6940856681461991e-02 5.8019895967875557e-01 + 5 -1.8393789675484831e-01 -1.5834568564675960e-01 -8.6224034419114470e-02 + 6 -1.7282212455395130e-01 4.5083734857249647e-02 3.1197253351678889e-02 + 7 -3.3619376905194437e-01 -5.8091977753188084e-01 -5.8107276386347717e-01 + 8 1.0273233422549642e-01 -8.5412334130676976e-02 5.6323287362551079e-02 + 9 -1.3215510856196822e-02 -3.8099218776399491e-02 2.0437541579240195e-01 + 10 1.6412187218573659e-01 4.5430627507431653e-01 -7.0297693657988702e-01 + 11 -4.9902630586834862e-02 6.7017696686888217e-01 8.2705477529688232e-01 + 12 5.2147711171131816e-02 -1.6146646227932876e-01 1.8929213157343128e-01 + 27 4.0569120071207609e-02 -4.4990684200391068e-02 -4.9804224785798434e-02 + 21 1.6856210984353245e-01 -7.9511292426074076e-02 1.0001675896785096e-02 + 24 -9.2732980601280657e-02 -1.0950138658861922e-02 -4.0836736654732086e-02 + 13 6.4751997045543686e-02 -3.5563305441624971e-01 1.2820269624458880e-01 + 14 -1.5333471357819128e-01 1.5914151143699928e-02 -6.5037280503974712e-02 + 15 1.2286738982966094e-01 1.9265004204325895e-01 -4.9637041122573833e-02 + 16 -1.0852990429909931e-01 7.3201982309721483e-02 -2.4712787611616815e-01 + 17 6.0229575881071917e-02 -1.8934283782071015e-02 6.7629621559359809e-02 + 18 9.6466429473633097e-02 -9.9301800509148969e-02 1.5137717899747341e-01 + 19 -7.7003389183944088e-02 -2.3023763423969890e-02 4.8266701905256490e-02 + 20 -1.7916905871455191e-01 1.9867797610853855e-01 4.8402207345646708e-02 + 22 3.4304140788237750e-02 1.3519423218540497e-01 6.6300981648753990e-02 + 23 6.2839752037413682e-02 -2.6370577409609117e-02 -1.1545103162740503e-01 + 44 7.4865147797376075e-04 -1.9134731646395786e-03 -2.0910975730097647e-03 + 25 -1.2036034340714141e-01 5.2468101598679873e-02 4.3362109026140239e-02 + 26 -1.3709346740420025e-01 -9.5632079961340877e-02 5.9007750969542250e-02 + 28 -6.4018377994091560e-02 6.0553928500104437e-02 -1.8776358251620712e-01 + 29 9.6890302093696382e-02 -1.2338057085228121e-01 6.7295979231108971e-03 + 30 1.5163669686192729e-01 -1.4218642480904720e-01 7.9473882014891972e-02 + 31 3.1597012409922437e-02 1.8162006569087685e-01 8.0853434851491893e-02 + 32 -1.5574245261504957e-01 -1.4903833490853655e-02 -5.9160677478346482e-02 + 33 1.4736721012005907e-01 -3.2985065985107143e-02 -6.7005897560507538e-02 + 34 2.2444726480772675e-01 1.4487810359056891e-01 7.1462055528190113e-02 + 35 -8.5673030495807490e-02 6.1015455839103921e-02 1.2177185351699812e-01 + 36 -8.9050814377041709e-02 -9.1447680120703895e-02 -1.4873052627530475e-01 + 39 1.5210289064479374e-01 6.3318639778475738e-02 2.3309631651053708e-02 + 37 -6.2333640474717122e-01 5.1087346671760403e-02 1.7873483824820902e-01 + 38 1.1822724805114426e-01 1.3806051076594161e-03 -7.8201063267624660e-02 + 40 2.9670421707793115e-01 -1.4891122500091292e-01 -2.2577727039126999e-01 + 41 -1.1163722101360789e-01 -1.6291547452462640e-02 1.1570402265470292e-01 + 42 -2.8439534417055767e-02 4.1199861152822509e-02 -2.5621427173460498e-02 + 43 -3.1571378405888584e-01 3.7002322228513365e-02 -1.2890733821154285e-01 + 45 2.7239277705401937e-01 7.6632675253599444e-03 -9.6378796865211891e-03 + 46 -7.4845763922132422e-02 2.0438477364830343e-02 1.4619059575391516e-01 + 47 1.9442828039042842e-01 7.3643646110724048e-02 -1.5176869728387757e-01 + 48 1.2011729494053558e-01 -1.3053139348677081e-01 1.5597458770641501e-01 +... diff --git a/unittest/force-styles/tests/manybody-pair-airebo_m.yaml b/unittest/force-styles/tests/manybody-pair-airebo_m.yaml new file mode 100644 index 0000000000..9afe790d4a --- /dev/null +++ b/unittest/force-styles/tests/manybody-pair-airebo_m.yaml @@ -0,0 +1,123 @@ +--- +lammps_version: 5 May 2020 +date_generated: Wed May 27 16:26:25 202 +epsilon: 1e-07 +prerequisites: ! | + pair airebo/morse +pre_commands: ! | + variable newton_pair delete + variable newton_pair index on +post_commands: ! "" +input_file: in.airebo +pair_style: airebo/morse 3.0 1 1 +pair_coeff: ! | + * * CH.airebo-m C H +extract: ! "" +natoms: 48 +init_vdwl: -184.906791169779 +init_coul: 0 +init_stress: ! |- + -1.9905840837585734e-01 9.9992116160260081e-01 -8.7107008837839661e-01 3.8867690764878343e-01 1.6780936142412156e-01 1.2045504927890958e+00 +init_forces: ! |2 + 1 -2.0517729766528860e-02 -1.4262995534169765e-02 -7.7963887627594861e-02 + 2 -2.3292944549651143e-02 -6.7249828039017299e-03 -7.6793499917455169e-02 + 3 -1.4092849573913088e-02 3.1805962926497053e-02 -3.4138357265727254e-02 + 4 2.1899004604710474e-03 -4.1989704976489765e-03 6.0201335634925482e-03 + 5 2.0241700654822448e-02 -1.5556027189412708e-02 2.6728671619349303e-02 + 6 1.1456048207589772e-02 4.4358273015205740e-03 9.1675791034385529e-02 + 7 -3.4229132775085536e-01 -1.1972452864837069e+00 -5.5203863487263571e-01 + 8 5.6656469172808935e-02 2.2263235858918210e-02 -2.8744416882031344e-03 + 9 7.0652957250645796e-03 1.2292922029980341e-03 6.8027547762351426e-02 + 10 1.6474826872584381e-02 5.1697228896774222e-02 -4.6429635472860976e-02 + 11 2.7359825402660776e-01 1.1591131630022211e+00 5.7604317521182036e-01 + 12 -1.6966183404425326e-02 2.0005776678633208e-02 7.4285303443834383e-02 + 25 -1.0348914179117446e-02 -1.5363032067927010e-02 3.8497206556342453e-03 + 26 3.6217728899200518e-03 -5.9579941688302062e-03 1.8307533288494764e-02 + 27 3.9412960252465476e-02 -5.4780576877686678e-02 -5.3261154604627423e-02 + 28 2.0208534504483162e-03 2.1660794039467311e-03 -1.0074165724085796e-02 + 29 3.1523279098070039e-02 1.3231992100660369e-02 -4.1037220112554042e-02 + 30 -1.7935081092400468e-02 -2.2567940364334811e-03 3.0924622213973543e-02 + 31 2.4301072874938292e-02 -2.0260797985721227e-02 -2.9066138023701869e-02 + 32 2.1291997787850396e-02 2.0049030065209292e-02 -2.8173565609265250e-02 + 33 3.8103121956027056e-03 2.0953495479834640e-02 -5.0688470245415417e-02 + 34 -3.5368448227485742e-02 4.0323812525656016e-04 1.2036955050128079e-02 + 35 2.1975636221484500e-03 -3.4548771183920565e-02 6.1836819899349076e-02 + 36 -1.0160663159000431e-02 2.3509241970262711e-02 2.8066559971084468e-02 + 13 -2.0459845454245021e-02 -4.1468146718981668e-03 -1.9151815940882014e-02 + 14 -2.3418059180109290e-02 3.0544955460059132e-02 -4.9090761147108801e-02 + 15 1.1656783637493524e-02 -2.8358346908418989e-02 -4.0123034264605187e-02 + 16 1.2765577695696089e-02 2.6181592218778943e-02 1.3256906225680189e-02 + 17 1.5271823911694370e-02 -1.9104098352645177e-02 1.4787739004554422e-02 + 18 -9.5060935539167460e-03 1.9643783746141224e-03 5.6998482114197217e-02 + 19 1.4229646387889518e-02 -3.5381316056916153e-03 7.7461982718596972e-03 + 20 4.5404064978554808e-02 -9.7586517126307219e-03 3.8251778495346195e-02 + 21 -6.3057799134156184e-02 -5.1054562301407494e-02 2.3619313205612120e-02 + 22 -6.2315350167798204e-03 1.1745903233472599e-02 2.8902034055890333e-03 + 23 -9.7471817248659821e-03 8.6921151015094036e-03 -1.1241037752092215e-02 + 24 1.8650178962035604e-02 3.2818240007903177e-02 -3.1102047239755275e-02 + 37 -8.7435994030670393e-03 3.1191405936012743e-04 1.7887396320730308e-03 + 38 2.5273964519169851e-03 -1.1504733773486877e-02 -1.3157241144539459e-02 + 39 -4.0646716094586713e-02 6.4275738930320136e-03 -5.4473387074653688e-03 + 40 1.0568584242762576e-02 1.9565157477192006e-03 -2.0095242662941738e-04 + 41 3.2440796644272754e-02 -1.6908051806037914e-02 -1.3019233412209725e-02 + 42 9.0435754174252661e-03 6.5794830651171431e-03 -3.6354784764202321e-02 + 43 -4.9001503636347888e-03 2.6746242116619755e-02 9.4368754420029784e-03 + 44 4.8308252882241862e-03 -5.8630425989018757e-03 -1.0391993922486365e-02 + 45 1.9202706435960823e-02 -3.5826931807379711e-02 -1.1278558300301649e-02 + 46 -1.2686955525069661e-02 1.5757428775066942e-02 7.5875168576671499e-03 + 47 1.3552850486712849e-02 -1.4399850633487542e-03 1.9372348907855261e-02 + 48 -3.5635040678223824e-02 1.8069673365221146e-02 4.9559034910065504e-02 +run_vdwl: -184.884287638713 +run_coul: 0 +run_stress: ! |- + -1.7553297389663807e+00 -2.0601635049893026e+00 -1.2914715105335668e+00 -1.2164852300255997e-01 -4.6612665537491982e-01 -1.7584106513907777e-01 +run_forces: ! |2 + 1 -4.7056658298582076e-04 -1.4634222942799394e-01 -3.1706476526805027e-01 + 2 -1.3535142579879833e-01 -3.4314289056189752e-02 -1.0367582735591681e-01 + 3 6.8650003463217715e-02 -8.3697069795512120e-03 9.6833809476059018e-02 + 4 4.2071591222775861e-01 1.7283632620651795e-01 3.9136383645688072e-01 + 5 -1.7865994780460992e-01 -1.4611726831783364e-01 -1.1398589448509859e-01 + 6 -1.7784101851934428e-01 4.5618526085822425e-02 1.8657271970413374e-02 + 7 2.3090519777513271e-01 9.6499512779086294e-01 3.5569275071901496e-01 + 8 6.8680141620648019e-02 -6.5043644160050693e-02 3.3101755591902426e-02 + 9 1.4039981406452870e-02 -5.8844391944973380e-02 9.9688858750920539e-02 + 10 5.3646218762077855e-02 4.9904730056839725e-01 -2.3006541661968963e-01 + 11 -4.4688380209968831e-01 -1.0148824359301210e+00 -3.2575486748268678e-01 + 12 5.9125769005741756e-02 -1.6455074843131096e-01 1.4182565053188184e-01 + 25 -5.8830023005069586e-02 5.5493152701298960e-02 8.9356007987085137e-02 + 26 -1.6126938215990105e-01 -1.0589550989698598e-01 4.4457820280718992e-02 + 27 3.2050225113605772e-02 -4.6858682187267103e-02 -4.6030115729389323e-02 + 28 -7.5947731462843282e-02 1.3782694351300281e-01 -1.7799302352415669e-01 + 29 1.0756252212717538e-01 -1.2493903809259364e-01 3.7463632651968878e-02 + 30 1.5346237725582387e-01 -1.7193789085169181e-01 5.7093382017703226e-02 + 31 3.7100886471736753e-02 6.6328162647684819e-02 -6.8241776528602388e-02 + 32 -1.5386863547969926e-01 3.1563293915620398e-02 -1.1714437764915764e-02 + 33 1.4713421544405372e-01 2.1760039530633707e-04 -3.2616373504918299e-02 + 34 1.9064328958682114e-01 1.4591501668099530e-01 9.8409456596864342e-02 + 35 -9.9846542261889978e-02 5.2704676893072323e-02 9.6991422347650041e-02 + 36 -7.6502955446541621e-02 -8.5095668829058016e-02 -1.3897135591211321e-01 + 13 7.4818684100851671e-02 -3.6120445920708949e-01 9.3359386334273653e-02 + 14 -1.5618766168829912e-01 2.0408313847255815e-02 -6.3657252717194857e-02 + 15 1.3274432075484421e-01 1.8890222305075144e-01 -5.3774497785697782e-02 + 16 -1.0939749808088689e-01 7.0297915308787498e-02 -2.0655632465075238e-01 + 17 6.6926827327773053e-02 -4.4104673887093666e-02 3.3117350168894881e-02 + 18 8.4614454722492821e-02 -1.0145181052862164e-01 1.6550368839223134e-01 + 19 -4.1619642190982541e-02 -9.6396190853089911e-02 4.1403847715373324e-02 + 20 -1.9839035226178811e-01 2.1599992066411777e-01 -1.3457232824090459e-02 + 21 1.5383852967224548e-01 -7.2701207696353312e-02 -5.0818378502930973e-04 + 22 -9.4230270862067055e-03 1.7342238753231365e-01 9.0815029821744414e-02 + 23 3.4558368487069897e-02 -1.2078171184596179e-02 -9.1321557338724546e-02 + 24 -4.7349089756643828e-02 7.0930724599967106e-03 9.2840611032212628e-03 + 37 -5.9216580817461095e-01 1.2321315564060400e-02 1.7075406198563545e-01 + 38 1.3228377510993414e-01 -1.4179759288390884e-02 -9.3273292141222208e-02 + 39 1.4106998279682412e-01 7.9136335255856782e-02 3.3231256275553296e-02 + 40 2.4863765861074733e-01 -8.9429039881233977e-02 -1.8767583738581864e-01 + 41 -9.8668584541866278e-02 -5.0568392084021939e-02 9.8367911149062015e-02 + 42 -4.9260030547804493e-02 4.8085923600047889e-02 -1.2364163270556597e-02 + 43 -1.1397987292289991e-02 -1.4101799789272826e-01 -1.4770764058051941e-01 + 44 6.9144141741118775e-03 -2.2619416778199885e-03 -6.2863438078055783e-03 + 45 1.0662201618495948e-01 1.1264787973634517e-01 1.1636487874690335e-02 + 46 -1.4095023595362419e-01 1.1420276586190301e-01 1.2027784751424971e-01 + 47 1.8817799678511232e-01 7.9435207983366785e-02 -1.2950610265865653e-01 + 48 6.5358179209163397e-02 -1.3591423997672408e-01 1.4351569940761391e-01 +... diff --git a/unittest/force-styles/tests/manybody-pair-airebo_m00.yaml b/unittest/force-styles/tests/manybody-pair-airebo_m00.yaml new file mode 100644 index 0000000000..9b266a5564 --- /dev/null +++ b/unittest/force-styles/tests/manybody-pair-airebo_m00.yaml @@ -0,0 +1,123 @@ +--- +lammps_version: 5 May 2020 +date_generated: Wed May 27 16:29:04 202 +epsilon: 1e-07 +prerequisites: ! | + pair airebo/morse +pre_commands: ! | + variable newton_pair delete + variable newton_pair index on +post_commands: ! "" +input_file: in.airebo +pair_style: airebo/morse 3.0 0 0 +pair_coeff: ! | + * * CH.airebo-m C H +extract: ! "" +natoms: 48 +init_vdwl: -184.961290756177 +init_coul: 0 +init_stress: ! |- + -1.5991107880755417e-02 1.7140062289608402e+00 -1.0794915656416637e+00 4.8928377143354418e-01 1.4299757801250498e-01 9.1729270327881118e-01 +init_forces: ! |2 + 1 1.3152583785902394e-01 4.8753765297722407e-02 -1.5563723988713196e-01 + 2 -6.4677574125421855e-02 -3.6433365193474787e-02 -1.3515634466513748e-01 + 3 1.6366540055346573e-03 1.6053102235330685e-02 -1.4025763253580847e-02 + 4 -8.7465878593573243e-02 -4.5665446908147445e-02 6.9471852842624970e-02 + 5 1.3196006750610195e-02 -8.8650251156534021e-03 4.7800865230702150e-02 + 6 1.9299301808352459e-02 3.2589957088717370e-02 9.4282242729599730e-02 + 7 -3.4087548212679419e-01 -1.2294752667452695e+00 -5.1904944997164693e-01 + 8 6.0078617802455783e-02 2.0498628992936883e-02 -9.3398597244978704e-03 + 9 1.2467192886648326e-02 3.8099500610843495e-02 1.4081370285705760e-01 + 10 -1.2918644768262050e-01 -2.1668533156799785e-02 -1.3804629901508914e-01 + 11 3.2262037268716748e-01 1.1759176707599115e+00 5.8980717273254846e-01 + 12 1.4376037289299093e-02 6.2603438310488174e-02 8.4228698980900824e-02 + 27 4.7005361439318077e-02 -5.2408426176605377e-02 -5.5149578856349829e-02 + 21 -5.0710356947559279e-02 -1.4285676294952748e-01 -3.0103912730198391e-02 + 24 7.8265517181488331e-03 4.3251923864515054e-02 -5.8933854751528125e-02 + 13 -3.5716712652627103e-02 1.3735681410832867e-02 1.4393711826134470e-02 + 14 -2.7941716820501609e-02 3.1552257494521507e-02 -4.2877340897456456e-02 + 15 1.5196317529582337e-02 -2.4839376668334828e-02 -5.3559475071731644e-02 + 16 7.3420523773577977e-03 3.7613136334306359e-02 -2.8703713987937803e-02 + 17 1.5584476459449964e-02 9.8879114554081271e-03 5.0428356540854230e-02 + 18 -1.1905338802559173e-04 6.3435717951509374e-03 3.8589803704210474e-02 + 19 -3.6317481447328021e-02 1.5667256621317516e-01 5.7218527576755107e-02 + 20 4.5103361944769826e-02 -5.6143964618761297e-02 1.1055811359300005e-01 + 22 2.1264619496304038e-02 -5.8783062697015775e-02 5.6556265461199795e-03 + 23 4.1238140118919062e-02 -9.3062149465309579e-03 -5.7265617948053335e-02 + 44 -2.7501983884904435e-03 -7.1276666877394812e-03 -5.4002244001689348e-03 + 25 -9.4094738859907934e-02 7.9609978294326034e-04 -7.8044314532108583e-02 + 26 4.4149651971254422e-02 1.1780662578757373e-02 5.7158432441624774e-02 + 28 3.4569663809708134e-02 -2.0908322434320625e-01 -2.7708578780154147e-02 + 29 5.2910800566559682e-04 6.4293440655586787e-02 -9.5734647942841478e-02 + 30 -2.5656282692781196e-02 8.9866518259576811e-02 7.6113053684404353e-02 + 31 3.4736314391823564e-02 1.0807969068365202e-01 1.4868993579665887e-01 + 32 1.7988755611627966e-02 -3.0751094993370962e-02 -8.7482941885915211e-02 + 33 -9.3425588225226341e-03 -2.1584491055374688e-02 -9.3877008553606200e-02 + 34 -1.5684631199890900e-02 1.5044628958073569e-03 1.4853366946912826e-02 + 35 3.1768878922333800e-02 -3.8885849858596389e-02 5.5946517738598732e-02 + 36 -1.8964161137310365e-02 2.3983785394224535e-02 3.0086185086425243e-02 + 39 -1.9729521703836572e-02 -6.3932341883306376e-02 -3.2518573786006422e-02 + 37 -1.3157059382780328e-01 1.5168014676918418e-01 4.1142179440578630e-04 + 38 -1.5988753846897796e-03 -2.5960455382179282e-02 2.0267750800645690e-02 + 40 1.6488495970003630e-01 -2.1535919097797926e-01 -3.0400741445342494e-02 + 41 -2.3107048489258319e-02 9.3912679031607021e-02 7.4598236747208668e-03 + 42 5.2864856296723328e-02 4.7976966093041584e-02 -5.4878418640677884e-02 + 43 -3.4984194842396499e-01 2.7616124926611707e-01 3.3585356232387786e-02 + 45 1.8178724152826475e-01 -1.8028798863029671e-01 -3.3398498292016243e-02 + 46 7.6023397517703095e-02 -2.2544487533539470e-01 4.2072193193403246e-02 + 47 -7.6877574240748030e-04 5.5783708545097566e-02 -2.0995954025529923e-02 + 48 5.1056308529232042e-02 8.5470102504109025e-02 6.8395640494008869e-02 +run_vdwl: -185.084340567887 +run_coul: 0 +run_stress: ! |- + -1.3323153386673774e+00 6.5009894327154760e-02 -1.7326291586383442e+00 4.9671868735735564e-01 2.8136179703319608e-02 5.7806981457586715e-01 +run_forces: ! |2 + 1 6.8355528493844298e-02 -1.1944451443270802e-01 -4.4125204825235098e-01 + 2 -1.2861924608968991e-01 -4.4137097431923344e-02 -1.2751824466012474e-01 + 3 8.1494435661480014e-02 -3.6920590518428054e-03 1.0040642950505263e-01 + 4 3.7527017608456914e-01 6.6940856681461991e-02 5.8019895967875557e-01 + 5 -1.8393789675484831e-01 -1.5834568564675960e-01 -8.6224034419114470e-02 + 6 -1.7282212455395130e-01 4.5083734857249647e-02 3.1197253351678889e-02 + 7 -3.3619376905194437e-01 -5.8091977753188084e-01 -5.8107276386347717e-01 + 8 1.0273233422549642e-01 -8.5412334130676976e-02 5.6323287362551079e-02 + 9 -1.3215510856196822e-02 -3.8099218776399491e-02 2.0437541579240195e-01 + 10 1.6412187218573659e-01 4.5430627507431653e-01 -7.0297693657988702e-01 + 11 -4.9902630586834862e-02 6.7017696686888217e-01 8.2705477529688232e-01 + 12 5.2147711171131816e-02 -1.6146646227932876e-01 1.8929213157343128e-01 + 27 4.0569120071207609e-02 -4.4990684200391068e-02 -4.9804224785798434e-02 + 21 1.6856210984353245e-01 -7.9511292426074076e-02 1.0001675896785096e-02 + 24 -9.2732980601280657e-02 -1.0950138658861922e-02 -4.0836736654732086e-02 + 13 6.4751997045543686e-02 -3.5563305441624971e-01 1.2820269624458880e-01 + 14 -1.5333471357819128e-01 1.5914151143699928e-02 -6.5037280503974712e-02 + 15 1.2286738982966094e-01 1.9265004204325895e-01 -4.9637041122573833e-02 + 16 -1.0852990429909931e-01 7.3201982309721483e-02 -2.4712787611616815e-01 + 17 6.0229575881071917e-02 -1.8934283782071015e-02 6.7629621559359809e-02 + 18 9.6466429473633097e-02 -9.9301800509148969e-02 1.5137717899747341e-01 + 19 -7.7003389183944088e-02 -2.3023763423969890e-02 4.8266701905256490e-02 + 20 -1.7916905871455191e-01 1.9867797610853855e-01 4.8402207345646708e-02 + 22 3.4304140788237750e-02 1.3519423218540497e-01 6.6300981648753990e-02 + 23 6.2839752037413682e-02 -2.6370577409609117e-02 -1.1545103162740503e-01 + 44 7.4865147797376075e-04 -1.9134731646395786e-03 -2.0910975730097647e-03 + 25 -1.2036034340714141e-01 5.2468101598679873e-02 4.3362109026140239e-02 + 26 -1.3709346740420025e-01 -9.5632079961340877e-02 5.9007750969542250e-02 + 28 -6.4018377994091560e-02 6.0553928500104437e-02 -1.8776358251620712e-01 + 29 9.6890302093696382e-02 -1.2338057085228121e-01 6.7295979231108971e-03 + 30 1.5163669686192729e-01 -1.4218642480904720e-01 7.9473882014891972e-02 + 31 3.1597012409922437e-02 1.8162006569087685e-01 8.0853434851491893e-02 + 32 -1.5574245261504957e-01 -1.4903833490853655e-02 -5.9160677478346482e-02 + 33 1.4736721012005907e-01 -3.2985065985107143e-02 -6.7005897560507538e-02 + 34 2.2444726480772675e-01 1.4487810359056891e-01 7.1462055528190113e-02 + 35 -8.5673030495807490e-02 6.1015455839103921e-02 1.2177185351699812e-01 + 36 -8.9050814377041709e-02 -9.1447680120703895e-02 -1.4873052627530475e-01 + 39 1.5210289064479374e-01 6.3318639778475738e-02 2.3309631651053708e-02 + 37 -6.2333640474717122e-01 5.1087346671760403e-02 1.7873483824820902e-01 + 38 1.1822724805114426e-01 1.3806051076594161e-03 -7.8201063267624660e-02 + 40 2.9670421707793115e-01 -1.4891122500091292e-01 -2.2577727039126999e-01 + 41 -1.1163722101360789e-01 -1.6291547452462640e-02 1.1570402265470292e-01 + 42 -2.8439534417055767e-02 4.1199861152822509e-02 -2.5621427173460498e-02 + 43 -3.1571378405888584e-01 3.7002322228513365e-02 -1.2890733821154285e-01 + 45 2.7239277705401937e-01 7.6632675253599444e-03 -9.6378796865211891e-03 + 46 -7.4845763922132422e-02 2.0438477364830343e-02 1.4619059575391516e-01 + 47 1.9442828039042842e-01 7.3643646110724048e-02 -1.5176869728387757e-01 + 48 1.2011729494053558e-01 -1.3053139348677081e-01 1.5597458770641501e-01 +... diff --git a/unittest/force-styles/tests/manybody-pair-bop.yaml b/unittest/force-styles/tests/manybody-pair-bop.yaml new file mode 100644 index 0000000000..a2d67718da --- /dev/null +++ b/unittest/force-styles/tests/manybody-pair-bop.yaml @@ -0,0 +1,157 @@ +--- +lammps_version: 5 May 2020 +date_generated: Wed May 27 20:55:13 202 +epsilon: 1e-12 +prerequisites: ! | + pair bop +pre_commands: ! | + variable newton_pair delete + variable newton_pair index on + comm_modify cutoff 14.0 +post_commands: ! | + change_box all x final 0 14 y final 0 14 z final 0 14 +input_file: in.manybody +pair_style: bop +pair_coeff: ! | + * * CdTeSe.bop.table Cd Cd Cd Cd Te Se Te Se +extract: ! "" +natoms: 64 +init_vdwl: 339.733829635833 +init_coul: -368.231322836704 +init_stress: ! |2- + 2.9664812306213270e+02 3.0033452819550314e+02 3.0554910490323380e+02 -1.4022398127673540e+01 6.2687826572337514e+01 7.2310160412711042e+00 +init_forces: ! |2 + 2 -5.8267302347683101e+00 -1.0985738664512801e+00 -1.1207325480685282e+00 + 4 1.6389231939707416e+00 1.3039054265757934e+00 -4.9484541697996569e+00 + 5 -9.2839172578555040e-01 -5.8117814364858527e+00 6.1937509525762235e-01 + 9 -4.5762270446238613e+00 -3.9204995645732330e+00 -4.6408361207050985e+00 + 10 3.8618996343997142e-01 -4.8246711362228695e-01 -3.7526005081196723e+00 + 13 -4.3804509161657346e-02 7.0660812021913753e+00 -2.1254459135586732e+00 + 11 3.8886725671841260e+00 -7.4853011189508871e+00 2.7200784131222786e+00 + 12 -5.6266554608940966e+00 -6.2227575850462040e+00 -6.7641807522819004e+00 + 19 -1.5797692251244013e+00 -4.2188505139224297e+00 -9.4790097400171314e-01 + 21 3.8592661596890726e-01 -1.4883663814395640e+00 -7.4891167147829378e+00 + 8 1.5621349267812392e+00 2.4576975160454420e+00 -3.1358448152260672e+00 + 29 -3.0255832723134746e+00 3.3927756633754584e+00 -6.0557583963081578e+00 + 16 2.6737613591719089e+00 -5.0915540944779225e-01 7.8962024622872171e+00 + 27 2.9079657925408924e+00 -1.9990089259048922e+00 2.7522842124838891e+00 + 17 5.7262605488897504e+00 4.7425068157791719e+00 -4.5038058973398165e+00 + 18 -4.9473883073572056e+00 4.0798454854730934e+00 3.1816208338734104e+00 + 24 1.4757687162926025e-01 -4.4440023665013301e-01 -1.9985463666180416e+00 + 26 -7.9632329659887191e-01 9.2714287042141752e-01 1.5745552832318039e+00 + 32 -1.2694222887563127e+00 -1.6824841867717204e+00 1.4704352584404901e+00 + 3 9.1289719044486706e-01 3.3335157010128356e+00 -8.5963837679782584e-01 + 1 1.4195759595451263e+00 1.7481274335943620e+00 -1.6315447028005174e+00 + 36 -1.4664876494816967e-01 -2.6215215046323128e+00 -1.0023899035559496e-01 + 37 -5.4264855248617803e+00 3.1861274438294198e+00 -2.4621905013504666e+00 + 7 -4.3255606592069187e+00 -4.6111368458594564e+00 1.6128097211296950e+00 + 41 -7.8678341332792789e-01 -3.7942894328039767e+00 -4.0798905604583535e-01 + 45 -1.9502924097548135e+00 1.4087782428004525e+00 -4.6291163060161038e+00 + 15 -2.6643905088894462e+00 7.5649247873111243e+00 -4.9108669990802944e+00 + 44 5.4794791334143422e+00 -3.9823134823509605e+00 1.7520385731242125e+00 + 33 5.2674360316474216e+00 -6.0617684774014382e+00 6.8823394510972093e+00 + 6 -5.3225918200326572e-01 4.9386042922997362e+00 1.9118378310624808e+00 + 49 -6.0184343889129206e+00 -5.8995776774325650e+00 -6.5046996708641398e+00 + 53 3.4205242091354151e+00 4.0891111321222473e+00 2.4058297207651580e+00 + 14 -2.3264779482243632e+00 5.8149129961896771e+00 9.5014458735634721e-01 + 23 3.4703238757116277e+00 5.3672082723011698e+00 1.6425403994309145e+00 + 40 6.5130875840840048e+00 -3.2723799054436933e+00 -2.4706268430282115e+00 + 57 4.4760818926750356e-01 -2.8488413602069711e+00 -5.6555890710257728e-01 + 61 -1.5120822865104833e+00 3.0576754346807191e+00 -1.9337375919944377e+00 + 31 2.8516292766400619e+00 6.5863160391523878e-01 9.9682202079080040e-01 + 48 2.9926209643952428e+00 1.1227614175601421e+00 -1.1715531045366330e+00 + 22 -8.4711410302594228e+00 5.8304011037945616e+00 -5.7015594000095282e+00 + 52 6.5879215791932753e+00 -4.7407764014303870e+00 7.0014238546920788e+00 + 30 -1.9777414910942188e+00 2.7173694651266573e+00 -1.5121154607863037e+00 + 56 -1.6887663553216334e+00 3.5691582670953483e+00 -1.8056264248838270e+00 + 60 -2.9651232553515801e+00 -5.5291477203574848e+00 -3.9147366021943402e+00 + 64 5.7753579488954081e+00 5.6893699286631358e+00 6.1188593857076974e+00 + 35 2.7491420931207142e+00 -5.8950425368461667e+00 2.6664136974805470e+00 + 39 3.1214774344817403e-01 1.3259890606544225e+00 1.7918011273453589e+00 + 42 -6.1298505645080388e+00 -1.5622737212548481e+00 -8.2710324136479288e-02 + 43 -5.2881711241098063e-02 -9.3044002747173309e+00 5.3902960319543580e-01 + 47 3.2984509939278075e+00 2.5465467247381470e+00 6.4412563543168480e+00 + 34 2.8255868816948211e+00 5.6904869676083880e-01 -4.1019702894249982e-01 + 38 -4.9223809099622962e-01 -2.0994167335759810e+00 1.0341827178200973e+00 + 51 -2.2706292600043141e+00 3.1887251962324710e+00 6.0722304901594635e+00 + 46 -6.7619318999617894e-01 -2.7385245483999534e+00 7.9011510613417961e+00 + 55 7.1872792391677520e-01 -4.3800511897017582e+00 -4.7368265069805311e+00 + 59 4.7992102161580945e+00 8.3852777377055798e-01 -2.9586297155134558e+00 + 63 9.0442902049721958e+00 -1.4095410747099721e+00 -3.3538816791526131e+00 + 50 -4.0447784759406700e+00 2.1475720348760432e+00 2.7880727533516918e+00 + 54 4.2285251590640366e-01 9.2479703347555364e-01 2.5886939236416312e-01 + 58 3.7503965772039942e+00 5.2062902627700891e-01 1.1329590126248945e+00 + 62 -3.4726169504324123e+00 5.2740847068077086e+00 -2.8158025997879781e+00 + 25 1.2768186113963365e+00 -1.9626922200900589e+00 4.6100355763822085e+00 + 20 -5.1944276144712305e+00 5.9225406589647793e+00 6.0059985600064563e+00 + 28 -1.9073991020555257e+00 7.5224803176560950e-01 9.6918725189281645e+00 +run_vdwl: 328.12039190566 +run_coul: -363.312225096902 +run_stress: ! |2- + 2.8230013128814915e+02 2.8656131447460984e+02 2.9181631824346204e+02 -1.1936544781278243e+01 5.4258103085030932e+01 1.0743049228637322e+01 +run_forces: ! |2 + 2 -5.5075765243395516e+00 -1.1490755696913171e+00 -1.2010272822402699e+00 + 4 1.6449866941055584e+00 1.3157691009108203e+00 -4.8005796253978295e+00 + 5 -9.6600352996619721e-01 -5.5486425670668087e+00 8.0466800051422105e-01 + 9 -4.4862976177645884e+00 -3.8649250462825440e+00 -4.5119249002601522e+00 + 10 9.3797199787040722e-02 -4.9196623851915222e-01 -2.6912698424760753e+00 + 13 8.7721831238569203e-01 5.9997306505759207e+00 -1.8140526415237341e+00 + 11 3.0734731059713334e+00 -6.7505501313840579e+00 2.0415883121595879e+00 + 12 -4.5867239258321444e+00 -4.9994870019006612e+00 -5.7646682591032015e+00 + 19 -1.7822908776371351e+00 -4.1630745817047794e+00 -8.9918948897748996e-01 + 21 5.2331194905821710e-01 -1.2867428882094816e+00 -7.2027500903962745e+00 + 8 1.3897208072975273e+00 2.3855097659298137e+00 -3.1735199887051473e+00 + 29 -2.6642634943080372e+00 2.9934911573505811e+00 -5.8750554017726095e+00 + 16 2.5436669799001654e+00 -1.0057929518796414e+00 6.4839169113188433e+00 + 27 2.6810098523443600e+00 -1.7002540834840822e+00 2.3947552507437293e+00 + 17 4.8083665670664200e+00 4.0667532717743784e+00 -3.9323641938744185e+00 + 18 -4.9278238691878267e+00 3.6754820075571049e+00 2.9552705503994323e+00 + 24 4.6097367619129404e-01 -7.8636498340568595e-01 -2.2066042710147649e+00 + 26 -9.0301834169602868e-01 1.1731702985146959e+00 1.5686119136705698e+00 + 32 -1.0716261381239105e+00 -1.4466979138459053e+00 1.2512585618004359e+00 + 3 5.6280893116800612e-01 3.3807783301019096e+00 -3.8927085897114910e-01 + 1 1.2094006584471133e+00 1.4972012980182414e+00 -1.3966614118871765e+00 + 36 -6.1947059398008408e-01 -2.2788751004462711e+00 -6.3226292177021803e-01 + 37 -5.0892672185532151e+00 2.7593899198380747e+00 -1.8750975210857241e+00 + 7 -3.8506648858913270e+00 -3.9000788676588707e+00 9.2046483420051983e-01 + 41 -3.9392661479233299e-01 -3.6326650788264541e+00 -4.4852960786515211e-02 + 45 -2.0903024652290947e+00 6.5403696832838498e-01 -3.8954629800648335e+00 + 15 -1.8847664851218144e+00 6.6312098846629608e+00 -3.8884149600049422e+00 + 44 5.0531181537102166e+00 -3.4334901733861405e+00 9.3114428555247419e-01 + 33 4.5215187429555277e+00 -5.1886187743287877e+00 5.8085608076614106e+00 + 6 1.8737050995498130e-02 4.4376121957876951e+00 1.8870203152016429e+00 + 49 -5.9485520777752026e+00 -5.5665450586946150e+00 -6.0830757377442710e+00 + 53 3.0848111502772113e+00 3.8405885878548869e+00 2.7427754922007561e+00 + 14 -2.3949790895045791e+00 5.1078232404778783e+00 1.1090928235716313e+00 + 23 3.3946219231880281e+00 5.1554894158129567e+00 1.4001045047031935e+00 + 40 6.1442830836550728e+00 -2.5948798656177550e+00 -2.2293415126040563e+00 + 57 3.5395757614019313e-01 -3.0475765881143806e+00 -5.9029962853607421e-01 + 61 -1.2744632882178495e+00 2.9325120669119698e+00 -1.6224561254464971e+00 + 31 2.9122176189253612e+00 6.8463354598274240e-01 9.6539522572680381e-01 + 48 2.9273899954311946e+00 1.3452816241286942e+00 -1.2628885222097392e+00 + 22 -7.0420904760678154e+00 4.8874483918285243e+00 -4.2523907014654894e+00 + 52 5.4306396741489111e+00 -3.1496371163570522e+00 5.4598735627672799e+00 + 30 -1.7631227690722784e+00 2.4014697413552710e+00 -1.3580540782727011e+00 + 56 -1.4207198828513452e+00 3.0787883554068443e+00 -1.5334043620685021e+00 + 60 -2.7430036755452867e+00 -4.7959755743412966e+00 -3.6589121362809793e+00 + 64 5.2745493408596680e+00 5.2305891172169332e+00 5.6658788951829120e+00 + 35 2.4928765089432634e+00 -5.3448694059941877e+00 2.3887118108529313e+00 + 39 4.7796063099958055e-02 1.0725963032581594e+00 1.7181088217424652e+00 + 42 -5.5692649798368743e+00 -1.6821639303091762e+00 -1.6723324968033218e-01 + 43 -1.4424925399687047e-01 -8.5523666921010619e+00 4.5258384510590621e-01 + 47 2.8527903759034379e+00 2.2528612008427649e+00 6.0359906613190466e+00 + 34 2.9635654591320097e+00 4.5094070096428251e-01 -3.4863299140598214e-01 + 38 -4.4510095261199589e-01 -2.0519825732102226e+00 9.2628347441614856e-01 + 51 -2.2828573674769213e+00 2.7781767264767150e+00 5.5620675245726012e+00 + 46 -2.4348265082156259e-01 -2.4117878531942281e+00 7.4570747320737123e+00 + 55 1.9489480373191797e-02 -3.7664964421140614e+00 -3.5726411020126752e+00 + 59 4.4138648986537783e+00 7.4012459625505356e-01 -2.5604939889732048e+00 + 63 8.3675946045751228e+00 -1.0836984638943927e+00 -3.0411489023050922e+00 + 50 -3.8404253960403993e+00 1.8877511590750304e+00 2.5404296022143984e+00 + 54 3.7304377536521460e-01 1.0130983067357455e+00 2.2264278235622006e-01 + 58 3.5290378879387294e+00 1.0620195995436412e+00 6.3876917379625520e-01 + 62 -2.9013359109981898e+00 4.7074815481252905e+00 -2.3570644684369930e+00 + 25 1.1155416794510971e+00 -1.7075022097207639e+00 4.4944420039447115e+00 + 20 -4.3187029083473529e+00 5.0333583520922209e+00 5.2930036036827008e+00 + 28 -2.0038065158576912e+00 7.4961629598766333e-01 8.7125788243024953e+00 +... diff --git a/unittest/force-styles/tests/manybody-pair-bop_save.yaml b/unittest/force-styles/tests/manybody-pair-bop_save.yaml new file mode 100644 index 0000000000..f2127a7f0c --- /dev/null +++ b/unittest/force-styles/tests/manybody-pair-bop_save.yaml @@ -0,0 +1,157 @@ +--- +lammps_version: 5 May 2020 +date_generated: Wed May 27 21:24:18 202 +epsilon: 1e-12 +prerequisites: ! | + pair bop +pre_commands: ! | + variable newton_pair delete + variable newton_pair index on + comm_modify cutoff 14.0 +post_commands: ! | + change_box all x final 0 14 y final 0 14 z final 0 14 +input_file: in.manybody +pair_style: bop save +pair_coeff: ! | + * * GaAs.bop.table Ga Ga Ga Ga As As As As +extract: ! "" +natoms: 64 +init_vdwl: 229.502330049105 +init_coul: -360.686843310281 +init_stress: ! |2- + 9.8370636261617548e+01 1.0009271927427929e+02 9.8087673650799545e+01 -4.9666892788617059e+00 3.2480551415561195e+01 2.9884184142795789e-01 +init_forces: ! |2 + 2 -1.8263567394371500e+00 -1.4180608690010226e+00 -1.1411979976674089e+00 + 4 5.0719016091806335e-01 -1.8057237340563612e-01 -1.0962975623380717e+00 + 5 -6.7895029755583602e-01 -1.1580184070865132e+00 1.0818217940471213e-01 + 9 -1.8693470551310727e+00 -1.2573015652812067e+00 -1.7447668003980394e+00 + 10 5.7344802761954361e-02 -2.0806591931751330e+00 -2.2262743599885200e+00 + 13 -2.4770517088274593e-01 4.4980575375194309e+00 -1.6377667054880565e+00 + 11 2.5047344239743370e+00 -3.4373732553424845e+00 2.1244778732828440e+00 + 12 -3.8636884971528436e+00 -4.3108978790114660e+00 -3.1418220562973738e+00 + 19 -1.0198800384860394e+00 -2.6761322253962025e+00 -3.3752922644567274e-01 + 21 -3.3298325356360209e-01 -3.8359267846884343e-01 -2.4806772337379965e+00 + 8 6.1798335543716698e-01 1.1820243894248470e+00 -1.7194019919057053e+00 + 29 -1.9945147130630443e+00 2.0803903462660407e+00 -2.2949545520905996e+00 + 16 1.4206310073812822e+00 -2.4085434647313092e-01 4.1430359498826812e+00 + 27 2.0068541740671089e+00 7.4395140739738241e-01 2.3459485096441921e+00 + 17 3.0229948833836806e+00 2.6748936562210877e+00 -2.3005394630036706e+00 + 18 -1.2210285062801753e+00 1.3155928491394759e+00 1.2686961377008017e+00 + 24 8.2638670208218620e-02 7.4144365811842625e-02 2.0666734068897675e-02 + 26 2.7093549436023746e-02 -6.9271060385762451e-01 1.2566811127273807e+00 + 32 -1.1595965681352090e-01 -1.3976800635927192e-01 1.3224245455988184e-01 + 3 8.2873058770991515e-01 9.3748007320394444e-01 -7.7535951065591868e-01 + 1 1.1595965681352090e-01 1.3976800635927192e-01 -1.3224245455988184e-01 + 36 -1.5234174848921145e-01 -2.9408786312426165e+00 -2.1961904356420331e-01 + 37 -1.3486114100020841e+00 1.1087408367864624e+00 -1.3777395790432716e+00 + 7 -1.3847541000785899e+00 -1.6046313040626370e+00 2.5262726038150296e+00 + 41 -3.5708864948996127e-01 -3.5940473779357168e-01 -5.4409457293803098e-01 + 45 -2.1641827357075734e+00 1.3307244288035727e+00 -3.4942166132949914e+00 + 15 -2.2171765787184574e+00 3.6547208095766375e+00 -1.9122298110085372e+00 + 44 3.5025068376725392e+00 -3.4617648386702573e+00 1.6106876842359206e+00 + 33 2.0266642505183672e+00 -2.6151288802501806e+00 2.5974523746415268e+00 + 6 -3.4842674703718884e-01 3.9043095404011803e+00 1.5983721408115077e+00 + 49 -2.7992316142200173e+00 -3.4205797218301242e+00 -3.5748188465203090e+00 + 53 2.7070516292437072e+00 2.9398311720118095e+00 1.6434285984414441e+00 + 14 -1.8177844790510349e+00 4.1434377791796457e+00 8.1493072449443904e-01 + 23 2.5610315795839864e+00 3.8836155348401404e+00 9.9814813230913091e-01 + 40 4.6986931841003567e+00 -1.9976837829184362e+00 -2.3125763095944700e+00 + 57 9.0474073001001146e-02 -1.0601913072984239e+00 -3.2960174902767808e-01 + 61 -1.6988167265427365e+00 1.8269669536015463e+00 -1.3720117275573034e+00 + 31 -1.9511654550951410e-01 3.8023218952608451e-01 4.2356012115267899e-01 + 48 1.5249422172107330e+00 7.5787368686969489e-02 4.4491770840391194e-02 + 22 -5.0430988309384253e+00 3.7020413609545004e+00 -3.8366800609269323e+00 + 52 4.3088244010357961e+00 -4.4356698267659249e+00 3.9254257628894274e+00 + 30 -1.3826582975741704e+00 1.0400985651230477e+00 -1.2260786047796837e+00 + 56 -1.0555049620942776e+00 1.3079942977807582e+00 -1.0745752137552673e+00 + 60 -1.6962505059009771e+00 -4.6137790972044801e+00 -2.1705934346532421e+00 + 64 3.0808261336511231e+00 3.1413604768568071e+00 3.1108884069467564e+00 + 35 1.3959955882157520e+00 -8.4631665492868635e-01 1.6674810145319829e+00 + 39 6.2820048659314787e-01 8.4229042021358932e-02 -1.0525117161665161e+00 + 42 -4.3799230472689930e+00 -1.4432995671646112e+00 2.8942575671754828e-01 + 43 5.8738872271264875e-01 -4.0150410920217450e+00 8.4856684462307697e-01 + 47 1.9530970591294399e+00 1.4187167780538439e+00 1.6133000921150709e+00 + 34 2.7626798587583837e-02 1.9334244652182114e-02 1.7419395950024935e-01 + 38 -2.1970789600406074e-01 -4.6762524302687118e-02 2.2021579972798938e-01 + 51 -1.8186738648918022e+00 2.0272296035989621e+00 4.2937244752484158e+00 + 46 -7.1460784727451476e-01 -1.3596469452119908e+00 4.9033501008237304e+00 + 55 6.7576842217513966e-01 -3.1074132695932213e+00 -3.3864997798374872e+00 + 59 2.9787943807382571e+00 1.6957261296696793e+00 -2.6807679537178868e+00 + 63 3.7475032428567294e+00 -1.2789954722960686e+00 -1.6076519751193632e+00 + 50 -1.3170106211213679e+00 1.1217072289962471e+00 9.7546031986257298e-01 + 54 2.8650966177596177e-01 -7.2293610544508791e-01 1.0058639724555830e-01 + 58 3.1128109616492874e+00 -5.8959484660624151e-01 8.5372265373140332e-01 + 62 -2.1820541673479572e+00 2.4884510598694281e+00 -1.7590338866984598e+00 + 25 2.1421443829733200e-01 -3.0491955555929523e-01 1.3612216311080305e+00 + 20 -3.0135333842372920e+00 3.0475984378967742e+00 2.5905800789514295e+00 + 28 -8.2411065297393349e-01 2.1142309379385305e-01 4.3747123967438419e+00 +run_vdwl: 225.483123234619 +run_coul: -358.525864873204 +run_stress: ! |2- + 9.2708340634004202e+01 9.4567250047602442e+01 9.3542392878203984e+01 -3.5188898428941879e+00 2.9172111770024983e+01 2.5838714184808751e+00 +run_forces: ! |2 + 2 -1.7952445271246664e+00 -1.4218851239799628e+00 -1.1587702523913164e+00 + 4 8.3608443721893311e-01 -2.9300301286855118e-01 -1.1300615346589309e+00 + 5 -8.0974284598680624e-01 -1.1743905637767758e+00 2.1194443649806144e-01 + 9 -2.1137406565834995e+00 -1.1189587128414018e+00 -1.8438345474652282e+00 + 10 -4.6803591985296066e-02 -1.9385835289305713e+00 -1.5715631476098573e+00 + 13 3.9516728015980274e-01 3.9884977620308151e+00 -1.3897244200262227e+00 + 11 2.1224282563066663e+00 -2.9696720334420705e+00 1.8102331225775177e+00 + 12 -3.5004456137542599e+00 -3.8012444953626483e+00 -2.6619954059079718e+00 + 19 -1.1827353281628663e+00 -2.7464995051745813e+00 -3.6513716492539117e-01 + 21 -1.3429601822013132e-01 -5.1202911643149118e-01 -2.5076125153203370e+00 + 8 5.2713815910806328e-01 1.1469424140595932e+00 -1.7206517405282333e+00 + 29 -1.8897897534108272e+00 1.9770299404566545e+00 -2.2761449369499362e+00 + 16 1.3574951697085507e+00 -3.5051996831920607e-01 3.5716346025832233e+00 + 27 1.9754081314959220e+00 5.5512144980327649e-01 2.1965106618877410e+00 + 17 2.6289345928448711e+00 2.3763340923405312e+00 -2.0313511348228737e+00 + 18 -1.3798861331946473e+00 1.3762714646580598e+00 1.2919153852528387e+00 + 24 3.3664631526424588e-01 -1.5598462775154304e-01 -1.6158927212020158e-01 + 26 -9.1319903515587442e-02 -4.9365927912993712e-01 1.2865878118928920e+00 + 32 -5.2461464343452280e-02 -6.3445874771083419e-02 6.0047690872422295e-02 + 3 5.5478781578872816e-01 1.0166262832007475e+00 -4.9270600194063685e-01 + 1 5.2461464343452280e-02 6.3445874771083419e-02 -6.0047690872422295e-02 + 36 -4.7957755204510966e-01 -2.6483422747174021e+00 -5.3805190516420609e-01 + 37 -1.2572679750686964e+00 9.6992929966066066e-01 -1.2270961498140143e+00 + 7 -1.1517087766541612e+00 -1.3245607639320900e+00 2.1503751717710062e+00 + 41 -1.4701041079431029e-01 -2.3080938022581338e-01 -3.2673541047210419e-01 + 45 -2.2413643960036964e+00 8.0325775766222773e-01 -3.0500826497180862e+00 + 15 -1.9891876262290782e+00 3.2416687992734254e+00 -1.5262610748773309e+00 + 44 3.3056208366847240e+00 -3.1571749982962367e+00 1.1182639533515728e+00 + 33 1.7888171042420402e+00 -2.2881077231541429e+00 2.2107802977083013e+00 + 6 1.2489390499997166e-01 3.6849603458227351e+00 1.6822337738199962e+00 + 49 -2.9994424951631067e+00 -3.4664174572228661e+00 -3.5674747455451401e+00 + 53 2.8124956399141539e+00 2.9660559514684497e+00 2.0685373458888394e+00 + 14 -1.9138573726925181e+00 3.8523404640765238e+00 7.5928353092630863e-01 + 23 2.5768083422823507e+00 3.8533003897315776e+00 9.5312752430003289e-01 + 40 4.6449644387898941e+00 -1.6920062703763807e+00 -2.1914395923558603e+00 + 57 5.1553323845256911e-02 -1.3671813398210970e+00 -3.8987060991398564e-01 + 61 -1.5348486017580774e+00 1.8011009782375174e+00 -1.2455408136685975e+00 + 31 -1.0066976443270784e-01 4.4203964938993617e-01 4.3880141855445942e-01 + 48 1.4535565137158473e+00 2.5952187241157976e-01 -3.3210475966326744e-02 + 22 -4.4355917278004471e+00 3.3178935668910494e+00 -3.2692290811528362e+00 + 52 3.8934964666261980e+00 -3.6369191438635475e+00 3.3519451907149684e+00 + 30 -1.2621388545199415e+00 8.1319864719143164e-01 -1.1462593883015966e+00 + 56 -9.6853921654063602e-01 9.6676984125909227e-01 -9.6934788270562888e-01 + 60 -1.8398166572824817e+00 -4.3838737927324054e+00 -2.2439588488613342e+00 + 64 3.0311416397213189e+00 3.1186981920332699e+00 3.0736206205182972e+00 + 35 1.3411637976344630e+00 -7.0966057217261513e-01 1.6154129097815140e+00 + 39 5.2435475770006990e-01 9.7036165266308726e-03 -1.0441916236238242e+00 + 42 -4.0727737583055967e+00 -1.6478523453785263e+00 1.4125120578899897e-01 + 43 3.7242001529259333e-01 -3.5616918801080111e+00 6.2600470217084692e-01 + 47 1.8346387590092910e+00 1.2824286835337535e+00 1.6235696472149697e+00 + 34 1.2954727830525320e-01 -6.0200675544908475e-02 1.8457241518256831e-01 + 38 -1.9027904716765798e-01 -4.3608165108422019e-03 1.9502009170946963e-01 + 51 -1.9595456145203474e+00 1.8918550738777526e+00 4.0715722065171711e+00 + 46 -5.5711891827535098e-01 -1.2214898451190077e+00 4.7520809728771933e+00 + 55 2.3521436347037364e-01 -2.7981702783839077e+00 -2.8171838683883714e+00 + 59 2.8374050093362801e+00 1.7351585453119913e+00 -2.4230495267529832e+00 + 63 3.5357973549417805e+00 -1.2721885918023130e+00 -1.5842416063937024e+00 + 50 -1.2415474182280879e+00 9.7988551618719577e-01 8.1053008547612437e-01 + 54 2.7074545892326524e-01 -6.6977778932741894e-01 1.1922242430325722e-01 + 58 3.0454225555369119e+00 -2.4963396862218679e-01 5.8727287281650487e-01 + 62 -1.9550862969301015e+00 2.2314107372332956e+00 -1.5611613409585052e+00 + 25 2.0909936419783498e-01 -2.2212812320858885e-01 1.2631598119352292e+00 + 20 -2.5961589908050140e+00 2.6426591433127462e+00 2.2346853176560528e+00 + 28 -9.1571123990994119e-01 2.8831752088653273e-01 4.0653791576256069e+00 +... diff --git a/unittest/force-styles/tests/manybody-pair-comb.yaml b/unittest/force-styles/tests/manybody-pair-comb.yaml new file mode 100644 index 0000000000..bb8383cd6e --- /dev/null +++ b/unittest/force-styles/tests/manybody-pair-comb.yaml @@ -0,0 +1,155 @@ +--- +lammps_version: 5 May 2020 +date_generated: Tue May 26 19:30:51 202 +epsilon: 1.0e-12 +prerequisites: ! | + pair comb +pre_commands: ! | + variable newton_pair delete + variable newton_pair index on +post_commands: ! "" +input_file: in.manybody-charge +pair_style: comb +pair_coeff: ! | + * * ffield.comb Si Si Si Si Si Si Si Si +extract: ! "" +natoms: 64 +init_vdwl: -275.751881079493 +init_coul: 0 +init_stress: ! |2- + 3.8073194277509302e+01 4.1007495365110245e+01 4.4067573198243295e+01 -6.7552732749378990e+00 2.6726661722305337e+01 2.8094275792955896e+00 +init_forces: ! |2 + 1 -7.7773551907908711e-01 2.8247596543345734e+00 1.3079009269893760e+00 + 2 -1.8152130072687704e+00 -1.2009468378400960e+00 -1.4751291672023381e+00 + 3 9.6298807688507981e-01 1.7113302865301083e-01 -8.9536582016243094e-01 + 4 -2.1176913938245869e+00 2.6189129211243767e+00 5.8603896379596510e-01 + 5 -1.9942883655888430e+00 -3.0219263787122536e-01 1.0216678225038286e-02 + 6 1.6910572153724987e-01 3.3936919390381699e+00 1.3904510251446307e+00 + 7 -7.8449600623721460e-01 -8.1141746577965734e-01 3.2110189378671823e+00 + 8 3.0538058013638020e-01 8.3551040448756386e-01 -1.3235929328413472e+00 + 9 -5.5780850209701516e-01 -2.3192138146720582e+00 -1.9907066175323656e+00 + 10 7.6250831093931021e-02 -1.9542588043709501e+00 -2.6688334461821070e+00 + 11 3.0386034695914814e+00 -3.5004996957229046e+00 2.9675425165642775e+00 + 12 -5.3314164643294344e+00 -3.8204324736925050e+00 -2.8063654353378009e+00 + 13 -4.4732786013323639e-01 4.7570778058875591e+00 -1.4163546943501750e+00 + 14 -1.5602916114539045e+00 3.9210941524724778e+00 2.3900632778944365e-02 + 15 -3.7176305594445793e+00 4.6429988530036121e+00 -2.8372682457950518e+00 + 16 1.7066805653544286e+00 -1.1066100973446247e-01 5.9242603096373996e+00 + 17 2.3198336153127173e+00 2.9483597098343073e+00 -3.5039826869216242e+00 + 18 -3.9996692170122827e-01 3.0854391946539117e-01 3.3694424553353182e+00 + 19 -1.2571312575531866e+00 -2.7334357936792051e+00 -3.8628454598797485e-01 + 20 -5.7425222661453832e+00 2.0343375133520780e-01 1.0224770474164471e+00 + 21 2.0536115751696906e+00 8.2665019797045047e-01 -2.0125073941326148e+00 + 22 -4.9825508533193865e+00 4.1151022895598945e+00 -4.6945991414982364e+00 + 23 1.9773508934595492e+00 3.2592055302022600e+00 1.0700298947591267e+00 + 24 1.8894804040829110e+00 1.0247427913411720e+00 3.0353789059074590e+00 + 25 7.6035693028898077e-01 -1.4868825364745319e-02 1.3589049480606676e+00 + 26 1.4158978505625192e-01 -3.1434409104898958e-01 1.0844263743748441e+00 + 27 2.2738874624511634e+00 -1.9314391781323362e-01 1.6015209849078811e+00 + 28 4.3258413945855168e-01 1.9896686584754573e+00 3.9089144709495542e+00 + 29 -3.0609567514736478e+00 1.0785760202953767e+00 -1.4442481625890624e+00 + 30 -1.4604020796936199e+00 8.7509293399206489e-01 -8.7234062201891849e-01 + 31 -1.3639960830898401e+00 1.5020815417757769e+00 -1.5372952064727685e-01 + 32 -2.7924706099917005e+00 7.7513917762024498e-01 -8.9981286693726581e-01 + 33 4.3462516719039055e+00 -2.5890297595737608e+00 2.9130917791315953e+00 + 34 8.6702948604247421e-01 -6.6915597072292776e-02 4.0173126227729838e-02 + 35 1.2333649639812814e+00 1.7569188905194899e-01 2.6141336237260435e+00 + 36 -5.3825350734163113e-01 -2.5728132063936835e+00 -2.3160451967347812e-02 + 37 -1.8213946820587967e+00 1.3435525863949602e+00 -2.0326823514567192e+00 + 38 -9.1863548637690418e-01 -3.0373605361668954e-01 7.2967096452479241e-01 + 39 2.9119584590224754e+00 -1.4073200526260301e+00 -3.5341351957817952e+00 + 40 4.1511912453477073e+00 -1.9560455827727017e+00 -2.2568414069570721e+00 + 41 -3.3733746501631856e-03 -9.0458206731973423e-01 -8.3342103506533238e-01 + 42 -3.4494055350443045e+00 -1.3959725628665207e+00 -3.1129838792119902e-01 + 43 1.0285546908996406e+00 -4.6957881003895379e+00 1.7273784019468774e-02 + 44 3.1944436557772691e+00 -3.5114991775842181e+00 1.8132214173995469e+00 + 45 -2.3485161709111262e+00 1.5760120206904780e+00 -2.8788633537567954e+00 + 46 -5.2653152582365426e-01 -1.4446191368204930e+00 4.9838195090350981e+00 + 47 2.6868585640903739e+00 1.7265316767888992e+00 7.6392468506300482e-01 + 48 1.2747899188181782e+00 -2.7670763770165285e-01 -8.9752819527847638e-02 + 49 -2.6996435637937308e+00 -4.1956451968554047e+00 -2.3350041480924268e+00 + 50 -5.6197993856796291e-01 2.6648857728410960e+00 -1.1952716416604021e+00 + 51 -2.0029715841449409e+00 2.0448853225242898e+00 3.7292313284873284e+00 + 52 4.7052456990574951e+00 -4.9522855831556436e+00 4.5257645077258681e+00 + 53 3.6332609816368979e+00 3.1007467579375110e+00 2.0930796308706414e+00 + 54 2.6042732306409517e+00 -3.2869087438083451e+00 -2.2112248989753125e+00 + 55 1.2186738350113355e+00 -3.0302157427484033e+00 -4.0989455583783956e+00 + 56 -5.0104589734434946e-01 -3.0330365981819263e-02 -1.8943149238143051e+00 + 57 -6.6665911733447908e-02 -8.4301867212566450e-01 -2.6020871941913154e-01 + 58 2.5380346573775858e+00 -8.7661228264214486e-01 1.4960768217200413e+00 + 59 2.9968798220086494e+00 2.5105114972286393e+00 -3.1785825283901530e+00 + 60 -2.9309240327015966e+00 -5.0196306109850655e+00 -2.7042001796731974e+00 + 61 -1.2139913595287466e+00 1.5502256830430707e+00 -1.1513544289412680e+00 + 62 -3.1661341866163668e+00 3.0572378789319057e+00 -2.1766321256993351e+00 + 63 2.4681627533803421e+00 -4.3463718591241030e+00 -2.6890657263468221e-01 + 64 2.9466851841874400e+00 3.1594069934522051e+00 5.2240357776040334e+00 +run_vdwl: -278.64539237138 +run_coul: 0 +run_stress: ! |2- + 3.2603718810965603e+01 3.5156988145665579e+01 3.7681890976318726e+01 -5.5775632087859073e+00 2.2840452275450104e+01 2.0531486195056812e+00 +run_forces: ! |2 + 1 -5.5397306955905634e-01 2.5532121805668933e+00 1.0779428121145571e+00 + 2 -1.6205109647151392e+00 -1.0452678927072085e+00 -1.3123147689675791e+00 + 3 9.2492584410483392e-01 2.3258483169401423e-01 -8.7074914258129654e-01 + 4 -1.8809319959865389e+00 2.2889432632664413e+00 3.2415430923337407e-01 + 5 -1.8929830622204289e+00 -2.7856584709070237e-01 -1.3871794499142193e-03 + 6 2.6832146152631214e-02 3.1705576574942653e+00 1.2843474477053722e+00 + 7 -7.4098057776004567e-01 -7.4561069525239276e-01 3.0855025146293191e+00 + 8 2.9560919501422128e-01 7.9434657493317973e-01 -1.2758663869501270e+00 + 9 -4.3187667703244870e-01 -2.1894305992975136e+00 -1.8545629391445928e+00 + 10 1.1030480790250274e-01 -1.8828797400505597e+00 -2.5052292079229947e+00 + 11 2.5621539986299333e+00 -3.1047262882622508e+00 2.5939511966583892e+00 + 12 -4.6636574436680380e+00 -3.1353405533941459e+00 -2.2522344584108005e+00 + 13 -2.2531162730421139e-01 4.2000481115201795e+00 -1.1961646085016158e+00 + 14 -1.3679332950923977e+00 3.5129283143613512e+00 2.8193031191732498e-01 + 15 -3.1213951029651739e+00 3.9481419946547267e+00 -2.2067190999598374e+00 + 16 1.4984375278271820e+00 -4.0576209729337531e-01 5.0335590341302918e+00 + 17 1.9789497195844739e+00 2.5740016211163232e+00 -3.1419520414469448e+00 + 18 -4.1880096903474273e-01 2.5856719013810903e-01 3.0862486816165422e+00 + 19 -1.1131273417550649e+00 -2.5169340303232848e+00 -2.0252736699689511e-01 + 20 -5.0584845485949979e+00 4.4822360054849852e-02 7.8274242101248603e-01 + 21 1.8799822442531455e+00 8.6561357765736235e-01 -1.7960994606260285e+00 + 22 -4.0548484069165145e+00 3.2356894546081207e+00 -3.6478999893817523e+00 + 23 1.8742900336278192e+00 3.0198507422284568e+00 8.3337196377476008e-01 + 24 1.7077784543129124e+00 7.9568135448205268e-01 2.7897381771777905e+00 + 25 7.3084794943112108e-01 2.1842857042399189e-02 1.3295697271823153e+00 + 26 1.2343345472846939e-01 -2.9263233644700481e-01 1.0697468816570765e+00 + 27 2.0657370541600910e+00 2.0103654000545167e-02 1.4591662468309909e+00 + 28 5.3872046657870243e-01 1.9102787172287403e+00 3.3715130661571759e+00 + 29 -2.8856028875180844e+00 9.0351646942263053e-01 -1.2676274670625387e+00 + 30 -1.4084547025716105e+00 8.2324986888554441e-01 -8.2858137093834827e-01 + 31 -1.3279936146893441e+00 1.4477088194222376e+00 -1.2765091390576577e-01 + 32 -2.6380662103899648e+00 6.8724849661915322e-01 -7.9931239141381738e-01 + 33 3.7895183341746748e+00 -1.9566198887983730e+00 2.2505126540203988e+00 + 34 8.5883652728199689e-01 -5.3566728436796218e-02 3.9237705744395335e-02 + 35 1.1644578963583530e+00 2.7144660881885407e-01 2.4026536195925643e+00 + 36 -5.3048368793908085e-01 -2.4758426990856779e+00 -3.0463539756172289e-02 + 37 -1.6654318534959174e+00 1.1930142332191604e+00 -1.8603517597249892e+00 + 38 -8.9081952354286464e-01 -2.9114390049618688e-01 6.8706642209427693e-01 + 39 2.6056927414132929e+00 -1.1478222801590530e+00 -3.2064461264819064e+00 + 40 3.7452234011856818e+00 -1.6143442144484257e+00 -1.9653540040056641e+00 + 41 -1.5227324691871935e-02 -8.9734904260981285e-01 -8.3345326021675170e-01 + 42 -3.2399160547926873e+00 -1.2271836120192232e+00 -2.0534738572382941e-01 + 43 9.0052122056985695e-01 -4.2424836367875995e+00 -9.3139821069259665e-02 + 44 2.7878561135455322e+00 -3.0928968455175889e+00 1.5322877363035767e+00 + 45 -2.1040990928666767e+00 1.2877395979091484e+00 -2.5402153820887490e+00 + 46 -2.8057693869514200e-01 -1.2582731837723404e+00 4.4490871461839268e+00 + 47 2.5104050907433013e+00 1.5895434963732580e+00 5.6184826880643790e-01 + 48 1.2692907009127792e+00 -3.0712740683597839e-01 -9.5770674686733281e-02 + 49 -2.3261423089284090e+00 -3.7378754972534836e+00 -1.8872334371865680e+00 + 50 -5.8081173869631009e-01 2.5496046956213245e+00 -1.1433307738006722e+00 + 51 -1.6449177803323278e+00 1.6149408965826320e+00 3.4135148274579401e+00 + 52 3.8302890563828664e+00 -4.0488676686085610e+00 3.4764387160426482e+00 + 53 3.2036103752554803e+00 2.6792299550456202e+00 1.6508090953042884e+00 + 54 2.3261285765448347e+00 -3.0155250108799159e+00 -1.8972572016801941e+00 + 55 8.2522866651108195e-01 -2.6052530646882328e+00 -3.6486212989846201e+00 + 56 -4.1222748994070124e-01 -9.0889178078118249e-02 -1.7263415682221259e+00 + 57 -5.6265630303914287e-02 -7.9967585610695224e-01 -2.6228933098085871e-01 + 58 2.4498430827774502e+00 -7.4597039405006582e-01 1.3844040814812364e+00 + 59 2.5126209260371275e+00 2.1135650148148510e+00 -2.8984636887562001e+00 + 60 -2.3478919343951086e+00 -4.2888509317848458e+00 -2.0619124848417005e+00 + 61 -1.2028214481978468e+00 1.4703329239436540e+00 -1.1112072076318062e+00 + 62 -2.9560311639616308e+00 2.8122848350725427e+00 -1.9886316384994360e+00 + 63 2.2315862818463441e+00 -3.8949051147749056e+00 5.3755961210724124e-03 + 64 2.3294845807056084e+00 2.4989758665119504e+00 4.4859887170485715e+00 +... diff --git a/unittest/force-styles/tests/manybody-pair-comb3.yaml b/unittest/force-styles/tests/manybody-pair-comb3.yaml new file mode 100644 index 0000000000..3b70a0513c --- /dev/null +++ b/unittest/force-styles/tests/manybody-pair-comb3.yaml @@ -0,0 +1,155 @@ +--- +lammps_version: 5 May 2020 +date_generated: Tue May 26 19:34:40 202 +epsilon: 1.0e-13 +prerequisites: ! | + pair comb3 +pre_commands: ! | + variable newton_pair delete + variable newton_pair index on +post_commands: ! "" +input_file: in.manybody-charge +pair_style: comb3 polar_off +pair_coeff: ! | + * * ffield.comb3 C C C C N N N N +extract: ! "" +natoms: 64 +init_vdwl: -4.262196799538 +init_coul: 0 +init_stress: ! |- + -5.4044225127487408e+01 -5.6294823503326228e+01 -6.1598553071527618e+01 4.6162435900156122e+00 -2.0509689129709702e+01 -4.2576678528074137e+00 +init_forces: ! |2 + 1 8.3104140069636778e-01 -7.2151374022104098e-01 -9.0883913671076377e-01 + 2 -2.0637148147196051e-03 -2.1255486510879298e-04 5.7411164018030137e-03 + 3 3.2330181820271059e-03 7.5968878104374889e-03 -3.4348949196179629e-03 + 4 7.8087009439436805e-01 -9.3985775318676990e-01 -9.5567606600447430e-01 + 5 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 6 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 7 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 8 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 9 1.1848091467122548e-03 -3.9110836422350977e-03 -7.5138989068182652e-03 + 10 -4.5570925334803419e-03 -7.8994341854715724e-03 -8.1753922692589156e-03 + 11 -2.4818858319587860e+00 2.1489282118859703e+00 -1.8640286299137689e+00 + 12 5.5403762223352713e+00 5.9155132025272952e+00 5.3936110645786419e+00 + 13 2.4846028399149240e+00 -2.1516902703383707e+00 1.8739771324907935e+00 + 14 2.0618714008342756e+00 -1.8399685505021717e+00 2.2692461526239662e+00 + 15 3.8433408155430397e+00 -4.3297310437400842e+00 5.1483662319302610e+00 + 16 -3.5007680988615113e+00 -4.1645288623158958e+00 -7.0722950659982899e+00 + 17 -2.0392451933220563e+00 -1.7582992254056438e+00 1.6761617435175991e+00 + 18 -8.9217938521746996e-03 2.4020170807160994e-03 4.5871089167712452e-03 + 19 2.5255412814827577e-03 -4.3611075390410986e-03 1.3786719724695874e-03 + 20 3.2844296232807739e+00 -2.5479461314658933e+00 -2.0211211618819114e+00 + 21 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 22 7.3778491349805249e+00 -7.1512802978365322e+00 8.9295337516531710e+00 + 23 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 24 -4.7590504036316206e-01 -5.5466217496793369e-01 -5.7257766665546028e-01 + 25 -2.1532383463416719e-03 -2.2364300453261486e-04 3.3626501149952950e-03 + 26 4.5724747484562536e-03 7.5221568185905867e-04 7.3797695807181979e-03 + 27 4.7151524327155034e-03 1.5639966552134957e-02 7.4943080009604911e-03 + 28 2.5165464976122660e+00 -2.0600934316390602e+00 -2.9321849196678387e+00 + 29 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 30 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 31 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 32 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 33 -3.8392094870177478e+00 4.3383682501870977e+00 -5.1470238022140151e+00 + 34 1.0458206061923953e-02 1.2730803272677858e-03 -6.0038680168180720e-03 + 35 2.4483565941686696e-03 6.7614503633665430e-03 3.9376953148958149e-03 + 36 -5.3856668710029259e-03 -7.5993721067773856e-03 5.4257886268142190e-04 + 37 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 38 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 39 -7.8777855626787230e-01 9.4319856038537409e-01 9.4977957789293788e-01 + 40 -2.4918184462877928e+00 2.8552098697788346e+00 2.2916152802189873e+00 + 41 -2.6021528733333465e-03 -6.6861414253559489e-03 -6.2513785433358339e-03 + 42 -1.3560627534732738e-02 -2.0696573806687417e-03 5.5379011380387389e-03 + 43 -6.0314060449036278e-01 6.9573027350241290e-01 -7.4841350630968306e-01 + 44 -2.0512952054941369e+00 1.8352513049941539e+00 -2.2660838644066854e+00 + 45 6.0705883978745001e-01 -7.0644344248350144e-01 7.4787407064343481e-01 + 46 4.2193194608816684e+00 3.9056858991717780e+00 -3.1805729412955257e+00 + 47 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 48 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 49 3.2476473769060705e+00 3.8760755698869427e+00 4.3714165671083061e+00 + 50 -4.4711096339615794e-03 5.7594725718924924e-03 -2.9474883917371408e-04 + 51 2.4912576285796106e+00 -2.8610327320817519e+00 -2.2805017545676010e+00 + 52 -7.3697092903203396e+00 7.1446422777888881e+00 -8.9321147541367534e+00 + 53 -3.2585196229519680e+00 -3.8803049460445278e+00 -4.3741493063698265e+00 + 54 -8.2793378797318695e-01 7.2566786270334316e-01 9.0392926012227648e-01 + 55 -2.8172784502848920e+00 3.0991941858106058e+00 2.5958541979738636e+00 + 56 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 57 8.4477608622557517e-04 8.5822979652785437e-03 -4.0574073377672663e-03 + 58 1.0974852126866457e-02 2.6948194431417475e-03 -4.8597272134201503e-04 + 59 -4.2121038582635597e+00 -3.8984247780767802e+00 3.1644200940476805e+00 + 60 4.9751130782417716e+00 5.4512675791863483e+00 5.6133838316010802e+00 + 61 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 62 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 63 -2.5176670219302633e+00 2.0717736507107034e+00 2.9357584209133982e+00 + 64 -4.9843077084015803e+00 -5.4592285318606883e+00 -5.6130890399330191e+00 +run_vdwl: -8.49268945242757 +run_coul: 0 +run_stress: ! |- + -7.3797567645145961e+01 -7.7584319730040974e+01 -8.3342647260134825e+01 7.0938246898836974e+00 -2.4910142288706471e+01 -1.1052327572739250e+01 +run_forces: ! |2 + 1 1.2601710105866797e+00 -1.0977233863187708e+00 -1.3772696443257477e+00 + 2 -1.6493479379932397e-03 -9.1248445550026159e-05 5.9701311031610301e-03 + 3 3.3820572608969368e-03 8.5521187645746476e-03 -4.6879090640333616e-03 + 4 1.1924413765949562e+00 -1.4326748930991036e+00 -1.4519947462386757e+00 + 5 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 6 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 7 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 8 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 9 1.1011770288065228e-03 -3.9056394222139741e-03 -7.8316919368359959e-03 + 10 -4.8732624579561692e-03 -7.8247393902565153e-03 -8.4014108100402985e-03 + 11 -3.9198577361272973e+00 3.3943827075612840e+00 -2.9488815032500826e+00 + 12 7.5755907014699142e+00 8.0808716879391778e+00 7.3065108886254571e+00 + 13 3.9230662035375534e+00 -3.3974166138288706e+00 2.9589801889217089e+00 + 14 3.2496221529217930e+00 -2.8998558479006338e+00 3.5763931643737141e+00 + 15 5.8621937724381752e+00 -6.6038599172524277e+00 7.8526619176418473e+00 + 16 -6.0354206691585279e+00 -6.7582792818441808e+00 -8.5510478256619784e+00 + 17 -1.5397733986077347e+00 -1.3315596514305144e+00 1.2402134158101406e+00 + 18 -9.2057661530317806e-03 2.3520318788864589e-03 4.0111516626017418e-03 + 19 2.4618298642403763e-03 -4.4243673049978423e-03 1.3621645427986549e-03 + 20 4.8112624548119189e+00 -4.3444774342909227e+00 -3.5373527320628204e+00 + 21 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 22 7.3369465010957011e+00 -7.1116099715000622e+00 8.8797912269397301e+00 + 23 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 24 -4.2601836462585518e-01 -5.0395425667637128e-01 -5.1952212818162302e-01 + 25 -2.4327828893773887e-03 -3.7730397656368799e-04 3.8196097788385469e-03 + 26 4.8268242621580916e-03 7.5762727887721860e-04 7.3439109155819761e-03 + 27 4.5058495192822840e-03 1.6931220122220005e-02 8.4998947737821608e-03 + 28 3.9859608719696160e+00 -3.2692360837103860e+00 -4.6455115101164628e+00 + 29 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 30 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 31 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 32 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 33 -5.8572235070309899e+00 6.6134174900119067e+00 -7.8508330617950470e+00 + 34 1.0288938857885540e-02 1.2625572334860741e-03 -6.0841713134835908e-03 + 35 2.3110873379904463e-03 6.5845183297797219e-03 3.6286854232872039e-03 + 36 -5.4094241242753673e-03 -7.8666007083064392e-03 2.7581893198741714e-04 + 37 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 38 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 39 -1.1995877109356030e+00 1.4362379370120428e+00 1.4462305723485172e+00 + 40 -3.9480352153322609e+00 4.5237333059017963e+00 3.6309325049885048e+00 + 41 -2.6494392352298893e-03 -6.6629222610104849e-03 -6.3019883521462624e-03 + 42 -1.4002246550612642e-02 -2.7057913731241773e-03 5.5941748010221734e-03 + 43 -9.1048927710541194e-01 1.0539543545232359e+00 -1.1268554602535943e+00 + 44 -3.2385649712771825e+00 2.8948706370093800e+00 -3.5726366381616335e+00 + 45 9.1459582698544972e-01 -1.0643429786328398e+00 1.1267358417879532e+00 + 46 6.5916706816610358e+00 6.1017014127048537e+00 -4.9690282103045202e+00 + 47 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 48 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 49 5.0701430226628075e+00 6.0463196913822923e+00 6.8179001643010757e+00 + 50 -3.9037131687346279e-03 5.4811939162223815e-03 -9.0308942205962763e-05 + 51 3.9473009737523754e+00 -4.5285103708642120e+00 -3.6193454999534920e+00 + 52 -7.3277038458522554e+00 7.1037425858553762e+00 -8.8797730740548300e+00 + 53 -5.0817480094222063e+00 -6.0513157240114719e+00 -6.8214346690872816e+00 + 54 -1.2571926096430224e+00 1.1019241455456459e+00 1.3725852315450791e+00 + 55 -4.3947828280151535e+00 4.8453501895858855e+00 4.0595637281885981e+00 + 56 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 57 9.3904984905926990e-04 8.8840016048667321e-03 -4.2850449790286646e-03 + 58 1.0863597548913782e-02 2.6848117403995568e-03 -1.2614764022259679e-03 + 59 -6.5833231226638445e+00 -6.0935937724583598e+00 4.9517495139799950e+00 + 60 7.2005497067801461e+00 7.8887466219189948e+00 8.1202714484072249e+00 + 61 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 62 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 63 -3.9875093604492866e+00 3.2813977842968987e+00 4.6497082934375324e+00 + 64 -7.2108390600335159e+00 -7.8978718354169333e+00 -8.1203029379823484e+00 +... diff --git a/unittest/force-styles/tests/manybody-pair-gw.yaml b/unittest/force-styles/tests/manybody-pair-gw.yaml new file mode 100644 index 0000000000..c53361cc6b --- /dev/null +++ b/unittest/force-styles/tests/manybody-pair-gw.yaml @@ -0,0 +1,155 @@ +--- +lammps_version: 5 May 2020 +date_generated: Wed May 27 06:34:15 202 +epsilon: 5.0e-13 +prerequisites: ! | + pair gw +pre_commands: ! | + variable newton_pair delete + variable newton_pair index on +post_commands: ! "" +input_file: in.manybody +pair_style: gw +pair_coeff: ! | + * * SiC.gw Si Si Si Si C C C C +extract: ! "" +natoms: 64 +init_vdwl: -175.936189332503 +init_coul: 0 +init_stress: ! |- + -5.8276420551105821e+02 -5.8346830418436662e+02 -5.9635186090956915e+02 -4.0793904942361108e+00 -2.1745769426357356e+01 6.6659517988421783e+01 +init_forces: ! |2 + 2 4.2357502846692050e+00 -1.0684948194982658e+01 7.8771260447967384e-01 + 5 5.6356217986200070e+00 5.0000768669845739e+00 7.2555453803852439e+00 + 4 1.3053845228045087e+00 -1.1939969136779807e+00 1.1402808300021505e+01 + 9 -1.4781063062061760e+01 3.8439767160068050e-01 1.1989506818951920e+00 + 11 2.2298859075728452e+00 4.2642036622917443e+00 7.9491883549356395e+00 + 13 -8.1934442969032362e-01 -2.9671165161482826e+00 7.1910517613949643e-01 + 8 -3.3071119986187840e+00 -8.5637325073483850e-01 1.7806260554154885e-01 + 27 1.7416046508201783e+00 -8.0463285375032374e+00 4.5451811986594876e-01 + 12 8.5883724596626809e+00 -8.0924194026005534e+00 -5.8623322353813272e+00 + 16 -7.0067366748220881e+00 6.2830854151483777e+00 3.7585497395851859e+00 + 17 9.0905582651496228e+00 3.4397567563062226e+00 6.2865859384567289e+00 + 18 -3.7214378635474126e+00 -3.6025131340548784e+00 1.8833585588346959e+00 + 21 -2.7802773760060555e+00 -1.0907996739970134e+01 1.2455850331305434e+00 + 19 4.2329545594690948e-01 -3.9381769512998726e+00 -8.3399572256640369e+00 + 29 4.3809985053476472e+00 8.7006006280132819e+00 -2.5085295217060066e+00 + 24 4.8832090771515020e+00 7.1126931295568605e+00 1.8948749694354730e+00 + 26 6.4193598371022759e-02 2.7384662279991095e-01 -7.1402609412555469e+00 + 1 -8.7926636042793973e+00 -1.7562715016439774e+00 -4.5862136805468579e-01 + 32 8.0683746340921250e+00 4.8645101145691445e+00 -4.2398095537132292e+00 + 7 -3.4705773220172071e+00 -6.8307531883308439e+00 -6.9347131449224149e+00 + 15 5.3938836431044468e-02 -9.2248237708860614e-01 -9.3587492833217585e+00 + 33 -9.4005252571549924e+00 -6.1931403820138788e+00 4.8929083518309726e+00 + 6 7.0002225174685622e+00 -4.8444755472447731e+00 3.8855862246844750e+00 + 10 -6.7082046379875218e+00 2.6859550331152078e+00 -3.3137123359811049e+00 + 14 6.5884837181499769e+00 3.0287795154024613e+00 -7.3778415419231083e+00 + 44 1.4577056026759643e+00 4.3313512565327299e+00 1.2961201157269365e+01 + 49 -6.3914488137818575e+00 8.9625197638904499e+00 -6.6543576526321599e+00 + 23 7.2613514027542010e+00 -8.5850477051845395e+00 5.0245991508809764e+00 + 31 8.9862694832490959e+00 -4.8524059838438767e+00 1.4671175930287688e+00 + 3 -9.5436962702495975e-01 3.5730303370702501e+00 -7.0008188002880756e-01 + 22 8.5433498665890450e+00 5.6105493218414280e+00 -7.5389345975660014e+00 + 30 1.0721463726559696e+01 -5.0407823405527044e+00 4.4640823827710010e+00 + 60 -6.8831000475563062e+00 9.8973374391645503e+00 -5.6086362451445808e+00 + 35 -1.5256310545922169e+00 -1.1044770570611641e+01 -8.8952348161151440e-01 + 37 -2.4143940427112440e+00 1.5851638195220861e+00 6.1728796068818710e+00 + 41 1.1768950345823814e-02 2.5323964216807244e+00 9.6796571992980649e+00 + 45 -8.7965206694647460e+00 4.9371963744980576e+00 -4.3763398056872118e+00 + 36 -1.1255635250669305e+00 1.2608921137270897e+01 -5.0952035433499887e-01 + 40 -3.6004231459804474e+00 -3.5970669014992191e+00 -7.2688204837564205e+00 + 42 8.1132489891103621e+00 -3.9405211294000400e+00 -5.5349366014308288e+00 + 48 -9.2658082105677320e+00 -8.4309088497502156e+00 4.9980608507763584e+00 + 53 2.5982753803472263e+00 3.3318724281023088e-01 1.1929343596685065e+01 + 51 -1.1362718299898933e+01 -7.2181393963698237e-01 -3.9383552153545041e+00 + 57 -3.6891436796088666e+00 1.1637555558079814e+01 3.0558861431501145e+00 + 61 -2.2645147642385752e+00 -1.4899895124783386e+01 -6.0034787388956623e-02 + 52 -9.6802689040459378e-01 1.9659965360569158e+00 1.9055763687258263e+00 + 56 -3.0695500083263783e-01 3.8628435017019340e+00 4.2302323005805640e+00 + 58 -1.1453519567233851e+01 -1.2916816897211105e+00 4.1462912559358154e+00 + 64 5.8092450572613377e+00 6.0819193766747937e+00 -9.3149111631847408e+00 + 39 6.8819733439425530e+00 -4.4906856150195225e+00 9.6262854218448695e+00 + 43 -2.2213547279484347e-01 3.1383369543541990e+00 9.3274012550271146e-01 + 47 -3.9475536976337600e-01 3.9145663528794286e+00 9.1713916446111821e+00 + 38 -1.8831704877497835e-01 5.5082277160898929e+00 -2.6609061963860778e+00 + 25 -4.8140844634213886e+00 -2.1012530134593779e+00 -9.2794887758294351e+00 + 46 -7.5059911494674738e+00 6.6415894286928383e+00 4.2806423802412183e+00 + 59 5.3658650951247084e+00 7.6532621061599926e+00 -8.4703878219623334e+00 + 34 -1.0662231298724807e+00 1.9262307028607504e+00 -6.3066032507587702e+00 + 50 6.3000783383769301e+00 -4.8327156653180161e+00 -2.1880861490079484e+00 + 55 1.2171102828362111e+01 -6.1393472942948402e-01 -1.6660029288996342e-01 + 28 -6.8458498037813316e+00 -6.2031109762709660e+00 3.2853792468017167e+00 + 63 -4.8143228297845866e+00 -4.0270544701096345e+00 -6.1213019115492795e+00 + 54 2.1706833879608967e+00 3.8604308614060052e+00 -9.5977298515051555e+00 + 20 4.2075141153830451e+00 -9.7642174596615838e-02 4.5461334652744778e-01 + 62 2.7519690325090496e+00 -9.9223410854458582e-01 1.1407638591976261e+00 +run_vdwl: -193.312864805708 +run_coul: 0 +run_stress: ! |- + -5.4066946404968030e+02 -5.3539705120734573e+02 -5.4571811632711672e+02 3.9789054403510207e+00 -2.5639055286872550e+00 5.1038719967247225e+01 +run_forces: ! |2 + 2 3.8589634564297346e+00 -1.2182272415511365e+01 1.2200876906255023e+00 + 5 3.6065089887595296e+00 5.1669430011686659e+00 9.9870487605114597e+00 + 4 3.7859620745039999e+00 4.7662618068459484e-01 9.6619345448570559e+00 + 9 -1.2921199082421369e+01 6.9733873984331585e-01 1.0987604447572705e+00 + 11 4.7437464253584665e+00 6.4387785208763022e+00 8.4065759815660890e+00 + 13 -1.0854155791565836e+00 -2.4775958244949554e+00 1.1195054660751282e+00 + 8 -3.8060684015514470e+00 -4.5723044932663481e-01 -6.4461929458864398e-01 + 27 1.6901849786610461e+00 -7.4878198235782731e+00 -1.1555757174490462e+00 + 12 6.8036849877976984e+00 -5.1988280044239286e+00 -3.5984551032716823e+00 + 16 -6.6413875064969945e+00 5.9302349269882635e+00 3.2559703717735746e+00 + 17 7.7777501510945477e+00 2.7644616910254904e+00 5.6707274818522722e+00 + 18 -5.4427524537043048e+00 -4.0179426490246151e+00 1.0850216369611116e+00 + 21 -2.6596070018577223e+00 -9.4619454789250241e+00 1.1729558941784273e+00 + 19 2.7140607305224616e+00 -1.9413883345089769e+00 -8.9692209726468874e+00 + 29 5.2836643266529038e-02 7.7586444923075950e+00 2.0821877168214566e+00 + 24 2.0331437118897773e+00 7.9924622886378982e+00 2.9582471903448839e+00 + 26 2.5619715103499980e+00 -2.3890336240086594e+00 -7.6784957495940489e+00 + 1 -8.6277798795624054e+00 -3.6815622035526563e-01 -3.9567082453141946e+00 + 32 6.9011456891725294e+00 2.0042051227213102e+00 -1.6457810562548612e+00 + 7 -2.1046785202808467e+00 -4.0938239124149387e+00 -9.1090089768285694e+00 + 15 -6.8987501158202225e-01 -1.1242442813924427e+00 -1.1686899502323723e+01 + 33 -7.1279903554204003e+00 -3.5306966309785830e+00 2.6325811823126530e+00 + 6 4.2244236236724886e+00 -6.1786050351305084e+00 4.4134657034505089e+00 + 10 -7.2048633787273113e+00 -8.1550180347605306e-01 -1.1253890151943271e+00 + 14 5.2998514529186513e+00 1.9682617371316087e+00 -6.0760696784610051e+00 + 44 -3.5292579564572291e-01 1.9997711805972200e+00 1.3016112471305417e+01 + 49 -3.1045046254934303e+00 6.0501772937557954e+00 -2.9302380344079602e+00 + 23 8.6236802547201243e+00 -9.1169465049242628e+00 6.3075864900762877e+00 + 31 7.0560180290044121e+00 -4.7496845240573371e-01 -2.0845959358299986e+00 + 3 1.3300303630536732e+00 2.3326294241228762e+00 -1.7282095861020628e+00 + 22 8.6942470489730699e+00 5.8139049031439898e+00 -6.2007015148032405e+00 + 30 6.8230136508545502e+00 -3.0045595155403859e+00 2.6132954335670604e+00 + 60 -3.7907604359541596e+00 6.9367356178894246e+00 -2.7380157783755998e+00 + 35 -3.4146980875472899e+00 -9.7380268825987173e+00 1.1151703291202315e+00 + 37 -5.8484339564150005e+00 4.5884928602723205e+00 8.9741758855614151e+00 + 41 -1.8400572364289123e+00 1.4201593566377635e-01 1.1478634359316157e+01 + 45 -5.5717226200137109e+00 4.6933518996947239e+00 -6.4188879232681586e+00 + 36 -3.1018390582490536e+00 8.1181667986228199e+00 -3.2099991161225505e+00 + 40 -4.1115802782835837e+00 -5.1337672078715557e-01 -2.5851323735447522e+00 + 42 7.8777278483406352e+00 -3.5790973798948587e+00 -3.0407987965288816e+00 + 48 -6.3517307140140797e+00 -8.9281828600248510e+00 7.6789287567742690e+00 + 53 3.1268392260466551e+00 -8.0987971044106155e-01 1.0609349758585569e+01 + 51 -1.1667642034478254e+01 -1.6310692693619107e+00 -2.7745502863523579e+00 + 57 -1.8152866890052484e+00 1.4359221590238048e+01 1.0017438179016009e+00 + 61 -4.7142147341717209e+00 -1.3612089754044785e+01 -3.0602646797848516e+00 + 52 -2.7582215166422523e+00 5.1218857342030311e-01 -2.8687362304964287e-01 + 56 5.1626356890365477e+00 5.6647250512757319e+00 3.0358278852642586e+00 + 58 -1.1291990567197121e+01 -1.3980521338702996e+00 4.2848456761750349e+00 + 64 3.6903701909626299e+00 3.5226180145711403e+00 -6.9391296757848151e+00 + 39 5.9379708204147610e+00 -4.0464116424892840e+00 9.0922229953492550e+00 + 43 -3.8534204387524340e-01 2.8930068300635017e+00 1.0510088118927550e+00 + 47 9.2950788093183445e-01 -2.3284970590293624e-01 8.1211036777812637e+00 + 38 -1.7135927419887675e-01 6.3554185023487069e+00 -4.5417101109085039e+00 + 25 -3.3490572228344759e+00 -3.6329693424919318e+00 -8.7373332500681720e+00 + 46 -7.7777235196332217e+00 6.8515631888706823e+00 4.6134653707329480e+00 + 59 5.9828280745310183e+00 5.2968296013142702e+00 -6.6890694908714057e+00 + 34 1.3564237012886158e+00 1.8876264168932266e+00 -1.1505824128346026e+01 + 50 3.9793021967016564e+00 -4.4234148576269545e+00 -3.3195367986874103e-01 + 55 1.0845720108316186e+01 9.3370174351410229e-01 -1.3860179756840392e+00 + 28 -4.2027661354654899e+00 -3.2897798141811139e+00 2.3654811439472589e-01 + 63 -3.0969273095825809e+00 -2.9625009679729546e+00 -6.6298480344622881e+00 + 54 2.5854711067077090e+00 3.9471811177139955e+00 -9.9596433268722322e+00 + 20 4.1131403354946947e+00 -1.4860626613635164e-01 5.1220818201154561e-01 + 62 2.8612400761146137e+00 -8.2941697712592788e-01 9.1772255106609146e-01 +... diff --git a/unittest/force-styles/tests/manybody-pair-gw_zbl.yaml b/unittest/force-styles/tests/manybody-pair-gw_zbl.yaml new file mode 100644 index 0000000000..a9b8f1b67c --- /dev/null +++ b/unittest/force-styles/tests/manybody-pair-gw_zbl.yaml @@ -0,0 +1,155 @@ +--- +lammps_version: 5 May 2020 +date_generated: Wed May 27 06:35:40 202 +epsilon: 5.0e-13 +prerequisites: ! | + pair gw/zbl +pre_commands: ! | + variable newton_pair delete + variable newton_pair index on +post_commands: ! "" +input_file: in.manybody +pair_style: gw/zbl +pair_coeff: ! | + * * SiC.gw.zbl Si Si Si Si C C C C +extract: ! "" +natoms: 64 +init_vdwl: -175.936174891673 +init_coul: 0 +init_stress: ! |- + -5.8276406110669188e+02 -5.8346815587322897e+02 -5.9635169680266551e+02 -4.0794077115757972e+00 -2.1745700506730312e+01 6.6659517818741762e+01 +init_forces: ! |2 + 2 4.2357489797936001e+00 -1.0684949293484816e+01 7.8771155431094175e-01 + 5 5.6356214451863904e+00 5.0000767093728120e+00 7.2555454206833776e+00 + 4 1.3053822302538920e+00 -1.1939937695990026e+00 1.1402810951434747e+01 + 9 -1.4781064224087242e+01 3.8439658572514734e-01 1.1989492824719581e+00 + 11 2.2298907562811197e+00 4.2641995035050559e+00 7.9491920533282991e+00 + 13 -8.1934793624817925e-01 -2.9671111691663574e+00 7.1910295031570115e-01 + 8 -3.3071121146731968e+00 -8.5637304444766782e-01 1.7806227255851947e-01 + 27 1.7416061773529932e+00 -8.0463299769387397e+00 4.5451929890917103e-01 + 12 8.5883609985008960e+00 -8.0924314033392619e+00 -5.8623431981081087e+00 + 16 -7.0067303872674671e+00 6.2830931395859464e+00 3.7585650048554897e+00 + 17 9.0905632153192073e+00 3.4397609762973742e+00 6.2865815606860842e+00 + 18 -3.7214378890457338e+00 -3.6025127172345730e+00 1.8833605752765705e+00 + 21 -2.7802765750527731e+00 -1.0907997594933978e+01 1.2455837015673081e+00 + 19 4.2329443390880966e-01 -3.9381783576826557e+00 -8.3399584727058276e+00 + 29 4.3809969319065409e+00 8.7006019656322824e+00 -2.5085306443295812e+00 + 24 4.8832112667925909e+00 7.1126956268714512e+00 1.8948777536757939e+00 + 26 6.4193587910480687e-02 2.7384662890772821e-01 -7.1402609484479136e+00 + 1 -8.7926660598178792e+00 -1.7562686180970930e+00 -4.5861870003049399e-01 + 32 8.0683733234008272e+00 4.8645106397442461e+00 -4.2398100044384845e+00 + 7 -3.4705780124976742e+00 -6.8307539747824206e+00 -6.9347124729220919e+00 + 15 5.3932014455223776e-02 -9.2247474642408456e-01 -9.3587584470880891e+00 + 33 -9.4005183437854463e+00 -6.1931478897018337e+00 4.8929172880421508e+00 + 6 7.0002233903025504e+00 -4.8444741654334997e+00 3.8855869055363259e+00 + 10 -6.7082057390897276e+00 2.6859539408136976e+00 -3.3137144777261378e+00 + 14 6.5884818021472720e+00 3.0287845420331796e+00 -7.3778438679833869e+00 + 44 1.4577094769004286e+00 4.3313476308247516e+00 1.2961205445775557e+01 + 49 -6.3914540404204665e+00 8.9625129826476826e+00 -6.6543647233861174e+00 + 23 7.2613526421959058e+00 -8.5850464402279272e+00 5.0246008537543823e+00 + 31 8.9862692303232681e+00 -4.8524057537797720e+00 1.4671173077939734e+00 + 3 -9.5436958384798043e-01 3.5730300484411224e+00 -7.0008170086067811e-01 + 22 8.5433263136142550e+00 5.6105720379732187e+00 -7.5389630920524953e+00 + 30 1.0721463556913690e+01 -5.0407821175220899e+00 4.4640821970924556e+00 + 60 -6.8831090229238052e+00 9.8973271589186158e+00 -5.6086464375279732e+00 + 35 -1.5256302919370812e+00 -1.1044771485452394e+01 -8.8952214909950755e-01 + 37 -2.4143950969904182e+00 1.5851650331053520e+00 6.1728785077450841e+00 + 41 1.1768951909320591e-02 2.5323964191781356e+00 9.6796571792105173e+00 + 45 -8.7965227067037262e+00 4.9371988800880064e+00 -4.3763428705092133e+00 + 36 -1.1255634634703997e+00 1.2608920501893842e+01 -5.0952031869237302e-01 + 40 -3.6004183026699987e+00 -3.5970716907067155e+00 -7.2688242281797963e+00 + 42 8.1132469734215746e+00 -3.9405230164154808e+00 -5.5349383551149103e+00 + 48 -9.2658081740909424e+00 -8.4309087673858496e+00 4.9980608996189879e+00 + 53 2.5982811647111972e+00 3.3319375526506134e-01 1.1929350533720726e+01 + 51 -1.1362722801691911e+01 -7.2180886429661473e-01 -3.9383510175555387e+00 + 57 -3.6891437061724219e+00 1.1637555466101791e+01 3.0558861508682633e+00 + 61 -2.2645148763331222e+00 -1.4899894908197304e+01 -6.0034928076230065e-02 + 52 -9.6800337765832911e-01 1.9659737905263535e+00 1.9056049681733944e+00 + 56 -3.0695538731062699e-01 3.8628437619184970e+00 4.2302313685378188e+00 + 58 -1.1453518994353894e+01 -1.2916823301031848e+00 4.1462917952767553e+00 + 64 5.8092540975566473e+00 6.0819293431378529e+00 -9.3149006808172707e+00 + 39 6.8819757521907814e+00 -4.4906885268535710e+00 9.6262824038598342e+00 + 43 -2.2213483522000627e-01 3.1383328029904827e+00 9.3274120257882054e-01 + 47 -3.9475361019691924e-01 3.9145677050276362e+00 9.1713933629663877e+00 + 38 -1.8831702318382959e-01 5.5082277650824949e+00 -2.6609062149491192e+00 + 25 -4.8140842669808883e+00 -2.1012532194425706e+00 -9.2794886340506650e+00 + 46 -7.5059962128623789e+00 6.6415852513709641e+00 4.2806494868985245e+00 + 59 5.3658719782614019e+00 7.6532681338575292e+00 -8.4703928765061693e+00 + 34 -1.0662231223647325e+00 1.9262306799135347e+00 -6.3066032287751383e+00 + 50 6.3000791269338077e+00 -4.8327147730081688e+00 -2.1880866118496130e+00 + 55 1.2171107540605087e+01 -6.1393988370374475e-01 -1.6660494048572838e-01 + 28 -6.8458521492100655e+00 -6.2031091954170856e+00 3.2853857186519604e+00 + 63 -4.8143194318839724e+00 -4.0270585558397460e+00 -6.1213061124576491e+00 + 54 2.1706861339480605e+00 3.8604283622091802e+00 -9.5977328723459063e+00 + 20 4.2075069476861513e+00 -9.7639424422236498e-02 4.5461513297756895e-01 + 62 2.7519673193592538e+00 -9.9223209492059505e-01 1.1407621379187511e+00 +run_vdwl: -193.312853528059 +run_coul: 0 +run_stress: ! |- + -5.4066934275981271e+02 -5.3539692137349732e+02 -5.4571796355268998e+02 3.9788786808580205e+00 -2.5638457494512634e+00 5.1038720866332895e+01 +run_forces: ! |2 + 2 3.8589613255677695e+00 -1.2182274186588572e+01 1.2200874450581158e+00 + 5 3.6065082281390186e+00 5.1669427242924169e+00 9.9870488236990909e+00 + 4 3.7859607366139292e+00 4.7662862010008389e-01 9.6619359571747268e+00 + 9 -1.2921199518089869e+01 6.9733763570710705e-01 1.0987591943611239e+00 + 11 4.7437505164088183e+00 6.4387759986175812e+00 8.4065799145269722e+00 + 13 -1.0854184196104706e+00 -2.4775908643592226e+00 1.1195049109784083e+00 + 8 -3.8060686137426289e+00 -4.5723011891033372e-01 -6.4461987470546578e-01 + 27 1.6901862855624712e+00 -7.4878193304420178e+00 -1.1555746080127431e+00 + 12 6.8036757384550999e+00 -5.1988342453747194e+00 -3.5984612443501485e+00 + 16 -6.6413823728598960e+00 5.9302403106086752e+00 3.2559803068427073e+00 + 17 7.7777534204858387e+00 2.7644631040804661e+00 5.6707235317708173e+00 + 18 -5.4427505787065185e+00 -4.0179389213338066e+00 1.0850266660465389e+00 + 21 -2.6596058078106477e+00 -9.4619456039413130e+00 1.1729547096952548e+00 + 19 2.7140599153796292e+00 -1.9413897637657505e+00 -8.9692213629342543e+00 + 29 5.2834057778781585e-02 7.7586444900352625e+00 2.0821886041064515e+00 + 24 2.0331453721306119e+00 7.9924636679279146e+00 2.9582497770410177e+00 + 26 2.5619714884463400e+00 -2.3890335739466586e+00 -7.6784961439679407e+00 + 1 -8.6277813837170996e+00 -3.6815356912781649e-01 -3.9567072357053927e+00 + 32 6.9011446653487551e+00 2.0042047039996818e+00 -1.6457805890053665e+00 + 7 -2.1046786080633120e+00 -4.0938241912243951e+00 -9.1090084112855756e+00 + 15 -6.8987939813923393e-01 -1.1242393596560829e+00 -1.1686907073851605e+01 + 33 -7.1279836004450239e+00 -3.5306988416018426e+00 2.6325849821981895e+00 + 6 4.2244244544978597e+00 -6.1786033433086853e+00 4.4134659256902458e+00 + 10 -7.2048631108887493e+00 -8.1550354985302786e-01 -1.1253905684192793e+00 + 14 5.2998494340360915e+00 1.9682641881011902e+00 -6.0760706983373254e+00 + 44 -3.5292413939131972e-01 1.9997679881601520e+00 1.3016115270182855e+01 + 49 -3.1045084518164119e+00 6.0501696170918624e+00 -2.9302437903579310e+00 + 23 8.6236811036531673e+00 -9.1169454341147382e+00 6.3075877532622755e+00 + 31 7.0560163648018364e+00 -4.7496724594562700e-01 -2.0845979644689794e+00 + 3 1.3300307944456162e+00 2.3326301828716520e+00 -1.7282105813177813e+00 + 22 8.6942219833331986e+00 5.8139224763227411e+00 -6.2007309219058415e+00 + 30 6.8230121395951482e+00 -3.0045575389791095e+00 2.6132932318988287e+00 + 60 -3.7907706823025058e+00 6.9367208647219538e+00 -2.7380275039942350e+00 + 35 -3.4146974870449518e+00 -9.7380272865336508e+00 1.1151712285765996e+00 + 37 -5.8484348847859042e+00 4.5884939458598870e+00 8.9741751166255330e+00 + 41 -1.8400571371576810e+00 1.4201619701308155e-01 1.1478634349552040e+01 + 45 -5.5717230758142824e+00 4.6933529666626095e+00 -6.4188907546899365e+00 + 36 -3.1018395483505579e+00 8.1181651630917298e+00 -3.2099999230558383e+00 + 40 -4.1115734183840100e+00 -5.1338091273431097e-01 -2.5851347293479332e+00 + 42 7.8777244660031815e+00 -3.5790980571087374e+00 -3.0408007992335033e+00 + 48 -6.3517302165875611e+00 -8.9281821597203841e+00 7.6789292438054932e+00 + 53 3.1268481898543841e+00 -8.0987030580600150e-01 1.0609352284577195e+01 + 51 -1.1667645949283481e+01 -1.6310649792712169e+00 -2.7745454685923630e+00 + 57 -1.8152871061206437e+00 1.4359220958131830e+01 1.0017442246365476e+00 + 61 -4.7142151813942741e+00 -1.3612088795758742e+01 -3.0602653978386143e+00 + 52 -2.7581999498237559e+00 5.1216578668919355e-01 -2.8684044621165616e-01 + 56 5.1626329831011502e+00 5.6647221205380056e+00 3.0358245934402035e+00 + 58 -1.1291990057020765e+01 -1.3980521358257956e+00 4.2848454040438746e+00 + 64 3.6903799481384696e+00 3.5226284234465064e+00 -6.9391139634832770e+00 + 39 5.9379720913779419e+00 -4.0464133125425690e+00 9.0922204133000708e+00 + 43 -3.8534267211770346e-01 2.8930029804153552e+00 1.0510098476143472e+00 + 47 9.2951105126052402e-01 -2.3285119436249052e-01 8.1211032721280727e+00 + 38 -1.7135968718820438e-01 6.3554195091843040e+00 -4.5417096642033856e+00 + 25 -3.3490567048167796e+00 -3.6329701644521282e+00 -8.7373325158615067e+00 + 46 -7.7777256783801354e+00 6.8515617040603516e+00 4.6134701878154249e+00 + 59 5.9828321440987393e+00 5.2968314253914688e+00 -6.6890721950533667e+00 + 34 1.3564237534349830e+00 1.8876260801910882e+00 -1.1505824014399003e+01 + 50 3.9793029598124665e+00 -4.4234122307884913e+00 -3.3195274578967915e-01 + 55 1.0845722416543193e+01 9.3369881118806963e-01 -1.3860210407080367e+00 + 28 -4.2027671155755355e+00 -3.2897771848501600e+00 2.3655262433935664e-01 + 63 -3.0969240922921752e+00 -2.9625040944105328e+00 -6.6298511920082674e+00 + 54 2.5854723369710229e+00 3.9471787562895742e+00 -9.9596454349695946e+00 + 20 4.1131351877265230e+00 -1.4860485808821977e-01 5.1220892255762340e-01 + 62 2.8612390947195339e+00 -8.2941404606465108e-01 9.1772014051982698e-01 +... diff --git a/unittest/force-styles/tests/manybody-pair-lcbop.yaml b/unittest/force-styles/tests/manybody-pair-lcbop.yaml new file mode 100644 index 0000000000..4d8903c2be --- /dev/null +++ b/unittest/force-styles/tests/manybody-pair-lcbop.yaml @@ -0,0 +1,155 @@ +--- +lammps_version: 5 May 2020 +date_generated: Wed May 27 06:37:35 202 +epsilon: 7.5e-12 +prerequisites: ! | + pair lcbop +pre_commands: ! | + variable newton_pair delete + variable newton_pair index on +post_commands: ! "" +input_file: in.manybody +pair_style: lcbop +pair_coeff: ! | + * * C.lcbop C C C C C C C C +extract: ! "" +natoms: 64 +init_vdwl: 8.17964021758716 +init_coul: 0 +init_stress: ! |- + -1.2435703568682847e+02 -1.2857102333786813e+02 -1.3890567540223492e+02 2.5932262530693418e+01 -2.6427929407841010e+01 -3.0892916656406346e+01 +init_forces: ! |2 + 2 -4.6556209438067381e-01 -3.5099813053416973e-02 -3.2166410668441087e-01 + 4 6.0416667096250753e+00 -7.0504063809341906e+00 -7.4555498385945018e+00 + 5 -1.7630326898093024e-01 -1.4453291550360667e-01 -9.1014974137603011e-02 + 6 5.9475271646390653e-02 3.5426810177275109e-01 7.7987788954305790e-02 + 7 -1.7665729405705119e-01 -2.1998339787782994e-01 1.8531951645099318e-01 + 8 1.6182597606329969e-02 8.3325159504138366e-02 -1.1778146293628297e-01 + 9 9.8964298756504324e-02 -2.1447561082739114e-01 -4.0257282371434611e-01 + 10 3.6982194695863275e+00 2.6683521594473993e+00 2.7157107169169126e+00 + 11 -1.0489280925979667e+01 9.0505423116078578e+00 -8.0598390069742489e+00 + 12 9.1751239821833313e+00 1.0221867409207196e+01 9.3501182759520081e+00 + 13 1.0767778232766320e+01 -8.7274234935159711e+00 8.1038461655908112e+00 + 14 5.6125157823536229e+00 -1.0652062150081900e+01 7.4288447654833671e+00 + 15 8.5577687796488355e+00 -9.6476386149379945e+00 1.1708000381131621e+01 + 16 1.3163914409064734e+00 -1.1168902080758076e+00 -1.7919978408248742e+01 + 17 -1.0810481355508186e+01 -9.1581134758167995e+00 8.4200132776642196e+00 + 27 -1.2335019174324789e-01 3.0769919870086088e-01 -8.3552139853850849e-02 + 33 -8.4321487683800669e+00 9.9257192929474627e+00 -1.1632903880149222e+01 + 44 -8.9771310336205410e+00 7.9108805763277656e+00 -1.0245475869232337e+01 + 3 3.6408074598378123e-02 -9.4669915320099080e-02 9.5684844337036834e-02 + 18 1.0326064139212729e-01 1.5056077583955585e-01 4.4340469237931712e-01 + 19 8.6072410286789580e-02 9.4236578153873332e-02 2.0155142088538511e-01 + 21 2.8973363119232554e-01 3.3202805878660036e-02 -4.9654359948004095e-01 + 22 7.6530347880357068e+00 -7.7288100739165211e+00 9.6197818954589209e+00 + 23 -4.3432956397358440e-02 1.5929221275465336e-01 5.4004925735576621e-03 + 24 -5.1622396501263434e+00 -5.9855904886451077e+00 -6.0618869454926463e+00 + 26 -1.0631876013284113e-01 -6.6063963439346715e-02 1.2591466872249188e-01 + 49 8.7266526531430593e+00 9.8335585638810237e+00 1.1506551051669387e+01 + 1 6.8558721949695336e+00 -5.6474396751536737e+00 -7.3553929901585988e+00 + 29 -3.2359808390777962e-02 -3.0299175862072358e-01 3.0270509308440363e-01 + 30 -2.3597521547158104e-01 1.2740106636135567e-01 -9.9493580487445499e-02 + 31 -2.4273886812508519e-01 1.0660270717918778e-01 -1.1930459479507495e-01 + 32 -5.0759837471723535e-01 3.4654485626817666e-02 1.7648504309685953e-02 + 60 9.3440101686324990e+00 9.7302438645837235e+00 1.0374147759719595e+01 + 25 6.0551716461082171e-02 -7.0718524425884347e-02 1.5392863380132524e-01 + 35 1.6508960363618516e-01 -9.4241542230865658e-02 3.1132857213051224e-01 + 36 8.3342882208953764e-02 -3.3458806623478970e-01 3.9848809622275314e-02 + 37 -2.3517925197379491e-01 3.0663663986287193e-01 -3.6883969759235580e-01 + 38 6.8697460913525021e-02 -5.4392952243697557e-02 -5.5694034516542146e-03 + 39 -6.0559155584957178e+00 7.2930567219735183e+00 6.9474107450271854e+00 + 40 -9.1878319345214354e+00 1.0777218820801650e+01 8.8334545622627161e+00 + 34 -4.9378273087815366e-02 -2.5105121875388964e-02 7.5411166788337758e-02 + 41 1.7999698253680857e-03 -3.7584742195514607e-03 -1.1519094183544777e-01 + 42 2.1863836225059536e+00 3.0176683835933886e+00 2.9028604016698689e+00 + 43 -4.6284751810837959e+00 6.9508273431719019e+00 -5.9488556147282798e+00 + 45 5.7418942795212935e+00 -6.5545823731071753e+00 6.7094613004347492e+00 + 46 8.7666963342867721e+00 7.1761165295116989e+00 -1.1169411280295618e+01 + 47 -7.9040938478436773e-01 -8.6896466553453966e-01 -9.8620608596721338e-01 + 48 1.8059324995115608e-01 1.6276430299380318e-01 -8.8361108492223672e-02 + 59 -1.1209283719093733e+01 -1.0622067871104244e+01 8.6668072852121938e+00 + 20 1.4502217946863617e+01 -4.7706076794805954e+00 -2.7739305326156565e+00 + 50 1.7410685695627226e-01 3.5651112629114623e-01 -9.1924314596656287e-02 + 51 9.5670283197850150e+00 -1.0536698880712994e+01 -8.4267941645894027e+00 + 52 -7.7816991631256700e+00 7.5941681987201282e+00 -9.4381889592903345e+00 + 53 -8.5327677073825097e+00 -1.0158585569657427e+01 -1.1642670022910565e+01 + 54 -6.7312830404695960e+00 5.8111576361562127e+00 7.4005665582810236e+00 + 55 -9.8708821110909639e+00 1.0594465977019395e+01 8.8486247286326307e+00 + 56 -3.7254100860928190e-04 8.6110730264757532e-02 -3.1420577571992964e-01 + 58 3.0904617597486433e-01 -1.3420139069743239e-01 2.7502256294234566e-02 + 28 7.8006127130589249e+00 -5.5454662448416530e+00 -1.2881323495821963e+01 + 57 1.1026492895159451e-01 -1.1035814591104355e-01 -6.2062678619598653e-02 + 61 3.1252075430895879e-02 2.9416915697183738e-01 -1.0792004038866698e-01 + 62 1.6765145761367202e+00 -2.0782148288797191e+00 1.8091954116807478e+00 + 63 -9.5306462336143234e+00 7.7221239702292852e+00 1.1380605030752243e+01 + 64 -9.2795211740539081e+00 -1.0180658540458492e+01 -9.9052284360191454e+00 +run_vdwl: -13.4267481536937 +run_coul: 0 +run_stress: ! |- + -1.2438239212694427e+02 -1.3519475156374412e+02 -1.4416839838037882e+02 3.3111116157538284e+01 -2.6229917528593294e+01 -3.8335936139116058e+01 +run_forces: ! |2 + 2 -3.4784773723724066e-01 5.8021175531924180e-02 -1.9282844439452179e-01 + 4 8.9627371436596874e+00 -1.0128310565833802e+01 -1.0940462565413972e+01 + 5 -2.0495275652233569e-01 -1.4749158812894328e-01 -6.5325760179552911e-02 + 6 -4.5894166333942159e-02 2.3341167638039803e-01 -1.7638128462845883e-02 + 7 -1.4374607519793065e-01 -1.6048460066541040e-01 1.4246413109296657e-01 + 8 -3.2618862078731652e-02 5.7365897211965229e-02 -1.2265252354866131e-01 + 9 7.3331139213081417e-02 -2.1708990748705911e-01 -3.8855082299377047e-01 + 10 1.2925523782779635e+00 8.3810370446567706e-01 8.0165058045173754e-01 + 11 -1.0807449647989586e+01 9.3190323421622008e+00 -8.0608058890001555e+00 + 12 7.4389513443756421e+00 8.2684938383505884e+00 7.5610754566331932e+00 + 13 1.1129152149348672e+01 -8.9821761744560789e+00 8.1388585875031296e+00 + 14 8.0104267350095917e+00 -8.8014454842160479e+00 9.5085383930126017e+00 + 15 6.7612410424413243e+00 -7.5839731195193565e+00 9.1469746868932056e+00 + 16 2.9587600556486966e+00 9.9277045064699432e-01 -1.5999232898916299e+01 + 17 -1.0723826453215171e+01 -9.2719019245618650e+00 8.3496828025577159e+00 + 27 -2.4595859093574450e+00 2.9901332424372256e+00 -2.5492929569917444e+00 + 33 -6.6928977325240897e+00 7.7975849681726119e+00 -9.0638538305403689e+00 + 44 -9.0041159730939704e+00 7.8790553352461217e+00 -1.0384351288244947e+01 + 3 -1.2739741644225200e-02 -1.0069277150486099e-01 1.4752434854502247e-01 + 18 9.3226069498408137e-01 -8.5891817203702514e-01 -4.4177882049807660e-01 + 19 2.9350610994824984e+00 2.8025568834250123e+00 4.1084216863962597e+00 + 21 -5.8338801389812611e-01 1.0218169449745131e+00 3.4039795100407311e-01 + 22 5.5682394642391131e+00 -5.6407873706161720e+00 7.0304723086905145e+00 + 23 -2.9158940469675949e+00 -2.5710316825770296e+00 -3.8993309002241676e+00 + 24 -8.3416424357855892e+00 -1.0437082353494505e+01 -1.0712843351776540e+01 + 26 -1.1632526714683127e-01 -2.9900942060980998e-02 1.1781801474278579e-01 + 49 6.1403083607061060e+00 7.0503020750142227e+00 8.2284087910300201e+00 + 1 1.0237370064906509e+01 -8.5336224828002631e+00 -1.1005218856144294e+01 + 29 2.3459873508897053e+00 -3.0123923174984149e+00 2.7236011429675608e+00 + 30 -1.8177730860772737e-01 8.2698219955128938e-02 -1.0093098691601560e-01 + 31 -2.2907382032950391e-01 7.8009241730791948e-02 -8.5782916261625153e-02 + 32 -4.9748760801256670e-01 4.9348367008571759e-02 5.2208739766674839e-03 + 60 6.3600795921193285e+00 6.7001231408260473e+00 7.1488900250145910e+00 + 25 5.9190017383165615e-02 -6.2394668680111620e-02 7.2193542569697025e-02 + 35 1.6693042892704785e-01 -9.5335461529506227e-02 3.3271260840975686e-01 + 36 8.6324944943528950e-02 -2.9856462667383954e-01 7.0121037648987836e-03 + 37 -2.3493637505619930e-01 2.7400121369297037e-01 -3.8948245198785114e-01 + 38 8.5835563840937878e-02 -9.8310161891456693e-03 2.9209035129394073e-02 + 39 -8.9651124141083933e+00 1.0381179554241854e+01 1.0410019902631097e+01 + 40 -7.7553940777805153e+00 9.3591953874588718e+00 7.6082905873697158e+00 + 34 -5.6126119110567502e-02 -2.3113798972523747e-02 9.6664432970543723e-02 + 41 5.4030428901812401e-02 5.0017457732297564e-02 -7.2601472186096014e-02 + 42 6.3012567393122483e+00 7.7954799812737479e+00 6.9439384760578111e+00 + 43 -8.0723303025037154e+00 1.0836742317896071e+01 -1.0201157607982962e+01 + 45 9.0116677705043458e+00 -1.0570676815817370e+01 1.0796597612607936e+01 + 46 2.5179275242639330e+00 2.4676411569379381e-01 -1.3501552848499399e+01 + 47 -6.8187197393971888e-01 -7.4578247139241105e-01 -7.9681785353501167e-01 + 48 1.6493317319493506e-01 1.8520807878677822e-01 -1.1598082269473209e-01 + 59 -9.0142198894423622e+00 -8.4170808356547280e+00 6.9481669269588773e+00 + 20 1.7044482718522822e+01 1.3061328109505732e-01 2.2303119946056467e+00 + 50 1.9941227344946760e-01 2.9769660530871350e-01 -1.0668103763425291e-01 + 51 8.0998852414652802e+00 -9.0613886920506062e+00 -7.2416058335264752e+00 + 52 -5.6677625995918017e+00 5.5405263265397915e+00 -6.8252324294864213e+00 + 53 -5.9504845141072256e+00 -7.3537318795462356e+00 -8.2909238047311238e+00 + 54 -1.0120499052084817e+01 8.6633616529210720e+00 1.1075973812429934e+01 + 55 -9.2160002516166131e+00 1.0093306328330192e+01 8.4605447762907513e+00 + 56 -1.1756295869275851e-02 3.3043586728988078e-02 -3.0689515156768227e-01 + 58 3.0192838322560334e-01 -1.2796525005797335e-01 2.6886528172325804e-03 + 28 6.9884993998993874e+00 -4.7550899162472877e+00 -1.1346594258061893e+01 + 57 9.9679963699159629e-02 -1.5477869684997456e-01 -7.2737184302784821e-02 + 61 7.8252823486902240e-02 2.9866501889263264e-01 -7.9878624563153089e-02 + 62 1.5686564027329066e+00 -1.9446009984305463e+00 1.6036033572355219e+00 + 63 -8.6247683835418361e+00 6.7625232752998583e+00 1.0003168078373522e+01 + 64 -6.2628266083598296e+00 -7.0695150998825946e+00 -6.7420733594669890e+00 +... diff --git a/unittest/force-styles/tests/manybody-pair-nb3b_harmonic.yaml b/unittest/force-styles/tests/manybody-pair-nb3b_harmonic.yaml new file mode 100644 index 0000000000..f8a77743f6 --- /dev/null +++ b/unittest/force-styles/tests/manybody-pair-nb3b_harmonic.yaml @@ -0,0 +1,156 @@ +--- +lammps_version: 5 May 2020 +date_generated: Wed May 27 06:42:57 202 +epsilon: 1.0e-12 +prerequisites: ! | + pair nb3b/harmonic +pre_commands: ! | + variable newton_pair delete + variable newton_pair index on +post_commands: ! | + change_box all x final 0 4.2 y final 0 4.2 z final 0 4.2 +input_file: in.manybody +pair_style: nb3b/harmonic +pair_coeff: ! | + * * MOH.nb3b.harmonic M M O O H H H H +extract: ! "" +natoms: 64 +init_vdwl: 2654.82155652424 +init_coul: 0 +init_stress: ! |- + -5.1017158429026651e+01 -1.3611903256981696e+01 6.4629061686009067e+01 -8.7135857294938191e+01 -1.1070515375917164e+02 7.5452837495497633e+01 +init_forces: ! |2 + 1 -1.0877972789090633e+01 2.7818609977822151e+00 5.3286346737471801e-01 + 2 2.3844946347198697e+00 3.8120293270515626e+00 -1.7852915817427366e+01 + 3 -5.5060972496922012e+01 -1.4649767245154461e+01 -8.0050176965474122e+01 + 4 1.7259636030947714e+01 9.3366797180178907e+00 1.5880959275683665e+01 + 5 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 6 1.7794992633465359e+01 -5.3419222655618320e+01 1.6321598833864002e+01 + 7 -6.7476300345434893e+01 6.2036681257356090e+00 -7.5139089756926083e+01 + 8 -2.4916802467563383e+02 3.9421473842157511e+00 -3.9134655098942254e+01 + 9 -4.2488750688310093e+00 4.0608847565742447e+00 -1.2332028245418186e+01 + 10 -5.6132393889097036e+00 1.7823276348533055e+00 1.2023878783019342e+00 + 11 2.7495846047096700e+02 3.6847059220182459e+01 -3.5747872835095954e+01 + 12 -8.5777111027672873e+01 -6.6703893761473649e+00 3.6593219992613264e+01 + 13 2.8150260504826656e+00 4.6881843084850182e+01 -2.8703190101594132e+00 + 14 4.3310482261409405e+01 5.7711396678423561e+01 5.5582267493210210e+01 + 15 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 16 1.2606972666826963e+00 -2.9949919839800152e+01 -3.8329654261193085e+01 + 17 -5.6603372959879501e+01 4.4199755708912090e+00 1.6646523859302970e+01 + 18 2.9145047807552785e+01 -3.8254292709284357e+01 -7.8685029062057863e+00 + 19 -3.9052132885118897e+02 -3.4874531498136278e+01 2.4335359036689007e+02 + 20 3.0523826465323211e+01 -2.7070245767455226e+01 5.8408159705563616e+00 + 21 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 22 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 23 7.4409325483379803e+01 -6.1338064797828309e+01 -4.0331673797102184e+01 + 24 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 25 -1.5434301681368330e+01 -1.8496773706788222e+01 -4.1692996127143651e+00 + 26 -7.2440757908713049e-01 -1.5411185566412183e+01 3.6729264463045794e+00 + 27 1.4857759801010695e+02 -8.7246598153787403e+01 3.5575180405196285e+00 + 28 1.1863298792067371e+02 8.2702860857456869e+01 1.5436298352562847e+00 + 29 4.7621783523283590e+01 2.8039369004096750e+00 2.7605524532590053e+01 + 30 2.8830156773978769e+02 -3.2784354352079447e+01 1.0018854518372478e+01 + 31 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 32 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 33 -5.8839244877108614e+00 4.3985789859461818e+01 2.3192635019620489e+01 + 34 -8.7966629741582576e+00 -3.7772557274042633e+00 -5.0822108474305443e+00 + 35 -1.1045699552194318e+02 -2.5865892104728207e+01 -3.3353488725325462e+01 + 36 -3.9928053482362905e+01 -3.7650338080860749e+01 -8.6463197758339003e+00 + 37 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 38 3.7625199613228766e-01 -5.9409197479738708e+01 1.1096821440484145e+01 + 39 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 40 -4.2079999725616096e+02 1.5030064155408525e+01 2.9502576524714826e+01 + 41 -7.1831348401232091e+00 2.3501863961013282e+01 3.3211487338838609e+01 + 42 -5.4333378031078610e+00 -3.8222885761439054e+00 5.2740780894998984e-01 + 43 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 44 6.3343303260433999e+01 4.9488759873343774e+01 5.0212324296502423e+01 + 45 4.2425954317559700e+02 5.6875319339115556e+01 -2.5998498159230604e+02 + 46 1.5374524942979843e+02 -2.4634003877741762e+01 -5.9674041391425958e-01 + 47 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 48 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 49 2.4664457425766684e-01 8.5221588811519311e-03 7.1570435255873655e+00 + 50 -2.9771445332463109e+01 -1.3053973386895201e+00 9.5074220439575612e+00 + 51 -1.8696262048502865e+02 -3.0046250420275893e+01 -1.9739208373694105e+01 + 52 -2.3539906256917567e+02 8.1697006804398669e+01 -1.1372898509058719e+02 + 53 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 54 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 55 -9.9888474306294608e+00 -6.3056149949578383e+01 -3.8789913572864435e+01 + 56 -1.5108125115180235e+02 8.7451440758083976e+01 6.2279587307098822e+01 + 57 -2.4707820063785416e+01 8.1430106606145536e+00 3.7927211164970971e+00 + 58 -7.9324636824924024e+00 1.1055979589866887e+00 -1.1979321661997941e+01 + 59 8.8647131566710783e+01 3.8727979707847247e+01 4.8159748997763351e+01 + 60 2.3037697796149806e+02 -4.6916609535445453e+00 9.6808251082403842e+01 + 61 8.6364330939177634e+01 1.4895642916188269e+01 9.8020771081533500e+00 + 62 4.1476164742574909e+01 -9.7738882325904193e+00 2.2124574239200477e+01 + 63 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 64 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 +run_vdwl: 2586.23310804073 +run_coul: 0 +run_stress: ! |- + -4.6723183908900717e+02 1.7852419684221977e+02 2.8870764224678692e+02 -7.3768673952427577e+01 8.1285715133964914e+01 -2.2175376931373922e+01 +run_forces: ! |2 + 1 -1.1750670180272866e+00 1.3131514736699824e+01 -3.8826576290188388e+00 + 2 2.3357180987384143e+00 2.6172640820169175e+01 -1.3859108643114411e+00 + 3 6.0695590546373353e+01 2.0642136613920513e+01 5.4996351260125280e+00 + 4 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 5 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 6 2.4546655526930735e+01 -3.1101905626646428e+01 3.8841426269193406e+01 + 7 -4.9616838878159811e+01 -1.0992414702422360e+01 4.8515728874677269e+00 + 8 -5.6453384170560540e+01 4.7672434067033826e+00 -1.9612102502967304e+00 + 9 -1.8392638626001174e+00 1.1828167793968992e+01 -2.0356506218224546e+01 + 10 -8.6013994200124220e+00 -1.0417698459793890e+01 5.4845710971785913e+00 + 11 6.0381617656756774e+01 -1.6620349247888100e+01 2.2225135196909434e+01 + 12 5.0979659960037345e+01 -2.2641974764565148e+01 8.6466127914636193e+00 + 13 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 14 9.6203506994347148e+00 2.0490558201590559e+01 3.8564561780893207e+00 + 15 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 16 4.2696341100597985e+00 -6.4394247758381127e+01 -2.3287529910455991e+00 + 17 -1.7809619943717419e+01 -1.9261779466882487e+00 2.6614972406661607e+01 + 18 -3.0062559069631483e+01 -4.6813849188661194e+01 2.0071390221802680e+01 + 19 2.2231227996316667e+00 5.5240594291246383e+00 -4.0911170180556759e+01 + 20 1.2156858565323886e+02 3.9830629488572413e+01 3.7706116674646424e+01 + 21 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 22 -1.6364437371629357e+01 3.2268779082011257e+01 -2.5552249817970370e+01 + 23 -8.3597998911963472e+01 -1.7654897749235602e+01 7.1337191308940682e+00 + 24 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 25 1.8771431821434961e+00 3.7184795487210792e+01 -6.1577014025376728e+00 + 26 -2.3472845707924179e+00 -4.2517776291726975e+01 1.4877047560362083e+01 + 27 9.9311610633439727e+01 5.8342547785154601e+01 6.2490107493557900e+01 + 28 8.1997428592624331e+01 4.9305082539955812e+01 -3.1924492771504966e+01 + 29 1.5755014250094833e+01 1.6333818401948033e+01 2.0837131374062341e+01 + 30 4.6444961759604695e+01 2.9380895149140301e+01 -1.2549027721695549e+02 + 31 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 32 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 33 -5.5005500969351843e+01 -4.4888400262284573e+00 -7.9881718186484276e+00 + 34 1.2391358513429662e+01 4.2205224695342682e+00 -8.7307512727212266e+00 + 35 -6.8048459171953510e+01 -5.0746781744565169e+01 1.6313940341424583e+01 + 36 1.7865132435199360e+00 -4.6549184761244362e+01 -1.8272256554692827e+00 + 37 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 38 2.9421387114598204e+01 -4.2086146965794974e+01 1.6800774864890816e+01 + 39 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 40 -3.8166935284463143e+01 4.1676208829419494e+01 -7.1239426844135672e+00 + 41 8.9777269850365204e-01 4.4289814981844543e+01 2.5485173899838237e+01 + 42 1.1863601054760339e+01 -5.5963639046028719e+00 -2.6542953642884349e+01 + 43 -1.4318530885017411e+01 2.2057393766498969e+01 4.4372607097293105e+01 + 44 1.4461973377279693e+02 -4.1284603574668154e+01 3.8323143295598186e+01 + 45 1.2862655952927490e+01 5.8051830292127509e+00 5.6062109819492129e+01 + 46 3.9950844327128916e+00 1.0816632720372052e+01 2.7359382513314188e+01 + 47 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 48 -8.2471941292632351e+00 7.2384082709877987e+01 7.6275073773084081e+00 + 49 7.0874669396804322e+00 1.0710819490993529e+01 6.8487083926871106e+00 + 50 -1.3702452391153543e+01 -3.1315676795828317e+01 -2.9390721004259010e+01 + 51 -5.1841862825969486e+01 -6.5229295766089322e+01 6.4345194792685618e+01 + 52 -1.0076730856559496e+02 -3.1323724404286470e+01 -2.7740629900930994e+01 + 53 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 54 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 + 55 -1.1783270126548655e+02 -1.9472584883618183e-01 -3.6574242640823016e+01 + 56 -5.3306408717222062e+01 -4.8054342798707381e+01 -3.9204734285983008e+01 + 57 -1.1225984573690962e+01 2.0902821304606945e+01 -1.0842828823499091e+00 + 58 -1.5639600973783883e+01 3.7055729017065011e+00 -1.9828404272923528e+01 + 59 5.4139156830996429e+00 5.9778757589813964e+01 -2.3883800709664158e+01 + 60 4.0289832362530653e+01 -4.1876270741423269e+00 -1.8019718733793713e+01 + 61 -2.9803789778276474e+01 -1.2846624364406747e+00 -5.0425625243893258e+01 + 62 8.0660338957777533e-01 5.4686577469802673e+00 -1.3547627168270241e+01 + 63 -8.5708358255591914e+00 -3.0150178540572348e+01 -1.4967860711132145e+01 + 64 9.0239994663437773e-01 5.5410990098449542e-01 4.1571851677482030e+00 +... diff --git a/unittest/force-styles/tests/manybody-pair-polymorphic_sw.yaml b/unittest/force-styles/tests/manybody-pair-polymorphic_sw.yaml new file mode 100644 index 0000000000..c96b6bc4ab --- /dev/null +++ b/unittest/force-styles/tests/manybody-pair-polymorphic_sw.yaml @@ -0,0 +1,156 @@ +--- +lammps_version: 5 May 2020 +date_generated: Thu May 28 20:26:24 202 +epsilon: 1e-12 +prerequisites: ! | + pair polymorphic +pre_commands: ! | + variable newton_pair delete + variable newton_pair index on +post_commands: ! | + change_box all x final 0 9.8 y final 0 9.8 z final 0 9.8 +input_file: in.manybody +pair_style: polymorphic +pair_coeff: ! | + * * GaN_sw.poly Ga Ga Ga Ga N N N N +extract: ! "" +natoms: 64 +init_vdwl: -110.558587505304 +init_coul: 0 +init_stress: ! |- + -1.6871753140960841e+01 6.7120289611391286e+01 -2.6350807630371186e+01 -3.7494795095495206e+01 -3.5036126410883412e+01 3.0898629782251593e+01 +init_forces: ! |2 + 1 -1.1876356686746147e+01 8.3228947849512878e+01 8.8917387625898012e+00 + 2 4.7296776233945348e+00 5.9647313236460253e-01 -9.3956721546004529e-01 + 3 -1.6045330981700412e-02 -6.7535865814758687e+00 1.4247262360590556e+00 + 4 2.1732620398553579e+00 8.9577905222859258e+00 8.4192920490925029e+00 + 5 4.1837921590018352e+00 1.1866420133320579e+01 2.1153051759137846e+01 + 9 -2.2384113017649545e+00 4.4536752704903400e+00 1.5096218238548453e+00 + 10 -2.9177426731426925e-01 -1.7303903390080693e+00 -1.3038967110556552e+00 + 11 -3.4983141002625708e+00 9.0652143349687826e+00 3.2178991471040082e+00 + 12 -9.9212036790697744e-01 2.2449356862892449e+00 2.9577096846264554e+00 + 13 -4.9316300937888069e-01 2.4422561908341036e+00 9.1219811758773617e-01 + 17 -1.8734015294806287e+01 3.0718420983330070e+01 1.1107207643605946e+01 + 19 -7.1238170210446949e-01 -2.1714784222861332e+00 3.1521235207803971e-01 + 8 -2.4317481980233051e+00 -2.2822568229610609e+00 3.4571517294012284e+00 + 25 3.4400858498533871e-01 1.5226731357055667e+00 -6.0820587782977578e+00 + 16 -3.1848477377047648e+00 6.6076663459050855e-01 2.5922723422669014e+00 + 27 1.1137706196275878e+00 5.8862855612158246e-02 4.0389979052289343e-01 + 18 1.0758770915143348e+01 -6.6194988940053658e+00 6.8483543911987832e+00 + 20 -6.2434030705621355e+00 -6.7516052940948521e+00 -4.5133702312336572e+00 + 21 5.2237364213406918e+00 2.9030600913792837e+00 5.9048187718238827e+00 + 24 2.2719438779448344e+00 2.5663554163640621e+00 9.8704278040802595e+00 + 26 1.0169145023293402e+00 4.9900797947442760e-01 -2.3444818586904415e-01 + 28 -2.7802655147758819e+00 -7.7736637855039681e-01 -9.3913183626105035e+00 + 29 -3.0027267996067777e+00 -3.0757159365914584e+00 6.7939382681691809e+00 + 32 -4.9670256055705408e-01 4.3000056772385467e+00 -1.4364174845027060e+00 + 33 -1.3596327450926818e+01 1.8414065535303045e+01 2.4334263710095701e+01 + 36 -5.3253768122809786e-01 -6.9422274314231169e-01 -2.2019860155014509e-01 + 7 4.2563687880916135e+00 4.0506626097092981e+00 4.3748195077329406e+00 + 41 1.1585103537587949e+00 5.0503755615975221e+00 -8.5430630696074650e-01 + 15 -4.6848914176164573e+00 4.4556948103194921e-01 -1.0791330113399094e+00 + 44 1.2694984075473326e-04 -2.7635220537281918e-01 2.6187403800177576e+00 + 6 7.8616535471324733e-01 1.5954258588644912e+00 5.1167669165787177e-01 + 49 4.4458115932912792e+00 -2.2959173243188595e+00 2.6540455608229876e+00 + 57 -6.4314667746578003e-01 -2.5995746206906561e-01 2.4684842120937420e-01 + 14 -6.0533578980418379e-01 2.0108343404544127e+00 -2.4054802910511142e-01 + 22 1.2537555380551291e+01 -1.0604620153104181e+01 -3.2880354910376319e+01 + 52 7.7471965556027609e+00 -8.2657558724752001e+00 3.9972347545367497e+00 + 23 5.7702309695920584e-01 2.8877157891265132e-01 5.5544328953631872e-01 + 30 1.0783647586182532e-01 -5.4641509054446882e+00 7.3374486675282335e-01 + 31 -6.4694659578752232e+00 5.7553633669109883e-01 -2.1973848204178221e+00 + 60 -2.6889428139329166e+00 -1.6475993616724236e+00 -7.0243130435758205e-01 + 34 -7.3629953239847454e+00 2.5605883637087925e+00 -5.4898025041264304e+00 + 35 1.3871854674124702e+00 2.7747076128110986e+00 -2.6257448062479676e+00 + 37 6.5898703758578989e+00 6.6508341602498744e-01 -1.6772014855456816e+00 + 39 1.9779086834666131e+00 -4.0384199145682480e+00 -7.8174849523008190e+00 + 42 1.9893929553260841e-02 9.0841234766752554e-01 -1.3315158150186110e+00 + 43 1.1430633351592987e+00 4.0282338029110338e+00 -1.1248415509691769e+00 + 45 -1.9076955138745046e+00 1.3903236004232424e+00 -1.2815693112841717e+00 + 47 -1.8581734433208236e+01 2.0739774918848162e+00 -5.4002387242185748e+00 + 38 1.7035656926068818e+01 -2.8571950398402265e+01 -1.3809923561275051e+01 + 51 -2.8777132956215135e-01 1.0135288187474920e+00 -6.9659813589718800e-01 + 40 2.0605775687918704e+00 -7.7402004101008171e-01 -1.6802151119150648e+00 + 46 -1.5632717229640027e+00 1.6285024746575694e-01 -4.1339579873977828e-01 + 48 -3.4369353064395689e+00 -2.6083655148640315e+00 1.9285780693031578e+00 + 59 1.0065893993811101e+00 1.9522168013291357e+00 -2.7320606701689365e+00 + 50 6.9157952496030912e+00 6.7983669013250916e+00 -8.7391056351942531e+00 + 53 2.4593632121410924e+00 1.5874078756976844e+00 9.7589780141945059e-01 + 54 1.7793110091954848e+01 -9.8334301284218412e+01 -2.4810713563228799e+01 + 55 1.0540520136483824e+00 -9.6004612877438511e-01 -2.0082647736978805e+00 + 56 1.4745164837558393e+00 -5.6319701841044774e+00 -1.0893415324199731e+00 + 58 -1.0698480722375397e-01 -1.4887976576832087e+00 3.2692801165676189e-01 + 61 -1.1049989258046302e+00 -9.8925992286869532e-02 -3.5975803029667830e-01 + 62 8.3847363183302388e+00 -7.9441779730970898e+00 -1.9428697652986431e+00 + 63 -6.4026447196181824e+00 -8.9658730208109318e+00 5.5791283935903966e+00 + 64 -5.7668345333930739e+00 -5.3444816699294773e+00 2.4892095494490190e+00 +run_vdwl: -144.992990349495 +run_coul: 0 +run_stress: ! |- + -3.1701076082952088e+01 -3.7656770030899871e+01 -5.4490422529108301e+01 -1.1611843352902998e+01 -1.9941609984748986e+01 5.8892703036043648e-01 +run_forces: ! |2 + 1 2.6001753980068312e+00 8.8453956044365452e+00 -9.8797166618993941e+00 + 2 4.7965777681525594e+00 3.1418955328442177e-01 -6.7264903627663886e-01 + 3 1.0165193459026138e+00 -6.9858270050310001e+00 1.8628184449968073e+00 + 4 3.8602538711737191e+00 8.4722642593294442e+00 8.8567452606533053e+00 + 5 1.4325862819782447e+00 9.6460774612528724e+00 1.8484498014247425e+01 + 9 -1.1481583330859353e+00 3.6688819286639918e+00 2.0596448842899480e+00 + 10 -1.5948540569760689e-01 -1.7804814659974553e+00 -1.0111342802770735e+00 + 11 -2.8695789524802331e+00 8.0006124848439448e+00 2.9516495359219297e+00 + 12 -1.3694287291703762e+00 2.6454487190474807e+00 2.8765938514624372e+00 + 13 -5.4843165416037032e-01 2.4178430786947298e+00 1.1398502101802370e+00 + 17 -1.1381825725808325e+01 1.2915502454739507e+01 5.1238681810529574e+00 + 19 -7.5431623569785000e-01 -2.1661936391034660e+00 2.4918735731106073e-01 + 8 -2.2825002748067025e+00 -2.1223012980285478e+00 3.5281401425639487e+00 + 25 1.7333054580403262e-01 1.3337276459680432e+00 -6.1609668099787775e+00 + 16 -3.0802569601088012e+00 9.5925986030005028e-01 2.2666056736776650e+00 + 27 1.2682618334346174e+00 -1.4700543015080925e-01 6.0935929813436018e-01 + 18 9.6111051916319816e+00 -4.7298952633755444e+00 5.5528105778138421e+00 + 20 -5.7550438939721049e+00 -5.8408478677394928e+00 -4.9085613229771701e+00 + 21 5.4549105790401802e+00 2.6630471078722162e+00 6.0325918454019254e+00 + 24 1.9791326592062606e+00 1.5389863050677755e+00 9.4124356044129698e+00 + 26 1.0230811841295624e+00 5.4629680416587312e-01 -2.0268842134531423e-01 + 28 -1.8827867210279361e+00 -8.0983579348143708e-02 -8.0957444624412709e+00 + 29 -2.7782453830324263e+00 -2.5573236098459677e+00 6.7705114865425902e+00 + 32 -7.1101699485116887e-01 2.7906283637156255e+00 -9.1751469515765138e-01 + 33 -6.8060323342038727e+00 1.2668101760691528e+01 1.0975710263736646e+01 + 36 -7.0034117601634915e-01 -7.3481334049701386e-01 -3.2923650090110673e-01 + 7 3.8845315180472229e+00 4.1363004105214696e+00 4.1612397006953481e+00 + 41 9.9038174862740713e-01 5.2034287095562535e+00 -9.2279549656139437e-01 + 15 -4.3970394902375318e+00 2.7529926135490668e-01 -1.0537111051268997e+00 + 44 -4.3138030953488220e-02 -2.1730377457745106e-01 2.5879362252594804e+00 + 6 9.9340453391254468e-01 1.6560100312784802e+00 7.8977347536819120e-01 + 49 4.1632394287441876e+00 -2.6793965025719482e+00 2.3094287627967724e+00 + 57 -6.9229115466318514e-01 -3.3674905932471810e-01 2.6880467900088900e-01 + 14 -6.4833543831883622e-01 1.8793140665316381e+00 -4.1708918178362042e-01 + 22 6.8075019401962757e+00 -6.2213593280347208e+00 -1.8529952635070035e+01 + 52 6.0477513556601279e+00 -6.8466072151236883e+00 2.9952979114061438e+00 + 23 4.6278885706494510e-01 3.8608940279342213e-01 8.5014465678374362e-01 + 30 4.8720777514052538e-01 -5.4014658873264407e+00 3.6862303261910623e-01 + 31 -6.7438316872628379e+00 4.4362126872178842e-01 -1.9853303658062882e+00 + 60 -3.0228065714741517e+00 -1.9614689041002695e+00 -9.8795271024452358e-01 + 34 -7.6430167294980933e+00 3.1186302206809264e+00 -6.4742189675725701e+00 + 35 7.0112612235293548e-01 3.2263957902917295e+00 -1.6627434314520302e+00 + 37 6.9659019279999326e+00 6.6687056140876833e-01 -1.7233441201475324e+00 + 39 1.2282661288072532e+00 -2.8886872299953255e+00 -8.5998645412511383e+00 + 42 -1.7823656100406512e-01 6.3207831041068252e-01 -1.2857226015957983e+00 + 43 7.5310776116899159e-01 4.0022631696456701e+00 -1.4783935084238897e+00 + 45 -1.9253816101880521e+00 1.3252488113122081e+00 -1.2487618876812336e+00 + 47 -1.8506359747177516e+01 6.3237428091566317e-01 -4.1112559217521163e+00 + 38 1.0144657031880191e+01 -1.0180115609902439e+01 -8.1296975662497548e+00 + 51 -7.6976444738773875e-01 7.2408105720737537e-01 -2.0882810980395097e-01 + 40 2.2197909873190063e+00 -7.9705770507637119e-01 -1.6269370534025505e+00 + 46 -1.4334721232398184e+00 1.8708798225467027e-01 -3.4929993475111276e-01 + 48 -3.3460942707282499e+00 -2.1689603476053896e+00 1.6173482627519267e+00 + 59 9.0492207431875471e-01 1.9820913506452942e+00 -2.6150393093642141e+00 + 50 6.3005475103750506e+00 5.0761727277929296e+00 -6.6034546604114785e+00 + 53 2.9350764434089260e+00 1.7618197320303048e+00 1.2296397931736294e+00 + 54 5.5219180293126131e+00 -2.1620842486142536e+01 -4.2059340473074602e+00 + 55 9.4497148035695844e-01 -8.8829453241008549e-01 -1.9741545697816292e+00 + 56 1.3986670274834250e+00 -5.8733780758809022e+00 -7.8406096467097630e-01 + 58 1.9591652237395313e-02 -1.3594894300349787e+00 3.5228908450816110e-01 + 61 -1.0808324746228049e+00 -9.8892831798155223e-02 -4.0399214029008695e-01 + 62 6.7102847473646960e+00 -7.3289558365414296e+00 -2.1817303825752870e+00 + 63 -5.6961477142673687e+00 -7.4946638072487755e+00 3.0071800556862467e+00 + 64 -5.4473739150961515e+00 -5.2320794746151691e+00 2.4517511318822947e+00 +... diff --git a/unittest/force-styles/tests/manybody-pair-polymorphic_tersoff.yaml b/unittest/force-styles/tests/manybody-pair-polymorphic_tersoff.yaml new file mode 100644 index 0000000000..2f2aa14608 --- /dev/null +++ b/unittest/force-styles/tests/manybody-pair-polymorphic_tersoff.yaml @@ -0,0 +1,156 @@ +--- +lammps_version: 5 May 2020 +date_generated: Thu May 28 20:29:01 202 +epsilon: 1e-12 +prerequisites: ! | + pair polymorphic +pre_commands: ! | + variable newton_pair delete + variable newton_pair index on +post_commands: ! | + change_box all x final 0 9.9 y final 0 9.9 z final 0 9.9 +input_file: in.manybody +pair_style: polymorphic +pair_coeff: ! | + * * GaN_tersoff.poly Ga Ga Ga Ga N N N N +extract: ! "" +natoms: 64 +init_vdwl: -112.241357306965 +init_coul: 0 +init_stress: ! |2- + 4.3249132419495197e+02 6.1806988005325991e+02 4.8708813529781338e+02 -2.2467788013860402e+02 -1.5225332287691344e+02 1.2236676585794305e+02 +init_forces: ! |2 + 1 -3.6576527209649853e+01 1.2938151330813227e+02 3.6345316984166146e+01 + 2 3.0977771717520954e+00 1.0739593384813553e+00 -4.6576264507651288e-01 + 3 9.8530602450832117e-01 -5.2416805937742517e+00 2.3321799148388038e+00 + 4 -9.9225324315448091e+00 1.5221288458098677e+01 8.8143676672282432e+00 + 5 3.2314320694378168e+01 1.1087279427646233e+02 1.3420046940012486e+02 + 9 4.4839529210690365e+00 5.4432932554408353e+00 1.0556917325814013e+00 + 10 -1.7521535083648562e-01 -1.0618497917189478e+00 -4.7535767072727675e-01 + 11 -2.2854505757948473e+00 5.1507466341367323e+00 4.5622702229903123e+00 + 12 -2.8113964035294297e+00 4.2388645326806227e+00 2.2147723017377579e+00 + 13 -1.2765060495244165e-01 1.0068988592168191e+00 -1.2365763873232410e-01 + 17 -2.3501002243763395e+01 3.3055061638078982e+01 1.7854192244654975e+01 + 19 -3.8181868116858864e-01 -1.2946600508103308e+00 4.3806378281490377e-01 + 8 -1.2106106126943370e+00 -1.0004811284718682e+00 2.2528835072663225e+00 + 25 1.1442499752518618e+00 1.3049784576661452e+00 -3.9372445813136152e+00 + 16 -1.6680446535103393e+00 3.4347842991462080e-01 1.8159391012790485e+00 + 27 3.8681985124513663e-01 2.1817713130227312e-01 -7.4274211430628095e-02 + 18 8.0626637261147565e+00 -1.0097638287045562e+01 9.2069941284667038e+00 + 20 -1.1961654715441478e+01 -1.4551730941350193e+01 -6.4766250405568355e+00 + 21 4.0081675615990839e+00 2.6895369384044807e+00 4.1167490865191887e+00 + 24 8.6492696284632693e+00 -6.0561557014483157e+01 7.2286862275972936e+01 + 26 1.1494621549537498e+00 -7.2432026533234029e-01 1.0869393856530929e+00 + 28 1.2645066510058989e-01 1.4320131071408668e+00 -6.7340392379246126e+00 + 29 -3.3702155567364684e+00 -3.2549006098999866e+00 4.8884522133575947e+00 + 32 -8.8483084469915610e+01 -1.1200047244916043e+01 9.5784775552006948e+01 + 33 -1.8644046130608288e+01 1.9364538700579399e+01 2.5778779302511367e+01 + 36 -2.8042870420021032e-01 -2.1860793435872525e-01 -7.6864979554238350e-02 + 7 2.5181109971965268e+00 3.2698722922262653e+00 2.8164026735484646e+00 + 41 5.5172958489046664e-01 2.9453718703404639e+00 -7.3110142207332629e-01 + 15 -2.3683646352557584e+01 2.1693607895628791e+01 -1.5164189390961038e+00 + 44 2.6573938517485385e-01 -5.4034160139055132e-01 9.6066687059865619e-01 + 6 1.9715873814008808e-01 7.7695128654241785e-01 6.0931852686477728e-01 + 49 3.3322235015568324e+00 -2.2418812526744318e+00 2.6146135232678560e+00 + 57 -4.0596556673288997e-01 -9.5749284320264763e-02 9.3874613972158169e-02 + 14 -3.2648583794155717e-01 7.4898927303350349e-01 -1.8298065978446745e-01 + 22 3.8037998520385763e+01 -3.5663802423995136e+01 -2.7458250761362578e+01 + 52 3.3239246849248909e+00 -3.5990994242240335e+00 2.8668757850233484e-01 + 23 4.8249073367896089e-01 4.1184614571846628e-01 -4.2839171008370558e-01 + 30 -2.9576701575095754e-01 -3.2760747002556472e+00 5.5196911179426422e-01 + 31 -4.7032916381504091e+00 1.8947124025478370e+00 -2.0884543144298373e+00 + 60 1.3469801683713634e-01 6.2189078552010812e-01 -3.2416745673411806e-01 + 34 -4.9077438486304317e+00 1.6092134233186410e+00 -1.5936338429999157e+00 + 35 2.5233224849597855e+00 3.5549922547808208e+00 -3.9173351808482244e+00 + 37 3.7345607063959041e+00 -4.5675353117101725e-01 -1.3118764437189274e+00 + 39 1.0238170156802811e+01 6.1259246571220871e+01 -6.9566508281160054e+01 + 42 3.1048969454169895e-01 7.0535058868601708e-01 -3.9123279022002549e-01 + 43 2.3421035807655830e+00 9.1704233370645483e-01 -1.7921408586477086e+00 + 45 -1.2462272926486704e+00 6.6243737496148558e-01 -3.9134993283158831e-01 + 47 -1.3714599075673763e+02 1.0122387435383013e+02 -6.1180372654184829e+00 + 38 2.2053662681085775e+01 -3.2675141691136901e+01 -1.9787196459938222e+01 + 51 -1.5107811740662136e-01 -9.5420656021299466e-01 -2.2740038600456280e-01 + 40 7.8343540459539973e-01 -2.0865227827621957e-01 -1.0896699134917764e+00 + 46 7.5199515301374475e-02 -3.7924801419959309e-01 -6.1781121018344654e-01 + 48 -1.8713289346764626e+00 -1.0088751558808138e+00 4.6162952627592091e-01 + 59 1.4812329930198839e-01 5.6950694539734759e-01 -1.1129911705762310e+00 + 50 4.8606176355069817e+00 8.2338518628894164e+00 -9.7207551169384487e+00 + 53 1.5020789095255760e+00 7.4762683643922823e-01 4.5499335434524368e-01 + 54 2.1648470709051230e+02 -3.2495513568950082e+02 -2.6797326382032088e+02 + 55 3.0448492140988748e-01 -5.7103418134695261e-01 -1.2743693125056259e+00 + 56 1.5544822032079768e+00 -4.5781311536801752e+00 -1.2969815929432023e+00 + 58 4.7136839274753717e-01 -6.9091586523089177e-01 5.5335017914685647e-01 + 61 -7.3439574845735711e-01 -2.1675143521702822e-01 -2.2874475272149264e-01 + 62 6.4996283247232540e+00 -7.4637247642767051e+00 -5.0174108531675454e+00 + 63 -5.7071873855477513e+00 -9.3348074441081295e+00 6.5081800066406998e+00 + 64 -4.5601626990206690e+00 -4.5257272492649570e+00 3.5749156843886922e+00 +run_vdwl: -203.611092321268 +run_coul: 0 +run_stress: ! |- + -4.2049484348235183e+01 -5.9189088685535481e+01 -5.0689386485552980e+01 -1.8364326484744367e+01 -1.2822694127765459e+01 1.7363774136149935e+01 +run_forces: ! |2 + 1 1.7939756373154978e+00 -1.1208319637796436e+01 -4.7866634606556708e+00 + 2 3.7204026301607032e+00 5.0628621597397228e-01 -5.3413782443010405e-01 + 3 1.8471257413913276e+00 -6.2823444167750928e+00 1.3665870486084699e+00 + 4 -3.2320065638233331e+00 6.7270122311417211e+00 8.1723438304257279e+00 + 5 4.6217901401315915e+00 1.0863412036937085e+01 1.1126624417063194e+01 + 9 -5.7081176786978531e+00 5.1677579033206058e+00 4.4647480813472766e+00 + 10 -1.3063455353378964e-01 -1.0836814049526238e+00 -3.2753858483337051e-01 + 11 -2.4246549271165598e+00 5.7101324774375772e+00 4.9315474886301178e+00 + 12 -3.7965311006712561e+00 5.8417042217798363e+00 2.7925668054307655e+00 + 13 -9.3612493581427925e-02 1.1534950866682339e+00 1.0344539998300817e-01 + 17 -1.0130328608941838e+01 1.0319068327042208e+01 5.2364714182394518e+00 + 19 -4.0037881131041847e-01 -1.2527014456384118e+00 3.6823689760325146e-01 + 8 -1.2232870679980579e+00 -1.0004421013562073e+00 2.3099733087226308e+00 + 25 9.6032966256812280e-01 1.1449000944189454e+00 -4.0054320422643075e+00 + 16 -1.6580254677123794e+00 2.1049836131872629e-01 1.5607821069119807e+00 + 27 4.7488975754088597e-01 8.9514263858711571e-02 5.8726290073366536e-02 + 18 7.4601352685103635e+00 -5.5310059308322508e+00 5.3125956730780217e+00 + 20 -7.0926635534301194e+00 -7.2590543601985615e+00 -6.1674919978387237e+00 + 21 4.1908954283746649e+00 3.0491822757804119e+00 4.4518291509682308e+00 + 24 5.7590645389044584e+00 4.3564682716409280e+00 6.4508519865865583e+00 + 26 1.4217364583576858e-01 1.4960650360445182e-01 4.5718190780874096e-01 + 28 1.1349236573774526e+00 2.2761435327220783e+00 -5.9730933464743714e+00 + 29 -2.7867012040747063e+00 -2.4702199788611980e+00 4.7211936268532444e+00 + 32 -1.1532642739483379e+00 2.9149579740167866e+00 -5.8998040394914284e+00 + 33 -8.1720168390170969e+00 1.0536116946211063e+01 7.8839425873690150e+00 + 36 -3.5717324453145044e-01 -2.2255539137938293e-01 -8.3906857577034130e-02 + 7 2.2209848870416780e+00 3.2189941222874436e+00 2.5910209493227510e+00 + 41 4.8936661703074336e-01 3.0547346740064669e+00 -7.3906935937596785e-01 + 15 -2.9409678566978847e+00 6.1085688155501927e-01 2.9475390395049600e-01 + 44 1.9541097803380220e-01 -4.4468176101268314e-01 1.0176986248574860e+00 + 6 3.0987750315356288e-01 8.3678762081949221e-01 7.0235938485577731e-01 + 49 2.9103116184165554e+00 -2.3426722789735948e+00 2.1935227677704248e+00 + 57 -4.1483289858517808e-01 -1.6475409302825694e-01 8.8751421011581177e-02 + 14 -3.6664330256500349e-01 7.5120063095742429e-01 -2.6314287009643650e-01 + 22 7.3478252843488718e+00 -6.1689027765702136e+00 -1.2191865417888138e+01 + 52 2.8234453813943876e+00 -3.2347981236230305e+00 4.6846318946505017e-01 + 23 5.2487632403478568e-01 4.5848786084689036e-01 -2.8426094252701828e-01 + 30 6.9788385652458373e-04 -3.2692120625975409e+00 2.4134335178597510e-01 + 31 -4.7289364647448959e+00 1.6531052258817445e+00 -1.7169707860995391e+00 + 60 -1.6047921602890547e-01 4.3809780266159670e-01 -4.9231335386324615e-01 + 34 -5.4996907115520708e+00 7.5181319813262526e-01 -2.3171213923254221e+00 + 35 4.8106995828675210e+00 7.1169887708264916e+00 -5.6110197589213691e+00 + 37 3.9037369696598163e+00 -3.5890001237788355e-01 -1.1199415586639974e+00 + 39 6.3364725802017006e+00 -5.4176635698201068e+00 -7.3318779334885562e+00 + 42 -3.9528153001845484e-01 1.5597737723367203e-01 5.2784338346775851e-02 + 43 2.2657812576932397e+00 1.9712039200390983e+00 -1.2370089231886103e+00 + 45 -1.2260709579840805e+00 6.1245263557219842e-01 -4.3698060412983547e-01 + 47 -1.0420135908179688e+01 5.7001528094305343e-01 -9.0003704553925488e+00 + 38 9.7334516769680874e+00 -8.8132706217214860e+00 -8.4313924553967841e+00 + 51 -1.5893799847955918e+00 -8.3821253179133404e-01 1.2455496182737864e+00 + 40 9.3358332318778159e-01 -2.4842482840019792e-01 -1.1357782777258685e+00 + 46 5.3072693972158191e-02 -4.1780244594259308e-01 -5.8470587436144816e-01 + 48 -1.7851692820511502e+00 -8.2285670190056948e-01 3.5445348939455101e-01 + 59 1.8342901227573127e-01 3.1930603555127135e-01 -8.5429628645135613e-01 + 50 4.9209401662251961e+00 6.4162503219489153e+00 -6.3625199989179393e+00 + 53 1.7195958602754113e+00 8.6752486866952305e-01 6.2371405899840404e-01 + 54 -3.3730515088927611e+00 -8.2571374860614952e+00 4.5905709087303457e+00 + 55 2.9111712152328195e-01 -6.0568036958349580e-01 -1.2650082903307274e+00 + 56 1.3734924894688838e+00 -4.7988036888201933e+00 -1.0498689187601902e+00 + 58 5.2202454854535030e-01 -2.0969163457055551e-01 1.0326238710272539e+00 + 61 -7.4031928141422254e-01 -2.4982528971416698e-01 -2.7078923661290932e-01 + 62 4.7240540893840048e+00 -6.5824371146058915e+00 -4.5927562090591252e+00 + 63 -4.2130786356549734e+00 -6.8532850187004968e+00 3.8433571293767557e+00 + 64 -4.4865200301162247e+00 -4.4107168742006451e+00 3.9565120242715395e+00 +... diff --git a/unittest/force-styles/tests/manybody-pair-rebo.yaml b/unittest/force-styles/tests/manybody-pair-rebo.yaml new file mode 100644 index 0000000000..896d4c9669 --- /dev/null +++ b/unittest/force-styles/tests/manybody-pair-rebo.yaml @@ -0,0 +1,123 @@ +--- +lammps_version: 5 May 2020 +date_generated: Wed May 27 16:29:21 202 +epsilon: 1e-07 +prerequisites: ! | + pair rebo +pre_commands: ! | + variable newton_pair delete + variable newton_pair index on +post_commands: ! "" +input_file: in.airebo +pair_style: rebo +pair_coeff: ! | + * * CH.rebo C H +extract: ! "" +natoms: 48 +init_vdwl: -184.39204996406 +init_coul: 0 +init_stress: ! |2- + 3.3789835306128507e-01 2.9478711461049310e+00 2.4743519134193620e-01 5.2979459234337423e-01 5.3569422394689620e-02 -6.3505274336891904e-03 +init_forces: ! |2 + 1 1.4202190879785526e-01 -1.6923984230378553e-02 -8.0222747253743343e-02 + 2 -6.4677585143091409e-02 -3.6433357195058524e-02 -1.3515634272432853e-01 + 3 1.6366649982768461e-03 1.6053110519967689e-02 -1.4025763949495174e-02 + 4 -8.7465877246782064e-02 -4.5665431983584470e-02 6.9471854481199857e-02 + 5 1.3195994863209298e-02 -8.8650322236522028e-03 4.7800865172213158e-02 + 6 1.9299312240111804e-02 3.2589948135326341e-02 9.4282241042096482e-02 + 7 -3.4087548299692300e-01 -1.2294752754679814e+00 -5.1904944459948887e-01 + 8 6.0078607638260430e-02 2.0498638968231599e-02 -9.3398594218969955e-03 + 9 1.2467205701909068e-02 3.8099505743407369e-02 1.4081369951564779e-01 + 10 -1.4036212729933867e-01 4.9553606683401752e-02 -2.1963701282202114e-01 + 11 3.2484928214165820e-01 1.1715484924862587e+00 5.9205862013599853e-01 + 12 4.5455440111838996e-03 7.0650496984066086e-02 9.7280898658545945e-02 + 27 5.5286552293670688e-02 -6.1630718420004310e-02 -6.4277008234728178e-02 + 21 -4.7676041551031507e-02 -1.4184636978150536e-01 -2.8031242280102477e-02 + 24 7.1293499799228721e-03 4.1506393546603043e-02 -6.0982020307679297e-02 + 13 1.4285882963341517e-01 -5.2384998310674569e-01 3.9059586453922496e-01 + 14 -2.6409215624427620e-02 4.0885007985568989e-02 -4.4527602205848518e-02 + 15 9.4148020666386945e-03 -2.1650842400402603e-02 -6.0700470522046301e-02 + 16 2.7589478534633342e-02 9.4400733405235110e-02 -8.2175724005590367e-02 + 17 1.9938322866522945e-02 1.4150256621370427e-02 5.7938275768113626e-02 + 18 -2.9140299812124015e-03 4.1224695127785871e-03 4.0285077968213873e-02 + 19 -1.0956826435917441e-01 9.8882094001784826e-02 5.1415130337933178e-02 + 20 4.2734074327792415e-02 -5.5424208208681991e-02 1.1052940421399760e-01 + 22 -1.0219053657335460e-01 4.7431777837340239e-01 -3.1183876381211661e-01 + 23 4.5058119107672233e-02 -1.1595478876420868e-02 -5.2231218382529837e-02 + 44 -5.9648884273971747e-03 -1.3897851072986189e-02 -1.0276711311569930e-02 + 25 -2.0136865848674812e-01 -4.7696365943292690e-01 2.4014128617877950e-01 + 26 4.6252559235559265e-02 1.2642361045365202e-02 5.3750496277286341e-02 + 28 -6.5526188863108709e-02 -1.0387188938520331e-01 2.2724432063331967e-02 + 29 5.2910469917024153e-04 6.4293429254679846e-02 -9.5734654968105404e-02 + 30 -2.5656270371135326e-02 8.9866516167501964e-02 7.6113059467498245e-02 + 31 2.8687599814099147e-02 2.7435698043211158e-02 2.1404025944551910e-01 + 32 2.0705832938081647e-02 -2.7784502684321359e-02 -8.9926281846312656e-02 + 33 -1.1574426610426986e-02 -1.8175898613825903e-02 -9.6238877865259878e-02 + 34 2.0032908192871635e-01 4.5813298053841539e-01 -4.2116917796723119e-01 + 35 3.2384272237732450e-02 -4.7898005988897652e-02 5.8652806051106940e-02 + 36 -2.4762906521939687e-02 2.2322971056000673e-02 3.7646653163387167e-02 + 39 -1.9729509365073616e-02 -6.3932335561141695e-02 -3.2518573086913416e-02 + 37 -1.3157059618544575e-01 1.5168013170222649e-01 4.1142188933296353e-04 + 38 -1.5988852221844319e-03 -2.5960445676513955e-02 2.0267750002825768e-02 + 40 1.8210944814579538e-01 -1.3682022454448478e-01 -1.5749873768297096e-01 + 41 -2.3107060620930875e-02 9.3912672524065405e-02 7.4598235310812111e-03 + 42 5.2864866169949176e-02 4.7976956598500820e-02 -5.4878417596658124e-02 + 43 -3.9860425909811842e-01 1.2112577926727722e-01 3.4047365974571434e-02 + 45 1.7935918713998519e-01 -1.7837444575824185e-01 -3.2987232446594350e-02 + 46 1.0998928173472683e-01 -1.5086188432942196e-01 1.6829691363685131e-01 + 47 -7.6878894879590064e-04 5.5783704671116340e-02 -2.0995953677601979e-02 + 48 5.1056316250091771e-02 8.5470091106617740e-02 6.8395639456075963e-02 +run_vdwl: -184.51998480396 +run_coul: 0 +run_stress: ! |- + -9.7239038536264044e-01 7.4669322717364839e-01 -7.7104364903424294e-01 5.4771494015343014e-01 -2.1796905704783737e-02 1.5820274570202170e-01 +run_forces: ! |2 + 1 7.4155582187185320e-02 -1.5455609952472066e-01 -4.0185659582818589e-01 + 2 -1.2599664371163707e-01 -4.7270532243529007e-02 -1.2614563997376005e-01 + 3 7.9410728544291417e-02 -6.7788695692031498e-03 1.0261863017785233e-01 + 4 3.7589897293458219e-01 6.5448581597716937e-02 5.8478513706716928e-01 + 5 -1.8406250774366176e-01 -1.5832209948748655e-01 -8.6604265862793073e-02 + 6 -1.7291110116223143e-01 4.4906356654481727e-02 3.0419307237807502e-02 + 7 -3.3201513523500364e-01 -5.7108644658989294e-01 -5.7184715922428109e-01 + 8 1.0238297541360618e-01 -8.5807437101430781e-02 5.5823992026930724e-02 + 9 -1.3228565520703811e-02 -3.7950591025267766e-02 2.0421517542414661e-01 + 10 1.4592100832953753e-01 5.0467945019617289e-01 -7.4626980273333943e-01 + 11 -5.1925532167434674e-02 6.6189711468983248e-01 8.1768796712217684e-01 + 12 5.1995519711525773e-02 -1.5927701231286884e-01 1.9862297055802863e-01 + 27 5.0374698419944214e-02 -5.5882415283804526e-02 -6.1449715991752973e-02 + 21 1.6055010729342936e-01 -8.1367480026234451e-02 4.7738041806187972e-03 + 24 -1.0140395868207885e-01 -1.0454584382977056e-02 -4.3414162729483508e-02 + 13 1.1052397822448223e-01 -4.8902847823072948e-01 2.2436653549186952e-01 + 14 -1.2659521957922421e-01 1.2816580952653644e-02 -3.9238318659560040e-02 + 15 1.0828096163587569e-01 1.5750742059927378e-01 -4.9031658140836099e-02 + 16 -9.3819071598751372e-02 1.1363099411041987e-01 -2.8917292131028305e-01 + 17 6.1264072128814004e-02 -1.0300523555956453e-02 7.5263991898455590e-02 + 18 9.3662574156401057e-02 -9.7235276408278087e-02 1.4807349757758884e-01 + 19 -1.3885588032919249e-01 -5.8043962338309218e-02 2.8993245656022994e-02 + 20 -1.7941687952715857e-01 1.9675979738168892e-01 4.8524391854859461e-02 + 22 2.9757987689549029e-02 2.6821741595825943e-01 5.0099879446351969e-03 + 23 8.0001033580391123e-02 9.3334873087038556e-03 -1.0495490808234802e-01 + 44 -3.9497049925369954e-03 -1.1835391368516579e-02 -9.1934856815404364e-03 + 25 -1.0758122712185991e-01 -7.4031425832087994e-02 7.9729207343358754e-02 + 26 -1.1995670080895027e-01 -1.3389321888390909e-01 5.7892521051779777e-02 + 28 -1.4765203681698147e-01 1.0766945779400883e-01 -1.2725063867138145e-01 + 29 9.8604349817134632e-02 -1.1569372528116473e-01 1.0229831981692472e-02 + 30 1.4286353986949066e-01 -1.3879111821390899e-01 7.8927078553209795e-02 + 31 1.3924003711072844e-02 1.3544044195264066e-01 1.3574982086169629e-01 + 32 -1.5074384592659218e-01 -1.6814340709227951e-02 -5.7556964094494831e-02 + 33 1.4184429434188114e-01 -3.5285331907102369e-02 -6.4237440338038271e-02 + 34 2.8579134215307045e-01 2.6727531865785603e-01 -5.8543384904504128e-02 + 35 -6.1822738170098798e-02 5.8781336914225123e-02 9.2908986409371730e-02 + 36 -9.5270981048167308e-02 -5.4657394491328407e-02 -1.4784901819268981e-01 + 39 1.5246274787180031e-01 6.3970465119924325e-02 2.2789344570593340e-02 + 37 -6.2050313799109447e-01 6.2522082639067444e-02 1.7931449902055974e-01 + 38 1.1783097105703605e-01 1.6630970573315029e-03 -7.7576019986230649e-02 + 40 3.0652623048947314e-01 -1.0727327421957705e-01 -3.0878707410990303e-01 + 41 -1.0805211258372868e-01 -1.2213265101714554e-02 1.1407035371979291e-01 + 42 -3.0772480548032222e-02 4.6330303739023915e-02 -2.8690841675368839e-02 + 43 -3.4159822655899680e-01 -6.1488889554779033e-02 -1.2996240931199338e-01 + 45 2.5974287224213982e-01 -5.1237846099988077e-03 -9.2705797475414742e-03 + 46 -5.2983750718683130e-02 6.0115740314057198e-02 2.2945318498880257e-01 + 47 1.9907355212167138e-01 7.7186684778662140e-02 -1.4956254800833946e-01 + 48 1.1827333461841494e-01 -1.2568916016199683e-01 1.5822209053962674e-01 +... diff --git a/unittest/force-styles/tests/manybody-pair-sw-multi.yaml b/unittest/force-styles/tests/manybody-pair-sw-multi.yaml new file mode 100644 index 0000000000..8adc86b0a1 --- /dev/null +++ b/unittest/force-styles/tests/manybody-pair-sw-multi.yaml @@ -0,0 +1,155 @@ +--- +lammps_version: 5 May 2020 +date_generated: Tue May 26 18:05:58 202 +epsilon: 2.0e-08 +prerequisites: ! | + pair sw +pre_commands: ! | + variable newton_pair delete + variable newton_pair index on +post_commands: ! "" +input_file: in.manybody +pair_style: sw +pair_coeff: ! | + * * CdTe.sw Cd Cd Cd Cd Te Te Te Te +extract: ! "" +natoms: 64 +init_vdwl: 26.7735450040197 +init_coul: 0 +init_stress: ! |2- + 9.2215589743259159e+02 9.2929136989037136e+02 9.3631381668759911e+02 -5.3594035381468430e+00 4.2951811491157862e+01 3.2493816047643775e-01 +init_forces: ! |2 + 2 -3.2460200489793500e+00 -5.2454244934730698e-01 -8.8554577908093124e-02 + 4 -3.7550229530879480e+00 3.9276906070864501e+00 -2.7341852448360364e+00 + 5 -4.9428952375813591e+00 -1.5230856400759230e-01 -5.1101382630543268e-01 + 9 1.2794779935016463e+00 -3.2797474990238538e+00 -5.6200604186324750e+00 + 10 -7.6407515298239637e-01 -3.2691443152328672e+00 -4.3863741561204703e+00 + 13 1.2158031330244996e+00 5.1423663033205678e+00 -2.8966995612129622e+00 + 11 3.3861615867750707e+00 -4.9683858971114292e+00 4.1895205613535911e+00 + 12 -8.2360448938242783e+00 -5.7062639185796451e+00 -1.7633724482362065e+00 + 19 -4.8754191121854851e-01 -1.4191538952970415e+00 -4.3840175796712788e-02 + 21 3.6257760541440107e+00 2.2065869922267831e+00 -4.4279331735523897e+00 + 8 1.4294689068331063e+00 2.2636360745056776e+00 -4.0762210594579216e+00 + 29 -6.4288306313241170e+00 2.1891252257805252e+00 8.0180629914706292e-01 + 16 3.1090011637105852e+00 -2.8708952335092541e+00 6.7224226467307773e+00 + 17 6.0070675731921135e+00 4.3687665039809715e+00 -6.5168175462804641e+00 + 27 2.9196375113283430e+00 3.2105451949929535e+00 4.6622933045440584e+00 + 3 1.8982766778217899e+00 1.4247248986395151e+00 3.3417857760650416e-01 + 18 -2.5811293221725813e+00 1.5826127169940429e+00 4.5091166627861483e+00 + 24 2.9307502716343357e+00 -1.2831272453754801e+00 5.3296902051586885e+00 + 26 8.3947981463781063e-01 -5.9385867219744581e-01 4.9885662492381027e+00 + 1 -2.2842357687112180e-01 4.5711301027610736e+00 1.0663499172221975e+00 + 32 -4.5990540370898660e+00 1.9017862542180055e+00 1.1279561864346763e+00 + 36 -2.1676126497687140e+00 -5.7474381104436114e+00 7.9938381326243613e-01 + 37 -3.1469638906320352e+00 2.3148038858393392e+00 -3.0837091562348684e+00 + 7 -9.1188184724900223e-01 -3.5329926484337690e+00 6.9677168336485051e+00 + 41 -8.9015251000077145e-01 -3.6085163924588057e+00 -3.0489396933152202e+00 + 45 -4.1660294761409054e+00 -3.1889192185217807e-01 -4.5619609508020380e+00 + 15 -4.6359026110831358e+00 7.1029582514682552e+00 -2.3130720807547620e+00 + 33 4.6732735059827046e+00 -4.6315169323752414e-01 4.0035554891858105e+00 + 44 7.3035711284712184e+00 -5.3542243951685702e+00 1.1949352597693155e+00 + 6 -2.4756292474045267e+00 3.2153632611075387e+00 3.1547575563672856e+00 + 49 -5.5900952571860074e+00 -7.0476051494345873e+00 -3.1532606769630389e+00 + 53 4.0050004638824044e+00 4.0608447613902179e+00 3.4204359602701251e+00 + 14 -1.3195428576137587e+00 5.1767642060630443e+00 2.3833307269095259e+00 + 23 5.7665250365337188e+00 5.8416202202466057e+00 1.4055520057744932e+00 + 40 5.7825826990543971e+00 -3.6716637199713942e+00 -2.5446105469850284e+00 + 57 5.6640134231150419e-01 2.7969953024820127e+00 -1.5623865556692038e+00 + 61 -4.0134099768670755e+00 3.6106638794841053e+00 -4.3505503690214633e+00 + 31 -3.4570968391377588e+00 2.0254336267386726e+00 9.7920837703037578e-01 + 48 4.8028621015371495e+00 -2.1678018622276980e+00 -1.2048945707498988e+00 + 22 -4.5482433499807309e+00 4.6101470986115896e+00 -5.0056427898370179e+00 + 52 7.8689290486835999e+00 -4.8945300694074909e+00 3.4814408430853940e+00 + 30 -4.6434600040657710e+00 -1.0277167779353258e-01 -1.1644667817110257e+00 + 56 2.0753540120539835e+00 -7.6011086760469038e-01 -2.5820593578923114e+00 + 60 -4.4328859148421191e+00 -6.9142081266200091e+00 -2.8459986051724675e+00 + 64 3.3607381935199805e+00 3.2378383101927035e+00 8.2922830712908908e+00 + 35 2.3440526742011376e+00 2.0906011640072126e+00 3.1911938441203187e+00 + 39 5.7415977036661667e+00 -9.3203605339588413e-01 -7.1228166877454759e+00 + 42 -8.0640816842653020e+00 -3.7533193854127642e+00 1.3753933975437806e+00 + 34 3.7681877949608844e+00 3.8683708170062236e-01 -1.1310375100028460e+00 + 43 1.5935624218461042e+00 -9.3085936553350273e+00 -6.9183248149807930e-01 + 47 4.5133603899464427e+00 2.5040501555312593e+00 3.0194519497094119e-01 + 38 -2.1812156988259108e+00 -4.7195703108168696e-01 1.0920297748904253e+00 + 51 -1.8258352996541620e+00 1.3105333422172052e+00 7.7936770351283249e+00 + 25 -4.0282792670412881e-01 -3.1185048295924478e-01 2.2254328237573522e+00 + 46 -2.5089483725830446e+00 -3.5357839429318179e+00 8.1445323194595041e+00 + 55 1.0013193616042407e-01 -4.4362680414767386e+00 -5.1340494338819598e+00 + 59 4.7076687123646712e+00 3.7686319760374349e+00 -6.0263320018699726e+00 + 63 6.2441950513095250e+00 -4.6853003614172328e+00 -7.1748142164134499e-02 + 20 -8.5686247583560906e+00 -1.5305219454477976e+00 6.0119182483286393e-01 + 50 -7.4120646899657228e-01 5.2581666380246004e+00 -1.0794641205685305e+00 + 54 2.8871025201085763e+00 -5.6941671339881497e+00 -4.2393473872817040e+00 + 58 5.7691847316800571e+00 -2.1903252845174292e-01 8.9352008938660221e-01 + 62 -5.8762448689533544e+00 5.8942813011991326e+00 -4.1862202974892249e+00 + 28 -6.7825287943553403e-01 5.5346595493857604e+00 4.7360555350433335e+00 +run_vdwl: 19.8072602419103 +run_coul: 0 +run_stress: ! |2- + 9.1390363988714034e+02 9.1951651479659233e+02 9.2668428352248520e+02 -5.2984147862115076e+00 3.7625408334862954e+01 3.2051937916419488e+00 +run_forces: ! |2 + 2 -2.8515988027093400e+00 -6.0968372901702494e-01 1.7256603688253935e-02 + 4 -3.3648566765740400e+00 3.6516610474224414e+00 -2.9098414971322515e+00 + 5 -4.5846512855840436e+00 1.6883148551150473e-02 -4.0868370268280718e-01 + 9 1.0174635499202966e+00 -3.5418896696884814e+00 -5.4414669644351701e+00 + 10 -5.6738756794623413e-01 -3.0401734464229921e+00 -2.9313851917820131e+00 + 13 2.0634964577695856e+00 4.4706508799704379e+00 -2.4133549173203712e+00 + 11 2.5396723941201182e+00 -4.0685321809935306e+00 4.0718488306335860e+00 + 12 -7.4747296390755338e+00 -4.7547264901392232e+00 -1.1281779474673606e+00 + 19 -7.9694360631920147e-01 -1.9592570226038628e+00 1.4219890816089698e-01 + 21 3.2554493726424818e+00 1.5504934323383981e+00 -4.2708579190106590e+00 + 8 7.2611045847713540e-01 1.7131228100338296e+00 -3.3331152296001285e+00 + 29 -5.7282950316123102e+00 2.2415836508890341e+00 7.0497683071922301e-01 + 16 2.7354633120474716e+00 -2.3407336807728365e+00 5.3358536263062000e+00 + 17 4.9869793173076431e+00 3.9083882264254277e+00 -5.4224906421086958e+00 + 27 3.0511331655602310e+00 2.4720858701870370e+00 4.1037460797386682e+00 + 3 1.1146389047910072e+00 1.6614111600330044e+00 6.3676683357797126e-01 + 18 -2.7105387319483438e+00 1.6535632817769448e+00 4.1496667610600042e+00 + 24 3.3200955951465971e+00 -1.7481783651092901e+00 4.4668521639151102e+00 + 26 4.6497724052627754e-01 -1.6913221443008841e-01 4.8305258814543892e+00 + 1 -1.5284730763200560e-01 3.8172151545616444e+00 1.0168503497368047e+00 + 32 -4.1934052619705353e+00 1.7194593831848892e+00 6.6502210951020446e-01 + 36 -2.2106118606769889e+00 -4.8369962100390849e+00 -9.7003448295869238e-02 + 37 -2.6166970950140440e+00 1.4135010802769816e+00 -3.0340678569859412e+00 + 7 -6.3758260374982312e-01 -2.3667639719647178e+00 6.1040092602077376e+00 + 41 -7.2084862404026451e-02 -2.9650260148844225e+00 -2.4127376619876548e+00 + 45 -4.1384713174295387e+00 -7.5974289099124848e-01 -3.9591244072711658e+00 + 15 -4.2775888742681865e+00 6.1110208958154404e+00 -1.5100458656642235e+00 + 33 3.8213735815121259e+00 -2.1848089351257471e-01 3.3432772141767759e+00 + 44 6.3275778902329698e+00 -5.0939770334947871e+00 4.5763897463933872e-01 + 6 -1.3002483767759503e+00 3.2609218497599373e+00 2.9951811804056216e+00 + 49 -5.3442444185223668e+00 -6.5696776957306113e+00 -2.6938169215347401e+00 + 53 4.0594332740789065e+00 3.8197360168002352e+00 3.5791145156414172e+00 + 14 -1.8242975219825477e+00 4.5526371610706891e+00 2.2486039035720937e+00 + 23 5.4150041468607126e+00 5.4599185364061054e+00 1.2317227670371538e+00 + 40 5.5539742539208694e+00 -3.0418082466398668e+00 -2.6346955977236997e+00 + 57 3.9772214614364254e-01 1.5384162837095778e+00 -1.6369950577440897e+00 + 61 -3.5502280579768906e+00 3.3258701983012884e+00 -3.7671998220773366e+00 + 31 -3.1996908900709831e+00 2.3195381217864712e+00 8.6566113628298269e-01 + 48 4.1730804015628600e+00 -1.4946280976381667e+00 -1.0493118788579503e+00 + 22 -3.9165618778402647e+00 4.2015644461033368e+00 -3.9463232078906452e+00 + 52 7.0777723708333280e+00 -3.8863255903298635e+00 2.8138153005856772e+00 + 30 -3.9360783853958679e+00 -3.5028641752732259e-01 -1.3267719331100807e+00 + 56 1.6476459199502638e+00 -1.2042335461580564e+00 -2.1949195755180275e+00 + 60 -4.2696629551960559e+00 -5.9899085006017048e+00 -2.5963403311435469e+00 + 64 3.2550859360838498e+00 3.1655780052020859e+00 7.3556532516114617e+00 + 35 2.6355237132468980e+00 1.9438160231764634e+00 3.0017721230704257e+00 + 39 4.9170205683738795e+00 -7.8307417744462426e-01 -6.4967317836721463e+00 + 42 -7.1099091722193704e+00 -3.8728995854118531e+00 8.9607000802964587e-01 + 34 3.2964588414108604e+00 3.3438941542380940e-01 -7.8757625958516719e-01 + 43 1.2772926326457257e+00 -8.0641497847427779e+00 -1.1979253666748355e+00 + 47 4.0927190686131443e+00 2.1401263586348334e+00 3.2786419658628352e-01 + 38 -1.8547289832196194e+00 -2.4609883854951919e-01 1.3766128066510439e+00 + 51 -2.0065132608046610e+00 1.1092813896356506e+00 7.1705548128000354e+00 + 25 -3.6588034989779572e-01 -4.2215256641440879e-02 1.5494280204758231e+00 + 46 -1.5330720102669051e+00 -2.8494350562995168e+00 7.3277629112332159e+00 + 55 -3.7330754133589483e-01 -3.8341600886844747e+00 -4.4903045860606703e+00 + 59 4.1859078247719612e+00 3.5064680009939551e+00 -5.4012959814404340e+00 + 63 5.5106246291361662e+00 -4.8535178853780963e+00 2.8414203389183856e-01 + 20 -7.4044835455706952e+00 -1.8186532500230552e+00 5.0469677686815106e-01 + 50 -8.3761106934299523e-01 4.6845215172232324e+00 -1.6208825157871269e+00 + 54 2.5216730877332072e+00 -5.1013242579496811e+00 -3.6211737684524539e+00 + 58 5.4557851448320749e+00 1.5778525958322920e-01 6.3128743400146203e-01 + 62 -5.3282207309127703e+00 5.2572350908152350e+00 -3.5569650679978193e+00 + 28 -3.6412552800645570e-01 5.2968463937220012e+00 4.0851493007455932e+00 +... diff --git a/unittest/force-styles/tests/manybody-pair-sw.yaml b/unittest/force-styles/tests/manybody-pair-sw.yaml new file mode 100644 index 0000000000..be84136cac --- /dev/null +++ b/unittest/force-styles/tests/manybody-pair-sw.yaml @@ -0,0 +1,155 @@ +--- +lammps_version: 5 May 2020 +date_generated: Tue May 26 18:05:51 202 +epsilon: 1.0e-10 +prerequisites: ! | + pair sw +pre_commands: ! | + variable newton_pair delete + variable newton_pair index on +post_commands: ! "" +input_file: in.manybody +pair_style: sw +pair_coeff: ! | + * * Si.sw Si Si Si Si Si Si Si Si +extract: ! "" +natoms: 64 +init_vdwl: -253.88807485819 +init_coul: 0 +init_stress: ! |2- + 1.9118540952213486e+01 2.1487344330656981e+01 2.4127534372405634e+01 -5.5872970545726481e+00 2.8576061542049843e+01 2.3167027692912461e+00 +init_forces: ! |2 + 2 -2.2012126959422345e+00 -1.1674395514820977e+00 -2.0409253966352141e+00 + 4 -2.1730863931054798e+00 2.6470999567943232e+00 2.6530736444650627e-01 + 5 -2.1795201398674968e+00 -5.2862894636616309e-01 -4.4220837115760192e-02 + 9 -1.3917863765068916e-01 -3.1860306966625096e+00 -2.4976502566299721e+00 + 10 3.2661136661167689e-01 -2.4435691947441400e+00 -2.9236975475672526e+00 + 13 -1.3253834583890486e-01 5.8526641375852861e+00 -1.2802189182299966e+00 + 11 3.1777684778464184e+00 -4.1462965343243177e+00 3.0863081477663723e+00 + 12 -6.0496134337564902e+00 -3.4461224974370288e+00 -2.5561355562257173e+00 + 19 -1.4293416433082273e+00 -3.2920638730500946e+00 -2.1162930792192924e-01 + 21 2.5509339675670981e+00 1.6034607998324086e+00 -2.4910719026798258e+00 + 8 3.9693505044939936e-01 1.0383904089991995e+00 -1.4096721271899095e+00 + 29 -3.6857503897950035e+00 9.2008921192915205e-01 -1.7053321068933536e+00 + 16 2.1050947206645496e+00 -7.5548001439982260e-01 6.0896035642147446e+00 + 17 1.3316793665557460e+00 3.2487343583834329e+00 -4.3793729290845205e+00 + 27 2.5727851169091394e+00 -1.6513780199048494e-01 1.5050895680562455e+00 + 3 1.1365310213497786e+00 1.3235079669780000e-01 -1.1157161792909034e+00 + 18 -5.9836080309900230e-02 -1.0871278008406093e-02 3.8503817474278255e+00 + 24 2.1462048213078933e+00 1.0187461512825882e+00 3.2252214920594082e+00 + 26 -2.5855519346588568e-01 -8.2507158000960201e-01 1.6583552036737776e+00 + 1 -4.9759858191908357e-01 3.0132899418886696e+00 1.4626597969834461e+00 + 32 -3.4996734214894456e+00 5.9789553643186732e-01 -1.3324292421218065e+00 + 36 -5.5931834666694513e-01 -3.2877703010485568e+00 -1.6639212161259645e-01 + 37 -2.1170101895377043e+00 1.6013718715190235e+00 -2.5271126281981449e+00 + 7 -7.2573959247269626e-01 -6.1577190115659541e-01 3.7932319813367896e+00 + 41 1.1540285351177237e-01 -1.0442505554185544e+00 -1.0801691124687778e+00 + 45 -2.2820489403888167e+00 1.8390588536095125e+00 -3.0133435197495007e+00 + 15 -4.1176976037977822e+00 5.0722347380034272e+00 -2.2776790801747562e+00 + 33 4.8946561854485937e+00 -2.4906485249012258e+00 2.6473098236716419e+00 + 44 3.8065142778743177e+00 -4.2332050409203159e+00 1.3563788178869336e+00 + 6 2.2534513148347193e-01 4.2846407598820875e+00 1.6518912966127544e+00 + 49 -2.5421597810622600e+00 -5.0319699014364225e+00 -2.3158626223594272e+00 + 53 3.7063986578754848e+00 3.2327130174817733e+00 1.5170077617948714e+00 + 14 -1.9570126852477334e+00 4.3442152203636217e+00 6.8694493539047996e-01 + 23 2.2665580812512665e+00 4.3258528670981544e+00 7.5181204189712958e-01 + 40 4.5874254163344252e+00 -1.7279497437650073e+00 -2.1331000042201995e+00 + 57 5.1591413700843969e-02 -1.4959477587795542e+00 -3.2859812825677709e-01 + 61 -1.2022082250453627e+00 2.0033484575087286e+00 -1.1129947258865871e+00 + 31 -1.6414764879730310e+00 2.0999403150540563e+00 -1.7229963996853165e-01 + 48 1.5167389214359610e+00 1.5298376302494854e-01 -2.5789822138450769e-01 + 22 -5.2847499924860868e+00 3.7821899870787323e+00 -4.1599999640815097e+00 + 52 4.4568825198619075e+00 -4.9925441721854593e+00 4.0916380719303644e+00 + 30 -1.8703681971727510e+00 1.4632987736068577e+00 -1.0402849064755992e+00 + 56 -7.2509388705493671e-01 2.0980182696764693e-01 -2.3597031202891561e+00 + 60 -2.2261048972576827e+00 -5.3276704228148448e+00 -2.3921715797651211e+00 + 64 2.4085468400267187e+00 2.7768510607664063e+00 5.9581090618923707e+00 + 35 1.3032055627087158e+00 3.8403943629484671e-01 3.1141123114620917e+00 + 39 3.1058313099859638e+00 -8.0310743690776876e-01 -4.0942640725481132e+00 + 42 -4.2969157691678115e+00 -1.6957476003065532e+00 2.4950142664132319e-01 + 34 9.0722771997537544e-01 -2.1668062183309428e-01 1.8842969884425048e-01 + 43 1.2767133867545042e+00 -5.5416749827902763e+00 -3.5257265855141828e-01 + 47 3.0454001121814054e+00 1.9757624835275525e+00 5.8514958477196966e-01 + 38 -8.7674081362189127e-01 -6.0046008124086581e-01 7.2057333910448773e-01 + 51 -1.7404968253492392e+00 2.3501312602013202e+00 4.1884637955587687e+00 + 25 1.1344710322500451e+00 1.1258010279683456e-02 1.8540832301912331e+00 + 46 1.3781501178122724e-01 -1.6055850735054080e+00 5.2694173701659155e+00 + 55 7.1992217178180606e-01 -2.9209111351456829e+00 -4.4816418558494622e+00 + 59 2.7023417343228240e+00 2.2709171437546818e+00 -3.2675382157620834e+00 + 63 2.3993184954990650e+00 -4.9641865732173134e+00 7.9872123640002823e-01 + 20 -6.5567590523418353e+00 -1.7891715254231055e-01 1.1573322311653984e+00 + 50 -9.5860560342618562e-01 3.5380645482132058e+00 -1.7572780657432441e+00 + 54 2.8551869252715547e+00 -3.6219846088082841e+00 -2.1129359836955128e+00 + 58 3.2852612826352545e+00 -1.1319181957349169e+00 2.0369704414884007e+00 + 62 -4.0082699844093890e+00 3.5694473660939119e+00 -2.3808957458290636e+00 + 28 1.3413828777147767e+00 2.1347706927787753e+00 4.0128029376207142e+00 +run_vdwl: -256.9339545343 +run_coul: 0 +run_stress: ! |2- + 1.5843188889767147e+01 1.8190455024358112e+01 2.1264292235186090e+01 -4.9797000707308179e+00 2.3968698092935220e+01 4.5927517884771163e+00 +run_forces: ! |2 + 2 -2.0061314282044962e+00 -1.2342036121209603e+00 -1.8435586584208290e+00 + 4 -1.7939057674135981e+00 2.5853973948705740e+00 -1.7032829106267777e-01 + 5 -2.2298900111403315e+00 -5.7368723541200040e-01 1.2977296718837444e-01 + 9 -2.4778546531376899e-01 -3.1598266667047135e+00 -2.5133762395951935e+00 + 10 2.0709733990484658e-01 -2.3290781644694531e+00 -2.2033504477979786e+00 + 13 6.1771554329113421e-01 5.1787177857752020e+00 -1.0890335657342345e+00 + 11 2.4810243028980135e+00 -3.4670076585046847e+00 2.8449506084234351e+00 + 12 -5.5850741022851071e+00 -2.9458519910050196e+00 -1.9863683514918771e+00 + 19 -1.5617467469737576e+00 -3.2518255073259681e+00 -2.3399776509865969e-01 + 21 2.4628999326281860e+00 1.2003828959598268e+00 -2.6030925973177972e+00 + 8 2.1389899833254722e-01 8.5662191581321001e-01 -1.2599393085210657e+00 + 29 -3.4492415239428458e+00 8.7816348687363166e-01 -1.5440589307879455e+00 + 16 1.8355851588651364e+00 -7.4846780831918402e-01 5.1399376836143675e+00 + 17 1.1439347812520357e+00 3.0422446897805635e+00 -3.8269698610724152e+00 + 27 2.5175445907126783e+00 -2.7584155775939329e-01 1.4794898139727328e+00 + 3 6.8578843421788593e-01 3.5701803780915492e-01 -7.2036839894006266e-01 + 18 -4.2845652043234950e-01 2.3503246276020195e-01 3.6378973892810853e+00 + 24 2.4123142711193868e+00 5.8345976075870809e-01 2.7723427223632191e+00 + 26 -4.2283907151897460e-01 -5.8939802783631923e-01 1.7501899350192609e+00 + 1 -3.6578292548544633e-01 2.6938114020987980e+00 1.2766164846443697e+00 + 32 -3.1002249351374411e+00 3.9873970766007116e-01 -1.3229350360525922e+00 + 36 -9.0399762105375059e-01 -2.9542299588270713e+00 -4.8608322442561586e-01 + 37 -1.7936679156609205e+00 1.1708324245444257e+00 -2.4192322453710844e+00 + 7 -5.3211870778708503e-01 -3.3599884060011714e-01 3.2636486915192116e+00 + 41 3.8234199444261141e-01 -6.7698004720397631e-01 -7.8643727656003715e-01 + 45 -2.3979704626150959e+00 1.2492134071413807e+00 -2.6497899219205840e+00 + 15 -3.6850781851645982e+00 4.5087424623938048e+00 -1.7035374584642433e+00 + 33 4.1653455984867831e+00 -2.0178763996032387e+00 2.2661107852019544e+00 + 44 3.6592606723183030e+00 -3.9033932782274898e+00 9.1447594561944401e-01 + 6 6.7475363082984230e-01 3.9843096464691095e+00 1.7053127915353490e+00 + 49 -2.8190036224401576e+00 -4.9756598213987626e+00 -2.2985459069712935e+00 + 53 3.7802577750393231e+00 3.1818226509456742e+00 1.8978179329696754e+00 + 14 -2.0219351143209856e+00 4.0293679988620807e+00 6.6005920931527284e-01 + 23 2.3154132524078084e+00 4.2295354619246996e+00 7.0192774970576266e-01 + 40 4.5766245241245525e+00 -1.4835891243884769e+00 -2.0254579408390461e+00 + 57 -1.0278153825775276e-02 -1.7590547717218432e+00 -3.8050385157103833e-01 + 61 -1.1046837927728306e+00 2.0121688747133786e+00 -1.0262861972292612e+00 + 31 -1.4329726782504648e+00 2.0744956749854593e+00 -1.6136629766074723e-01 + 48 1.4791743756919560e+00 3.2930311672553897e-01 -3.3251232834027605e-01 + 22 -4.4520730716392176e+00 3.3117098541474856e+00 -3.5702683345712267e+00 + 52 3.9549296687811850e+00 -4.1670071205174999e+00 3.4176842915138534e+00 + 30 -1.5601654953771171e+00 1.0756173859838869e+00 -1.1556923853526757e+00 + 56 -7.0135086633206289e-01 -2.8264635141509542e-01 -2.0782448637476088e+00 + 60 -2.4007353452591169e+00 -4.9535087757235390e+00 -2.3369481395252585e+00 + 64 2.5369452958734855e+00 2.7290957114029144e+00 5.6584378752025701e+00 + 35 1.3703983500185393e+00 6.3751434723797462e-01 2.8982134075057688e+00 + 39 2.6747423965046568e+00 -6.1886552588225685e-01 -3.7752112134997056e+00 + 42 -4.0093916318806793e+00 -1.7600197455049928e+00 1.4158067768452562e-01 + 34 7.8962141897352622e-01 -1.7291813201580905e-01 2.1455734469338450e-01 + 43 1.0810851465046887e+00 -4.9037733502694021e+00 -5.6118074069955282e-01 + 47 2.8489632446318085e+00 1.6707606130329649e+00 5.6710506567185048e-01 + 38 -7.2035828994436901e-01 -4.6741417560464382e-01 8.2618393105671006e-01 + 51 -1.8835990999898564e+00 2.2102135960125726e+00 3.9823344470968713e+00 + 25 1.0367388664189889e+00 1.0505702244104692e-01 1.4930827689968442e+00 + 46 2.3716733588519823e-01 -1.4351351359916347e+00 5.0137864251962760e+00 + 55 3.0820341820502367e-01 -2.6771926047563457e+00 -3.8161188793303533e+00 + 59 2.5406360371694832e+00 2.2352821526100755e+00 -3.0033129814690653e+00 + 63 2.3143355745162886e+00 -4.8762705311639651e+00 6.8436817225651048e-01 + 20 -5.9022686658289807e+00 -4.4443599747613016e-01 9.5453010416851425e-01 + 50 -9.8083373394835083e-01 3.2894810840183051e+00 -1.8940705065580201e+00 + 54 2.4876677131729039e+00 -3.3806730320075102e+00 -1.7675616195950672e+00 + 58 3.2097378883129877e+00 -7.2897169480175061e-01 1.6182800942864837e+00 + 62 -3.6496637512835903e+00 3.1293667187055498e+00 -2.0518216022328217e+00 + 28 1.1510771716913335e+00 2.3773229001009710e+00 3.6868660521242318e+00 +... diff --git a/unittest/force-styles/tests/manybody-pair-tersoff.yaml b/unittest/force-styles/tests/manybody-pair-tersoff.yaml new file mode 100644 index 0000000000..c8e5541331 --- /dev/null +++ b/unittest/force-styles/tests/manybody-pair-tersoff.yaml @@ -0,0 +1,155 @@ +--- +lammps_version: 5 May 2020 +date_generated: Tue May 26 18:05:25 202 +epsilon: 5.0e-13 +prerequisites: ! | + pair tersoff +pre_commands: ! | + variable newton_pair delete + variable newton_pair index on +post_commands: ! "" +input_file: in.manybody +pair_style: tersoff +pair_coeff: ! | + * * SiC.tersoff Si Si Si Si C C C C +extract: ! "" +natoms: 64 +init_vdwl: -163.150573313048 +init_coul: 0 +init_stress: ! |- + -5.4897530176832697e+02 -5.4663450719170669e+02 -5.6139257517016426e+02 -1.4199304590474418e+01 -1.3994570965097115e+01 5.4389605871425246e+01 +init_forces: ! |2 + 2 2.9602498712671452e+00 -1.0588320544842651e+01 1.1519772530615358e+00 + 5 4.1945116087801502e+00 4.0211675202040693e+00 6.4807220477828054e+00 + 4 7.6414578298653435e-01 4.0213523942979013e-01 9.4797175075936373e+00 + 9 -1.3829126879378810e+01 3.3400779631917277e-01 8.3332691135051706e-01 + 11 2.7312864224296671e+00 4.0287946263367500e+00 8.9204658499239251e+00 + 13 -1.5858309992357273e+00 -2.3812819396093934e+00 1.2460555338797787e+00 + 8 -3.4780857052968415e+00 -4.5196373264239198e-01 -3.4348484485387509e-01 + 27 3.1192079889978230e+00 -6.5362208060545628e+00 1.2268964071865918e+00 + 12 7.8751891700625904e+00 -7.7186307214801797e+00 -5.2791439019701114e+00 + 16 -7.2727057172127685e+00 6.4043826683606628e+00 3.5171698455744105e+00 + 17 9.5539951969070547e+00 2.6379654076395345e+00 5.0065343169077945e+00 + 18 -3.9214285985710289e+00 -3.3891469739812172e+00 3.2978277630465125e+00 + 21 -3.2053627402696465e+00 -9.8463742292726408e+00 1.2907611413251274e+00 + 19 5.2752276712922141e-01 -5.0346196994826009e+00 -7.2649963109726121e+00 + 29 3.6213632449475486e+00 7.9953345033105618e+00 -2.4577107962677385e+00 + 24 4.1068542205309111e+00 7.3847751157925199e+00 2.2530249788791874e+00 + 26 9.6130868394163904e-01 4.2613891391897135e-01 -6.2159492546416457e+00 + 1 -8.1912892931149894e+00 7.5887354282236608e-01 -1.2625078865710950e+00 + 32 7.4385441920429161e+00 4.0458707919489969e+00 -3.4391127020935182e+00 + 7 -4.5091473605325696e+00 -7.7672528121795326e+00 -5.4811778043718888e+00 + 15 -4.3326311771962445e-02 -6.0170386352470562e-01 -1.0129825989425537e+01 + 33 -7.6856588792542304e+00 -5.2818796645272048e+00 4.5261033372808726e+00 + 6 6.6450126498528483e+00 -3.3655099236048991e+00 2.4183675473801021e+00 + 10 -4.6448721480660096e+00 2.1918975237587448e+00 -4.2071718234681317e+00 + 14 6.2686278379542264e+00 2.5996877962621214e+00 -7.3065539727817423e+00 + 44 9.0533839182766673e-01 3.1947228611599816e+00 1.2778052286326369e+01 + 49 -5.5873879559778343e+00 7.7963293184336617e+00 -5.6221041743396887e+00 + 23 7.0209510094956986e+00 -8.2134652397570367e+00 4.8499600596081835e+00 + 31 7.3989572826939201e+00 -4.1718610802469280e+00 -8.0314138211966313e-01 + 3 1.9949098978773105e-01 3.3201790603073089e+00 -1.2360541799328186e+00 + 22 7.4683659037949859e+00 5.0663391168235794e+00 -7.7210795150894302e+00 + 30 9.3099853021452930e+00 -4.1372759628053686e+00 2.4543788703785023e+00 + 60 -6.2782603157083186e+00 8.1725418209406957e+00 -4.4584633713007520e+00 + 35 -2.0808410967907274e+00 -1.0280592113229023e+01 5.1428946976574741e-01 + 37 -2.2686352055426395e+00 2.1331123333755340e+00 5.6453425235790373e+00 + 41 -5.9529127476328636e-01 2.1159296355895192e+00 8.6146423556989973e+00 + 45 -7.2126726281236007e+00 4.8416302234272584e+00 -4.7112146424964925e+00 + 36 -8.8183779521306405e-01 9.8684615667595459e+00 -4.8109031519057527e-01 + 40 -2.3301691419577937e+00 -3.2758785270630066e+00 -5.7819201702562930e+00 + 42 5.9189513497850648e+00 -2.5092333558200637e+00 -5.1879957283630036e+00 + 48 -9.3992570471024575e+00 -7.2012852783004933e+00 5.3036194512231303e+00 + 53 3.0404706830256303e+00 1.2330889276234737e-01 1.0538693274614536e+01 + 51 -1.0615369098452508e+01 -1.1947069593051742e+00 -2.4754931735718033e+00 + 57 -3.9059207579783326e+00 1.0936390766210906e+01 2.4937931794373531e+00 + 61 -2.3223903213770005e+00 -1.3559332411250972e+01 2.2972608899644109e-01 + 52 -1.0276441993468604e+00 1.2386128581162801e+00 2.7418262118600261e+00 + 56 -8.4664025172925417e-01 4.2930578794119461e+00 2.5997052919321426e+00 + 58 -9.2443531485287878e+00 -2.8306427796695184e+00 4.3004542463117321e+00 + 64 5.1027628612149876e+00 5.3292269345077372e+00 -8.7272297575101980e+00 + 39 6.2802359097693028e+00 -4.4534617586305956e+00 8.8595185494148723e+00 + 43 -3.9541467863883950e-01 1.7167882940314338e+00 1.2472048975129875e+00 + 47 4.7420508215326551e-01 2.6438079361177045e+00 9.3458736364390571e+00 + 38 -3.1134845125038391e-01 5.3227665374006232e+00 -2.1683540213154733e+00 + 25 -3.9317998834815548e+00 -2.5156019711898603e+00 -7.5848748129221573e+00 + 46 -7.1816028879383049e+00 6.7619490219881930e+00 3.7606013072495070e+00 + 59 6.4468827293851163e+00 6.7385166803754615e+00 -8.2413070730835223e+00 + 34 1.4341383089365500e-02 1.9309480517379565e+00 -5.5943902542352966e+00 + 50 6.8601963794059770e+00 -2.4660866715270968e+00 -1.6122667028154534e+00 + 55 1.1299172592074738e+01 7.6545677558556874e-02 -3.9336839343099766e-01 + 28 -6.0381257391328775e+00 -5.1923165377355414e+00 2.9595508172547853e+00 + 63 -6.1967102136017562e+00 -4.9695212866018759e+00 -5.2998409387882619e+00 + 54 2.1362122614980152e+00 3.4829232055967774e+00 -1.0358441996855289e+01 + 20 3.3539383489473220e+00 -3.4277977518290026e-01 5.8115196917869794e-01 + 62 3.0202286274163948e+00 -5.8173499219835723e-02 3.7893096308014718e-01 +run_vdwl: -178.057797644483 +run_coul: 0 +run_stress: ! |- + -5.1394876000526904e+02 -5.0846789891891115e+02 -5.2011743811579913e+02 -8.7897109075449080e+00 5.6462282276932196e+00 4.7065631120726231e+01 +run_forces: ! |2 + 2 2.3998549960918485e+00 -1.1947673981292548e+01 1.7252161658738601e+00 + 5 3.5224788421144408e+00 4.8564117258168524e+00 9.6179393026613287e+00 + 4 3.3347810373798397e+00 1.0397364810786498e+00 8.4324583903881276e+00 + 9 -1.1549807405176985e+01 3.3343530555806744e-01 8.9829078829569753e-01 + 11 4.4274091610325623e+00 5.6792150201161649e+00 9.4332862837992906e+00 + 13 -2.3188614153697360e+00 -1.3290385649650782e+00 2.0742500235150465e+00 + 8 -3.3580419547204547e+00 -2.4465646973981237e-03 -1.3620840979996087e+00 + 27 3.7275438839555903e+00 -5.2709882923928619e+00 4.4767818672353638e-01 + 12 6.1014707687900591e+00 -4.8029860875184038e+00 -3.0355893912254222e+00 + 16 -6.7644759933493575e+00 5.9161982066335010e+00 2.8177782766175898e+00 + 17 8.5459718690297741e+00 1.6413604267406297e+00 3.9669710341314848e+00 + 18 -4.8222944210892980e+00 -4.3708893934198123e+00 3.4937679750767012e+00 + 21 -2.7659124274397215e+00 -8.6441488913101203e+00 1.5812554115164845e+00 + 19 2.2265410166640107e+00 -2.8737227736329869e+00 -7.8165866581232937e+00 + 29 1.5236376013573949e-01 7.2360376297632625e+00 2.2791470343821976e+00 + 24 1.2066504210681979e+00 8.3472697578316577e+00 3.1725449496368388e+00 + 26 2.5713462215706637e+00 -2.5408054310756762e+00 -7.0385969034077789e+00 + 1 -9.2566080668166677e+00 1.0077345660602521e+00 -4.8027837358053862e+00 + 32 6.2466835697011049e+00 2.4999913007009900e+00 -2.1641083204656102e+00 + 7 -1.8091201412671638e+00 -4.6871967323166972e+00 -7.9984696770011308e+00 + 15 -3.5894172212591169e-01 -6.1865516691859401e-01 -1.2154453860523191e+01 + 33 -5.9880400237419984e+00 -2.7478960497717777e+00 2.8138571408519608e+00 + 6 4.5275612875996325e+00 -4.9223113798304370e+00 3.3528199373209628e+00 + 10 -5.5043570494496645e+00 -2.4520581125354686e+00 -1.9605063597984129e+00 + 14 5.1178558951892512e+00 1.6515628496884578e+00 -6.0532912801239496e+00 + 44 -9.4956239475653748e-01 8.2546724916137393e-01 1.2487370224632080e+01 + 49 -3.2036171757340735e+00 5.5662326854851774e+00 -2.7617497737709584e+00 + 23 7.8425232176598900e+00 -8.4405335083437265e+00 5.6779106583756898e+00 + 31 5.6883462483239162e+00 -9.6340434155968691e-01 -4.2245906553646080e+00 + 3 1.7761214518867432e+00 1.9053879815768173e+00 -2.2724172317028390e+00 + 22 7.8148663646910199e+00 5.0038212586600528e+00 -7.0422848225097265e+00 + 30 7.0114818183698757e+00 -1.8786174880505371e+00 1.4572736275096392e+00 + 60 -3.9127580559710342e+00 5.8663680661648741e+00 -2.1774465911788097e+00 + 35 -3.5060328052736081e+00 -9.0237104049998660e+00 1.1770665190158094e+00 + 37 -5.5405600851398740e+00 4.3460948419738035e+00 8.5790385451499276e+00 + 41 -2.6751556738427134e+00 1.0538495035185869e-01 9.7388926801719631e+00 + 45 -4.4331091299885044e+00 5.2116640750108694e+00 -6.2695747729220717e+00 + 36 -2.5246589184542718e+00 7.0663241830147019e+00 -3.1349368626458713e+00 + 40 -2.6474814456519438e+00 -9.6098953161179135e-01 -1.8111368068890648e+00 + 42 5.5610935834238182e+00 -2.2468129145203859e+00 -3.4123429349506615e+00 + 48 -6.9517337938680814e+00 -7.2112413993202038e+00 7.6606470174297794e+00 + 53 3.5580034191029153e+00 -5.2224354079849489e-01 9.3830808810249469e+00 + 51 -1.0745375893597979e+01 -2.1284285048684288e+00 -1.3329596168537496e+00 + 57 -2.3065086458088020e+00 1.2871947065650650e+01 9.0847850193887925e-01 + 61 -4.1017669917956683e+00 -1.2643475167127736e+01 -2.5183998149672018e+00 + 52 -2.6515821662669508e+00 -7.3145571997004305e-02 1.1061901267020042e+00 + 56 4.5355647349403094e+00 5.0851906158415590e+00 2.1898774836355059e+00 + 58 -9.7296598489860848e+00 -1.6561484398383972e+00 3.4072771607410308e+00 + 64 3.3020302368588315e+00 3.1627875726160184e+00 -6.8660451794450079e+00 + 39 5.4184170996144356e+00 -3.4406019213299284e+00 8.6553990435256001e+00 + 43 -9.3679194990337122e-01 9.9722489594945496e-01 1.7818305269282892e+00 + 47 1.9858560179863964e+00 -1.4852584443949506e+00 8.4274294453710148e+00 + 38 -1.3910460017782382e+00 6.8645671813956781e+00 -4.4200912343413501e+00 + 25 -3.6623885665286662e+00 -4.1813768417007040e+00 -7.2968160676754019e+00 + 46 -7.3320374431776933e+00 6.8971611306068921e+00 3.8963698210690194e+00 + 59 6.8712340624705277e+00 4.5941242868785981e+00 -6.5895961456756549e+00 + 34 2.5647931350902438e+00 1.8617472141965041e+00 -9.7172893728458796e+00 + 50 4.3053470939466232e+00 -2.3640368532431211e+00 7.4208386122303893e-01 + 55 1.0034709237186064e+01 1.0234440983477382e+00 -8.8643705191119926e-01 + 28 -3.4150646959468727e+00 -2.3852176188882792e+00 -5.0237355808061657e-02 + 63 -3.7332705534580439e+00 -3.4101641368095517e+00 -6.2778934997510385e+00 + 54 1.6688835294759237e+00 2.6487460256538875e+00 -1.0427244374266991e+01 + 20 3.2796797669756979e+00 -5.3191473664348798e-01 7.7821286289553404e-01 + 62 3.5191591081500224e+00 6.4550013919915683e-01 -2.8572943818092944e-01 +... diff --git a/unittest/force-styles/tests/manybody-pair-tersoff_mod.yaml b/unittest/force-styles/tests/manybody-pair-tersoff_mod.yaml new file mode 100644 index 0000000000..ae9970c15d --- /dev/null +++ b/unittest/force-styles/tests/manybody-pair-tersoff_mod.yaml @@ -0,0 +1,155 @@ +--- +lammps_version: 5 May 2020 +date_generated: Wed May 27 10:27:56 202 +epsilon: 1e-12 +prerequisites: ! | + pair tersoff/mod +pre_commands: ! | + variable newton_pair delete + variable newton_pair index on +post_commands: ! "" +input_file: in.manybody +pair_style: tersoff/mod +pair_coeff: ! | + * * Si.tersoff.mod Si Si Si Si Si Si Si Si +extract: ! "" +natoms: 64 +init_vdwl: -271.724273648021 +init_coul: 0 +init_stress: ! |2- + 4.5327307609410205e+01 4.8520624491107604e+01 4.9902937603449253e+01 -9.5506101395831298e+00 3.2604807162960689e+01 3.7958926469664576e+00 +init_forces: ! |2 + 2 -2.0954555386253175e+00 -1.7654085262330996e+00 -1.8532577270904687e+00 + 5 -2.2339471154402837e+00 -4.0007755923806543e-01 1.2555572333857423e-01 + 4 -2.5214919613545850e+00 3.0505938787742286e+00 8.5556867413215443e-01 + 9 -6.9326758274324463e-01 -2.8733710553178735e+00 -2.4740438488877459e+00 + 11 3.7082399304089573e+00 -4.4335060560642923e+00 3.5780289702018742e+00 + 13 -1.0545105917528061e+00 5.9534933227328537e+00 -1.2541339268562639e+00 + 8 3.0016862396459665e-01 9.5380838768747189e-01 -1.3651064654046985e+00 + 27 2.9093832181966754e+00 -5.2366747707677330e-01 1.7866950461283688e+00 + 12 -6.2207601922482070e+00 -4.2728239828918628e+00 -3.8672463790561697e+00 + 16 2.0376392283211429e+00 4.1379151497049238e-02 7.3383531261943142e+00 + 17 2.5868961445484078e+00 3.3855091049241492e+00 -4.3525116836709090e+00 + 18 -2.0691760334270426e-01 1.1174781095513309e-01 3.9956653276596352e+00 + 21 1.9661997284095161e+00 5.8407645448956558e-01 -2.1403769815463689e+00 + 19 -1.7181968595197383e+00 -3.2977071933364361e+00 -6.7298506096511712e-01 + 29 -3.7917232870403828e+00 1.3473159628039733e+00 -1.9274546986124070e+00 + 24 2.5151508371365803e+00 1.4617337639339523e+00 3.4414267080105279e+00 + 26 5.9916481607206099e-02 -5.7366071373394834e-01 1.3123953222317672e+00 + 1 -1.1892795399502762e+00 3.4257359265649283e+00 1.7874368716815203e+00 + 32 -3.2712791280387576e+00 7.1096851908456316e-01 -1.2734746552927405e+00 + 7 -8.6448706557168009e-01 -9.4197647582959165e-01 3.4802822970950045e+00 + 15 -4.3678587432815448e+00 5.2039733154082759e+00 -3.8907877292288418e+00 + 33 5.2911245069099460e+00 -3.4010540959332545e+00 3.6524180132002586e+00 + 6 6.9406481651349483e-01 4.0779990387340961e+00 1.5289132846276394e+00 + 10 4.6147807167257193e-02 -2.2738498964512495e+00 -3.1717588361770175e+00 + 14 -1.9555282724792578e+00 4.9515688839071048e+00 7.5550610196808976e-02 + 44 3.7094881869229743e+00 -4.0305786490774889e+00 2.4402506192353060e+00 + 49 -3.1588233852954701e+00 -5.4636934937363648e+00 -3.0409687849567568e+00 + 23 2.1953645827992441e+00 3.8674084242261273e+00 1.6173483594542475e+00 + 31 -1.3151578459616253e+00 1.8871395994432212e+00 -2.7011060864608871e-01 + 3 1.1876001464899757e+00 1.9242256463464447e-02 -9.0670530051980980e-01 + 22 -6.4806179729927962e+00 5.2609892436594707e+00 -5.8464202950859878e+00 + 30 -1.6130847767696728e+00 1.3894366643496951e+00 -1.0830830302555146e+00 + 60 -3.3457486474429414e+00 -5.8722985930097442e+00 -3.2731439760160956e+00 + 35 1.4066245523460819e+00 2.6509737902065122e-02 3.3189083125822232e+00 + 37 -2.1879917887538411e+00 1.8340593401715548e+00 -2.5952825292852095e+00 + 41 -2.2964879304419927e-02 -9.5684782238783939e-01 -8.4045745865603538e-01 + 45 -2.5415464668779046e+00 2.3561442767971252e+00 -3.3698756670727792e+00 + 36 -5.9348529189884680e-01 -3.0775310512793967e+00 7.3726020443943635e-02 + 40 5.0170678274997247e+00 -2.4371237670262524e+00 -2.7953264349333442e+00 + 42 -3.7325596565462327e+00 -1.4944324070127961e+00 -6.6156987915423582e-01 + 48 1.1757816284297755e+00 -8.0697689137480266e-02 -2.5399512834746130e-01 + 53 4.3349543609042716e+00 3.8955013047694798e+00 2.4358913852148913e+00 + 51 -2.7543054752091045e+00 2.8286849763020028e+00 4.2904949083466351e+00 + 57 1.4923040822361899e-03 -1.2901024427293186e+00 -1.9986655014236149e-01 + 61 -1.2066779913281913e+00 1.8517791870265143e+00 -1.1888511310265368e+00 + 52 5.8417676659988604e+00 -6.1620383217354462e+00 5.8373190892393598e+00 + 56 -7.2812157006377631e-01 2.7705521432161806e-01 -2.4526401278051884e+00 + 58 2.8839232710488920e+00 -1.4968148916784054e+00 1.9674510279452671e+00 + 64 3.5261103084670364e+00 3.7869432645771459e+00 5.8249511151439197e+00 + 39 3.1966416370423714e+00 -1.7900106360847508e+00 -3.8176153923506142e+00 + 43 8.2163161790382777e-01 -5.6551284520222911e+00 3.5034152559291865e-01 + 47 3.2198087191803304e+00 2.1050004196645213e+00 1.1081985447058491e+00 + 38 -8.4063356882763873e-01 -5.1045205546434858e-01 7.5648910376227496e-01 + 25 1.0523978389374937e+00 -5.2326428640524392e-02 1.5897502115131033e+00 + 46 -8.0311065526091541e-01 -1.8070192617844101e+00 5.9279212669666430e+00 + 59 3.7290396548099460e+00 2.9236672921889606e+00 -3.5739265191731291e+00 + 34 7.9555324781102965e-01 -1.0583159648069751e-01 1.3094669311144647e-01 + 50 -2.7634926151772410e-01 3.1171696810177565e+00 -1.2591746592873663e+00 + 55 1.7020114280700853e+00 -3.1207712150229088e+00 -4.5927309465946955e+00 + 28 8.9638119308977648e-01 1.9996170391979944e+00 4.7622873174925884e+00 + 63 2.2829467996296287e+00 -4.8025431165588612e+00 -4.2319407270880705e-01 + 54 3.1961654886581594e+00 -3.9231725683375429e+00 -2.8101612958752127e+00 + 20 -6.6869704016886153e+00 6.5629477674615799e-01 8.5744900543906888e-01 + 62 -3.8148306661769906e+00 3.5439712709911046e+00 -2.7497767002061515e+00 +run_vdwl: -275.301478992035 +run_coul: 0 +run_stress: ! |2- + 3.7648596612475586e+01 4.0392775754357999e+01 4.2450922933587087e+01 -6.7686158075529761e+00 2.6503184957410216e+01 6.7047212014675468e+00 +run_forces: ! |2 + 2 -1.9845814788855547e+00 -1.6963202395628771e+00 -1.7539340797352434e+00 + 5 -2.2866392379727172e+00 -4.7845815808353476e-01 2.8723762953259424e-01 + 4 -1.9750433429758454e+00 2.8108734691215282e+00 2.5558748773433981e-01 + 9 -7.8055739111326838e-01 -2.9617708332130066e+00 -2.5154646427817955e+00 + 11 2.7717216440585446e+00 -3.5945289811506926e+00 3.0102532273647937e+00 + 13 -3.5871963818307803e-02 5.1413632456916005e+00 -7.2849611074393339e-01 + 8 1.1276934750002487e-01 8.0819324031726825e-01 -1.2597707785775791e+00 + 27 2.7870666357683986e+00 -5.0716047432483646e-01 1.7077565068755518e+00 + 12 -5.4937773786261612e+00 -3.3296255424806929e+00 -2.9047226121830310e+00 + 16 1.7870712086580398e+00 -3.1786706739718235e-01 5.9419000924923147e+00 + 17 2.1141670976353346e+00 3.0622487965900937e+00 -3.6979864228899375e+00 + 18 -6.5287327278710539e-01 4.2233991595116249e-01 3.8077283403591333e+00 + 21 2.0367776573932010e+00 3.2353455052636448e-01 -2.3391497908222498e+00 + 19 -1.7825043678972610e+00 -3.2484299399093142e+00 -6.5730511593208751e-01 + 29 -3.5916678116084531e+00 1.1678602836540846e+00 -1.7379682157150091e+00 + 24 2.6829720270132977e+00 9.5208819336551964e-01 2.9131618406393676e+00 + 26 -8.1420135505578792e-02 -3.7800027508766199e-01 1.3992952453256409e+00 + 1 -8.6494553949113606e-01 2.9723558371616852e+00 1.4612300089162402e+00 + 32 -2.9014808575985596e+00 5.0853545112312659e-01 -1.2089730389798246e+00 + 7 -5.8290348209558207e-01 -5.4259350500699011e-01 3.0320327455855125e+00 + 15 -3.6750263422474276e+00 4.3818614117260202e+00 -2.8514923985486029e+00 + 33 4.3874388530111021e+00 -2.5897571121334155e+00 2.7688741069572336e+00 + 6 1.0571916979749698e+00 3.8102334133881302e+00 1.6922864641606938e+00 + 10 3.1166854744505368e-02 -2.2688125147274176e+00 -2.3982322066311199e+00 + 14 -2.0085952441815622e+00 4.4192308092747723e+00 1.7254612827329116e-01 + 44 3.4424067082774608e+00 -3.6458431164550218e+00 1.7989897372666217e+00 + 49 -3.2179925611273097e+00 -5.3897109528177793e+00 -2.9848233906282324e+00 + 23 2.1878137890758995e+00 3.8081812141573153e+00 1.5447266637121240e+00 + 31 -1.1879426277484932e+00 1.9083391337509910e+00 -2.4658803119449613e-01 + 3 7.5053913245740167e-01 2.8615760532766732e-01 -6.0978040710802206e-01 + 22 -5.1283230533645128e+00 4.2073579667546008e+00 -4.5303477801183796e+00 + 30 -1.3525353106049680e+00 1.0418770131892268e+00 -1.1231091152147039e+00 + 60 -3.2821645847621683e+00 -5.3370261921599447e+00 -3.0200568539595380e+00 + 35 1.3875337186072136e+00 3.5684097931366532e-01 3.0067462591936374e+00 + 37 -1.8304884054052768e+00 1.3533089100273676e+00 -2.3943952988569928e+00 + 41 2.3329293508714910e-01 -6.5236854772015218e-01 -6.3288790137225348e-01 + 45 -2.5337896763591088e+00 1.6080565205257269e+00 -2.8885218244909838e+00 + 36 -1.0126806506030355e+00 -2.8248663655987860e+00 -3.3658562392334768e-01 + 40 4.9128963636802077e+00 -2.0433231305774040e+00 -2.5381030557498074e+00 + 42 -3.5858411933352810e+00 -1.6060523138739158e+00 -6.5085586098421877e-01 + 48 1.1531569725136972e+00 1.0584511035501354e-01 -2.6324814802482294e-01 + 53 4.2543548717694097e+00 3.7982801895545246e+00 2.6629735677036144e+00 + 51 -2.6625024594691196e+00 2.6035179492511236e+00 4.0503804230479039e+00 + 57 -3.9975307244232983e-02 -1.5340530158525147e+00 -2.5806622970318549e-01 + 61 -1.0900772054127172e+00 1.8693889679020239e+00 -1.1038292115987847e+00 + 52 4.7123880350175407e+00 -4.8793528658480181e+00 4.4034891887836318e+00 + 56 -6.0555550366134159e-01 -2.6412431710414541e-01 -2.0828450845443385e+00 + 58 2.8251586977789254e+00 -9.9456549595935806e-01 1.4900284243066526e+00 + 64 3.3693961200184583e+00 3.5427020966737439e+00 5.4708241924527599e+00 + 39 2.7047865085605665e+00 -1.2845807744438225e+00 -3.4345054112485691e+00 + 43 6.3821363094632366e-01 -4.8854069787762402e+00 1.0211205553915415e-02 + 47 3.0567570449946135e+00 1.7467987759397205e+00 9.3466868808377912e-01 + 38 -7.3772928279941330e-01 -4.1206466474823134e-01 8.1055291957532338e-01 + 25 9.9066935306998383e-01 7.2437726480663378e-02 1.3350031099311763e+00 + 46 -4.2853467463581274e-01 -1.4780448471152405e+00 5.5699892454382480e+00 + 59 3.3267083734120622e+00 2.6722437793685465e+00 -3.2265576515575320e+00 + 34 7.0797438096177989e-01 -7.3365476838379795e-02 1.5222575287138618e-01 + 50 -2.7853337957895841e-01 2.9097717579818072e+00 -1.4137445645426245e+00 + 55 9.6254861475545161e-01 -2.6805899881839550e+00 -3.7502045244401114e+00 + 28 7.5588400802775713e-01 2.3309525558710038e+00 4.2272028065549829e+00 + 63 2.1942936363061740e+00 -4.7135611317994410e+00 -3.4789973397550722e-01 + 54 2.7053985262594291e+00 -3.5967294897899285e+00 -2.2499455897230054e+00 + 20 -5.8899125313851677e+00 1.4239019516227858e-01 5.7788343738746750e-01 + 62 -3.4780481910334862e+00 3.0637872432615314e+00 -2.3553887395800706e+00 +... diff --git a/unittest/force-styles/tests/manybody-pair-tersoff_mod_c.yaml b/unittest/force-styles/tests/manybody-pair-tersoff_mod_c.yaml new file mode 100644 index 0000000000..871e7b88da --- /dev/null +++ b/unittest/force-styles/tests/manybody-pair-tersoff_mod_c.yaml @@ -0,0 +1,155 @@ +--- +lammps_version: 5 May 2020 +date_generated: Wed May 27 10:28:17 202 +epsilon: 5e-13 +prerequisites: ! | + pair tersoff/mod/c +pre_commands: ! | + variable newton_pair delete + variable newton_pair index on +post_commands: ! "" +input_file: in.manybody +pair_style: tersoff/mod/c +pair_coeff: ! | + * * Si.tersoff.modc Si Si Si Si Si Si Si Si +extract: ! "" +natoms: 64 +init_vdwl: -270.221167046491 +init_coul: 0 +init_stress: ! |2- + 3.7721371080158519e+01 4.0406255097836009e+01 4.5487367411373484e+01 -4.8266606949369901e+00 4.8727889805432568e+01 1.1408515692636302e+01 +init_forces: ! |2 + 2 -2.6231172245796350e+00 -1.1364993928076723e+00 -2.3817153144708119e+00 + 5 -2.1612651325906471e+00 -4.9869587691769302e-01 1.7250163832481702e-01 + 4 -2.9108777089667255e+00 3.4825750603217136e+00 1.2609281774155390e+00 + 9 -8.3063920816990322e-02 -3.7423608933633652e+00 -3.2160720450535623e+00 + 11 4.1864404556275057e+00 -4.8481896851463224e+00 3.8312060479472567e+00 + 13 1.9646495165853503e-01 7.9861477095384776e+00 -2.7367062033436418e+00 + 8 3.5140079778346966e-01 9.6087816332530318e-01 -1.2820504415972398e+00 + 27 2.8896757936606288e+00 -2.5598906474617455e-01 1.6995818028265111e+00 + 12 -9.6713935862591818e+00 -6.6227112990242984e+00 -4.6446377068123139e+00 + 16 3.2825165212935894e+00 1.4503238718907385e-01 9.9619494807553099e+00 + 17 1.8077787360512412e+00 5.6235488307785566e+00 -6.6752189747857935e+00 + 18 -2.9067694818601864e-01 7.0277766073193071e-01 4.3645591263313168e+00 + 21 4.0755651659561503e+00 2.5055927550712744e+00 -3.9295891445176494e+00 + 19 -1.7799419254476889e+00 -3.2770446346967073e+00 -8.1006577744305008e-01 + 29 -3.7884290849364386e+00 1.1944698204128446e+00 -1.8602750345964847e+00 + 24 2.7497519642890418e+00 1.7304732457306626e+00 3.6549891820852740e+00 + 26 -7.0481851150491104e-01 -1.3637381624788669e+00 2.0613502828213091e+00 + 1 -1.1121702900549253e+00 3.2962355779814700e+00 1.7214327613339293e+00 + 32 -3.2907053780286306e+00 6.2378355508109218e-01 -1.2902338668409254e+00 + 7 -7.2171003353241292e-01 -8.7428867981606628e-01 3.1938058862406162e+00 + 15 -7.2775531579340491e+00 8.3478926291447397e+00 -3.2404980553662845e+00 + 33 6.9062659492175591e+00 -4.6716700051867610e+00 4.5297058615592185e+00 + 6 6.2541430916574392e-01 4.1094941300847427e+00 1.7170100483649258e+00 + 10 -3.1901729169774407e-02 -2.3415669618762114e+00 -3.0883299406012168e+00 + 14 -2.7684114622587317e+00 5.5939194639363317e+00 -4.0547714650260891e-01 + 44 6.3180364208751865e+00 -6.7411789158583639e+00 1.1116278345350947e+00 + 49 -3.4072597072209669e+00 -6.1070390605333742e+00 -3.5306063249176431e+00 + 23 2.5236349600547641e+00 5.0871858657739679e+00 1.6016380934443952e+00 + 31 -1.4835767031477887e+00 2.1960643033804708e+00 9.3118779237245430e-02 + 3 1.2454687790439651e+00 -2.0768859787664962e-02 -9.0044014975037079e-01 + 22 -8.4726851156999654e+00 6.8585462938413606e+00 -7.2078210589983769e+00 + 30 -1.5649995972155133e+00 1.3796901248411295e+00 -1.0422790561923814e+00 + 60 -5.2081470599725392e+00 -8.3618639601252767e+00 -5.4019706110934393e+00 + 35 1.3870533247216423e+00 2.2599941992339145e-01 3.1691771352499218e+00 + 37 -2.2156632667821259e+00 1.5777720928381880e+00 -2.5373496014392680e+00 + 41 -1.5543959327638301e-02 -9.9903820196554505e-01 -7.7550537312763934e-01 + 45 -2.7247244318737365e+00 2.5615735720407926e+00 -3.7075812268108588e+00 + 36 -7.2485340203448956e-01 -2.9468050589090384e+00 1.5881949315158159e-01 + 40 5.1068862232776402e+00 -2.6572250807869788e+00 -3.0350555471127509e+00 + 42 -5.8719118783583797e+00 -3.2250092618452633e+00 7.4849260312585963e-01 + 48 1.2590145861274618e+00 -5.9135053727527920e-02 -4.0063540451436003e-01 + 53 4.8598008110851412e+00 4.5281870222367191e+00 2.4268297257522375e+00 + 51 -2.3733120960180147e+00 3.4165620256287563e+00 5.0660386533198327e+00 + 57 1.9063253744204015e-01 -1.3950288071553631e+00 -1.8130645334635304e-01 + 61 -8.8016078852763746e-01 2.1182748970403305e+00 -1.4653540228996813e+00 + 52 7.4960119597573005e+00 -7.9932429491872048e+00 7.3092067723825780e+00 + 56 -8.2057128294593273e-01 8.9531331465382280e-03 -2.4950139723745406e+00 + 58 2.7864038109729163e+00 -1.4751542377211930e+00 1.8723178449480449e+00 + 64 5.1815592623345079e+00 6.0301829566070024e+00 1.0737893845502111e+01 + 39 5.0768954315972890e+00 -7.0255010522737926e-01 -5.9161474934557994e+00 + 43 2.1153755526140956e+00 -7.5250264265041178e+00 -1.0871022565761495e+00 + 47 3.3265285405418528e+00 2.1536423096918682e+00 1.2451815742139596e+00 + 38 -7.4860652592984511e-01 -7.1078971807313196e-01 6.9730423004496167e-01 + 25 1.0225647279133203e+00 4.0532546754561860e-02 1.5536574739628866e+00 + 46 8.4025894151274122e-02 -2.0180730336203885e+00 7.0249965065180646e+00 + 59 3.9282544607350491e+00 2.9149707637849871e+00 -3.6540900686538595e+00 + 34 5.9955487511258954e-01 5.1028650560414057e-02 2.1001425329185341e-01 + 50 -1.2324925097128006e+00 4.1915062662249349e+00 -2.5666620297721936e+00 + 55 2.0540824843371199e+00 -4.5011288518162811e+00 -5.8606842068916176e+00 + 28 7.8372315678940652e-01 2.2486288715348084e+00 5.6768795736306181e+00 + 63 3.8818660647417813e+00 -6.6892167616182174e+00 6.9165485826786144e-01 + 54 3.3983704274453550e+00 -4.0220846635515732e+00 -2.4796461202922617e+00 + 20 -9.9453199957259972e+00 -4.4689488447166381e-01 2.9031488756869921e+00 + 62 -4.7911545216150282e+00 4.3378864433672462e+00 -2.6608977921209904e+00 +run_vdwl: -275.794870368791 +run_coul: 0 +run_stress: ! |2- + 3.2474795701510089e+01 3.4510987071484891e+01 3.8695007722179838e+01 -3.8232466751064074e+00 3.3193703212455567e+01 1.1651133689747770e+01 +run_forces: ! |2 + 2 -1.9908598696494593e+00 -1.4004484316870771e+00 -1.8145676055549023e+00 + 5 -2.1959577489014253e+00 -5.3375610794985517e-01 3.0935341215172696e-01 + 4 -2.0336821018762752e+00 2.8424588959923311e+00 3.3252044603120101e-01 + 9 -4.0222713614306760e-01 -3.4299839962359178e+00 -2.9343220173145870e+00 + 11 2.7522904492196867e+00 -3.6376794324618826e+00 2.9263944168334208e+00 + 13 9.6240327585601659e-01 6.0913367240319563e+00 -1.5511863103751238e+00 + 8 1.6353807548321675e-01 8.0887386656658800e-01 -1.1924042469473850e+00 + 27 2.7335748823624391e+00 -2.5792839151285446e-01 1.6492029804597561e+00 + 12 -6.8719738770845460e+00 -4.1509297509477712e+00 -2.6379028083278735e+00 + 16 2.1221231073423663e+00 -5.1299215714532576e-01 6.4956658419632358e+00 + 17 1.3029918045704934e+00 4.2355009939984161e+00 -4.9226387352903016e+00 + 18 -7.9940101898037452e-01 6.3301139977495069e-01 3.8482841555360325e+00 + 21 3.2378945616894415e+00 1.5421146866664430e+00 -3.3042016258789113e+00 + 19 -1.8467782474594197e+00 -3.1619290842305112e+00 -7.3141992352870522e-01 + 29 -3.6207126139010413e+00 1.0543869760675495e+00 -1.6814536890505254e+00 + 24 2.7630055810652823e+00 1.0349673143123788e+00 2.9527688556547163e+00 + 26 -7.3056017976262955e-01 -1.0638228894045350e+00 2.0441004906079465e+00 + 1 -7.9916337729098008e-01 2.8395319668361365e+00 1.3687637443678211e+00 + 32 -2.8257774695522162e+00 3.8783262206394742e-01 -1.2643365178571548e+00 + 7 -4.6399863391393725e-01 -5.1382489104889850e-01 2.8559566100881222e+00 + 15 -5.1483118535835803e+00 5.9508828570962207e+00 -1.7011650335360340e+00 + 33 4.7599487247686429e+00 -2.7597182889335601e+00 2.8229177540882748e+00 + 6 1.0155423645964312e+00 3.6798897239381803e+00 1.6556939773922417e+00 + 10 -6.3244922266550041e-02 -2.2623367837346486e+00 -2.3386308215641209e+00 + 14 -2.3872510774898710e+00 4.6964545685072867e+00 8.7144933207622108e-02 + 44 4.9889262122944951e+00 -5.2625564341002029e+00 6.2893319159386329e-01 + 49 -3.3521487664968794e+00 -5.6726783066381348e+00 -3.1052568895711494e+00 + 23 2.6910591392000378e+00 4.5217377435987434e+00 1.2431414293232086e+00 + 31 -1.2137577282937255e+00 2.0268100180314703e+00 -9.7395850996118805e-02 + 3 8.4923996979905203e-01 3.1418762059340777e-01 -6.3912272072932219e-01 + 22 -5.2188836792454518e+00 4.2555634530532211e+00 -4.3873476691850408e+00 + 30 -1.3462238630781862e+00 1.0418545293477948e+00 -1.1016639019306111e+00 + 60 -3.7574605564721586e+00 -6.0307875427419715e+00 -3.5246947220861968e+00 + 35 1.3345226768554266e+00 5.0029742209038197e-01 2.8641229427441424e+00 + 37 -1.7805140255845884e+00 1.2140214584480664e+00 -2.2265073901788459e+00 + 41 2.0874661037264897e-01 -6.9701598297907597e-01 -5.8203495844387154e-01 + 45 -2.5849271883896847e+00 1.6204602869165532e+00 -2.8946576662876069e+00 + 36 -1.1217877109611538e+00 -2.7359037710368241e+00 -2.2514663503374624e-01 + 40 4.7957022364437663e+00 -2.0725765651572310e+00 -2.6958077632617914e+00 + 42 -4.5351533556579531e+00 -2.3915196071777896e+00 2.1058309538404144e-01 + 48 1.2228540754982880e+00 7.8998634910681598e-02 -3.9822088016694884e-01 + 53 4.3693214239702955e+00 3.9811506175295404e+00 2.6445458170463865e+00 + 51 -2.3394093576305144e+00 2.7664815454176295e+00 4.3509700303650565e+00 + 57 1.1433821124718713e-01 -1.5670170198273878e+00 -2.0814868576955831e-01 + 61 -8.9293024279856215e-01 2.0033343537690698e+00 -1.2487352376829823e+00 + 52 4.7940149473631690e+00 -4.9119221166835381e+00 4.2517331562128842e+00 + 56 -5.8211143716302594e-01 -3.9743235564492085e-01 -2.0095025235163426e+00 + 58 2.6695231003096840e+00 -1.0533780221295008e+00 1.3662688329066752e+00 + 64 3.9217198033909910e+00 3.9105913229570115e+00 7.5376626537329443e+00 + 39 3.5017506527775359e+00 -5.3565729084921365e-01 -4.3470655497656310e+00 + 43 1.2286706775182532e+00 -5.5089849808766029e+00 -7.0217100291119161e-01 + 47 3.0542841751222456e+00 1.6659726007819589e+00 8.9127795507627994e-01 + 38 -6.4050934363464929e-01 -6.1238442484364475e-01 7.1329619936905031e-01 + 25 9.7835650126070939e-01 1.6204200310558764e-01 1.3301639932222076e+00 + 46 -3.0446016113671648e-02 -1.6054137540965632e+00 5.9779174764707381e+00 + 59 3.3933409795739005e+00 2.5675383553329434e+00 -3.2731885334332276e+00 + 34 5.4922745006786333e-01 9.3065731147143449e-02 2.1724391371509988e-01 + 50 -9.3103591718884804e-01 3.5400288054672151e+00 -2.2077966214036970e+00 + 55 8.7397374494345714e-01 -3.0225604582538672e+00 -4.1352355112113433e+00 + 28 6.4648962756636141e-01 2.6064822661580873e+00 4.6206112630123641e+00 + 63 3.1330925571892028e+00 -5.7967556323730109e+00 4.6233787916491820e-01 + 54 2.7201019549059295e+00 -3.5163356288233216e+00 -2.0564993136098142e+00 + 20 -7.3523997387218074e+00 -8.8938490118371005e-01 1.6456233535658136e+00 + 62 -3.9929704993382833e+00 3.2977536362004498e+00 -2.1647714388871426e+00 +... diff --git a/unittest/force-styles/tests/manybody-pair-tersoff_table.yaml b/unittest/force-styles/tests/manybody-pair-tersoff_table.yaml new file mode 100644 index 0000000000..51220b8c8e --- /dev/null +++ b/unittest/force-styles/tests/manybody-pair-tersoff_table.yaml @@ -0,0 +1,155 @@ +--- +lammps_version: 5 May 2020 +date_generated: Wed May 27 12:29:41 202 +epsilon: 5e-12 +prerequisites: ! | + pair tersoff/table +pre_commands: ! | + variable newton_pair delete + variable newton_pair index on +post_commands: ! "" +input_file: in.manybody +pair_style: tersoff/table +pair_coeff: ! | + * * SiC.tersoff Si Si Si Si C C C C +extract: ! "" +natoms: 64 +init_vdwl: -163.150900631379 +init_coul: 0 +init_stress: ! |- + -5.4897522008245971e+02 -5.4663587944021037e+02 -5.6139301217903756e+02 -1.4199635275715510e+01 -1.3994168950171279e+01 5.4390995854173852e+01 +init_forces: ! |2 + 2 2.9602521876147176e+00 -1.0588299237500024e+01 1.1519654700042441e+00 + 5 4.1945114341051344e+00 4.0211672993908660e+00 6.4807177213713789e+00 + 4 7.6414519558297345e-01 4.0213287923736052e-01 9.4797135442425891e+00 + 9 -1.3829119741572150e+01 3.3401097132503921e-01 8.3332674911616689e-01 + 11 2.7313064825056337e+00 4.0288498999271312e+00 8.9204006232997397e+00 + 13 -1.5858276216676674e+00 -2.3812904172209493e+00 1.2460511885998462e+00 + 8 -3.4780834065792208e+00 -4.5196290557007668e-01 -3.4348776679574877e-01 + 27 3.1192046243419642e+00 -6.5362165965430741e+00 1.2268967392291725e+00 + 12 7.8752077144580763e+00 -7.7186229362459287e+00 -5.2791355687772210e+00 + 16 -7.2727160608078663e+00 6.4043845780100694e+00 3.5171680304729906e+00 + 17 9.5539908170443351e+00 2.6379662075117647e+00 5.0065379719065648e+00 + 18 -3.9214261911691390e+00 -3.3891425704694704e+00 3.2978196749403610e+00 + 21 -3.2053627266037932e+00 -9.8463715357577080e+00 1.2907610236217359e+00 + 19 5.2750906204378756e-01 -5.0345590564215463e+00 -7.2650068215316805e+00 + 29 3.6213713199579916e+00 7.9953291551968046e+00 -2.4577113980133283e+00 + 24 4.1068476115479928e+00 7.3847707018820277e+00 2.2530281011135385e+00 + 26 9.6129454875876141e-01 4.2613557545514386e-01 -6.2159579949997381e+00 + 1 -8.1912855772716675e+00 7.5886846388025908e-01 -1.2625065086707230e+00 + 32 7.4385436017189335e+00 4.0458709198292651e+00 -3.4391105099892787e+00 + 7 -4.5092073870118954e+00 -7.7672008859314374e+00 -5.4813477436093789e+00 + 15 -4.3315594512093547e-02 -6.0171955193131588e-01 -1.0129803574581116e+01 + 33 -7.6856665163460098e+00 -5.2818773356933475e+00 4.5261055958856780e+00 + 6 6.6450032670391348e+00 -3.3655380833330351e+00 2.4183722566270958e+00 + 10 -4.6448815827296821e+00 2.1918982104407707e+00 -4.2071716578675620e+00 + 14 6.2686256403136342e+00 2.5996830623680731e+00 -7.3065524129950337e+00 + 44 9.0533765946125933e-01 3.1947260234644457e+00 1.2778048261494950e+01 + 49 -5.5873863516744358e+00 7.7963295187872799e+00 -5.6221013863655038e+00 + 23 7.0209277594565433e+00 -8.2135277331293750e+00 4.8499160246098310e+00 + 31 7.3989522015929481e+00 -4.1718648028621477e+00 -8.0313838020621731e-01 + 3 1.9949839597681829e-01 3.3201894207855709e+00 -1.2360566140445726e+00 + 22 7.4683745828756765e+00 5.0663239468298809e+00 -7.7210768214116170e+00 + 30 9.3099714838106973e+00 -4.1373208011398592e+00 2.4544416872471841e+00 + 60 -6.2782692138357969e+00 8.1725433314529354e+00 -4.4584611625037285e+00 + 35 -2.0808393703756760e+00 -1.0280587687024974e+01 5.1428083196561214e-01 + 37 -2.2686155372548118e+00 2.1330864264550597e+00 5.6453366760178820e+00 + 41 -5.9518488482655152e-01 2.1158297352137931e+00 8.6147740396231818e+00 + 45 -7.2126713192466338e+00 4.8416258879433061e+00 -4.7112137693868412e+00 + 36 -8.8187586785729322e-01 9.8685266592413150e+00 -4.8105107805298791e-01 + 40 -2.3301714443818611e+00 -3.2758889459093115e+00 -5.7819077673967341e+00 + 42 5.9189525707468791e+00 -2.5092320775490315e+00 -5.1879922894811976e+00 + 48 -9.3992551194731497e+00 -7.2012846985155203e+00 5.3036186825085387e+00 + 53 3.0404144992556801e+00 1.2322928313633699e-01 1.0538754040021310e+01 + 51 -1.0615361540829273e+01 -1.1947083105153979e+00 -2.4754943007799026e+00 + 57 -3.9058710558507475e+00 1.0936413442669394e+01 2.4938375966696702e+00 + 61 -2.3223894968810712e+00 -1.3559331880074218e+01 2.2972606944882779e-01 + 52 -1.0276662258817708e+00 1.2386607108895646e+00 2.7416968036121099e+00 + 56 -8.4656585326110989e-01 4.2930993591472042e+00 2.5997668721502096e+00 + 58 -9.2443565080752883e+00 -2.8306355780794106e+00 4.3004468885981195e+00 + 64 5.1027648459718051e+00 5.3292253828779392e+00 -8.7272294951206089e+00 + 39 6.2802322550736394e+00 -4.4534589381837577e+00 8.8595160616330659e+00 + 43 -3.9578007630386047e-01 1.7159840058827476e+00 1.2478759028161310e+00 + 47 4.7419400153756941e-01 2.6437961931182845e+00 9.3458619244678740e+00 + 38 -3.1134573696082368e-01 5.3227648841703603e+00 -2.1683518971852513e+00 + 25 -3.9318004312455885e+00 -2.5156028374100616e+00 -7.5848697372287823e+00 + 46 -7.1816003228107261e+00 6.7619459056569209e+00 3.7605967878206505e+00 + 59 6.4468801204955275e+00 6.7385156912896562e+00 -8.2413040694593409e+00 + 34 1.4316711932039983e-02 1.9309684074033533e+00 -5.5943779332938215e+00 + 50 6.8601878849069884e+00 -2.4660969267234041e+00 -1.6122673342594418e+00 + 55 1.1299164497924442e+01 7.6540882276683750e-02 -3.9336190342878180e-01 + 28 -6.0383037111862325e+00 -5.1918701774327776e+00 2.9591750241896020e+00 + 63 -6.1967090156304634e+00 -4.9695164154437226e+00 -5.2998409073804016e+00 + 54 2.1362124519360979e+00 3.4829297698969057e+00 -1.0358432593090363e+01 + 20 3.3539449451716496e+00 -3.4278019617537614e-01 5.8115252824167496e-01 + 62 3.0207711149550320e+00 -5.7813674257257364e-02 3.7863400433938121e-01 +run_vdwl: -178.058033986288 +run_coul: 0 +run_stress: ! |- + -5.1394768731412853e+02 -5.0846653160199179e+02 -5.2011513854153361e+02 -8.7883229436386543e+00 5.6457828153841163e+00 4.7063925693300376e+01 +run_forces: ! |2 + 2 2.3998487120357463e+00 -1.1947631024354305e+01 1.7251986198303744e+00 + 5 3.5224792751936431e+00 4.8564111701585588e+00 9.6179331696942683e+00 + 4 3.3347785572465374e+00 1.0397334593442422e+00 8.4324550053413869e+00 + 9 -1.1549806305315341e+01 3.3343498697717511e-01 8.9829395072264329e-01 + 11 4.4274986064211923e+00 5.6793833478923901e+00 9.4331085728817197e+00 + 13 -2.3188554697832462e+00 -1.3290565032582846e+00 2.0742401835202036e+00 + 8 -3.3580456698963550e+00 -2.4400667637465290e-03 -1.3620810815360920e+00 + 27 3.7275421200222043e+00 -5.2709856078665993e+00 4.4767837754634376e-01 + 12 6.1014992011004878e+00 -4.8029899046342139e+00 -3.0355892483172444e+00 + 16 -6.7644890708483318e+00 5.9162038704925104e+00 2.8177777892073563e+00 + 17 8.5459633198301663e+00 1.6413621151982376e+00 3.9669796408418505e+00 + 18 -4.8222891876168532e+00 -4.3708824274261051e+00 3.4937579569867365e+00 + 21 -2.7659211894610944e+00 -8.6441355234481865e+00 1.5812466435689063e+00 + 19 2.2264463224541462e+00 -2.8733975334529207e+00 -7.8166829931591453e+00 + 29 1.5240042016292588e-01 7.2360697725698051e+00 2.2791037638024929e+00 + 24 1.2066522542360372e+00 8.3472687716242522e+00 3.1725426610707537e+00 + 26 2.5713412068524004e+00 -2.5408002550043456e+00 -7.0385977434330425e+00 + 1 -9.2566035348884999e+00 1.0077283504202199e+00 -4.8027801783339070e+00 + 32 6.2466840236582701e+00 2.4999913216931047e+00 -2.1641073643855426e+00 + 7 -1.8093095036034370e+00 -4.6870632389741917e+00 -7.9986911225867274e+00 + 15 -3.5892947760292770e-01 -6.1866493923735444e-01 -1.2154433323458562e+01 + 33 -5.9880417986967380e+00 -2.7478931805546631e+00 2.8138567722489123e+00 + 6 4.5275108875256000e+00 -4.9224374871203640e+00 3.3528524831601034e+00 + 10 -5.5043537244684773e+00 -2.4520398038303037e+00 -1.9605025585455449e+00 + 14 5.1178562414224791e+00 1.6515608570444342e+00 -6.0532914619417362e+00 + 44 -9.4956184895320117e-01 8.2547135221670487e-01 1.2487365842645433e+01 + 49 -3.2036157031172867e+00 5.5662434195554056e+00 -2.7617454643589232e+00 + 23 7.8425937035300022e+00 -8.4410864460326405e+00 5.6778064251855405e+00 + 31 5.6883358059498450e+00 -9.6341549807637272e-01 -4.2245884323528475e+00 + 3 1.7761229185696443e+00 1.9054018879858150e+00 -2.2724102717374479e+00 + 22 7.8148804202727495e+00 5.0038217200793857e+00 -7.0422846461300344e+00 + 30 7.0113846179699513e+00 -1.8787657129693625e+00 1.4574293534812237e+00 + 60 -3.9127677104140677e+00 5.8663584436714515e+00 -2.1774330406300964e+00 + 35 -3.5060341733584526e+00 -9.0237098060215768e+00 1.1770654221112442e+00 + 37 -5.5405496188611218e+00 4.3460853070738512e+00 8.5790341076662955e+00 + 41 -2.6749746281308302e+00 1.0522701742849794e-01 9.7391280556148896e+00 + 45 -4.4331175102913996e+00 5.2116495599290911e+00 -6.2695791083891343e+00 + 36 -2.5246494643706727e+00 7.0663728535561230e+00 -3.1349307977062026e+00 + 40 -2.6475382751305840e+00 -9.6105514528384273e-01 -1.8110660765453432e+00 + 42 5.5610943228802574e+00 -2.2468106492546469e+00 -3.4123407480689298e+00 + 48 -6.9517319181050343e+00 -7.2112415844753510e+00 7.6606438686829286e+00 + 53 3.5579108889862212e+00 -5.2237815190825754e-01 9.3831787574673822e+00 + 51 -1.0745364984704796e+01 -2.1284297905694660e+00 -1.3329579329854062e+00 + 57 -2.3063688729216909e+00 1.2872297695277920e+01 9.0859036310960128e-01 + 61 -4.1017636130215696e+00 -1.2643498990124758e+01 -2.5184011843270957e+00 + 52 -2.6515694547782132e+00 -7.3074505448276331e-02 1.1060256600653522e+00 + 56 4.5356429306807264e+00 5.0852597474470889e+00 2.1899165642851095e+00 + 58 -9.7296681808057723e+00 -1.6561529998497799e+00 3.4072849729092032e+00 + 64 3.3020300351577703e+00 3.1627843949473773e+00 -6.8660441174914375e+00 + 39 5.4184148388185953e+00 -3.4406000337881224e+00 8.6553968902184817e+00 + 43 -9.3652047930018023e-01 9.9796616927878401e-01 1.7812183103345820e+00 + 47 1.9858371790970455e+00 -1.4852614449249550e+00 8.4274231441037486e+00 + 38 -1.3910399033222542e+00 6.8645625994929125e+00 -4.4200902140846656e+00 + 25 -3.6623878162645775e+00 -4.1813758257450804e+00 -7.2968136532147163e+00 + 46 -7.3320350700380148e+00 6.8971581770134662e+00 3.8963658146337847e+00 + 59 6.8712291462544846e+00 4.5941231523074855e+00 -6.5895924901577025e+00 + 34 2.5647817565489164e+00 1.8617523523366026e+00 -9.7172849593190236e+00 + 50 4.3053409655962884e+00 -2.3640451738266752e+00 7.4207546641204158e-01 + 55 1.0034713945938609e+01 1.0234413969920062e+00 -8.8643316171984998e-01 + 28 -3.4154859921828082e+00 -2.3851066028409340e+00 -5.0316223108728408e-02 + 63 -3.7332743224945890e+00 -3.4101596176779831e+00 -6.2778891731735511e+00 + 54 1.6688888928644392e+00 2.6487643134277210e+00 -1.0427233594443427e+01 + 20 3.2796801180628909e+00 -5.3191450367785598e-01 7.7821247928959858e-01 + 62 3.5192808374081448e+00 6.4461039498890293e-01 -2.8499472299838891e-01 +... diff --git a/unittest/force-styles/tests/manybody-pair-tersoff_zbl.yaml b/unittest/force-styles/tests/manybody-pair-tersoff_zbl.yaml new file mode 100644 index 0000000000..d161c10b23 --- /dev/null +++ b/unittest/force-styles/tests/manybody-pair-tersoff_zbl.yaml @@ -0,0 +1,155 @@ +--- +lammps_version: 5 May 2020 +date_generated: Wed May 27 10:29:02 202 +epsilon: 5e-12 +prerequisites: ! | + pair tersoff/zbl +pre_commands: ! | + variable newton_pair delete + variable newton_pair index on +post_commands: ! "" +input_file: in.manybody +pair_style: tersoff/zbl +pair_coeff: ! | + * * SiC.tersoff.zbl Si Si Si Si C C C C +extract: ! "" +natoms: 64 +init_vdwl: -154.312424904672 +init_coul: 0 +init_stress: ! |- + -5.4522412416158102e+02 -5.4620277297655377e+02 -5.5815536323162701e+02 -1.7213270572024335e+01 -7.7594128912815306e+00 5.4428966311706318e+01 +init_forces: ! |2 + 2 3.7509929454128033e+00 -1.1608422146949774e+01 5.9829237011901226e-01 + 5 2.8065933831668208e+00 4.1360726535826693e+00 6.5929843993713302e+00 + 4 1.4187200625138665e+00 5.9303547363431663e-01 1.0375888219204084e+01 + 9 -1.4162689681759806e+01 -6.0833719091296479e-02 6.5862389183669001e-01 + 11 2.3782322441244537e+00 2.8028996002466671e+00 8.3974909855476199e+00 + 13 -1.7339461509015812e+00 -6.2656293614589265e-01 1.4680700372946309e+00 + 8 -3.1266026325384808e+00 2.7397841938566925e-01 -1.4637526104090299e+00 + 27 3.3486790257685142e+00 -7.6427425596683571e+00 6.9823818008918426e-01 + 12 7.2245884140175605e+00 -7.1545180209348835e+00 -5.6015217582408967e+00 + 16 -6.9180189161072780e+00 6.0016649351285860e+00 5.2030407483493528e+00 + 17 8.7820893390038446e+00 2.7984560892702510e+00 4.7728900338248890e+00 + 18 -3.1913649483034638e+00 -3.4524044281061714e+00 3.7538798176451111e+00 + 21 -2.4701212056737192e+00 -9.3941282330265476e+00 5.2105099848053948e-01 + 19 -6.4128808124179412e-02 -6.0635767184752192e+00 -6.8997640473277917e+00 + 29 1.8990657601464958e+00 7.9462823825407645e+00 -2.2852349979707096e+00 + 24 4.8510712718085323e+00 6.8813453271828884e+00 3.7726541864639174e+00 + 26 5.4873724451387218e-01 8.5331027006887650e-01 -7.0355245447133861e+00 + 1 -7.7223891253517722e+00 1.0669552508817124e+00 -9.3076553380222071e-01 + 32 6.1729069395305345e+00 3.9913522288972123e+00 -3.3335846601483548e+00 + 7 -3.5965225360426096e+00 -7.2511307484456236e+00 -3.6830937953307998e+00 + 15 -2.6319683461903143e-01 9.5625752411607756e-02 -9.9869806512065207e+00 + 33 -7.5775036922654033e+00 -5.9605069713583001e+00 4.1414777448263917e+00 + 6 6.5638996551157218e+00 -1.5686673063102741e+00 1.7631493864177592e+00 + 10 -4.1588593526494853e+00 1.9471124735881842e+00 -4.7275429783999288e+00 + 14 5.8837298095438388e+00 4.0439697767810125e+00 -7.0902659577335854e+00 + 44 7.8526164522640796e-01 2.4185951124909324e+00 1.2604481861672642e+01 + 49 -5.2670245468846746e+00 6.9877705136631088e+00 -5.1191274136784921e+00 + 23 6.4376905136579818e+00 -7.0439226225786209e+00 4.6084176140211843e+00 + 31 7.0252868086935667e+00 -3.4623097800839489e+00 -1.1862906778911682e+00 + 3 2.6417923119560638e-01 2.2717446840373618e+00 -1.9580554374326651e+00 + 22 5.7383565771653142e+00 4.8828947154874278e+00 -7.9926266338824732e+00 + 30 8.5847044839182303e+00 -3.5987773729518682e+00 1.9210111641479415e+00 + 60 -5.4343710487746817e+00 7.8480050696419266e+00 -4.6430620541349326e+00 + 35 -1.7413957750584443e+00 -9.7866905973519476e+00 9.2507002642295422e-01 + 37 -2.5316818073756524e+00 2.4727832341958438e+00 5.3238709757802045e+00 + 41 -6.1063699317217113e-01 2.7151522550600631e+00 9.2123263221338334e+00 + 45 -8.0247682250156345e+00 4.9293205753843372e+00 -6.0682015920462939e+00 + 36 -1.0604503231041353e+00 8.9118947434778093e+00 -3.2649864820235919e-01 + 40 -7.6762734626138085e-02 -2.7743904987196446e+00 -6.0821504748439743e+00 + 42 6.2163089480270228e+00 -2.7694305062107678e+00 -5.7921208552013903e+00 + 48 -8.5076653112250291e+00 -7.1852711589841762e+00 5.5735000792544982e+00 + 53 4.9486726742870886e+00 1.0898234069639925e+00 1.0082593834352190e+01 + 51 -1.1727851021662977e+01 -5.1582585170714235e-01 -3.4928360372493388e+00 + 57 -4.0457598988134817e+00 9.3402867028335077e+00 3.6326633592191828e+00 + 61 -2.5195325804478843e+00 -1.2692534018971337e+01 -1.0104567253349769e-01 + 52 -1.1984284285057771e-01 1.1918867317733057e+00 3.9396044306165670e+00 + 56 -1.1393680684316139e+00 3.9820344303361921e+00 5.3281327318845495e-01 + 58 -9.5259925551691484e+00 -3.0439646719749209e+00 5.4130118641158047e+00 + 64 5.1854732626889648e+00 5.4062029912491161e+00 -7.4682505070688565e+00 + 39 6.6090376159255850e+00 -4.8443063100623718e+00 8.3554827564728651e+00 + 43 -8.7180001448292499e-01 1.7901126742696198e+00 1.5519575254278921e+00 + 47 2.1314788601538375e+00 3.3362663032911404e+00 8.4585802162670074e+00 + 38 -4.3233426310435874e-01 4.8360652833090603e+00 -1.9586012106375454e+00 + 25 -3.4489436588305233e+00 -3.5502395499027601e+00 -6.7416968668150439e+00 + 46 -7.1949455773882338e+00 6.5987259516018728e+00 5.4937477906872818e+00 + 59 6.1684616977984712e+00 6.7515296579212762e+00 -8.2182898830145366e+00 + 34 -9.0946996290491056e-01 1.2572967653270477e+00 -5.2123947596604268e+00 + 50 6.7159251463526664e+00 -1.9613746718933034e+00 -1.5344273158709154e+00 + 55 1.0985523411199667e+01 3.8088963907017875e-01 -2.0149022524288043e+00 + 28 -5.4974820053188704e+00 -5.2192989519390922e+00 2.9981122024503728e+00 + 63 -5.8030976211176633e+00 -5.8640980265649132e+00 -4.9661385661230621e+00 + 54 1.9535564702196746e+00 2.2045675779591183e+00 -1.0184339640672373e+01 + 20 3.4388871104450129e+00 -3.8200104001389068e-02 5.1166837878832272e-01 + 62 2.6584101684745818e+00 9.8218829465888779e-02 2.4244336018167600e-01 +run_vdwl: -168.515804855579 +run_coul: 0 +run_stress: ! |- + -5.1841557043298781e+02 -5.1892174147548633e+02 -5.2617752502111762e+02 -1.1314531552299417e+01 8.7875167476580707e+00 5.1815980028093890e+01 +run_forces: ! |2 + 2 3.2776810672840515e+00 -1.3085871606564051e+01 1.1806494551293618e+00 + 5 2.4299243014499536e+00 5.0866323414920460e+00 9.7139919882983641e+00 + 4 3.8787767570488025e+00 1.0720562363070822e+00 9.5864034165261582e+00 + 9 -1.2006758069598721e+01 -1.0775761244461626e-01 1.0576688982994074e+00 + 11 3.8346282033681951e+00 4.2063245193633296e+00 9.1383763500636750e+00 + 13 -2.7554683698851719e+00 7.3965653975875301e-01 2.5875764021965244e+00 + 8 -2.4926478080666103e+00 8.1851419495890321e-01 -2.6565204652884225e+00 + 27 3.6594088209184088e+00 -5.8213707201333351e+00 -9.7349396071893537e-02 + 12 5.6014613299568596e+00 -4.5852098712070246e+00 -3.4691765391064520e+00 + 16 -5.9881602539519481e+00 5.1615703973749332e+00 3.9522722890022290e+00 + 17 7.8066454734355712e+00 1.9356843569113025e+00 4.0183959460032330e+00 + 18 -4.2048129687598035e+00 -4.0107703447097283e+00 4.1242761620578161e+00 + 21 -2.0059193900008001e+00 -8.2626725133010037e+00 7.9178047700536291e-01 + 19 1.2413487667153138e+00 -4.3779805564052214e+00 -7.2463002623400321e+00 + 29 -1.3801123684640757e+00 7.7648130182871817e+00 2.3498640537061890e+00 + 24 2.8041674125680007e+00 7.0833805099855329e+00 4.9750118173063154e+00 + 26 1.9053152499257546e+00 -1.7517119961442660e+00 -8.4726338069977398e+00 + 1 -9.1301609181552656e+00 1.1957683204487815e+00 -4.5460157073376077e+00 + 32 5.3497803111618376e+00 2.2838226340208188e+00 -1.9283210626990019e+00 + 7 -7.7439181529068757e-01 -4.8310181062524213e+00 -6.0078686870229205e+00 + 15 -4.6144395917172876e-01 2.3640466933840187e-01 -1.1865629739424508e+01 + 33 -5.9972742663279579e+00 -3.4333507575957460e+00 2.3025591247805979e+00 + 6 5.0985768567980276e+00 -2.8555457774588864e+00 2.6253842585461493e+00 + 10 -4.8060944156753980e+00 -2.6906377370548809e+00 -3.2193306503164898e+00 + 14 4.4201029530371860e+00 2.6546408449900443e+00 -5.5339107464515802e+00 + 44 -8.9645973513136368e-01 2.8454341478593514e-01 1.2778900767085311e+01 + 49 -3.2314428261947796e+00 5.1411738528568511e+00 -2.7914758327825977e+00 + 23 7.0325744091503566e+00 -7.0223702574030256e+00 5.3077646024130116e+00 + 31 5.9377496148015423e+00 -4.4922784551999351e-01 -4.0773550421387643e+00 + 3 1.8315841558517838e+00 1.3262909027211442e+00 -2.9986780541343045e+00 + 22 5.8364843151195656e+00 4.4196082996900588e+00 -7.6558901741958403e+00 + 30 6.9424985761025138e+00 -1.5365468622633238e+00 1.0924482547129712e+00 + 60 -3.4830354675710242e+00 6.0076208382264751e+00 -2.8700155510928020e+00 + 35 -2.9795968885401094e+00 -8.5885588128963448e+00 1.4525876983612640e+00 + 37 -5.4798081033351140e+00 4.3891901412370453e+00 7.8219815334416278e+00 + 41 -2.4325575558185237e+00 1.3608400669370035e+00 1.0325858665182825e+01 + 45 -5.6032890374369204e+00 4.6996820031013522e+00 -8.0230836793876730e+00 + 36 -2.9014668114053594e+00 6.9215485497600540e+00 -2.6287602960505483e+00 + 40 -3.4421192945532586e-02 -6.7084512524494011e-01 -2.7259226462323105e+00 + 42 5.5797723756711779e+00 -2.1376550929874067e+00 -4.0413495715073200e+00 + 48 -6.1840116866801207e+00 -7.2532543764210109e+00 7.9062093908630056e+00 + 53 5.3787811655827769e+00 1.3525171052070943e+00 8.4804933473882471e+00 + 51 -1.1573799806332197e+01 -1.5119534851867609e+00 -2.3549528277235590e+00 + 57 -2.6975098048400517e+00 1.0504487768024228e+01 2.3461539049689519e+00 + 61 -3.9256945420303895e+00 -1.1566074896871783e+01 -2.4769887519388551e+00 + 52 -2.0099195969716588e+00 -4.3653471871907124e-01 2.8132126631806047e+00 + 56 3.8928323724490936e+00 4.3247888544127688e+00 5.5261512377621991e-01 + 58 -9.8957591837494618e+00 -1.0753274251205771e+00 3.8521254579996631e+00 + 64 3.3724731165803483e+00 3.2200570250582743e+00 -5.4250274767730042e+00 + 39 5.5046258795003506e+00 -3.6734121933735961e+00 7.8548197056507121e+00 + 43 -1.3459189031983463e+00 1.1486677610790905e+00 2.1193773133864147e+00 + 47 4.0131015467795255e+00 -1.1094771865954856e-01 7.2472616550054099e+00 + 38 -1.4114452832435900e+00 6.2046846182972999e+00 -3.9380910474694599e+00 + 25 -4.1774709120449858e+00 -4.9678314741113541e+00 -6.2607312380148255e+00 + 46 -6.9158221680072787e+00 6.3575947622331599e+00 5.1651381663367077e+00 + 59 6.3773097304508113e+00 4.3409941136654648e+00 -6.9533437007241155e+00 + 34 7.0071644178570391e-01 9.6756304631948331e-01 -8.7521477682404800e+00 + 50 4.8382411105825529e+00 -1.5201401041732816e+00 9.3971670483645164e-01 + 55 9.4611642726669309e+00 4.9437887022790628e-01 -1.6092705652227484e+00 + 28 -3.2397345588226778e+00 -2.7462426540062821e+00 3.7542506318260926e-01 + 63 -3.2853115933185668e+00 -4.1199055035244392e+00 -5.8243046369201750e+00 + 54 1.1694727578627844e+00 7.7340028625284152e-01 -1.0541423347485072e+01 + 20 3.3996176655745556e+00 -5.7342465446724944e-02 5.4967688817860072e-01 + 62 3.1309032507858996e+00 7.7916774786999388e-01 -3.9410827378090074e-01 +... diff --git a/unittest/force-styles/tests/manybody-pair-vashishta.yaml b/unittest/force-styles/tests/manybody-pair-vashishta.yaml new file mode 100644 index 0000000000..5942ae17df --- /dev/null +++ b/unittest/force-styles/tests/manybody-pair-vashishta.yaml @@ -0,0 +1,155 @@ +--- +lammps_version: 5 May 2020 +date_generated: Wed May 27 10:58:14 202 +epsilon: 5e-13 +prerequisites: ! | + pair vashishta +pre_commands: ! | + variable newton_pair delete + variable newton_pair index on +post_commands: ! "" +input_file: in.manybody +pair_style: vashishta +pair_coeff: ! | + * * SiC.vashishta Si Si Si Si C C C C +extract: ! "" +natoms: 64 +init_vdwl: -313.692565300211 +init_coul: 0 +init_stress: ! |- + -1.6865844788070896e+02 -1.6802557677032220e+02 -1.7078202792877408e+02 1.2410655645813289e+00 -1.2389436818899767e+01 1.3028516323660728e+00 +init_forces: ! |2 + 2 1.4047821022916134e+00 -3.4557466406036697e-01 7.9241501680828397e-01 + 4 1.5843160204105311e-01 -1.1028096475846372e+00 -2.5757543801235155e-01 + 5 -7.4244711251462892e-01 5.0759473728923621e-01 4.7756151075234277e-01 + 6 -3.3887593589521825e-01 -5.0889866087169999e-02 4.4291059542940481e-01 + 7 6.2397209388287966e-01 1.5650484499784467e-01 1.1451269815786989e+00 + 8 5.2818538291552497e-01 4.4023965758370026e-01 -2.6801464948869519e-01 + 9 -7.0475179471280924e-01 1.4836164038322393e-02 8.0074140958481965e-01 + 10 -6.5223518994630725e-01 -7.0165070270421925e-01 -2.1536894255035988e-01 + 11 -3.7259714037422187e-01 -2.1888537767830751e-01 5.0838294742217438e-01 + 12 5.5060158706628637e-01 -2.0160641829856840e-01 9.4385633652860013e-02 + 13 5.3756367675513173e-01 -5.8165546465130247e-01 -3.5019921038526342e-01 + 14 -1.5936326739193174e-01 -3.5321279713531106e-01 1.8749544517274300e-02 + 15 2.1420534370487598e-01 1.8242928398200622e-01 7.5899213470388194e-02 + 16 -2.8658934277608583e-01 -4.1838870583984722e-01 -8.4865232124881129e-01 + 17 4.3921950961262524e-01 1.3242362092979842e-01 9.5220992145353334e-01 + 27 2.4765427605642529e-01 9.0700726983259783e-01 -2.1059681289778287e-01 + 33 -7.3377879347892039e-01 -1.0878799779475634e-01 -5.1965132343626030e-01 + 44 -3.2194872028199151e-02 6.8546389763352666e-01 2.7821776324844860e-01 + 3 1.3708556794578625e-01 8.5411982846933887e-01 -8.9498891697744809e-01 + 18 -8.4631731921500775e-01 -4.4236636472213586e-01 -3.1161952459012032e-01 + 19 -8.3055211370870574e-02 -7.1847184059982327e-01 2.1568757006036499e-01 + 21 -1.4865820075390945e-01 1.8932934602799723e-01 8.2154184263142627e-01 + 22 1.0215672350121201e+00 1.4715761910049885e-01 1.2993874645585812e-01 + 23 3.1140118096630404e-01 -6.0032762314866581e-02 -5.7046540879039520e-01 + 24 2.5897896904458467e-01 -1.0967568239388985e+00 2.3332780290403404e-01 + 26 7.0517946746267501e-01 3.1761242834462411e-01 -1.8447687215244010e-01 + 49 -8.2810885661784617e-01 1.0170766851786808e+00 2.9499403002766433e-01 + 1 4.0652502956324721e-01 -9.1496946301617188e-01 -6.3694160827578861e-01 + 29 -2.5096614495371911e-01 -3.2280555204710809e-01 -7.8829051869479860e-02 + 30 -2.8339564737837886e-01 -1.3874935555614967e-01 5.7662645971782236e-03 + 31 3.8758881586559812e-01 -9.1841528714741216e-02 2.7177297384787469e-01 + 32 8.5960795958976344e-01 3.3606082318697572e-01 -2.1871847942185818e-01 + 60 8.2145040521668156e-02 8.8970915666282513e-01 6.3991924667120936e-01 + 25 -1.2009733494362101e-01 2.3145989727328486e-01 -1.4422393173147061e-01 + 35 -3.3534537127094532e-01 7.6315277915305957e-01 1.9786863030810564e-01 + 36 -8.9374644030954165e-01 2.4197992356056630e-01 -2.6992311959917697e-01 + 37 1.0210562060212902e-01 -6.0820921533480399e-01 3.5865165186771186e-01 + 38 -1.0619990592652044e+00 3.9811077570080400e-01 3.5952328839664549e-01 + 39 8.2791774114859029e-01 3.2894839791485431e-01 6.3343120586878443e-01 + 40 2.5906624332440059e-01 4.1028513744218365e-01 -7.9906606975547689e-01 + 34 9.3511614095840012e-01 9.9555882470179213e-03 -4.4906877782009125e-01 + 41 1.2072922079160947e-01 -4.8949130894176940e-01 -1.3327165972435168e-01 + 42 4.9837527237279194e-01 7.1268817780157856e-01 5.0839531379284941e-01 + 43 4.7552136285959379e-01 2.2253227617700755e-01 2.3144957437005048e-01 + 45 -1.0693159811040500e+00 1.5621567566240435e-01 2.7928292547369132e-01 + 46 1.7624907025999317e-01 -6.2035718807434616e-02 -1.4161651193926755e-01 + 47 -3.2453126051658643e-01 9.4068662506403722e-01 -3.0837177671988286e-01 + 48 -1.5411935359197826e-01 -1.2869344840768573e+00 4.4935347966860295e-01 + 59 -2.6492058959645831e-01 1.0177772361376798e+00 -1.1679570774063064e+00 + 20 8.9690563017530156e-01 2.7650312180803749e-01 1.6742341511708736e-01 + 50 -1.3303889992590097e+00 -1.5530036067511843e-01 -2.8542326186128619e-02 + 51 -4.8616146106178049e-01 -1.6884814295791504e+00 -2.1452095397205029e-01 + 52 -5.5507340820572026e-01 -6.3140391845561972e-03 -9.1783294879880029e-01 + 53 7.2162563010911263e-01 4.8728051695705404e-02 2.4867065203167682e-01 + 54 1.6630503275218989e-01 -4.2637980829713018e-01 -2.6445409529452890e-01 + 55 -2.0441312919315491e-01 4.5571213735911037e-01 -2.2213382067240908e-01 + 56 -8.4770657142837894e-02 -4.9111925904915327e-01 3.1713056895555780e-01 + 58 4.5871855155288627e-01 1.7620429363715145e-01 5.8850394497842418e-01 + 28 1.4145701400013533e-01 5.7253504567460456e-01 -1.1163765815834221e+00 + 57 -1.5333131310312106e-01 3.7092149519733092e-01 1.1759008747976697e-01 + 61 -1.4701074072598794e+00 -7.2902116254680860e-01 -4.0309029925812756e-01 + 62 -2.6745936396158526e-01 2.8111058048742638e-01 1.6204295193993715e-01 + 63 3.3265811552668922e-01 -8.0829164437628798e-01 6.1676655388945945e-01 + 64 2.5167047246154373e-01 2.2796118436162449e-01 -1.2890847486936465e+00 +run_vdwl: -313.860735066532 +run_coul: 0 +run_stress: ! |- + -1.6823266272734222e+02 -1.6769002622828248e+02 -1.7052203092220537e+02 1.6390415183743356e+00 -1.1679532092037334e+01 8.3280653475887612e-01 +run_forces: ! |2 + 2 1.3393977794128566e+00 -2.7348565261442026e-01 8.7655961303357333e-01 + 4 1.9796427463902799e-01 -1.0921013729581110e+00 -2.9042812842603660e-01 + 5 -6.7902521648735226e-01 5.8080284239232793e-01 4.0066311685188527e-01 + 6 -2.8452980230104119e-01 -5.0018672753884857e-02 3.5551068635415151e-01 + 7 5.8572215816797180e-01 1.2640037062834633e-01 1.0942180533161248e+00 + 8 5.4834736203953538e-01 3.9763058063722501e-01 -2.0200882443276269e-01 + 9 -6.6261672013750861e-01 8.6603390966248570e-02 7.1554511072340488e-01 + 10 -5.5929402642412196e-01 -7.1960480457817821e-01 -1.4907250085043805e-01 + 11 -3.3250480870141408e-01 -1.6273718034280316e-01 5.7152914630563867e-01 + 12 5.5602656449431520e-01 -2.0378555616033520e-01 7.8990528833246532e-02 + 13 4.7489008863328686e-01 -6.2440679278521216e-01 -3.7631116796095471e-01 + 14 -2.0609926816794977e-01 -2.7580432590210063e-01 -4.0417350127801004e-02 + 15 2.7394322065681798e-01 9.3892857792986395e-02 3.7982358930011673e-02 + 16 -2.5162804323859178e-01 -3.7771297423259487e-01 -9.8238587852850667e-01 + 17 4.1877939802730868e-01 8.5731711109771958e-02 9.3859218724784710e-01 + 27 3.1723875018509745e-01 8.0840008953553444e-01 -1.3402639439359032e-01 + 33 -8.1204031193767900e-01 -2.5918584535096545e-02 -5.4822621102922708e-01 + 44 2.7166631736183833e-02 6.3755896938460666e-01 3.1019975268431810e-01 + 3 1.5707486941719284e-01 8.1153240527643589e-01 -9.7289836461546320e-01 + 18 -7.2471977878478144e-01 -4.0664368465993972e-01 -3.4553372464886356e-01 + 19 -4.8745937087625535e-02 -6.2356012040857323e-01 2.0727390034813520e-01 + 21 -1.9258260457687104e-01 1.5417500787852179e-01 8.4979385157019172e-01 + 22 9.6739412405966108e-01 1.7094777029994024e-01 1.6519141214180810e-01 + 23 2.9640988596724127e-01 -6.4727860062706630e-02 -5.2331198239284404e-01 + 24 3.1197288934637141e-01 -1.0653738889812776e+00 2.4613115703079824e-01 + 26 6.6963858336879611e-01 2.7536443311377506e-01 -1.3921358926032371e-01 + 49 -9.0057183341478408e-01 9.1800333277327995e-01 2.2039239023465473e-01 + 1 4.8644131471971841e-01 -9.1232608143660543e-01 -6.2310194460362922e-01 + 29 -2.8301007482603474e-01 -2.8409275618929547e-01 -5.7362303628387082e-02 + 30 -3.1800791834958703e-01 -1.4722568793242755e-01 -7.2299408071138382e-02 + 31 3.7785555685247557e-01 7.8528837793268580e-03 2.0510546212129288e-01 + 32 7.8568823142872413e-01 3.7621441926789645e-01 -2.2195231721335040e-01 + 60 1.7324286279956747e-02 8.9299818746122483e-01 6.4705074359535664e-01 + 25 -1.3222157048900707e-01 1.9287824417448718e-01 -1.0687909706274114e-01 + 35 -3.0228449693476567e-01 7.6823424966386022e-01 1.9710074184774423e-01 + 36 -9.1006897873334558e-01 2.2243346236343808e-01 -1.9589687356432450e-01 + 37 1.4230521719479650e-01 -6.5154051987310280e-01 3.9917443593572977e-01 + 38 -1.1292151026630861e+00 4.0635956316044064e-01 3.6653385069281041e-01 + 39 7.7368097436126093e-01 3.3585148445359836e-01 7.5798069110913358e-01 + 40 2.5675490646756788e-01 4.4146779801073416e-01 -7.5832420936942102e-01 + 34 9.0377430089083910e-01 2.3556023563222617e-03 -5.4249181274543457e-01 + 41 7.9683299154939075e-02 -5.0998023619050059e-01 -1.6942094109849781e-01 + 42 5.3489923215345148e-01 6.2583893444475647e-01 5.3150357966827078e-01 + 43 4.3150953366175226e-01 3.4251106617468263e-01 1.8713858579638765e-01 + 45 -1.0266415763007517e+00 1.6282879655478405e-01 2.4889912862867503e-01 + 46 1.6312901571568492e-01 -4.4541049259555897e-02 -1.6364537246217073e-01 + 47 -3.2467268967905150e-01 8.6794088351002507e-01 -1.8425672458764986e-01 + 48 -2.3621080452325272e-01 -1.1969459110188581e+00 5.3625923507429407e-01 + 59 -3.2367672070843334e-01 9.9079666853049564e-01 -1.1595397017822693e+00 + 20 8.1232215990984924e-01 2.8338121278738360e-01 2.3413383735199889e-01 + 50 -1.3715621346135916e+00 -1.6292126845965993e-01 -1.9130145378467800e-02 + 51 -4.9091417055006148e-01 -1.7653094190066536e+00 -1.9135516672542885e-01 + 52 -6.0210124847882640e-01 -2.7443951813942963e-02 -9.4957908163132521e-01 + 53 8.3243980764689196e-01 8.5420859954954353e-02 2.2294347279673232e-01 + 54 1.2671424980101897e-01 -4.6285869425318049e-01 -3.0047230827733917e-01 + 55 -1.7627588718280662e-01 5.2996528719115910e-01 -2.6201418848310271e-01 + 56 -1.0703755083130259e-01 -5.0757765604513283e-01 2.9114293137467201e-01 + 58 4.7688278738147094e-01 1.9738885358609715e-01 6.4289217276979960e-01 + 28 1.6455690667075529e-01 5.7894053910339294e-01 -1.1167034403931775e+00 + 57 -1.0905729896799360e-01 3.2808582473665598e-01 1.2346577335199894e-01 + 61 -1.4935302022207437e+00 -7.9239974668545465e-01 -4.4856933855602110e-01 + 62 -2.1277601252075656e-01 2.1138739770169473e-01 1.6557617222026333e-01 + 63 3.6167529106202745e-01 -7.6209406783076528e-01 6.3677417578544659e-01 + 64 3.3401913832828206e-01 1.9496253621395221e-01 -1.2154197634257087e+00 +... diff --git a/unittest/force-styles/tests/manybody-pair-vashishta_table.yaml b/unittest/force-styles/tests/manybody-pair-vashishta_table.yaml new file mode 100644 index 0000000000..eb723cf78b --- /dev/null +++ b/unittest/force-styles/tests/manybody-pair-vashishta_table.yaml @@ -0,0 +1,155 @@ +--- +lammps_version: 5 May 2020 +date_generated: Wed May 27 12:26:05 202 +epsilon: 1.0e-12 +prerequisites: ! | + pair vashishta/table +pre_commands: ! | + variable newton_pair delete + variable newton_pair index on +post_commands: ! "" +input_file: in.manybody +pair_style: vashishta/table 10000 0.2 +pair_coeff: ! | + * * SiC.vashishta Si Si Si Si C C C C +extract: ! "" +natoms: 64 +init_vdwl: -313.692612242023 +init_coul: 0 +init_stress: ! |- + -1.6865842944245654e+02 -1.6802555802886161e+02 -1.7078200929565867e+02 1.2410702337908432e+00 -1.2389422965610184e+01 1.3028679521322537e+00 +init_forces: ! |2 + 2 1.4047810862502077e+00 -3.4557511292381471e-01 7.9241387100252669e-01 + 4 1.5842977016277032e-01 -1.1028070944350965e+00 -2.5757366998458364e-01 + 5 -7.4244708134640858e-01 5.0759502472968010e-01 4.7756201758480898e-01 + 6 -3.3887566608892361e-01 -5.0888855862226301e-02 4.4291166673417726e-01 + 7 6.2397126152661786e-01 1.5650439035879338e-01 1.1451277518876657e+00 + 8 5.2818534888694846e-01 4.4024010546864212e-01 -2.6801542201014483e-01 + 9 -7.0475239554061420e-01 1.4835088189460891e-02 8.0074042537333434e-01 + 10 -6.5223535528601728e-01 -7.0165094229987512e-01 -2.1537000776042828e-01 + 11 -3.7259483671434857e-01 -2.1888807143282896e-01 5.0838582784480901e-01 + 12 5.5059651162410916e-01 -2.0161213237228728e-01 9.4380338298230115e-02 + 13 5.3756160332764324e-01 -5.8165243112279463e-01 -3.5020061350045661e-01 + 14 -1.5936407475132430e-01 -3.5321096404176933e-01 1.8749553005965522e-02 + 15 2.1420418283785914e-01 1.8243030624759585e-01 7.5898630026710157e-02 + 16 -2.8658638170453432e-01 -4.1838551560221404e-01 -8.4864497225612867e-01 + 17 4.3922235564766421e-01 1.3242576554920804e-01 9.5220751900354750e-01 + 27 2.4765597883836338e-01 9.0700682072165972e-01 -2.1059580809672063e-01 + 33 -7.3377775982817861e-01 -1.0878846199652992e-01 -5.1965047041670365e-01 + 44 -3.2193309438836692e-02 6.8546285722744960e-01 2.7821922090391582e-01 + 3 1.3708563627216658e-01 8.5412021999234211e-01 -8.9498899575926238e-01 + 18 -8.4631785951847682e-01 -4.4236621557782119e-01 -3.1161827099886852e-01 + 19 -8.3055190857545647e-02 -7.1847263426953312e-01 2.1568711859842082e-01 + 21 -1.4865756035775646e-01 1.8932859336052132e-01 8.2154058870790170e-01 + 22 1.0215661027655285e+00 1.4715903967055510e-01 1.2993709905111550e-01 + 23 3.1140201639385451e-01 -6.0031908627583896e-02 -5.7046465821843895e-01 + 24 2.5898036316732242e-01 -1.0967549823637563e+00 2.3332917520009377e-01 + 26 7.0518023657092443e-01 3.1761184709309520e-01 -1.8447637213088361e-01 + 49 -8.2811185037572643e-01 1.0170729298274659e+00 2.9499069825625512e-01 + 1 4.0652330058013075e-01 -9.1496811068741879e-01 -6.3694021071271667e-01 + 29 -2.5096751879287688e-01 -3.2280416140141027e-01 -7.8829608736718404e-02 + 30 -2.8339557964285605e-01 -1.3874942549404048e-01 5.7653465110299824e-03 + 31 3.8758816855982753e-01 -9.1841664272267143e-02 2.7177272448705381e-01 + 32 8.5960761691311682e-01 3.3606116109676964e-01 -2.1871878356035168e-01 + 60 8.2141202649191669e-02 8.8970468473315456e-01 6.3991520035969329e-01 + 25 -1.2009758141046861e-01 2.3145940489169153e-01 -1.4422331905460625e-01 + 35 -3.3534451301875257e-01 7.6315242118647919e-01 1.9786973172868705e-01 + 36 -8.9374646041854811e-01 2.4197917322961615e-01 -2.6992324509651450e-01 + 37 1.0210504442609136e-01 -6.0820848407209538e-01 3.5865029760963263e-01 + 38 -1.0619993809979698e+00 3.9811089018874379e-01 3.5952405117685160e-01 + 39 8.2791956824087731e-01 3.2894625512937448e-01 6.3342895150479284e-01 + 40 2.5906832194290130e-01 4.1028277766392890e-01 -7.9906718404861043e-01 + 34 9.3511606834735261e-01 9.9560612334916865e-03 -4.4906889641832226e-01 + 41 1.2072860100394289e-01 -4.8949150979448597e-01 -1.3327122908148614e-01 + 42 4.9837323154800983e-01 7.1268730233784450e-01 5.0839388641850825e-01 + 43 4.7552183906336354e-01 2.2253026044651936e-01 2.3144979242640051e-01 + 45 -1.0693166835880621e+00 1.5621656404253007e-01 2.7928173363139797e-01 + 46 1.7624715562970680e-01 -6.2037140167759158e-02 -1.4161257902108665e-01 + 47 -3.2453071036245351e-01 9.4068735947980930e-01 -3.0837107830047650e-01 + 48 -1.5411909963126691e-01 -1.2869346629638345e+00 4.4935345650188241e-01 + 59 -2.6491714378451203e-01 1.0177801849126309e+00 -1.1679599616063263e+00 + 20 8.9690245559580983e-01 2.7650321162178593e-01 1.6742357523983106e-01 + 50 -1.3303886789107711e+00 -1.5529990630085266e-01 -2.8542234965068802e-02 + 51 -4.8616303965670210e-01 -1.6884797590336122e+00 -2.1451907338099307e-01 + 52 -5.5507159877409340e-01 -6.3158334141685812e-03 -9.1783099618205932e-01 + 53 7.2162860267616891e-01 4.8731569491245130e-02 2.4867359067732797e-01 + 54 1.6630642051274069e-01 -4.2638144910712272e-01 -2.6445598382019220e-01 + 55 -2.0441134825607365e-01 4.5571040697754533e-01 -2.2213597629159157e-01 + 56 -8.4770718683342461e-02 -4.9111916806236844e-01 3.1712955345569516e-01 + 58 4.5871927259400364e-01 1.7620394341774248e-01 5.8850475701154548e-01 + 28 1.4145500088357499e-01 5.7253619379976384e-01 -1.1163727029218857e+00 + 57 -1.5333081269513615e-01 3.7092192234165755e-01 1.1758956057185933e-01 + 61 -1.4701078368063907e+00 -7.2902106713784864e-01 -4.0309074079071339e-01 + 62 -2.6746099007558671e-01 2.8111186444558228e-01 1.6204174885500391e-01 + 63 3.3266077763541602e-01 -8.0829458064608550e-01 6.1676384476099411e-01 + 64 2.5167391424034580e-01 2.2796564437912092e-01 -1.2890802392853251e+00 +run_vdwl: -313.860787111984 +run_coul: 0 +run_stress: ! |- + -1.6823263768839590e+02 -1.6768999741246441e+02 -1.7052199674722613e+02 1.6390291310249023e+00 -1.1679505157505281e+01 8.3282156133592133e-01 +run_forces: ! |2 + 2 1.3393970551420284e+00 -2.7348631215722752e-01 8.7656003775331692e-01 + 4 1.9796308588264225e-01 -1.0920991675744256e+00 -2.9042664590850975e-01 + 5 -6.7902502869429027e-01 5.8080225827896559e-01 4.0066326010564079e-01 + 6 -2.8452906920996102e-01 -5.0017962437035768e-02 3.5551058835958232e-01 + 7 5.8572168296208360e-01 1.2639982283069465e-01 1.0942191505502643e+00 + 8 5.4834728892347584e-01 3.9763083138085875e-01 -2.0200953434963598e-01 + 9 -6.6261848607216822e-01 8.6602325540039729e-02 7.1554334663115393e-01 + 10 -5.5929477357757118e-01 -7.1960607796533893e-01 -1.4907414660880589e-01 + 11 -3.3250197475214827e-01 -1.6273909853793533e-01 5.7153160717989926e-01 + 12 5.5602077298874542e-01 -2.0379120447095356e-01 7.8985281507950367e-02 + 13 4.7488904633716533e-01 -6.2440285917525329e-01 -3.7631163832662479e-01 + 14 -2.0610060963339505e-01 -2.7580114393155308e-01 -4.0418688109324974e-02 + 15 2.7393999196675356e-01 9.3896441261293845e-02 3.7977584906644268e-02 + 16 -2.5162414216378948e-01 -3.7770879299724180e-01 -9.8237995213577300e-01 + 17 4.1878095558303929e-01 8.5733098228963911e-02 9.3859066560991833e-01 + 27 3.1723991553363523e-01 8.0839985005492676e-01 -1.3402533180051507e-01 + 33 -8.1203720540168001e-01 -2.5922326579699062e-02 -5.4822243399849613e-01 + 44 2.7168883603989724e-02 6.3755616007026894e-01 3.1020253558756594e-01 + 3 1.5707457437048239e-01 8.1153282312124486e-01 -9.7289808708836922e-01 + 18 -7.2471999968184031e-01 -4.0664314267379442e-01 -3.4553226041629270e-01 + 19 -4.8747030705768912e-02 -6.2356184236365286e-01 2.0727293941392799e-01 + 21 -1.9258237982505166e-01 1.5417385585229759e-01 8.4979292938095119e-01 + 22 9.6738761320018796e-01 1.7095434510575469e-01 1.6518343230446453e-01 + 23 2.9641139306938402e-01 -6.4726570340463585e-02 -5.2331086264611826e-01 + 24 3.1197417779939834e-01 -1.0653721542318437e+00 2.4613274275617086e-01 + 26 6.6963886061060252e-01 2.7536385988334566e-01 -1.3921312434497593e-01 + 49 -9.0057579467427185e-01 9.1799859977308063e-01 2.2038703217227917e-01 + 1 4.8643934396600130e-01 -9.1232450634319884e-01 -6.2309984412029351e-01 + 29 -2.8301112181298715e-01 -2.8409154360132843e-01 -5.7362916394254039e-02 + 30 -3.1800816279770322e-01 -1.4722530973270934e-01 -7.2299290402477553e-02 + 31 3.7785481684837974e-01 7.8531092069256681e-03 2.0510530482170064e-01 + 32 7.8568752952762599e-01 3.7621476517704400e-01 -2.2195280731906686e-01 + 60 1.7321224005276470e-02 8.9299454909940190e-01 6.4704757395763857e-01 + 25 -1.3222171952250339e-01 1.9287768100206326e-01 -1.0687924976834715e-01 + 35 -3.0228327958249046e-01 7.6823370462453611e-01 1.9710205023672339e-01 + 36 -9.1006885272139959e-01 2.2243300075122782e-01 -1.9589762228314500e-01 + 37 1.4230427618173391e-01 -6.5153952938074511e-01 3.9917398015950634e-01 + 38 -1.1292153420865634e+00 4.0635985553749920e-01 3.6653397360164197e-01 + 39 7.7368280707787718e-01 3.3584965342664047e-01 7.5797843838218371e-01 + 40 2.5675885918999680e-01 4.4146399818678894e-01 -7.5832679932908920e-01 + 34 9.0377460914505237e-01 2.3552141752345435e-03 -5.4249134913710195e-01 + 41 7.9683402196387781e-02 -5.0998040783871934e-01 -1.6942098992427415e-01 + 42 5.3489699626166898e-01 6.2583730851285024e-01 5.3150208371900720e-01 + 43 4.3150956143664604e-01 3.4250825988285294e-01 1.8713887101525389e-01 + 45 -1.0266429053965518e+00 1.6282994454776395e-01 2.4889701484354437e-01 + 46 1.6312811693107243e-01 -4.4541539004164986e-02 -1.6364110665168197e-01 + 47 -3.2467151696196184e-01 8.6794246035160338e-01 -1.8425592835579940e-01 + 48 -2.3621112329277294e-01 -1.1969456647848244e+00 5.3625977722340679e-01 + 59 -3.2367381008922569e-01 9.9079888938550253e-01 -1.1595418529236365e+00 + 20 8.1231821717085750e-01 2.8338281302863888e-01 2.3413423145833803e-01 + 50 -1.3715616895198379e+00 -1.6292020343939573e-01 -1.9130780323660446e-02 + 51 -4.9091785462224702e-01 -1.7653059189178366e+00 -1.9135186975074114e-01 + 52 -6.0209469440153063e-01 -2.7450279959428697e-02 -9.4957073476771980e-01 + 53 8.3244449885719096e-01 8.5426208281090654e-02 2.2294898130454177e-01 + 54 1.2671625051150670e-01 -4.6286116542115052e-01 -3.0047463370941307e-01 + 55 -1.7627349548864624e-01 5.2996202650720814e-01 -2.6201655394381895e-01 + 56 -1.0703773816343104e-01 -5.0757761020025316e-01 2.9114207851626195e-01 + 58 4.7688344146622963e-01 1.9738924583394712e-01 6.4289279657826992e-01 + 28 1.6455519331940571e-01 5.7894206248936431e-01 -1.1166986726492978e+00 + 57 -1.0905709388422054e-01 3.2808607558617775e-01 1.2346604726903815e-01 + 61 -1.4935302461803932e+00 -7.9239986965629849e-01 -4.4857034231877757e-01 + 62 -2.1277755172895357e-01 2.1138904089935556e-01 1.6557437926064877e-01 + 63 3.6167814594592884e-01 -7.6209767583855903e-01 6.3677139949544848e-01 + 64 3.3402210463290194e-01 1.9496574167957959e-01 -1.2154160662568430e+00 +... diff --git a/unittest/formats/CMakeLists.txt b/unittest/formats/CMakeLists.txt new file mode 100644 index 0000000000..848fc0b6c7 --- /dev/null +++ b/unittest/formats/CMakeLists.txt @@ -0,0 +1,11 @@ +add_executable(test_potential_file_reader test_potential_file_reader.cpp) +target_link_libraries(test_potential_file_reader PRIVATE lammps GTest::GMock GTest::GTest) +add_test(NAME PotentialFileReader COMMAND test_potential_file_reader WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) +set_tests_properties(PotentialFileReader PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR}") + +if (PKG_MANYBODY) + add_executable(test_eim_potential_file_reader test_eim_potential_file_reader.cpp) + target_link_libraries(test_eim_potential_file_reader PRIVATE lammps GTest::GMock GTest::GTest) + add_test(NAME EIMPotentialFileReader COMMAND test_eim_potential_file_reader WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + set_tests_properties(EIMPotentialFileReader PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR}") +endif() diff --git a/unittest/formats/test_eim_potential_file_reader.cpp b/unittest/formats/test_eim_potential_file_reader.cpp new file mode 100644 index 0000000000..af5e08ebeb --- /dev/null +++ b/unittest/formats/test_eim_potential_file_reader.cpp @@ -0,0 +1,178 @@ +#include "gmock/gmock.h" +#include "gtest/gtest.h" +#include "lammps.h" +#include "utils.h" +#include "MANYBODY/pair_eim.h" + +#include + +using namespace LAMMPS_NS; + +class EIMPotentialFileReaderTest : public ::testing::Test { +protected: + LAMMPS * lmp; + PairEIM::Setfl setfl; + static const int nelements = 9; + + void SetUp() override { + const char *args[] = {"PotentialFileReaderTest", "-log", "none", "-echo", "screen", "-nocite" }; + char **argv = (char **)args; + int argc = sizeof(args)/sizeof(char *); + ::testing::internal::CaptureStdout(); + lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD); + ::testing::internal::GetCapturedStdout(); + + int npair = nelements*(nelements+1)/2; + setfl.ielement = new int[nelements]; + setfl.mass = new double[nelements]; + setfl.negativity = new double[nelements]; + setfl.ra = new double[nelements]; + setfl.ri = new double[nelements]; + setfl.Ec = new double[nelements]; + setfl.q0 = new double[nelements]; + setfl.rcutphiA = new double[npair]; + setfl.rcutphiR = new double[npair]; + setfl.Eb = new double[npair]; + setfl.r0 = new double[npair]; + setfl.alpha = new double[npair]; + setfl.beta = new double[npair]; + setfl.rcutq = new double[npair]; + setfl.Asigma = new double[npair]; + setfl.rq = new double[npair]; + setfl.rcutsigma = new double[npair]; + setfl.Ac = new double[npair]; + setfl.zeta = new double[npair]; + setfl.rs = new double[npair]; + setfl.tp = new int[npair]; + } + + void TearDown() override { + delete [] setfl.ielement; + delete [] setfl.mass; + delete [] setfl.negativity; + delete [] setfl.ra; + delete [] setfl.ri; + delete [] setfl.Ec; + delete [] setfl.q0; + delete [] setfl.rcutphiA; + delete [] setfl.rcutphiR; + delete [] setfl.Eb; + delete [] setfl.r0; + delete [] setfl.alpha; + delete [] setfl.beta; + delete [] setfl.rcutq; + delete [] setfl.Asigma; + delete [] setfl.rq; + delete [] setfl.rcutsigma; + delete [] setfl.Ac; + delete [] setfl.zeta; + delete [] setfl.rs; + delete [] setfl.tp; + + ::testing::internal::CaptureStdout(); + delete lmp; + ::testing::internal::GetCapturedStdout(); + } +}; + +TEST_F(EIMPotentialFileReaderTest, global_line) { + ::testing::internal::CaptureStdout(); + EIMPotentialFileReader reader(lmp, "ffield.eim"); + ::testing::internal::GetCapturedStdout(); + + reader.get_global(&setfl); + ASSERT_DOUBLE_EQ(setfl.division, 2.0); + ASSERT_DOUBLE_EQ(setfl.rbig, -1.645); + ASSERT_DOUBLE_EQ(setfl.rsmall, 1.645); +} + +TEST_F(EIMPotentialFileReaderTest, element_line_sequential) { + ::testing::internal::CaptureStdout(); + EIMPotentialFileReader reader(lmp, "ffield.eim"); + ::testing::internal::GetCapturedStdout(); + + reader.get_element(&setfl, 0, "Li"); + ASSERT_EQ(setfl.ielement[0], 3); + ASSERT_DOUBLE_EQ(setfl.mass[0], 6.9410e+00); + ASSERT_DOUBLE_EQ(setfl.negativity[0], 9.8000e-01); + ASSERT_DOUBLE_EQ(setfl.ra[0], 1.1220e+00); + ASSERT_DOUBLE_EQ(setfl.ri[0], 1.1220e+00); + ASSERT_DOUBLE_EQ(setfl.Ec[0], -1.6500e+00); + ASSERT_DOUBLE_EQ(setfl.q0[0], 0.0000e+00); + + reader.get_element(&setfl, 1, "Na"); + ASSERT_EQ(setfl.ielement[1], 11); + ASSERT_DOUBLE_EQ(setfl.mass[1], 2.2990e+01); + ASSERT_DOUBLE_EQ(setfl.negativity[1], 9.3000e-01); + ASSERT_DOUBLE_EQ(setfl.ra[1], 1.3690e+00); + ASSERT_DOUBLE_EQ(setfl.ri[1], 1.3690e+00); + ASSERT_DOUBLE_EQ(setfl.Ec[1], -1.1100e+00); + ASSERT_DOUBLE_EQ(setfl.q0[1], 0.0000e+00); +} + +TEST_F(EIMPotentialFileReaderTest, element_line_random) { + ::testing::internal::CaptureStdout(); + EIMPotentialFileReader reader(lmp, "ffield.eim"); + ::testing::internal::GetCapturedStdout(); + + reader.get_element(&setfl, 0, "Id"); + ASSERT_EQ(setfl.ielement[0], 53); + ASSERT_DOUBLE_EQ(setfl.mass[0], 1.2690e+02); + ASSERT_DOUBLE_EQ(setfl.negativity[0], 2.6600e+00); + ASSERT_DOUBLE_EQ(setfl.ra[0], 1.8500e+00); + ASSERT_DOUBLE_EQ(setfl.ri[0], 1.8500e+00); + ASSERT_DOUBLE_EQ(setfl.Ec[0], -1.1100e+00); + ASSERT_DOUBLE_EQ(setfl.q0[0], 0.0000e+00); +} + +TEST_F(EIMPotentialFileReaderTest, pair_line) { + ::testing::internal::CaptureStdout(); + EIMPotentialFileReader reader(lmp, "ffield.eim"); + ::testing::internal::GetCapturedStdout(); + + reader.get_pair(&setfl, 0, "Li", "Li"); + ASSERT_DOUBLE_EQ(setfl.rcutphiA[0], 6.0490e+00); + ASSERT_DOUBLE_EQ(setfl.rcutphiR[0], 6.0490e+00); + ASSERT_DOUBLE_EQ(setfl.Eb[0], -2.5330e-01); + ASSERT_DOUBLE_EQ(setfl.r0[0], 3.6176e+00); + ASSERT_DOUBLE_EQ(setfl.alpha[0], 7.5536e+00); + ASSERT_DOUBLE_EQ(setfl.beta[0], 3.5017e+00); + ASSERT_DOUBLE_EQ(setfl.rcutq[0], 0.0000e+00); + ASSERT_DOUBLE_EQ(setfl.Asigma[0], 2.1778e-02); + ASSERT_DOUBLE_EQ(setfl.rq[0], 2.0000e+00); + ASSERT_DOUBLE_EQ(setfl.rcutsigma[0], 7.0637e+00); + ASSERT_DOUBLE_EQ(setfl.Ac[0], 3.3271e-01); + ASSERT_DOUBLE_EQ(setfl.zeta[0], 6.0000e-01); + ASSERT_DOUBLE_EQ(setfl.rs[0], 2.0000e+00); + ASSERT_EQ(setfl.tp[0], 1); +} + +TEST_F(EIMPotentialFileReaderTest, pair_identical) { + ::testing::internal::CaptureStdout(); + EIMPotentialFileReader reader(lmp, "ffield.eim"); + ::testing::internal::GetCapturedStdout(); + + reader.get_pair(&setfl, 0, "Li", "Na"); + reader.get_pair(&setfl, 1, "Na", "Li"); + ASSERT_DOUBLE_EQ(setfl.rcutphiA[0], setfl.rcutphiA[1]); + ASSERT_DOUBLE_EQ(setfl.rcutphiR[0], setfl.rcutphiR[1]); + ASSERT_DOUBLE_EQ(setfl.Eb[0], setfl.Eb[1]); + ASSERT_DOUBLE_EQ(setfl.r0[0], setfl.r0[1]); + ASSERT_DOUBLE_EQ(setfl.alpha[0], setfl.alpha[1]); + ASSERT_DOUBLE_EQ(setfl.beta[0], setfl.beta[1]); + ASSERT_DOUBLE_EQ(setfl.rcutq[0], setfl.rcutq[1]); + ASSERT_DOUBLE_EQ(setfl.Asigma[0], setfl.Asigma[1]); + ASSERT_DOUBLE_EQ(setfl.rq[0], setfl.rq[1]); + ASSERT_DOUBLE_EQ(setfl.rcutsigma[0], setfl.rcutsigma[1]); + ASSERT_DOUBLE_EQ(setfl.Ac[0], setfl.Ac[1]); + ASSERT_DOUBLE_EQ(setfl.zeta[0], setfl.zeta[1]); + ASSERT_DOUBLE_EQ(setfl.rs[0], setfl.rs[1]); + ASSERT_EQ(setfl.tp[0], setfl.tp[1]); +} + +int main(int argc, char **argv) +{ + MPI_Init(&argc, &argv); + ::testing::InitGoogleMock(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/unittest/formats/test_potential_file_reader.cpp b/unittest/formats/test_potential_file_reader.cpp new file mode 100644 index 0000000000..6ce6a315cb --- /dev/null +++ b/unittest/formats/test_potential_file_reader.cpp @@ -0,0 +1,159 @@ +#include "gmock/gmock.h" +#include "gtest/gtest.h" +#include "potential_file_reader.h" +#include "lammps.h" +#include "utils.h" +#include "MANYBODY/pair_sw.h" +#include "MANYBODY/pair_comb.h" +#include "MANYBODY/pair_comb3.h" +#include "MANYBODY/pair_tersoff.h" +#include "MANYBODY/pair_tersoff_mod.h" +#include "MANYBODY/pair_tersoff_mod_c.h" +#include "MANYBODY/pair_tersoff_zbl.h" +#include "MANYBODY/pair_gw.h" +#include "MANYBODY/pair_gw_zbl.h" +#include "MANYBODY/pair_nb3b_harmonic.h" +#include "MANYBODY/pair_vashishta.h" +#include "MANYBODY/pair_eim.h" + +#include + +using namespace LAMMPS_NS; + +const int LAMMPS_NS::PairSW::NPARAMS_PER_LINE; +const int LAMMPS_NS::PairComb::NPARAMS_PER_LINE; +const int LAMMPS_NS::PairComb3::NPARAMS_PER_LINE; +const int LAMMPS_NS::PairTersoff::NPARAMS_PER_LINE; +const int LAMMPS_NS::PairTersoffMOD::NPARAMS_PER_LINE; +const int LAMMPS_NS::PairTersoffMODC::NPARAMS_PER_LINE; +const int LAMMPS_NS::PairTersoffZBL::NPARAMS_PER_LINE; +const int LAMMPS_NS::PairGW::NPARAMS_PER_LINE; +const int LAMMPS_NS::PairGWZBL::NPARAMS_PER_LINE; +const int LAMMPS_NS::PairNb3bHarmonic::NPARAMS_PER_LINE; +const int LAMMPS_NS::PairVashishta::NPARAMS_PER_LINE; + +class PotentialFileReaderTest : public ::testing::Test { +protected: + LAMMPS * lmp; + + void SetUp() override { + const char *args[] = {"PotentialFileReaderTest", "-log", "none", "-echo", "screen", "-nocite" }; + char **argv = (char **)args; + int argc = sizeof(args)/sizeof(char *); + ::testing::internal::CaptureStdout(); + lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD); + ::testing::internal::GetCapturedStdout(); + } + + void TearDown() override { + ::testing::internal::CaptureStdout(); + delete lmp; + ::testing::internal::GetCapturedStdout(); + } +}; + +TEST_F(PotentialFileReaderTest, Si) { + ::testing::internal::CaptureStdout(); + PotentialFileReader reader(lmp, "Si.sw", "Stillinger-Weber"); + ::testing::internal::GetCapturedStdout(); + + auto line = reader.next_line(PairSW::NPARAMS_PER_LINE); + ASSERT_EQ(utils::count_words(line), PairSW::NPARAMS_PER_LINE); +} + +TEST_F(PotentialFileReaderTest, Comb) { + ::testing::internal::CaptureStdout(); + PotentialFileReader reader(lmp, "ffield.comb", "COMB"); + ::testing::internal::GetCapturedStdout(); + + auto line = reader.next_line(PairComb::NPARAMS_PER_LINE); + ASSERT_EQ(utils::count_words(line), PairComb::NPARAMS_PER_LINE); +} + +TEST_F(PotentialFileReaderTest, Comb3) { + ::testing::internal::CaptureStdout(); + PotentialFileReader reader(lmp, "ffield.comb3", "COMB3"); + ::testing::internal::GetCapturedStdout(); + + auto line = reader.next_line(PairComb3::NPARAMS_PER_LINE); + ASSERT_EQ(utils::count_words(line), PairComb3::NPARAMS_PER_LINE); +} + +TEST_F(PotentialFileReaderTest, Tersoff) { + ::testing::internal::CaptureStdout(); + PotentialFileReader reader(lmp, "Si.tersoff", "Tersoff"); + ::testing::internal::GetCapturedStdout(); + + auto line = reader.next_line(PairTersoff::NPARAMS_PER_LINE); + ASSERT_EQ(utils::count_words(line), PairTersoff::NPARAMS_PER_LINE); +} + +TEST_F(PotentialFileReaderTest, TersoffMod) { + ::testing::internal::CaptureStdout(); + PotentialFileReader reader(lmp, "Si.tersoff.mod", "Tersoff/Mod"); + ::testing::internal::GetCapturedStdout(); + + auto line = reader.next_line(PairTersoffMOD::NPARAMS_PER_LINE); + ASSERT_EQ(utils::count_words(line), PairTersoffMOD::NPARAMS_PER_LINE); +} + +TEST_F(PotentialFileReaderTest, TersoffModC) { + ::testing::internal::CaptureStdout(); + PotentialFileReader reader(lmp, "Si.tersoff.modc", "Tersoff/ModC"); + ::testing::internal::GetCapturedStdout(); + + auto line = reader.next_line(PairTersoffMODC::NPARAMS_PER_LINE); + ASSERT_EQ(utils::count_words(line), PairTersoffMODC::NPARAMS_PER_LINE); +} + +TEST_F(PotentialFileReaderTest, TersoffZBL) { + ::testing::internal::CaptureStdout(); + PotentialFileReader reader(lmp, "SiC.tersoff.zbl", "Tersoff/ZBL"); + ::testing::internal::GetCapturedStdout(); + + auto line = reader.next_line(PairTersoffZBL::NPARAMS_PER_LINE); + ASSERT_EQ(utils::count_words(line), PairTersoffZBL::NPARAMS_PER_LINE); +} + +TEST_F(PotentialFileReaderTest, GW) { + ::testing::internal::CaptureStdout(); + PotentialFileReader reader(lmp, "SiC.gw", "GW"); + ::testing::internal::GetCapturedStdout(); + + auto line = reader.next_line(PairGW::NPARAMS_PER_LINE); + ASSERT_EQ(utils::count_words(line), PairGW::NPARAMS_PER_LINE); +} + +TEST_F(PotentialFileReaderTest, GWZBL) { + ::testing::internal::CaptureStdout(); + PotentialFileReader reader(lmp, "SiC.gw.zbl", "GW/ZBL"); + ::testing::internal::GetCapturedStdout(); + + auto line = reader.next_line(PairGWZBL::NPARAMS_PER_LINE); + ASSERT_EQ(utils::count_words(line), PairGWZBL::NPARAMS_PER_LINE); +} + +TEST_F(PotentialFileReaderTest, Nb3bHarmonic) { + ::testing::internal::CaptureStdout(); + PotentialFileReader reader(lmp, "MOH.nb3b.harmonic", "NB3B Harmonic"); + ::testing::internal::GetCapturedStdout(); + + auto line = reader.next_line(PairNb3bHarmonic::NPARAMS_PER_LINE); + ASSERT_EQ(utils::count_words(line), PairNb3bHarmonic::NPARAMS_PER_LINE); +} + +TEST_F(PotentialFileReaderTest, Vashishta) { + ::testing::internal::CaptureStdout(); + PotentialFileReader reader(lmp, "SiC.vashishta", "Vashishta"); + ::testing::internal::GetCapturedStdout(); + + auto line = reader.next_line(PairVashishta::NPARAMS_PER_LINE); + ASSERT_EQ(utils::count_words(line), PairVashishta::NPARAMS_PER_LINE); +} + +int main(int argc, char **argv) +{ + MPI_Init(&argc, &argv); + ::testing::InitGoogleMock(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/unittest/utils/CMakeLists.txt b/unittest/utils/CMakeLists.txt new file mode 100644 index 0000000000..5df52f1f9f --- /dev/null +++ b/unittest/utils/CMakeLists.txt @@ -0,0 +1,7 @@ +add_executable(test_tokenizer test_tokenizer.cpp) +target_link_libraries(test_tokenizer PRIVATE lammps GTest::GMockMain GTest::GMock GTest::GTest) +add_test(Tokenizer test_tokenizer) + +add_executable(test_utils test_utils.cpp) +target_link_libraries(test_utils PRIVATE lammps GTest::GMockMain GTest::GMock GTest::GTest) +add_test(Utils test_utils) diff --git a/unittest/utils/test_tokenizer.cpp b/unittest/utils/test_tokenizer.cpp new file mode 100644 index 0000000000..23f2e85d98 --- /dev/null +++ b/unittest/utils/test_tokenizer.cpp @@ -0,0 +1,101 @@ +#include +#include +#include "tokenizer.h" + +using namespace LAMMPS_NS; +using ::testing::Eq; + +TEST(Tokenizer, empty_string) { + Tokenizer t("", " "); + ASSERT_EQ(t.count(), 0); +} + +TEST(Tokenizer, whitespace_only) { + Tokenizer t(" ", " "); + ASSERT_EQ(t.count(), 0); +} + +TEST(Tokenizer, single_word) { + Tokenizer t("test", " "); + ASSERT_EQ(t.count(), 1); +} + +TEST(Tokenizer, two_words) { + Tokenizer t("test word", " "); + ASSERT_EQ(t.count(), 2); +} + +TEST(Tokenizer, prefix_seperators) { + Tokenizer t(" test word", " "); + ASSERT_EQ(t.count(), 2); +} + +TEST(Tokenizer, postfix_seperators) { + Tokenizer t("test word ", " "); + ASSERT_EQ(t.count(), 2); +} + +TEST(Tokenizer, iterate_words) { + Tokenizer t(" test word ", " "); + ASSERT_THAT(t[0], Eq("test")); + ASSERT_THAT(t[1], Eq("word")); + ASSERT_EQ(t.count(), 2); +} + +TEST(Tokenizer, default_seperators) { + Tokenizer t(" \r\n test \t word \f"); + ASSERT_THAT(t[0], Eq("test")); + ASSERT_THAT(t[1], Eq("word")); + ASSERT_EQ(t.count(), 2); +} + +TEST(Tokenizer, for_loop) { + Tokenizer t(" \r\n test \t word \f"); + std::vector list; + + for(auto word : t) { + list.push_back(word); + } + ASSERT_THAT(list[0], Eq("test")); + ASSERT_THAT(list[1], Eq("word")); +} + +TEST(ValueTokenizer, empty_string) { + ValueTokenizer values(""); + ASSERT_FALSE(values.has_next()); +} + +TEST(ValueTokenizer, bad_integer) { + ValueTokenizer values("f10"); + ASSERT_THROW(values.next_int(), InvalidIntegerException); +} + +TEST(ValueTokenizer, bad_double) { + ValueTokenizer values("1a.0"); + ASSERT_THROW(values.next_double(), InvalidFloatException); +} + +TEST(ValueTokenizer, valid_int) { + ValueTokenizer values("10"); + ASSERT_EQ(values.next_int(), 10); +} + +TEST(ValueTokenizer, valid_tagint) { + ValueTokenizer values("42"); + ASSERT_EQ(values.next_tagint(), 42); +} + +TEST(ValueTokenizer, valid_bigint) { + ValueTokenizer values("42"); + ASSERT_EQ(values.next_bigint(), 42); +} + +TEST(ValueTokenizer, valid_double) { + ValueTokenizer values("3.14"); + ASSERT_DOUBLE_EQ(values.next_double(), 3.14); +} + +TEST(ValueTokenizer, valid_double_with_exponential) { + ValueTokenizer values("3.14e22"); + ASSERT_DOUBLE_EQ(values.next_double(), 3.14e22); +} diff --git a/unittest/utils/test_utils.cpp b/unittest/utils/test_utils.cpp new file mode 100644 index 0000000000..f7f298920f --- /dev/null +++ b/unittest/utils/test_utils.cpp @@ -0,0 +1,52 @@ +#include +#include +#include "utils.h" +#include + +using namespace LAMMPS_NS; +using ::testing::Eq; + +TEST(Utils, trim_comment) { + auto trimmed = utils::trim_comment("some text # comment"); + ASSERT_THAT(trimmed, Eq("some text ")); +} + +TEST(Utils, count_words) { + ASSERT_EQ(utils::count_words("some text # comment"), 2); +} + +TEST(Utils, valid_integer) { + ASSERT_TRUE(utils::is_integer("10")); +} + +TEST(Utils, valid_double) { + ASSERT_TRUE(utils::is_double("10.0")); +} + +TEST(Utils, empty_not_an_integer) { + ASSERT_FALSE(utils::is_integer("")); +} + +TEST(Utils, empty_not_a_double) { + ASSERT_FALSE(utils::is_double("")); +} + +TEST(Utils, double_not_an_integer) { + ASSERT_FALSE(utils::is_integer("10.0")); +} + +TEST(Utils, integer_is_double) { + ASSERT_TRUE(utils::is_double("10")); +} + +TEST(Utils, is_double_with_exponential) { + ASSERT_TRUE(utils::is_double("10e22")); +} + +TEST(Utils, is_double_with_neg_exponential) { + ASSERT_TRUE(utils::is_double("10e-22")); +} + +TEST(Utils, signed_double_and_exponential) { + ASSERT_TRUE(utils::is_double("-10E-22")); +}