diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index b34e3a4d1f..e5dc5b194d 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -57,7 +57,6 @@ check_for_autogen_files(${LAMMPS_SOURCE_DIR}) # compiler tests # these need ot be done early (before further tests). ##################################################################### -include(CheckCCompilerFlag) include(CheckIncludeFileCXX) # set required compiler flags and compiler/CPU arch specific optimizations @@ -83,15 +82,6 @@ set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) -# GNU compiler specific features for testing -if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") - option(ENABLE_COVERAGE "Enable collecting code coverage data" OFF) - mark_as_advanced(ENABLE_COVERAGE) - if(ENABLE_COVERAGE) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") - endif() -endif() - ######################################################################## # User input options # ######################################################################## @@ -248,6 +238,48 @@ if(BUILD_OMP) target_link_libraries(lammps PRIVATE OpenMP::OpenMP_CXX) endif() +# Compiler specific features for testing +if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") + option(ENABLE_COVERAGE "Enable collecting code coverage data" OFF) + mark_as_advanced(ENABLE_COVERAGE) + if(ENABLE_COVERAGE) + if(CMAKE_VERSION VERSION_LESS 3.13) + if(CMAKE_CXX_FLAGS) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_${CMAKE_BUILD_TYPE}_FLAGS} --coverage") + endif() + else() + target_compile_options(lammps PUBLIC --coverage) + target_link_options(lammps PUBLIC --coverage) + endif() + endif() +endif() + +set(ENABLE_SANITIZER "none" CACHE STRING "Select a code sanitizer option (none (default), address, thread, undefined)") +mark_as_advanced(ENABLE_SANITIZER) +set(ENABLE_SANITIZER_VALUES none address thread undefined) +set_property(CACHE ENABLE_SANITIZER PROPERTY STRINGS ${ENABLE_SANITIZER_VALUES}) +validate_option(ENABLE_SANITIZER ENABLE_SANITIZER_VALUES) +string(TOLOWER ${ENABLE_SANITIZER} ENABLE_SANITIZER) +if(NOT ENABLE_SANITIZER STREQUAL "none") + if((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")) + if(CMAKE_VERSION VERSION_LESS 3.13) + if(CMAKE_CXX_FLAGS) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=${ENABLE_SANITIZER}") + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_${CMAKE_BUILD_TYPE}_FLAGS} -fsanitize=${ENABLE_SANITIZER}") + endif() + else() + target_compile_options(lammps PUBLIC -fsanitize=${ENABLE_SANITIZER}) + target_link_options(lammps PUBLIC -fsanitize=${ENABLE_SANITIZER}) + endif() + else() + message(WARNING "ENABLE_SANITIZER option not supported by ${CMAKE_CXX_COMPILER_ID} compilers. Ignoring.") + set(ENABLE_SANITIZER "none") + endif() +endif() + if(PKG_MSCG OR PKG_USER-ATC OR PKG_USER-AWPMD OR PKG_USER-QUIP OR PKG_LATTE) enable_language(C) find_package(LAPACK) @@ -335,15 +367,8 @@ endforeach() set(CMAKE_TUNE_FLAGS "${CMAKE_TUNE_DEFAULT}" CACHE STRING "Compiler specific optimization or instrumentation") separate_arguments(CMAKE_TUNE_FLAGS) -include(CheckCXXCompilerFlag) foreach(_FLAG ${CMAKE_TUNE_FLAGS}) - string(REGEX REPLACE "[=\"]" "" _FLAGX ${_FLAG}) - check_cxx_compiler_flag("${_FLAG}" COMPILER_SUPPORTS${_FLAGX}) - if(COMPILER_SUPPORTS${_FLAGX}) - target_compile_options(lammps PRIVATE ${_FLAG}) - else() - message(WARNING "${_FLAG} found in CMAKE_TUNE_FLAGS, but not supported by the compiler, skipping") - endif() + target_compile_options(lammps PRIVATE ${_FLAG}) endforeach() ######################################################################## # Basic system tests (standard libraries, headers, functions, types) # diff --git a/cmake/Modules/Packages/USER-SCAFACOS.cmake b/cmake/Modules/Packages/USER-SCAFACOS.cmake index a6851210b2..dc5c400c36 100644 --- a/cmake/Modules/Packages/USER-SCAFACOS.cmake +++ b/cmake/Modules/Packages/USER-SCAFACOS.cmake @@ -14,40 +14,23 @@ endif() option(DOWNLOAD_SCAFACOS "Download ScaFaCoS library instead of using an already installed one" ${DOWNLOAD_SCAFACOS_DEFAULT}) if(DOWNLOAD_SCAFACOS) message(STATUS "ScaFaCoS download requested - we will build our own") - # create variables to pass our compiler flags along to the subsystem compile - # need to apply -fallow-argument-mismatch, if the fortran compiler supports it - include(CheckFortranCompilerFlag) - check_fortran_compiler_flag("-fallow-argument-mismatch" GNUFortran_ARGUMENT_MISMATCH_FLAG) - if(GNUFortran_ARGUMENT_MISMATCH_FLAG) - set(APPEND_Fortran_FLAG "-fallow-argument-mismatch") - endif() - if(CMAKE_Fortran_FLAGS) - set(SCAFACOS_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${APPEND_Fortran_FLAG}") - else() - set(SCAFACOS_Fortran_FLAGS "${CMAKE_Fortran_${CMAKE_BUILD_TYPE}_FLAGS} ${APPEND_Fortran_FLAG}") - endif() - if(CMAKE_CXX_FLAGS) - set(SCAFACOS_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - else() - set(SCAFACOS_CXX_FLAGS "${CMAKE_CXX_${CMAKE_BUILD_TYPE}_FLAGS}") - endif() - if(CMAKE_C_FLAGS) - set(SCAFACOS_C_FLAGS "${CMAKE_C_FLAGS}") - else() - set(SCAFACOS_C_FLAGS "${CMAKE_C_${CMAKE_BUILD_TYPE}_FLAGS}") - endif() + + # version 1.0.1 needs a patch to compile and linke cleanly with GCC 10 and later. + file(DOWNLOAD https://download.lammps.org/thirdparty/scafacos-1.0.1-fix.diff ${CMAKE_CURRENT_BINARY_DIR}/scafacos-1.0.1.fix.diff + EXPECTED_HASH MD5=4baa1333bb28fcce102d505e1992d032) include(ExternalProject) ExternalProject_Add(scafacos_build URL https://github.com/scafacos/scafacos/releases/download/v1.0.1/scafacos-1.0.1.tar.gz URL_MD5 bd46d74e3296bd8a444d731bb10c1738 + PATCH_COMMAND patch -p1 < ${CMAKE_CURRENT_BINARY_DIR}/scafacos-1.0.1.fix.diff CONFIGURE_COMMAND /configure --prefix= --disable-doc --enable-fcs-solvers=fmm,p2nfft,direct,ewald,p3m --with-internal-fftw --with-internal-pfft --with-internal-pnfft ${CONFIGURE_REQUEST_PIC} - FC=${CMAKE_MPI_Fortran_COMPILER} FCFLAGS=${SCAFACOS_Fortran_FLAGS} - CXX=${CMAKE_MPI_CXX_COMPILER} CXXFLAGS=${SCAFACOS_CXX_FLAGS} - CC=${CMAKE_MPI_C_COMPILER} CFLAGS=${SCAFACOS_C_FLAGS} + FC=${CMAKE_MPI_Fortran_COMPILER} + CXX=${CMAKE_MPI_CXX_COMPILER} + CC=${CMAKE_MPI_C_COMPILER} F77= BUILD_BYPRODUCTS /lib/libfcs.a diff --git a/doc/src/Build_development.rst b/doc/src/Build_development.rst index cf7d8c7955..deb9d5b3cb 100644 --- a/doc/src/Build_development.rst +++ b/doc/src/Build_development.rst @@ -8,8 +8,8 @@ useful during development, testing or debugging. .. _compilation: -Verify compilation flags ------------------------- +Monitor compilation flags +------------------------- Sometimes it is necessary to verify the complete sequence of compilation flags generated by the CMake build. To enable a more verbose output during @@ -19,7 +19,8 @@ compilation you can use the following option. -D CMAKE_VERBOSE_MAKEFILE=value # value = no (default) or yes -Another way of doing this without reconfiguration is calling make with variable VERBOSE set to 1: +Another way of doing this without reconfiguration is calling make with +variable VERBOSE set to 1: .. code-block:: bash @@ -33,25 +34,26 @@ Address, Undefined Behavior, and Thread Sanitizer Support --------------------------------------------------------- Compilers such as GCC and Clang support generating instrumented binaries -which use different sanitizer libraries to detect problems in code +which use different sanitizer libraries to detect problems in the code during run-time. They can detect issues like: - `memory leaks `_ - `undefined behavior `_ - `data races `_ -Please note that this kind of instrumentation usually comes with a small -performance hit (much less than using tools like `Valgrind -`_). The to enable these features additional -compiler flags need to be added to the compilation and linking stages. -This is most easily done through setting the ``CMAKE_TUNE_FLAGS`` -variable during configuration. Examples: +Please note that this kind of instrumentation usually comes with a +performance hit (but much less than using tools like `Valgrind +`_ with a more low level approach). The to enable +these features additional compiler flags need to be added to the +compilation and linking stages. This is done through setting the +``ENABLE_SANITIZER`` variable during configuration. Examples: .. code-block:: bash - -D CMAKE_TUNE_FLAGS=-fsanitize=address # enable address sanitizer / memory leak checker - -D CMAKE_TUNE_FLAGS=-fsanitize=undefined # enable undefined behavior sanitizer - -D CMAKE_TUNE_FLAGS=-fsanitize=thread # enable thread sanitizer + -D ENABLE_SANITIZER=none # no sanitizer active (default) + -D ENABLE_SANITIZER=address # enable address sanitizer / memory leak checker + -D ENABLE_SANITIZER=undefined # enable undefined behavior sanitizer + -D ENABLE_SANITIZER=thread # enable thread sanitizer ---------- @@ -86,19 +88,21 @@ The output of this command will be looking something like this:: [...]$ ctest Test project /home/akohlmey/compile/lammps/build-testing Start 1: MolPairStyle:hybrid-overlay - 1/26 Test #1: MolPairStyle:hybrid-overlay ......... Passed 0.02 sec + 1/109 Test #1: MolPairStyle:hybrid-overlay ......... Passed 0.02 sec Start 2: MolPairStyle:hybrid - 2/26 Test #2: MolPairStyle:hybrid ................. Passed 0.01 sec + 2/109 Test #2: MolPairStyle:hybrid ................. Passed 0.01 sec Start 3: MolPairStyle:lj_class2 [...] - Start 25: AngleStyle:harmonic - 25/26 Test #25: AngleStyle:harmonic ................. Passed 0.01 sec - Start 26: AngleStyle:zero - 26/26 Test #26: AngleStyle:zero ..................... Passed 0.01 sec + Start 107: PotentialFileReader + 107/109 Test #107: PotentialFileReader ................ Passed 0.04 sec + Start 108: EIMPotentialFileReader + 108/109 Test #108: EIMPotentialFileReader ............. Passed 0.03 sec + Start 109: TestSimpleCommands + 109/109 Test #109: TestSimpleCommands ................. Passed 0.02 sec 100% tests passed, 0 tests failed out of 26 - Total Test time (real) = 0.27 sec + Total Test time (real) = 25.57 sec The ``ctest`` command has many options, the most important ones are: @@ -193,8 +197,8 @@ 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. +recording (see next section) to confirm how well the tests cover the code +paths in the individual source files. The force style test programs have a common set of options: @@ -211,6 +215,14 @@ The force style test programs have a common set of options: * - -v - verbose output: also print the executed LAMMPS commands +The ``ctest`` tool has no mechanism to directly pass flags to the individual +test programs, but a workaround has been implmented where these flags can be +set in an environment variable ``TEST_ARGS``. Example: + +.. code-block:: bash + + env TEST_ARGS=-s ctest -V -R BondStyle + 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 @@ -244,6 +256,16 @@ and working. of mis-compiled code (or an undesired large loss of precision due to significant reordering of operations and thus less error cancellation). +Tests for other components and utility functions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Additional tests that validate utility functions or specific components +of LAMMPS are implemented as standalone executable which may, or may not +require creating a suitable LAMMPS instance. These tests are more specific +and do not require YAML format input files. To add a test, either an +existing source file needs to be extended or a new file added, which in turn +requires additions to the ``CMakeLists.txt`` file in the source folder. + Collect and visualize code coverage metrics ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -306,3 +328,23 @@ The images below illustrate how the data is presented. :target: JPG/coverage-file-branches.png Source page with branches + +Coding style utilities +---------------------- + +To aid with enforcing some of the coding style conventions in LAMMPS +some additional build targets have been added. These require Python 3.5 +or later and will only work on Unix-like operating and file systems. +The following options are available. + +.. code-block:: bash + + make check-whitespace # generate coverage report in HTML format + make fix-whitespace # generate coverage report in XML format + make check-permissions # delete folder with HTML format coverage report + make fix-permissions # delete all collected coverage data and HTML output + +For the code in the ``unittest`` tree we are using the `clang-format` +tool (Clang version 8.0 or later is required). If available, the source +code files in the ``unittest`` tree can be updated to conform to the +formatting settings using ``make format-tests``. diff --git a/doc/src/pair_mdf.rst b/doc/src/pair_mdf.rst index 983e817f1d..9cb9eaa6b2 100644 --- a/doc/src/pair_mdf.rst +++ b/doc/src/pair_mdf.rst @@ -85,7 +85,8 @@ standard 12-6 Lennard-Jones written in the epsilon/sigma form: .. math:: - E(r) = 4\epsilon\biggl[\bigl(\frac{\sigma}{r}\bigr)^{12} - \bigl(\frac{\sigma}{r}\bigr)^6\biggr] + E(r) = 4 \epsilon \left[ \left(\frac{\sigma}{r}\right)^{12} - + \left(\frac{\sigma}{r}\right)^6 \right] Either the first two or all of the following coefficients must be defined for each pair of atoms types via the pair_coeff command as in @@ -141,7 +142,7 @@ given or both left out: **Mixing, shift, table, tail correction, restart, rRESPA info**\ : For atom type pairs I,J and I != J, the :math:`\epsilon` and -:math:`sigma` coefficients and cutoff distances for the lj/mdf pair +:math:`\sigma` coefficients and cutoff distances for the lj/mdf pair style can be mixed. The default mix value is *geometric*\ . See the "pair_modify" command for details. The other two pair styles buck/mdf and lennard/mdf do not support mixing, so all I,J pairs of coefficients diff --git a/examples/snap/in.snap.Mo_Chen b/examples/snap/in.snap.Mo_Chen index bb9fb0900d..b58c510ea9 100644 --- a/examples/snap/in.snap.Mo_Chen +++ b/examples/snap/in.snap.Mo_Chen @@ -39,7 +39,7 @@ neigh_modify once no every 1 delay 0 check yes # Run MD -velocity all create 300.0 4928459 +velocity all create 300.0 4928459 loop geom fix 1 all nve run ${nsteps} diff --git a/examples/snap/in.snap.Ta06A b/examples/snap/in.snap.Ta06A index 0ca5275e97..59618786b9 100644 --- a/examples/snap/in.snap.Ta06A +++ b/examples/snap/in.snap.Ta06A @@ -39,7 +39,7 @@ neigh_modify once no every 1 delay 0 check yes # Run MD -velocity all create 300.0 4928459 +velocity all create 300.0 4928459 loop geom fix 1 all nve run ${nsteps} diff --git a/examples/snap/in.snap.W.2940 b/examples/snap/in.snap.W.2940 index 7e59b5198e..31aa958340 100644 --- a/examples/snap/in.snap.W.2940 +++ b/examples/snap/in.snap.W.2940 @@ -39,7 +39,7 @@ neigh_modify once no every 1 delay 0 check yes # Run MD -velocity all create 300.0 4928459 +velocity all create 300.0 4928459 loop geom fix 1 all nve run ${nsteps} diff --git a/examples/snap/in.snap.WBe.PRB2019 b/examples/snap/in.snap.WBe.PRB2019 index 6b342ea56f..8ef95b9f08 100644 --- a/examples/snap/in.snap.WBe.PRB2019 +++ b/examples/snap/in.snap.WBe.PRB2019 @@ -42,7 +42,7 @@ neigh_modify once no every 1 delay 0 check yes # Run MD -velocity all create 300.0 4928459 +velocity all create 300.0 4928459 loop geom fix 1 all nve run ${nsteps} diff --git a/examples/snap/in.snap.hybrid.WSNAP.HePair b/examples/snap/in.snap.hybrid.WSNAP.HePair index 1092c28119..9ad53d60db 100644 --- a/examples/snap/in.snap.hybrid.WSNAP.HePair +++ b/examples/snap/in.snap.hybrid.WSNAP.HePair @@ -42,7 +42,7 @@ neigh_modify once no every 1 delay 0 check yes # Run MD -velocity all create 300.0 4928459 +velocity all create 300.0 4928459 loop geom fix 1 all nve run ${nsteps} diff --git a/examples/snap/log.27Nov18.snap.Mo_Chen.g++.1 b/examples/snap/log.15Jun20.snap.Mo_Chen.g++.1 similarity index 50% rename from examples/snap/log.27Nov18.snap.Mo_Chen.g++.1 rename to examples/snap/log.15Jun20.snap.Mo_Chen.g++.1 index 0ca8406d10..5ba22dcaee 100644 --- a/examples/snap/log.27Nov18.snap.Mo_Chen.g++.1 +++ b/examples/snap/log.15Jun20.snap.Mo_Chen.g++.1 @@ -1,13 +1,13 @@ -LAMMPS (27 Nov 2018) +LAMMPS (15 Jun 2020) using 1 OpenMP thread(s) per MPI task -# Demonstrate SNAP Ta potential +# Demonstrate SNAP Mo potential # Initialize simulation variable nsteps index 100 variable nrep equal 4 variable a equal 3.160 -units metal +units metal # generate the box and atom positions using a BCC lattice @@ -18,21 +18,21 @@ variable ny equal 4 variable nz equal ${nrep} variable nz equal 4 -boundary p p p +boundary p p p lattice bcc $a lattice bcc 3.16 Lattice spacing in x,y,z = 3.16 3.16 3.16 -region box block 0 ${nx} 0 ${ny} 0 ${nz} -region box block 0 4 0 ${ny} 0 ${nz} -region box block 0 4 0 4 0 ${nz} -region box block 0 4 0 4 0 4 -create_box 1 box -Created orthogonal box = (0 0 0) to (12.64 12.64 12.64) +region box block 0 ${nx} 0 ${ny} 0 ${nz} +region box block 0 4 0 ${ny} 0 ${nz} +region box block 0 4 0 4 0 ${nz} +region box block 0 4 0 4 0 4 +create_box 1 box +Created orthogonal box = (0.0 0.0 0.0) to (12.64 12.64 12.64) 1 by 1 by 1 MPI processor grid -create_atoms 1 box +create_atoms 1 box Created 128 atoms - Time spent = 0.00029707 secs + create_atoms CPU = 0.000 seconds mass 1 183.84 @@ -40,11 +40,11 @@ mass 1 183.84 include Mo_Chen_PRM2017.snap -# DATE: 2017-09-18 CONTRIBUTOR: Chi Chen CITATION: C. Chen, Z. Deng, R. Tran, H. Tang, I.-H. Chu, S. P. Ong, "Accurate force field for molybdenum by machine learning large materials data" Physical Review Materials 1, 04 3603 (2017) +# DATE: 2017-09-18 UNITS: metal CONTRIBUTOR: Chi Chen CITATION: C. Chen, Z. Deng, R. Tran, H. Tang, I.-H. Chu, S. P. Ong, "Accurate force field for molybdenum by machine learning large materials data" Physical Review Materials 1, 04 3603 (2017) # Generated by Materials Virtual Lab # Definition of SNAP potential. pair_style snap -pair_coeff * * Mo_Chen_PRM2017.snapcoeff Mo Mo_Chen_PRM2017.snapparam Mo +pair_coeff * * Mo_Chen_PRM2017.snapcoeff Mo_Chen_PRM2017.snapparam Mo Reading potential file Mo_Chen_PRM2017.snapcoeff with DATE: 2017-09-18 SNAP Element = Mo, Radius 0.5, Weight 1 Reading potential file Mo_Chen_PRM2017.snapparam with DATE: 2017-09-18 @@ -54,7 +54,7 @@ SNAP keyword twojmax 6 # Setup output -thermo 10 +thermo 10 thermo_modify norm yes # Set up NVE run @@ -65,7 +65,7 @@ neigh_modify once no every 1 delay 0 check yes # Run MD -velocity all create 300.0 4928459 +velocity all create 300.0 4928459 loop geom fix 1 all nve run ${nsteps} run 100 @@ -81,33 +81,33 @@ Neighbor list info ... pair build: full/bin/atomonly stencil: full/bin/3d bin: standard -Per MPI rank memory allocation (min/avg/max) = 3.507 | 3.507 | 3.507 Mbytes +Per MPI rank memory allocation (min/avg/max) = 3.335 | 3.335 | 3.335 Mbytes Step Temp E_pair E_mol TotEng Press 0 300 -22.405975 0 -22.3675 2575.7657 - 10 294.77555 -22.405305 0 -22.3675 2756.6894 - 20 279.53011 -22.40335 0 -22.3675 3285.8272 - 30 255.52174 -22.40027 0 -22.3675 4122.8933 - 40 224.7299 -22.396321 0 -22.367499 5204.3499 - 50 189.67529 -22.391825 0 -22.367499 6449.1308 - 60 153.18862 -22.387145 0 -22.367499 7765.911 - 70 118.14998 -22.382652 0 -22.367499 9061.1616 - 80 87.224916 -22.378685 0 -22.367499 10247.68 - 90 62.623892 -22.37553 0 -22.367498 11250.067 - 100 45.9103 -22.373386 0 -22.367498 12011.726 -Loop time of 7.00873 on 1 procs for 100 steps with 128 atoms + 10 294.8148 -22.40531 0 -22.3675 2762.0942 + 20 279.68628 -22.40337 0 -22.3675 3306.7656 + 30 255.84798 -22.400312 0 -22.3675 4168.2979 + 40 225.22346 -22.396384 0 -22.367499 5281.9537 + 50 190.25143 -22.391899 0 -22.367499 6565.6626 + 60 153.66642 -22.387207 0 -22.367499 7927.3186 + 70 118.25575 -22.382665 0 -22.367499 9271.9554 + 80 86.616338 -22.378607 0 -22.367499 10510.959 + 90 60.935787 -22.375314 0 -22.367498 11568.261 + 100 42.815823 -22.37299 0 -22.367498 12385.433 +Loop time of 0.897752 on 1 procs for 100 steps with 128 atoms -Performance: 0.616 ns/day, 38.937 hours/ns, 14.268 timesteps/s -99.7% CPU use with 1 MPI tasks x 1 OpenMP threads +Performance: 4.812 ns/day, 4.988 hours/ns, 111.389 timesteps/s +99.9% CPU use with 1 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 7.0068 | 7.0068 | 7.0068 | 0.0 | 99.97 +Pair | 0.89711 | 0.89711 | 0.89711 | 0.0 | 99.93 Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0.00083661 | 0.00083661 | 0.00083661 | 0.0 | 0.01 -Output | 0.00025535 | 0.00025535 | 0.00025535 | 0.0 | 0.00 -Modify | 0.00034285 | 0.00034285 | 0.00034285 | 0.0 | 0.00 -Other | | 0.0005035 | | | 0.01 +Comm | 0.0002501 | 0.0002501 | 0.0002501 | 0.0 | 0.03 +Output | 0.00013161 | 0.00013161 | 0.00013161 | 0.0 | 0.01 +Modify | 0.00010276 | 0.00010276 | 0.00010276 | 0.0 | 0.01 +Other | | 0.0001559 | | | 0.02 Nlocal: 128 ave 128 max 128 min Histogram: 1 0 0 0 0 0 0 0 0 0 @@ -123,4 +123,4 @@ Ave neighs/atom = 58 Neighbor list builds = 0 Dangerous builds = 0 -Total wall time: 0:00:07 +Total wall time: 0:00:00 diff --git a/examples/snap/log.27Nov18.snap.Mo_Chen.g++.4 b/examples/snap/log.15Jun20.snap.Mo_Chen.g++.4 similarity index 50% rename from examples/snap/log.27Nov18.snap.Mo_Chen.g++.4 rename to examples/snap/log.15Jun20.snap.Mo_Chen.g++.4 index a8c3d6858c..2574882d08 100644 --- a/examples/snap/log.27Nov18.snap.Mo_Chen.g++.4 +++ b/examples/snap/log.15Jun20.snap.Mo_Chen.g++.4 @@ -1,13 +1,13 @@ -LAMMPS (27 Nov 2018) +LAMMPS (15 Jun 2020) using 1 OpenMP thread(s) per MPI task -# Demonstrate SNAP Ta potential +# Demonstrate SNAP Mo potential # Initialize simulation variable nsteps index 100 variable nrep equal 4 variable a equal 3.160 -units metal +units metal # generate the box and atom positions using a BCC lattice @@ -18,21 +18,21 @@ variable ny equal 4 variable nz equal ${nrep} variable nz equal 4 -boundary p p p +boundary p p p lattice bcc $a lattice bcc 3.16 Lattice spacing in x,y,z = 3.16 3.16 3.16 -region box block 0 ${nx} 0 ${ny} 0 ${nz} -region box block 0 4 0 ${ny} 0 ${nz} -region box block 0 4 0 4 0 ${nz} -region box block 0 4 0 4 0 4 -create_box 1 box -Created orthogonal box = (0 0 0) to (12.64 12.64 12.64) +region box block 0 ${nx} 0 ${ny} 0 ${nz} +region box block 0 4 0 ${ny} 0 ${nz} +region box block 0 4 0 4 0 ${nz} +region box block 0 4 0 4 0 4 +create_box 1 box +Created orthogonal box = (0.0 0.0 0.0) to (12.64 12.64 12.64) 1 by 2 by 2 MPI processor grid -create_atoms 1 box +create_atoms 1 box Created 128 atoms - Time spent = 0.000289917 secs + create_atoms CPU = 0.000 seconds mass 1 183.84 @@ -40,11 +40,11 @@ mass 1 183.84 include Mo_Chen_PRM2017.snap -# DATE: 2017-09-18 CONTRIBUTOR: Chi Chen CITATION: C. Chen, Z. Deng, R. Tran, H. Tang, I.-H. Chu, S. P. Ong, "Accurate force field for molybdenum by machine learning large materials data" Physical Review Materials 1, 04 3603 (2017) +# DATE: 2017-09-18 UNITS: metal CONTRIBUTOR: Chi Chen CITATION: C. Chen, Z. Deng, R. Tran, H. Tang, I.-H. Chu, S. P. Ong, "Accurate force field for molybdenum by machine learning large materials data" Physical Review Materials 1, 04 3603 (2017) # Generated by Materials Virtual Lab # Definition of SNAP potential. pair_style snap -pair_coeff * * Mo_Chen_PRM2017.snapcoeff Mo Mo_Chen_PRM2017.snapparam Mo +pair_coeff * * Mo_Chen_PRM2017.snapcoeff Mo_Chen_PRM2017.snapparam Mo Reading potential file Mo_Chen_PRM2017.snapcoeff with DATE: 2017-09-18 SNAP Element = Mo, Radius 0.5, Weight 1 Reading potential file Mo_Chen_PRM2017.snapparam with DATE: 2017-09-18 @@ -54,7 +54,7 @@ SNAP keyword twojmax 6 # Setup output -thermo 10 +thermo 10 thermo_modify norm yes # Set up NVE run @@ -65,7 +65,7 @@ neigh_modify once no every 1 delay 0 check yes # Run MD -velocity all create 300.0 4928459 +velocity all create 300.0 4928459 loop geom fix 1 all nve run ${nsteps} run 100 @@ -81,33 +81,33 @@ Neighbor list info ... pair build: full/bin/atomonly stencil: full/bin/3d bin: standard -Per MPI rank memory allocation (min/avg/max) = 3.486 | 3.486 | 3.486 Mbytes +Per MPI rank memory allocation (min/avg/max) = 3.271 | 3.271 | 3.271 Mbytes Step Temp E_pair E_mol TotEng Press 0 300 -22.405975 0 -22.3675 2575.7657 - 10 294.63153 -22.405286 0 -22.3675 2753.4662 - 20 278.98535 -22.40328 0 -22.3675 3272.416 - 30 254.38916 -22.400125 0 -22.3675 4091.8933 - 40 222.91191 -22.396088 0 -22.367499 5148.5505 - 50 187.16984 -22.391504 0 -22.367499 6362.2454 - 60 150.08253 -22.386747 0 -22.367499 7643.2732 - 70 114.60307 -22.382197 0 -22.367499 8900.2448 - 80 83.449257 -22.378201 0 -22.367499 10047.619 - 90 58.862643 -22.375048 0 -22.367498 11012.233 - 100 42.41931 -22.372939 0 -22.367498 11740.641 -Loop time of 2.15419 on 4 procs for 100 steps with 128 atoms + 10 294.8148 -22.40531 0 -22.3675 2762.0942 + 20 279.68628 -22.40337 0 -22.3675 3306.7656 + 30 255.84798 -22.400312 0 -22.3675 4168.2979 + 40 225.22346 -22.396384 0 -22.367499 5281.9537 + 50 190.25143 -22.391899 0 -22.367499 6565.6626 + 60 153.66642 -22.387207 0 -22.367499 7927.3186 + 70 118.25575 -22.382665 0 -22.367499 9271.9554 + 80 86.616338 -22.378607 0 -22.367499 10510.959 + 90 60.935787 -22.375314 0 -22.367498 11568.261 + 100 42.815823 -22.37299 0 -22.367498 12385.433 +Loop time of 0.260783 on 4 procs for 100 steps with 128 atoms -Performance: 2.005 ns/day, 11.968 hours/ns, 46.421 timesteps/s -92.0% CPU use with 4 MPI tasks x 1 OpenMP threads +Performance: 16.566 ns/day, 1.449 hours/ns, 383.461 timesteps/s +97.1% CPU use with 4 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 1.7677 | 1.9028 | 1.9897 | 6.2 | 88.33 +Pair | 0.23045 | 0.23744 | 0.24455 | 1.2 | 91.05 Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0.15367 | 0.24295 | 0.38029 | 17.6 | 11.28 -Output | 0.00034404 | 0.0012512 | 0.0017219 | 1.6 | 0.06 -Modify | 0.00018859 | 0.00021273 | 0.00023699 | 0.0 | 0.01 -Other | | 0.007011 | | | 0.33 +Comm | 0.014524 | 0.021267 | 0.027713 | 3.7 | 8.15 +Output | 0.00014997 | 0.00040495 | 0.0011623 | 0.0 | 0.16 +Modify | 4.2439e-05 | 4.6909e-05 | 5.0068e-05 | 0.0 | 0.02 +Other | | 0.00162 | | | 0.62 Nlocal: 32 ave 32 max 32 min Histogram: 4 0 0 0 0 0 0 0 0 0 @@ -123,4 +123,4 @@ Ave neighs/atom = 58 Neighbor list builds = 0 Dangerous builds = 0 -Total wall time: 0:00:02 +Total wall time: 0:00:00 diff --git a/examples/snap/log.27Nov18.snap.Ta06A.g++.1 b/examples/snap/log.15Jun20.snap.Ta06A.g++.1 similarity index 58% rename from examples/snap/log.27Nov18.snap.Ta06A.g++.1 rename to examples/snap/log.15Jun20.snap.Ta06A.g++.1 index 76cdc8641a..e85235a055 100644 --- a/examples/snap/log.27Nov18.snap.Ta06A.g++.1 +++ b/examples/snap/log.15Jun20.snap.Ta06A.g++.1 @@ -1,4 +1,4 @@ -LAMMPS (27 Nov 2018) +LAMMPS (15 Jun 2020) using 1 OpenMP thread(s) per MPI task # Demonstrate SNAP Ta potential @@ -7,7 +7,7 @@ LAMMPS (27 Nov 2018) variable nsteps index 100 variable nrep equal 4 variable a equal 3.316 -units metal +units metal # generate the box and atom positions using a BCC lattice @@ -18,28 +18,28 @@ variable ny equal 4 variable nz equal ${nrep} variable nz equal 4 -boundary p p p +boundary p p p lattice bcc $a lattice bcc 3.316 Lattice spacing in x,y,z = 3.316 3.316 3.316 -region box block 0 ${nx} 0 ${ny} 0 ${nz} -region box block 0 4 0 ${ny} 0 ${nz} -region box block 0 4 0 4 0 ${nz} -region box block 0 4 0 4 0 4 -create_box 1 box -Created orthogonal box = (0 0 0) to (13.264 13.264 13.264) +region box block 0 ${nx} 0 ${ny} 0 ${nz} +region box block 0 4 0 ${ny} 0 ${nz} +region box block 0 4 0 4 0 ${nz} +region box block 0 4 0 4 0 4 +create_box 1 box +Created orthogonal box = (0.0 0.0 0.0) to (13.264 13.264 13.264) 1 by 1 by 1 MPI processor grid -create_atoms 1 box +create_atoms 1 box Created 128 atoms - Time spent = 0.000350714 secs + create_atoms CPU = 0.000 seconds mass 1 180.88 # choose potential include Ta06A.snap -# DATE: 2014-09-05 CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: Thompson, Swiler, Trott, Foiles and Tucker, arxiv.org, 1409.3880 (2014) +# DATE: 2014-09-05 UNITS: metal CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: Thompson, Swiler, Trott, Foiles and Tucker, arxiv.org, 1409.3880 (2014) # Definition of SNAP potential Ta_Cand06A # Assumes 1 LAMMPS atom type @@ -56,7 +56,7 @@ pair_style hybrid/overlay zbl 4 4.8 snap pair_coeff 1 1 zbl ${zblz} ${zblz} pair_coeff 1 1 zbl 73 ${zblz} pair_coeff 1 1 zbl 73 73 -pair_coeff * * snap Ta06A.snapcoeff Ta Ta06A.snapparam Ta +pair_coeff * * snap Ta06A.snapcoeff Ta06A.snapparam Ta Reading potential file Ta06A.snapcoeff with DATE: 2014-09-05 SNAP Element = Ta, Radius 0.5, Weight 1 Reading potential file Ta06A.snapparam with DATE: 2014-09-05 @@ -64,14 +64,13 @@ SNAP keyword rcutfac 4.67637 SNAP keyword twojmax 6 SNAP keyword rfac0 0.99363 SNAP keyword rmin0 0 -SNAP keyword diagonalstyle 3 SNAP keyword bzeroflag 0 SNAP keyword quadraticflag 0 # Setup output -thermo 10 +thermo 10 thermo_modify norm yes # Set up NVE run @@ -82,7 +81,7 @@ neigh_modify once no every 1 delay 0 check yes # Run MD -velocity all create 300.0 4928459 +velocity all create 300.0 4928459 loop geom fix 1 all nve run ${nsteps} run 100 @@ -103,33 +102,33 @@ Neighbor list info ... pair build: full/bin/atomonly stencil: full/bin/3d bin: standard -Per MPI rank memory allocation (min/avg/max) = 4.138 | 4.138 | 4.138 Mbytes +Per MPI rank memory allocation (min/avg/max) = 3.967 | 3.967 | 3.967 Mbytes Step Temp E_pair E_mol TotEng Press 0 300 -11.85157 0 -11.813095 2717.1661 - 10 295.96579 -11.851053 0 -11.813095 2696.1559 - 20 284.32535 -11.84956 0 -11.813095 2301.3713 - 30 266.04602 -11.847215 0 -11.813095 1832.1745 - 40 242.2862 -11.844168 0 -11.813095 1492.6765 - 50 214.48968 -11.840603 0 -11.813094 1312.8908 - 60 184.32523 -11.836734 0 -11.813094 1284.582 - 70 153.58055 -11.832791 0 -11.813094 1374.4457 - 80 124.04276 -11.829003 0 -11.813094 1537.703 - 90 97.37622 -11.825582 0 -11.813094 1734.9662 - 100 75.007873 -11.822714 0 -11.813094 1930.8005 -Loop time of 5.03244 on 1 procs for 100 steps with 128 atoms + 10 296.01467 -11.851059 0 -11.813095 2697.4796 + 20 284.53666 -11.849587 0 -11.813095 2289.1527 + 30 266.51577 -11.847275 0 -11.813095 1851.7131 + 40 243.05007 -11.844266 0 -11.813095 1570.684 + 50 215.51032 -11.840734 0 -11.813094 1468.1899 + 60 185.48331 -11.836883 0 -11.813094 1524.8757 + 70 154.6736 -11.832931 0 -11.813094 1698.3351 + 80 124.79303 -11.829099 0 -11.813094 1947.0715 + 90 97.448054 -11.825592 0 -11.813094 2231.9563 + 100 74.035418 -11.822589 0 -11.813094 2515.8526 +Loop time of 0.702618 on 1 procs for 100 steps with 128 atoms -Performance: 0.858 ns/day, 27.958 hours/ns, 19.871 timesteps/s -98.9% CPU use with 1 MPI tasks x 1 OpenMP threads +Performance: 6.148 ns/day, 3.903 hours/ns, 142.325 timesteps/s +99.7% CPU use with 1 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 5.0308 | 5.0308 | 5.0308 | 0.0 | 99.97 +Pair | 0.70188 | 0.70188 | 0.70188 | 0.0 | 99.90 Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0.00070858 | 0.00070858 | 0.00070858 | 0.0 | 0.01 -Output | 0.00024676 | 0.00024676 | 0.00024676 | 0.0 | 0.00 -Modify | 0.0002749 | 0.0002749 | 0.0002749 | 0.0 | 0.01 -Other | | 0.0004299 | | | 0.01 +Comm | 0.00025487 | 0.00025487 | 0.00025487 | 0.0 | 0.04 +Output | 0.00015402 | 0.00015402 | 0.00015402 | 0.0 | 0.02 +Modify | 0.00011039 | 0.00011039 | 0.00011039 | 0.0 | 0.02 +Other | | 0.000217 | | | 0.03 Nlocal: 128 ave 128 max 128 min Histogram: 1 0 0 0 0 0 0 0 0 0 @@ -145,4 +144,4 @@ Ave neighs/atom = 58 Neighbor list builds = 0 Dangerous builds = 0 -Total wall time: 0:00:05 +Total wall time: 0:00:00 diff --git a/examples/snap/log.27Nov18.snap.Ta06A.g++.4 b/examples/snap/log.15Jun20.snap.Ta06A.g++.4 similarity index 58% rename from examples/snap/log.27Nov18.snap.Ta06A.g++.4 rename to examples/snap/log.15Jun20.snap.Ta06A.g++.4 index 4cc5b82c9b..0dc0c3f21b 100644 --- a/examples/snap/log.27Nov18.snap.Ta06A.g++.4 +++ b/examples/snap/log.15Jun20.snap.Ta06A.g++.4 @@ -1,4 +1,4 @@ -LAMMPS (27 Nov 2018) +LAMMPS (15 Jun 2020) using 1 OpenMP thread(s) per MPI task # Demonstrate SNAP Ta potential @@ -7,7 +7,7 @@ LAMMPS (27 Nov 2018) variable nsteps index 100 variable nrep equal 4 variable a equal 3.316 -units metal +units metal # generate the box and atom positions using a BCC lattice @@ -18,28 +18,28 @@ variable ny equal 4 variable nz equal ${nrep} variable nz equal 4 -boundary p p p +boundary p p p lattice bcc $a lattice bcc 3.316 Lattice spacing in x,y,z = 3.316 3.316 3.316 -region box block 0 ${nx} 0 ${ny} 0 ${nz} -region box block 0 4 0 ${ny} 0 ${nz} -region box block 0 4 0 4 0 ${nz} -region box block 0 4 0 4 0 4 -create_box 1 box -Created orthogonal box = (0 0 0) to (13.264 13.264 13.264) +region box block 0 ${nx} 0 ${ny} 0 ${nz} +region box block 0 4 0 ${ny} 0 ${nz} +region box block 0 4 0 4 0 ${nz} +region box block 0 4 0 4 0 4 +create_box 1 box +Created orthogonal box = (0.0 0.0 0.0) to (13.264 13.264 13.264) 1 by 2 by 2 MPI processor grid -create_atoms 1 box +create_atoms 1 box Created 128 atoms - Time spent = 0.000299692 secs + create_atoms CPU = 0.000 seconds mass 1 180.88 # choose potential include Ta06A.snap -# DATE: 2014-09-05 CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: Thompson, Swiler, Trott, Foiles and Tucker, arxiv.org, 1409.3880 (2014) +# DATE: 2014-09-05 UNITS: metal CONTRIBUTOR: Aidan Thompson athomps@sandia.gov CITATION: Thompson, Swiler, Trott, Foiles and Tucker, arxiv.org, 1409.3880 (2014) # Definition of SNAP potential Ta_Cand06A # Assumes 1 LAMMPS atom type @@ -56,7 +56,7 @@ pair_style hybrid/overlay zbl 4 4.8 snap pair_coeff 1 1 zbl ${zblz} ${zblz} pair_coeff 1 1 zbl 73 ${zblz} pair_coeff 1 1 zbl 73 73 -pair_coeff * * snap Ta06A.snapcoeff Ta Ta06A.snapparam Ta +pair_coeff * * snap Ta06A.snapcoeff Ta06A.snapparam Ta Reading potential file Ta06A.snapcoeff with DATE: 2014-09-05 SNAP Element = Ta, Radius 0.5, Weight 1 Reading potential file Ta06A.snapparam with DATE: 2014-09-05 @@ -64,14 +64,13 @@ SNAP keyword rcutfac 4.67637 SNAP keyword twojmax 6 SNAP keyword rfac0 0.99363 SNAP keyword rmin0 0 -SNAP keyword diagonalstyle 3 SNAP keyword bzeroflag 0 SNAP keyword quadraticflag 0 # Setup output -thermo 10 +thermo 10 thermo_modify norm yes # Set up NVE run @@ -82,7 +81,7 @@ neigh_modify once no every 1 delay 0 check yes # Run MD -velocity all create 300.0 4928459 +velocity all create 300.0 4928459 loop geom fix 1 all nve run ${nsteps} run 100 @@ -103,33 +102,33 @@ Neighbor list info ... pair build: full/bin/atomonly stencil: full/bin/3d bin: standard -Per MPI rank memory allocation (min/avg/max) = 4.118 | 4.118 | 4.118 Mbytes +Per MPI rank memory allocation (min/avg/max) = 3.903 | 3.903 | 3.903 Mbytes Step Temp E_pair E_mol TotEng Press 0 300 -11.85157 0 -11.813095 2717.1661 - 10 295.8664 -11.85104 0 -11.813095 2702.935 - 20 283.95868 -11.849513 0 -11.813095 2301.3242 - 30 265.29535 -11.847119 0 -11.813095 1870.3173 - 40 241.09337 -11.844015 0 -11.813095 1568.1549 - 50 212.86732 -11.840395 0 -11.813094 1409.2092 - 60 182.35256 -11.836481 0 -11.813094 1389.0527 - 70 151.38968 -11.83251 0 -11.813094 1474.9232 - 80 121.80051 -11.828715 0 -11.813094 1627.6911 - 90 95.262635 -11.825311 0 -11.813094 1812.9327 - 100 73.194645 -11.822481 0 -11.813094 1995.2199 -Loop time of 1.4959 on 4 procs for 100 steps with 128 atoms + 10 296.01467 -11.851059 0 -11.813095 2697.4796 + 20 284.53666 -11.849587 0 -11.813095 2289.1527 + 30 266.51577 -11.847275 0 -11.813095 1851.7131 + 40 243.05007 -11.844266 0 -11.813095 1570.684 + 50 215.51032 -11.840734 0 -11.813094 1468.1899 + 60 185.48331 -11.836883 0 -11.813094 1524.8757 + 70 154.6736 -11.832931 0 -11.813094 1698.3351 + 80 124.79303 -11.829099 0 -11.813094 1947.0715 + 90 97.448054 -11.825592 0 -11.813094 2231.9563 + 100 74.035418 -11.822589 0 -11.813094 2515.8526 +Loop time of 0.230164 on 4 procs for 100 steps with 128 atoms -Performance: 2.888 ns/day, 8.311 hours/ns, 66.850 timesteps/s -94.6% CPU use with 4 MPI tasks x 1 OpenMP threads +Performance: 18.769 ns/day, 1.279 hours/ns, 434.473 timesteps/s +93.5% CPU use with 4 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 1.2973 | 1.3263 | 1.3444 | 1.6 | 88.66 +Pair | 0.1824 | 0.19154 | 0.21822 | 3.5 | 83.22 Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0.14155 | 0.16475 | 0.19518 | 5.0 | 11.01 -Output | 0.00055361 | 0.0006234 | 0.00078511 | 0.0 | 0.04 -Modify | 0.00016427 | 0.00020635 | 0.00032949 | 0.0 | 0.01 -Other | | 0.004009 | | | 0.27 +Comm | 0.010843 | 0.037176 | 0.046129 | 7.9 | 16.15 +Output | 0.00014973 | 0.00028926 | 0.00070024 | 0.0 | 0.13 +Modify | 5.3883e-05 | 5.6803e-05 | 6.1989e-05 | 0.0 | 0.02 +Other | | 0.001104 | | | 0.48 Nlocal: 32 ave 32 max 32 min Histogram: 4 0 0 0 0 0 0 0 0 0 @@ -145,4 +144,4 @@ Ave neighs/atom = 58 Neighbor list builds = 0 Dangerous builds = 0 -Total wall time: 0:00:01 +Total wall time: 0:00:00 diff --git a/examples/snap/log.27Nov18.snap.W.2940.g++.1 b/examples/snap/log.15Jun20.snap.W.2940.g++.1 similarity index 57% rename from examples/snap/log.27Nov18.snap.W.2940.g++.1 rename to examples/snap/log.15Jun20.snap.W.2940.g++.1 index d2c540c709..599fdf6380 100644 --- a/examples/snap/log.27Nov18.snap.W.2940.g++.1 +++ b/examples/snap/log.15Jun20.snap.W.2940.g++.1 @@ -1,13 +1,13 @@ -LAMMPS (27 Nov 2018) +LAMMPS (15 Jun 2020) using 1 OpenMP thread(s) per MPI task -# Demonstrate SNAP Ta potential +# Demonstrate SNAP W potential # Initialize simulation variable nsteps index 100 variable nrep equal 4 variable a equal 3.1803 -units metal +units metal # generate the box and atom positions using a BCC lattice @@ -18,28 +18,28 @@ variable ny equal 4 variable nz equal ${nrep} variable nz equal 4 -boundary p p p +boundary p p p lattice bcc $a lattice bcc 3.1803 Lattice spacing in x,y,z = 3.1803 3.1803 3.1803 -region box block 0 ${nx} 0 ${ny} 0 ${nz} -region box block 0 4 0 ${ny} 0 ${nz} -region box block 0 4 0 4 0 ${nz} -region box block 0 4 0 4 0 4 -create_box 1 box -Created orthogonal box = (0 0 0) to (12.7212 12.7212 12.7212) +region box block 0 ${nx} 0 ${ny} 0 ${nz} +region box block 0 4 0 ${ny} 0 ${nz} +region box block 0 4 0 4 0 ${nz} +region box block 0 4 0 4 0 4 +create_box 1 box +Created orthogonal box = (0.0 0.0 0.0) to (12.7212 12.7212 12.7212) 1 by 1 by 1 MPI processor grid -create_atoms 1 box +create_atoms 1 box Created 128 atoms - Time spent = 0.000316143 secs + create_atoms CPU = 0.000 seconds mass 1 183.84 # choose potential include W_2940_2017_2.snap -# DATE: 2017-02-20 CONTRIBUTOR: Mitchell Wood mitwood@sandia.gov CITATION: Wood, M. A. and Thompson, A. P. "Quantum-Accurate Molecular Dynamics Potential for Tungsten" arXiv:1702.07042 [physics.comp-ph] +# DATE: 2017-02-20 UNITS: metal CONTRIBUTOR: Mitchell Wood mitwood@sandia.gov CITATION: Wood, M. A. and Thompson, A. P. "Quantum-Accurate Molecular Dynamics Potential for Tungsten" arXiv:1702.07042 [physics.comp-ph] # # Definition of SNAP+ZBL potential. variable zblcutinner equal 4 @@ -54,7 +54,7 @@ pair_style hybrid/overlay zbl 4 4.8 snap pair_coeff 1 1 zbl ${zblz} ${zblz} pair_coeff 1 1 zbl 74 ${zblz} pair_coeff 1 1 zbl 74 74 -pair_coeff * * snap W_2940_2017_2.snapcoeff W W_2940_2017_2.snapparam W +pair_coeff * * snap W_2940_2017_2.snapcoeff W_2940_2017_2.snapparam W Reading potential file W_2940_2017_2.snapcoeff with DATE: 2017-02-20 SNAP Element = W, Radius 0.5, Weight 1 Reading potential file W_2940_2017_2.snapparam with DATE: 2017-02-20 @@ -62,7 +62,6 @@ SNAP keyword rcutfac 4.73442 SNAP keyword twojmax 8 SNAP keyword rfac0 0.99363 SNAP keyword rmin0 0 -SNAP keyword diagonalstyle 3 SNAP keyword bzeroflag 0 SNAP keyword quadraticflag 0 @@ -70,7 +69,7 @@ SNAP keyword quadraticflag 0 # Setup output -thermo 10 +thermo 10 thermo_modify norm yes # Set up NVE run @@ -81,7 +80,7 @@ neigh_modify once no every 1 delay 0 check yes # Run MD -velocity all create 300.0 4928459 +velocity all create 300.0 4928459 loop geom fix 1 all nve run ${nsteps} run 100 @@ -102,33 +101,33 @@ Neighbor list info ... pair build: full/bin/atomonly stencil: full/bin/3d bin: standard -Per MPI rank memory allocation (min/avg/max) = 5.15 | 5.15 | 5.15 Mbytes +Per MPI rank memory allocation (min/avg/max) = 4.268 | 4.268 | 4.268 Mbytes Step Temp E_pair E_mol TotEng Press 0 300 -11.028325 0 -10.98985 3010.497 - 10 293.40666 -11.027479 0 -10.989849 3246.0559 - 20 274.27375 -11.025025 0 -10.989849 3927.9497 - 30 244.50457 -11.021207 0 -10.989849 4983.5484 - 40 207.0784 -11.016407 0 -10.989849 6299.9473 - 50 165.74442 -11.011105 0 -10.989848 7736.5123 - 60 124.62181 -11.005831 0 -10.989848 9140.8587 - 70 87.744792 -11.001101 0 -10.989848 10366.489 - 80 58.605244 -10.997364 0 -10.989848 11289.914 - 90 39.754503 -10.994946 0 -10.989848 11824.945 - 100 32.524085 -10.994019 0 -10.989848 11932.118 -Loop time of 18.7678 on 1 procs for 100 steps with 128 atoms + 10 293.10848 -11.027441 0 -10.989849 3259.9445 + 20 273.14727 -11.024881 0 -10.989849 3979.8968 + 30 242.20285 -11.020912 0 -10.989849 5089.0797 + 40 203.51992 -11.01595 0 -10.989849 6462.9419 + 50 161.14556 -11.010515 0 -10.989848 7948.1798 + 60 119.47232 -11.00517 0 -10.989848 9380.8543 + 70 82.729175 -11.000458 0 -10.989848 10606.025 + 80 54.483648 -10.996835 0 -10.989848 11496.424 + 90 37.225263 -10.994622 0 -10.989847 11967.579 + 100 32.094224 -10.993964 0 -10.989847 11987.181 +Loop time of 2.29953 on 1 procs for 100 steps with 128 atoms -Performance: 0.230 ns/day, 104.265 hours/ns, 5.328 timesteps/s -99.8% CPU use with 1 MPI tasks x 1 OpenMP threads +Performance: 1.879 ns/day, 12.775 hours/ns, 43.487 timesteps/s +99.7% CPU use with 1 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 18.766 | 18.766 | 18.766 | 0.0 | 99.99 +Pair | 2.2988 | 2.2988 | 2.2988 | 0.0 | 99.97 Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0.00081968 | 0.00081968 | 0.00081968 | 0.0 | 0.00 -Output | 0.00028563 | 0.00028563 | 0.00028563 | 0.0 | 0.00 -Modify | 0.0003283 | 0.0003283 | 0.0003283 | 0.0 | 0.00 -Other | | 0.0005233 | | | 0.00 +Comm | 0.00027108 | 0.00027108 | 0.00027108 | 0.0 | 0.01 +Output | 0.00014758 | 0.00014758 | 0.00014758 | 0.0 | 0.01 +Modify | 0.00010991 | 0.00010991 | 0.00010991 | 0.0 | 0.00 +Other | | 0.0001643 | | | 0.01 Nlocal: 128 ave 128 max 128 min Histogram: 1 0 0 0 0 0 0 0 0 0 @@ -144,4 +143,4 @@ Ave neighs/atom = 58 Neighbor list builds = 0 Dangerous builds = 0 -Total wall time: 0:00:18 +Total wall time: 0:00:02 diff --git a/examples/snap/log.27Nov18.snap.W.2940.g++.4 b/examples/snap/log.15Jun20.snap.W.2940.g++.4 similarity index 57% rename from examples/snap/log.27Nov18.snap.W.2940.g++.4 rename to examples/snap/log.15Jun20.snap.W.2940.g++.4 index cdd063de28..149eea3352 100644 --- a/examples/snap/log.27Nov18.snap.W.2940.g++.4 +++ b/examples/snap/log.15Jun20.snap.W.2940.g++.4 @@ -1,13 +1,13 @@ -LAMMPS (27 Nov 2018) +LAMMPS (15 Jun 2020) using 1 OpenMP thread(s) per MPI task -# Demonstrate SNAP Ta potential +# Demonstrate SNAP W potential # Initialize simulation variable nsteps index 100 variable nrep equal 4 variable a equal 3.1803 -units metal +units metal # generate the box and atom positions using a BCC lattice @@ -18,28 +18,28 @@ variable ny equal 4 variable nz equal ${nrep} variable nz equal 4 -boundary p p p +boundary p p p lattice bcc $a lattice bcc 3.1803 Lattice spacing in x,y,z = 3.1803 3.1803 3.1803 -region box block 0 ${nx} 0 ${ny} 0 ${nz} -region box block 0 4 0 ${ny} 0 ${nz} -region box block 0 4 0 4 0 ${nz} -region box block 0 4 0 4 0 4 -create_box 1 box -Created orthogonal box = (0 0 0) to (12.7212 12.7212 12.7212) +region box block 0 ${nx} 0 ${ny} 0 ${nz} +region box block 0 4 0 ${ny} 0 ${nz} +region box block 0 4 0 4 0 ${nz} +region box block 0 4 0 4 0 4 +create_box 1 box +Created orthogonal box = (0.0 0.0 0.0) to (12.7212 12.7212 12.7212) 1 by 2 by 2 MPI processor grid -create_atoms 1 box +create_atoms 1 box Created 128 atoms - Time spent = 0.000297546 secs + create_atoms CPU = 0.000 seconds mass 1 183.84 # choose potential include W_2940_2017_2.snap -# DATE: 2017-02-20 CONTRIBUTOR: Mitchell Wood mitwood@sandia.gov CITATION: Wood, M. A. and Thompson, A. P. "Quantum-Accurate Molecular Dynamics Potential for Tungsten" arXiv:1702.07042 [physics.comp-ph] +# DATE: 2017-02-20 UNITS: metal CONTRIBUTOR: Mitchell Wood mitwood@sandia.gov CITATION: Wood, M. A. and Thompson, A. P. "Quantum-Accurate Molecular Dynamics Potential for Tungsten" arXiv:1702.07042 [physics.comp-ph] # # Definition of SNAP+ZBL potential. variable zblcutinner equal 4 @@ -54,7 +54,7 @@ pair_style hybrid/overlay zbl 4 4.8 snap pair_coeff 1 1 zbl ${zblz} ${zblz} pair_coeff 1 1 zbl 74 ${zblz} pair_coeff 1 1 zbl 74 74 -pair_coeff * * snap W_2940_2017_2.snapcoeff W W_2940_2017_2.snapparam W +pair_coeff * * snap W_2940_2017_2.snapcoeff W_2940_2017_2.snapparam W Reading potential file W_2940_2017_2.snapcoeff with DATE: 2017-02-20 SNAP Element = W, Radius 0.5, Weight 1 Reading potential file W_2940_2017_2.snapparam with DATE: 2017-02-20 @@ -62,7 +62,6 @@ SNAP keyword rcutfac 4.73442 SNAP keyword twojmax 8 SNAP keyword rfac0 0.99363 SNAP keyword rmin0 0 -SNAP keyword diagonalstyle 3 SNAP keyword bzeroflag 0 SNAP keyword quadraticflag 0 @@ -70,7 +69,7 @@ SNAP keyword quadraticflag 0 # Setup output -thermo 10 +thermo 10 thermo_modify norm yes # Set up NVE run @@ -81,7 +80,7 @@ neigh_modify once no every 1 delay 0 check yes # Run MD -velocity all create 300.0 4928459 +velocity all create 300.0 4928459 loop geom fix 1 all nve run ${nsteps} run 100 @@ -102,33 +101,33 @@ Neighbor list info ... pair build: full/bin/atomonly stencil: full/bin/3d bin: standard -Per MPI rank memory allocation (min/avg/max) = 5.13 | 5.13 | 5.13 Mbytes +Per MPI rank memory allocation (min/avg/max) = 4.167 | 4.167 | 4.167 Mbytes Step Temp E_pair E_mol TotEng Press 0 300 -11.028325 0 -10.98985 3010.497 - 10 293.22504 -11.027456 0 -10.989849 3258.275 - 20 273.60084 -11.024939 0 -10.989849 3973.9038 - 30 243.15327 -11.021034 0 -10.989849 5077.9172 - 40 205.01905 -11.016142 0 -10.989849 6448.4941 - 50 163.10914 -11.010767 0 -10.989848 7935.6835 - 60 121.67854 -11.005453 0 -10.989848 9378.9959 - 70 84.846972 -11.000729 0 -10.989848 10626.301 - 80 56.127265 -10.997046 0 -10.989848 11551.687 - 90 38.025013 -10.994724 0 -10.989847 12069.936 - 100 31.768127 -10.993922 0 -10.989847 12145.648 -Loop time of 5.38055 on 4 procs for 100 steps with 128 atoms + 10 293.10848 -11.027441 0 -10.989849 3259.9445 + 20 273.14727 -11.024881 0 -10.989849 3979.8968 + 30 242.20285 -11.020912 0 -10.989849 5089.0797 + 40 203.51992 -11.01595 0 -10.989849 6462.9419 + 50 161.14556 -11.010515 0 -10.989848 7948.1798 + 60 119.47232 -11.00517 0 -10.989848 9380.8543 + 70 82.729175 -11.000458 0 -10.989848 10606.025 + 80 54.483648 -10.996835 0 -10.989848 11496.424 + 90 37.225263 -10.994622 0 -10.989847 11967.579 + 100 32.094224 -10.993964 0 -10.989847 11987.181 +Loop time of 0.700403 on 4 procs for 100 steps with 128 atoms -Performance: 0.803 ns/day, 29.892 hours/ns, 18.585 timesteps/s -96.1% CPU use with 4 MPI tasks x 1 OpenMP threads +Performance: 6.168 ns/day, 3.891 hours/ns, 142.775 timesteps/s +95.9% CPU use with 4 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 4.8254 | 5.0245 | 5.2817 | 7.7 | 93.38 +Pair | 0.59296 | 0.62019 | 0.6504 | 2.8 | 88.55 Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0.093845 | 0.34915 | 0.5466 | 29.1 | 6.49 -Output | 0.00032616 | 0.0011846 | 0.0037167 | 4.2 | 0.02 -Modify | 0.00022507 | 0.00025326 | 0.0002687 | 0.0 | 0.00 -Other | | 0.005432 | | | 0.10 +Comm | 0.048731 | 0.078938 | 0.10647 | 7.8 | 11.27 +Output | 0.00015879 | 0.00024194 | 0.00048518 | 0.0 | 0.03 +Modify | 6.4373e-05 | 6.9439e-05 | 7.7963e-05 | 0.0 | 0.01 +Other | | 0.0009654 | | | 0.14 Nlocal: 32 ave 32 max 32 min Histogram: 4 0 0 0 0 0 0 0 0 0 @@ -144,4 +143,4 @@ Ave neighs/atom = 58 Neighbor list builds = 0 Dangerous builds = 0 -Total wall time: 0:00:05 +Total wall time: 0:00:00 diff --git a/examples/snap/log.18Sep19.snap.WBeSNAP.g++.1 b/examples/snap/log.15Jun20.snap.WBe.PRB2019.g++.1 similarity index 54% rename from examples/snap/log.18Sep19.snap.WBeSNAP.g++.1 rename to examples/snap/log.15Jun20.snap.WBe.PRB2019.g++.1 index 2b889e036b..71320a642c 100644 --- a/examples/snap/log.18Sep19.snap.WBeSNAP.g++.1 +++ b/examples/snap/log.15Jun20.snap.WBe.PRB2019.g++.1 @@ -1,4 +1,5 @@ -LAMMPS (7 Aug 2019) +LAMMPS (15 Jun 2020) + using 1 OpenMP thread(s) per MPI task # Demonstrate SNAP W-Be potential # Initialize simulation @@ -6,7 +7,7 @@ LAMMPS (7 Aug 2019) variable nsteps index 100 variable nrep equal 4 variable a equal 3.1803 -units metal +units metal # generate the box and atom positions using a BCC lattice @@ -17,33 +18,33 @@ variable ny equal 4 variable nz equal ${nrep} variable nz equal 4 -boundary p p p +boundary p p p lattice bcc $a lattice bcc 3.1803 Lattice spacing in x,y,z = 3.1803 3.1803 3.1803 -region box block 0 ${nx} 0 ${ny} 0 ${nz} -region box block 0 4 0 ${ny} 0 ${nz} -region box block 0 4 0 4 0 ${nz} -region box block 0 4 0 4 0 4 -create_box 2 box -Created orthogonal box = (0 0 0) to (12.7212 12.7212 12.7212) +region box block 0 ${nx} 0 ${ny} 0 ${nz} +region box block 0 4 0 ${ny} 0 ${nz} +region box block 0 4 0 4 0 ${nz} +region box block 0 4 0 4 0 4 +create_box 2 box +Created orthogonal box = (0.0 0.0 0.0) to (12.7212 12.7212 12.7212) 1 by 1 by 1 MPI processor grid -create_atoms 1 box +create_atoms 1 box Created 128 atoms - create_atoms CPU = 0.000234842 secs + create_atoms CPU = 0.000 seconds mass 1 183.84 mass 2 9.012182 -set group all type/fraction 2 0.05 3590153 # Change 5% of W to He - 5 settings made for type/fraction -group tungsten type 1 +set group all type/fraction 2 0.05 3590153 # Change 5% of W to He + 5 settings made for type/fractiongroup tungsten type 1 123 atoms in group tungsten -group beryllium type 2 +group beryllium type 2 5 atoms in group beryllium # choose potential include WBe_Wood_PRB2019.snap +# DATE: 2019-09-18 UNITS: metal CONTRIBUTOR: Mary Alice Cusentino mcusent@sandia.gov CITATION: M.A. Wood, M.A. Cusentino, B.D. Wirth, and A.P. Thompson, "Data-driven material models for atomistic simulation", Physical Review B 99, 184305 (2019) # Definition of SNAP+ZBL potential. variable zblcutinner equal 4 variable zblcutouter equal 4.8 @@ -77,7 +78,7 @@ SNAP keyword quadraticflag 0 # Setup output -thermo 10 +thermo 10 thermo_modify norm yes # Set up NVE run @@ -88,7 +89,7 @@ neigh_modify once no every 1 delay 0 check yes # Run MD -velocity all create 300.0 4928459 +velocity all create 300.0 4928459 loop geom fix 1 all nve run ${nsteps} run 100 @@ -112,43 +113,43 @@ Neighbor list info ... Per MPI rank memory allocation (min/avg/max) = 4.268 | 4.268 | 4.268 Mbytes Step Temp E_pair E_mol TotEng Press 0 300 -8.5980876 0 -8.5596125 -35284.855 - 10 299.29029 -8.5979965 0 -8.5596125 -35299.259 - 20 288.99334 -8.5966759 0 -8.5596124 -35004.093 - 30 269.91027 -8.5942284 0 -8.5596123 -34447.077 - 40 243.57361 -8.5908505 0 -8.5596121 -33687.105 - 50 212.21385 -8.5868284 0 -8.5596119 -32821.864 - 60 178.77144 -8.5825391 0 -8.5596116 -31971.17 - 70 146.71854 -8.578428 0 -8.5596113 -31245.51 - 80 119.50956 -8.5749383 0 -8.5596111 -30724.137 - 90 99.872785 -8.5724197 0 -8.559611 -30440.244 - 100 89.604584 -8.5711027 0 -8.5596109 -30392.805 -Loop time of 3.16831 on 1 procs for 100 steps with 128 atoms + 10 296.32664 -8.5976164 0 -8.5596124 -35188.339 + 20 282.41417 -8.595832 0 -8.5596123 -34782.293 + 30 259.69014 -8.5929175 0 -8.5596121 -34113.316 + 40 230.50415 -8.5891741 0 -8.5596119 -33260.777 + 50 197.88816 -8.5849908 0 -8.5596116 -32309.975 + 60 165.27259 -8.5808076 0 -8.5596113 -31365.766 + 70 136.15697 -8.5770733 0 -8.5596111 -30542.657 + 80 113.58947 -8.5741788 0 -8.5596109 -29939.23 + 90 99.477916 -8.572369 0 -8.5596109 -29619.939 + 100 94.121939 -8.5716822 0 -8.559611 -29598.002 +Loop time of 2.26616 on 1 procs for 100 steps with 128 atoms -Performance: 1.364 ns/day, 17.602 hours/ns, 31.563 timesteps/s -199.5% CPU use with 1 MPI tasks x no OpenMP threads +Performance: 1.906 ns/day, 12.590 hours/ns, 44.128 timesteps/s +99.3% CPU use with 1 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 3.1672 | 3.1672 | 3.1672 | 0.0 | 99.97 -Neigh | 0.00030208 | 0.00030208 | 0.00030208 | 0.0 | 0.01 -Comm | 0.00029612 | 0.00029612 | 0.00029612 | 0.0 | 0.01 -Output | 0.00019813 | 0.00019813 | 0.00019813 | 0.0 | 0.01 -Modify | 0.00014448 | 0.00014448 | 0.00014448 | 0.0 | 0.00 -Other | | 0.0001433 | | | 0.00 +Pair | 2.2531 | 2.2531 | 2.2531 | 0.0 | 99.42 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 0.0002594 | 0.0002594 | 0.0002594 | 0.0 | 0.01 +Output | 0.012544 | 0.012544 | 0.012544 | 0.0 | 0.55 +Modify | 0.00010347 | 0.00010347 | 0.00010347 | 0.0 | 0.00 +Other | | 0.0001583 | | | 0.01 Nlocal: 128 ave 128 max 128 min Histogram: 1 0 0 0 0 0 0 0 0 0 Nghost: 727 ave 727 max 727 min Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 3710 ave 3710 max 3710 min +Neighs: 3712 ave 3712 max 3712 min Histogram: 1 0 0 0 0 0 0 0 0 0 -FullNghs: 7420 ave 7420 max 7420 min +FullNghs: 7424 ave 7424 max 7424 min Histogram: 1 0 0 0 0 0 0 0 0 0 -Total # of neighbors = 7420 -Ave neighs/atom = 57.9688 -Neighbor list builds = 1 +Total # of neighbors = 7424 +Ave neighs/atom = 58 +Neighbor list builds = 0 Dangerous builds = 0 -Total wall time: 0:00:03 +Total wall time: 0:00:02 diff --git a/examples/snap/log.18Sep19.snap.WBeSNAP.g++.4 b/examples/snap/log.15Jun20.snap.WBe.PRB2019.g++.4 similarity index 51% rename from examples/snap/log.18Sep19.snap.WBeSNAP.g++.4 rename to examples/snap/log.15Jun20.snap.WBe.PRB2019.g++.4 index d8cdae6810..fa24dae5c3 100644 --- a/examples/snap/log.18Sep19.snap.WBeSNAP.g++.4 +++ b/examples/snap/log.15Jun20.snap.WBe.PRB2019.g++.4 @@ -1,4 +1,5 @@ -LAMMPS (7 Aug 2019) +LAMMPS (15 Jun 2020) + using 1 OpenMP thread(s) per MPI task # Demonstrate SNAP W-Be potential # Initialize simulation @@ -6,7 +7,7 @@ LAMMPS (7 Aug 2019) variable nsteps index 100 variable nrep equal 4 variable a equal 3.1803 -units metal +units metal # generate the box and atom positions using a BCC lattice @@ -17,33 +18,33 @@ variable ny equal 4 variable nz equal ${nrep} variable nz equal 4 -boundary p p p +boundary p p p lattice bcc $a lattice bcc 3.1803 Lattice spacing in x,y,z = 3.1803 3.1803 3.1803 -region box block 0 ${nx} 0 ${ny} 0 ${nz} -region box block 0 4 0 ${ny} 0 ${nz} -region box block 0 4 0 4 0 ${nz} -region box block 0 4 0 4 0 4 -create_box 2 box -Created orthogonal box = (0 0 0) to (12.7212 12.7212 12.7212) +region box block 0 ${nx} 0 ${ny} 0 ${nz} +region box block 0 4 0 ${ny} 0 ${nz} +region box block 0 4 0 4 0 ${nz} +region box block 0 4 0 4 0 4 +create_box 2 box +Created orthogonal box = (0.0 0.0 0.0) to (12.7212 12.7212 12.7212) 1 by 2 by 2 MPI processor grid -create_atoms 1 box +create_atoms 1 box Created 128 atoms - create_atoms CPU = 0.000317097 secs + create_atoms CPU = 0.000 seconds mass 1 183.84 mass 2 9.012182 -set group all type/fraction 2 0.05 3590153 # Change 5% of W to He - 5 settings made for type/fraction -group tungsten type 1 +set group all type/fraction 2 0.05 3590153 # Change 5% of W to He + 5 settings made for type/fractiongroup tungsten type 1 123 atoms in group tungsten -group beryllium type 2 +group beryllium type 2 5 atoms in group beryllium # choose potential include WBe_Wood_PRB2019.snap +# DATE: 2019-09-18 UNITS: metal CONTRIBUTOR: Mary Alice Cusentino mcusent@sandia.gov CITATION: M.A. Wood, M.A. Cusentino, B.D. Wirth, and A.P. Thompson, "Data-driven material models for atomistic simulation", Physical Review B 99, 184305 (2019) # Definition of SNAP+ZBL potential. variable zblcutinner equal 4 variable zblcutouter equal 4.8 @@ -77,7 +78,7 @@ SNAP keyword quadraticflag 0 # Setup output -thermo 10 +thermo 10 thermo_modify norm yes # Set up NVE run @@ -88,7 +89,7 @@ neigh_modify once no every 1 delay 0 check yes # Run MD -velocity all create 300.0 4928459 +velocity all create 300.0 4928459 loop geom fix 1 all nve run ${nsteps} run 100 @@ -112,43 +113,43 @@ Neighbor list info ... Per MPI rank memory allocation (min/avg/max) = 4.167 | 4.167 | 4.167 Mbytes Step Temp E_pair E_mol TotEng Press 0 300 -8.5980876 0 -8.5596125 -35284.855 - 10 296.24946 -8.5976065 0 -8.5596124 -35140.29 - 20 282.27904 -8.5958147 0 -8.5596123 -34710.3 - 30 259.54978 -8.5928995 0 -8.5596121 -34060.43 - 40 230.41412 -8.5891626 0 -8.5596119 -33258.275 - 50 197.85135 -8.5849861 0 -8.5596116 -32389.527 - 60 165.21732 -8.5808005 0 -8.5596113 -31550.426 - 70 135.94024 -8.5770455 0 -8.5596111 -30839.006 - 80 113.06617 -8.5741117 0 -8.5596109 -30339.177 - 90 98.542347 -8.572249 0 -8.5596109 -30094.29 - 100 92.524343 -8.5714774 0 -8.5596111 -30091.988 -Loop time of 0.813674 on 4 procs for 100 steps with 128 atoms + 10 296.32664 -8.5976164 0 -8.5596124 -35188.339 + 20 282.41417 -8.595832 0 -8.5596123 -34782.293 + 30 259.69014 -8.5929175 0 -8.5596121 -34113.316 + 40 230.50415 -8.5891741 0 -8.5596119 -33260.777 + 50 197.88816 -8.5849908 0 -8.5596116 -32309.975 + 60 165.27259 -8.5808076 0 -8.5596113 -31365.766 + 70 136.15697 -8.5770733 0 -8.5596111 -30542.657 + 80 113.58947 -8.5741788 0 -8.5596109 -29939.23 + 90 99.477916 -8.572369 0 -8.5596109 -29619.939 + 100 94.121939 -8.5716822 0 -8.559611 -29598.002 +Loop time of 0.668977 on 4 procs for 100 steps with 128 atoms -Performance: 5.309 ns/day, 4.520 hours/ns, 122.899 timesteps/s -99.7% CPU use with 4 MPI tasks x no OpenMP threads +Performance: 6.458 ns/day, 3.717 hours/ns, 149.482 timesteps/s +97.2% CPU use with 4 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 0.79079 | 0.79788 | 0.80888 | 0.8 | 98.06 -Neigh | 7.1049e-05 | 8.0049e-05 | 9.2983e-05 | 0.0 | 0.01 -Comm | 0.0041246 | 0.01515 | 0.022235 | 5.5 | 1.86 -Output | 0.000144 | 0.00017095 | 0.00024796 | 0.0 | 0.02 -Modify | 4.4823e-05 | 5.8889e-05 | 7.2718e-05 | 0.0 | 0.01 -Other | | 0.000338 | | | 0.04 +Pair | 0.57811 | 0.60637 | 0.63609 | 2.6 | 90.64 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 0.031571 | 0.061612 | 0.090021 | 8.3 | 9.21 +Output | 0.00015521 | 0.00021636 | 0.00038552 | 0.0 | 0.03 +Modify | 5.4836e-05 | 6.1393e-05 | 7.2956e-05 | 0.0 | 0.01 +Other | | 0.0007139 | | | 0.11 -Nlocal: 32 ave 37 max 28 min -Histogram: 1 0 0 1 1 0 0 0 0 1 -Nghost: 431 ave 435 max 426 min -Histogram: 1 0 0 0 0 1 1 0 0 1 -Neighs: 927 ave 1071 max 821 min -Histogram: 1 0 1 0 1 0 0 0 0 1 -FullNghs: 1854 ave 2144 max 1624 min -Histogram: 1 0 0 1 1 0 0 0 0 1 +Nlocal: 32 ave 32 max 32 min +Histogram: 4 0 0 0 0 0 0 0 0 0 +Nghost: 431 ave 431 max 431 min +Histogram: 4 0 0 0 0 0 0 0 0 0 +Neighs: 928 ave 928 max 928 min +Histogram: 4 0 0 0 0 0 0 0 0 0 +FullNghs: 1856 ave 1856 max 1856 min +Histogram: 4 0 0 0 0 0 0 0 0 0 -Total # of neighbors = 7416 -Ave neighs/atom = 57.9375 -Neighbor list builds = 1 +Total # of neighbors = 7424 +Ave neighs/atom = 58 +Neighbor list builds = 0 Dangerous builds = 0 Total wall time: 0:00:00 diff --git a/examples/snap/log.27Nov18.snap.hybrid.WSNAP.HePair.g++.1 b/examples/snap/log.15Jun20.snap.hybrid.WSNAP.HePair.g++.1 similarity index 64% rename from examples/snap/log.27Nov18.snap.hybrid.WSNAP.HePair.g++.1 rename to examples/snap/log.15Jun20.snap.hybrid.WSNAP.HePair.g++.1 index 7d49043aa0..00161f4d4a 100644 --- a/examples/snap/log.27Nov18.snap.hybrid.WSNAP.HePair.g++.1 +++ b/examples/snap/log.15Jun20.snap.hybrid.WSNAP.HePair.g++.1 @@ -1,13 +1,13 @@ -LAMMPS (27 Nov 2018) +LAMMPS (15 Jun 2020) using 1 OpenMP thread(s) per MPI task -# Demonstrate SNAP Ta potential +# Demonstrate SNAP W with tabulated He-He and W-He using hybrid pair style # Initialize simulation variable nsteps index 100 variable nrep equal 4 variable a equal 3.1803 -units metal +units metal # generate the box and atom positions using a BCC lattice @@ -18,34 +18,33 @@ variable ny equal 4 variable nz equal ${nrep} variable nz equal 4 -boundary p p p +boundary p p p lattice bcc $a lattice bcc 3.1803 Lattice spacing in x,y,z = 3.1803 3.1803 3.1803 -region box block 0 ${nx} 0 ${ny} 0 ${nz} -region box block 0 4 0 ${ny} 0 ${nz} -region box block 0 4 0 4 0 ${nz} -region box block 0 4 0 4 0 4 -create_box 2 box -Created orthogonal box = (0 0 0) to (12.7212 12.7212 12.7212) +region box block 0 ${nx} 0 ${ny} 0 ${nz} +region box block 0 4 0 ${ny} 0 ${nz} +region box block 0 4 0 4 0 ${nz} +region box block 0 4 0 4 0 4 +create_box 2 box +Created orthogonal box = (0.0 0.0 0.0) to (12.7212 12.7212 12.7212) 1 by 1 by 1 MPI processor grid -create_atoms 1 box +create_atoms 1 box Created 128 atoms - Time spent = 0.000426054 secs + create_atoms CPU = 0.001 seconds mass 1 183.84 mass 2 4.0026 -set group all type/fraction 2 0.05 3590153 # Change 5% of W to He - 5 settings made for type/fraction -group tungsten type 1 +set group all type/fraction 2 0.05 3590153 # Change 5% of W to He + 5 settings made for type/fractiongroup tungsten type 1 123 atoms in group tungsten -group helium type 2 +group helium type 2 5 atoms in group helium # choose potential include W_2940_2017_2_He_JW2013.snap -# DATE: 2017-02-20 CONTRIBUTOR: Mitchell Wood mitwood@sandia.gov CITATION: Wood, M. A. and Thompson, A. P. "Quantum-Accurate Molecular Dynamics Potential for Tungsten" arXiv:1702.07042 [physics.comp-ph] +# DATE: 2017-02-20 UNITS: metal CONTRIBUTOR: Mitchell Wood mitwood@sandia.gov CITATION: Wood, M. A. and Thompson, A. P. "Quantum-Accurate Molecular Dynamics Potential for Tungsten" arXiv:1702.07042 [physics.comp-ph] # # Definition of SNAP+ZBL+Tabulated potential. variable zblcutinner equal 4 @@ -60,7 +59,7 @@ pair_style hybrid/overlay zbl 4 4.8 snap table spline 10000 table spline 10000 pair_coeff 1 1 zbl ${zblz} ${zblz} pair_coeff 1 1 zbl 74 ${zblz} pair_coeff 1 1 zbl 74 74 -pair_coeff * * snap W_2940_2017_2.snapcoeff W W_2940_2017_2.snapparam W NULL +pair_coeff * * snap W_2940_2017_2.snapcoeff W_2940_2017_2.snapparam W NULL Reading potential file W_2940_2017_2.snapcoeff with DATE: 2017-02-20 SNAP Element = W, Radius 0.5, Weight 1 Reading potential file W_2940_2017_2.snapparam with DATE: 2017-02-20 @@ -68,24 +67,23 @@ SNAP keyword rcutfac 4.73442 SNAP keyword twojmax 8 SNAP keyword rfac0 0.99363 SNAP keyword rmin0 0 -SNAP keyword diagonalstyle 3 SNAP keyword bzeroflag 0 SNAP keyword quadraticflag 0 pair_coeff 2 2 table 1 He_He_JW2013.table HeHe Reading potential file He_He_JW2013.table with DATE: 2017-02-20 WARNING: 1 of 4999 force values in table are inconsistent with -dE/dr. - Should only be flagged at inflection points (src/pair_table.cpp:481) + Should only be flagged at inflection points (src/pair_table.cpp:467) pair_coeff 1 2 table 2 W_He_JW2013.table WHe Reading potential file W_He_JW2013.table with DATE: 2017-02-20 WARNING: 3 of 325 force values in table are inconsistent with -dE/dr. - Should only be flagged at inflection points (src/pair_table.cpp:481) + Should only be flagged at inflection points (src/pair_table.cpp:467) #Hybrid/overlay will take all pair styles and add their contributions equally, order of pair_coeff doesnt matter here #This is not the case for pair_style hybrid ... where only one pair_coeff is read for each type combination, order matters here. # Setup output -thermo 10 +thermo 10 thermo_modify norm yes # Set up NVE run @@ -96,7 +94,7 @@ neigh_modify once no every 1 delay 0 check yes # Run MD -velocity all create 300.0 4928459 +velocity all create 300.0 4928459 loop geom fix 1 all nve run ${nsteps} run 100 @@ -137,33 +135,33 @@ Neighbor list info ... pair build: full/bin/atomonly stencil: full/bin/3d bin: standard -Per MPI rank memory allocation (min/avg/max) = 7.676 | 7.676 | 7.676 Mbytes +Per MPI rank memory allocation (min/avg/max) = 6.789 | 6.789 | 6.789 Mbytes Step Temp E_pair E_mol TotEng Press 0 300 -10.438105 0 -10.39963 -5445.2808 - 10 290.48923 -10.436885 0 -10.399629 -5646.4813 - 20 271.18868 -10.434409 0 -10.399629 -5654.4646 - 30 246.2601 -10.431212 0 -10.399629 -5281.8873 - 40 218.69918 -10.427677 0 -10.399629 -4343.3636 - 50 189.12519 -10.423885 0 -10.399629 -2903.1138 - 60 155.55701 -10.419579 0 -10.399629 -1402.2278 - 70 118.83581 -10.414869 0 -10.399629 -146.36141 - 80 85.903126 -10.410645 0 -10.399628 857.74986 - 90 65.223651 -10.407993 0 -10.399628 1494.2746 - 100 59.833542 -10.407302 0 -10.399628 1938.9164 -Loop time of 17.6435 on 1 procs for 100 steps with 128 atoms + 10 292.90716 -10.437195 0 -10.39963 -5400.8323 + 20 275.59696 -10.434975 0 -10.399629 -5055.199 + 30 250.28699 -10.431729 0 -10.399629 -4317.4619 + 40 218.58148 -10.427662 0 -10.399629 -3069.0256 + 50 182.80754 -10.423074 0 -10.399629 -1514.9501 + 60 144.77789 -10.418197 0 -10.399629 134.6083 + 70 108.06164 -10.413487 0 -10.399628 1747.8913 + 80 79.630821 -10.409841 0 -10.399628 2913.2733 + 90 62.795831 -10.407682 0 -10.399628 3646.2528 + 100 57.450965 -10.406996 0 -10.399628 4022.2665 +Loop time of 2.15336 on 1 procs for 100 steps with 128 atoms -Performance: 0.245 ns/day, 98.019 hours/ns, 5.668 timesteps/s -98.9% CPU use with 1 MPI tasks x 1 OpenMP threads +Performance: 2.006 ns/day, 11.963 hours/ns, 46.439 timesteps/s +99.9% CPU use with 1 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 17.641 | 17.641 | 17.641 | 0.0 | 99.99 -Neigh | 0.00054359 | 0.00054359 | 0.00054359 | 0.0 | 0.00 -Comm | 0.00080729 | 0.00080729 | 0.00080729 | 0.0 | 0.00 -Output | 0.00026512 | 0.00026512 | 0.00026512 | 0.0 | 0.00 -Modify | 0.00033879 | 0.00033879 | 0.00033879 | 0.0 | 0.00 -Other | | 0.0005448 | | | 0.00 +Pair | 2.1524 | 2.1524 | 2.1524 | 0.0 | 99.96 +Neigh | 0.00030732 | 0.00030732 | 0.00030732 | 0.0 | 0.01 +Comm | 0.00026202 | 0.00026202 | 0.00026202 | 0.0 | 0.01 +Output | 0.00013041 | 0.00013041 | 0.00013041 | 0.0 | 0.01 +Modify | 0.00010085 | 0.00010085 | 0.00010085 | 0.0 | 0.00 +Other | | 0.0001643 | | | 0.01 Nlocal: 128 ave 128 max 128 min Histogram: 1 0 0 0 0 0 0 0 0 0 @@ -179,4 +177,4 @@ Ave neighs/atom = 53.5156 Neighbor list builds = 1 Dangerous builds = 0 -Total wall time: 0:00:17 +Total wall time: 0:00:02 diff --git a/examples/snap/log.27Nov18.snap.hybrid.WSNAP.HePair.g++.4 b/examples/snap/log.15Jun20.snap.hybrid.WSNAP.HePair.g++.4 similarity index 59% rename from examples/snap/log.27Nov18.snap.hybrid.WSNAP.HePair.g++.4 rename to examples/snap/log.15Jun20.snap.hybrid.WSNAP.HePair.g++.4 index 05db710266..413aa10baa 100644 --- a/examples/snap/log.27Nov18.snap.hybrid.WSNAP.HePair.g++.4 +++ b/examples/snap/log.15Jun20.snap.hybrid.WSNAP.HePair.g++.4 @@ -1,13 +1,13 @@ -LAMMPS (27 Nov 2018) +LAMMPS (15 Jun 2020) using 1 OpenMP thread(s) per MPI task -# Demonstrate SNAP Ta potential +# Demonstrate SNAP W with tabulated He-He and W-He using hybrid pair style # Initialize simulation variable nsteps index 100 variable nrep equal 4 variable a equal 3.1803 -units metal +units metal # generate the box and atom positions using a BCC lattice @@ -18,34 +18,33 @@ variable ny equal 4 variable nz equal ${nrep} variable nz equal 4 -boundary p p p +boundary p p p lattice bcc $a lattice bcc 3.1803 Lattice spacing in x,y,z = 3.1803 3.1803 3.1803 -region box block 0 ${nx} 0 ${ny} 0 ${nz} -region box block 0 4 0 ${ny} 0 ${nz} -region box block 0 4 0 4 0 ${nz} -region box block 0 4 0 4 0 4 -create_box 2 box -Created orthogonal box = (0 0 0) to (12.7212 12.7212 12.7212) +region box block 0 ${nx} 0 ${ny} 0 ${nz} +region box block 0 4 0 ${ny} 0 ${nz} +region box block 0 4 0 4 0 ${nz} +region box block 0 4 0 4 0 4 +create_box 2 box +Created orthogonal box = (0.0 0.0 0.0) to (12.7212 12.7212 12.7212) 1 by 2 by 2 MPI processor grid -create_atoms 1 box +create_atoms 1 box Created 128 atoms - Time spent = 0.000303984 secs + create_atoms CPU = 0.000 seconds mass 1 183.84 mass 2 4.0026 -set group all type/fraction 2 0.05 3590153 # Change 5% of W to He - 5 settings made for type/fraction -group tungsten type 1 +set group all type/fraction 2 0.05 3590153 # Change 5% of W to He + 5 settings made for type/fractiongroup tungsten type 1 123 atoms in group tungsten -group helium type 2 +group helium type 2 5 atoms in group helium # choose potential include W_2940_2017_2_He_JW2013.snap -# DATE: 2017-02-20 CONTRIBUTOR: Mitchell Wood mitwood@sandia.gov CITATION: Wood, M. A. and Thompson, A. P. "Quantum-Accurate Molecular Dynamics Potential for Tungsten" arXiv:1702.07042 [physics.comp-ph] +# DATE: 2017-02-20 UNITS: metal CONTRIBUTOR: Mitchell Wood mitwood@sandia.gov CITATION: Wood, M. A. and Thompson, A. P. "Quantum-Accurate Molecular Dynamics Potential for Tungsten" arXiv:1702.07042 [physics.comp-ph] # # Definition of SNAP+ZBL+Tabulated potential. variable zblcutinner equal 4 @@ -60,7 +59,7 @@ pair_style hybrid/overlay zbl 4 4.8 snap table spline 10000 table spline 10000 pair_coeff 1 1 zbl ${zblz} ${zblz} pair_coeff 1 1 zbl 74 ${zblz} pair_coeff 1 1 zbl 74 74 -pair_coeff * * snap W_2940_2017_2.snapcoeff W W_2940_2017_2.snapparam W NULL +pair_coeff * * snap W_2940_2017_2.snapcoeff W_2940_2017_2.snapparam W NULL Reading potential file W_2940_2017_2.snapcoeff with DATE: 2017-02-20 SNAP Element = W, Radius 0.5, Weight 1 Reading potential file W_2940_2017_2.snapparam with DATE: 2017-02-20 @@ -68,24 +67,23 @@ SNAP keyword rcutfac 4.73442 SNAP keyword twojmax 8 SNAP keyword rfac0 0.99363 SNAP keyword rmin0 0 -SNAP keyword diagonalstyle 3 SNAP keyword bzeroflag 0 SNAP keyword quadraticflag 0 pair_coeff 2 2 table 1 He_He_JW2013.table HeHe Reading potential file He_He_JW2013.table with DATE: 2017-02-20 WARNING: 1 of 4999 force values in table are inconsistent with -dE/dr. - Should only be flagged at inflection points (src/pair_table.cpp:481) + Should only be flagged at inflection points (src/pair_table.cpp:467) pair_coeff 1 2 table 2 W_He_JW2013.table WHe Reading potential file W_He_JW2013.table with DATE: 2017-02-20 WARNING: 3 of 325 force values in table are inconsistent with -dE/dr. - Should only be flagged at inflection points (src/pair_table.cpp:481) + Should only be flagged at inflection points (src/pair_table.cpp:467) #Hybrid/overlay will take all pair styles and add their contributions equally, order of pair_coeff doesnt matter here #This is not the case for pair_style hybrid ... where only one pair_coeff is read for each type combination, order matters here. # Setup output -thermo 10 +thermo 10 thermo_modify norm yes # Set up NVE run @@ -96,7 +94,7 @@ neigh_modify once no every 1 delay 0 check yes # Run MD -velocity all create 300.0 4928459 +velocity all create 300.0 4928459 loop geom fix 1 all nve run ${nsteps} run 100 @@ -137,46 +135,46 @@ Neighbor list info ... pair build: full/bin/atomonly stencil: full/bin/3d bin: standard -Per MPI rank memory allocation (min/avg/max) = 7.656 | 7.656 | 7.656 Mbytes +Per MPI rank memory allocation (min/avg/max) = 6.687 | 6.69 | 6.692 Mbytes Step Temp E_pair E_mol TotEng Press 0 300 -10.438105 0 -10.39963 -5445.2808 - 10 292.13979 -10.437097 0 -10.39963 -5516.3963 - 20 272.55728 -10.434585 0 -10.399629 -5460.4268 - 30 245.06559 -10.431059 0 -10.399629 -5016.6351 - 40 212.79459 -10.42692 0 -10.399629 -3924.2175 - 50 178.03903 -10.422462 0 -10.399629 -2354.5485 - 60 141.62155 -10.417791 0 -10.399628 -595.41345 - 70 107.24843 -10.413383 0 -10.399628 1138.4107 - 80 79.985938 -10.409886 0 -10.399628 2392.1106 - 90 62.568933 -10.407652 0 -10.399628 3141.7027 - 100 56.697933 -10.406899 0 -10.399628 3583.9538 -Loop time of 4.7853 on 4 procs for 100 steps with 128 atoms + 10 292.90716 -10.437195 0 -10.39963 -5400.8323 + 20 275.59696 -10.434975 0 -10.399629 -5055.199 + 30 250.28699 -10.431729 0 -10.399629 -4317.4619 + 40 218.58148 -10.427662 0 -10.399629 -3069.0256 + 50 182.80754 -10.423074 0 -10.399629 -1514.9501 + 60 144.77789 -10.418197 0 -10.399629 134.6083 + 70 108.06164 -10.413487 0 -10.399628 1747.8913 + 80 79.630821 -10.409841 0 -10.399628 2913.2733 + 90 62.795831 -10.407682 0 -10.399628 3646.2528 + 100 57.450965 -10.406996 0 -10.399628 4022.2665 +Loop time of 0.652565 on 4 procs for 100 steps with 128 atoms -Performance: 0.903 ns/day, 26.585 hours/ns, 20.897 timesteps/s -97.3% CPU use with 4 MPI tasks x 1 OpenMP threads +Performance: 6.620 ns/day, 3.625 hours/ns, 153.241 timesteps/s +96.1% CPU use with 4 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 4.394 | 4.5813 | 4.7463 | 5.9 | 95.74 -Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0.035261 | 0.19515 | 0.38629 | 28.5 | 4.08 -Output | 0.00031662 | 0.00060844 | 0.0014563 | 0.0 | 0.01 -Modify | 0.00018692 | 0.0001924 | 0.00020123 | 0.0 | 0.00 -Other | | 0.008012 | | | 0.17 +Pair | 0.5462 | 0.57357 | 0.59096 | 2.3 | 87.89 +Neigh | 8.2016e-05 | 8.3506e-05 | 8.4877e-05 | 0.0 | 0.01 +Comm | 0.060158 | 0.07569 | 0.10482 | 6.5 | 11.60 +Output | 0.00015974 | 0.00035232 | 0.00092149 | 0.0 | 0.05 +Modify | 5.6982e-05 | 6.777e-05 | 7.3671e-05 | 0.0 | 0.01 +Other | | 0.002799 | | | 0.43 -Nlocal: 32 ave 32 max 32 min -Histogram: 4 0 0 0 0 0 0 0 0 0 -Nghost: 431 ave 431 max 431 min -Histogram: 4 0 0 0 0 0 0 0 0 0 -Neighs: 856.25 ave 885 max 818 min -Histogram: 1 0 0 0 1 0 0 0 1 1 -FullNghs: 1712.5 ave 1738 max 1658 min -Histogram: 1 0 0 0 0 0 0 0 2 1 +Nlocal: 32 ave 33 max 31 min +Histogram: 1 0 0 0 0 2 0 0 0 1 +Nghost: 431 ave 432 max 430 min +Histogram: 1 0 0 0 0 2 0 0 0 1 +Neighs: 856.25 ave 949 max 794 min +Histogram: 1 1 0 0 0 1 0 0 0 1 +FullNghs: 1712.5 ave 1854 max 1604 min +Histogram: 1 0 1 0 0 1 0 0 0 1 Total # of neighbors = 6850 Ave neighs/atom = 53.5156 -Neighbor list builds = 0 +Neighbor list builds = 1 Dangerous builds = 0 -Total wall time: 0:00:04 +Total wall time: 0:00:00 diff --git a/src/KSPACE/msm.cpp b/src/KSPACE/msm.cpp index 1520c2c607..abc8ca1150 100644 --- a/src/KSPACE/msm.cpp +++ b/src/KSPACE/msm.cpp @@ -28,6 +28,8 @@ #include "domain.h" #include "memory.h" #include "error.h" +#include "utils.h" +#include "fmt/format.h" #include "math_const.h" @@ -63,9 +65,6 @@ MSM::MSM(LAMMPS *lmp) : KSpace(lmp), factors[0] = 2; MPI_Comm_rank(world,&me); - procneigh_levels = NULL; - world_levels = NULL; - active_flag = NULL; phi1d = dphi1d = NULL; @@ -81,15 +80,7 @@ MSM::MSM(LAMMPS *lmp) : KSpace(lmp), v0_direct_top = v1_direct_top = v2_direct_top = NULL; v3_direct_top = v4_direct_top = v5_direct_top = NULL; - cg_all = cg_peratom_all = NULL; - cg = cg_peratom = NULL; - ngrid = NULL; - cg = NULL; - cg_peratom = NULL; - procneigh_levels = NULL; - world_levels = NULL; - active_flag = NULL; alpha = betax = betay = betaz = NULL; nx_msm = ny_msm = nz_msm = NULL; @@ -150,10 +141,7 @@ MSM::~MSM() void MSM::init() { - if (me == 0) { - if (screen) fprintf(screen,"MSM initialization ...\n"); - if (logfile) fprintf(logfile,"MSM initialization ...\n"); - } + if (me == 0) utils::logmesg(lmp,"MSM initialization ...\n"); // error check @@ -169,13 +157,8 @@ void MSM::init() if ((slabflag == 1) && (me == 0)) error->warning(FLERR,"Slab correction not needed for MSM"); - if (order < 4 || order > 10) { - char str[128]; - sprintf(str,"MSM order must be 4, 6, 8, or 10"); - error->all(FLERR,str); - } - - if (order%2 != 0) error->all(FLERR,"MSM order must be 4, 6, 8, or 10"); + if ((order < 4) || (order > 10) || (order%2 != 0)) + error->all(FLERR,"MSM order must be 4, 6, 8, or 10"); if (sizeof(FFT_SCALAR) != 8) error->all(FLERR,"Cannot (yet) use single precision with MSM " @@ -221,33 +204,14 @@ void MSM::init() MPI_Allreduce(&ngrid[0],&ngrid_max,1,MPI_INT,MPI_MAX,world); if (me == 0) { - if (screen) { - fprintf(screen," 3d grid size/proc = %d\n", - ngrid_max); - fprintf(screen," estimated absolute RMS force accuracy = %g\n", - estimated_error); - fprintf(screen," estimated relative force accuracy = %g\n", - estimated_error/two_charge_force); - } - if (logfile) { - fprintf(logfile," 3d grid size/proc = %d\n", - ngrid_max); - fprintf(logfile," estimated absolute RMS force accuracy = %g\n", - estimated_error); - fprintf(logfile," estimated relative force accuracy = %g\n", - estimated_error/two_charge_force); - } - } - - if (me == 0) { - if (screen) { - fprintf(screen," grid = %d %d %d\n",nx_msm[0],ny_msm[0],nz_msm[0]); - fprintf(screen," order = %d\n",order); - } - if (logfile) { - fprintf(logfile," grid = %d %d %d\n",nx_msm[0],ny_msm[0],nz_msm[0]); - fprintf(logfile," order = %d\n",order); - } + std::string mesg = fmt::format(" 3d grid size/proc = {}\n", ngrid_max); + mesg += fmt::format(" estimated absolute RMS force accuracy = {}\n", + estimated_error); + mesg += fmt::format(" estimated relative force accuracy = {}\n", + estimated_error/two_charge_force); + mesg += fmt::format(" grid = {} {} {}\n",nx_msm[0],ny_msm[0],nz_msm[0]); + mesg += fmt::format(" order = {}\n",order); + utils::logmesg(lmp,mesg); } } @@ -398,7 +362,6 @@ void MSM::setup() nmax_direct = 8*(nxhi_direct+1)*(nyhi_direct+1)*(nzhi_direct+1); - deallocate(); if (peratom_allocate_flag) deallocate_peratom(); // compute direct sum interaction weights @@ -649,6 +612,8 @@ void MSM::compute(int eflag, int vflag) void MSM::allocate() { + deallocate(); + // interpolation coeffs order_allocated = order; @@ -670,9 +635,9 @@ void MSM::allocate() // allocate memory for each grid level for (int n=0; ncreate3d_offset(qgrid[n],nzlo_out[n],nzhi_out[n], nylo_out[n],nyhi_out[n],nxlo_out[n],nxhi_out[n],"msm:qgrid"); - memory->create3d_offset(egrid[n],nzlo_out[n],nzhi_out[n], nylo_out[n],nyhi_out[n],nxlo_out[n],nxhi_out[n],"msm:egrid"); @@ -685,7 +650,7 @@ void MSM::allocate() nxlo_out[n],nxhi_out[n],nylo_out[n],nyhi_out[n],nzlo_out[n],nzhi_out[n], procneigh[0][0],procneigh[0][1],procneigh[1][0], procneigh[1][1],procneigh[2][0],procneigh[2][1]); - } + } else cg[n] = nullptr; } } @@ -695,24 +660,23 @@ void MSM::allocate() void MSM::deallocate() { + delete cg_all; + cg_all = nullptr; + memory->destroy2d_offset(phi1d,-order_allocated); memory->destroy2d_offset(dphi1d,-order_allocated); - if (cg_all) delete cg_all; - for (int n=0; ndestroy3d_offset(qgrid[n],nzlo_out[n],nylo_out[n],nxlo_out[n]); + memory->destroy3d_offset(qgrid[n],nzlo_out[n],nylo_out[n],nxlo_out[n]); + memory->destroy3d_offset(egrid[n],nzlo_out[n],nylo_out[n],nxlo_out[n]); - if (egrid[n]) - memory->destroy3d_offset(egrid[n],nzlo_out[n],nylo_out[n],nxlo_out[n]); + if (world_levels[n] != MPI_COMM_NULL) + MPI_Comm_free(&world_levels[n]); + world_levels[n] = MPI_COMM_NULL; + active_flag[n] = 0; - if (world_levels) - if (world_levels[n] != MPI_COMM_NULL) - MPI_Comm_free(&world_levels[n]); - - if (cg) - if (cg[n]) delete cg[n]; + delete cg[n]; + cg[n] = nullptr; } } @@ -801,6 +765,7 @@ void MSM::deallocate_peratom() void MSM::allocate_levels() { + deallocate_levels(); ngrid = new int[levels]; cg = new GridComm*[levels]; @@ -850,21 +815,21 @@ void MSM::allocate_levels() v5grid = new double***[levels]; for (int n=0; ndestroy(procneigh_levels); delete [] world_levels; @@ -919,6 +886,50 @@ void MSM::deallocate_levels() delete [] v3grid; delete [] v4grid; delete [] v5grid; + + world_levels = nullptr; + active_flag = nullptr; + cg = nullptr; + cg_peratom = nullptr; + + alpha = nullptr; + betax = nullptr; + betay = nullptr; + betaz = nullptr; + + nx_msm = nullptr; + ny_msm = nullptr; + nz_msm = nullptr; + + nxlo_in = nullptr; + nylo_in = nullptr; + nzlo_in = nullptr; + + nxhi_in = nullptr; + nyhi_in = nullptr; + nzhi_in = nullptr; + + nxlo_out = nullptr; + nylo_out = nullptr; + nzlo_out = nullptr; + + nxhi_out = nullptr; + nyhi_out = nullptr; + nzhi_out = nullptr; + + delxinv = nullptr; + delyinv = nullptr; + delzinv = nullptr; + + qgrid = nullptr; + egrid = nullptr; + + v0grid = nullptr; + v1grid = nullptr; + v2grid = nullptr; + v3grid = nullptr; + v4grid = nullptr; + v5grid = nullptr; } /* ---------------------------------------------------------------------- @@ -1053,9 +1064,9 @@ void MSM::set_grid_global() double *p_cutoff = (double *) force->pair->extract("cut_coul",itmp); *p_cutoff = cutoff; - char str[128]; - sprintf(str,"Adjusting Coulombic cutoff for MSM, new cutoff = %g",cutoff); - if (me == 0) error->warning(FLERR,str); + if (me == 0) + error->warning(FLERR,fmt::format("Adjusting Coulombic cutoff for " + "MSM, new cutoff = {}", cutoff)); } if (triclinic == 0) { @@ -1094,7 +1105,6 @@ void MSM::set_grid_global() if (!domain->nonperiodic) levels -= 1; - deallocate_levels(); allocate_levels(); // find number of grid levels in each direction @@ -1318,8 +1328,8 @@ void MSM::set_grid_local() void MSM::set_proc_grid(int n) { - for (int i=0; i<3; i++) - myloc[i] = comm->myloc[i]; + for (int i=0; i<3; i++) + myloc[i] = comm->myloc[i]; // size of inner MSM grid owned by this proc @@ -1362,6 +1372,7 @@ void MSM::set_proc_grid(int n) // define a new MPI communicator for this grid level that only includes active procs + if(world_levels[n] != MPI_COMM_NULL) MPI_Comm_free(&world_levels[n]); MPI_Comm_split(world,color,me,&world_levels[n]); if (!active_flag[n]) return; @@ -1479,16 +1490,13 @@ void MSM::particle_map() void MSM::make_rho() { - //fprintf(screen,"MSM aninterpolation\n\n"); - int i,l,m,n,nx,ny,nz,mx,my,mz; double dx,dy,dz,x0,y0,z0; // clear 3d density array - double ***qgridn = qgrid[0]; - - memset(&(qgridn[nzlo_out[0]][nylo_out[0]][nxlo_out[0]]),0,ngrid[0]*sizeof(double)); + double ***qgrid0 = qgrid[0]; + memset(&(qgrid0[nzlo_out[0]][nylo_out[0]][nxlo_out[0]]),0,ngrid[0]*sizeof(double)); // loop over my charges, add their contribution to nearby grid points // (nx,ny,nz) = global coords of grid pt to "lower left" of charge @@ -1519,7 +1527,7 @@ void MSM::make_rho() x0 = y0*phi1d[1][m]; for (l = nlower; l <= nupper; l++) { mx = l+nx; - qgridn[mz][my][mx] += x0*phi1d[0][l]; + qgrid0[mz][my][mx] += x0*phi1d[0][l]; } } } @@ -1534,8 +1542,6 @@ void MSM::make_rho() void MSM::direct(int n) { - //fprintf(screen,"Direct contribution on level %i\n\n",n); - double ***qgridn = qgrid[n]; double ***egridn = egrid[n]; double ***v0gridn = v0grid[n]; @@ -1768,8 +1774,6 @@ void MSM::direct(int n) void MSM::direct_peratom(int n) { - //fprintf(screen,"Direct contribution on level %i\n\n",n); - double ***qgridn = qgrid[n]; double ***v0gridn = v0grid[n]; double ***v1gridn = v1grid[n]; @@ -1892,8 +1896,6 @@ void MSM::direct_peratom(int n) void MSM::direct_top(int n) { - //fprintf(screen,"Direct contribution on level %i\n\n",n); - double ***qgridn = qgrid[n]; double ***egridn = egrid[n]; double ***v0gridn = v0grid[n]; @@ -2257,8 +2259,6 @@ void MSM::direct_peratom_top(int n) void MSM::restriction(int n) { - //fprintf(screen,"Restricting from level %i to %i\n\n",n,n+1); - const int p = order-1; double ***qgrid1 = qgrid[n]; @@ -2281,8 +2281,7 @@ void MSM::restriction(int n) // zero out charge on coarser grid - memset(&(qgrid2[nzlo_out[n+1]][nylo_out[n+1]][nxlo_out[n+1]]),0, - ngrid[n+1]*sizeof(double)); + memset(&(qgrid2[nzlo_out[n+1]][nylo_out[n+1]][nxlo_out[n+1]]),0,ngrid[n+1]*sizeof(double)); for (kp = nzlo_in[n+1]; kp <= nzhi_in[n+1]; kp++) for (jp = nylo_in[n+1]; jp <= nyhi_in[n+1]; jp++) @@ -2331,8 +2330,6 @@ void MSM::restriction(int n) void MSM::prolongation(int n) { - //fprintf(screen,"Prolongating from level %i to %i\n\n",n+1,n); - const int p = order-1; double ***egrid1 = egrid[n]; @@ -2721,8 +2718,6 @@ void MSM::unpack_reverse(int flag, double *buf, int nlist, int *list) void MSM::fieldforce() { - //fprintf(screen,"MSM interpolation\n\n"); - double ***egridn = egrid[0]; int i,l,m,n,nx,ny,nz,mx,my,mz; diff --git a/src/MANYBODY/pair_bop.cpp b/src/MANYBODY/pair_bop.cpp index d922cf6d33..21630ad001 100644 --- a/src/MANYBODY/pair_bop.cpp +++ b/src/MANYBODY/pair_bop.cpp @@ -257,12 +257,8 @@ PairBOP::~PairBOP() memory->destroy(gfunc6); memory->destroy(gpara); } - if(allocate_sigma) { - destroy_sigma(); - } - if(allocate_pi) { - destroy_pi(); - } + memory->destroy(bt_sg); + memory->destroy(bt_pi); } /* ---------------------------------------------------------------------- */ @@ -635,8 +631,6 @@ void PairBOP::coeff(int narg, char **arg) bop_step=0; nb_pi=0; nb_sg=0; - allocate_sigma=0; - allocate_pi=0; allocate_neigh=0; update_list=0; maxnall=0; @@ -768,19 +762,18 @@ void PairBOP::gneigh() int *type = atom->type; if(allocate_neigh==0) { - memory->create (BOP_index,nall,"BOP_index"); - memory->create (BOP_index3,nall,"BOP_index3"); - memory->create (BOP_total,nall,"BOP_total"); - memory->create (BOP_total3,nall,"BOP_total"); - if (otfly==0) memory->create (cos_index,nall,"cos_index"); + memory->create(BOP_index,nall,"BOP_index"); + memory->create(BOP_index3,nall,"BOP_index3"); + memory->create(BOP_total,nall,"BOP_total"); + memory->create(BOP_total3,nall,"BOP_total"); + if (otfly==0) memory->create(cos_index,nall,"cos_index"); allocate_neigh=1; - } - else { - memory->grow (BOP_index,nall,"BOP_index"); - memory->grow (BOP_index3,nall,"BOP_index3"); - memory->grow (BOP_total,nall,"BOP_total"); - memory->grow (BOP_total3,nall,"BOP_total3"); - if (otfly==0) memory->grow (cos_index,nall,"cos_index"); + } else { + memory->grow(BOP_index,nall,"BOP_index"); + memory->grow(BOP_index3,nall,"BOP_index3"); + memory->grow(BOP_total,nall,"BOP_total"); + memory->grow(BOP_total3,nall,"BOP_total3"); + if (otfly==0) memory->grow(cos_index,nall,"cos_index"); allocate_neigh=1; } ilist = list->ilist; @@ -1140,10 +1133,6 @@ double PairBOP::sigmaBo(int itmp, int jtmp) if(nb_sg==0) { nb_sg=(maxneigh)*(maxneigh/2); } - if(allocate_sigma) { - destroy_sigma(); - } - create_sigma(nb_sg); sigB=0; if(itmpdestroy(bt_pi); bt_pi = (B_PI *) memory->smalloc(n_tot*sizeof(B_PI),"BOP:bt_pi"); - allocate_pi=1; } void PairBOP::create_sigma(int n_tot) -{ - bt_sg = (B_SG *) memory->smalloc(n_tot*sizeof(B_SG),"BOP:bt_sg"); - allocate_sigma=1; -} - -void PairBOP::destroy_pi() -{ - memory->destroy(bt_pi); - allocate_pi=0; -} - -void PairBOP::destroy_sigma() { memory->destroy(bt_sg); - allocate_sigma=0; + bt_sg = (B_SG *) memory->smalloc(n_tot*sizeof(B_SG),"BOP:bt_sg"); } /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_bop.h b/src/MANYBODY/pair_bop.h index 2d6962e27c..d61c969094 100644 --- a/src/MANYBODY/pair_bop.h +++ b/src/MANYBODY/pair_bop.h @@ -58,8 +58,6 @@ class PairBOP : public Pair { int ***elem2param; int nparams; int bop_step; - int allocate_pi; - int allocate_sigma; int allocate_neigh; int nb_pi,nb_sg; int ago1; diff --git a/src/MANYBODY/pair_comb.cpp b/src/MANYBODY/pair_comb.cpp index 201b325bf3..d966fa723f 100644 --- a/src/MANYBODY/pair_comb.cpp +++ b/src/MANYBODY/pair_comb.cpp @@ -1335,6 +1335,18 @@ void PairComb::sm_table() // allocate arrays + memory->sfree(sht_first); + memory->destroy(intype); + memory->destroy(fafb); + memory->destroy(dfafb); + memory->destroy(ddfafb); + memory->destroy(phin); + memory->destroy(dphin); + memory->destroy(erpaw); + memory->destroy(NCo); + memory->destroy(bbij); + memory->destroy(sht_num); + memory->create(intype,n,n,"pair:intype"); memory->create(fafb,ncoul,nntypes,"pair:fafb"); memory->create(dfafb,ncoul,nntypes,"pair:dfafb"); diff --git a/src/MANYBODY/pair_comb3.cpp b/src/MANYBODY/pair_comb3.cpp index 5b039c8eb5..e5f729f19a 100644 --- a/src/MANYBODY/pair_comb3.cpp +++ b/src/MANYBODY/pair_comb3.cpp @@ -2258,6 +2258,26 @@ void PairComb3::tables() int n = nelements; + memory->destroy(intype); + memory->destroy(erpaw); + memory->destroy(fafb); + memory->destroy(dfafb); + memory->destroy(ddfafb); + memory->destroy(phin); + memory->destroy(dphin); + memory->destroy(afb); + memory->destroy(dafb); + memory->destroy(vvdw); + memory->destroy(vdvdw); + memory->destroy(dpl); + memory->destroy(bbij); + memory->destroy(xcctmp); + memory->destroy(xchtmp); + memory->destroy(xcotmp); + memory->destroy(NCo); + memory->destroy(sht_num); + memory->sfree(sht_first); + dra = 0.001; drin = 0.100; drbuf = 0.100; diff --git a/src/MANYBODY/pair_eam_cd.cpp b/src/MANYBODY/pair_eam_cd.cpp index eb8fc4e768..102e2a62f3 100644 --- a/src/MANYBODY/pair_eam_cd.cpp +++ b/src/MANYBODY/pair_eam_cd.cpp @@ -62,7 +62,7 @@ PairEAMCD::~PairEAMCD() { memory->destroy(rhoB); memory->destroy(D_values); - if (hcoeff) delete[] hcoeff; + delete[] hcoeff; } void PairEAMCD::compute(int eflag, int vflag) @@ -521,6 +521,7 @@ void PairEAMCD::read_h_coeff(char *filename) if ((int)values.count() != nhcoeff + 1 || nhcoeff < 1) error->one(FLERR, "Failed to read h(x) function coefficients in EAM file."); + delete[] hcoeff; hcoeff = new double[nhcoeff]; int i = 0; @@ -534,7 +535,10 @@ void PairEAMCD::read_h_coeff(char *filename) } MPI_Bcast(&nhcoeff, 1, MPI_INT, 0, world); - if (comm->me != 0) hcoeff = new double[nhcoeff]; + if (comm->me != 0) { + delete[] hcoeff; + hcoeff = new double[nhcoeff]; + } MPI_Bcast(hcoeff, nhcoeff, MPI_DOUBLE, 0, world); } diff --git a/src/MANYBODY/pair_polymorphic.cpp b/src/MANYBODY/pair_polymorphic.cpp index a3f6d08522..502580719a 100644 --- a/src/MANYBODY/pair_polymorphic.cpp +++ b/src/MANYBODY/pair_polymorphic.cpp @@ -47,26 +47,26 @@ PairPolymorphic::PairPolymorphic(LAMMPS *lmp) : Pair(lmp) one_coeff = 1; nelements = 0; - elements = NULL; - match = NULL; - pairParameters = NULL; - tripletParameters = NULL; - elem2param = NULL; - elem3param = NULL; - map = NULL; + elements = nullptr; + match = nullptr; + pairParameters = nullptr; + tripletParameters = nullptr; + elem2param = nullptr; + elem3param = nullptr; + map = nullptr; epsilon = 0.0; neighsize = 0; - firstneighV = NULL; - firstneighW = NULL; - firstneighW1 = NULL; - delxV = NULL; - delyV = NULL; - delzV = NULL; - drV = NULL; - delxW = NULL; - delyW = NULL; - delzW = NULL; - drW = NULL; + firstneighV = nullptr; + firstneighW = nullptr; + firstneighW1 = nullptr; + delxV = nullptr; + delyV = nullptr; + delzV = nullptr; + drV = nullptr; + delxW = nullptr; + delyW = nullptr; + delzW = nullptr; + drW = nullptr; } /* ---------------------------------------------------------------------- @@ -79,8 +79,10 @@ PairPolymorphic::~PairPolymorphic() for (int i = 0; i < nelements; i++) delete [] elements[i]; delete [] elements; delete [] match; - memory->destroy(pairParameters); - memory->destroy(tripletParameters); + + delete [] pairParameters; + delete [] tripletParameters; + memory->destroy(elem2param); memory->destroy(elem3param); if (allocated) { @@ -487,7 +489,7 @@ void PairPolymorphic::coeff(int narg, char **arg) delete [] elements; } elements = new char*[atom->ntypes]; - for (i = 0; i < atom->ntypes; i++) elements[i] = NULL; + for (i = 0; i < atom->ntypes; i++) elements[i] = nullptr; nelements = 0; for (i = 3; i < narg; i++) { @@ -581,6 +583,7 @@ void PairPolymorphic::read_file(char *file) eta = values.next_int(); // map the elements in the potential file to LAMMPS atom types + delete [] match; match = new int[nelements]; for (int i = 0; i < nelements; i++) { @@ -617,8 +620,10 @@ void PairPolymorphic::read_file(char *file) // 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"); + delete [] pairParameters; + delete [] tripletParameters; + pairParameters = new PairParameters[npair]; + tripletParameters = new TripletParameters[ntriple]; for (int i = 0; i < npair; i++) { PairParameters & p = pairParameters[i]; @@ -641,9 +646,12 @@ void PairPolymorphic::read_file(char *file) MPI_Bcast(&ntriple, 1, MPI_INT, 0, world); if(comm->me != 0) { + delete [] match; match = new int[nelements]; - pairParameters = (PairParameters*) memory->srealloc(pairParameters,npair*sizeof(PairParameters), "pair:pairParameters"); - tripletParameters = (TripletParameters*) memory->srealloc(tripletParameters,ntriple*sizeof(TripletParameters), "pair:tripletParameters"); + delete [] pairParameters; + delete [] tripletParameters; + pairParameters = new PairParameters[npair]; + tripletParameters = new TripletParameters[ntriple]; } MPI_Bcast(match, nelements, MPI_INT, 0, world); diff --git a/src/MANYBODY/pair_polymorphic.h b/src/MANYBODY/pair_polymorphic.h index b4ff169b76..18956699d7 100644 --- a/src/MANYBODY/pair_polymorphic.h +++ b/src/MANYBODY/pair_polymorphic.h @@ -50,14 +50,14 @@ class PairPolymorphic : public Pair { xmax = 0.0; xmaxsq = xmax*xmax; vmax = 0.0; - xs = NULL; - ys = NULL; - ys1 = NULL; - ys2 = NULL; - ys3 = NULL; - ys4 = NULL; - ys5 = NULL; - ys6 = NULL; + xs = nullptr; + ys = nullptr; + ys1 = nullptr; + ys2 = nullptr; + ys3 = nullptr; + ys4 = nullptr; + ys5 = nullptr; + ys6 = nullptr; } tabularFunction(int n) { size = n; @@ -88,14 +88,14 @@ class PairPolymorphic : public Pair { ys6 = new double[n]; } virtual ~tabularFunction() { - if (xs) delete [] xs; - if (ys) delete [] ys; - if (ys1) delete [] ys1; - if (ys2) delete [] ys2; - if (ys3) delete [] ys3; - if (ys4) delete [] ys4; - if (ys5) delete [] ys5; - if (ys6) delete [] ys6; + delete [] xs; + delete [] ys; + delete [] ys1; + delete [] ys2; + delete [] ys3; + delete [] ys4; + delete [] ys5; + delete [] ys6; } void set_xrange(double x1, double x2) { xmin = x1; @@ -198,21 +198,21 @@ class PairPolymorphic : public Pair { void resize(int n) { if (n != size) { size = n; - if (xs) delete [] xs; + delete [] xs; xs = new double[n]; - if (ys) delete [] ys; + delete [] ys; ys = new double[n]; - if (ys1) delete [] ys1; + delete [] ys1; ys1 = new double[n]; - if (ys2) delete [] ys2; + delete [] ys2; ys2 = new double[n]; - if (ys3) delete [] ys3; + delete [] ys3; ys3 = new double[n]; - if (ys4) delete [] ys4; + delete [] ys4; ys4 = new double[n]; - if (ys5) delete [] ys5; + delete [] ys5; ys5 = new double[n]; - if (ys6) delete [] ys6; + delete [] ys6; ys6 = new double[n]; } } @@ -248,35 +248,45 @@ class PairPolymorphic : public Pair { } int size; double xmin,xmax,xmaxsq,rdx,vmax; - double * ys, * ys1, * ys2, * ys3, * ys4, * ys5, * ys6; - double * xs; + double *ys, *ys1, *ys2, *ys3, *ys4, *ys5, *ys6; + double *xs; }; struct PairParameters { double cut; double cutsq; double xi; - class tabularFunction * U; - class tabularFunction * V; - class tabularFunction * W; - class tabularFunction * F; + class tabularFunction *U; + class tabularFunction *V; + class tabularFunction *W; + class tabularFunction *F; PairParameters() { cut = 0.0; cutsq = 0.0; xi = 1.0; - U = NULL; - V = NULL; - W = NULL; - F = NULL; + U = nullptr; + V = nullptr; + W = nullptr; + F = nullptr; }; + ~PairParameters() { + delete U; + delete V; + delete W; + delete F; + } }; struct TripletParameters { - class tabularFunction * P; - class tabularFunction * G; + class tabularFunction *P; + class tabularFunction *G; TripletParameters() { - P = NULL; - G = NULL; + P = nullptr; + G = nullptr; }; + ~TripletParameters() { + delete P; + delete G; + } }; double epsilon; diff --git a/src/MOLECULE/bond_fene.cpp b/src/MOLECULE/bond_fene.cpp index 91c0877478..f87f12a3b1 100644 --- a/src/MOLECULE/bond_fene.cpp +++ b/src/MOLECULE/bond_fene.cpp @@ -23,6 +23,7 @@ #include "memory.h" #include "error.h" #include "utils.h" +#include "fmt/format.h" using namespace LAMMPS_NS; @@ -82,13 +83,11 @@ void BondFENE::compute(int eflag, int vflag) // if r -> r0, then rlogarg < 0.0 which is an error // issue a warning and reset rlogarg = epsilon // if r > 2*r0 something serious is wrong, abort + printf("r = %g r0 = %g rlogarg = %g\n",sqrt(rsq),sqrt(r0sq),rlogarg); if (rlogarg < 0.1) { - char str[128]; - sprintf(str,"FENE bond too long: " BIGINT_FORMAT " " - TAGINT_FORMAT " " TAGINT_FORMAT " %g", - update->ntimestep,atom->tag[i1],atom->tag[i2],sqrt(rsq)); - error->warning(FLERR,str,0); + error->warning(FLERR,fmt::format("FENE bond too long: {} {} {} {}", + update->ntimestep,atom->tag[i1],atom->tag[i2],sqrt(rsq))); if (rlogarg <= -3.0) error->one(FLERR,"Bad FENE bond"); rlogarg = 0.1; } diff --git a/src/USER-MISC/pair_tersoff_table.cpp b/src/USER-MISC/pair_tersoff_table.cpp index 57c897bdfc..8ab64b1d5a 100644 --- a/src/USER-MISC/pair_tersoff_table.cpp +++ b/src/USER-MISC/pair_tersoff_table.cpp @@ -61,14 +61,21 @@ PairTersoffTable::PairTersoffTable(LAMMPS *lmp) : Pair(lmp) manybody_flag = 1; nelements = 0; - elements = NULL; + elements = nullptr; nparams = maxparam = 0; - params = NULL; - elem2param = NULL; + params = nullptr; + elem2param = nullptr; allocated = 0; - preGtetaFunction = preGtetaFunctionDerived = NULL; - preCutoffFunction = preCutoffFunctionDerived = NULL; + preGtetaFunction = preGtetaFunctionDerived = nullptr; + preCutoffFunction = preCutoffFunctionDerived = nullptr; + exponential = nullptr; + gtetaFunction = nullptr; + gtetaFunctionDerived = nullptr; + cutoffFunction = nullptr; + cutoffFunctionDerived = nullptr; + betaZetaPower = nullptr; + betaZetaPowerDerived = nullptr; } /* ---------------------------------------------------------------------- @@ -88,9 +95,9 @@ PairTersoffTable::~PairTersoffTable() memory->destroy(cutsq); delete [] map; - deallocateGrids(); - deallocatePreLoops(); } + deallocateGrids(); + deallocatePreLoops(); } /* ---------------------------------------------------------------------- */ @@ -525,13 +532,15 @@ void PairTersoffTable::deallocatePreLoops(void) void PairTersoffTable::allocatePreLoops(void) { - memory->create(preGtetaFunction,leadingDimensionInteractionList,leadingDimensionInteractionList,"tersofftable:preGtetaFunction"); - - memory->create(preGtetaFunctionDerived,leadingDimensionInteractionList,leadingDimensionInteractionList,"tersofftable:preGtetaFunctionDerived"); - - memory->create(preCutoffFunction,leadingDimensionInteractionList,"tersofftable:preCutoffFunction"); - - memory->create(preCutoffFunctionDerived,leadingDimensionInteractionList,"tersofftable:preCutoffFunctionDerived"); + deallocatePreLoops(); + memory->create(preGtetaFunction,leadingDimensionInteractionList, + leadingDimensionInteractionList,"tersofftable:preGtetaFunction"); + memory->create(preGtetaFunctionDerived,leadingDimensionInteractionList, + leadingDimensionInteractionList,"tersofftable:preGtetaFunctionDerived"); + memory->create(preCutoffFunction,leadingDimensionInteractionList, + "tersofftable:preCutoffFunction"); + memory->create(preCutoffFunctionDerived,leadingDimensionInteractionList, + "tersofftable:preCutoffFunctionDerived"); } void PairTersoffTable::deallocateGrids() @@ -557,6 +566,8 @@ void PairTersoffTable::allocateGrids(void) double r, minMu, maxLambda, maxCutoff; double const PI=acos(-1.0); + deallocateGrids(); + // exponential // find min and max argument @@ -569,9 +580,7 @@ void PairTersoffTable::allocateGrids(void) maxCutoff=cutmax; minArgumentExponential=minMu*GRIDSTART; - numGridPointsExponential=(int)((maxLambda*maxCutoff-minArgumentExponential)*GRIDDENSITY_EXP)+2; - memory->create(exponential,numGridPointsExponential,"tersofftable:exponential"); r = minArgumentExponential; diff --git a/src/atom.cpp b/src/atom.cpp index 471061cd5e..42ff9d4613 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -249,115 +249,6 @@ Atom::~Atom() delete [] peratom[i].name; memory->sfree(peratom); - // -------------------------------------------------------------------- - // 2nd customization section: customize by adding new per-atom variables - // delete atom arrays - - memory->destroy(tag); - memory->destroy(type); - memory->destroy(mask); - memory->destroy(image); - memory->destroy(x); - memory->destroy(v); - memory->destroy(f); - - memory->destroy(molecule); - memory->destroy(molindex); - memory->destroy(molatom); - - memory->destroy(q); - memory->destroy(mu); - memory->destroy(omega); - memory->destroy(angmom); - memory->destroy(torque); - memory->destroy(radius); - memory->destroy(rmass); - memory->destroy(ellipsoid); - memory->destroy(line); - memory->destroy(tri); - memory->destroy(body); - - memory->destroy(sp); - memory->destroy(fm); - memory->destroy(fm_long); - - memory->destroy(vfrac); - memory->destroy(s0); - memory->destroy(x0); - - memory->destroy(spin); - memory->destroy(eradius); - memory->destroy(ervel); - memory->destroy(erforce); - memory->destroy(ervelforce); - memory->destroy(cs); - memory->destroy(csforce); - memory->destroy(vforce); - memory->destroy(etag); - - memory->destroy(rho); - memory->destroy(drho); - memory->destroy(esph); - memory->destroy(desph); - memory->destroy(cv); - memory->destroy(vest); - - // USER-MESONT package - memory->destroy(length); - memory->destroy(buckling); - memory->destroy(bond_nt); - - memory->destroy(contact_radius); - memory->destroy(smd_data_9); - memory->destroy(smd_stress); - memory->destroy(eff_plastic_strain); - memory->destroy(eff_plastic_strain_rate); - memory->destroy(damage); - - memory->destroy(dpdTheta); - memory->destroy(uCond); - memory->destroy(uMech); - memory->destroy(uChem); - memory->destroy(uCG); - memory->destroy(uCGnew); - memory->destroy(duChem); - - memory->destroy(cc); - memory->destroy(cc_flux); - memory->destroy(edpd_temp); - memory->destroy(edpd_flux); - memory->destroy(edpd_cv); - - memory->destroy(nspecial); - memory->destroy(special); - - memory->destroy(num_bond); - memory->destroy(bond_type); - memory->destroy(bond_atom); - - memory->destroy(num_angle); - memory->destroy(angle_type); - memory->destroy(angle_atom1); - memory->destroy(angle_atom2); - memory->destroy(angle_atom3); - - memory->destroy(num_dihedral); - memory->destroy(dihedral_type); - memory->destroy(dihedral_atom1); - memory->destroy(dihedral_atom2); - memory->destroy(dihedral_atom3); - memory->destroy(dihedral_atom4); - - memory->destroy(num_improper); - memory->destroy(improper_type); - memory->destroy(improper_atom1); - memory->destroy(improper_atom2); - memory->destroy(improper_atom3); - memory->destroy(improper_atom4); - - // end of customization section - // -------------------------------------------------------------------- - // delete custom atom arrays for (int i = 0; i < nivector; i++) { @@ -430,7 +321,7 @@ void Atom::peratom_create() nperatom = maxperatom = 0; // -------------------------------------------------------------------- - // 3rd customization section: add peratom variables here, order does not matter + // 2nd customization section: add peratom variables here, order does not matter // register tagint & imageint variables as INT or BIGINT int tagintsize = INT; @@ -671,7 +562,7 @@ void Atom::add_peratom_vary(const char *name, void *address, void Atom::set_atomflag_defaults() { // -------------------------------------------------------------------- - // 4th customization section: customize by adding new flag + // 3rd customization section: customize by adding new flag // identical list as 2nd customization in atom.h sphere_flag = ellipsoid_flag = line_flag = tri_flag = body_flag = 0; @@ -2462,7 +2353,7 @@ void Atom::remove_custom(int flag, int index) void *Atom::extract(char *name) { // -------------------------------------------------------------------- - // 5th customization section: customize by adding new variable name + // 4th customization section: customize by adding new variable name if (strcmp(name,"mass") == 0) return (void *) mass; diff --git a/src/atom_vec.cpp b/src/atom_vec.cpp index 708fedd15e..6a294d3ccf 100644 --- a/src/atom_vec.cpp +++ b/src/atom_vec.cpp @@ -90,9 +90,51 @@ AtomVec::AtomVec(LAMMPS *lmp) : Pointers(lmp) AtomVec::~AtomVec() { + int datatype,cols; + void *pdata; + for (int i = 0; i < nargcopy; i++) delete [] argcopy[i]; delete [] argcopy; + memory->destroy(atom->tag); + memory->destroy(atom->type); + memory->destroy(atom->mask); + memory->destroy(atom->image); + memory->destroy(atom->x); + memory->destroy(atom->v); + memory->destroy(atom->f); + + for (int i = 0; i < ngrow; i++) { + pdata = mgrow.pdata[i]; + datatype = mgrow.datatype[i]; + cols = mgrow.cols[i]; + if (datatype == Atom::DOUBLE) { + if (cols == 0) + memory->destroy(*((double **) pdata)); + else if (cols > 0) + memory->destroy(*((double ***) pdata)); + else { + memory->destroy(*((double ***) pdata)); + } + } else if (datatype == Atom::INT) { + if (cols == 0) + memory->destroy(*((int **) pdata)); + else if (cols > 0) + memory->destroy(*((int ***) pdata)); + else { + memory->destroy(*((int ***) pdata)); + } + } else if (datatype == Atom::BIGINT) { + if (cols == 0) + memory->destroy(*((bigint **) pdata)); + else if (cols > 0) + memory->destroy(*((bigint ***) pdata)); + else { + memory->destroy(*((bigint ***) pdata)); + } + } + } + destroy_method(&mgrow); destroy_method(&mcopy); destroy_method(&mcomm); @@ -2335,9 +2377,9 @@ void AtomVec::setup_fields() { int n,cols; - if (strstr(fields_data_atom,"id ") != fields_data_atom) + if (!utils::strmatch(fields_data_atom,"^id ")) error->all(FLERR,"Atom style fields_data_atom must have id as first field"); - if (strstr(fields_data_vel,"id v") != fields_data_vel) + if (!utils::strmatch(fields_data_vel,"^id v")) error->all(FLERR,"Atom style fields_data_vel must have " "'id v' as first fields"); @@ -2469,31 +2511,21 @@ int AtomVec::process_fields(char *str, const char *default_str, Method *method) for (match = 0; match < nperatom; match++) if (strcmp(field, peratom[match].name) == 0) break; - if (match == nperatom) { - char str[128]; - sprintf(str,"Peratom field %s not recognized", field); - error->all(FLERR,str); - } + if (match == nperatom) + error->all(FLERR,fmt::format("Peratom field {} not recognized", field)); index[i] = match; // error if field appears multiple times for (match = 0; match < i; match++) - if (index[i] == index[match]) { - char str[128]; - sprintf(str,"Peratom field %s is repeated", field); - error->all(FLERR,str); - } + if (index[i] == index[match]) + error->all(FLERR,fmt::format("Peratom field {} is repeated", field)); // error if field is in default str for (match = 0; match < ndef; match++) - if (strcmp(field, def_words[match].c_str()) == 0) { - char str[128]; - sprintf(str,"Peratom field %s is a default", field); - error->all(FLERR,str); - } - + if (strcmp(field, def_words[match].c_str()) == 0) + error->all(FLERR,fmt::format("Peratom field {} is a default", field)); } method->index = index; diff --git a/src/comm.cpp b/src/comm.cpp index b00308a6e5..111c4c1de4 100644 --- a/src/comm.cpp +++ b/src/comm.cpp @@ -901,7 +901,9 @@ rendezvous_irregular(int n, char *inbuf, int insize, int inorder, int *procs, if (inorder) nrvous = irregular->create_data_grouped(n,procs); else nrvous = irregular->create_data(n,procs); - char *inbuf_rvous = (char *) memory->smalloc((bigint) nrvous*insize, + // add 1 item to the allocated buffer size, so the returned pointer is not NULL + + char *inbuf_rvous = (char *) memory->smalloc((bigint) nrvous*insize+1, "rendezvous:inbuf"); irregular->exchange_data(inbuf,insize,inbuf_rvous); @@ -936,7 +938,9 @@ rendezvous_irregular(int n, char *inbuf, int insize, int inorder, int *procs, nout = irregular->create_data_grouped(nrvous_out,procs_rvous); else nout = irregular->create_data(nrvous_out,procs_rvous); - outbuf = (char *) memory->smalloc((bigint) nout*outsize, + // add 1 item to the allocated buffer size, so the returned pointer is not NULL + + outbuf = (char *) memory->smalloc((bigint) nout*outsize+1, "rendezvous:outbuf"); irregular->exchange_data(outbuf_rvous,outsize,outbuf); @@ -975,7 +979,10 @@ rendezvous_all2all(int n, char *inbuf, int insize, int inorder, int *procs, if (!inorder) { memory->create(procs_a2a,nprocs,"rendezvous:procs"); - inbuf_a2a = (char *) memory->smalloc((bigint) n*insize, + + // add 1 item to the allocated buffer size, so the returned pointer is not NULL + + inbuf_a2a = (char *) memory->smalloc((bigint) n*insize+1, "rendezvous:inbuf"); memset(inbuf_a2a,0,(bigint)n*insize*sizeof(char)); memory->create(offsets,nprocs,"rendezvous:offsets"); @@ -1038,8 +1045,9 @@ rendezvous_all2all(int n, char *inbuf, int insize, int inorder, int *procs, } // all2all comm of inbuf from caller decomp to rendezvous decomp + // add 1 item to the allocated buffer size, so the returned pointer is not NULL - char *inbuf_rvous = (char *) memory->smalloc((bigint) nrvous*insize, + char *inbuf_rvous = (char *) memory->smalloc((bigint) nrvous*insize+1, "rendezvous:inbuf"); memset(inbuf_rvous,0,(bigint) nrvous*insize*sizeof(char)); @@ -1079,7 +1087,9 @@ rendezvous_all2all(int n, char *inbuf, int insize, int inorder, int *procs, if (!outorder) { memory->create(procs_a2a,nprocs,"rendezvous_a2a:procs"); - outbuf_a2a = (char *) memory->smalloc((bigint) nrvous_out*outsize, + // add 1 item to the allocated buffer size, so the returned pointer is not NULL + + outbuf_a2a = (char *) memory->smalloc((bigint) nrvous_out*outsize+1, "rendezvous:outbuf"); memory->create(offsets,nprocs,"rendezvous:offsets"); @@ -1138,8 +1148,9 @@ rendezvous_all2all(int n, char *inbuf, int insize, int inorder, int *procs, // all2all comm of outbuf from rendezvous decomp back to caller decomp // caller will free outbuf + // add 1 item to the allocated buffer size, so the returned pointer is not NULL - outbuf = (char *) memory->smalloc((bigint) nout*outsize,"rendezvous:outbuf"); + outbuf = (char *) memory->smalloc((bigint) nout*outsize+1,"rendezvous:outbuf"); MPI_Alltoallv(outbuf_a2a,sendcount,sdispls,MPI_CHAR, outbuf,recvcount,rdispls,MPI_CHAR,world); diff --git a/src/create_atoms.cpp b/src/create_atoms.cpp index 526a2069e6..3732662295 100644 --- a/src/create_atoms.cpp +++ b/src/create_atoms.cpp @@ -193,7 +193,7 @@ void CreateAtoms::command(int narg, char **arg) if (iarg+5 > narg) error->all(FLERR,"Illegal create_atoms command"); double thetaone; double axisone[3]; - thetaone = force->numeric(FLERR,arg[iarg+1]); + thetaone = force->numeric(FLERR,arg[iarg+1]) / 180.0 * MY_PI;; axisone[0] = force->numeric(FLERR,arg[iarg+2]); axisone[1] = force->numeric(FLERR,arg[iarg+3]); axisone[2] = force->numeric(FLERR,arg[iarg+4]); diff --git a/src/error.cpp b/src/error.cpp index 392624f40b..7458f816c0 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -107,6 +107,7 @@ void Error::universe_one(const std::string &file, int line, const std::string &s throw LAMMPSAbortException(mesg, universe->uworld); #else MPI_Abort(universe->uworld,1); + exit(1); // to trick "smart" compilers into believing this does not return #endif } @@ -205,6 +206,7 @@ void Error::one(const std::string &file, int line, const std::string &str) if (screen) fflush(screen); if (logfile) fflush(logfile); MPI_Abort(world,1); + exit(1); // to trick "smart" compilers into believing this does not return #endif } diff --git a/src/error.h b/src/error.h index 23f7f64cf3..40c1559464 100644 --- a/src/error.h +++ b/src/error.h @@ -27,20 +27,20 @@ class Error : protected Pointers { public: Error(class LAMMPS *); - void universe_all(const std::string &, int, const std::string &); - void universe_one(const std::string &, int, const std::string &); + [[ noreturn ]] void universe_all(const std::string &, int, const std::string &); + [[ noreturn ]] void universe_one(const std::string &, int, const std::string &); void universe_warn(const std::string &, int, const std::string &); - void all(const std::string &, int, const std::string &); - void one(const std::string &, int, const std::string &); + [[ noreturn ]] void all(const std::string &, int, const std::string &); + [[ noreturn ]] void one(const std::string &, int, const std::string &); void warning(const std::string &, int, const std::string &, int = 1); void message(const std::string &, int, const std::string &, int = 1); - void done(int = 0); // 1 would be fully backwards compatible + [[ noreturn ]] void done(int = 0); // 1 would be fully backwards compatible #ifdef LAMMPS_EXCEPTIONS std::string get_last_error() const; ErrorType get_last_error_type() const; - void set_last_error(const std::string &msg, ErrorType type = ERROR_NORMAL); + void set_last_error(const std::string &msg, ErrorType type = ERROR_NORMAL); private: std::string last_error_message; diff --git a/src/force.cpp b/src/force.cpp index 840d7e31ca..5824e35648 100644 --- a/src/force.cpp +++ b/src/force.cpp @@ -34,6 +34,7 @@ #include "improper.h" #include "kspace.h" #include "error.h" +#include "update.h" #include "utils.h" #include "fmt/format.h" @@ -1013,15 +1014,20 @@ tagint Force::tnumeric(const char *file, int line, char *str) FILE *Force::open_potential(const char *name) { std::string filepath = utils::get_potential_file_path(name); - std::string date; if(!filepath.empty()) { - date = utils::get_potential_date(filepath, "potential"); + std::string unit_style = update->unit_style; + std::string date = utils::get_potential_date(filepath, "potential"); + std::string units = utils::get_potential_units(filepath, "potential"); if(!date.empty()) { utils::logmesg(lmp, fmt::format("Reading potential file {} " "with DATE: {}\n", name, date)); } + if (!units.empty() && (units != unit_style)) { + error->one(FLERR, fmt::format("Potential file {} requires {} units " + "but {} units are in use", name, units, unit_style)); + } return fopen(filepath.c_str(), "r"); } return nullptr; diff --git a/src/input.h b/src/input.h index 182c38b89d..a50f769561 100644 --- a/src/input.h +++ b/src/input.h @@ -24,6 +24,7 @@ class Input : protected Pointers { friend class Info; friend class Error; friend class Deprecated; + friend class SimpleCommandsTest_Echo_Test; public: int narg; // # of command args diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt index 99b5463a81..ab8c771dc8 100644 --- a/unittest/CMakeLists.txt +++ b/unittest/CMakeLists.txt @@ -1,10 +1,9 @@ include(GTest) add_subdirectory(force-styles) - add_subdirectory(utils) - add_subdirectory(formats) +add_subdirectory(commands) find_package(ClangFormat 8.0) diff --git a/unittest/commands/CMakeLists.txt b/unittest/commands/CMakeLists.txt new file mode 100644 index 0000000000..472337f1bc --- /dev/null +++ b/unittest/commands/CMakeLists.txt @@ -0,0 +1,4 @@ + +add_executable(test_simple_commands test_simple_commands.cpp) +target_link_libraries(test_simple_commands PRIVATE lammps GTest::GMock GTest::GTest) +add_test(NAME TestSimpleCommands COMMAND test_simple_commands WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/unittest/commands/test_simple_commands.cpp b/unittest/commands/test_simple_commands.cpp new file mode 100644 index 0000000000..1f5d4b5493 --- /dev/null +++ b/unittest/commands/test_simple_commands.cpp @@ -0,0 +1,135 @@ +/* ---------------------------------------------------------------------- + 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. +------------------------------------------------------------------------- */ + +#include "input.h" +#include "lammps.h" +#include "utils.h" +#include "gmock/gmock.h" +#include "gtest/gtest.h" + +#include +#include +#include +#include +#include + +// whether to print verbose output (i.e. not capturing LAMMPS screen output). +bool verbose = false; + +namespace LAMMPS_NS { +using ::testing::Eq; + +class SimpleCommandsTest : public ::testing::Test { +protected: + LAMMPS *lmp; + + void SetUp() override + { + const char *args[] = {"SimpleCommandsTest", "-log", "none", "-echo", "screen", "-nocite"}; + char **argv = (char **)args; + int argc = sizeof(args) / sizeof(char *); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD); + if (!verbose) ::testing::internal::GetCapturedStdout(); + } + + void TearDown() override + { + if (!verbose) ::testing::internal::CaptureStdout(); + delete lmp; + if (!verbose) ::testing::internal::GetCapturedStdout(); + } +}; + +TEST_F(SimpleCommandsTest, Echo) +{ + ASSERT_EQ(lmp->input->echo_screen, 1); + ASSERT_EQ(lmp->input->echo_log, 0); + + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("echo none"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_EQ(lmp->input->echo_screen, 0); + ASSERT_EQ(lmp->input->echo_log, 0); + + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("echo both"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_EQ(lmp->input->echo_screen, 1); + ASSERT_EQ(lmp->input->echo_log, 1); + + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("echo screen"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_EQ(lmp->input->echo_screen, 1); + ASSERT_EQ(lmp->input->echo_log, 0); + + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("echo log"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_EQ(lmp->input->echo_screen, 0); + ASSERT_EQ(lmp->input->echo_log, 1); +} + +TEST_F(SimpleCommandsTest, Log) +{ + ASSERT_EQ(lmp->logfile, nullptr); + + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("log simple_command_test.log"); + lmp->input->one("print 'test1'"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_NE(lmp->logfile, nullptr); + + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("log none"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_EQ(lmp->logfile, nullptr); + + std::string text; + std::ifstream in; + in.open("simple_command_test.log"); + in >> text; + in.close(); + ASSERT_THAT(text, Eq("test1")); + + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("log simple_command_test.log append"); + lmp->input->one("print 'test2'"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_NE(lmp->logfile, nullptr); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("log none"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_EQ(lmp->logfile, nullptr); + + in.open("simple_command_test.log"); + in >> text; + ASSERT_THAT(text, Eq("test1")); + in >> text; + ASSERT_THAT(text, Eq("test2")); + in.close(); + remove("simple_command_test.log"); +} +} // namespace LAMMPS_NS + +int main(int argc, char **argv) +{ + MPI_Init(&argc, &argv); + ::testing::InitGoogleMock(&argc, argv); + if ((argc > 1) && (strcmp(argv[1], "-v") == 0)) verbose = true; + + int rv = RUN_ALL_TESTS(); + MPI_Finalize(); + return rv; +} diff --git a/unittest/force-styles/CMakeLists.txt b/unittest/force-styles/CMakeLists.txt index c7937336f2..aed715ee65 100644 --- a/unittest/force-styles/CMakeLists.txt +++ b/unittest/force-styles/CMakeLists.txt @@ -15,6 +15,13 @@ if(BUILD_MPI) else() target_link_libraries(style_tests PUBLIC mpi_stubs) endif() +# propagate sanitizer options to test tools +if (NOT ENABLE_SANITIZER STREQUAL "none") + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.13) + target_compile_options(style_tests PUBLIC -fsanitize=${ENABLE_SANITIZER}) + target_link_options(style_tests PUBLIC -fsanitize=${ENABLE_SANITIZER}) + endif() +endif() # unit test for error stats class add_executable(test_error_stats test_error_stats.cpp) diff --git a/unittest/force-styles/angle_style.cpp b/unittest/force-styles/angle_style.cpp index b38d23ce55..dd4588fa74 100644 --- a/unittest/force-styles/angle_style.cpp +++ b/unittest/force-styles/angle_style.cpp @@ -87,8 +87,8 @@ LAMMPS *init_lammps(int argc, char **argv, const TestConfig &cfg, const bool new if (!info->has_style(prerequisite.first, style)) ++nfail; } + delete info; if (nfail > 0) { - delete info; cleanup_lammps(lmp, cfg); return nullptr; } diff --git a/unittest/force-styles/bond_style.cpp b/unittest/force-styles/bond_style.cpp index c2db3b608b..7ba4a08705 100644 --- a/unittest/force-styles/bond_style.cpp +++ b/unittest/force-styles/bond_style.cpp @@ -87,8 +87,8 @@ LAMMPS *init_lammps(int argc, char **argv, const TestConfig &cfg, const bool new if (!info->has_style(prerequisite.first, style)) ++nfail; } + delete info; if (nfail > 0) { - delete info; cleanup_lammps(lmp, cfg); return nullptr; } diff --git a/unittest/force-styles/pair_style.cpp b/unittest/force-styles/pair_style.cpp index 81acd872b0..9354ad7f03 100644 --- a/unittest/force-styles/pair_style.cpp +++ b/unittest/force-styles/pair_style.cpp @@ -87,8 +87,8 @@ LAMMPS *init_lammps(int argc, char **argv, const TestConfig &cfg, const bool new if (!info->has_style(prerequisite.first, style)) ++nfail; } + delete info; if (nfail > 0) { - delete info; cleanup_lammps(lmp, cfg); return nullptr; } diff --git a/unittest/force-styles/test_main.cpp b/unittest/force-styles/test_main.cpp index fc59163a60..6ff5194076 100644 --- a/unittest/force-styles/test_main.cpp +++ b/unittest/force-styles/test_main.cpp @@ -14,6 +14,7 @@ #include "test_main.h" #include "test_config.h" #include "test_config_reader.h" +#include "gmock/gmock.h" #include "gtest/gtest.h" #include @@ -63,7 +64,7 @@ std::string INPUT_FOLDER = STRINGIFY(TEST_INPUT_FOLDER); int main(int argc, char **argv) { MPI_Init(&argc, &argv); - ::testing::InitGoogleTest(&argc, argv); + ::testing::InitGoogleMock(&argc, argv); if (argc < 2) { usage(std::cerr, argv[0]); @@ -109,5 +110,8 @@ int main(int argc, char **argv) return 1; } } - return RUN_ALL_TESTS(); + + int rv = RUN_ALL_TESTS(); + MPI_Finalize(); + return rv; } diff --git a/unittest/force-styles/tests/atomic-pair-eim.yaml b/unittest/force-styles/tests/atomic-pair-eim.yaml index c3469c753a..56d18874f2 100644 --- a/unittest/force-styles/tests/atomic-pair-eim.yaml +++ b/unittest/force-styles/tests/atomic-pair-eim.yaml @@ -1,7 +1,7 @@ --- lammps_version: 5 May 2020 date_generated: Tue May 26 21:02:07 202 -epsilon: 5.0e-12 +epsilon: 1.0e-11 prerequisites: ! | pair eim pre_commands: ! "" diff --git a/unittest/force-styles/tests/manybody-pair-airebo.yaml b/unittest/force-styles/tests/manybody-pair-airebo.yaml index 5c0da81381..bf86ee82d0 100644 --- a/unittest/force-styles/tests/manybody-pair-airebo.yaml +++ b/unittest/force-styles/tests/manybody-pair-airebo.yaml @@ -1,7 +1,7 @@ --- lammps_version: 5 May 2020 date_generated: Wed May 27 16:13:46 202 -epsilon: 2e-7 +epsilon: 5e-6 prerequisites: ! | pair airebo pre_commands: ! | diff --git a/unittest/force-styles/tests/manybody-pair-polymorphic_tersoff.yaml b/unittest/force-styles/tests/manybody-pair-polymorphic_tersoff.yaml index 2f2aa14608..3cd409e95c 100644 --- a/unittest/force-styles/tests/manybody-pair-polymorphic_tersoff.yaml +++ b/unittest/force-styles/tests/manybody-pair-polymorphic_tersoff.yaml @@ -1,7 +1,7 @@ --- lammps_version: 5 May 2020 date_generated: Thu May 28 20:29:01 202 -epsilon: 1e-12 +epsilon: 1e-11 prerequisites: ! | pair polymorphic pre_commands: ! | diff --git a/unittest/force-styles/tests/manybody-pair-tersoff_mod.yaml b/unittest/force-styles/tests/manybody-pair-tersoff_mod.yaml index ae9970c15d..3d67aee32d 100644 --- a/unittest/force-styles/tests/manybody-pair-tersoff_mod.yaml +++ b/unittest/force-styles/tests/manybody-pair-tersoff_mod.yaml @@ -1,7 +1,7 @@ --- lammps_version: 5 May 2020 date_generated: Wed May 27 10:27:56 202 -epsilon: 1e-12 +epsilon: 5e-11 prerequisites: ! | pair tersoff/mod pre_commands: ! | diff --git a/unittest/force-styles/tests/manybody-pair-tersoff_mod_c.yaml b/unittest/force-styles/tests/manybody-pair-tersoff_mod_c.yaml index 871e7b88da..1d138480cf 100644 --- a/unittest/force-styles/tests/manybody-pair-tersoff_mod_c.yaml +++ b/unittest/force-styles/tests/manybody-pair-tersoff_mod_c.yaml @@ -1,7 +1,7 @@ --- lammps_version: 5 May 2020 date_generated: Wed May 27 10:28:17 202 -epsilon: 5e-13 +epsilon: 1e-12 prerequisites: ! | pair tersoff/mod/c pre_commands: ! | diff --git a/unittest/force-styles/tests/manybody-pair-tersoff_table.yaml b/unittest/force-styles/tests/manybody-pair-tersoff_table.yaml index 51220b8c8e..10c28f7335 100644 --- a/unittest/force-styles/tests/manybody-pair-tersoff_table.yaml +++ b/unittest/force-styles/tests/manybody-pair-tersoff_table.yaml @@ -1,7 +1,7 @@ --- lammps_version: 5 May 2020 date_generated: Wed May 27 12:29:41 202 -epsilon: 5e-12 +epsilon: 5e-11 prerequisites: ! | pair tersoff/table pre_commands: ! | diff --git a/unittest/force-styles/tests/manybody-pair-tersoff_zbl.yaml b/unittest/force-styles/tests/manybody-pair-tersoff_zbl.yaml index d161c10b23..dba684ab3e 100644 --- a/unittest/force-styles/tests/manybody-pair-tersoff_zbl.yaml +++ b/unittest/force-styles/tests/manybody-pair-tersoff_zbl.yaml @@ -1,7 +1,7 @@ --- lammps_version: 5 May 2020 date_generated: Wed May 27 10:29:02 202 -epsilon: 5e-12 +epsilon: 5e-11 prerequisites: ! | pair tersoff/zbl pre_commands: ! | diff --git a/unittest/force-styles/tests/mol-pair-coul_dsf.yaml b/unittest/force-styles/tests/mol-pair-coul_dsf.yaml index 496e5997ca..7a93ee81c7 100644 --- a/unittest/force-styles/tests/mol-pair-coul_dsf.yaml +++ b/unittest/force-styles/tests/mol-pair-coul_dsf.yaml @@ -1,7 +1,7 @@ --- lammps_version: 2 Jun 2020 date_generated: Sun Jun 14 14:42:09 202 -epsilon: 2e-13 +epsilon: 1e-12 prerequisites: ! | atom full pair coul/dsf diff --git a/unittest/force-styles/tests/mol-pair-lj_class2_coul_cut.yaml b/unittest/force-styles/tests/mol-pair-lj_class2_coul_cut.yaml index 5f09340637..4f2f6d86df 100644 --- a/unittest/force-styles/tests/mol-pair-lj_class2_coul_cut.yaml +++ b/unittest/force-styles/tests/mol-pair-lj_class2_coul_cut.yaml @@ -1,7 +1,7 @@ --- lammps_version: 5 May 2020 date_generated: Sat May 30 18:04:12 202 -epsilon: 5e-13 +epsilon: 5e-12 prerequisites: ! | atom full pair lj/class2/coul/cut diff --git a/unittest/force-styles/tests/mol-pair-lj_class2_coul_long.yaml b/unittest/force-styles/tests/mol-pair-lj_class2_coul_long.yaml index b358010160..c77348089d 100644 --- a/unittest/force-styles/tests/mol-pair-lj_class2_coul_long.yaml +++ b/unittest/force-styles/tests/mol-pair-lj_class2_coul_long.yaml @@ -1,7 +1,7 @@ --- lammps_version: 5 May 2020 date_generated: Fri May 15 19:08:06 202 -epsilon: 5.0e-13 +epsilon: 5.0e-12 prerequisites: ! | atom full pair lj/class2/coul/long diff --git a/unittest/force-styles/tests/mol-pair-lj_class2_coul_table.yaml b/unittest/force-styles/tests/mol-pair-lj_class2_coul_table.yaml index 4e85b29b2a..d7857de99b 100644 --- a/unittest/force-styles/tests/mol-pair-lj_class2_coul_table.yaml +++ b/unittest/force-styles/tests/mol-pair-lj_class2_coul_table.yaml @@ -1,7 +1,7 @@ --- lammps_version: 5 May 2020 date_generated: Fri May 15 19:08:06 202 -epsilon: 5.0e-13 +epsilon: 5.0e-12 prerequisites: ! | atom full pair lj/class2/coul/long diff --git a/unittest/formats/CMakeLists.txt b/unittest/formats/CMakeLists.txt index 848fc0b6c7..aaf6731855 100644 --- a/unittest/formats/CMakeLists.txt +++ b/unittest/formats/CMakeLists.txt @@ -1,3 +1,8 @@ + +add_executable(test_atom_styles test_atom_styles.cpp) +target_link_libraries(test_atom_styles PRIVATE lammps GTest::GMock GTest::GTest) +add_test(NAME AtomStyles COMMAND test_atom_styles WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + 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}) diff --git a/unittest/formats/test_atom_styles.cpp b/unittest/formats/test_atom_styles.cpp new file mode 100644 index 0000000000..614a72e678 --- /dev/null +++ b/unittest/formats/test_atom_styles.cpp @@ -0,0 +1,756 @@ +/* ---------------------------------------------------------------------- + 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. +------------------------------------------------------------------------- */ + +#include "atom.h" +#include "input.h" +#include "lammps.h" +#include "utils.h" +#include "gmock/gmock.h" +#include "gtest/gtest.h" + +#include +#include +#include + +#if !defined(_FORTIFY_SOURCE) || (_FORTIFY_SOURCE == 0) +#if defined(__INTEL_COMPILER) +#define _do_nothing +#elif defined(__GNUC__) +#if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 9)) +#pragma GCC optimize("no-var-tracking-assignments", "O0") +#else +#pragma GCC optimize("no-var-tracking-assignments") +#endif +#else +#define _do_nothing +#endif +#endif + +// whether to print verbose output (i.e. not capturing LAMMPS screen output). +bool verbose = false; + +namespace LAMMPS_NS { +using ::testing::Eq; + +class AtomStyleTest : public ::testing::Test { +protected: + LAMMPS *lmp; + + void SetUp() override + { + const char *args[] = {"SimpleCommandsTest", "-log", "none", "-echo", "screen", "-nocite"}; + char **argv = (char **)args; + int argc = sizeof(args) / sizeof(char *); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_NE(lmp, nullptr); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("units real"); + lmp->input->one("dimension 3"); + lmp->input->one("pair_style zero 4.0"); + lmp->input->one("region box block -4 4 -4 4 -4 4"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + } + + void TearDown() override + { + if (!verbose) ::testing::internal::CaptureStdout(); + delete lmp; + if (!verbose) ::testing::internal::GetCapturedStdout(); + remove("test_atom_styles.data"); + remove("test_atom_styles.restart"); + } +}; + +TEST_F(AtomStyleTest, atomic) +{ + ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("atomic")); + ASSERT_NE(lmp->atom->avec, nullptr); + ASSERT_EQ(lmp->atom->natoms, 0); + ASSERT_EQ(lmp->atom->nlocal, 0); + ASSERT_EQ(lmp->atom->nghost, 0); + ASSERT_EQ(lmp->atom->nmax, 1); + ASSERT_EQ(lmp->atom->tag_enable, 1); + ASSERT_EQ(lmp->atom->molecular, 0); + ASSERT_EQ(lmp->atom->nellipsoids, 0); + ASSERT_EQ(lmp->atom->nlines, 0); + ASSERT_EQ(lmp->atom->ntris, 0); + ASSERT_EQ(lmp->atom->nbodies, 0); + ASSERT_EQ(lmp->atom->nbonds, 0); + ASSERT_EQ(lmp->atom->nangles, 0); + ASSERT_EQ(lmp->atom->ndihedrals, 0); + ASSERT_EQ(lmp->atom->nimpropers, 0); + ASSERT_EQ(lmp->atom->ntypes, 0); + ASSERT_EQ(lmp->atom->nbondtypes, 0); + ASSERT_EQ(lmp->atom->nangletypes, 0); + ASSERT_EQ(lmp->atom->ndihedraltypes, 0); + ASSERT_EQ(lmp->atom->nimpropertypes, 0); + ASSERT_EQ(lmp->atom->bond_per_atom, 0); + ASSERT_EQ(lmp->atom->angle_per_atom, 0); + ASSERT_EQ(lmp->atom->dihedral_per_atom, 0); + ASSERT_EQ(lmp->atom->improper_per_atom, 0); + ASSERT_EQ(lmp->atom->extra_bond_per_atom, 0); + ASSERT_EQ(lmp->atom->extra_angle_per_atom, 0); + ASSERT_EQ(lmp->atom->extra_dihedral_per_atom, 0); + ASSERT_EQ(lmp->atom->extra_improper_per_atom, 0); + + ASSERT_EQ(lmp->atom->sphere_flag, 0); + ASSERT_EQ(lmp->atom->ellipsoid_flag, 0); + ASSERT_EQ(lmp->atom->line_flag, 0); + ASSERT_EQ(lmp->atom->tri_flag, 0); + ASSERT_EQ(lmp->atom->body_flag, 0); + ASSERT_EQ(lmp->atom->peri_flag, 0); + ASSERT_EQ(lmp->atom->electron_flag, 0); + ASSERT_EQ(lmp->atom->wavepacket_flag, 0); + ASSERT_EQ(lmp->atom->sph_flag, 0); + ASSERT_EQ(lmp->atom->molecule_flag, 0); + ASSERT_EQ(lmp->atom->molindex_flag, 0); + ASSERT_EQ(lmp->atom->molatom_flag, 0); + ASSERT_EQ(lmp->atom->q_flag, 0); + ASSERT_EQ(lmp->atom->mu_flag, 0); + ASSERT_EQ(lmp->atom->rmass_flag, 0); + ASSERT_EQ(lmp->atom->radius_flag, 0); + ASSERT_EQ(lmp->atom->omega_flag, 0); + ASSERT_EQ(lmp->atom->torque_flag, 0); + ASSERT_EQ(lmp->atom->angmom_flag, 0); + ASSERT_EQ(lmp->atom->vfrac_flag, 0); + ASSERT_EQ(lmp->atom->spin_flag, 0); + ASSERT_EQ(lmp->atom->eradius_flag, 0); + ASSERT_EQ(lmp->atom->ervel_flag, 0); + ASSERT_EQ(lmp->atom->erforce_flag, 0); + ASSERT_EQ(lmp->atom->cs_flag, 0); + ASSERT_EQ(lmp->atom->csforce_flag, 0); + ASSERT_EQ(lmp->atom->vforce_flag, 0); + ASSERT_EQ(lmp->atom->ervelforce_flag, 0); + ASSERT_EQ(lmp->atom->etag_flag, 0); + ASSERT_EQ(lmp->atom->rho_flag, 0); + ASSERT_EQ(lmp->atom->esph_flag, 0); + ASSERT_EQ(lmp->atom->cv_flag, 0); + ASSERT_EQ(lmp->atom->vest_flag, 0); + ASSERT_EQ(lmp->atom->dpd_flag, 0); + ASSERT_EQ(lmp->atom->edpd_flag, 0); + ASSERT_EQ(lmp->atom->tdpd_flag, 0); + ASSERT_EQ(lmp->atom->mesont_flag, 0); + ASSERT_EQ(lmp->atom->sp_flag, 0); + ASSERT_EQ(lmp->atom->x0_flag, 0); + ASSERT_EQ(lmp->atom->smd_flag, 0); + ASSERT_EQ(lmp->atom->damage_flag, 0); + ASSERT_EQ(lmp->atom->contact_radius_flag, 0); + ASSERT_EQ(lmp->atom->smd_data_9_flag, 0); + ASSERT_EQ(lmp->atom->smd_stress_flag, 0); + ASSERT_EQ(lmp->atom->eff_plastic_strain_flag, 0); + ASSERT_EQ(lmp->atom->eff_plastic_strain_rate_flag, 0); + ASSERT_EQ(lmp->atom->pdscale, 1.0); + + ASSERT_NE(lmp->atom->tag, nullptr); + ASSERT_NE(lmp->atom->type, nullptr); + ASSERT_NE(lmp->atom->mask, nullptr); + ASSERT_NE(lmp->atom->image, nullptr); + ASSERT_NE(lmp->atom->x, nullptr); + ASSERT_NE(lmp->atom->v, nullptr); + ASSERT_NE(lmp->atom->f, nullptr); + ASSERT_EQ(lmp->atom->q, nullptr); + ASSERT_EQ(lmp->atom->mu, nullptr); + ASSERT_EQ(lmp->atom->omega, nullptr); + ASSERT_EQ(lmp->atom->angmom, nullptr); + ASSERT_EQ(lmp->atom->torque, nullptr); + ASSERT_EQ(lmp->atom->radius, nullptr); + ASSERT_EQ(lmp->atom->rmass, nullptr); + ASSERT_EQ(lmp->atom->ellipsoid, nullptr); + ASSERT_EQ(lmp->atom->line, nullptr); + ASSERT_EQ(lmp->atom->tri, nullptr); + ASSERT_EQ(lmp->atom->body, nullptr); + ASSERT_EQ(lmp->atom->molecule, nullptr); + ASSERT_EQ(lmp->atom->molindex, nullptr); + ASSERT_EQ(lmp->atom->molatom, nullptr); + ASSERT_EQ(lmp->atom->num_bond, nullptr); + ASSERT_EQ(lmp->atom->bond_type, nullptr); + ASSERT_EQ(lmp->atom->bond_atom, nullptr); + ASSERT_EQ(lmp->atom->num_angle, nullptr); + ASSERT_EQ(lmp->atom->angle_type, nullptr); + ASSERT_EQ(lmp->atom->angle_atom1, nullptr); + ASSERT_EQ(lmp->atom->angle_atom2, nullptr); + ASSERT_EQ(lmp->atom->angle_atom3, nullptr); + ASSERT_EQ(lmp->atom->num_dihedral, nullptr); + ASSERT_EQ(lmp->atom->dihedral_type, nullptr); + ASSERT_EQ(lmp->atom->dihedral_atom1, nullptr); + ASSERT_EQ(lmp->atom->dihedral_atom2, nullptr); + ASSERT_EQ(lmp->atom->dihedral_atom3, nullptr); + ASSERT_EQ(lmp->atom->dihedral_atom4, nullptr); + ASSERT_EQ(lmp->atom->num_improper, nullptr); + ASSERT_EQ(lmp->atom->improper_type, nullptr); + ASSERT_EQ(lmp->atom->improper_atom1, nullptr); + ASSERT_EQ(lmp->atom->improper_atom2, nullptr); + ASSERT_EQ(lmp->atom->improper_atom3, nullptr); + ASSERT_EQ(lmp->atom->improper_atom4, nullptr); + ASSERT_EQ(lmp->atom->maxspecial, 1); + ASSERT_EQ(lmp->atom->nspecial, nullptr); + ASSERT_EQ(lmp->atom->special, nullptr); + ASSERT_EQ(lmp->atom->vfrac, nullptr); + ASSERT_EQ(lmp->atom->s0, nullptr); + ASSERT_EQ(lmp->atom->x0, nullptr); + ASSERT_EQ(lmp->atom->sp, nullptr); + ASSERT_EQ(lmp->atom->fm, nullptr); + ASSERT_EQ(lmp->atom->fm_long, nullptr); + ASSERT_EQ(lmp->atom->spin, nullptr); + ASSERT_EQ(lmp->atom->eradius, nullptr); + ASSERT_EQ(lmp->atom->ervel, nullptr); + ASSERT_EQ(lmp->atom->erforce, nullptr); + ASSERT_EQ(lmp->atom->ervelforce, nullptr); + ASSERT_EQ(lmp->atom->cs, nullptr); + ASSERT_EQ(lmp->atom->csforce, nullptr); + ASSERT_EQ(lmp->atom->vforce, nullptr); + ASSERT_EQ(lmp->atom->etag, nullptr); + ASSERT_EQ(lmp->atom->uCond, nullptr); + ASSERT_EQ(lmp->atom->uMech, nullptr); + ASSERT_EQ(lmp->atom->uChem, nullptr); + ASSERT_EQ(lmp->atom->uCG, nullptr); + ASSERT_EQ(lmp->atom->uCGnew, nullptr); + ASSERT_EQ(lmp->atom->duChem, nullptr); + ASSERT_EQ(lmp->atom->dpdTheta, nullptr); + ASSERT_EQ(lmp->atom->cc, nullptr); + ASSERT_EQ(lmp->atom->cc_flux, nullptr); + ASSERT_EQ(lmp->atom->edpd_temp, nullptr); + ASSERT_EQ(lmp->atom->edpd_flux, nullptr); + ASSERT_EQ(lmp->atom->edpd_cv, nullptr); + ASSERT_EQ(lmp->atom->length, nullptr); + ASSERT_EQ(lmp->atom->buckling, nullptr); + ASSERT_EQ(lmp->atom->bond_nt, nullptr); + ASSERT_EQ(lmp->atom->contact_radius, nullptr); + ASSERT_EQ(lmp->atom->smd_data_9, nullptr); + ASSERT_EQ(lmp->atom->smd_stress, nullptr); + ASSERT_EQ(lmp->atom->eff_plastic_strain, nullptr); + ASSERT_EQ(lmp->atom->eff_plastic_strain_rate, nullptr); + ASSERT_EQ(lmp->atom->damage, nullptr); + ASSERT_EQ(lmp->atom->rho, nullptr); + ASSERT_EQ(lmp->atom->drho, nullptr); + ASSERT_EQ(lmp->atom->esph, nullptr); + ASSERT_EQ(lmp->atom->desph, nullptr); + ASSERT_EQ(lmp->atom->cv, nullptr); + ASSERT_EQ(lmp->atom->vest, nullptr); + ASSERT_EQ(lmp->atom->nmolecule, 0); + ASSERT_EQ(lmp->atom->molecules, nullptr); + ASSERT_EQ(lmp->atom->nivector, 0); + ASSERT_EQ(lmp->atom->ndvector, 0); + ASSERT_EQ(lmp->atom->iname, nullptr); + ASSERT_EQ(lmp->atom->dname, nullptr); + ASSERT_EQ(lmp->atom->mass, nullptr); + ASSERT_EQ(lmp->atom->mass_setflag, nullptr); + ASSERT_EQ(lmp->atom->nextra_grow, 0); + ASSERT_EQ(lmp->atom->nextra_restart, 0); + ASSERT_EQ(lmp->atom->nextra_border, 0); + ASSERT_EQ(lmp->atom->nextra_grow_max, 0); + ASSERT_EQ(lmp->atom->nextra_restart_max, 0); + ASSERT_EQ(lmp->atom->nextra_border_max, 0); + ASSERT_EQ(lmp->atom->nextra_store, 0); + ASSERT_EQ(lmp->atom->extra_grow, nullptr); + ASSERT_EQ(lmp->atom->extra_restart, nullptr); + ASSERT_EQ(lmp->atom->extra_border, nullptr); + ASSERT_EQ(lmp->atom->extra, nullptr); + ASSERT_EQ(lmp->atom->sametag, nullptr); + ASSERT_EQ(lmp->atom->map_style, 0); + ASSERT_EQ(lmp->atom->map_user, 0); + ASSERT_EQ(lmp->atom->map_tag_max, -1); + + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("atom_style charge"); + lmp->input->one("atom_style atomic"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + + ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("atomic")); + ASSERT_NE(lmp->atom->avec, nullptr); + ASSERT_EQ(lmp->atom->natoms, 0); + ASSERT_EQ(lmp->atom->nlocal, 0); + ASSERT_EQ(lmp->atom->nghost, 0); + ASSERT_EQ(lmp->atom->nmax, 1); + ASSERT_EQ(lmp->atom->tag_enable, 1); + ASSERT_EQ(lmp->atom->molecular, 0); + ASSERT_EQ(lmp->atom->ntypes, 0); + + ASSERT_EQ(lmp->atom->molecule_flag, 0); + ASSERT_EQ(lmp->atom->molindex_flag, 0); + ASSERT_EQ(lmp->atom->molatom_flag, 0); + + ASSERT_EQ(lmp->atom->q_flag, 0); + ASSERT_EQ(lmp->atom->q, nullptr); + + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("atom_modify map hash"); + lmp->input->one("create_box 2 box"); + lmp->input->one("create_atoms 1 single -2.0 2.0 0.1"); + lmp->input->one("create_atoms 1 single -2.0 -2.0 -0.1"); + lmp->input->one("create_atoms 2 single 2.0 2.0 -0.1"); + lmp->input->one("create_atoms 2 single 2.0 -2.0 0.1"); + lmp->input->one("mass 1 4.0"); + lmp->input->one("mass 2 2.4"); + lmp->input->one("pair_coeff * *"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("atomic")); + ASSERT_NE(lmp->atom->avec, nullptr); + ASSERT_EQ(lmp->atom->natoms, 4); + ASSERT_EQ(lmp->atom->nlocal, 4); + ASSERT_EQ(lmp->atom->nghost, 0); + ASSERT_NE(lmp->atom->nmax, -1); + ASSERT_EQ(lmp->atom->tag_enable, 1); + ASSERT_EQ(lmp->atom->molecular, 0); + ASSERT_EQ(lmp->atom->ntypes, 2); + + ASSERT_NE(lmp->atom->mass, nullptr); + ASSERT_NE(lmp->atom->mass_setflag, nullptr); + ASSERT_NE(lmp->atom->sametag, nullptr); + ASSERT_EQ(lmp->atom->map_style, 2); + ASSERT_EQ(lmp->atom->map_user, 2); + ASSERT_EQ(lmp->atom->map_tag_max, 4); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("pair_coeff * *"); + lmp->input->one("write_data test_atom_styles.data nocoeff"); + lmp->input->one("clear"); + lmp->input->one("atom_style atomic"); + lmp->input->one("pair_style zero 4.0"); + lmp->input->one("atom_modify map array"); + lmp->input->one("units real"); + lmp->input->one("read_data test_atom_styles.data"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("atomic")); + ASSERT_NE(lmp->atom->avec, nullptr); + ASSERT_EQ(lmp->atom->natoms, 4); + ASSERT_EQ(lmp->atom->nlocal, 4); + ASSERT_EQ(lmp->atom->nghost, 0); + ASSERT_NE(lmp->atom->nmax, -1); + ASSERT_EQ(lmp->atom->tag_enable, 1); + ASSERT_EQ(lmp->atom->molecular, 0); + ASSERT_EQ(lmp->atom->ntypes, 2); + + double **x = lmp->atom->x; + double **v = lmp->atom->v; + ASSERT_DOUBLE_EQ(x[0][0], -2.0); + ASSERT_DOUBLE_EQ(x[0][1], 2.0); + ASSERT_DOUBLE_EQ(x[0][2], 0.1); + ASSERT_DOUBLE_EQ(x[1][0], -2.0); + ASSERT_DOUBLE_EQ(x[1][1], -2.0); + ASSERT_DOUBLE_EQ(x[1][2], -0.1); + ASSERT_DOUBLE_EQ(x[2][0], 2.0); + ASSERT_DOUBLE_EQ(x[2][1], 2.0); + ASSERT_DOUBLE_EQ(x[2][2], -0.1); + ASSERT_DOUBLE_EQ(x[3][0], 2.0); + ASSERT_DOUBLE_EQ(x[3][1], -2.0); + ASSERT_DOUBLE_EQ(x[3][2], 0.1); + ASSERT_DOUBLE_EQ(v[0][0], 0.0); + ASSERT_DOUBLE_EQ(v[0][1], 0.0); + ASSERT_DOUBLE_EQ(v[0][2], 0.0); + ASSERT_DOUBLE_EQ(v[1][0], 0.0); + ASSERT_DOUBLE_EQ(v[1][1], 0.0); + ASSERT_DOUBLE_EQ(v[1][2], 0.0); + ASSERT_DOUBLE_EQ(v[2][0], 0.0); + ASSERT_DOUBLE_EQ(v[2][1], 0.0); + ASSERT_DOUBLE_EQ(v[2][2], 0.0); + ASSERT_DOUBLE_EQ(v[3][0], 0.0); + ASSERT_DOUBLE_EQ(v[3][1], 0.0); + ASSERT_DOUBLE_EQ(v[3][2], 0.0); + + ASSERT_DOUBLE_EQ(lmp->atom->mass[1], 4.0); + ASSERT_DOUBLE_EQ(lmp->atom->mass[2], 2.4); + ASSERT_EQ(lmp->atom->mass_setflag[1], 1); + ASSERT_EQ(lmp->atom->mass_setflag[2], 1); + ASSERT_EQ(lmp->atom->map_style, 1); + ASSERT_EQ(lmp->atom->map_user, 1); + ASSERT_EQ(lmp->atom->map_tag_max, 4); + ASSERT_EQ(lmp->atom->tag_consecutive(), 1); + + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("pair_coeff * *"); + lmp->input->one("group two id 2:4:2"); + lmp->input->one("delete_atoms group two compress no"); + lmp->input->one("write_restart test_atom_styles.restart"); + lmp->input->one("clear"); + lmp->input->one("read_restart test_atom_styles.restart"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("atomic")); + ASSERT_NE(lmp->atom->avec, nullptr); + ASSERT_EQ(lmp->atom->natoms, 2); + ASSERT_EQ(lmp->atom->nlocal, 2); + ASSERT_EQ(lmp->atom->nghost, 0); + ASSERT_NE(lmp->atom->nmax, -1); + ASSERT_EQ(lmp->atom->tag_enable, 1); + ASSERT_EQ(lmp->atom->molecular, 0); + ASSERT_EQ(lmp->atom->ntypes, 2); + ASSERT_EQ(lmp->atom->tag_consecutive(), 0); + + x = lmp->atom->x; + v = lmp->atom->v; + ASSERT_DOUBLE_EQ(x[0][0], -2.0); + ASSERT_DOUBLE_EQ(x[0][1], 2.0); + ASSERT_DOUBLE_EQ(x[0][2], 0.1); + ASSERT_DOUBLE_EQ(x[1][0], 2.0); + ASSERT_DOUBLE_EQ(x[1][1], 2.0); + ASSERT_DOUBLE_EQ(x[1][2], -0.1); + ASSERT_DOUBLE_EQ(v[0][0], 0.0); + ASSERT_DOUBLE_EQ(v[0][1], 0.0); + ASSERT_DOUBLE_EQ(v[0][2], 0.0); + ASSERT_DOUBLE_EQ(v[1][0], 0.0); + ASSERT_DOUBLE_EQ(v[1][1], 0.0); + ASSERT_DOUBLE_EQ(v[1][2], 0.0); + + ASSERT_DOUBLE_EQ(lmp->atom->mass[1], 4.0); + ASSERT_DOUBLE_EQ(lmp->atom->mass[2], 2.4); + ASSERT_EQ(lmp->atom->mass_setflag[1], 1); + ASSERT_EQ(lmp->atom->mass_setflag[2], 1); + ASSERT_EQ(lmp->atom->map_style, 1); + ASSERT_EQ(lmp->atom->map_user, 1); + ASSERT_EQ(lmp->atom->map_tag_max, 3); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("reset_ids"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_EQ(lmp->atom->map_tag_max, 2); + ASSERT_EQ(lmp->atom->tag_consecutive(), 1); +} + +TEST_F(AtomStyleTest, charge) +{ + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("atom_style charge"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("charge")); + ASSERT_NE(lmp->atom->avec, nullptr); + ASSERT_EQ(lmp->atom->natoms, 0); + ASSERT_EQ(lmp->atom->nlocal, 0); + ASSERT_EQ(lmp->atom->nghost, 0); + ASSERT_EQ(lmp->atom->nmax, 1); + ASSERT_EQ(lmp->atom->tag_enable, 1); + ASSERT_EQ(lmp->atom->molecular, 0); + ASSERT_EQ(lmp->atom->nellipsoids, 0); + ASSERT_EQ(lmp->atom->nlines, 0); + ASSERT_EQ(lmp->atom->ntris, 0); + ASSERT_EQ(lmp->atom->nbodies, 0); + ASSERT_EQ(lmp->atom->nbonds, 0); + ASSERT_EQ(lmp->atom->nangles, 0); + ASSERT_EQ(lmp->atom->ndihedrals, 0); + ASSERT_EQ(lmp->atom->nimpropers, 0); + ASSERT_EQ(lmp->atom->ntypes, 0); + ASSERT_EQ(lmp->atom->nbondtypes, 0); + ASSERT_EQ(lmp->atom->nangletypes, 0); + ASSERT_EQ(lmp->atom->ndihedraltypes, 0); + ASSERT_EQ(lmp->atom->nimpropertypes, 0); + ASSERT_EQ(lmp->atom->bond_per_atom, 0); + ASSERT_EQ(lmp->atom->angle_per_atom, 0); + ASSERT_EQ(lmp->atom->dihedral_per_atom, 0); + ASSERT_EQ(lmp->atom->improper_per_atom, 0); + ASSERT_EQ(lmp->atom->extra_bond_per_atom, 0); + ASSERT_EQ(lmp->atom->extra_angle_per_atom, 0); + ASSERT_EQ(lmp->atom->extra_dihedral_per_atom, 0); + ASSERT_EQ(lmp->atom->extra_improper_per_atom, 0); + + ASSERT_EQ(lmp->atom->sphere_flag, 0); + ASSERT_EQ(lmp->atom->ellipsoid_flag, 0); + ASSERT_EQ(lmp->atom->line_flag, 0); + ASSERT_EQ(lmp->atom->tri_flag, 0); + ASSERT_EQ(lmp->atom->body_flag, 0); + ASSERT_EQ(lmp->atom->peri_flag, 0); + ASSERT_EQ(lmp->atom->electron_flag, 0); + ASSERT_EQ(lmp->atom->wavepacket_flag, 0); + ASSERT_EQ(lmp->atom->sph_flag, 0); + ASSERT_EQ(lmp->atom->molecule_flag, 0); + ASSERT_EQ(lmp->atom->molindex_flag, 0); + ASSERT_EQ(lmp->atom->molatom_flag, 0); + ASSERT_EQ(lmp->atom->q_flag, 1); + ASSERT_EQ(lmp->atom->mu_flag, 0); + ASSERT_EQ(lmp->atom->rmass_flag, 0); + ASSERT_EQ(lmp->atom->radius_flag, 0); + ASSERT_EQ(lmp->atom->omega_flag, 0); + ASSERT_EQ(lmp->atom->torque_flag, 0); + ASSERT_EQ(lmp->atom->angmom_flag, 0); + ASSERT_EQ(lmp->atom->vfrac_flag, 0); + ASSERT_EQ(lmp->atom->spin_flag, 0); + ASSERT_EQ(lmp->atom->eradius_flag, 0); + ASSERT_EQ(lmp->atom->ervel_flag, 0); + ASSERT_EQ(lmp->atom->erforce_flag, 0); + ASSERT_EQ(lmp->atom->cs_flag, 0); + ASSERT_EQ(lmp->atom->csforce_flag, 0); + ASSERT_EQ(lmp->atom->vforce_flag, 0); + ASSERT_EQ(lmp->atom->ervelforce_flag, 0); + ASSERT_EQ(lmp->atom->etag_flag, 0); + ASSERT_EQ(lmp->atom->rho_flag, 0); + ASSERT_EQ(lmp->atom->esph_flag, 0); + ASSERT_EQ(lmp->atom->cv_flag, 0); + ASSERT_EQ(lmp->atom->vest_flag, 0); + ASSERT_EQ(lmp->atom->dpd_flag, 0); + ASSERT_EQ(lmp->atom->edpd_flag, 0); + ASSERT_EQ(lmp->atom->tdpd_flag, 0); + ASSERT_EQ(lmp->atom->mesont_flag, 0); + ASSERT_EQ(lmp->atom->sp_flag, 0); + ASSERT_EQ(lmp->atom->x0_flag, 0); + ASSERT_EQ(lmp->atom->smd_flag, 0); + ASSERT_EQ(lmp->atom->damage_flag, 0); + ASSERT_EQ(lmp->atom->contact_radius_flag, 0); + ASSERT_EQ(lmp->atom->smd_data_9_flag, 0); + ASSERT_EQ(lmp->atom->smd_stress_flag, 0); + ASSERT_EQ(lmp->atom->eff_plastic_strain_flag, 0); + ASSERT_EQ(lmp->atom->eff_plastic_strain_rate_flag, 0); + ASSERT_EQ(lmp->atom->pdscale, 1.0); + + ASSERT_NE(lmp->atom->tag, nullptr); + ASSERT_NE(lmp->atom->type, nullptr); + ASSERT_NE(lmp->atom->mask, nullptr); + ASSERT_NE(lmp->atom->image, nullptr); + ASSERT_NE(lmp->atom->x, nullptr); + ASSERT_NE(lmp->atom->v, nullptr); + ASSERT_NE(lmp->atom->f, nullptr); + ASSERT_NE(lmp->atom->q, nullptr); + ASSERT_EQ(lmp->atom->mu, nullptr); + ASSERT_EQ(lmp->atom->omega, nullptr); + ASSERT_EQ(lmp->atom->angmom, nullptr); + ASSERT_EQ(lmp->atom->torque, nullptr); + ASSERT_EQ(lmp->atom->radius, nullptr); + ASSERT_EQ(lmp->atom->rmass, nullptr); + ASSERT_EQ(lmp->atom->ellipsoid, nullptr); + ASSERT_EQ(lmp->atom->line, nullptr); + ASSERT_EQ(lmp->atom->tri, nullptr); + ASSERT_EQ(lmp->atom->body, nullptr); + ASSERT_EQ(lmp->atom->molecule, nullptr); + ASSERT_EQ(lmp->atom->molindex, nullptr); + ASSERT_EQ(lmp->atom->molatom, nullptr); + ASSERT_EQ(lmp->atom->num_bond, nullptr); + ASSERT_EQ(lmp->atom->bond_type, nullptr); + ASSERT_EQ(lmp->atom->bond_atom, nullptr); + ASSERT_EQ(lmp->atom->num_angle, nullptr); + ASSERT_EQ(lmp->atom->angle_type, nullptr); + ASSERT_EQ(lmp->atom->angle_atom1, nullptr); + ASSERT_EQ(lmp->atom->angle_atom2, nullptr); + ASSERT_EQ(lmp->atom->angle_atom3, nullptr); + ASSERT_EQ(lmp->atom->num_dihedral, nullptr); + ASSERT_EQ(lmp->atom->dihedral_type, nullptr); + ASSERT_EQ(lmp->atom->dihedral_atom1, nullptr); + ASSERT_EQ(lmp->atom->dihedral_atom2, nullptr); + ASSERT_EQ(lmp->atom->dihedral_atom3, nullptr); + ASSERT_EQ(lmp->atom->dihedral_atom4, nullptr); + ASSERT_EQ(lmp->atom->num_improper, nullptr); + ASSERT_EQ(lmp->atom->improper_type, nullptr); + ASSERT_EQ(lmp->atom->improper_atom1, nullptr); + ASSERT_EQ(lmp->atom->improper_atom2, nullptr); + ASSERT_EQ(lmp->atom->improper_atom3, nullptr); + ASSERT_EQ(lmp->atom->improper_atom4, nullptr); + ASSERT_EQ(lmp->atom->maxspecial, 1); + ASSERT_EQ(lmp->atom->nspecial, nullptr); + ASSERT_EQ(lmp->atom->special, nullptr); + ASSERT_EQ(lmp->atom->vfrac, nullptr); + ASSERT_EQ(lmp->atom->s0, nullptr); + ASSERT_EQ(lmp->atom->x0, nullptr); + ASSERT_EQ(lmp->atom->sp, nullptr); + ASSERT_EQ(lmp->atom->fm, nullptr); + ASSERT_EQ(lmp->atom->fm_long, nullptr); + ASSERT_EQ(lmp->atom->spin, nullptr); + ASSERT_EQ(lmp->atom->eradius, nullptr); + ASSERT_EQ(lmp->atom->ervel, nullptr); + ASSERT_EQ(lmp->atom->erforce, nullptr); + ASSERT_EQ(lmp->atom->ervelforce, nullptr); + ASSERT_EQ(lmp->atom->cs, nullptr); + ASSERT_EQ(lmp->atom->csforce, nullptr); + ASSERT_EQ(lmp->atom->vforce, nullptr); + ASSERT_EQ(lmp->atom->etag, nullptr); + ASSERT_EQ(lmp->atom->uCond, nullptr); + ASSERT_EQ(lmp->atom->uMech, nullptr); + ASSERT_EQ(lmp->atom->uChem, nullptr); + ASSERT_EQ(lmp->atom->uCG, nullptr); + ASSERT_EQ(lmp->atom->uCGnew, nullptr); + ASSERT_EQ(lmp->atom->duChem, nullptr); + ASSERT_EQ(lmp->atom->dpdTheta, nullptr); + ASSERT_EQ(lmp->atom->cc, nullptr); + ASSERT_EQ(lmp->atom->cc_flux, nullptr); + ASSERT_EQ(lmp->atom->edpd_temp, nullptr); + ASSERT_EQ(lmp->atom->edpd_flux, nullptr); + ASSERT_EQ(lmp->atom->edpd_cv, nullptr); + ASSERT_EQ(lmp->atom->length, nullptr); + ASSERT_EQ(lmp->atom->buckling, nullptr); + ASSERT_EQ(lmp->atom->bond_nt, nullptr); + ASSERT_EQ(lmp->atom->contact_radius, nullptr); + ASSERT_EQ(lmp->atom->smd_data_9, nullptr); + ASSERT_EQ(lmp->atom->smd_stress, nullptr); + ASSERT_EQ(lmp->atom->eff_plastic_strain, nullptr); + ASSERT_EQ(lmp->atom->eff_plastic_strain_rate, nullptr); + ASSERT_EQ(lmp->atom->damage, nullptr); + ASSERT_EQ(lmp->atom->rho, nullptr); + ASSERT_EQ(lmp->atom->drho, nullptr); + ASSERT_EQ(lmp->atom->esph, nullptr); + ASSERT_EQ(lmp->atom->desph, nullptr); + ASSERT_EQ(lmp->atom->cv, nullptr); + ASSERT_EQ(lmp->atom->vest, nullptr); + ASSERT_EQ(lmp->atom->nmolecule, 0); + ASSERT_EQ(lmp->atom->molecules, nullptr); + ASSERT_EQ(lmp->atom->nivector, 0); + ASSERT_EQ(lmp->atom->ndvector, 0); + ASSERT_EQ(lmp->atom->iname, nullptr); + ASSERT_EQ(lmp->atom->dname, nullptr); + ASSERT_EQ(lmp->atom->mass, nullptr); + ASSERT_EQ(lmp->atom->mass_setflag, nullptr); + ASSERT_EQ(lmp->atom->nextra_grow, 0); + ASSERT_EQ(lmp->atom->nextra_restart, 0); + ASSERT_EQ(lmp->atom->nextra_border, 0); + ASSERT_EQ(lmp->atom->nextra_grow_max, 0); + ASSERT_EQ(lmp->atom->nextra_restart_max, 0); + ASSERT_EQ(lmp->atom->nextra_border_max, 0); + ASSERT_EQ(lmp->atom->nextra_store, 0); + ASSERT_EQ(lmp->atom->extra_grow, nullptr); + ASSERT_EQ(lmp->atom->extra_restart, nullptr); + ASSERT_EQ(lmp->atom->extra_border, nullptr); + ASSERT_EQ(lmp->atom->extra, nullptr); + ASSERT_EQ(lmp->atom->sametag, nullptr); + ASSERT_EQ(lmp->atom->map_style, 0); + ASSERT_EQ(lmp->atom->map_user, 0); + ASSERT_EQ(lmp->atom->map_tag_max, -1); + + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("create_box 2 box"); + lmp->input->one("create_atoms 1 single -2.0 2.0 0.1"); + lmp->input->one("create_atoms 1 single -2.0 -2.0 -0.1"); + lmp->input->one("create_atoms 2 single 2.0 2.0 -0.1"); + lmp->input->one("create_atoms 2 single 2.0 -2.0 0.1"); + lmp->input->one("mass 1 4.0"); + lmp->input->one("mass 2 2.4"); + lmp->input->one("set atom 1 charge -0.5"); + lmp->input->one("set atom 2 charge 0.5"); + lmp->input->one("set atom 3 charge -1.0"); + lmp->input->one("set atom 4 charge 1.0"); + lmp->input->one("pair_coeff * *"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("charge")); + ASSERT_NE(lmp->atom->avec, nullptr); + ASSERT_EQ(lmp->atom->natoms, 4); + ASSERT_EQ(lmp->atom->nlocal, 4); + ASSERT_EQ(lmp->atom->nghost, 0); + ASSERT_NE(lmp->atom->nmax, -1); + ASSERT_EQ(lmp->atom->tag_enable, 1); + ASSERT_EQ(lmp->atom->molecular, 0); + ASSERT_EQ(lmp->atom->ntypes, 2); + + ASSERT_NE(lmp->atom->mass, nullptr); + ASSERT_NE(lmp->atom->mass_setflag, nullptr); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("pair_coeff * *"); + lmp->input->one("write_data test_atom_styles.data nocoeff"); + lmp->input->one("clear"); + lmp->input->one("atom_style charge"); + lmp->input->one("pair_style zero 4.0"); + lmp->input->one("units real"); + lmp->input->one("atom_modify map array"); + lmp->input->one("read_data test_atom_styles.data"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("charge")); + ASSERT_NE(lmp->atom->avec, nullptr); + ASSERT_EQ(lmp->atom->natoms, 4); + ASSERT_EQ(lmp->atom->nlocal, 4); + ASSERT_EQ(lmp->atom->nghost, 0); + ASSERT_NE(lmp->atom->nmax, -1); + ASSERT_EQ(lmp->atom->tag_enable, 1); + ASSERT_EQ(lmp->atom->molecular, 0); + ASSERT_EQ(lmp->atom->ntypes, 2); + ASSERT_EQ(lmp->atom->q_flag, 1); + ASSERT_NE(lmp->atom->sametag, nullptr); + ASSERT_EQ(lmp->atom->tag_consecutive(), 1); + ASSERT_EQ(lmp->atom->map_style, 1); + ASSERT_EQ(lmp->atom->map_user, 1); + ASSERT_EQ(lmp->atom->map_tag_max, 4); + + double **x = lmp->atom->x; + double **v = lmp->atom->v; + double *q = lmp->atom->q; + ASSERT_DOUBLE_EQ(x[0][0], -2.0); + ASSERT_DOUBLE_EQ(x[0][1], 2.0); + ASSERT_DOUBLE_EQ(x[0][2], 0.1); + ASSERT_DOUBLE_EQ(x[1][0], -2.0); + ASSERT_DOUBLE_EQ(x[1][1], -2.0); + ASSERT_DOUBLE_EQ(x[1][2], -0.1); + ASSERT_DOUBLE_EQ(x[2][0], 2.0); + ASSERT_DOUBLE_EQ(x[2][1], 2.0); + ASSERT_DOUBLE_EQ(x[2][2], -0.1); + ASSERT_DOUBLE_EQ(x[3][0], 2.0); + ASSERT_DOUBLE_EQ(x[3][1], -2.0); + ASSERT_DOUBLE_EQ(x[3][2], 0.1); + ASSERT_DOUBLE_EQ(v[0][0], 0.0); + ASSERT_DOUBLE_EQ(v[0][1], 0.0); + ASSERT_DOUBLE_EQ(v[0][2], 0.0); + ASSERT_DOUBLE_EQ(v[1][0], 0.0); + ASSERT_DOUBLE_EQ(v[1][1], 0.0); + ASSERT_DOUBLE_EQ(v[1][2], 0.0); + ASSERT_DOUBLE_EQ(v[2][0], 0.0); + ASSERT_DOUBLE_EQ(v[2][1], 0.0); + ASSERT_DOUBLE_EQ(v[2][2], 0.0); + ASSERT_DOUBLE_EQ(v[3][0], 0.0); + ASSERT_DOUBLE_EQ(v[3][1], 0.0); + ASSERT_DOUBLE_EQ(v[3][2], 0.0); + ASSERT_DOUBLE_EQ(q[0], -0.5); + ASSERT_DOUBLE_EQ(q[1], 0.5); + ASSERT_DOUBLE_EQ(q[2], -1.0); + ASSERT_DOUBLE_EQ(q[3], 1.0); + + ASSERT_DOUBLE_EQ(lmp->atom->mass[1], 4.0); + ASSERT_DOUBLE_EQ(lmp->atom->mass[2], 2.4); + ASSERT_EQ(lmp->atom->mass_setflag[1], 1); + ASSERT_EQ(lmp->atom->mass_setflag[2], 1); + + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("pair_coeff * *"); + lmp->input->one("group two id 2:4:2"); + lmp->input->one("delete_atoms group two compress no"); + lmp->input->one("write_restart test_atom_styles.restart"); + lmp->input->one("clear"); + lmp->input->one("read_restart test_atom_styles.restart"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_THAT(std::string(lmp->atom->atom_style), Eq("charge")); + ASSERT_NE(lmp->atom->avec, nullptr); + ASSERT_EQ(lmp->atom->natoms, 2); + ASSERT_EQ(lmp->atom->nlocal, 2); + ASSERT_EQ(lmp->atom->nghost, 0); + ASSERT_NE(lmp->atom->nmax, -1); + ASSERT_EQ(lmp->atom->tag_enable, 1); + ASSERT_EQ(lmp->atom->molecular, 0); + ASSERT_EQ(lmp->atom->ntypes, 2); + ASSERT_EQ(lmp->atom->tag_consecutive(), 0); + ASSERT_EQ(lmp->atom->map_tag_max, 3); + + x = lmp->atom->x; + v = lmp->atom->v; + q = lmp->atom->q; + ASSERT_DOUBLE_EQ(x[0][0], -2.0); + ASSERT_DOUBLE_EQ(x[0][1], 2.0); + ASSERT_DOUBLE_EQ(x[0][2], 0.1); + ASSERT_DOUBLE_EQ(x[1][0], 2.0); + ASSERT_DOUBLE_EQ(x[1][1], 2.0); + ASSERT_DOUBLE_EQ(x[1][2], -0.1); + ASSERT_DOUBLE_EQ(v[0][0], 0.0); + ASSERT_DOUBLE_EQ(v[0][1], 0.0); + ASSERT_DOUBLE_EQ(v[0][2], 0.0); + ASSERT_DOUBLE_EQ(v[1][0], 0.0); + ASSERT_DOUBLE_EQ(v[1][1], 0.0); + ASSERT_DOUBLE_EQ(v[1][2], 0.0); + ASSERT_DOUBLE_EQ(q[0], -0.5); + ASSERT_DOUBLE_EQ(q[1], -1.0); + + ASSERT_DOUBLE_EQ(lmp->atom->mass[1], 4.0); + ASSERT_DOUBLE_EQ(lmp->atom->mass[2], 2.4); + ASSERT_EQ(lmp->atom->mass_setflag[1], 1); + ASSERT_EQ(lmp->atom->mass_setflag[2], 1); +} + +} // namespace LAMMPS_NS + +int main(int argc, char **argv) +{ + MPI_Init(&argc, &argv); + ::testing::InitGoogleMock(&argc, argv); + if ((argc > 1) && (strcmp(argv[1], "-v") == 0)) verbose = true; + + int rv = RUN_ALL_TESTS(); + MPI_Finalize(); + return rv; +} diff --git a/unittest/formats/test_eim_potential_file_reader.cpp b/unittest/formats/test_eim_potential_file_reader.cpp index 0aaa236fea..bf0d9ba8dd 100644 --- a/unittest/formats/test_eim_potential_file_reader.cpp +++ b/unittest/formats/test_eim_potential_file_reader.cpp @@ -12,15 +12,21 @@ ------------------------------------------------------------------------- */ #include "MANYBODY/pair_eim.h" +#include "info.h" +#include "input.h" #include "lammps.h" #include "utils.h" #include "gmock/gmock.h" #include "gtest/gtest.h" +#include #include using namespace LAMMPS_NS; +// whether to print verbose output (i.e. not capturing LAMMPS screen output). +bool verbose = false; + class EIMPotentialFileReaderTest : public ::testing::Test { protected: LAMMPS *lmp; @@ -33,9 +39,16 @@ protected: "PotentialFileReaderTest", "-log", "none", "-echo", "screen", "-nocite"}; char **argv = (char **)args; int argc = sizeof(args) / sizeof(char *); - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD); - ::testing::internal::GetCapturedStdout(); + lmp->input->one("units metal"); + if (!verbose) ::testing::internal::GetCapturedStdout(); + ASSERT_NE(lmp, nullptr); + + // check if the prerequisite eim pair style is available + Info *info = new Info(lmp); + ASSERT_TRUE(info->has_style("pair", "eim")); + delete info; int npair = nelements * (nelements + 1) / 2; setfl.ielement = new int[nelements]; @@ -85,17 +98,17 @@ protected: delete[] setfl.rs; delete[] setfl.tp; - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); delete lmp; - ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); } }; TEST_F(EIMPotentialFileReaderTest, global_line) { - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); EIMPotentialFileReader reader(lmp, "ffield.eim"); - ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); reader.get_global(&setfl); ASSERT_DOUBLE_EQ(setfl.division, 2.0); @@ -105,9 +118,9 @@ TEST_F(EIMPotentialFileReaderTest, global_line) TEST_F(EIMPotentialFileReaderTest, element_line_sequential) { - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); EIMPotentialFileReader reader(lmp, "ffield.eim"); - ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); reader.get_element(&setfl, 0, "Li"); ASSERT_EQ(setfl.ielement[0], 3); @@ -130,9 +143,9 @@ TEST_F(EIMPotentialFileReaderTest, element_line_sequential) TEST_F(EIMPotentialFileReaderTest, element_line_random) { - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); EIMPotentialFileReader reader(lmp, "ffield.eim"); - ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); reader.get_element(&setfl, 0, "Id"); ASSERT_EQ(setfl.ielement[0], 53); @@ -146,9 +159,9 @@ TEST_F(EIMPotentialFileReaderTest, element_line_random) TEST_F(EIMPotentialFileReaderTest, pair_line) { - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); EIMPotentialFileReader reader(lmp, "ffield.eim"); - ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); reader.get_pair(&setfl, 0, "Li", "Li"); ASSERT_DOUBLE_EQ(setfl.rcutphiA[0], 6.0490e+00); @@ -169,9 +182,9 @@ TEST_F(EIMPotentialFileReaderTest, pair_line) TEST_F(EIMPotentialFileReaderTest, pair_identical) { - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); EIMPotentialFileReader reader(lmp, "ffield.eim"); - ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); reader.get_pair(&setfl, 0, "Li", "Na"); reader.get_pair(&setfl, 1, "Na", "Li"); @@ -195,5 +208,9 @@ int main(int argc, char **argv) { MPI_Init(&argc, &argv); ::testing::InitGoogleMock(&argc, argv); - return RUN_ALL_TESTS(); + if ((argc > 1) && (strcmp(argv[1], "-v") == 0)) verbose = true; + + int rv = RUN_ALL_TESTS(); + MPI_Finalize(); + return rv; } diff --git a/unittest/formats/test_potential_file_reader.cpp b/unittest/formats/test_potential_file_reader.cpp index 199a4ad329..d168ca22c0 100644 --- a/unittest/formats/test_potential_file_reader.cpp +++ b/unittest/formats/test_potential_file_reader.cpp @@ -23,16 +23,21 @@ #include "MANYBODY/pair_tersoff_mod_c.h" #include "MANYBODY/pair_tersoff_zbl.h" #include "MANYBODY/pair_vashishta.h" +#include "input.h" #include "lammps.h" #include "potential_file_reader.h" #include "utils.h" #include "gmock/gmock.h" #include "gtest/gtest.h" +#include #include using namespace LAMMPS_NS; +// whether to print verbose output (i.e. not capturing LAMMPS screen output). +bool verbose = false; + const int LAMMPS_NS::PairSW::NPARAMS_PER_LINE; const int LAMMPS_NS::PairComb::NPARAMS_PER_LINE; const int LAMMPS_NS::PairComb3::NPARAMS_PER_LINE; @@ -55,24 +60,25 @@ protected: "PotentialFileReaderTest", "-log", "none", "-echo", "screen", "-nocite"}; char **argv = (char **)args; int argc = sizeof(args) / sizeof(char *); - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD); - ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); } void TearDown() override { - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); delete lmp; - ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); } }; TEST_F(PotentialFileReaderTest, Si) { - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("units metal"); PotentialFileReader reader(lmp, "Si.sw", "Stillinger-Weber"); - ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); auto line = reader.next_line(PairSW::NPARAMS_PER_LINE); ASSERT_EQ(utils::count_words(line), PairSW::NPARAMS_PER_LINE); @@ -80,9 +86,10 @@ TEST_F(PotentialFileReaderTest, Si) TEST_F(PotentialFileReaderTest, Comb) { - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("units metal"); PotentialFileReader reader(lmp, "ffield.comb", "COMB"); - ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); auto line = reader.next_line(PairComb::NPARAMS_PER_LINE); ASSERT_EQ(utils::count_words(line), PairComb::NPARAMS_PER_LINE); @@ -90,9 +97,10 @@ TEST_F(PotentialFileReaderTest, Comb) TEST_F(PotentialFileReaderTest, Comb3) { - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("units metal"); PotentialFileReader reader(lmp, "ffield.comb3", "COMB3"); - ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); auto line = reader.next_line(PairComb3::NPARAMS_PER_LINE); ASSERT_EQ(utils::count_words(line), PairComb3::NPARAMS_PER_LINE); @@ -100,9 +108,10 @@ TEST_F(PotentialFileReaderTest, Comb3) TEST_F(PotentialFileReaderTest, Tersoff) { - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("units metal"); PotentialFileReader reader(lmp, "Si.tersoff", "Tersoff"); - ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); auto line = reader.next_line(PairTersoff::NPARAMS_PER_LINE); ASSERT_EQ(utils::count_words(line), PairTersoff::NPARAMS_PER_LINE); @@ -110,9 +119,10 @@ TEST_F(PotentialFileReaderTest, Tersoff) TEST_F(PotentialFileReaderTest, TersoffMod) { - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("units metal"); PotentialFileReader reader(lmp, "Si.tersoff.mod", "Tersoff/Mod"); - ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); auto line = reader.next_line(PairTersoffMOD::NPARAMS_PER_LINE); ASSERT_EQ(utils::count_words(line), PairTersoffMOD::NPARAMS_PER_LINE); @@ -120,9 +130,10 @@ TEST_F(PotentialFileReaderTest, TersoffMod) TEST_F(PotentialFileReaderTest, TersoffModC) { - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("units metal"); PotentialFileReader reader(lmp, "Si.tersoff.modc", "Tersoff/ModC"); - ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); auto line = reader.next_line(PairTersoffMODC::NPARAMS_PER_LINE); ASSERT_EQ(utils::count_words(line), PairTersoffMODC::NPARAMS_PER_LINE); @@ -130,9 +141,10 @@ TEST_F(PotentialFileReaderTest, TersoffModC) TEST_F(PotentialFileReaderTest, TersoffZBL) { - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("units metal"); PotentialFileReader reader(lmp, "SiC.tersoff.zbl", "Tersoff/ZBL"); - ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); auto line = reader.next_line(PairTersoffZBL::NPARAMS_PER_LINE); ASSERT_EQ(utils::count_words(line), PairTersoffZBL::NPARAMS_PER_LINE); @@ -140,9 +152,10 @@ TEST_F(PotentialFileReaderTest, TersoffZBL) TEST_F(PotentialFileReaderTest, GW) { - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("units metal"); PotentialFileReader reader(lmp, "SiC.gw", "GW"); - ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); auto line = reader.next_line(PairGW::NPARAMS_PER_LINE); ASSERT_EQ(utils::count_words(line), PairGW::NPARAMS_PER_LINE); @@ -150,9 +163,10 @@ TEST_F(PotentialFileReaderTest, GW) TEST_F(PotentialFileReaderTest, GWZBL) { - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("units metal"); PotentialFileReader reader(lmp, "SiC.gw.zbl", "GW/ZBL"); - ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); auto line = reader.next_line(PairGWZBL::NPARAMS_PER_LINE); ASSERT_EQ(utils::count_words(line), PairGWZBL::NPARAMS_PER_LINE); @@ -160,9 +174,10 @@ TEST_F(PotentialFileReaderTest, GWZBL) TEST_F(PotentialFileReaderTest, Nb3bHarmonic) { - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("units metal"); PotentialFileReader reader(lmp, "MOH.nb3b.harmonic", "NB3B Harmonic"); - ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); auto line = reader.next_line(PairNb3bHarmonic::NPARAMS_PER_LINE); ASSERT_EQ(utils::count_words(line), PairNb3bHarmonic::NPARAMS_PER_LINE); @@ -170,9 +185,10 @@ TEST_F(PotentialFileReaderTest, Nb3bHarmonic) TEST_F(PotentialFileReaderTest, Vashishta) { - ::testing::internal::CaptureStdout(); + if (!verbose) ::testing::internal::CaptureStdout(); + lmp->input->one("units metal"); PotentialFileReader reader(lmp, "SiC.vashishta", "Vashishta"); - ::testing::internal::GetCapturedStdout(); + if (!verbose) ::testing::internal::GetCapturedStdout(); auto line = reader.next_line(PairVashishta::NPARAMS_PER_LINE); ASSERT_EQ(utils::count_words(line), PairVashishta::NPARAMS_PER_LINE); @@ -182,5 +198,9 @@ int main(int argc, char **argv) { MPI_Init(&argc, &argv); ::testing::InitGoogleMock(&argc, argv); - return RUN_ALL_TESTS(); + if ((argc > 1) && (strcmp(argv[1], "-v") == 0)) verbose = true; + + int rv = RUN_ALL_TESTS(); + MPI_Finalize(); + return rv; }