diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index e0fca5bd9b..3af67bf8e0 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -90,8 +90,11 @@ if((CMAKE_CXX_COMPILER_ID STREQUAL "Intel") OR (CMAKE_CXX_COMPILER_ID STREQUAL " endif() endif() -# we require C++11 without extensions +# we require C++11 without extensions. Kokkos requires at least C++14 (currently) set(CMAKE_CXX_STANDARD 11) +if(PKG_KOKKOS AND (CMAKE_CXX_STANDARD LESS 14)) + set(CMAKE_CXX_STANDARD 14) +endif() set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF CACHE BOOL "Use compiler extensions") # ugly hack for MSVC which by default always reports an old C++ standard in the __cplusplus macro diff --git a/cmake/Modules/Packages/KOKKOS.cmake b/cmake/Modules/Packages/KOKKOS.cmake index d5fccad4ba..fe6c17801e 100644 --- a/cmake/Modules/Packages/KOKKOS.cmake +++ b/cmake/Modules/Packages/KOKKOS.cmake @@ -1,7 +1,7 @@ ######################################################################## # As of version 3.3.0 Kokkos requires C++14 if(CMAKE_CXX_STANDARD LESS 14) - set(CMAKE_CXX_STANDARD 14) + message(FATAL_ERROR "The KOKKOS package requires the C++ standard to be set to at least C++14") endif() ######################################################################## # consistency checks and Kokkos options/settings required by LAMMPS diff --git a/cmake/Modules/Packages/LATTE.cmake b/cmake/Modules/Packages/LATTE.cmake index ddf31a68ed..a96e850f7e 100644 --- a/cmake/Modules/Packages/LATTE.cmake +++ b/cmake/Modules/Packages/LATTE.cmake @@ -19,6 +19,14 @@ if(DOWNLOAD_LATTE) set(LATTE_MD5 "820e73a457ced178c08c71389a385de7" CACHE STRING "MD5 checksum of LATTE tarball") mark_as_advanced(LATTE_URL) mark_as_advanced(LATTE_MD5) + + # CMake cannot pass BLAS or LAPACK library variable to external project if they are a list + list(LENGTH BLAS_LIBRARIES} NUM_BLAS) + list(LENGTH LAPACK_LIBRARIES NUM_LAPACK) + if((NUM_BLAS GREATER 1) OR (NUM_LAPACK GREATER 1)) + message(FATAL_ERROR "Cannot compile downloaded LATTE library due to a technical limitation") + endif() + include(ExternalProject) ExternalProject_Add(latte_build URL ${LATTE_URL} diff --git a/cmake/Modules/Packages/MACHDYN.cmake b/cmake/Modules/Packages/MACHDYN.cmake index fab532541e..8729d80dbf 100644 --- a/cmake/Modules/Packages/MACHDYN.cmake +++ b/cmake/Modules/Packages/MACHDYN.cmake @@ -7,8 +7,9 @@ endif() option(DOWNLOAD_EIGEN3 "Download Eigen3 instead of using an already installed one)" ${DOWNLOAD_EIGEN3_DEFAULT}) if(DOWNLOAD_EIGEN3) message(STATUS "Eigen3 download requested - we will build our own") - set(EIGEN3_URL "https://gitlab.com/libeigen/eigen/-/archive/3.3.9/eigen-3.3.9.tar.gz" CACHE STRING "URL for Eigen3 tarball") - set(EIGEN3_MD5 "609286804b0f79be622ccf7f9ff2b660" CACHE STRING "MD5 checksum of Eigen3 tarball") + + set(EIGEN3_URL "https://download.lammps.org/thirdparty/eigen-3.4.0.tar.gz" CACHE STRING "URL for Eigen3 tarball") + set(EIGEN3_MD5 "4c527a9171d71a72a9d4186e65bea559" CACHE STRING "MD5 checksum of Eigen3 tarball") mark_as_advanced(EIGEN3_URL) mark_as_advanced(EIGEN3_MD5) include(ExternalProject) diff --git a/cmake/Modules/Packages/ML-HDNNP.cmake b/cmake/Modules/Packages/ML-HDNNP.cmake index 44873b9929..e27b3a1410 100644 --- a/cmake/Modules/Packages/ML-HDNNP.cmake +++ b/cmake/Modules/Packages/ML-HDNNP.cmake @@ -45,12 +45,12 @@ if(DOWNLOAD_N2P2) # get path to MPI include directory when cross-compiling to windows if((CMAKE_SYSTEM_NAME STREQUAL Windows) AND CMAKE_CROSSCOMPILING) get_target_property(N2P2_MPI_INCLUDE MPI::MPI_CXX INTERFACE_INCLUDE_DIRECTORIES) - set(N2P2_PROJECT_OPTIONS "-I ${N2P2_MPI_INCLUDE} -DMPICH_SKIP_MPICXX=1") + set(N2P2_PROJECT_OPTIONS "-I${N2P2_MPI_INCLUDE}") set(MPI_CXX_COMPILER ${CMAKE_CXX_COMPILER}) endif() if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") get_target_property(N2P2_MPI_INCLUDE MPI::MPI_CXX INTERFACE_INCLUDE_DIRECTORIES) - set(N2P2_PROJECT_OPTIONS "-I ${N2P2_MPI_INCLUDE} -DMPICH_SKIP_MPICXX=1") + set(N2P2_PROJECT_OPTIONS "-I${N2P2_MPI_INCLUDE}") set(MPI_CXX_COMPILER ${CMAKE_CXX_COMPILER}) endif() endif() @@ -69,6 +69,12 @@ if(DOWNLOAD_N2P2) # echo final flag for debugging message(STATUS "N2P2 BUILD OPTIONS: ${N2P2_BUILD_OPTIONS}") + # must have "sed" command to compile n2p2 library (for now) + find_program(HAVE_SED sed) + if(NOT HAVE_SED) + message(FATAL_ERROR "Must have 'sed' program installed to compile 'n2p2' library for ML-HDNNP package") + endif() + # download compile n2p2 library. much patch MPI calls in LAMMPS interface to accommodate MPI-2 (e.g. for cross-compiling) include(ExternalProject) ExternalProject_Add(n2p2_build diff --git a/cmake/Modules/Packages/ML-QUIP.cmake b/cmake/Modules/Packages/ML-QUIP.cmake index 5a80e63d55..92418e8939 100644 --- a/cmake/Modules/Packages/ML-QUIP.cmake +++ b/cmake/Modules/Packages/ML-QUIP.cmake @@ -50,7 +50,7 @@ if(DOWNLOAD_QUIP) GIT_TAG origin/public GIT_SHALLOW YES GIT_PROGRESS YES - PATCH_COMMAND cp ${CMAKE_BINARY_DIR}/quip.config /arch/Makefile.lammps + PATCH_COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/quip.config /arch/Makefile.lammps CONFIGURE_COMMAND env QUIP_ARCH=lammps make config BUILD_COMMAND env QUIP_ARCH=lammps make libquip INSTALL_COMMAND "" diff --git a/cmake/Modules/Packages/MSCG.cmake b/cmake/Modules/Packages/MSCG.cmake index 6ac62cb012..cf3d506c82 100644 --- a/cmake/Modules/Packages/MSCG.cmake +++ b/cmake/Modules/Packages/MSCG.cmake @@ -12,6 +12,13 @@ if(DOWNLOAD_MSCG) mark_as_advanced(MSCG_URL) mark_as_advanced(MSCG_MD5) + # CMake cannot pass BLAS or LAPACK library variable to external project if they are a list + list(LENGTH BLAS_LIBRARIES} NUM_BLAS) + list(LENGTH LAPACK_LIBRARIES NUM_LAPACK) + if((NUM_BLAS GREATER 1) OR (NUM_LAPACK GREATER 1)) + message(FATAL_ERROR "Cannot compile downloaded MSCG library due to a technical limitation") + endif() + include(ExternalProject) ExternalProject_Add(mscg_build URL ${MSCG_URL} diff --git a/cmake/Modules/Packages/SCAFACOS.cmake b/cmake/Modules/Packages/SCAFACOS.cmake index fd355420c3..de611a1edb 100644 --- a/cmake/Modules/Packages/SCAFACOS.cmake +++ b/cmake/Modules/Packages/SCAFACOS.cmake @@ -23,6 +23,11 @@ if(DOWNLOAD_SCAFACOS) file(DOWNLOAD ${LAMMPS_THIRDPARTY_URL}/scafacos-1.0.1-fix.diff ${CMAKE_CURRENT_BINARY_DIR}/scafacos-1.0.1.fix.diff EXPECTED_HASH MD5=4baa1333bb28fcce102d505e1992d032) + find_program(HAVE_PATCH patch) + if(NOT HAVE_PATCH) + message(FATAL_ERROR "The 'patch' program is required to build the ScaFaCoS library") + endif() + include(ExternalProject) ExternalProject_Add(scafacos_build URL ${SCAFACOS_URL} diff --git a/doc/lammps.1 b/doc/lammps.1 index fb79b8d774..c868a2a86f 100644 --- a/doc/lammps.1 +++ b/doc/lammps.1 @@ -1,4 +1,4 @@ -.TH LAMMPS "20 September 2021" "2021-09-20" +.TH LAMMPS "29 September 2021" "2021-09-29" .SH NAME .B LAMMPS \- Molecular Dynamics Simulator. diff --git a/doc/src/Developer_utils.rst b/doc/src/Developer_utils.rst index 17da8bef22..041fce60b0 100644 --- a/doc/src/Developer_utils.rst +++ b/doc/src/Developer_utils.rst @@ -60,6 +60,9 @@ silently returning the result of a partial conversion or zero in cases where the string is not a valid number. This behavior allows to more easily detect typos or issues when processing input files. +Similarly the :cpp:func:`logical() ` function +will convert a string into a boolean and will only accept certain words. + The *do_abort* flag should be set to ``true`` in case this function is called only on a single MPI rank, as that will then trigger the a call to ``Error::one()`` for errors instead of ``Error::all()`` @@ -83,6 +86,9 @@ strings for compliance without conversion. .. doxygenfunction:: tnumeric :project: progguide +.. doxygenfunction:: logical + :project: progguide + String processing ^^^^^^^^^^^^^^^^^ diff --git a/doc/src/Howto_thermostat.rst b/doc/src/Howto_thermostat.rst index fbeb1f7785..fe53fff540 100644 --- a/doc/src/Howto_thermostat.rst +++ b/doc/src/Howto_thermostat.rst @@ -2,8 +2,8 @@ Thermostats =========== Thermostatting means controlling the temperature of particles in an MD -simulation. :doc:`Barostatting ` means controlling the -pressure. Since the pressure includes a kinetic component due to +simulation. :doc:`Barostatting ` means controlling +the pressure. Since the pressure includes a kinetic component due to particle velocities, both these operations require calculation of the temperature. Typically a target temperature (T) and/or pressure (P) is specified by the user, and the thermostat or barostat attempts to @@ -26,11 +26,13 @@ can be invoked via the *dpd/tstat* pair style: * :doc:`pair_style dpd/tstat ` :doc:`Fix nvt ` only thermostats the translational velocity of -particles. :doc:`Fix nvt/sllod ` also does this, except -that it subtracts out a velocity bias due to a deforming box and -integrates the SLLOD equations of motion. See the :doc:`Howto nemd ` page for further details. :doc:`Fix nvt/sphere ` and :doc:`fix nvt/asphere ` thermostat not only translation -velocities but also rotational velocities for spherical and aspherical -particles. +particles. :doc:`Fix nvt/sllod ` also does this, +except that it subtracts out a velocity bias due to a deforming box +and integrates the SLLOD equations of motion. See the :doc:`Howto +nemd ` page for further details. :doc:`Fix nvt/sphere +` and :doc:`fix nvt/asphere ` +thermostat not only translation velocities but also rotational +velocities for spherical and aspherical particles. .. note:: @@ -40,25 +42,31 @@ particles. e.g. molecular systems. The latter can be tricky to do correctly. DPD thermostatting alters pairwise interactions in a manner analogous -to the per-particle thermostatting of :doc:`fix langevin `. +to the per-particle thermostatting of :doc:`fix langevin +`. -Any of the thermostatting fixes can be instructed to use custom temperature -computes that remove bias which has two effects: first, the current -calculated temperature, which is compared to the requested target temperature, -is calculated with the velocity bias removed; second, the thermostat adjusts -only the thermal temperature component of the particle's velocities, which are -the velocities with the bias removed. The removed bias is then added back -to the adjusted velocities. See the doc pages for the individual -fixes and for the :doc:`fix_modify ` command for -instructions on how to assign a temperature compute to a -thermostatting fix. For example, you can apply a thermostat to only -the x and z components of velocity by using it in conjunction with -:doc:`compute temp/partial `. Of you could -thermostat only the thermal temperature of a streaming flow of -particles without affecting the streaming velocity, by using -:doc:`compute temp/profile `. +Any of the thermostatting fixes can be instructed to use custom +temperature computes that remove bias which has two effects: first, +the current calculated temperature, which is compared to the requested +target temperature, is calculated with the velocity bias removed; +second, the thermostat adjusts only the thermal temperature component +of the particle's velocities, which are the velocities with the bias +removed. The removed bias is then added back to the adjusted +velocities. See the doc pages for the individual fixes and for the +:doc:`fix_modify ` command for instructions on how to +assign a temperature compute to a thermostatting fix. -Below is a list of some custom temperature computes that can be used like that: +For example, you can apply a thermostat only to atoms in a spatial +region by using it in conjunction with :doc:`compute temp/region +`. Or you can apply a thermostat to only the x +and z components of velocity by using it with :doc:`compute +temp/partial `. Of you could thermostat only +the thermal temperature of a streaming flow of particles without +affecting the streaming velocity, by using :doc:`compute temp/profile +`. + +Below is a list of custom temperature computes that can be used like +that: * :doc:`compute_temp_asphere` * :doc:`compute_temp_body` @@ -72,8 +80,6 @@ Below is a list of some custom temperature computes that can be used like that: * :doc:`compute_temp_rotate` * :doc:`compute_temp_sphere` - - .. note:: Only the nvt fixes perform time integration, meaning they update @@ -86,17 +92,17 @@ Below is a list of some custom temperature computes that can be used like that: * :doc:`fix nve/sphere ` * :doc:`fix nve/asphere ` -Thermodynamic output, which can be setup via the -:doc:`thermo_style ` command, often includes temperature -values. As explained on the page for the -:doc:`thermo_style ` command, the default temperature is -setup by the thermo command itself. It is NOT the temperature -associated with any thermostatting fix you have defined or with any -compute you have defined that calculates a temperature. The doc pages -for the thermostatting fixes explain the ID of the temperature compute -they create. Thus if you want to view these temperatures, you need to -specify them explicitly via the :doc:`thermo_style custom ` command. Or you can use the -:doc:`thermo_modify ` command to re-define what +Thermodynamic output, which can be setup via the :doc:`thermo_style +` command, often includes temperature values. As +explained on the page for the :doc:`thermo_style ` +command, the default temperature is setup by the thermo command +itself. It is NOT the temperature associated with any thermostatting +fix you have defined or with any compute you have defined that +calculates a temperature. The doc pages for the thermostatting fixes +explain the ID of the temperature compute they create. Thus if you +want to view these temperatures, you need to specify them explicitly +via the :doc:`thermo_style custom ` command. Or you can +use the :doc:`thermo_modify ` command to re-define what temperature compute is used for default thermodynamic output. ---------- diff --git a/doc/src/Library_create.rst b/doc/src/Library_create.rst index 3566cb3cc9..8043819891 100644 --- a/doc/src/Library_create.rst +++ b/doc/src/Library_create.rst @@ -34,7 +34,7 @@ simple example demonstrating its use: int lmpargc = sizeof(lmpargv)/sizeof(const char *); /* create LAMMPS instance */ - handle = lammps_open_no_mpi(lmpargc, lmpargv, NULL); + handle = lammps_open_no_mpi(lmpargc, (char **)lmpargv, NULL); if (handle == NULL) { printf("LAMMPS initialization failed"); lammps_mpi_finalize(); diff --git a/doc/src/fix_langevin.rst b/doc/src/fix_langevin.rst index c8be9afc31..5979155799 100644 --- a/doc/src/fix_langevin.rst +++ b/doc/src/fix_langevin.rst @@ -138,16 +138,18 @@ temperature with optional time-dependence as well. Like other fixes that perform thermostatting, this fix can be used with :doc:`compute commands ` that remove a "bias" from the -atom velocities. E.g. removing the center-of-mass velocity from a -group of atoms or removing the x-component of velocity from the -calculation. This is not done by default, but only if the -:doc:`fix_modify ` command is used to assign a temperature -compute to this fix that includes such a bias term. See the doc pages -for individual :doc:`compute commands ` to determine which ones -include a bias. In this case, the thermostat works in the following -manner: bias is removed from each atom, thermostatting is performed on -the remaining thermal degrees of freedom, and the bias is added back -in. +atom velocities. E.g. to apply the thermostat only to atoms within a +spatial :doc:`region `, or to remove the center-of-mass +velocity from a group of atoms, or to remove the x-component of +velocity from the calculation. + +This is not done by default, but only if the :doc:`fix_modify +` command is used to assign a temperature compute to this +fix that includes such a bias term. See the doc pages for individual +:doc:`compute temp commands ` to determine which ones include +a bias. In this case, the thermostat works in the following manner: +bias is removed from each atom, thermostatting is performed on the +remaining thermal degrees of freedom, and the bias is added back in. The *damp* parameter is specified in time units and determines how rapidly the temperature is relaxed. For example, a value of 100.0 means @@ -183,7 +185,8 @@ omega (which is derived from the angular momentum in the case of aspherical particles). The rotational temperature of the particles can be monitored by the -:doc:`compute temp/sphere ` and :doc:`compute temp/asphere ` commands with their rotate +:doc:`compute temp/sphere ` and :doc:`compute +temp/asphere ` commands with their rotate options. For the *omega* keyword there is also a scale factor of diff --git a/doc/src/fix_langevin_drude.rst b/doc/src/fix_langevin_drude.rst index 3486723a67..89ea28cf08 100644 --- a/doc/src/fix_langevin_drude.rst +++ b/doc/src/fix_langevin_drude.rst @@ -167,17 +167,20 @@ functions, and include :doc:`thermo_style ` command keywords for the simulation box parameters and timestep and elapsed time. Thus it is easy to specify a time-dependent temperature. -Like other fixes that perform thermostatting, this fix can be used with -:doc:`compute commands ` that remove a "bias" from the atom -velocities. E.g. removing the center-of-mass velocity from a group of -atoms. This is not done by default, but only if the -:doc:`fix_modify ` command is used to assign a temperature -compute to this fix that includes such a bias term. See the doc pages -for individual :doc:`compute commands ` to determine which ones -include a bias. In this case, the thermostat works in the following -manner: bias is removed from each atom, thermostatting is performed on -the remaining thermal degrees of freedom, and the bias is added back -in. NOTE: this feature has not been tested. +Like other fixes that perform thermostatting, this fix can be used +with :doc:`compute commands ` that remove a "bias" from the +atom velocities. E.g. to apply the thermostat only to atoms within a +spatial :doc:`region `, or to remove the center-of-mass +velocity from a group of atoms, or to remove the x-component of +velocity from the calculation. + +This is not done by default, but only if the :doc:`fix_modify +` command is used to assign a temperature compute to this +fix that includes such a bias term. See the doc pages for individual +:doc:`compute temp commands ` to determine which ones include +a bias. In this case, the thermostat works in the following manner: +bias is removed from each atom, thermostatting is performed on the +remaining thermal degrees of freedom, and the bias is added back in. Note: The temperature thermostatting the core-Drude particle pairs should be chosen low enough, so as to mimic as closely as possible the diff --git a/doc/src/fix_nh.rst b/doc/src/fix_nh.rst index 46b343fdce..cb9e6ba61e 100644 --- a/doc/src/fix_nh.rst +++ b/doc/src/fix_nh.rst @@ -486,19 +486,20 @@ temperature or pressure during thermodynamic output via the compute-ID. It also means that changing attributes of *thermo_temp* or *thermo_press* will have no effect on this fix. -Like other fixes that perform thermostatting, fix nvt and fix npt can -be used with :doc:`compute commands ` that calculate a -temperature after removing a "bias" from the atom velocities. -E.g. removing the center-of-mass velocity from a group of atoms or -only calculating temperature on the x-component of velocity or only -calculating temperature for atoms in a geometric region. This is not -done by default, but only if the :doc:`fix_modify ` command -is used to assign a temperature compute to this fix that includes such -a bias term. See the doc pages for individual :doc:`compute commands ` to determine which ones include a bias. In -this case, the thermostat works in the following manner: the current -temperature is calculated taking the bias into account, bias is -removed from each atom, thermostatting is performed on the remaining -thermal degrees of freedom, and the bias is added back in. +Like other fixes that perform thermostatting, this fix can be used +with :doc:`compute commands ` that remove a "bias" from the +atom velocities. E.g. to apply the thermostat only to atoms within a +spatial :doc:`region `, or to remove the center-of-mass +velocity from a group of atoms, or to remove the x-component of +velocity from the calculation. + +This is not done by default, but only if the :doc:`fix_modify +` command is used to assign a temperature compute to this +fix that includes such a bias term. See the doc pages for individual +:doc:`compute temp commands ` to determine which ones include +a bias. In this case, the thermostat works in the following manner: +bias is removed from each atom, thermostatting is performed on the +remaining thermal degrees of freedom, and the bias is added back in. ---------- diff --git a/doc/src/fix_npt_asphere.rst b/doc/src/fix_npt_asphere.rst index 28edb59f8d..64e1c45be7 100644 --- a/doc/src/fix_npt_asphere.rst +++ b/doc/src/fix_npt_asphere.rst @@ -48,8 +48,9 @@ can also have a bias velocity removed from them before thermostatting takes place; see the description below. Additional parameters affecting the thermostat and barostat are -specified by keywords and values documented with the :doc:`fix npt ` command. See, for example, discussion of the *temp*, -*iso*, *aniso*, and *dilate* keywords. +specified by keywords and values documented with the :doc:`fix npt +` command. See, for example, discussion of the *temp*, *iso*, +*aniso*, and *dilate* keywords. The particles in the fix group are the only ones whose velocities and positions are updated by the velocity/position update portion of the @@ -89,18 +90,19 @@ It also means that changing attributes of *thermo_temp* or *thermo_press* will have no effect on this fix. Like other fixes that perform thermostatting, this fix can be used -with :doc:`compute commands ` that calculate a temperature -after removing a "bias" from the atom velocities. E.g. removing the -center-of-mass velocity from a group of atoms or only calculating -temperature on the x-component of velocity or only calculating -temperature for atoms in a geometric region. This is not done by -default, but only if the :doc:`fix_modify ` command is used -to assign a temperature compute to this fix that includes such a bias -term. See the doc pages for individual :doc:`compute commands ` to determine which ones include a bias. In -this case, the thermostat works in the following manner: the current -temperature is calculated taking the bias into account, bias is -removed from each atom, thermostatting is performed on the remaining -thermal degrees of freedom, and the bias is added back in. +with :doc:`compute commands ` that remove a "bias" from the +atom velocities. E.g. to apply the thermostat only to atoms within a +spatial :doc:`region `, or to remove the center-of-mass +velocity from a group of atoms, or to remove the x-component of +velocity from the calculation. + +This is not done by default, but only if the :doc:`fix_modify +` command is used to assign a temperature compute to this +fix that includes such a bias term. See the doc pages for individual +:doc:`compute temp commands ` to determine which ones include +a bias. In this case, the thermostat works in the following manner: +bias is removed from each atom, thermostatting is performed on the +remaining thermal degrees of freedom, and the bias is added back in. ---------- diff --git a/doc/src/fix_npt_body.rst b/doc/src/fix_npt_body.rst index d44870a4fb..ff98638b63 100644 --- a/doc/src/fix_npt_body.rst +++ b/doc/src/fix_npt_body.rst @@ -87,18 +87,19 @@ It also means that changing attributes of *thermo_temp* or *thermo_press* will have no effect on this fix. Like other fixes that perform thermostatting, this fix can be used -with :doc:`compute commands ` that calculate a temperature -after removing a "bias" from the atom velocities. E.g. removing the -center-of-mass velocity from a group of atoms or only calculating -temperature on the x-component of velocity or only calculating -temperature for atoms in a geometric region. This is not done by -default, but only if the :doc:`fix_modify ` command is used -to assign a temperature compute to this fix that includes such a bias -term. See the doc pages for individual :doc:`compute commands ` to determine which ones include a bias. In -this case, the thermostat works in the following manner: the current -temperature is calculated taking the bias into account, bias is -removed from each atom, thermostatting is performed on the remaining -thermal degrees of freedom, and the bias is added back in. +with :doc:`compute commands ` that remove a "bias" from the +atom velocities. E.g. to apply the thermostat only to atoms within a +spatial :doc:`region `, or to remove the center-of-mass +velocity from a group of atoms, or to remove the x-component of +velocity from the calculation. + +This is not done by default, but only if the :doc:`fix_modify +` command is used to assign a temperature compute to this +fix that includes such a bias term. See the doc pages for individual +:doc:`compute temp commands ` to determine which ones include +a bias. In this case, the thermostat works in the following manner: +bias is removed from each atom, thermostatting is performed on the +remaining thermal degrees of freedom, and the bias is added back in. ---------- diff --git a/doc/src/fix_npt_cauchy.rst b/doc/src/fix_npt_cauchy.rst index 13b5b7bf70..6ff3dffba3 100644 --- a/doc/src/fix_npt_cauchy.rst +++ b/doc/src/fix_npt_cauchy.rst @@ -400,19 +400,20 @@ temperature or pressure during thermodynamic output via the compute-ID. It also means that changing attributes of *thermo_temp* or *thermo_press* will have no effect on this fix. -Like other fixes that perform thermostatting, fix npt/cauchy can -be used with :doc:`compute commands ` that calculate a -temperature after removing a "bias" from the atom velocities. -E.g. removing the center-of-mass velocity from a group of atoms or -only calculating temperature on the x-component of velocity or only -calculating temperature for atoms in a geometric region. This is not -done by default, but only if the :doc:`fix_modify ` command -is used to assign a temperature compute to this fix that includes such -a bias term. See the doc pages for individual :doc:`compute commands ` to determine which ones include a bias. In -this case, the thermostat works in the following manner: the current -temperature is calculated taking the bias into account, bias is -removed from each atom, thermostatting is performed on the remaining -thermal degrees of freedom, and the bias is added back in. +Like other fixes that perform thermostatting, this fix can be used +with :doc:`compute commands ` that remove a "bias" from the +atom velocities. E.g. to apply the thermostat only to atoms within a +spatial :doc:`region `, or to remove the center-of-mass +velocity from a group of atoms, or to remove the x-component of +velocity from the calculation. + +This is not done by default, but only if the :doc:`fix_modify +` command is used to assign a temperature compute to this +fix that includes such a bias term. See the doc pages for individual +:doc:`compute temp commands ` to determine which ones include +a bias. In this case, the thermostat works in the following manner: +bias is removed from each atom, thermostatting is performed on the +remaining thermal degrees of freedom, and the bias is added back in. ---------- diff --git a/doc/src/fix_npt_sphere.rst b/doc/src/fix_npt_sphere.rst index 75e4c9a4ec..bd52ca9dc5 100644 --- a/doc/src/fix_npt_sphere.rst +++ b/doc/src/fix_npt_sphere.rst @@ -103,18 +103,19 @@ appropriate compute-ID. It also means that changing attributes of *thermo_temp* or *thermo_press* will have no effect on this fix. Like other fixes that perform thermostatting, this fix can be used -with :doc:`compute commands ` that calculate a temperature -after removing a "bias" from the atom velocities. E.g. removing the -center-of-mass velocity from a group of atoms or only calculating -temperature on the x-component of velocity or only calculating -temperature for atoms in a geometric region. This is not done by -default, but only if the :doc:`fix_modify ` command is used -to assign a temperature compute to this fix that includes such a bias -term. See the doc pages for individual :doc:`compute commands ` to determine which ones include a bias. In -this case, the thermostat works in the following manner: the current -temperature is calculated taking the bias into account, bias is -removed from each atom, thermostatting is performed on the remaining -thermal degrees of freedom, and the bias is added back in. +with :doc:`compute commands ` that remove a "bias" from the +atom velocities. E.g. to apply the thermostat only to atoms within a +spatial :doc:`region `, or to remove the center-of-mass +velocity from a group of atoms, or to remove the x-component of +velocity from the calculation. + +This is not done by default, but only if the :doc:`fix_modify +` command is used to assign a temperature compute to this +fix that includes such a bias term. See the doc pages for individual +:doc:`compute temp commands ` to determine which ones include +a bias. In this case, the thermostat works in the following manner: +bias is removed from each atom, thermostatting is performed on the +remaining thermal degrees of freedom, and the bias is added back in. ---------- diff --git a/doc/src/fix_nvt_asphere.rst b/doc/src/fix_nvt_asphere.rst index 00f4588f7f..7ce3aec125 100644 --- a/doc/src/fix_nvt_asphere.rst +++ b/doc/src/fix_nvt_asphere.rst @@ -72,18 +72,19 @@ It also means that changing attributes of *thermo_temp* will have no effect on this fix. Like other fixes that perform thermostatting, this fix can be used -with :doc:`compute commands ` that calculate a temperature -after removing a "bias" from the atom velocities. E.g. removing the -center-of-mass velocity from a group of atoms or only calculating -temperature on the x-component of velocity or only calculating -temperature for atoms in a geometric region. This is not done by -default, but only if the :doc:`fix_modify ` command is used -to assign a temperature compute to this fix that includes such a bias -term. See the doc pages for individual :doc:`compute commands ` to determine which ones include a bias. In -this case, the thermostat works in the following manner: the current -temperature is calculated taking the bias into account, bias is -removed from each atom, thermostatting is performed on the remaining -thermal degrees of freedom, and the bias is added back in. +with :doc:`compute commands ` that remove a "bias" from the +atom velocities. E.g. to apply the thermostat only to atoms within a +spatial :doc:`region `, or to remove the center-of-mass +velocity from a group of atoms, or to remove the x-component of +velocity from the calculation. + +This is not done by default, but only if the :doc:`fix_modify +` command is used to assign a temperature compute to this +fix that includes such a bias term. See the doc pages for individual +:doc:`compute temp commands ` to determine which ones include +a bias. In this case, the thermostat works in the following manner: +bias is removed from each atom, thermostatting is performed on the +remaining thermal degrees of freedom, and the bias is added back in. ---------- diff --git a/doc/src/fix_nvt_body.rst b/doc/src/fix_nvt_body.rst index 28ad3e7857..7b9e996a5b 100644 --- a/doc/src/fix_nvt_body.rst +++ b/doc/src/fix_nvt_body.rst @@ -69,18 +69,19 @@ It also means that changing attributes of *thermo_temp* will have no effect on this fix. Like other fixes that perform thermostatting, this fix can be used -with :doc:`compute commands ` that calculate a temperature -after removing a "bias" from the atom velocities. E.g. removing the -center-of-mass velocity from a group of atoms or only calculating -temperature on the x-component of velocity or only calculating -temperature for atoms in a geometric region. This is not done by -default, but only if the :doc:`fix_modify ` command is used -to assign a temperature compute to this fix that includes such a bias -term. See the doc pages for individual :doc:`compute commands ` to determine which ones include a bias. In -this case, the thermostat works in the following manner: the current -temperature is calculated taking the bias into account, bias is -removed from each atom, thermostatting is performed on the remaining -thermal degrees of freedom, and the bias is added back in. +with :doc:`compute commands ` that remove a "bias" from the +atom velocities. E.g. to apply the thermostat only to atoms within a +spatial :doc:`region `, or to remove the center-of-mass +velocity from a group of atoms, or to remove the x-component of +velocity from the calculation. + +This is not done by default, but only if the :doc:`fix_modify +` command is used to assign a temperature compute to this +fix that includes such a bias term. See the doc pages for individual +:doc:`compute temp commands ` to determine which ones include +a bias. In this case, the thermostat works in the following manner: +bias is removed from each atom, thermostatting is performed on the +remaining thermal degrees of freedom, and the bias is added back in. ---------- diff --git a/doc/src/fix_nvt_sllod.rst b/doc/src/fix_nvt_sllod.rst index 3d041ca767..4bb4478991 100644 --- a/doc/src/fix_nvt_sllod.rst +++ b/doc/src/fix_nvt_sllod.rst @@ -37,15 +37,16 @@ trajectory consistent with the canonical ensemble. This thermostat is used for a simulation box that is changing size and/or shape, for example in a non-equilibrium MD (NEMD) simulation. -The size/shape change is induced by use of the :doc:`fix deform ` command, so each point in the simulation box -can be thought of as having a "streaming" velocity. This -position-dependent streaming velocity is subtracted from each atom's -actual velocity to yield a thermal velocity which is used for -temperature computation and thermostatting. For example, if the box -is being sheared in x, relative to y, then points at the bottom of the -box (low y) have a small x velocity, while points at the top of the -box (hi y) have a large x velocity. These velocities do not -contribute to the thermal "temperature" of the atom. +The size/shape change is induced by use of the :doc:`fix deform +` command, so each point in the simulation box can be +thought of as having a "streaming" velocity. This position-dependent +streaming velocity is subtracted from each atom's actual velocity to +yield a thermal velocity which is used for temperature computation and +thermostatting. For example, if the box is being sheared in x, +relative to y, then points at the bottom of the box (low y) have a +small x velocity, while points at the top of the box (hi y) have a +large x velocity. These velocities do not contribute to the thermal +"temperature" of the atom. .. note:: @@ -60,13 +61,15 @@ contribute to the thermal "temperature" of the atom. consistent. The SLLOD equations of motion, originally proposed by Hoover and Ladd -(see :ref:`(Evans and Morriss) `), were proven to be equivalent to -Newton's equations of motion for shear flow by :ref:`(Evans and Morriss) `. They were later shown to generate the desired -velocity gradient and the correct production of work by stresses for -all forms of homogeneous flow by :ref:`(Daivis and Todd) `. As -implemented in LAMMPS, they are coupled to a Nose/Hoover chain -thermostat in a velocity Verlet formulation, closely following the -implementation used for the :doc:`fix nvt ` command. +(see :ref:`(Evans and Morriss) `), were proven to be +equivalent to Newton's equations of motion for shear flow by +:ref:`(Evans and Morriss) `. They were later shown to generate +the desired velocity gradient and the correct production of work by +stresses for all forms of homogeneous flow by :ref:`(Daivis and Todd) +`. As implemented in LAMMPS, they are coupled to a +Nose/Hoover chain thermostat in a velocity Verlet formulation, closely +following the implementation used for the :doc:`fix nvt ` +command. .. note:: @@ -94,27 +97,28 @@ underscore + "temp", and the group for the new compute is the same as the fix group. Note that this is NOT the compute used by thermodynamic output (see -the :doc:`thermo_style ` command) with ID = *thermo_temp*. -This means you can change the attributes of this fix's temperature -(e.g. its degrees-of-freedom) via the -:doc:`compute_modify ` command or print this temperature -during thermodynamic output via the :doc:`thermo_style custom ` command using the appropriate compute-ID. -It also means that changing attributes of *thermo_temp* will have no -effect on this fix. +the :doc:`thermo_style ` command) with ID = +*thermo_temp*. This means you can change the attributes of this fix's +temperature (e.g. its degrees-of-freedom) via the :doc:`compute_modify +` command or print this temperature during +thermodynamic output via the :doc:`thermo_style custom ` +command using the appropriate compute-ID. It also means that changing +attributes of *thermo_temp* will have no effect on this fix. Like other fixes that perform thermostatting, this fix can be used -with :doc:`compute commands ` that calculate a temperature -after removing a "bias" from the atom velocities. E.g. removing the -center-of-mass velocity from a group of atoms or only calculating -temperature on the x-component of velocity or only calculating -temperature for atoms in a geometric region. This is not done by -default, but only if the :doc:`fix_modify ` command is used -to assign a temperature compute to this fix that includes such a bias -term. See the doc pages for individual :doc:`compute commands ` to determine which ones include a bias. In -this case, the thermostat works in the following manner: the current -temperature is calculated taking the bias into account, bias is -removed from each atom, thermostatting is performed on the remaining -thermal degrees of freedom, and the bias is added back in. +with :doc:`compute commands ` that remove a "bias" from the +atom velocities. E.g. to apply the thermostat only to atoms within a +spatial :doc:`region `, or to remove the center-of-mass +velocity from a group of atoms, or to remove the x-component of +velocity from the calculation. + +This is not done by default, but only if the :doc:`fix_modify +` command is used to assign a temperature compute to this +fix that includes such a bias term. See the doc pages for individual +:doc:`compute temp commands ` to determine which ones include +a bias. In this case, the thermostat works in the following manner: +bias is removed from each atom, thermostatting is performed on the +remaining thermal degrees of freedom, and the bias is added back in. ---------- diff --git a/doc/src/fix_nvt_sphere.rst b/doc/src/fix_nvt_sphere.rst index 31c8d91889..91575d4c48 100644 --- a/doc/src/fix_nvt_sphere.rst +++ b/doc/src/fix_nvt_sphere.rst @@ -86,18 +86,19 @@ It also means that changing attributes of *thermo_temp* will have no effect on this fix. Like other fixes that perform thermostatting, this fix can be used -with :doc:`compute commands ` that calculate a temperature -after removing a "bias" from the atom velocities. E.g. removing the -center-of-mass velocity from a group of atoms or only calculating -temperature on the x-component of velocity or only calculating -temperature for atoms in a geometric region. This is not done by -default, but only if the :doc:`fix_modify ` command is used -to assign a temperature compute to this fix that includes such a bias -term. See the doc pages for individual :doc:`compute commands ` to determine which ones include a bias. In -this case, the thermostat works in the following manner: the current -temperature is calculated taking the bias into account, bias is -removed from each atom, thermostatting is performed on the remaining -thermal degrees of freedom, and the bias is added back in. +with :doc:`compute commands ` that remove a "bias" from the +atom velocities. E.g. to apply the thermostat only to atoms within a +spatial :doc:`region `, or to remove the center-of-mass +velocity from a group of atoms, or to remove the x-component of +velocity from the calculation. + +This is not done by default, but only if the :doc:`fix_modify +` command is used to assign a temperature compute to this +fix that includes such a bias term. See the doc pages for individual +:doc:`compute temp commands ` to determine which ones include +a bias. In this case, the thermostat works in the following manner: +bias is removed from each atom, thermostatting is performed on the +remaining thermal degrees of freedom, and the bias is added back in. ---------- diff --git a/doc/src/fix_temp_berendsen.rst b/doc/src/fix_temp_berendsen.rst index 89fc2392f4..473c30aced 100644 --- a/doc/src/fix_temp_berendsen.rst +++ b/doc/src/fix_temp_berendsen.rst @@ -102,18 +102,19 @@ It also means that changing attributes of *thermo_temp* will have no effect on this fix. Like other fixes that perform thermostatting, this fix can be used -with :doc:`compute commands ` that calculate a temperature -after removing a "bias" from the atom velocities. E.g. removing the -center-of-mass velocity from a group of atoms or only calculating -temperature on the x-component of velocity or only calculating -temperature for atoms in a geometric region. This is not done by -default, but only if the :doc:`fix_modify ` command is used -to assign a temperature compute to this fix that includes such a bias -term. See the doc pages for individual :doc:`compute commands ` to determine which ones include a bias. In -this case, the thermostat works in the following manner: the current -temperature is calculated taking the bias into account, bias is -removed from each atom, thermostatting is performed on the remaining -thermal degrees of freedom, and the bias is added back in. +with :doc:`compute commands ` that remove a "bias" from the +atom velocities. E.g. to apply the thermostat only to atoms within a +spatial :doc:`region `, or to remove the center-of-mass +velocity from a group of atoms, or to remove the x-component of +velocity from the calculation. + +This is not done by default, but only if the :doc:`fix_modify +` command is used to assign a temperature compute to this +fix that includes such a bias term. See the doc pages for individual +:doc:`compute temp commands ` to determine which ones include +a bias. In this case, the thermostat works in the following manner: +bias is removed from each atom, thermostatting is performed on the +remaining thermal degrees of freedom, and the bias is added back in. ---------- diff --git a/doc/src/fix_temp_csvr.rst b/doc/src/fix_temp_csvr.rst index 81379f346b..5fc6e8eae7 100644 --- a/doc/src/fix_temp_csvr.rst +++ b/doc/src/fix_temp_csvr.rst @@ -110,28 +110,29 @@ during thermodynamic output via the :doc:`thermo_style custom ` co It also means that changing attributes of *thermo_temp* will have no effect on this fix. -Like other fixes that perform thermostatting, these fixes can be used -with :doc:`compute commands ` that calculate a temperature -after removing a "bias" from the atom velocities. E.g. removing the -center-of-mass velocity from a group of atoms or only calculating -temperature on the x-component of velocity or only calculating -temperature for atoms in a geometric region. This is not done by -default, but only if the :doc:`fix_modify ` command is used -to assign a temperature compute to this fix that includes such a bias -term. See the doc pages for individual :doc:`compute commands ` to determine which ones include a bias. In -this case, the thermostat works in the following manner: the current -temperature is calculated taking the bias into account, bias is -removed from each atom, thermostatting is performed on the remaining -thermal degrees of freedom, and the bias is added back in. +Like other fixes that perform thermostatting, this fix can be used +with :doc:`compute commands ` that remove a "bias" from the +atom velocities. E.g. to apply the thermostat only to atoms within a +spatial :doc:`region `, or to remove the center-of-mass +velocity from a group of atoms, or to remove the x-component of +velocity from the calculation. + +This is not done by default, but only if the :doc:`fix_modify +` command is used to assign a temperature compute to this +fix that includes such a bias term. See the doc pages for individual +:doc:`compute temp commands ` to determine which ones include +a bias. In this case, the thermostat works in the following manner: +bias is removed from each atom, thermostatting is performed on the +remaining thermal degrees of freedom, and the bias is added back in. An important feature of these thermostats is that they have an -associated effective energy that is a constant of motion. -The effective energy is the total energy (kinetic + potential) plus -the accumulated kinetic energy changes due to the thermostat. The -latter quantity is the global scalar computed by these fixes. This -feature is useful to check the integration of the equations of motion -against discretization errors. In other words, the conservation of -the effective energy can be used to choose an appropriate integration +associated effective energy that is a constant of motion. The +effective energy is the total energy (kinetic + potential) plus the +accumulated kinetic energy changes due to the thermostat. The latter +quantity is the global scalar computed by these fixes. This feature is +useful to check the integration of the equations of motion against +discretization errors. In other words, the conservation of the +effective energy can be used to choose an appropriate integration :doc:`timestep `. This is similar to the usual paradigm of checking the conservation of the total energy in the microcanonical ensemble. diff --git a/doc/src/fix_temp_rescale.rst b/doc/src/fix_temp_rescale.rst index a61773d2a2..41ad8709cc 100644 --- a/doc/src/fix_temp_rescale.rst +++ b/doc/src/fix_temp_rescale.rst @@ -109,19 +109,19 @@ command using the appropriate compute-ID. It also means that changing attributes of *thermo_temp* will have no effect on this fix. Like other fixes that perform thermostatting, this fix can be used -with :doc:`compute commands ` that calculate a temperature -after removing a "bias" from the atom velocities. E.g. removing the -center-of-mass velocity from a group of atoms or only calculating -temperature on the x-component of velocity or only calculating -temperature for atoms in a geometric region. This is not done by -default, but only if the :doc:`fix_modify ` command is -used to assign a temperature compute to this fix that includes such a -bias term. See the doc pages for individual :doc:`compute commands -` to determine which ones include a bias. In this case, the -thermostat works in the following manner: the current temperature is -calculated taking the bias into account, bias is removed from each -atom, thermostatting is performed on the remaining thermal degrees of -freedom, and the bias is added back in. +with :doc:`compute commands ` that remove a "bias" from the +atom velocities. E.g. to apply the thermostat only to atoms within a +spatial :doc:`region `, or to remove the center-of-mass +velocity from a group of atoms, or to remove the x-component of +velocity from the calculation. + +This is not done by default, but only if the :doc:`fix_modify +` command is used to assign a temperature compute to this +fix that includes such a bias term. See the doc pages for individual +:doc:`compute temp commands ` to determine which ones include +a bias. In this case, the thermostat works in the following manner: +bias is removed from each atom, thermostatting is performed on the +remaining thermal degrees of freedom, and the bias is added back in. ---------- diff --git a/doc/src/fix_tgnh_drude.rst b/doc/src/fix_tgnh_drude.rst index 7088692353..d1f5cf19a4 100644 --- a/doc/src/fix_tgnh_drude.rst +++ b/doc/src/fix_tgnh_drude.rst @@ -187,26 +187,32 @@ barostatting. ---------- -Like other fixes that perform thermostatting, these fixes can -be used with :doc:`compute commands ` that calculate a -temperature after removing a "bias" from the atom velocities. -This is not done by default, but only if the :doc:`fix_modify ` command -is used to assign a temperature compute to this fix that includes such -a bias term. See the doc pages for individual :doc:`compute commands ` to determine which ones include a bias. In -this case, the thermostat works in the following manner: the current -temperature is calculated taking the bias into account, bias is -removed from each atom, thermostatting is performed on the remaining -thermal DOF, and the bias is added back in. +Like other fixes that perform thermostatting, this fix can be used +with :doc:`compute commands ` that remove a "bias" from the +atom velocities. E.g. to apply the thermostat only to atoms within a +spatial :doc:`region `, or to remove the center-of-mass +velocity from a group of atoms, or to remove the x-component of +velocity from the calculation. + +This is not done by default, but only if the :doc:`fix_modify +` command is used to assign a temperature compute to this +fix that includes such a bias term. See the doc pages for individual +:doc:`compute temp commands ` to determine which ones include +a bias. In this case, the thermostat works in the following manner: +bias is removed from each atom, thermostatting is performed on the +remaining thermal degrees of freedom, and the bias is added back in. .. note:: - However, not all temperature compute commands are valid to be used with these fixes. - Precisely, only temperature compute that does not modify the DOF of the group can be used. - E.g. :doc:`compute temp/ramp ` and :doc:`compute viscosity/cos ` - compute the kinetic energy after remove a velocity gradient without affecting the DOF of the group, - then they can be invoked in this way. - In contrast, :doc:`compute temp/partial ` may remove the DOF at one or more dimensions, - therefore it cannot be used with these fixes. + However, not all temperature compute commands are valid to be used + with these fixes. Precisely, only temperature compute that does + not modify the DOF of the group can be used. E.g. :doc:`compute + temp/ramp ` and :doc:`compute viscosity/cos + ` compute the kinetic energy after remove a + velocity gradient without affecting the DOF of the group, then they + can be invoked in this way. In contrast, :doc:`compute + temp/partial ` may remove the DOF at one or + more dimensions, therefore it cannot be used with these fixes. ---------- diff --git a/doc/src/group.rst b/doc/src/group.rst index e72eeb7c19..36559ba68a 100644 --- a/doc/src/group.rst +++ b/doc/src/group.rst @@ -38,7 +38,7 @@ Syntax *intersect* args = two or more group IDs *dynamic* args = parent-ID keyword value ... one or more keyword/value pairs may be appended - keyword = *region* or *var* or *every* + keyword = *region* or *var* or *property* or *every* *region* value = region-ID *var* value = name of variable *property* value = name of custom integer or floating point vector diff --git a/doc/utils/requirements.txt b/doc/utils/requirements.txt index f367727d20..9b8e106875 100644 --- a/doc/utils/requirements.txt +++ b/doc/utils/requirements.txt @@ -1,7 +1,7 @@ -Sphinx==4.0.3 -sphinxcontrib-spelling==7.2.1 +Sphinx +sphinxcontrib-spelling git+git://github.com/akohlmey/sphinx-fortran@parallel-read -sphinx_tabs==3.2.0 -breathe==4.31.0 -Pygments==2.10.0 -six==1.16.0 +sphinx_tabs +breathe +Pygments +six diff --git a/doc/utils/sphinx-config/false_positives.txt b/doc/utils/sphinx-config/false_positives.txt index 5394cf92c1..5f64a4229c 100644 --- a/doc/utils/sphinx-config/false_positives.txt +++ b/doc/utils/sphinx-config/false_positives.txt @@ -2262,6 +2262,7 @@ Nmols nn nnodes Nocedal +nO nocite nocoeff nodeless @@ -3657,6 +3658,7 @@ Yc ycm Yeh yellowgreen +yEs Yethiraj yflag yhi diff --git a/lib/machdyn/Install.py b/lib/machdyn/Install.py index 2e90c9ca0f..8471316401 100644 --- a/lib/machdyn/Install.py +++ b/lib/machdyn/Install.py @@ -17,11 +17,12 @@ parser = ArgumentParser(prog='Install.py', # settings -version = '3.3.9' +version = '3.4.0' tarball = "eigen.tar.gz" # known checksums for different Eigen versions. used to validate the download. checksums = { \ + '3.4.0' : '4c527a9171d71a72a9d4186e65bea559', \ '3.3.9' : '609286804b0f79be622ccf7f9ff2b660', \ '3.3.7' : '9e30f67e8531477de4117506fe44669b' \ } @@ -35,7 +36,7 @@ Syntax from src dir: make lib-smd args="-b" Syntax from lib dir: python Install.py -b or: python Install.py -p /usr/include/eigen3" - or: python Install.py -v 3.3.7 -b + or: python Install.py -v 3.4.0 -b Example: @@ -77,7 +78,7 @@ if pathflag: if buildflag: print("Downloading Eigen ...") eigentar = os.path.join(homepath, tarball) - url = "https://gitlab.com/libeigen/eigen/-/archive/%s/eigen-%s.tar.gz" % (version,version) + url = "https://download.lammps.org/thirdparty/eigen-%s.tar.gz" % version geturl(url, eigentar) # verify downloaded archive integrity via md5 checksum, if known. diff --git a/src/.gitignore b/src/.gitignore index 174ee35be5..1a87b9fa5c 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -27,6 +27,9 @@ /*_ssa.h /*_ssa.cpp +!accelerator_kokkos.h +!accelerator_omp.h + /fix_mdi_engine.cpp /fix_mdi_engine.h /library_mdi.cpp @@ -202,7 +205,6 @@ /plugin.cpp /plugin.h -/lammpsplugin.h /atom_vec_spin.cpp /atom_vec_spin.h @@ -265,8 +267,6 @@ /fix_drag.h /fix_numdiff.cpp /fix_numdiff.h -/fix_nve_noforce.cpp -/fix_nve_noforce.h /fix_spring_rg.cpp /fix_spring_rg.h /fix_temp_csld.cpp @@ -367,8 +367,6 @@ /atom_vec_dpd.h /atom_vec_electron.cpp /atom_vec_electron.h -/atom_vec_ellipsoid.cpp -/atom_vec_ellipsoid.h /atom_vec_full.cpp /atom_vec_full.h /atom_vec_full_hars.cpp @@ -535,8 +533,6 @@ /dihedral_harmonic.h /dihedral_helix.cpp /dihedral_helix.h -/dihedral_hybrid.cpp -/dihedral_hybrid.h /dihedral_multi_harmonic.cpp /dihedral_multi_harmonic.h /dihedral_nharmonic.cpp @@ -883,8 +879,6 @@ /fix_widom.cpp /fix_widom.h /gpu_extra.h -/gridcomm.cpp -/gridcomm.h /group_ndx.cpp /group_ndx.h /gz_file_writer.cpp @@ -909,8 +903,6 @@ /improper_fourier.h /improper_harmonic.cpp /improper_harmonic.h -/improper_hybrid.cpp -/improper_hybrid.h /improper_inversion_harmonic.cpp /improper_inversion_harmonic.h /improper_ring.cpp @@ -1332,8 +1324,6 @@ /thr_data.h /verlet_split.cpp /verlet_split.h -/write_dump.cpp -/write_dump.h /xdr_compat.cpp /xdr_compat.h /zstd_file_writer.cpp diff --git a/src/BOCS/fix_bocs.cpp b/src/BOCS/fix_bocs.cpp index a3ec4b6b56..786ff216b0 100644 --- a/src/BOCS/fix_bocs.cpp +++ b/src/BOCS/fix_bocs.cpp @@ -233,9 +233,7 @@ FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else if (strcmp(arg[iarg],"mtk") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix bocs command"); - if (strcmp(arg[iarg+1],"yes") == 0) mtk_flag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) mtk_flag = 0; - else error->all(FLERR,"Illegal fix bocs command"); + mtk_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"tloop") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix bocs command"); diff --git a/src/COLVARS/fix_colvars.cpp b/src/COLVARS/fix_colvars.cpp index 5ee77768c6..32211f7689 100644 --- a/src/COLVARS/fix_colvars.cpp +++ b/src/COLVARS/fix_colvars.cpp @@ -312,32 +312,26 @@ FixColvars::FixColvars(LAMMPS *lmp, int narg, char **arg) : tmp_name = nullptr; /* parse optional arguments */ - int argsdone = 4; - while (argsdone < narg) { + int iarg = 4; + while (iarg < narg) { // we have keyword/value pairs. check if value is missing - if (argsdone+1 == narg) + if (iarg+1 == narg) error->all(FLERR,"Missing argument to keyword"); - if (0 == strcmp(arg[argsdone], "input")) { - inp_name = strdup(arg[argsdone+1]); - } else if (0 == strcmp(arg[argsdone], "output")) { - out_name = strdup(arg[argsdone+1]); - } else if (0 == strcmp(arg[argsdone], "seed")) { - rng_seed = utils::inumeric(FLERR,arg[argsdone+1],false,lmp); - } else if (0 == strcmp(arg[argsdone], "unwrap")) { - if (0 == strcmp(arg[argsdone+1], "yes")) { - unwrap_flag = 1; - } else if (0 == strcmp(arg[argsdone+1], "no")) { - unwrap_flag = 0; - } else { - error->all(FLERR,"Incorrect fix colvars unwrap flag"); - } - } else if (0 == strcmp(arg[argsdone], "tstat")) { - tmp_name = strdup(arg[argsdone+1]); + if (0 == strcmp(arg[iarg], "input")) { + inp_name = strdup(arg[iarg+1]); + } else if (0 == strcmp(arg[iarg], "output")) { + out_name = strdup(arg[iarg+1]); + } else if (0 == strcmp(arg[iarg], "seed")) { + rng_seed = utils::inumeric(FLERR,arg[iarg+1],false,lmp); + } else if (0 == strcmp(arg[iarg], "unwrap")) { + unwrap_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); + } else if (0 == strcmp(arg[iarg], "tstat")) { + tmp_name = strdup(arg[iarg+1]); } else { error->all(FLERR,"Unknown fix colvars parameter"); } - ++argsdone; ++argsdone; + ++iarg; ++iarg; } if (!out_name) out_name = strdup("out"); diff --git a/src/COMPRESS/dump_atom_zstd.cpp b/src/COMPRESS/dump_atom_zstd.cpp index aa9d14b324..a23ea2025b 100644 --- a/src/COMPRESS/dump_atom_zstd.cpp +++ b/src/COMPRESS/dump_atom_zstd.cpp @@ -188,17 +188,11 @@ int DumpAtomZstd::modify_param(int narg, char **arg) try { if (strcmp(arg[0], "checksum") == 0) { if (narg < 2) error->all(FLERR, "Illegal dump_modify command"); - if (strcmp(arg[1], "yes") == 0) - writer.setChecksum(true); - else if (strcmp(arg[1], "no") == 0) - writer.setChecksum(false); - else - error->all(FLERR, "Illegal dump_modify command"); + writer.setChecksum(utils::logical(FLERR, arg[1], false, lmp) == 1); return 2; } else if (strcmp(arg[0], "compression_level") == 0) { if (narg < 2) error->all(FLERR, "Illegal dump_modify command"); - int compression_level = utils::inumeric(FLERR, arg[1], false, lmp); - writer.setCompressionLevel(compression_level); + writer.setCompressionLevel(utils::inumeric(FLERR, arg[1], false, lmp)); return 2; } } catch (FileWriterException &e) { diff --git a/src/COMPRESS/dump_cfg_zstd.cpp b/src/COMPRESS/dump_cfg_zstd.cpp index 15ea1e540c..73ee3e7e11 100644 --- a/src/COMPRESS/dump_cfg_zstd.cpp +++ b/src/COMPRESS/dump_cfg_zstd.cpp @@ -233,17 +233,11 @@ int DumpCFGZstd::modify_param(int narg, char **arg) try { if (strcmp(arg[0], "checksum") == 0) { if (narg < 2) error->all(FLERR, "Illegal dump_modify command"); - if (strcmp(arg[1], "yes") == 0) - writer.setChecksum(true); - else if (strcmp(arg[1], "no") == 0) - writer.setChecksum(false); - else - error->all(FLERR, "Illegal dump_modify command"); + writer.setChecksum(utils::logical(FLERR, arg[1], false, lmp) == 1); return 2; } else if (strcmp(arg[0], "compression_level") == 0) { if (narg < 2) error->all(FLERR, "Illegal dump_modify command"); - int compression_level = utils::inumeric(FLERR, arg[1], false, lmp); - writer.setCompressionLevel(compression_level); + writer.setCompressionLevel(utils::inumeric(FLERR, arg[1], false, lmp)); return 2; } } catch (FileWriterException &e) { diff --git a/src/COMPRESS/dump_custom_zstd.cpp b/src/COMPRESS/dump_custom_zstd.cpp index 3824709d5e..8b7d153fc4 100644 --- a/src/COMPRESS/dump_custom_zstd.cpp +++ b/src/COMPRESS/dump_custom_zstd.cpp @@ -203,16 +203,13 @@ int DumpCustomZstd::modify_param(int narg, char **arg) int consumed = DumpCustom::modify_param(narg, arg); if (consumed == 0) { try { - if (strcmp(arg[0],"checksum") == 0) { - if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); - if (strcmp(arg[1],"yes") == 0) writer.setChecksum(true); - else if (strcmp(arg[1],"no") == 0) writer.setChecksum(false); - else error->all(FLERR,"Illegal dump_modify command"); + if (strcmp(arg[0], "checksum") == 0) { + if (narg < 2) error->all(FLERR, "Illegal dump_modify command"); + writer.setChecksum(utils::logical(FLERR, arg[1], false, lmp) == 1); return 2; - } else if (strcmp(arg[0],"compression_level") == 0) { - if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); - int compression_level = utils::inumeric(FLERR, arg[1], false, lmp); - writer.setCompressionLevel(compression_level); + } else if (strcmp(arg[0], "compression_level") == 0) { + if (narg < 2) error->all(FLERR, "Illegal dump_modify command"); + writer.setCompressionLevel(utils::inumeric(FLERR, arg[1], false, lmp)); return 2; } } catch (FileWriterException &e) { diff --git a/src/COMPRESS/dump_local_zstd.cpp b/src/COMPRESS/dump_local_zstd.cpp index cf233aff19..91fb36bb6e 100644 --- a/src/COMPRESS/dump_local_zstd.cpp +++ b/src/COMPRESS/dump_local_zstd.cpp @@ -190,17 +190,11 @@ int DumpLocalZstd::modify_param(int narg, char **arg) try { if (strcmp(arg[0], "checksum") == 0) { if (narg < 2) error->all(FLERR, "Illegal dump_modify command"); - if (strcmp(arg[1], "yes") == 0) - writer.setChecksum(true); - else if (strcmp(arg[1], "no") == 0) - writer.setChecksum(false); - else - error->all(FLERR, "Illegal dump_modify command"); + writer.setChecksum(utils::logical(FLERR, arg[1], false, lmp) == 1); return 2; } else if (strcmp(arg[0], "compression_level") == 0) { if (narg < 2) error->all(FLERR, "Illegal dump_modify command"); - int compression_level = utils::inumeric(FLERR, arg[1], false, lmp); - writer.setCompressionLevel(compression_level); + writer.setCompressionLevel(utils::inumeric(FLERR, arg[1], false, lmp)); return 2; } } catch (FileWriterException &e) { diff --git a/src/COMPRESS/dump_xyz_zstd.cpp b/src/COMPRESS/dump_xyz_zstd.cpp index d5c79d181b..534bc0ee56 100644 --- a/src/COMPRESS/dump_xyz_zstd.cpp +++ b/src/COMPRESS/dump_xyz_zstd.cpp @@ -156,17 +156,11 @@ int DumpXYZZstd::modify_param(int narg, char **arg) try { if (strcmp(arg[0], "checksum") == 0) { if (narg < 2) error->all(FLERR, "Illegal dump_modify command"); - if (strcmp(arg[1], "yes") == 0) - writer.setChecksum(true); - else if (strcmp(arg[1], "no") == 0) - writer.setChecksum(false); - else - error->all(FLERR, "Illegal dump_modify command"); + writer.setChecksum(utils::logical(FLERR, arg[1], false, lmp) == 1); return 2; } else if (strcmp(arg[0], "compression_level") == 0) { if (narg < 2) error->all(FLERR, "Illegal dump_modify command"); - int compression_level = utils::inumeric(FLERR, arg[1], false, lmp); - writer.setCompressionLevel(compression_level); + writer.setCompressionLevel(utils::inumeric(FLERR, arg[1], false, lmp)); return 2; } } catch (FileWriterException &e) { diff --git a/src/DIELECTRIC/fix_polarize_bem_gmres.cpp b/src/DIELECTRIC/fix_polarize_bem_gmres.cpp index 538ce15575..f5f119f686 100644 --- a/src/DIELECTRIC/fix_polarize_bem_gmres.cpp +++ b/src/DIELECTRIC/fix_polarize_bem_gmres.cpp @@ -796,12 +796,7 @@ int FixPolarizeBEMGMRES::modify_param(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg], "kspace") == 0) { if (iarg + 2 > narg) error->all(FLERR, "Illegal fix_modify command"); - if (strcmp(arg[iarg + 1], "yes") == 0) - kspaceflag = 1; - else if (strcmp(arg[iarg + 1], "no") == 0) - kspaceflag = 0; - else - error->all(FLERR, "Illegal fix_modify command for fix polarize"); + kspaceflag = utils::logical(FLERR, arg[iarg + 1], false, lmp); iarg += 2; } else if (strcmp(arg[iarg], "dielectrics") == 0) { if (iarg + 6 > narg) error->all(FLERR, "Illegal fix_modify command"); diff --git a/src/DIELECTRIC/fix_polarize_bem_icc.cpp b/src/DIELECTRIC/fix_polarize_bem_icc.cpp index 4c137878a2..35171c0a19 100644 --- a/src/DIELECTRIC/fix_polarize_bem_icc.cpp +++ b/src/DIELECTRIC/fix_polarize_bem_icc.cpp @@ -355,12 +355,7 @@ int FixPolarizeBEMICC::modify_param(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg], "kspace") == 0) { if (iarg + 2 > narg) error->all(FLERR, "Illegal fix_modify command"); - if (strcmp(arg[iarg + 1], "yes") == 0) - kspaceflag = 1; - else if (strcmp(arg[iarg + 1], "no") == 0) - kspaceflag = 0; - else - error->all(FLERR, "Illegal fix_modify command for fix polarize"); + kspaceflag = utils::logical(FLERR, arg[iarg + 1], false, lmp); iarg += 2; } else if (strcmp(arg[iarg], "dielectrics") == 0) { if (iarg + 6 > narg) error->all(FLERR, "Illegal fix_modify command"); diff --git a/src/DIELECTRIC/fix_polarize_functional.cpp b/src/DIELECTRIC/fix_polarize_functional.cpp index 2d67bca0a7..2e43d40ba0 100644 --- a/src/DIELECTRIC/fix_polarize_functional.cpp +++ b/src/DIELECTRIC/fix_polarize_functional.cpp @@ -478,12 +478,7 @@ int FixPolarizeFunctional::modify_param(int narg, char **arg) while (iarg < narg) { if (strcmp(arg[iarg], "kspace") == 0) { if (iarg + 2 > narg) error->all(FLERR, "Illegal fix_modify command"); - if (strcmp(arg[iarg + 1], "yes") == 0) - kspaceflag = 1; - else if (strcmp(arg[iarg + 1], "no") == 0) - kspaceflag = 0; - else - error->all(FLERR, "Illegal fix_modify command for fix polarize/functional"); + kspaceflag = utils::logical(FLERR, arg[iarg + 1], false, lmp); iarg += 2; } else if (strcmp(arg[iarg], "dielectrics") == 0) { if (iarg + 6 > narg) error->all(FLERR, "Illegal fix_modify command"); diff --git a/src/DPD-REACT/random_external_state.h b/src/DPD-REACT/random_external_state.h index 503118f0bf..9a69392a3b 100644 --- a/src/DPD-REACT/random_external_state.h +++ b/src/DPD-REACT/random_external_state.h @@ -78,8 +78,8 @@ namespace random_external_state { typedef uint64_t es_RNG_t; -enum { MAX_URAND = 0xffffffffU }; -enum { MAX_URAND64 = 0xffffffffffffffffULL - 1 }; +constexpr uint32_t MAX_URAND = 0xffffffffU; +constexpr uint64_t MAX_URAND64 = 0xffffffffffffffffULL - 1; LAMMPS_INLINE uint32_t es_urand(es_RNG_t &state_) diff --git a/src/DRUDE/fix_langevin_drude.cpp b/src/DRUDE/fix_langevin_drude.cpp index 205b36ce51..dea2f9ce62 100644 --- a/src/DRUDE/fix_langevin_drude.cpp +++ b/src/DRUDE/fix_langevin_drude.cpp @@ -91,9 +91,7 @@ FixLangevinDrude::FixLangevinDrude(LAMMPS *lmp, int narg, char **arg) : while (iarg < narg) { if (strcmp(arg[iarg],"zero") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix langevin/drude command"); - if (strcmp(arg[iarg+1],"no") == 0) zero = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) zero = 1; - else error->all(FLERR,"Illegal fix langevin/drude command"); + zero = utils::logical(FLERR, arg[iarg + 1], false, lmp); iarg += 2; } else error->all(FLERR,"Illegal fix langevin/drude command"); } diff --git a/src/DRUDE/fix_tgnh_drude.cpp b/src/DRUDE/fix_tgnh_drude.cpp index fe8cf448f0..eb8922d4cc 100644 --- a/src/DRUDE/fix_tgnh_drude.cpp +++ b/src/DRUDE/fix_tgnh_drude.cpp @@ -256,9 +256,7 @@ FixTGNHDrude::FixTGNHDrude(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else if (strcmp(arg[iarg],"mtk") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); - if (strcmp(arg[iarg+1],"yes") == 0) mtk_flag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) mtk_flag = 0; - else error->all(FLERR,"Illegal fix nvt/npt/nph command"); + mtk_flag = utils::logical(FLERR, arg[iarg + 1], false, lmp); iarg += 2; } else if (strcmp(arg[iarg],"tloop") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); @@ -277,27 +275,19 @@ FixTGNHDrude::FixTGNHDrude(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else if (strcmp(arg[iarg],"scalexy") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); - if (strcmp(arg[iarg+1],"yes") == 0) scalexy = 1; - else if (strcmp(arg[iarg+1],"no") == 0) scalexy = 0; - else error->all(FLERR,"Illegal fix nvt/npt/nph command"); + scalexy = utils::logical(FLERR, arg[iarg + 1], false, lmp); iarg += 2; } else if (strcmp(arg[iarg],"scalexz") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); - if (strcmp(arg[iarg+1],"yes") == 0) scalexz = 1; - else if (strcmp(arg[iarg+1],"no") == 0) scalexz = 0; - else error->all(FLERR,"Illegal fix nvt/npt/nph command"); + scalexz = utils::logical(FLERR, arg[iarg + 1], false, lmp); iarg += 2; } else if (strcmp(arg[iarg],"scaleyz") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); - if (strcmp(arg[iarg+1],"yes") == 0) scaleyz = 1; - else if (strcmp(arg[iarg+1],"no") == 0) scaleyz = 0; - else error->all(FLERR,"Illegal fix nvt/npt/nph command"); + scaleyz = utils::logical(FLERR, arg[iarg + 1], false, lmp); iarg += 2; } else if (strcmp(arg[iarg],"flip") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); - if (strcmp(arg[iarg+1],"yes") == 0) flipflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) flipflag = 0; - else error->all(FLERR,"Illegal fix nvt/npt/nph command"); + flipflag = utils::logical(FLERR, arg[iarg + 1], false, lmp); iarg += 2; } else if (strcmp(arg[iarg],"fixedpoint") == 0) { if (iarg+4 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); diff --git a/src/EXTRA-COMPUTE/compute_ackland_atom.cpp b/src/EXTRA-COMPUTE/compute_ackland_atom.cpp index 05fd374a10..dc55167dc5 100644 --- a/src/EXTRA-COMPUTE/compute_ackland_atom.cpp +++ b/src/EXTRA-COMPUTE/compute_ackland_atom.cpp @@ -18,20 +18,22 @@ Updated algorithm by: Brian Barnes, brian.c.barnes11.civ@mail.mil ------------------------------------------------------------------------- */ -#include -#include #include "compute_ackland_atom.h" + #include "atom.h" -#include "update.h" +#include "comm.h" +#include "error.h" +#include "force.h" +#include "memory.h" #include "modify.h" -#include "neighbor.h" #include "neigh_list.h" #include "neigh_request.h" -#include "force.h" +#include "neighbor.h" #include "pair.h" -#include "comm.h" -#include "memory.h" -#include "error.h" +#include "update.h" + +#include +#include using namespace LAMMPS_NS; @@ -60,16 +62,10 @@ ComputeAcklandAtom::ComputeAcklandAtom(LAMMPS *lmp, int narg, char **arg) : int iarg = 3; while (narg > iarg) { if (strcmp("legacy",arg[iarg]) == 0) { - ++iarg; - if (iarg >= narg) - error->all(FLERR,"Invalid compute ackland/atom command"); - if (strcmp("yes",arg[iarg]) == 0) - legacy = 1; - else if (strcmp("no",arg[iarg]) == 0) - legacy = 0; - else error->all(FLERR,"Invalid compute ackland/atom command"); + if (iarg+2 > narg) error->all(FLERR,"Invalid compute ackland/atom command"); + legacy = utils::logical(FLERR,arg[iarg+1],false,lmp); + iarg += 2; } - ++iarg; } } diff --git a/src/EXTRA-COMPUTE/compute_entropy_atom.cpp b/src/EXTRA-COMPUTE/compute_entropy_atom.cpp index d0866c946c..ac53bf1e7f 100644 --- a/src/EXTRA-COMPUTE/compute_entropy_atom.cpp +++ b/src/EXTRA-COMPUTE/compute_entropy_atom.cpp @@ -17,21 +17,23 @@ ------------------------------------------------------------------------- */ #include "compute_entropy_atom.h" -#include -#include + #include "atom.h" -#include "update.h" -#include "modify.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "neigh_request.h" -#include "force.h" -#include "pair.h" #include "comm.h" +#include "domain.h" +#include "error.h" +#include "force.h" #include "math_const.h" #include "memory.h" -#include "error.h" -#include "domain.h" +#include "modify.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "neighbor.h" +#include "pair.h" +#include "update.h" + +#include +#include using namespace LAMMPS_NS; using namespace MathConst; @@ -44,8 +46,7 @@ ComputeEntropyAtom(LAMMPS *lmp, int narg, char **arg) : pair_entropy(nullptr), pair_entropy_avg(nullptr) { if (narg < 5 || narg > 10) - error->all(FLERR,"Illegal compute entropy/atom command; wrong number" - " of arguments"); + error->all(FLERR,"Illegal compute entropy/atom command; wrong number of arguments"); // Arguments are: sigma cutoff avg yes/no cutoff2 local yes/no // sigma is the gaussian width @@ -57,11 +58,9 @@ ComputeEntropyAtom(LAMMPS *lmp, int narg, char **arg) : // the g(r) sigma = utils::numeric(FLERR,arg[3],false,lmp); - if (sigma <= 0.0) error->all(FLERR,"Illegal compute entropy/atom" - " command; sigma must be positive"); + if (sigma <= 0.0) error->all(FLERR,"Illegal compute entropy/atom command; sigma must be positive"); cutoff = utils::numeric(FLERR,arg[4],false,lmp); - if (cutoff <= 0.0) error->all(FLERR,"Illegal compute entropy/atom" - " command; cutoff must be positive"); + if (cutoff <= 0.0) error->all(FLERR,"Illegal compute entropy/atom command; cutoff must be positive"); cutoff2 = 0.; avg_flag = 0; @@ -71,26 +70,17 @@ ComputeEntropyAtom(LAMMPS *lmp, int narg, char **arg) : int iarg = 5; while (iarg < narg) { if (strcmp(arg[iarg],"avg") == 0) { - if (iarg+2 > narg) - error->all(FLERR,"Illegal compute entropy/atom;" - " missing arguments after avg"); - if (strcmp(arg[iarg+1],"yes") == 0) avg_flag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) avg_flag = 0; - else error->all(FLERR,"Illegal compute entropy/atom;" - " argument after avg should be yes or no"); + if (iarg+3 > narg) error->all(FLERR,"Illegal compute entropy/atom command"); + avg_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); cutoff2 = utils::numeric(FLERR,arg[iarg+2],false,lmp); - if (cutoff2 < 0.0) error->all(FLERR,"Illegal compute entropy/atom" - " command; negative cutoff2"); + if (cutoff2 < 0.0) error->all(FLERR,"Illegal compute entropy/atom command; negative cutoff2"); cutsq2 = cutoff2*cutoff2; iarg += 3; } else if (strcmp(arg[iarg],"local") == 0) { - if (strcmp(arg[iarg+1],"yes") == 0) local_flag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) local_flag = 0; - else error->all(FLERR,"Illegal compute entropy/atom;" - " argument after local should be yes or no"); + if (iarg+2 > narg) error->all(FLERR,"Illegal compute entropy/atom command"); + local_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; - } else error->all(FLERR,"Illegal compute entropy/atom; argument after" - " sigma and cutoff should be avg or local"); + } else error->all(FLERR,"Illegal compute entropy/atom command"); } diff --git a/src/EXTRA-DUMP/dump_dcd.cpp b/src/EXTRA-DUMP/dump_dcd.cpp index 97c9bec646..ec3973448a 100644 --- a/src/EXTRA-DUMP/dump_dcd.cpp +++ b/src/EXTRA-DUMP/dump_dcd.cpp @@ -258,9 +258,7 @@ int DumpDCD::modify_param(int narg, char **arg) { if (strcmp(arg[0],"unwrap") == 0) { if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); - if (strcmp(arg[1],"yes") == 0) unwrap_flag = 1; - else if (strcmp(arg[1],"no") == 0) unwrap_flag = 0; - else error->all(FLERR,"Illegal dump_modify command"); + unwrap_flag = utils::logical(FLERR,arg[1],false,lmp); return 2; } return 0; diff --git a/src/EXTRA-DUMP/dump_xtc.cpp b/src/EXTRA-DUMP/dump_xtc.cpp index 7de6d03561..94846671cd 100644 --- a/src/EXTRA-DUMP/dump_xtc.cpp +++ b/src/EXTRA-DUMP/dump_xtc.cpp @@ -24,19 +24,20 @@ ------------------------------------------------------------------------- */ #include "dump_xtc.h" -#include -#include -#include -#include "domain.h" #include "atom.h" -#include "update.h" -#include "group.h" -#include "output.h" -#include "force.h" #include "comm.h" -#include "memory.h" +#include "domain.h" #include "error.h" +#include "force.h" +#include "group.h" +#include "memory.h" +#include "output.h" +#include "update.h" + +#include +#include +#include using namespace LAMMPS_NS; @@ -278,9 +279,7 @@ int DumpXTC::modify_param(int narg, char **arg) { if (strcmp(arg[0],"unwrap") == 0) { if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); - if (strcmp(arg[1],"yes") == 0) unwrap_flag = 1; - else if (strcmp(arg[1],"no") == 0) unwrap_flag = 0; - else error->all(FLERR,"Illegal dump_modify command"); + unwrap_flag = utils::logical(FLERR,arg[1],false,lmp); return 2; } else if (strcmp(arg[0],"precision") == 0) { if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); diff --git a/src/EXTRA-FIX/fix_flow_gauss.cpp b/src/EXTRA-FIX/fix_flow_gauss.cpp index 415f1eecc0..2f8de2e21a 100644 --- a/src/EXTRA-FIX/fix_flow_gauss.cpp +++ b/src/EXTRA-FIX/fix_flow_gauss.cpp @@ -91,9 +91,7 @@ FixFlowGauss::FixFlowGauss(LAMMPS *lmp, int narg, char **arg) : while (iarg < narg) { if (strcmp(arg[iarg],"energy") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal energy keyword"); - if (strcmp(arg[iarg+1],"yes") == 0) workflag = true; - else if (strcmp(arg[iarg+1],"no") != 0) - error->all(FLERR,"Illegal energy keyword"); + workflag = utils::logical(FLERR,arg[iarg+1],false,lmp) == 1; iarg += 2; } else error->all(FLERR,"Illegal fix flow/gauss command"); } diff --git a/src/EXTRA-FIX/fix_gld.cpp b/src/EXTRA-FIX/fix_gld.cpp index 3f807d0f51..41585e4fd0 100644 --- a/src/EXTRA-FIX/fix_gld.cpp +++ b/src/EXTRA-FIX/fix_gld.cpp @@ -19,17 +19,18 @@ #include "fix_gld.h" +#include "atom.h" +#include "comm.h" +#include "error.h" +#include "force.h" +#include "group.h" +#include "memory.h" +#include "random_mars.h" +#include "respa.h" +#include "update.h" + #include #include -#include "atom.h" -#include "force.h" -#include "update.h" -#include "respa.h" -#include "comm.h" -#include "random_mars.h" -#include "memory.h" -#include "error.h" -#include "group.h" #define GLD_UNIFORM_DISTRO @@ -128,26 +129,14 @@ FixGLD::FixGLD(LAMMPS *lmp, int narg, char **arg) : while (iarg < narg) { if (strcmp(arg[iarg],"zero") == 0) { - if (iarg+2 > narg) { - error->all(FLERR, "Illegal fix gld command"); - } - if (strcmp(arg[iarg+1],"no") == 0) { - zeroflag = 0; - } else if (strcmp(arg[iarg+1],"yes") == 0) { - zeroflag = 1; - } else { - error->all(FLERR,"Illegal fix gld command"); - } + if (iarg+2 > narg) error->all(FLERR, "Illegal fix gld command"); + zeroflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"frozen") == 0) { - if (iarg+2 > narg) { - error->all(FLERR, "Illegal fix gld command"); - } - if (strcmp(arg[iarg+1],"no") == 0) { - freezeflag = 0; - } else if (strcmp(arg[iarg+1],"yes") == 0) { - freezeflag = 1; + if (iarg+2 > narg) error->all(FLERR, "Illegal fix gld command"); + freezeflag = utils::logical(FLERR,arg[iarg+1],false,lmp); + if (freezeflag) { for (int i = 0; i < atom->nlocal; i++) { if (atom->mask[i] & groupbit) { for (int k = 0; k < 3*prony_terms; k=k+3) @@ -158,8 +147,6 @@ FixGLD::FixGLD(LAMMPS *lmp, int narg, char **arg) : } } } - } else { - error->all(FLERR, "Illegal fix gld command"); } iarg += 2; } diff --git a/src/EXTRA-FIX/fix_npt_cauchy.cpp b/src/EXTRA-FIX/fix_npt_cauchy.cpp index 5e392eef0d..d9a0f850db 100644 --- a/src/EXTRA-FIX/fix_npt_cauchy.cpp +++ b/src/EXTRA-FIX/fix_npt_cauchy.cpp @@ -297,9 +297,7 @@ FixNPTCauchy::FixNPTCauchy(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else if (strcmp(arg[iarg],"mtk") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix npt/cauchy command"); - if (strcmp(arg[iarg+1],"yes") == 0) mtk_flag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) mtk_flag = 0; - else error->all(FLERR,"Illegal fix npt/cauchy command"); + mtk_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"tloop") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix npt/cauchy command"); @@ -318,27 +316,19 @@ FixNPTCauchy::FixNPTCauchy(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else if (strcmp(arg[iarg],"scalexy") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix npt/cauchy command"); - if (strcmp(arg[iarg+1],"yes") == 0) scalexy = 1; - else if (strcmp(arg[iarg+1],"no") == 0) scalexy = 0; - else error->all(FLERR,"Illegal fix npt/cauchy command"); + scalexy = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"scalexz") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix npt/cauchy command"); - if (strcmp(arg[iarg+1],"yes") == 0) scalexz = 1; - else if (strcmp(arg[iarg+1],"no") == 0) scalexz = 0; - else error->all(FLERR,"Illegal fix npt/cauchy command"); + scalexz = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"scaleyz") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix npt/cauchy command"); - if (strcmp(arg[iarg+1],"yes") == 0) scaleyz = 1; - else if (strcmp(arg[iarg+1],"no") == 0) scaleyz = 0; - else error->all(FLERR,"Illegal fix npt/cauchy command"); + scaleyz = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"flip") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix npt/cauchy command"); - if (strcmp(arg[iarg+1],"yes") == 0) flipflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) flipflag = 0; - else error->all(FLERR,"Illegal fix npt/cauchy command"); + flipflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"update") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix npt/cauchy command"); @@ -352,10 +342,8 @@ FixNPTCauchy::FixNPTCauchy(LAMMPS *lmp, int narg, char **arg) : alpha = utils::numeric(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"continue") == 0) { - if (strcmp(arg[iarg+1],"yes") != 0 && strcmp(arg[iarg+1],"no") != 0) - error->all(FLERR,"Illegal cauchystat continue value. " - "Must be 'yes' or 'no'"); - restartPK = !strcmp(arg[iarg+1],"yes"); + if (iarg+2 > narg) error->all(FLERR,"Illegal fix npt/cauchy command"); + restartPK = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"fixedpoint") == 0) { if (iarg+4 > narg) error->all(FLERR,"Illegal fix npt/cauchy command"); diff --git a/src/EXTRA-FIX/fix_pafi.cpp b/src/EXTRA-FIX/fix_pafi.cpp index 3b51906ae1..fbb6fb2971 100644 --- a/src/EXTRA-FIX/fix_pafi.cpp +++ b/src/EXTRA-FIX/fix_pafi.cpp @@ -103,16 +103,12 @@ FixPAFI::FixPAFI(LAMMPS *lmp, int narg, char **arg) : int iarg = 7; while (iarg < narg) { if (strcmp(arg[iarg],"overdamped") == 0) { - if (strcmp(arg[iarg+1],"no") == 0) od_flag = 0; - else if (strcmp(arg[iarg+1],"0") == 0) od_flag = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) od_flag = 1; - else if (strcmp(arg[iarg+1],"1") == 0) od_flag = 1; + if (iarg+2 > narg) error->all(FLERR,"Illegal fix pafi command"); + od_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"com") == 0) { - if (strcmp(arg[iarg+1],"no") == 0) com_flag = 0; - else if (strcmp(arg[iarg+1],"0") == 0) com_flag = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) com_flag = 1; - else if (strcmp(arg[iarg+1],"1") == 0) com_flag = 1; + if (iarg+2 > narg) error->all(FLERR,"Illegal fix pafi command"); + com_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else error->all(FLERR,"Illegal fix pafi command"); } diff --git a/src/EXTRA-MOLECULE/angle_gaussian.cpp b/src/EXTRA-MOLECULE/angle_gaussian.cpp index e4310e0a22..54c2aa1880 100644 --- a/src/EXTRA-MOLECULE/angle_gaussian.cpp +++ b/src/EXTRA-MOLECULE/angle_gaussian.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -34,9 +33,9 @@ using namespace MathConst; /* ---------------------------------------------------------------------- */ -AngleGaussian::AngleGaussian(LAMMPS *lmp) - : Angle(lmp), nterms(nullptr), angle_temperature(nullptr), - alpha(nullptr), width(nullptr), theta0(nullptr) +AngleGaussian::AngleGaussian(LAMMPS *lmp) : + Angle(lmp), nterms(nullptr), angle_temperature(nullptr), alpha(nullptr), width(nullptr), + theta0(nullptr) { } @@ -49,13 +48,13 @@ AngleGaussian::~AngleGaussian() memory->destroy(nterms); memory->destroy(angle_temperature); for (int i = 1; i <= atom->nangletypes; i++) { - delete [] alpha[i]; - delete [] width[i]; - delete [] theta0[i]; + delete[] alpha[i]; + delete[] width[i]; + delete[] theta0[i]; } - delete [] alpha; - delete [] width; - delete [] theta0; + delete[] alpha; + delete[] width; + delete[] theta0; } } @@ -63,15 +62,15 @@ AngleGaussian::~AngleGaussian() void AngleGaussian::compute(int eflag, int vflag) { - int i1,i2,i3,n,type; - double delx1,dely1,delz1,delx2,dely2,delz2; - double eangle,f1[3],f3[3]; + int i1, i2, i3, n, type; + double delx1, dely1, delz1, delx2, dely2, delz2; + double eangle, f1[3], f3[3]; double dtheta; - double rsq1,rsq2,r1,r2,c,s,a,a11,a12,a22; + double rsq1, rsq2, r1, r2, c, s, a, a11, a12, a22; double prefactor, exponent, g_i, sum_g_i, sum_numerator; eangle = 0.0; - ev_init(eflag,vflag); + ev_init(eflag, vflag); double **x = atom->x; double **f = atom->f; @@ -92,7 +91,7 @@ void AngleGaussian::compute(int eflag, int vflag) dely1 = x[i1][1] - x[i2][1]; delz1 = x[i1][2] - x[i2][2]; - rsq1 = delx1*delx1 + dely1*dely1 + delz1*delz1; + rsq1 = delx1 * delx1 + dely1 * dely1 + delz1 * delz1; r1 = sqrt(rsq1); // 2nd bond @@ -101,20 +100,20 @@ void AngleGaussian::compute(int eflag, int vflag) dely2 = x[i3][1] - x[i2][1]; delz2 = x[i3][2] - x[i2][2]; - rsq2 = delx2*delx2 + dely2*dely2 + delz2*delz2; + rsq2 = delx2 * delx2 + dely2 * dely2 + delz2 * delz2; r2 = sqrt(rsq2); // angle (cos and sin) - c = delx1*delx2 + dely1*dely2 + delz1*delz2; - c /= r1*r2; + c = delx1 * delx2 + dely1 * dely2 + delz1 * delz2; + c /= r1 * r2; if (c > 1.0) c = 1.0; if (c < -1.0) c = -1.0; - s = sqrt(1.0 - c*c); + s = sqrt(1.0 - c * c); if (s < SMAL) s = SMAL; - s = 1.0/s; + s = 1.0 / s; // force & energy double theta = acos(c); @@ -123,28 +122,28 @@ void AngleGaussian::compute(int eflag, int vflag) sum_numerator = 0.0; for (int i = 0; i < nterms[type]; i++) { dtheta = theta - theta0[type][i]; - prefactor = (alpha[type][i]/(width[type][i]*sqrt(MY_PI2))); - exponent = -2*dtheta*dtheta/(width[type][i]*width[type][i]); - g_i = prefactor*exp(exponent); + prefactor = (alpha[type][i] / (width[type][i] * sqrt(MY_PI2))); + exponent = -2 * dtheta * dtheta / (width[type][i] * width[type][i]); + g_i = prefactor * exp(exponent); sum_g_i += g_i; - sum_numerator += g_i*dtheta/(width[type][i]*width[type][i]); + sum_numerator += g_i * dtheta / (width[type][i] * width[type][i]); } if (sum_g_i < SMALL) sum_g_i = SMALL; - if (eflag) eangle = -(force->boltz*angle_temperature[type])*log(sum_g_i); + if (eflag) eangle = -(force->boltz * angle_temperature[type]) * log(sum_g_i); // I should check about the sign of this expression - a = -4.0*(force->boltz*angle_temperature[type])*(sum_numerator/sum_g_i)*s; - a11 = a*c / rsq1; - a12 = -a / (r1*r2); - a22 = a*c / rsq2; + a = -4.0 * (force->boltz * angle_temperature[type]) * (sum_numerator / sum_g_i) * s; + a11 = a * c / rsq1; + a12 = -a / (r1 * r2); + a22 = a * c / rsq2; - f1[0] = a11*delx1 + a12*delx2; - f1[1] = a11*dely1 + a12*dely2; - f1[2] = a11*delz1 + a12*delz2; - f3[0] = a22*delx2 + a12*delx1; - f3[1] = a22*dely2 + a12*dely1; - f3[2] = a22*delz2 + a12*delz1; + f1[0] = a11 * delx1 + a12 * delx2; + f1[1] = a11 * dely1 + a12 * dely2; + f1[2] = a11 * delz1 + a12 * delz2; + f3[0] = a22 * delx2 + a12 * delx1; + f3[1] = a22 * dely2 + a12 * dely1; + f3[2] = a22 * delz2 + a12 * delz1; // apply force to each of 3 atoms @@ -166,8 +165,9 @@ void AngleGaussian::compute(int eflag, int vflag) f[i3][2] += f3[2]; } - if (evflag) ev_tally(i1,i2,i3,nlocal,newton_bond,eangle,f1,f3, - delx1,dely1,delz1,delx2,dely2,delz2); + if (evflag) + ev_tally(i1, i2, i3, nlocal, newton_bond, eangle, f1, f3, delx1, dely1, delz1, delx2, dely2, + delz2); } } @@ -176,20 +176,20 @@ void AngleGaussian::compute(int eflag, int vflag) void AngleGaussian::allocate() { allocated = 1; - int n = atom->nangletypes; + int n = atom->nangletypes + 1; - memory->create(nterms,n+1,"angle:nterms"); - memory->create(angle_temperature,n+1,"angle:angle_temperature"); + memory->create(nterms, n, "angle:nterms"); + memory->create(angle_temperature, n, "angle:angle_temperature"); - alpha = new double *[n+1]; - width = new double *[n+1]; - theta0 = new double *[n+1]; - memset(alpha,0,sizeof(double)*(n+1)); - memset(width,0,sizeof(double)*(n+1)); - memset(theta0,0,sizeof(double)*(n+1)); + alpha = new double *[n]; + width = new double *[n]; + theta0 = new double *[n]; + memset(alpha, 0, sizeof(double *) * n); + memset(width, 0, sizeof(double *) * n); + memset(theta0, 0, sizeof(double *) * n); - memory->create(setflag,n+1,"angle:setflag"); - for (int i = 1; i <= n; i++) setflag[i] = 0; + memory->create(setflag, n, "angle:setflag"); + memset(setflag, 0, sizeof(int) * n); } /* ---------------------------------------------------------------------- @@ -198,15 +198,14 @@ void AngleGaussian::allocate() void AngleGaussian::coeff(int narg, char **arg) { - if (narg < 6) error->all(FLERR,"Incorrect args for angle coefficients"); + if (narg < 6) error->all(FLERR, "Incorrect args for angle coefficients"); - int ilo,ihi; - utils::bounds(FLERR,arg[0],1,atom->nangletypes,ilo,ihi,error); + int ilo, ihi; + utils::bounds(FLERR, arg[0], 1, atom->nangletypes, ilo, ihi, error); - double angle_temperature_one = utils::numeric(FLERR,arg[1],false,lmp); - int n = utils::inumeric(FLERR,arg[2],false,lmp); - if (narg != 3*n + 3) - error->all(FLERR,"Incorrect args for angle coefficients"); + double angle_temperature_one = utils::numeric(FLERR, arg[1], false, lmp); + int n = utils::inumeric(FLERR, arg[2], false, lmp); + if (narg != 3 * n + 3) error->all(FLERR, "Incorrect args for angle coefficients"); if (!allocated) allocate(); @@ -217,21 +216,21 @@ void AngleGaussian::coeff(int narg, char **arg) angle_temperature[i] = angle_temperature_one; nterms[i] = n; delete[] alpha[i]; - alpha[i] = new double [n]; + alpha[i] = new double[n]; delete[] width[i]; - width[i] = new double [n]; + width[i] = new double[n]; delete[] theta0[i]; - theta0[i] = new double [n]; + theta0[i] = new double[n]; for (int j = 0; j < n; j++) { - alpha[i][j] = utils::numeric(FLERR,arg[3+3*j],false,lmp); - width[i][j] = utils::numeric(FLERR,arg[4+3*j],false,lmp); - theta0[i][j] = utils::numeric(FLERR,arg[5+3*j],false,lmp)* MY_PI / 180.0; + alpha[i][j] = utils::numeric(FLERR, arg[3 + 3 * j], false, lmp); + width[i][j] = utils::numeric(FLERR, arg[4 + 3 * j], false, lmp); + theta0[i][j] = utils::numeric(FLERR, arg[5 + 3 * j], false, lmp) * MY_PI / 180.0; setflag[i] = 1; } count++; } - if (count == 0) error->all(FLERR,"Incorrect args for angle coefficients"); + if (count == 0) error->all(FLERR, "Incorrect args for angle coefficients"); } /* ---------------------------------------------------------------------- */ @@ -247,12 +246,12 @@ double AngleGaussian::equilibrium_angle(int i) void AngleGaussian::write_restart(FILE *fp) { - fwrite(&angle_temperature[1],sizeof(double),atom->nangletypes,fp); - fwrite(&nterms[1],sizeof(int),atom->nangletypes,fp); + fwrite(&angle_temperature[1], sizeof(double), atom->nangletypes, fp); + fwrite(&nterms[1], sizeof(int), atom->nangletypes, fp); for (int i = 1; i <= atom->nangletypes; i++) { - fwrite(alpha[i],sizeof(double),nterms[i],fp); - fwrite(width[i],sizeof(double),nterms[i],fp); - fwrite(theta0[i],sizeof(double),nterms[i],fp); + fwrite(alpha[i], sizeof(double), nterms[i], fp); + fwrite(width[i], sizeof(double), nterms[i], fp); + fwrite(theta0[i], sizeof(double), nterms[i], fp); } } @@ -265,31 +264,32 @@ void AngleGaussian::read_restart(FILE *fp) allocate(); if (comm->me == 0) { - utils::sfread(FLERR,&angle_temperature[1],sizeof(double),atom->nangletypes,fp,nullptr,error); - utils::sfread(FLERR,&nterms[1],sizeof(int),atom->nangletypes,fp,nullptr,error); + utils::sfread(FLERR, &angle_temperature[1], sizeof(double), atom->nangletypes, fp, nullptr, + error); + utils::sfread(FLERR, &nterms[1], sizeof(int), atom->nangletypes, fp, nullptr, error); } - MPI_Bcast(&angle_temperature[1],atom->nangletypes,MPI_DOUBLE,0,world); - MPI_Bcast(&nterms[1],atom->nangletypes,MPI_INT,0,world); + MPI_Bcast(&angle_temperature[1], atom->nangletypes, MPI_DOUBLE, 0, world); + MPI_Bcast(&nterms[1], atom->nangletypes, MPI_INT, 0, world); // allocate for (int i = 1; i <= atom->nangletypes; i++) { - alpha[i] = new double [nterms[i]]; - width[i] = new double [nterms[i]]; - theta0[i] = new double [nterms[i]]; + alpha[i] = new double[nterms[i]]; + width[i] = new double[nterms[i]]; + theta0[i] = new double[nterms[i]]; } if (comm->me == 0) { for (int i = 1; i <= atom->nangletypes; i++) { - utils::sfread(FLERR,alpha[i],sizeof(double),nterms[i],fp,nullptr,error); - utils::sfread(FLERR,width[i],sizeof(double),nterms[i],fp,nullptr,error); - utils::sfread(FLERR,theta0[i],sizeof(double),nterms[i],fp,nullptr,error); + utils::sfread(FLERR, alpha[i], sizeof(double), nterms[i], fp, nullptr, error); + utils::sfread(FLERR, width[i], sizeof(double), nterms[i], fp, nullptr, error); + utils::sfread(FLERR, theta0[i], sizeof(double), nterms[i], fp, nullptr, error); } } for (int i = 1; i <= atom->nangletypes; i++) { - MPI_Bcast(alpha[i],nterms[i],MPI_DOUBLE,0,world); - MPI_Bcast(width[i],nterms[i],MPI_DOUBLE,0,world); - MPI_Bcast(theta0[i],nterms[i],MPI_DOUBLE,0,world); + MPI_Bcast(alpha[i], nterms[i], MPI_DOUBLE, 0, world); + MPI_Bcast(width[i], nterms[i], MPI_DOUBLE, 0, world); + MPI_Bcast(theta0[i], nterms[i], MPI_DOUBLE, 0, world); } for (int i = 1; i <= atom->nangletypes; i++) setflag[i] = 1; @@ -302,13 +302,12 @@ void AngleGaussian::read_restart(FILE *fp) void AngleGaussian::write_data(FILE *fp) { for (int i = 1; i <= atom->nangletypes; i++) { - fprintf(fp,"%d %g %d",i,angle_temperature[i],nterms[i]); + fprintf(fp, "%d %g %d", i, angle_temperature[i], nterms[i]); for (int j = 0; j < nterms[i]; j++) { - fprintf(fp," %g %g %g",alpha[i][j],width[i][j],(theta0[i][j]/MY_PI)*180.0); + fprintf(fp, " %g %g %g", alpha[i][j], width[i][j], (theta0[i][j] / MY_PI) * 180.0); } fprintf(fp, "\n"); } - } /* ---------------------------------------------------------------------- */ @@ -320,30 +319,30 @@ double AngleGaussian::single(int type, int i1, int i2, int i3) double delx1 = x[i1][0] - x[i2][0]; double dely1 = x[i1][1] - x[i2][1]; double delz1 = x[i1][2] - x[i2][2]; - domain->minimum_image(delx1,dely1,delz1); - double r1 = sqrt(delx1*delx1 + dely1*dely1 + delz1*delz1); + domain->minimum_image(delx1, dely1, delz1); + double r1 = sqrt(delx1 * delx1 + dely1 * dely1 + delz1 * delz1); double delx2 = x[i3][0] - x[i2][0]; double dely2 = x[i3][1] - x[i2][1]; double delz2 = x[i3][2] - x[i2][2]; - domain->minimum_image(delx2,dely2,delz2); - double r2 = sqrt(delx2*delx2 + dely2*dely2 + delz2*delz2); + domain->minimum_image(delx2, dely2, delz2); + double r2 = sqrt(delx2 * delx2 + dely2 * dely2 + delz2 * delz2); - double c = delx1*delx2 + dely1*dely2 + delz1*delz2; - c /= r1*r2; + double c = delx1 * delx2 + dely1 * dely2 + delz1 * delz2; + c /= r1 * r2; if (c > 1.0) c = 1.0; if (c < -1.0) c = -1.0; - double theta = acos(c) ; + double theta = acos(c); double sum_g_i = 0.0; for (int i = 0; i < nterms[type]; i++) { double dtheta = theta - theta0[type][i]; - double prefactor = (alpha[type][i]/(width[type][i]*sqrt(MY_PI2))); - double exponent = -2*dtheta*dtheta/(width[type][i]*width[type][i]); - double g_i = prefactor*exp(exponent); + double prefactor = (alpha[type][i] / (width[type][i] * sqrt(MY_PI2))); + double exponent = -2 * dtheta * dtheta / (width[type][i] * width[type][i]); + double g_i = prefactor * exp(exponent); sum_g_i += g_i; } if (sum_g_i < SMALL) sum_g_i = SMALL; - return -(force->boltz*angle_temperature[type])*log(sum_g_i); + return -(force->boltz * angle_temperature[type]) * log(sum_g_i); } diff --git a/src/EXTRA-MOLECULE/bond_gaussian.cpp b/src/EXTRA-MOLECULE/bond_gaussian.cpp index ca0bd13df8..c2ab00dfde 100644 --- a/src/EXTRA-MOLECULE/bond_gaussian.cpp +++ b/src/EXTRA-MOLECULE/bond_gaussian.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -14,16 +13,16 @@ #include "bond_gaussian.h" -#include -#include #include "atom.h" -#include "neighbor.h" #include "comm.h" +#include "error.h" #include "force.h" #include "math_const.h" #include "memory.h" -#include "error.h" +#include "neighbor.h" +#include +#include using namespace LAMMPS_NS; using namespace MathConst; @@ -32,9 +31,9 @@ using namespace MathConst; /* ---------------------------------------------------------------------- */ -BondGaussian::BondGaussian(LAMMPS *lmp) - : Bond(lmp), nterms(nullptr), bond_temperature(nullptr), - alpha(nullptr), width(nullptr), r0(nullptr) +BondGaussian::BondGaussian(LAMMPS *lmp) : + Bond(lmp), nterms(nullptr), bond_temperature(nullptr), alpha(nullptr), width(nullptr), + r0(nullptr) { reinitflag = 1; } @@ -48,13 +47,13 @@ BondGaussian::~BondGaussian() memory->destroy(nterms); memory->destroy(bond_temperature); for (int i = 1; i <= atom->nbondtypes; i++) { - delete [] alpha[i]; - delete [] width[i]; - delete [] r0[i]; + delete[] alpha[i]; + delete[] width[i]; + delete[] r0[i]; } - delete [] alpha; - delete [] width; - delete [] r0; + delete[] alpha; + delete[] width; + delete[] r0; } } @@ -62,13 +61,13 @@ BondGaussian::~BondGaussian() void BondGaussian::compute(int eflag, int vflag) { - int i1,i2,n,type; - double delx,dely,delz,ebond,fbond; - double rsq,r,dr; + int i1, i2, n, type; + double delx, dely, delz, ebond, fbond; + double rsq, r, dr; double prefactor, exponent, g_i, sum_g_i, sum_numerator; ebond = 0.0; - ev_init(eflag,vflag); + ev_init(eflag, vflag); double **x = atom->x; double **f = atom->f; @@ -86,43 +85,45 @@ void BondGaussian::compute(int eflag, int vflag) dely = x[i1][1] - x[i2][1]; delz = x[i1][2] - x[i2][2]; - rsq = delx*delx + dely*dely + delz*delz; + rsq = delx * delx + dely * dely + delz * delz; r = sqrt(rsq); sum_g_i = 0.0; sum_numerator = 0.0; for (int i = 0; i < nterms[type]; i++) { dr = r - r0[type][i]; - prefactor = (alpha[type][i]/(width[type][i]*sqrt(MY_PI2))); - exponent = -2*dr*dr/(width[type][i]*width[type][i]); - g_i = prefactor*exp(exponent); + prefactor = (alpha[type][i] / (width[type][i] * sqrt(MY_PI2))); + exponent = -2 * dr * dr / (width[type][i] * width[type][i]); + g_i = prefactor * exp(exponent); sum_g_i += g_i; - sum_numerator += g_i*dr/(width[type][i]*width[type][i]); + sum_numerator += g_i * dr / (width[type][i] * width[type][i]); } // force & energy if (sum_g_i < SMALL) sum_g_i = SMALL; - if (r > 0.0) fbond = -4.0*(force->boltz*bond_temperature[type])*(sum_numerator/sum_g_i)/r; - else fbond = 0.0; + if (r > 0.0) + fbond = -4.0 * (force->boltz * bond_temperature[type]) * (sum_numerator / sum_g_i) / r; + else + fbond = 0.0; - if (eflag) ebond = -(force->boltz*bond_temperature[type])*log(sum_g_i); + if (eflag) ebond = -(force->boltz * bond_temperature[type]) * log(sum_g_i); // apply force to each of 2 atoms if (newton_bond || i1 < nlocal) { - f[i1][0] += delx*fbond; - f[i1][1] += dely*fbond; - f[i1][2] += delz*fbond; + f[i1][0] += delx * fbond; + f[i1][1] += dely * fbond; + f[i1][2] += delz * fbond; } if (newton_bond || i2 < nlocal) { - f[i2][0] -= delx*fbond; - f[i2][1] -= dely*fbond; - f[i2][2] -= delz*fbond; + f[i2][0] -= delx * fbond; + f[i2][1] -= dely * fbond; + f[i2][2] -= delz * fbond; } - if (evflag) ev_tally(i1,i2,nlocal,newton_bond,ebond,fbond,delx,dely,delz); + if (evflag) ev_tally(i1, i2, nlocal, newton_bond, ebond, fbond, delx, dely, delz); } } @@ -131,20 +132,20 @@ void BondGaussian::compute(int eflag, int vflag) void BondGaussian::allocate() { allocated = 1; - int n = atom->nbondtypes; + int n = atom->nbondtypes + 1; - memory->create(nterms,n+1,"bond:nterms"); - memory->create(bond_temperature,n+1,"bond:bond_temperature"); + memory->create(nterms, n, "bond:nterms"); + memory->create(bond_temperature, n, "bond:bond_temperature"); - alpha = new double *[n+1]; - width = new double *[n+1]; - r0 = new double *[n+1]; - memset(alpha,0,sizeof(double)*(n+1)); - memset(width,0,sizeof(double)*(n+1)); - memset(r0,0,sizeof(double)*(n+1)); + alpha = new double *[n]; + width = new double *[n]; + r0 = new double *[n]; + memset(alpha, 0, sizeof(double *) * n); + memset(width, 0, sizeof(double *) * n); + memset(r0, 0, sizeof(double *) * n); - memory->create(setflag,n+1,"bond:setflag"); - for (int i = 1; i <= n; i++) setflag[i] = 0; + memory->create(setflag, n, "bond:setflag"); + memset(setflag, 0, sizeof(int) * n); } /* ---------------------------------------------------------------------- @@ -153,15 +154,14 @@ void BondGaussian::allocate() void BondGaussian::coeff(int narg, char **arg) { - if (narg < 6) error->all(FLERR,"Incorrect args for bond coefficients"); + if (narg < 6) error->all(FLERR, "Incorrect args for bond coefficients"); - int ilo,ihi; - utils::bounds(FLERR,arg[0],1,atom->nbondtypes,ilo,ihi,error); + int ilo, ihi; + utils::bounds(FLERR, arg[0], 1, atom->nbondtypes, ilo, ihi, error); - double bond_temp_one = utils::numeric(FLERR,arg[1],false,lmp); - int n = utils::inumeric(FLERR,arg[2],false,lmp); - if (narg != 3*n + 3) - error->all(FLERR,"Incorrect args for bond coefficients"); + double bond_temp_one = utils::numeric(FLERR, arg[1], false, lmp); + int n = utils::inumeric(FLERR, arg[2], false, lmp); + if (narg != 3 * n + 3) error->all(FLERR, "Incorrect args for bond coefficients"); if (!allocated) allocate(); @@ -170,21 +170,21 @@ void BondGaussian::coeff(int narg, char **arg) bond_temperature[i] = bond_temp_one; nterms[i] = n; delete[] alpha[i]; - alpha[i] = new double [n]; + alpha[i] = new double[n]; delete[] width[i]; - width[i] = new double [n]; + width[i] = new double[n]; delete[] r0[i]; - r0[i] = new double [n]; + r0[i] = new double[n]; for (int j = 0; j < n; j++) { - alpha[i][j] = utils::numeric(FLERR,arg[3+3*j],false,lmp); - width[i][j] = utils::numeric(FLERR,arg[4+3*j],false,lmp); - r0[i][j] = utils::numeric(FLERR,arg[5+3*j],false,lmp); + alpha[i][j] = utils::numeric(FLERR, arg[3 + 3 * j], false, lmp); + width[i][j] = utils::numeric(FLERR, arg[4 + 3 * j], false, lmp); + r0[i][j] = utils::numeric(FLERR, arg[5 + 3 * j], false, lmp); setflag[i] = 1; } count++; } - if (count == 0) error->all(FLERR,"Incorrect args for bond coefficients"); + if (count == 0) error->all(FLERR, "Incorrect args for bond coefficients"); } /* ---------------------------------------------------------------------- @@ -202,12 +202,12 @@ double BondGaussian::equilibrium_distance(int i) void BondGaussian::write_restart(FILE *fp) { - fwrite(&bond_temperature[1],sizeof(double),atom->nbondtypes,fp); - fwrite(&nterms[1],sizeof(int),atom->nbondtypes,fp); + fwrite(&bond_temperature[1], sizeof(double), atom->nbondtypes, fp); + fwrite(&nterms[1], sizeof(int), atom->nbondtypes, fp); for (int i = 1; i <= atom->nbondtypes; i++) { - fwrite(alpha[i],sizeof(double),nterms[i],fp); - fwrite(width[i],sizeof(double),nterms[i],fp); - fwrite(r0[i],sizeof(double),nterms[i],fp); + fwrite(alpha[i], sizeof(double), nterms[i], fp); + fwrite(width[i], sizeof(double), nterms[i], fp); + fwrite(r0[i], sizeof(double), nterms[i], fp); } } @@ -220,31 +220,32 @@ void BondGaussian::read_restart(FILE *fp) allocate(); if (comm->me == 0) { - utils::sfread(FLERR,&bond_temperature[1],sizeof(double),atom->nbondtypes,fp,nullptr,error); - utils::sfread(FLERR,&nterms[1],sizeof(int),atom->nbondtypes,fp,nullptr,error); + utils::sfread(FLERR, &bond_temperature[1], sizeof(double), atom->nbondtypes, fp, nullptr, + error); + utils::sfread(FLERR, &nterms[1], sizeof(int), atom->nbondtypes, fp, nullptr, error); } - MPI_Bcast(&bond_temperature[1],atom->nbondtypes,MPI_DOUBLE,0,world); - MPI_Bcast(&nterms[1],atom->nbondtypes,MPI_INT,0,world); + MPI_Bcast(&bond_temperature[1], atom->nbondtypes, MPI_DOUBLE, 0, world); + MPI_Bcast(&nterms[1], atom->nbondtypes, MPI_INT, 0, world); // allocate for (int i = 1; i <= atom->nbondtypes; i++) { - alpha[i] = new double [nterms[i]]; - width[i] = new double [nterms[i]]; - r0[i] = new double [nterms[i]]; + alpha[i] = new double[nterms[i]]; + width[i] = new double[nterms[i]]; + r0[i] = new double[nterms[i]]; } if (comm->me == 0) { for (int i = 1; i <= atom->nbondtypes; i++) { - utils::sfread(FLERR,alpha[i],sizeof(double),nterms[i],fp,nullptr,error); - utils::sfread(FLERR,width[i],sizeof(double),nterms[i],fp,nullptr,error); - utils::sfread(FLERR,r0[i],sizeof(double),nterms[i],fp,nullptr,error); + utils::sfread(FLERR, alpha[i], sizeof(double), nterms[i], fp, nullptr, error); + utils::sfread(FLERR, width[i], sizeof(double), nterms[i], fp, nullptr, error); + utils::sfread(FLERR, r0[i], sizeof(double), nterms[i], fp, nullptr, error); } } for (int i = 1; i <= atom->nbondtypes; i++) { - MPI_Bcast(alpha[i],nterms[i],MPI_DOUBLE,0,world); - MPI_Bcast(width[i],nterms[i],MPI_DOUBLE,0,world); - MPI_Bcast(r0[i],nterms[i],MPI_DOUBLE,0,world); + MPI_Bcast(alpha[i], nterms[i], MPI_DOUBLE, 0, world); + MPI_Bcast(width[i], nterms[i], MPI_DOUBLE, 0, world); + MPI_Bcast(r0[i], nterms[i], MPI_DOUBLE, 0, world); } for (int i = 1; i <= atom->nbondtypes; i++) setflag[i] = 1; @@ -257,9 +258,9 @@ void BondGaussian::read_restart(FILE *fp) void BondGaussian::write_data(FILE *fp) { for (int i = 1; i <= atom->nbondtypes; i++) { - fprintf(fp,"%d %g %d",i,bond_temperature[i],nterms[i]); + fprintf(fp, "%d %g %d", i, bond_temperature[i], nterms[i]); for (int j = 0; j < nterms[i]; j++) { - fprintf(fp," %g %g %g",alpha[i][j],width[i][j],r0[i][j]); + fprintf(fp, " %g %g %g", alpha[i][j], width[i][j], r0[i][j]); } fprintf(fp, "\n"); } @@ -267,26 +268,25 @@ void BondGaussian::write_data(FILE *fp) /* ---------------------------------------------------------------------- */ -double BondGaussian::single(int type, double rsq, int /*i*/, int /*j*/, - double &fforce) +double BondGaussian::single(int type, double rsq, int /*i*/, int /*j*/, double &fforce) { double r = sqrt(rsq); fforce = 0; double sum_g_i = 0.0; double sum_numerator = 0.0; - for (int i = 0; i < nterms[type]; i++) { - double dr = r - r0[type][i]; - double prefactor = (alpha[type][i]/(width[type][i]*sqrt(MY_PI2))); - double exponent = -2*dr*dr/(width[type][i]*width[type][i]); - double g_i = prefactor*exp(exponent); - sum_g_i += g_i; - sum_numerator += g_i*dr/(width[type][i]*width[type][i]); - } + for (int i = 0; i < nterms[type]; i++) { + double dr = r - r0[type][i]; + double prefactor = (alpha[type][i] / (width[type][i] * sqrt(MY_PI2))); + double exponent = -2 * dr * dr / (width[type][i] * width[type][i]); + double g_i = prefactor * exp(exponent); + sum_g_i += g_i; + sum_numerator += g_i * dr / (width[type][i] * width[type][i]); + } if (sum_g_i < SMALL) sum_g_i = SMALL; - if (r > 0.0) fforce = -4.0*(force->boltz*bond_temperature[type])*(sum_numerator/sum_g_i)/r; + if (r > 0.0) + fforce = -4.0 * (force->boltz * bond_temperature[type]) * (sum_numerator / sum_g_i) / r; - return -(force->boltz*bond_temperature[type])*log(sum_g_i); + return -(force->boltz * bond_temperature[type]) * log(sum_g_i); } - diff --git a/src/EXTRA-PAIR/pair_coul_exclude.cpp b/src/EXTRA-PAIR/pair_coul_exclude.cpp index 404fc9c784..74890bcf08 100644 --- a/src/EXTRA-PAIR/pair_coul_exclude.cpp +++ b/src/EXTRA-PAIR/pair_coul_exclude.cpp @@ -189,7 +189,7 @@ void PairCoulExclude::init_style() init for one type pair i,j and corresponding j,i ------------------------------------------------------------------------- */ -double PairCoulExclude::init_one(int i, int j) +double PairCoulExclude::init_one(int /*i*/, int /*j*/) { return cut_global; } diff --git a/src/FEP/compute_fep.cpp b/src/FEP/compute_fep.cpp index 683fbe114a..787c8a29e6 100644 --- a/src/FEP/compute_fep.cpp +++ b/src/FEP/compute_fep.cpp @@ -124,18 +124,12 @@ ComputeFEP::ComputeFEP(LAMMPS *lmp, int narg, char **arg) : while (iarg < narg) { if (strcmp(arg[iarg],"tail") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal optional keyword " - "in compute fep"); - if (strcmp(arg[iarg+1],"no") == 0) tailflag = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) tailflag = 1; - else error->all(FLERR,"Illegal optional keyword in compute fep"); + if (iarg+2 > narg) error->all(FLERR,"Illegal optional keyword in compute fep"); + tailflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"volume") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal optional keyword " - "in compute fep"); - if (strcmp(arg[iarg+1],"no") == 0) volumeflag = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) volumeflag = 1; - else error->all(FLERR,"Illegal optional keyword in compute fep"); + if (iarg+2 > narg) error->all(FLERR,"Illegal optional keyword in compute fep"); + volumeflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else error->all(FLERR,"Illegal optional keyword in compute fep"); diff --git a/src/FEP/fix_adapt_fep.cpp b/src/FEP/fix_adapt_fep.cpp index a6891c8742..d43c053b9a 100644 --- a/src/FEP/fix_adapt_fep.cpp +++ b/src/FEP/fix_adapt_fep.cpp @@ -138,21 +138,15 @@ FixAdaptFEP::FixAdaptFEP(LAMMPS *lmp, int narg, char **arg) : while (iarg < narg) { if (strcmp(arg[iarg],"reset") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix adapt/fep command"); - if (strcmp(arg[iarg+1],"no") == 0) resetflag = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) resetflag = 1; - else error->all(FLERR,"Illegal fix adapt/fep command"); + resetflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"scale") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix adapt/fep command"); - if (strcmp(arg[iarg+1],"no") == 0) scaleflag = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) scaleflag = 1; - else error->all(FLERR,"Illegal fix adapt/fep command"); + scaleflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"after") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix adapt/fep command"); - if (strcmp(arg[iarg+1],"no") == 0) afterflag = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) afterflag = 1; - else error->all(FLERR,"Illegal fix adapt/fep command"); + afterflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else error->all(FLERR,"Illegal fix adapt/fep command"); } diff --git a/src/GPU/fix_gpu.cpp b/src/GPU/fix_gpu.cpp index d26493e57b..7180a04873 100644 --- a/src/GPU/fix_gpu.cpp +++ b/src/GPU/fix_gpu.cpp @@ -136,16 +136,17 @@ FixGPU::FixGPU(LAMMPS *lmp, int narg, char **arg) : while (iarg < narg) { if (strcmp(arg[iarg],"neigh") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal package gpu command"); - if (strcmp(arg[iarg+1],"yes") == 0) _gpu_mode = GPU_NEIGH; - else if (strcmp(arg[iarg+1],"no") == 0) _gpu_mode = GPU_FORCE; - else if (strcmp(arg[iarg+1],"hybrid") == 0) _gpu_mode = GPU_HYB_NEIGH; + const std::string modearg = arg[iarg+1]; + if ((modearg == "yes") || (modearg == "on") || (modearg == "true")) + _gpu_mode = GPU_NEIGH; + else if ((modearg == "no") || (modearg == "off") || (modearg == "false")) + _gpu_mode = GPU_FORCE; + else if (modearg == "hybrid") _gpu_mode = GPU_HYB_NEIGH; else error->all(FLERR,"Illegal package gpu command"); iarg += 2; } else if (strcmp(arg[iarg],"newton") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal package gpu command"); - if (strcmp(arg[iarg+1],"off") == 0) newtonflag = 0; - else if (strcmp(arg[iarg+1],"on") == 0) newtonflag = 1; - else error->all(FLERR,"Illegal package gpu command"); + newtonflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"binsize") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal package gpu command"); @@ -185,9 +186,7 @@ FixGPU::FixGPU(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else if (strcmp(arg[iarg],"pair/only") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal package gpu command"); - if (strcmp(arg[iarg+1],"off") == 0) pair_only_flag = 0; - else if (strcmp(arg[iarg+1],"on") == 0) pair_only_flag = 1; - else error->all(FLERR,"Illegal package gpu command"); + pair_only_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"ocl_args") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal package gpu command"); diff --git a/src/H5MD/dump_h5md.cpp b/src/H5MD/dump_h5md.cpp index 3e19772bc8..bc9c98caa0 100644 --- a/src/H5MD/dump_h5md.cpp +++ b/src/H5MD/dump_h5md.cpp @@ -153,25 +153,14 @@ DumpH5MD::DumpH5MD(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg) error->all(FLERR, "Invalid number of arguments in dump h5md"); } box_is_set = true; - if (strcmp(arg[iarg+1], "yes")==0) - do_box=true; - else if (strcmp(arg[iarg+1], "no")==0) - do_box=false; - else - error->all(FLERR, "Illegal dump h5md command"); + do_box = utils::logical(FLERR,arg[iarg+1],false,lmp) == 1; iarg+=2; } else if (strcmp(arg[iarg], "create_group")==0) { if (iarg+1>=narg) { error->all(FLERR, "Invalid number of arguments in dump h5md"); } create_group_is_set = true; - if (strcmp(arg[iarg+1], "yes")==0) - create_group=true; - else if (strcmp(arg[iarg+1], "no")==0) { - create_group=false; - } - else - error->all(FLERR, "Illegal dump h5md command"); + create_group = utils::logical(FLERR,arg[iarg+1],false,lmp) == 1; iarg+=2; } else if (strcmp(arg[iarg], "author")==0) { if (iarg+1>=narg) { @@ -471,9 +460,7 @@ int DumpH5MD::modify_param(int narg, char **arg) { if (strcmp(arg[0],"unwrap") == 0) { if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); - if (strcmp(arg[1],"yes") == 0) unwrap_flag = 1; - else if (strcmp(arg[1],"no") == 0) unwrap_flag = 0; - else error->all(FLERR,"Illegal dump_modify command"); + unwrap_flag = utils::logical(FLERR, arg[1], false, lmp); return 2; } return 0; diff --git a/src/INTEL/fix_intel.cpp b/src/INTEL/fix_intel.cpp index d0633d7791..de17c02864 100644 --- a/src/INTEL/fix_intel.cpp +++ b/src/INTEL/fix_intel.cpp @@ -118,9 +118,7 @@ FixIntel::FixIntel(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) iarg += 2; } else if (strcmp(arg[iarg], "ghost") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal package intel command"); - if (strcmp(arg[iarg+1],"yes") == 0) _offload_ghost = 1; - else if (strcmp(arg[iarg+1],"no") == 0) _offload_ghost = 0; - else error->all(FLERR,"Illegal package intel command"); + _offload_ghost = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg], "tpc") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal package intel command"); @@ -135,9 +133,7 @@ FixIntel::FixIntel(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) iarg++; } else if (strcmp(arg[iarg], "lrt") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal package intel command"); - if (strcmp(arg[iarg+1],"yes") == 0) _lrt = 1; - else if (strcmp(arg[iarg+1],"no") == 0) _lrt = 0; - else error->all(FLERR,"Illegal package intel command"); + _lrt = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } diff --git a/src/INTERLAYER/pair_drip.cpp b/src/INTERLAYER/pair_drip.cpp index e9d32bdb8b..b9a4d1f05b 100644 --- a/src/INTERLAYER/pair_drip.cpp +++ b/src/INTERLAYER/pair_drip.cpp @@ -31,7 +31,6 @@ #include "neigh_request.h" #include "neighbor.h" #include "potential_file_reader.h" -#include "tokenizer.h" #include #include @@ -241,17 +240,17 @@ void PairDRIP::read_file(char *filename) nparams++; } - - MPI_Bcast(&nparams, 1, MPI_INT, 0, world); - MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); - - if (comm->me != 0) { - params = (Param *) memory->srealloc(params, maxparam * sizeof(Param), "pair:params"); - } - - MPI_Bcast(params, maxparam * sizeof(Param), MPI_BYTE, 0, world); } + MPI_Bcast(&nparams, 1, MPI_INT, 0, world); + MPI_Bcast(&maxparam, 1, MPI_INT, 0, world); + + if (comm->me != 0) { + params = (Param *) memory->srealloc(params, maxparam * sizeof(Param), "pair:params"); + } + + MPI_Bcast(params, maxparam * sizeof(Param), MPI_BYTE, 0, world); + memory->destroy(elem2param); memory->create(elem2param, nelements, nelements, "pair:elem2param"); for (int i = 0; i < nelements; i++) { diff --git a/src/KOKKOS/kokkos.cpp b/src/KOKKOS/kokkos.cpp index aa435d5b0b..be32604f94 100644 --- a/src/KOKKOS/kokkos.cpp +++ b/src/KOKKOS/kokkos.cpp @@ -381,9 +381,7 @@ void KokkosLMP::accelerator(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg],"newton") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command"); - if (strcmp(arg[iarg+1],"off") == 0) newtonflag = 0; - else if (strcmp(arg[iarg+1],"on") == 0) newtonflag = 1; - else error->all(FLERR,"Illegal package kokkos command"); + newtonflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"comm") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command"); @@ -459,21 +457,15 @@ void KokkosLMP::accelerator(int narg, char **arg) } else if ((strcmp(arg[iarg],"gpu/aware") == 0) || (strcmp(arg[iarg],"cuda/aware") == 0)) { if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command"); - if (strcmp(arg[iarg+1],"off") == 0) gpu_aware_flag = 0; - else if (strcmp(arg[iarg+1],"on") == 0) gpu_aware_flag = 1; - else error->all(FLERR,"Illegal package kokkos command"); + gpu_aware_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"pair/only") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command"); - if (strcmp(arg[iarg+1],"off") == 0) pair_only_flag = 0; - else if (strcmp(arg[iarg+1],"on") == 0) pair_only_flag = 1; - else error->all(FLERR,"Illegal package kokkos command"); + pair_only_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"neigh/thread") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command"); - if (strcmp(arg[iarg+1],"off") == 0) neigh_thread = 0; - else if (strcmp(arg[iarg+1],"on") == 0) neigh_thread = 1; - else error->all(FLERR,"Illegal package kokkos command"); + neigh_thread = utils::logical(FLERR,arg[iarg+1],false,lmp); neigh_thread_set = 1; iarg += 2; } else error->all(FLERR,"Illegal package kokkos command"); diff --git a/src/KOKKOS/kokkos_type.h b/src/KOKKOS/kokkos_type.h index 05c839db3f..cd829ec3e4 100644 --- a/src/KOKKOS/kokkos_type.h +++ b/src/KOKKOS/kokkos_type.h @@ -25,7 +25,9 @@ #include #include -enum{FULL=1u,HALFTHREAD=2u,HALF=4u}; +constexpr int FULL = 1; +constexpr int HALFTHREAD = 2; +constexpr int HALF = 4; #if defined(KOKKOS_ENABLE_CXX11) #undef ISFINITE diff --git a/src/LATBOLTZ/fix_lb_rigid_pc_sphere.cpp b/src/LATBOLTZ/fix_lb_rigid_pc_sphere.cpp index 9db1c2acec..304d5bbf0f 100644 --- a/src/LATBOLTZ/fix_lb_rigid_pc_sphere.cpp +++ b/src/LATBOLTZ/fix_lb_rigid_pc_sphere.cpp @@ -19,19 +19,19 @@ #include "fix_lb_rigid_pc_sphere.h" -#include - -#include #include "atom.h" -#include "domain.h" -#include "update.h" -#include "modify.h" -#include "group.h" #include "comm.h" -#include "force.h" -#include "memory.h" +#include "domain.h" #include "error.h" #include "fix_lb_fluid.h" +#include "force.h" +#include "group.h" +#include "memory.h" +#include "modify.h" +#include "update.h" + +#include +#include using namespace LAMMPS_NS; using namespace FixConst; @@ -237,15 +237,9 @@ FixLbRigidPCSphere::FixLbRigidPCSphere(LAMMPS *lmp, int narg, char **arg) : utils::bounds(FLERR,arg[iarg+1],1,nbody,mlo,mhi,error); double xflag,yflag,zflag; - if (strcmp(arg[iarg+2],"off") == 0) xflag = 0.0; - else if (strcmp(arg[iarg+2],"on") == 0) xflag = 1.0; - else error->all(FLERR,"Illegal fix lb/rigid/pc/sphere command"); - if (strcmp(arg[iarg+2],"off") == 0) yflag = 0.0; - else if (strcmp(arg[iarg+3],"on") == 0) yflag = 1.0; - else error->all(FLERR,"Illegal fix lb/rigid/pc/sphere command"); - if (strcmp(arg[iarg+4],"off") == 0) zflag = 0.0; - else if (strcmp(arg[iarg+4],"on") == 0) zflag = 1.0; - else error->all(FLERR,"Illegal fix lb/rigid/pc/sphere command"); + xflag = (double) utils::logical(FLERR, arg[iarg+2], false, lmp); + yflag = (double) utils::logical(FLERR, arg[iarg+3], false, lmp); + zflag = (double) utils::logical(FLERR, arg[iarg+4], false, lmp); int count = 0; for (int m = mlo; m <= mhi; m++) { @@ -263,16 +257,9 @@ FixLbRigidPCSphere::FixLbRigidPCSphere(LAMMPS *lmp, int narg, char **arg) : int mlo,mhi; utils::bounds(FLERR,arg[iarg+1],1,nbody,mlo,mhi,error); - double xflag,yflag,zflag; - if (strcmp(arg[iarg+2],"off") == 0) xflag = 0.0; - else if (strcmp(arg[iarg+2],"on") == 0) xflag = 1.0; - else error->all(FLERR,"Illegal fix lb/rigid/pc/sphere command"); - if (strcmp(arg[iarg+3],"off") == 0) yflag = 0.0; - else if (strcmp(arg[iarg+3],"on") == 0) yflag = 1.0; - else error->all(FLERR,"Illegal fix lb/rigid/pc/sphere command"); - if (strcmp(arg[iarg+4],"off") == 0) zflag = 0.0; - else if (strcmp(arg[iarg+4],"on") == 0) zflag = 1.0; - else error->all(FLERR,"Illegal fix lb/rigid/pc/sphere command"); + const double xflag = (double) utils::logical(FLERR,arg[iarg+2],false,lmp); + const double yflag = (double) utils::logical(FLERR,arg[iarg+3],false,lmp); + const double zflag = (double) utils::logical(FLERR,arg[iarg+4],false,lmp); int count = 0; for (int m = mlo; m <= mhi; m++) { diff --git a/src/MC/fix_atom_swap.cpp b/src/MC/fix_atom_swap.cpp index 84c060a557..76200dc614 100644 --- a/src/MC/fix_atom_swap.cpp +++ b/src/MC/fix_atom_swap.cpp @@ -160,15 +160,11 @@ void FixAtomSwap::options(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg],"ke") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix atom/swap command"); - if (strcmp(arg[iarg+1],"no") == 0) conserve_ke_flag = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) conserve_ke_flag = 1; - else error->all(FLERR,"Illegal fix atom/swap command"); + conserve_ke_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"semi-grand") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix atom/swap command"); - if (strcmp(arg[iarg+1],"no") == 0) semi_grand_flag = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) semi_grand_flag = 1; - else error->all(FLERR,"Illegal fix atom/swap command"); + semi_grand_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"types") == 0) { if (iarg+3 > narg) error->all(FLERR,"Illegal fix atom/swap command"); diff --git a/src/MC/fix_charge_regulation.cpp b/src/MC/fix_charge_regulation.cpp index 2497b3d976..078e7eb9db 100644 --- a/src/MC/fix_charge_regulation.cpp +++ b/src/MC/fix_charge_regulation.cpp @@ -1180,8 +1180,8 @@ void FixChargeRegulation::setThermoTemperaturePointer() { int ifix = -1; ifix = modify->find_fix(idftemp); if (ifix == -1) { - error->all(FLERR, - "fix charge/regulation regulation could not find a temperature fix id provided by tempfixid\n"); + error->all(FLERR, "fix charge/regulation regulation could not find " + "a temperature fix id provided by tempfixid\n"); } Fix *temperature_fix = modify->fix[ifix]; int dim; @@ -1198,8 +1198,7 @@ void FixChargeRegulation::assign_tags() { for (int i = 0; i < atom->nlocal; i++) maxtag = MAX(maxtag, tag[i]); maxtag_all = maxtag; MPI_Allreduce(&maxtag, &maxtag_all, 1, MPI_LMP_TAGINT, MPI_MAX, world); - if (maxtag_all >= MAXTAGINT) - error->all(FLERR, "New atom IDs exceed maximum allowed ID"); + if (maxtag_all >= MAXTAGINT) error->all(FLERR, "New atom IDs exceed maximum allowed ID"); tagint notag = 0; tagint notag_all; @@ -1267,23 +1266,19 @@ void FixChargeRegulation::options(int narg, char **arg) { while (iarg < narg) { if (strcmp(arg[iarg], "lunit_nm") == 0) { - if (iarg + 2 > narg) - error->all(FLERR, "Illegal fix charge/regulation command"); + if (iarg + 2 > narg) error->all(FLERR, "Illegal fix charge/regulation command"); llength_unit_in_nm = utils::numeric(FLERR, arg[iarg + 1], false, lmp); iarg += 2; } else if (strcmp(arg[iarg], "acid_type") == 0) { - if (iarg + 2 > narg) - error->all(FLERR, "Illegal fix charge/regulation command"); + if (iarg + 2 > narg) error->all(FLERR, "Illegal fix charge/regulation command"); acid_type = utils::inumeric(FLERR, arg[iarg + 1], false, lmp); iarg += 2; } else if (strcmp(arg[iarg], "base_type") == 0) { - if (iarg + 2 > narg) - error->all(FLERR, "Illegal fix charge/regulation command"); + if (iarg + 2 > narg) error->all(FLERR, "Illegal fix charge/regulation command"); base_type = utils::inumeric(FLERR, arg[iarg + 1], false, lmp); iarg += 2; } else if (strcmp(arg[iarg], "pH") == 0) { - if (iarg + 2 > narg) - error->all(FLERR, "Illegal fix charge/regulation command"); + if (iarg + 2 > narg) error->all(FLERR, "Illegal fix charge/regulation command"); if (strstr(arg[iarg + 1],"v_") == arg[iarg + 1]) { pHstr = utils::strdup(&arg[iarg + 1][2]); } else { @@ -1292,45 +1287,37 @@ void FixChargeRegulation::options(int narg, char **arg) { } iarg += 2; } else if (strcmp(arg[iarg], "pIp") == 0) { - if (iarg + 2 > narg) - error->all(FLERR, "Illegal fix charge/regulation command"); + if (iarg + 2 > narg) error->all(FLERR, "Illegal fix charge/regulation command"); pI_plus = utils::numeric(FLERR, arg[iarg + 1], false, lmp); iarg += 2; } else if (strcmp(arg[iarg], "pIm") == 0) { - if (iarg + 2 > narg) - error->all(FLERR, "Illegal fix charge/regulation command"); + if (iarg + 2 > narg) error->all(FLERR, "Illegal fix charge/regulation command"); pI_minus = utils::numeric(FLERR, arg[iarg + 1], false, lmp); iarg += 2; } else if (strcmp(arg[iarg], "pKa") == 0) { - if (iarg + 2 > narg) - error->all(FLERR, "Illegal fix charge/regulation command"); + if (iarg + 2 > narg) error->all(FLERR, "Illegal fix charge/regulation command"); pKa = utils::numeric(FLERR, arg[iarg + 1], false, lmp); iarg += 2; } else if (strcmp(arg[iarg], "pKb") == 0) { - if (iarg + 2 > narg) - error->all(FLERR, "Illegal fix charge/regulation command"); + if (iarg + 2 > narg) error->all(FLERR, "Illegal fix charge/regulation command"); pKb = utils::numeric(FLERR, arg[iarg + 1], false, lmp); iarg += 2; } else if (strcmp(arg[iarg], "temp") == 0) { - if (iarg + 2 > narg) - error->all(FLERR, "Illegal fix charge/regulation command"); + if (iarg + 2 > narg) error->all(FLERR, "Illegal fix charge/regulation command"); reservoir_temperature = utils::numeric(FLERR, arg[iarg + 1], false, lmp); iarg += 2; } else if (strcmp(arg[iarg], "pKs") == 0) { - if (iarg + 2 > narg) - error->all(FLERR, "Illegal fix charge/regulation command"); + if (iarg + 2 > narg) error->all(FLERR, "Illegal fix charge/regulation command"); pKs = utils::numeric(FLERR, arg[iarg + 1], false, lmp); iarg += 2; } else if (strcmp(arg[iarg], "tempfixid") == 0) { - if (iarg + 2 > narg) - error->all(FLERR, "Illegal fix charge/regulation command"); + if (iarg + 2 > narg) error->all(FLERR, "Illegal fix charge/regulation command"); idftemp = utils::strdup(arg[iarg+1]); setThermoTemperaturePointer(); iarg += 2; } else if (strcmp(arg[iarg], "rxd") == 0) { - if (iarg + 2 > narg) - error->all(FLERR, "Illegal fix charge/regulation command"); + if (iarg + 2 > narg) error->all(FLERR, "Illegal fix charge/regulation command"); reaction_distance = utils::numeric(FLERR, arg[iarg + 1], false, lmp); if ((reaction_distance > domain->prd_half[0]) || (reaction_distance > domain->prd_half[1]) || @@ -1342,61 +1329,44 @@ void FixChargeRegulation::options(int narg, char **arg) { } iarg += 2; } else if (strcmp(arg[iarg], "nevery") == 0) { - if (iarg + 2 > narg) - error->all(FLERR, "Illegal fix charge/regulation command"); + if (iarg + 2 > narg) error->all(FLERR, "Illegal fix charge/regulation command"); nevery = utils::inumeric(FLERR, arg[iarg + 1], false, lmp); iarg += 2; } else if (strcmp(arg[iarg], "nmc") == 0) { - if (iarg + 2 > narg) - error->all(FLERR, "Illegal fix charge/regulation command"); + if (iarg + 2 > narg) error->all(FLERR, "Illegal fix charge/regulation command"); nmc = utils::inumeric(FLERR, arg[iarg + 1], false, lmp); iarg += 2; } else if (strcmp(arg[iarg], "pmcmoves") == 0) { - if (iarg + 4 > narg) - error->all(FLERR, "Illegal fix charge/regulation command"); + if (iarg + 4 > narg) error->all(FLERR, "Illegal fix charge/regulation command"); pmcmoves[0] = utils::numeric(FLERR, arg[iarg + 1], false, lmp); pmcmoves[1] = utils::numeric(FLERR, arg[iarg + 2], false, lmp); pmcmoves[2] = utils::numeric(FLERR, arg[iarg + 3], false, lmp); iarg += 4; } else if (strcmp(arg[iarg], "seed") == 0) { - if (iarg + 2 > narg) - error->all(FLERR, "Illegal fix charge/regulation command"); + if (iarg + 2 > narg) error->all(FLERR, "Illegal fix charge/regulation command"); seed = utils::inumeric(FLERR, arg[iarg + 1], false, lmp); iarg += 2; } else if (strcmp(arg[iarg], "tag") == 0) { - if (iarg + 2 > narg) - error->all(FLERR, "Illegal fix charge/regulation command"); - if (strcmp(arg[iarg + 1], "yes") == 0) { - add_tags_flag = true; - } else if (strcmp(arg[iarg + 1], "no") == 0) { - add_tags_flag = false; - } else error->all(FLERR, "Illegal fix charge/regulation command"); + if (iarg + 2 > narg) error->all(FLERR, "Illegal fix charge/regulation command"); + add_tags_flag = utils::logical(FLERR,arg[iarg+1],false,lmp) == 1; iarg += 2; } else if (strcmp(arg[iarg], "onlysalt") == 0) { - if (iarg + 2 > narg) - error->all(FLERR, "Illegal fix charge/regulation command"); - if (strcmp(arg[iarg + 1], "yes") == 0) { - only_salt_flag = true; + if (iarg + 2 > narg) error->all(FLERR, "Illegal fix charge/regulation command"); + only_salt_flag = utils::logical(FLERR,arg[iarg+1],false,lmp) == 1; + iarg += 2; + if (only_salt_flag) { // need to specify salt charge - if (iarg + 4 > narg) - error->all(FLERR, "Illegal fix charge/regulation command"); - salt_charge[0] = utils::inumeric(FLERR, arg[iarg + 2], false, lmp); - salt_charge[1] = utils::inumeric(FLERR, arg[iarg + 3], false, lmp); - iarg += 4; - } else if (strcmp(arg[iarg + 1], "no") == 0) { - only_salt_flag = false; + if (iarg + 2 > narg) error->all(FLERR, "Illegal fix charge/regulation command"); + salt_charge[0] = utils::inumeric(FLERR, arg[iarg], false, lmp); + salt_charge[1] = utils::inumeric(FLERR, arg[iarg + 1], false, lmp); iarg += 2; - } else error->all(FLERR, "Illegal fix charge/regulation command"); - + } } else if (strcmp(arg[iarg], "group") == 0) { - if (iarg + 2 > narg) - error->all(FLERR, "Illegal fix fix charge/regulation command"); + if (iarg + 2 > narg) error->all(FLERR, "Illegal fix fix charge/regulation command"); if (ngroups >= ngroupsmax) { ngroupsmax = ngroups + 1; groupstrings = (char **) - memory->srealloc(groupstrings, - ngroupsmax * sizeof(char *), - "fix_charge_regulation:groupstrings"); + memory->srealloc(groupstrings, ngroupsmax * sizeof(char *), "fix_charge_regulation:groupstrings"); } groupstrings[ngroups] = utils::strdup(arg[iarg+1]); ngroups++; diff --git a/src/MISC/fix_imd.cpp b/src/MISC/fix_imd.cpp index abba37cf3f..1e2160ef07 100644 --- a/src/MISC/fix_imd.cpp +++ b/src/MISC/fix_imd.cpp @@ -458,28 +458,20 @@ FixIMD::FixIMD(LAMMPS *lmp, int narg, char **arg) : imd_trate = 1; /* parse optional arguments */ - int argsdone = 4; - while (argsdone+1 < narg) { - if (0 == strcmp(arg[argsdone], "unwrap")) { - if (0 == strcmp(arg[argsdone+1], "on")) { - unwrap_flag = 1; - } else { - unwrap_flag = 0; - } - } else if (0 == strcmp(arg[argsdone], "nowait")) { - if (0 == strcmp(arg[argsdone+1], "on")) { - nowait_flag = 1; - } else { - nowait_flag = 0; - } - } else if (0 == strcmp(arg[argsdone], "fscale")) { - imd_fscale = utils::numeric(FLERR,arg[argsdone+1],false,lmp); - } else if (0 == strcmp(arg[argsdone], "trate")) { - imd_trate = utils::inumeric(FLERR,arg[argsdone+1],false,lmp); + int iarg = 4; + while (iarg+1 < narg) { + if (0 == strcmp(arg[iarg], "unwrap")) { + unwrap_flag = utils::logical(FLERR, arg[iarg+1], false, lmp); + } else if (0 == strcmp(arg[iarg], "nowait")) { + nowait_flag = utils::logical(FLERR, arg[iarg+1], false, lmp); + } else if (0 == strcmp(arg[iarg], "fscale")) { + imd_fscale = utils::numeric(FLERR,arg[iarg+1],false,lmp); + } else if (0 == strcmp(arg[iarg], "trate")) { + imd_trate = utils::inumeric(FLERR,arg[iarg+1],false,lmp); } else { error->all(FLERR,"Unknown fix imd parameter"); } - ++argsdone; ++argsdone; + ++iarg; ++iarg; } /* sanity check on parameters */ diff --git a/src/MISC/fix_ipi.cpp b/src/MISC/fix_ipi.cpp index b56c5eebcb..b82339713e 100644 --- a/src/MISC/fix_ipi.cpp +++ b/src/MISC/fix_ipi.cpp @@ -200,22 +200,10 @@ FixIPI::FixIPI(LAMMPS *lmp, int narg, char **arg) : hasdata = bsize = 0; // creates a temperature compute for all atoms - char** newarg = new char*[3]; - newarg[0] = (char *) "IPI_TEMP"; - newarg[1] = (char *) "all"; - newarg[2] = (char *) "temp"; - modify->add_compute(3,newarg); - delete [] newarg; + modify->add_compute("IPI_TEMP all temp"); // creates a pressure compute to extract the virial - newarg = new char*[5]; - newarg[0] = (char *) "IPI_PRESS"; - newarg[1] = (char *) "all"; - newarg[2] = (char *) "pressure"; - newarg[3] = (char *) "IPI_TEMP"; - newarg[4] = (char *) "virial"; - modify->add_compute(5,newarg); - delete [] newarg; + modify->add_compute("IPI_PRESS all pressure IPI_TEMP virial"); // create instance of Irregular class irregular = new Irregular(lmp); diff --git a/src/MISC/pair_srp.cpp b/src/MISC/pair_srp.cpp index 456d45c0ae..77a8eb4c2d 100644 --- a/src/MISC/pair_srp.cpp +++ b/src/MISC/pair_srp.cpp @@ -378,12 +378,8 @@ void PairSRP::settings(int narg, char **arg) while (iarg < narg) { if (strcmp(arg[iarg],"exclude") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal pair srp command"); - if (strcmp(arg[iarg+1],"yes") == 0) - exclude = 1; - if (strcmp(arg[iarg+1],"no") == 0) { - if (min) error->all(FLERR,"Illegal exclude option in pair srp command"); - exclude = 0; - } + exclude = utils::logical(FLERR, arg[iarg+1], false, lmp); + if (min && !exclude) error->all(FLERR,"Illegal exclude option in pair srp command"); iarg += 2; } else if (strcmp(arg[iarg],"bptype") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal pair srp command"); diff --git a/src/ML-HDNNP/pair_hdnnp.cpp b/src/ML-HDNNP/pair_hdnnp.cpp index c27f93c132..8411a0c3cf 100644 --- a/src/ML-HDNNP/pair_hdnnp.cpp +++ b/src/ML-HDNNP/pair_hdnnp.cpp @@ -148,12 +148,7 @@ void PairHDNNP::settings(int narg, char **arg) // show extrapolation warnings } else if (strcmp(arg[iarg], "showew") == 0) { if (iarg + 2 > narg) error->all(FLERR, "Illegal pair_style command"); - if (strcmp(arg[iarg + 1], "yes") == 0) - showew = true; - else if (strcmp(arg[iarg + 1], "no") == 0) - showew = false; - else - error->all(FLERR, "Illegal pair_style command"); + showew = utils::logical(FLERR, arg[iarg + 1], false, lmp) == 1; iarg += 2; // show extrapolation warning summary } else if (strcmp(arg[iarg], "showewsum") == 0) { @@ -168,12 +163,7 @@ void PairHDNNP::settings(int narg, char **arg) // reset extrapolation warning counter } else if (strcmp(arg[iarg], "resetew") == 0) { if (iarg + 2 > narg) error->all(FLERR, "Illegal pair_style command"); - if (strcmp(arg[iarg + 1], "yes") == 0) - resetew = true; - else if (strcmp(arg[iarg + 1], "no") == 0) - resetew = false; - else - error->all(FLERR, "Illegal pair_style command"); + resetew = utils::logical(FLERR, arg[iarg + 1], false, lmp) == 1; iarg += 2; // length unit conversion factor } else if (strcmp(arg[iarg], "cflength") == 0) { diff --git a/src/MOLFILE/dump_molfile.cpp b/src/MOLFILE/dump_molfile.cpp index c1c4120405..052fb444a4 100644 --- a/src/MOLFILE/dump_molfile.cpp +++ b/src/MOLFILE/dump_molfile.cpp @@ -421,9 +421,7 @@ int DumpMolfile::modify_param(int narg, char **arg) { if (strcmp(arg[0],"unwrap") == 0) { if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); - if (strcmp(arg[1],"yes") == 0) unwrap_flag = 1; - else if (strcmp(arg[1],"no") == 0) unwrap_flag = 0; - else error->all(FLERR,"Illegal dump_modify command"); + unwrap_flag = utils::logical(FLERR,arg[1],false,lmp); return 2; } else if (strcmp(arg[0],"element") == 0) { diff --git a/src/MSCG/fix_mscg.cpp b/src/MSCG/fix_mscg.cpp index 15b288dc36..1aa644b976 100644 --- a/src/MSCG/fix_mscg.cpp +++ b/src/MSCG/fix_mscg.cpp @@ -77,11 +77,7 @@ FixMSCG::FixMSCG(LAMMPS *lmp, int narg, char **arg) : while (iarg < narg) { if (strcmp(arg[iarg],"range") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix mscg command"); - if (strcmp(arg[iarg+1],"on") == 0) - range_flag = 1; - else if (strcmp(arg[iarg+1],"off") == 0) - range_flag = 0; - else error->all(FLERR,"Illegal fix mscg command"); + range_flag = utils::logical(FLERR, arg[iarg+1], false, lmp); iarg += 2; } else if (strcmp(arg[iarg],"name") == 0) { if (iarg+ntypes+1 > narg) @@ -324,8 +320,7 @@ void FixMSCG::post_run() if (nframes != n_frames) error->warning(FLERR,"Fix mscg n_frames is inconsistent with control.in"); if (nframes % block_size != 0) - error->warning(FLERR,"Fix mscg n_frames is not divisible by " - "block_size in control.in"); + error->warning(FLERR,"Fix mscg n_frames is not divisible by block_size in control.in"); if (range_flag) rangefinder_solve_and_output(mscg_struct); diff --git a/src/NETCDF/dump_netcdf.cpp b/src/NETCDF/dump_netcdf.cpp index cd7783a0aa..5702c94499 100644 --- a/src/NETCDF/dump_netcdf.cpp +++ b/src/NETCDF/dump_netcdf.cpp @@ -871,19 +871,13 @@ int DumpNetCDF::modify_param(int narg, char **arg) int iarg = 0; if (strcmp(arg[iarg],"double") == 0) { iarg++; - if (iarg >= narg) - error->all(FLERR,"expected 'yes' or 'no' after 'double' keyword."); - if (strcmp(arg[iarg],"yes") == 0) { - double_precision = true; - } else if (strcmp(arg[iarg],"no") == 0) { - double_precision = false; - } else error->all(FLERR,"expected 'yes' or 'no' after 'double' keyword."); + if (iarg >= narg) error->all(FLERR,"expected 'yes' or 'no' after 'double' keyword."); + double_precision = utils::logical(FLERR,arg[iarg],false,lmp) == 1; iarg++; return 2; } else if (strcmp(arg[iarg],"at") == 0) { iarg++; - if (iarg >= narg) - error->all(FLERR,"expected additional arg after 'at' keyword."); + if (iarg >= narg) error->all(FLERR,"expected additional arg after 'at' keyword."); framei = utils::inumeric(FLERR,arg[iarg],false,lmp); if (framei == 0) error->all(FLERR,"frame 0 not allowed for 'at' keyword."); else if (framei < 0) framei--; @@ -891,13 +885,8 @@ int DumpNetCDF::modify_param(int narg, char **arg) return 2; } else if (strcmp(arg[iarg],"thermo") == 0) { iarg++; - if (iarg >= narg) - error->all(FLERR,"expected 'yes' or 'no' after 'thermo' keyword."); - if (strcmp(arg[iarg],"yes") == 0) { - thermo = true; - } else if (strcmp(arg[iarg],"no") == 0) { - thermo = false; - } else error->all(FLERR,"expected 'yes' or 'no' after 'thermo' keyword."); + if (iarg >= narg) error->all(FLERR,"expected 'yes' or 'no' after 'thermo' keyword."); + thermo = utils::logical(FLERR,arg[iarg],false,lmp) == 1; iarg++; return 2; } else return 0; diff --git a/src/NETCDF/dump_netcdf_mpiio.cpp b/src/NETCDF/dump_netcdf_mpiio.cpp index 4179b362c8..a6c3c535c9 100644 --- a/src/NETCDF/dump_netcdf_mpiio.cpp +++ b/src/NETCDF/dump_netcdf_mpiio.cpp @@ -866,19 +866,13 @@ int DumpNetCDFMPIIO::modify_param(int narg, char **arg) int iarg = 0; if (strcmp(arg[iarg],"double") == 0) { iarg++; - if (iarg >= narg) - error->all(FLERR,"expected 'yes' or 'no' after 'double' keyword."); - if (strcmp(arg[iarg],"yes") == 0) { - double_precision = true; - } else if (strcmp(arg[iarg],"no") == 0) { - double_precision = false; - } else error->all(FLERR,"expected 'yes' or 'no' after 'double' keyword."); + if (iarg >= narg) error->all(FLERR,"expected 'yes' or 'no' after 'double' keyword."); + double_precision = utils::logical(FLERR,arg[iarg],false,lmp) == 1; iarg++; return 2; } else if (strcmp(arg[iarg],"at") == 0) { iarg++; - if (iarg >= narg) - error->all(FLERR,"expected additional arg after 'at' keyword."); + if (iarg >= narg) error->all(FLERR,"expected additional arg after 'at' keyword."); framei = utils::inumeric(FLERR,arg[iarg],false,lmp); if (framei == 0) error->all(FLERR,"frame 0 not allowed for 'at' keyword."); else if (framei < 0) framei--; @@ -886,13 +880,8 @@ int DumpNetCDFMPIIO::modify_param(int narg, char **arg) return 2; } else if (strcmp(arg[iarg],"thermo") == 0) { iarg++; - if (iarg >= narg) - error->all(FLERR,"expected 'yes' or 'no' after 'thermo' keyword."); - if (strcmp(arg[iarg],"yes") == 0) { - thermo = true; - } else if (strcmp(arg[iarg],"no") == 0) { - thermo = false; - } else error->all(FLERR,"expected 'yes' or 'no' after 'thermo' keyword."); + if (iarg >= narg) error->all(FLERR,"expected 'yes' or 'no' after 'thermo' keyword."); + thermo = utils::logical(FLERR,arg[iarg],false,lmp) == 1; iarg++; return 2; } else return 0; diff --git a/src/OPENMP/fix_omp.cpp b/src/OPENMP/fix_omp.cpp index 2b7e7eeaf9..ec5b1d5be0 100644 --- a/src/OPENMP/fix_omp.cpp +++ b/src/OPENMP/fix_omp.cpp @@ -99,9 +99,7 @@ FixOMP::FixOMP(LAMMPS *lmp, int narg, char **arg) while (iarg < narg) { if (strcmp(arg[iarg],"neigh") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal package omp command"); - if (strcmp(arg[iarg+1],"yes") == 0) _neighbor = true; - else if (strcmp(arg[iarg+1],"no") == 0) _neighbor = false; - else error->all(FLERR,"Illegal package omp command"); + _neighbor = utils::logical(FLERR,arg[iarg+1],false,lmp) != 0; iarg += 2; } else error->all(FLERR,"Illegal package omp command"); } diff --git a/src/PHONON/dynamical_matrix.cpp b/src/PHONON/dynamical_matrix.cpp index 810111998e..f7cb3f7f44 100644 --- a/src/PHONON/dynamical_matrix.cpp +++ b/src/PHONON/dynamical_matrix.cpp @@ -181,30 +181,29 @@ void DynamicalMatrix::command(int narg, char **arg) void DynamicalMatrix::options(int narg, char **arg) { - if (narg < 0) error->all(FLERR,"Illegal dynamical_matrix command"); - int iarg = 0; - const char* filename = "dynmat.dyn"; - while (iarg < narg) { - if (strcmp(arg[iarg],"binary") == 0) { - if (iarg + 2 > narg) error->all(FLERR, "Illegal dynamical_matrix command"); - if (strcmp(arg[iarg+1],"gzip") == 0) { - compressed = 1; - } - else if (strcmp(arg[iarg+1],"yes") == 0) { - binaryflag = 1; - } - iarg += 2; - } - else if (strcmp(arg[iarg],"file") == 0) { - if (iarg+2 > narg) error->all(FLERR, "Illegal dynamical_matrix command"); - filename = arg[iarg + 1]; - file_flag = 1; - iarg += 2; - } else error->all(FLERR,"Illegal dynamical_matrix command"); - } - if (file_flag == 1) { - openfile(filename); - } + if (narg < 0) error->all(FLERR,"Illegal dynamical_matrix command"); + int iarg = 0; + const char* filename = "dynmat.dyn"; + + while (iarg < narg) { + if (strcmp(arg[iarg],"binary") == 0) { + if (iarg + 2 > narg) error->all(FLERR, "Illegal dynamical_matrix command"); + if (strcmp(arg[iarg+1],"gzip") == 0) { + compressed = 1; + } else { + binaryflag = utils::logical(FLERR,arg[iarg+1],false,lmp); + } + iarg += 2; + } else if (strcmp(arg[iarg],"file") == 0) { + if (iarg+2 > narg) error->all(FLERR, "Illegal dynamical_matrix command"); + filename = arg[iarg + 1]; + file_flag = 1; + iarg += 2; + } else error->all(FLERR,"Illegal dynamical_matrix command"); + } + if (file_flag == 1) { + openfile(filename); + } } /* ---------------------------------------------------------------------- diff --git a/src/PHONON/third_order.cpp b/src/PHONON/third_order.cpp index e9add72267..565e8b50e5 100644 --- a/src/PHONON/third_order.cpp +++ b/src/PHONON/third_order.cpp @@ -185,19 +185,19 @@ void ThirdOrder::options(int narg, char **arg) const char *filename = "third_order.dat"; while (iarg < narg) { - if (strcmp(arg[iarg],"file") == 0) { - if (iarg+2 > narg) error->all(FLERR, "Illegal third_order command"); - filename = arg[iarg + 1]; - file_flag = 1; - iarg += 2; - } else if (strcmp(arg[iarg],"binary") == 0) { + if (strcmp(arg[iarg],"binary") == 0) { if (iarg + 2 > narg) error->all(FLERR, "Illegal third_order command"); if (strcmp(arg[iarg+1],"gzip") == 0) { compressed = 1; - } else if (strcmp(arg[iarg+1],"yes") == 0) { - binaryflag = 1; + } else { + binaryflag = utils::logical(FLERR,arg[iarg+1],false,lmp); } iarg += 2; + } else if (strcmp(arg[iarg],"file") == 0) { + if (iarg+2 > narg) error->all(FLERR, "Illegal third_order command"); + filename = arg[iarg + 1]; + file_flag = 1; + iarg += 2; } else error->all(FLERR,"Illegal third_order command"); } if (file_flag == 1 and me == 0) { diff --git a/src/PLUMED/fix_plumed.cpp b/src/PLUMED/fix_plumed.cpp index b38e745b7a..7a142b57f8 100644 --- a/src/PLUMED/fix_plumed.cpp +++ b/src/PLUMED/fix_plumed.cpp @@ -215,31 +215,13 @@ FixPlumed::FixPlumed(LAMMPS *lmp, int narg, char **arg) : // Define compute to calculate potential energy - id_pe = new char[8]; - strcpy(id_pe,"plmd_pe"); - char **newarg = new char*[3]; - newarg[0] = id_pe; - newarg[1] = (char *) "all"; - newarg[2] = (char *) "pe"; - modify->add_compute(3,newarg); - delete [] newarg; - int ipe = modify->find_compute(id_pe); - c_pe = modify->compute[ipe]; + id_pe = utils::strdup("plmd_pe"); + c_pe = modify->add_compute(std::string(id_pe) + " all pe"); // Define compute to calculate pressure tensor - id_press = new char[11]; - strcpy(id_press,"plmd_press"); - newarg = new char*[5]; - newarg[0] = id_press; - newarg[1] = (char *) "all"; - newarg[2] = (char *) "pressure"; - newarg[3] = (char *) "NULL"; - newarg[4] = (char *) "virial"; - modify->add_compute(5,newarg); - delete [] newarg; - int ipress = modify->find_compute(id_press); - c_press = modify->compute[ipress]; + id_press = utils::strdup("plmd_press"); + c_press = modify->add_compute(std::string(id_press) + " all pressure NULL virial"); for (int i = 0; i < modify->nfix; i++) { const char * const check_style = modify->fix[i]->style; diff --git a/src/QEQ/fix_qeq_dynamic.cpp b/src/QEQ/fix_qeq_dynamic.cpp index b8fc08dc14..06cfe0d0bd 100644 --- a/src/QEQ/fix_qeq_dynamic.cpp +++ b/src/QEQ/fix_qeq_dynamic.cpp @@ -56,9 +56,7 @@ FixQEqDynamic::FixQEqDynamic(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else if (strcmp(arg[iarg],"warn") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix qeq/dynamic command"); - if (strcmp(arg[iarg+1],"no") == 0) maxwarn = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) maxwarn = 1; - else error->all(FLERR,"Illegal fix qeq/dynamic command"); + maxwarn = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else error->all(FLERR,"Illegal fix qeq/dynamic command"); } diff --git a/src/QEQ/fix_qeq_fire.cpp b/src/QEQ/fix_qeq_fire.cpp index eb206effc6..77a5ae36a1 100644 --- a/src/QEQ/fix_qeq_fire.cpp +++ b/src/QEQ/fix_qeq_fire.cpp @@ -66,9 +66,7 @@ FixQEqFire::FixQEqFire(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else if (strcmp(arg[iarg],"warn") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix qeq/fire command"); - if (strcmp(arg[iarg+1],"no") == 0) maxwarn = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) maxwarn = 1; - else error->all(FLERR,"Illegal fix qeq/fire command"); + maxwarn = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else error->all(FLERR,"Illegal fix qeq/fire command"); } diff --git a/src/QEQ/fix_qeq_point.cpp b/src/QEQ/fix_qeq_point.cpp index e836c0dad8..3ad76b74d9 100644 --- a/src/QEQ/fix_qeq_point.cpp +++ b/src/QEQ/fix_qeq_point.cpp @@ -42,9 +42,7 @@ FixQEqPoint::FixQEqPoint(LAMMPS *lmp, int narg, char **arg) : FixQEq(lmp, narg, arg) { if (narg == 10) { if (strcmp(arg[8],"warn") == 0) { - if (strcmp(arg[9],"no") == 0) maxwarn = 0; - else if (strcmp(arg[9],"yes") == 0) maxwarn = 1; - else error->all(FLERR,"Illegal fix qeq/point command"); + maxwarn = utils::logical(FLERR,arg[9],false,lmp); } else error->all(FLERR,"Illegal fix qeq/point command"); } else if (narg > 8) error->all(FLERR,"Illegal fix qeq/point command"); } diff --git a/src/QEQ/fix_qeq_shielded.cpp b/src/QEQ/fix_qeq_shielded.cpp index 4cc254a361..8c1b95996b 100644 --- a/src/QEQ/fix_qeq_shielded.cpp +++ b/src/QEQ/fix_qeq_shielded.cpp @@ -43,9 +43,7 @@ FixQEqShielded::FixQEqShielded(LAMMPS *lmp, int narg, char **arg) : FixQEq(lmp, narg, arg) { if (narg == 10) { if (strcmp(arg[8],"warn") == 0) { - if (strcmp(arg[9],"no") == 0) maxwarn = 0; - else if (strcmp(arg[9],"yes") == 0) maxwarn = 1; - else error->all(FLERR,"Illegal fix qeq/shielded command"); + maxwarn = utils::logical(FLERR,arg[9],false,lmp); } else error->all(FLERR,"Illegal fix qeq/shielded command"); } else if (narg > 8) error->all(FLERR,"Illegal fix qeq/shielded command"); if (reax_flag) extract_reax(); diff --git a/src/QEQ/fix_qeq_slater.cpp b/src/QEQ/fix_qeq_slater.cpp index 4b4814d982..d491b301d5 100644 --- a/src/QEQ/fix_qeq_slater.cpp +++ b/src/QEQ/fix_qeq_slater.cpp @@ -55,9 +55,7 @@ FixQEqSlater::FixQEqSlater(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else if (strcmp(arg[iarg],"warn") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix qeq/slater command"); - if (strcmp(arg[iarg+1],"no") == 0) maxwarn = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) maxwarn = 1; - else error->all(FLERR,"Illegal fix qeq/slater command"); + maxwarn = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else error->all(FLERR,"Illegal fix qeq/slater command"); } diff --git a/src/REACTION/fix_bond_react.cpp b/src/REACTION/fix_bond_react.cpp index 7b891d42fe..69c9c87ddf 100644 --- a/src/REACTION/fix_bond_react.cpp +++ b/src/REACTION/fix_bond_react.cpp @@ -179,24 +179,20 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) : int num_common_keywords = 2; for (int m = 0; m < num_common_keywords; m++) { if (strcmp(arg[iarg],"stabilization") == 0) { - if (strcmp(arg[iarg+1],"no") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix bond/react command: " - "'stabilization' keyword has too few arguments"); - iarg += 2; - } - if (strcmp(arg[iarg+1],"yes") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal fix bond/react command: " + "'stabilization' keyword has too few arguments"); + stabilization_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); + if (stabilization_flag) { if (iarg+4 > narg) error->all(FLERR,"Illegal fix bond/react command:" "'stabilization' keyword has too few arguments"); exclude_group = utils::strdup(arg[iarg+2]); - stabilization_flag = 1; nve_limit_xmax = arg[iarg+3]; iarg += 4; - } + } else iarg += 2; } else if (strcmp(arg[iarg],"reset_mol_ids") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix bond/react command: " "'reset_mol_ids' keyword has too few arguments"); - if (strcmp(arg[iarg+1],"yes") == 0) reset_mol_ids_flag = 1; // default - if (strcmp(arg[iarg+1],"no") == 0) reset_mol_ids_flag = 0; + reset_mol_ids_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"react") == 0) { break; @@ -914,7 +910,8 @@ void FixBondReact::post_integrate() int j; for (rxnID = 0; rxnID < nreacts; rxnID++) { - if (max_rxn[rxnID] <= reaction_count_total[rxnID]) continue; + if ((update->ntimestep % nevery[rxnID]) || + (max_rxn[rxnID] <= reaction_count_total[rxnID])) continue; for (int ii = 0; ii < nall; ii++) { partner[ii] = 0; finalpartner[ii] = 0; diff --git a/src/REAXFF/pair_reaxff.cpp b/src/REAXFF/pair_reaxff.cpp index 758ee70ab7..a8cc249e58 100644 --- a/src/REAXFF/pair_reaxff.cpp +++ b/src/REAXFF/pair_reaxff.cpp @@ -227,21 +227,18 @@ void PairReaxFF::settings(int narg, char **arg) while (iarg < narg) { if (strcmp(arg[iarg],"checkqeq") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal pair_style reaxff command"); + qeqflag = utils::logical(FLERR,arg[iarg+1],false,lmp); if (strcmp(arg[iarg+1],"yes") == 0) qeqflag = 1; else if (strcmp(arg[iarg+1],"no") == 0) qeqflag = 0; else error->all(FLERR,"Illegal pair_style reaxff command"); iarg += 2; } else if (strcmp(arg[iarg],"enobonds") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal pair_style reaxff command"); - if (strcmp(arg[iarg+1],"yes") == 0) api->control->enobondsflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) api->control->enobondsflag = 0; - else error->all(FLERR,"Illegal pair_style reaxff command"); + api->control->enobondsflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"lgvdw") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal pair_style reaxff command"); - if (strcmp(arg[iarg+1],"yes") == 0) api->control->lgflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) api->control->lgflag = 0; - else error->all(FLERR,"Illegal pair_style reaxff command"); + api->control->lgflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"safezone") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal pair_style reaxff command"); diff --git a/src/RIGID/fix_rigid.cpp b/src/RIGID/fix_rigid.cpp index 6f3486945c..db9767d01e 100644 --- a/src/RIGID/fix_rigid.cpp +++ b/src/RIGID/fix_rigid.cpp @@ -535,9 +535,7 @@ FixRigid::FixRigid(LAMMPS *lmp, int narg, char **arg) : } else if (strcmp(arg[iarg],"reinit") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix rigid command"); - if (strcmp("yes",arg[iarg+1]) == 0) reinitflag = 1; - else if (strcmp("no",arg[iarg+1]) == 0) reinitflag = 0; - else error->all(FLERR,"Illegal fix rigid command"); + reinitflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"gravity") == 0) { diff --git a/src/RIGID/fix_rigid_small.cpp b/src/RIGID/fix_rigid_small.cpp index 40bfc3ce2d..7216c56c83 100644 --- a/src/RIGID/fix_rigid_small.cpp +++ b/src/RIGID/fix_rigid_small.cpp @@ -227,17 +227,13 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) : } else if (strcmp(arg[iarg],"reinit") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix rigid/small command"); - if (strcmp("yes",arg[iarg+1]) == 0) reinitflag = 1; - else if (strcmp("no",arg[iarg+1]) == 0) reinitflag = 0; - else error->all(FLERR,"Illegal fix rigid/small command"); + reinitflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"mol") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix rigid/small command"); int imol = atom->find_molecule(arg[iarg+1]); - if (imol == -1) - error->all(FLERR,"Molecule template ID for " - "fix rigid/small does not exist"); + if (imol == -1) error->all(FLERR,"Molecule template ID for fix rigid/small does not exist"); onemols = &atom->molecules[imol]; nmol = onemols[0]->nset; restart_file = 1; diff --git a/src/SHOCK/fix_msst.cpp b/src/SHOCK/fix_msst.cpp index e8430b6ab1..ae1d0f4cd5 100644 --- a/src/SHOCK/fix_msst.cpp +++ b/src/SHOCK/fix_msst.cpp @@ -129,9 +129,7 @@ FixMSST::FixMSST(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else if (strcmp(arg[iarg],"dftb") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix msst command"); - if (strcmp(arg[iarg+1],"yes") == 0) dftb = 1; - else if (strcmp(arg[iarg+1],"yes") == 0) dftb = 0; - else error->all(FLERR,"Illegal fix msst command"); + dftb = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"beta") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix msst command"); @@ -152,8 +150,7 @@ FixMSST::FixMSST(LAMMPS *lmp, int narg, char **arg) : mesg += fmt::format(" Cell mass-like parameter qmass " "(units of mass^2/length^4) = {:.8g}\n", qmass); mesg += fmt::format(" Shock velocity = {:.8g}\n", velocity); - mesg += fmt::format(" Artificial viscosity " - "(units of mass/length/time) = {:.8g}\n", mu); + mesg += fmt::format(" Artificial viscosity (units of mass/length/time) = {:.8g}\n", mu); if (p0_set) mesg += fmt::format(" Initial pressure specified to be {:.8g}\n", p0); diff --git a/src/SPIN/fix_nve_spin.cpp b/src/SPIN/fix_nve_spin.cpp index c64609cfe3..970af9c4fb 100644 --- a/src/SPIN/fix_nve_spin.cpp +++ b/src/SPIN/fix_nve_spin.cpp @@ -71,7 +71,7 @@ FixNVESpin::FixNVESpin(LAMMPS *lmp, int narg, char **arg) : { if (lmp->citeme) lmp->citeme->add(cite_fix_nve_spin); - if (narg < 4) error->all(FLERR,"Illegal fix/NVE/spin command"); + if (narg < 4) error->all(FLERR,"Illegal fix/nve/spin command"); time_integrate = 1; sector_flag = NONE; @@ -86,7 +86,7 @@ FixNVESpin::FixNVESpin(LAMMPS *lmp, int narg, char **arg) : // checking if map array or hash is defined if (atom->map_style == Atom::MAP_NONE) - error->all(FLERR,"Fix NVE/spin requires an atom map, see atom_modify"); + error->all(FLERR,"Fix nve/spin requires an atom map, see atom_modify"); // defining sector_flag @@ -95,7 +95,7 @@ FixNVESpin::FixNVESpin(LAMMPS *lmp, int narg, char **arg) : sector_flag = 0; } else if (nprocs_tmp >= 1) { sector_flag = 1; - } else error->all(FLERR,"Illegal fix/NVE/spin command"); + } else error->all(FLERR,"Illegal fix/nve/spin command"); // defining lattice_flag @@ -105,25 +105,26 @@ FixNVESpin::FixNVESpin(LAMMPS *lmp, int narg, char **arg) : int iarg = 3; while (iarg < narg) { if (strcmp(arg[iarg],"lattice") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix/NVE/spin command"); - if (strcmp(arg[iarg+1],"no") == 0) lattice_flag = 0; - else if (strcmp(arg[iarg+1],"frozen") == 0) lattice_flag = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) lattice_flag = 1; - else if (strcmp(arg[iarg+1],"moving") == 0) lattice_flag = 1; - else error->all(FLERR,"Illegal fix/NVE/spin command"); + if (iarg+2 > narg) error->all(FLERR,"Illegal fix/nve/spin command"); + const std::string latarg = arg[iarg+1]; + if ((latarg == "no") || (latarg == "off") || (latarg == "false") || (latarg == "frozen")) + lattice_flag = 0; + else if ((latarg == "yes") || (latarg == "on") || (latarg == "true") || (latarg == "moving")) + lattice_flag = 1; + else error->all(FLERR,"Illegal fix/nve/spin command"); iarg += 2; - } else error->all(FLERR,"Illegal fix/NVE/spin command"); + } else error->all(FLERR,"Illegal fix/nve/spin command"); } // check if the atom/spin style is defined if (!atom->sp_flag) - error->all(FLERR,"Fix NVE/spin requires atom/spin style"); + error->all(FLERR,"Fix nve/spin requires atom/spin style"); // check if sector_flag is correctly defined if (sector_flag == 0 && nprocs_tmp > 1) - error->all(FLERR,"Illegal fix/NVE/spin command"); + error->all(FLERR,"Illegal fix/nve/spin command"); // initialize the magnetic interaction flags @@ -307,7 +308,7 @@ void FixNVESpin::init() // setting the sector variables/lists nsectors = 0; - memory->create(rsec,3,"NVE/spin:rsec"); + memory->create(rsec,3,"nve/spin:rsec"); // perform the sectoring operation @@ -316,10 +317,10 @@ void FixNVESpin::init() // init. size of stacking lists (sectoring) nlocal_max = atom->nlocal; - memory->grow(stack_head,nsectors,"NVE/spin:stack_head"); - memory->grow(stack_foot,nsectors,"NVE/spin:stack_foot"); - memory->grow(backward_stacks,nlocal_max,"NVE/spin:backward_stacks"); - memory->grow(forward_stacks,nlocal_max,"NVE/spin:forward_stacks"); + memory->grow(stack_head,nsectors,"nve/spin:stack_head"); + memory->grow(stack_foot,nsectors,"nve/spin:stack_foot"); + memory->grow(backward_stacks,nlocal_max,"nve/spin:backward_stacks"); + memory->grow(forward_stacks,nlocal_max,"nve/spin:forward_stacks"); } /* ---------------------------------------------------------------------- */ @@ -391,7 +392,7 @@ void FixNVESpin::initial_integrate(int /*vflag*/) AdvanceSingleSpin(i); } } - } else error->all(FLERR,"Illegal fix NVE/spin command"); + } else error->all(FLERR,"Illegal fix nve/spin command"); // update x for all particles @@ -444,7 +445,7 @@ void FixNVESpin::initial_integrate(int /*vflag*/) AdvanceSingleSpin(i); } } - } else error->all(FLERR,"Illegal fix NVE/spin command"); + } else error->all(FLERR,"Illegal fix nve/spin command"); } @@ -468,8 +469,8 @@ void FixNVESpin::pre_neighbor() if (nlocal_max < nlocal) { // grow linked lists if necessary nlocal_max = nlocal; - memory->grow(backward_stacks,nlocal_max,"NVE/spin:backward_stacks"); - memory->grow(forward_stacks,nlocal_max,"NVE/spin:forward_stacks"); + memory->grow(backward_stacks,nlocal_max,"nve/spin:backward_stacks"); + memory->grow(forward_stacks,nlocal_max,"nve/spin:forward_stacks"); } for (int j = 0; j < nsectors; j++) { diff --git a/src/SPIN/pair_spin_exchange.cpp b/src/SPIN/pair_spin_exchange.cpp index 23553a9d94..329ad5e100 100644 --- a/src/SPIN/pair_spin_exchange.cpp +++ b/src/SPIN/pair_spin_exchange.cpp @@ -105,7 +105,6 @@ void PairSpinExchange::coeff(int narg, char **arg) // get exchange arguments from input command - int iarg = 7; const double rc = utils::numeric(FLERR,arg[3],false,lmp); const double j1 = utils::numeric(FLERR,arg[4],false,lmp); const double j2 = utils::numeric(FLERR,arg[5],false,lmp); @@ -113,13 +112,10 @@ void PairSpinExchange::coeff(int narg, char **arg) // read energy offset flag if specified + int iarg = 7; while (iarg < narg) { - if (strcmp(arg[7],"offset") == 0) { - if (strcmp(arg[8],"yes") == 0) { - e_offset = 1; - } else if (strcmp(arg[8],"no") == 0) { - e_offset = 0; - } else error->all(FLERR,"Incorrect args for pair coefficients"); + if (strcmp(arg[iarg],"offset") == 0) { + e_offset = utils::logical(FLERR, arg[iarg+1], false, lmp); iarg += 2; } else error->all(FLERR,"Incorrect args for pair coefficients"); } diff --git a/src/SPIN/pair_spin_exchange_biquadratic.cpp b/src/SPIN/pair_spin_exchange_biquadratic.cpp index 8bff5e1b1d..fb727e1939 100644 --- a/src/SPIN/pair_spin_exchange_biquadratic.cpp +++ b/src/SPIN/pair_spin_exchange_biquadratic.cpp @@ -121,12 +121,8 @@ void PairSpinExchangeBiquadratic::coeff(int narg, char **arg) // read energy offset flag if specified while (iarg < narg) { - if (strcmp(arg[10],"offset") == 0) { - if (strcmp(arg[11],"yes") == 0) { - e_offset = 1; - } else if (strcmp(arg[11],"no") == 0) { - e_offset = 0; - } else error->all(FLERR,"Incorrect args for pair coefficients"); + if (strcmp(arg[iarg],"offset") == 0) { + e_offset = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else error->all(FLERR,"Incorrect args for pair coefficients"); } diff --git a/src/SRD/fix_srd.cpp b/src/SRD/fix_srd.cpp index 22fade7bf3..f1e17eaa24 100644 --- a/src/SRD/fix_srd.cpp +++ b/src/SRD/fix_srd.cpp @@ -142,12 +142,7 @@ FixSRD::FixSRD(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else if (strcmp(arg[iarg], "overlap") == 0) { if (iarg + 2 > narg) error->all(FLERR, "Illegal fix srd command"); - if (strcmp(arg[iarg + 1], "yes") == 0) - overlap = 1; - else if (strcmp(arg[iarg + 1], "no") == 0) - overlap = 0; - else - error->all(FLERR, "Illegal fix srd command"); + overlap = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg], "inside") == 0) { if (iarg + 2 > narg) error->all(FLERR, "Illegal fix srd command"); @@ -162,12 +157,7 @@ FixSRD::FixSRD(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else if (strcmp(arg[iarg], "exact") == 0) { if (iarg + 2 > narg) error->all(FLERR, "Illegal fix srd command"); - if (strcmp(arg[iarg + 1], "yes") == 0) - exactflag = 1; - else if (strcmp(arg[iarg + 1], "no") == 0) - exactflag = 0; - else - error->all(FLERR, "Illegal fix srd command"); + exactflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg], "radius") == 0) { if (iarg + 2 > narg) error->all(FLERR, "Illegal fix srd command"); @@ -206,12 +196,7 @@ FixSRD::FixSRD(LAMMPS *lmp, int narg, char **arg) : iarg += 3; } else if (strcmp(arg[iarg], "tstat") == 0) { if (iarg + 2 > narg) error->all(FLERR, "Illegal fix srd command"); - if (strcmp(arg[iarg + 1], "no") == 0) - tstat = 0; - else if (strcmp(arg[iarg + 1], "yes") == 0) - tstat = 1; - else - error->all(FLERR, "Illegal fix srd command"); + tstat = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg], "rescale") == 0) { if (iarg + 2 > narg) error->all(FLERR, "Illegal fix srd command"); diff --git a/src/VORONOI/compute_voronoi_atom.cpp b/src/VORONOI/compute_voronoi_atom.cpp index 5808b8d17c..2be02e3d2a 100644 --- a/src/VORONOI/compute_voronoi_atom.cpp +++ b/src/VORONOI/compute_voronoi_atom.cpp @@ -109,15 +109,11 @@ ComputeVoronoi::ComputeVoronoi(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else if (strcmp(arg[iarg], "neighbors") == 0) { if (iarg + 2 > narg) error->all(FLERR,"Illegal compute voronoi/atom command"); - if (strcmp(arg[iarg+1],"yes") == 0) faces_flag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) faces_flag = 0; - else error->all(FLERR,"Illegal compute voronoi/atom command"); + faces_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg], "peratom") == 0) { if (iarg + 2 > narg) error->all(FLERR,"Illegal compute voronoi/atom command"); - if (strcmp(arg[iarg+1],"yes") == 0) peratom_flag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) peratom_flag = 0; - else error->all(FLERR,"Illegal compute voronoi/atom command"); + peratom_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else error->all(FLERR,"Illegal compute voronoi/atom command"); diff --git a/src/VTK/dump_vtk.cpp b/src/VTK/dump_vtk.cpp index f323ce820f..a7aabe3f51 100644 --- a/src/VTK/dump_vtk.cpp +++ b/src/VTK/dump_vtk.cpp @@ -2070,9 +2070,7 @@ int DumpVTK::modify_param(int narg, char **arg) if (strcmp(arg[0],"binary") == 0) { if (narg < 2) error->all(FLERR,"Illegal dump_modify command [binary]"); - if (strcmp(arg[1],"yes") == 0) binary = 1; - else if (strcmp(arg[1],"no") == 0) binary = 0; - else error->all(FLERR,"Illegal dump_modify command [binary]"); + binary = utils::logical(FLERR,arg[1],false,lmp); return 2; } diff --git a/src/atom.cpp b/src/atom.cpp index 43d2578828..9fe115f5aa 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -822,17 +822,13 @@ void Atom::modify_params(int narg, char **arg) if (strcmp(arg[iarg],"id") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal atom_modify command"); if (domain->box_exist) - error->all(FLERR, - "Atom_modify id command after simulation box is defined"); - if (strcmp(arg[iarg+1],"yes") == 0) tag_enable = 1; - else if (strcmp(arg[iarg+1],"no") == 0) tag_enable = 0; - else error->all(FLERR,"Illegal atom_modify command"); + error->all(FLERR,"Atom_modify id command after simulation box is defined"); + tag_enable = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"map") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal atom_modify command"); if (domain->box_exist) - error->all(FLERR, - "Atom_modify map command after simulation box is defined"); + error->all(FLERR,"Atom_modify map command after simulation box is defined"); if (strcmp(arg[iarg+1],"array") == 0) map_user = 1; else if (strcmp(arg[iarg+1],"hash") == 0) map_user = 2; else if (strcmp(arg[iarg+1],"yes") == 0) map_user = 3; diff --git a/src/comm.cpp b/src/comm.cpp index f79c48ace1..afe074cb5c 100644 --- a/src/comm.cpp +++ b/src/comm.cpp @@ -395,9 +395,7 @@ void Comm::modify_params(int narg, char **arg) iarg += 1; } else if (strcmp(arg[iarg],"vel") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal comm_modify command"); - if (strcmp(arg[iarg+1],"yes") == 0) ghost_velocity = 1; - else if (strcmp(arg[iarg+1],"no") == 0) ghost_velocity = 0; - else error->all(FLERR,"Illegal comm_modify command"); + ghost_velocity = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else error->all(FLERR,"Illegal comm_modify command"); } diff --git a/src/compute.cpp b/src/compute.cpp index 76a953484b..ba1d53e7c3 100644 --- a/src/compute.cpp +++ b/src/compute.cpp @@ -128,9 +128,7 @@ void Compute::modify_params(int narg, char **arg) } else if (strcmp(arg[iarg],"dynamic") == 0 || strcmp(arg[iarg],"dynamic/dof") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal compute_modify command"); - if (strcmp(arg[iarg+1],"no") == 0) dynamic_user = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) dynamic_user = 1; - else error->all(FLERR,"Illegal compute_modify command"); + dynamic_user = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else error->all(FLERR,"Illegal compute_modify command"); } diff --git a/src/compute_angle_local.cpp b/src/compute_angle_local.cpp index 7401d8b214..2bceb91dd5 100644 --- a/src/compute_angle_local.cpp +++ b/src/compute_angle_local.cpp @@ -194,7 +194,7 @@ void ComputeAngleLocal::compute_local() int ComputeAngleLocal::compute_angles(int flag) { - int i,m,n,na,atom1,atom2,atom3,imol,iatom,atype,ivar; + int i,m,na,atom1,atom2,atom3,imol,iatom,atype,ivar; tagint tagprev; double delx1,dely1,delz1,delx2,dely2,delz2; double rsq1,rsq2,r1,r2,c,theta; diff --git a/src/compute_centro_atom.cpp b/src/compute_centro_atom.cpp index 5816bee17a..90f535613b 100644 --- a/src/compute_centro_atom.cpp +++ b/src/compute_centro_atom.cpp @@ -17,19 +17,21 @@ ------------------------------------------------------------------------- */ #include "compute_centro_atom.h" -#include + #include "atom.h" -#include "update.h" -#include "modify.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "neigh_request.h" -#include "force.h" -#include "pair.h" #include "comm.h" +#include "error.h" +#include "force.h" #include "math_extra.h" #include "memory.h" -#include "error.h" +#include "modify.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "neighbor.h" +#include "pair.h" +#include "update.h" + +#include using namespace LAMMPS_NS; @@ -55,11 +57,8 @@ ComputeCentroAtom::ComputeCentroAtom(LAMMPS *lmp, int narg, char **arg) : int iarg = 4; while (iarg < narg) { if (strcmp(arg[iarg],"axes") == 0) { - if (iarg+2 > narg) - error->all(FLERR,"Illegal compute centro/atom command3"); - if (strcmp(arg[iarg+1],"yes") == 0) axes_flag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) axes_flag = 0; - else error->all(FLERR,"Illegal compute centro/atom command2"); + if (iarg+2 > narg) error->all(FLERR,"Illegal compute centro/atom command3"); + axes_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else error->all(FLERR,"Illegal compute centro/atom command1"); } diff --git a/src/compute_chunk_atom.cpp b/src/compute_chunk_atom.cpp index 5d789f722a..fc4f17e53a 100644 --- a/src/compute_chunk_atom.cpp +++ b/src/compute_chunk_atom.cpp @@ -220,9 +220,7 @@ ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else if (strcmp(arg[iarg],"compress") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal compute chunk/atom command"); - else if (strcmp(arg[iarg+1],"no") == 0) compress = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) compress = 1; - else error->all(FLERR,"Illegal compute chunk/atom command"); + compress = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"discard") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal compute chunk/atom command"); @@ -255,9 +253,7 @@ ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else if (strcmp(arg[iarg],"pbc") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal compute chunk/atom command"); - if (strcmp(arg[iarg+1],"no") == 0) pbcflag = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) pbcflag = 1; - else error->all(FLERR,"Illegal compute chunk/atom command"); + pbcflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else error->all(FLERR,"Illegal compute chunk/atom command"); } diff --git a/src/compute_fragment_atom.cpp b/src/compute_fragment_atom.cpp index b0a72080df..9ed57fef60 100644 --- a/src/compute_fragment_atom.cpp +++ b/src/compute_fragment_atom.cpp @@ -54,9 +54,7 @@ ComputeFragmentAtom::ComputeFragmentAtom(LAMMPS *lmp, int narg, char **arg) : while (iarg < narg) { if (strcmp(arg[iarg],"single") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal compute fragment/atom command"); - if (strcmp(arg[iarg+1],"yes") == 0) singleflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) singleflag = 0; - else error->all(FLERR,"Illegal compute fragment/atom command"); + singleflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else error->all(FLERR,"Illegal compute fragment/atom command"); } diff --git a/src/compute_group_group.cpp b/src/compute_group_group.cpp index 161126b53a..db26a75880 100644 --- a/src/compute_group_group.cpp +++ b/src/compute_group_group.cpp @@ -19,21 +19,22 @@ #include "compute_group_group.h" -#include -#include #include "atom.h" -#include "update.h" -#include "force.h" -#include "pair.h" -#include "neighbor.h" -#include "neigh_request.h" -#include "neigh_list.h" -#include "group.h" -#include "kspace.h" -#include "error.h" #include "comm.h" #include "domain.h" +#include "error.h" +#include "force.h" +#include "group.h" +#include "kspace.h" #include "math_const.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "neighbor.h" +#include "pair.h" +#include "update.h" + +#include +#include using namespace LAMMPS_NS; using namespace MathConst; @@ -69,29 +70,19 @@ ComputeGroupGroup::ComputeGroupGroup(LAMMPS *lmp, int narg, char **arg) : int iarg = 4; while (iarg < narg) { if (strcmp(arg[iarg],"pair") == 0) { - if (iarg+2 > narg) - error->all(FLERR,"Illegal compute group/group command"); - if (strcmp(arg[iarg+1],"yes") == 0) pairflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) pairflag = 0; - else error->all(FLERR,"Illegal compute group/group command"); + if (iarg+2 > narg) error->all(FLERR,"Illegal compute group/group command"); + pairflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"kspace") == 0) { - if (iarg+2 > narg) - error->all(FLERR,"Illegal compute group/group command"); - if (strcmp(arg[iarg+1],"yes") == 0) kspaceflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) kspaceflag = 0; - else error->all(FLERR,"Illegal compute group/group command"); + if (iarg+2 > narg) error->all(FLERR,"Illegal compute group/group command"); + kspaceflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"boundary") == 0) { - if (iarg+2 > narg) - error->all(FLERR,"Illegal compute group/group command"); - if (strcmp(arg[iarg+1],"yes") == 0) boundaryflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) boundaryflag = 0; - else error->all(FLERR,"Illegal compute group/group command"); + if (iarg+2 > narg) error->all(FLERR,"Illegal compute group/group command"); + boundaryflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"molecule") == 0) { - if (iarg+2 > narg) - error->all(FLERR,"Illegal compute group/group command"); + if (iarg+2 > narg) error->all(FLERR,"Illegal compute group/group command"); if (strcmp(arg[iarg+1],"off") == 0) molflag = OFF; else if (strcmp(arg[iarg+1],"inter") == 0) molflag = INTER; else if (strcmp(arg[iarg+1],"intra") == 0) molflag = INTRA; diff --git a/src/compute_msd.cpp b/src/compute_msd.cpp index 209eec2810..7eee23a466 100644 --- a/src/compute_msd.cpp +++ b/src/compute_msd.cpp @@ -49,15 +49,11 @@ ComputeMSD::ComputeMSD(LAMMPS *lmp, int narg, char **arg) : while (iarg < narg) { if (strcmp(arg[iarg],"com") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal compute msd command"); - if (strcmp(arg[iarg+1],"no") == 0) comflag = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) comflag = 1; - else error->all(FLERR,"Illegal compute msd command"); + comflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"average") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal compute msd command"); - if (strcmp(arg[iarg+1],"no") == 0) avflag = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) avflag = 1; - else error->all(FLERR,"Illegal compute msd command"); + avflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else error->all(FLERR,"Illegal compute msd command"); } diff --git a/src/compute_orientorder_atom.cpp b/src/compute_orientorder_atom.cpp index b77e68062f..d4291251b6 100644 --- a/src/compute_orientorder_atom.cpp +++ b/src/compute_orientorder_atom.cpp @@ -83,53 +83,41 @@ ComputeOrientOrderAtom::ComputeOrientOrderAtom(LAMMPS *lmp, int narg, char **arg int iarg = 3; while (iarg < narg) { if (strcmp(arg[iarg],"nnn") == 0) { - if (iarg+2 > narg) - error->all(FLERR,"Illegal compute orientorder/atom command"); + if (iarg+2 > narg) error->all(FLERR,"Illegal compute orientorder/atom command"); if (strcmp(arg[iarg+1],"NULL") == 0) { nnn = 0; } else { nnn = utils::numeric(FLERR,arg[iarg+1],false,lmp); - if (nnn <= 0) - error->all(FLERR,"Illegal compute orientorder/atom command"); + if (nnn <= 0) error->all(FLERR,"Illegal compute orientorder/atom command"); } iarg += 2; } else if (strcmp(arg[iarg],"degrees") == 0) { - if (iarg+2 > narg) - error->all(FLERR,"Illegal compute orientorder/atom command"); + if (iarg+2 > narg) error->all(FLERR,"Illegal compute orientorder/atom command"); nqlist = utils::numeric(FLERR,arg[iarg+1],false,lmp); - if (nqlist <= 0) - error->all(FLERR,"Illegal compute orientorder/atom command"); + if (nqlist <= 0) error->all(FLERR,"Illegal compute orientorder/atom command"); memory->destroy(qlist); memory->create(qlist,nqlist,"orientorder/atom:qlist"); iarg += 2; - if (iarg+nqlist > narg) - error->all(FLERR,"Illegal compute orientorder/atom command"); + if (iarg+nqlist > narg) error->all(FLERR,"Illegal compute orientorder/atom command"); qmax = 0; for (int il = 0; il < nqlist; il++) { qlist[il] = utils::numeric(FLERR,arg[iarg+il],false,lmp); - if (qlist[il] < 0) - error->all(FLERR,"Illegal compute orientorder/atom command"); + if (qlist[il] < 0) error->all(FLERR,"Illegal compute orientorder/atom command"); if (qlist[il] > qmax) qmax = qlist[il]; } iarg += nqlist; } else if (strcmp(arg[iarg],"wl") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal compute orientorder/atom command"); - if (strcmp(arg[iarg+1],"yes") == 0) wlflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) wlflag = 0; - else error->all(FLERR,"Illegal compute orientorder/atom command"); + wlflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"wl/hat") == 0) { - if (iarg+2 > narg) - error->all(FLERR,"Illegal compute orientorder/atom command"); - if (strcmp(arg[iarg+1],"yes") == 0) wlhatflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) wlhatflag = 0; - else error->all(FLERR,"Illegal compute orientorder/atom command"); + if (iarg+2 > narg) error->all(FLERR,"Illegal compute orientorder/atom command"); + wlhatflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"components") == 0) { qlcompflag = 1; - if (iarg+2 > narg) - error->all(FLERR,"Illegal compute orientorder/atom command"); + if (iarg+2 > narg) error->all(FLERR,"Illegal compute orientorder/atom command"); qlcomp = utils::numeric(FLERR,arg[iarg+1],false,lmp); iqlcomp = -1; for (int il = 0; il < nqlist; il++) @@ -137,23 +125,18 @@ ComputeOrientOrderAtom::ComputeOrientOrderAtom(LAMMPS *lmp, int narg, char **arg iqlcomp = il; break; } - if (iqlcomp == -1) - error->all(FLERR,"Illegal compute orientorder/atom command"); + if (iqlcomp == -1) error->all(FLERR,"Illegal compute orientorder/atom command"); iarg += 2; } else if (strcmp(arg[iarg],"cutoff") == 0) { - if (iarg+2 > narg) - error->all(FLERR,"Illegal compute orientorder/atom command"); + if (iarg+2 > narg) error->all(FLERR,"Illegal compute orientorder/atom command"); double cutoff = utils::numeric(FLERR,arg[iarg+1],false,lmp); - if (cutoff <= 0.0) - error->all(FLERR,"Illegal compute orientorder/atom command"); + if (cutoff <= 0.0) error->all(FLERR,"Illegal compute orientorder/atom command"); cutsq = cutoff*cutoff; iarg += 2; } else if (strcmp(arg[iarg],"chunksize") == 0) { - if (iarg+2 > narg) - error->all(FLERR,"Illegal compute orientorder/atom command"); + if (iarg+2 > narg) error->all(FLERR,"Illegal compute orientorder/atom command"); chunksize = utils::numeric(FLERR,arg[iarg+1],false,lmp); - if (chunksize <= 0) - error->all(FLERR,"Illegal compute orientorder/atom command"); + if (chunksize <= 0) error->all(FLERR,"Illegal compute orientorder/atom command"); iarg += 2; } else error->all(FLERR,"Illegal compute orientorder/atom command"); } diff --git a/src/compute_temp_chunk.cpp b/src/compute_temp_chunk.cpp index 60014c7e21..8798835071 100644 --- a/src/compute_temp_chunk.cpp +++ b/src/compute_temp_chunk.cpp @@ -14,15 +14,16 @@ #include "compute_temp_chunk.h" -#include #include "atom.h" -#include "update.h" -#include "force.h" -#include "modify.h" #include "compute_chunk_atom.h" #include "domain.h" -#include "memory.h" #include "error.h" +#include "force.h" +#include "memory.h" +#include "modify.h" +#include "update.h" + +#include using namespace LAMMPS_NS; @@ -76,26 +77,20 @@ ComputeTempChunk::ComputeTempChunk(LAMMPS *lmp, int narg, char **arg) : while (iarg < narg) { if (strcmp(arg[iarg],"com") == 0) { - if (iarg+2 > narg) - error->all(FLERR,"Illegal compute temp/chunk command"); - if (strcmp(arg[iarg+1],"yes") == 0) comflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) comflag = 0; - else error->all(FLERR,"Illegal compute temp/chunk command"); + if (iarg+2 > narg) error->all(FLERR,"Illegal compute temp/chunk command"); + comflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"bias") == 0) { - if (iarg+2 > narg) - error->all(FLERR,"Illegal compute temp/chunk command"); + if (iarg+2 > narg) error->all(FLERR,"Illegal compute temp/chunk command"); biasflag = 1; id_bias = utils::strdup(arg[iarg+1]); iarg += 2; } else if (strcmp(arg[iarg],"adof") == 0) { - if (iarg+2 > narg) - error->all(FLERR,"Illegal compute temp/chunk command"); + if (iarg+2 > narg) error->all(FLERR,"Illegal compute temp/chunk command"); adof = utils::numeric(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"cdof") == 0) { - if (iarg+2 > narg) - error->all(FLERR,"Illegal compute temp/chunk command"); + if (iarg+2 > narg) error->all(FLERR,"Illegal compute temp/chunk command"); cdof = utils::numeric(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else error->all(FLERR,"Illegal compute temp/chunk command"); diff --git a/src/create_atoms.cpp b/src/create_atoms.cpp index cdcdc42a45..8baf6f88f7 100644 --- a/src/create_atoms.cpp +++ b/src/create_atoms.cpp @@ -151,9 +151,7 @@ void CreateAtoms::command(int narg, char **arg) iarg += 3; } else if (strcmp(arg[iarg],"remap") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal create_atoms command"); - if (strcmp(arg[iarg+1],"yes") == 0) remapflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) remapflag = 0; - else error->all(FLERR,"Illegal create_atoms command"); + remapflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"mol") == 0) { if (iarg+3 > narg) error->all(FLERR,"Illegal create_atoms command"); diff --git a/src/create_bonds.cpp b/src/create_bonds.cpp index 99cfdfa958..ab3bba7041 100644 --- a/src/create_bonds.cpp +++ b/src/create_bonds.cpp @@ -125,9 +125,7 @@ void CreateBonds::command(int narg, char **arg) while (iarg < narg) { if (strcmp(arg[iarg],"special") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal create_bonds command"); - if (strcmp(arg[iarg+1],"yes") == 0) specialflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) specialflag = 0; - else error->all(FLERR,"Illegal create_bonds command"); + specialflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else error->all(FLERR,"Illegal create_bonds command"); } diff --git a/src/delete_atoms.cpp b/src/delete_atoms.cpp index a9c25200d1..55b05e3d98 100644 --- a/src/delete_atoms.cpp +++ b/src/delete_atoms.cpp @@ -738,30 +738,21 @@ void DeleteAtoms::options(int narg, char **arg) while (iarg < narg) { if (strcmp(arg[iarg],"compress") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal delete_atoms command"); - if (strcmp(arg[iarg+1],"yes") == 0) compress_flag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) compress_flag = 0; - else error->all(FLERR,"Illegal delete_atoms command"); + compress_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"bond") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal delete_atoms command"); if (atom->molecular == Atom::ATOMIC) - error->all(FLERR,"Cannot delete_atoms bond yes for " - "non-molecular systems"); + error->all(FLERR,"Cannot delete_atoms bond yes for non-molecular systems"); if (atom->molecular == Atom::TEMPLATE) - error->all(FLERR,"Cannot use delete_atoms bond yes with " - "atom_style template"); - if (strcmp(arg[iarg+1],"yes") == 0) bond_flag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) bond_flag = 0; - else error->all(FLERR,"Illegal delete_atoms command"); + error->all(FLERR,"Cannot use delete_atoms bond yes with atom_style template"); + bond_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"mol") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal delete_atoms command"); if (atom->molecule_flag == 0) - error->all(FLERR,"Delete_atoms mol yes requires " - "atom attribute molecule"); - if (strcmp(arg[iarg+1],"yes") == 0) mol_flag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) mol_flag = 0; - else error->all(FLERR,"Illegal delete_atoms command"); + error->all(FLERR,"Delete_atoms mol yes requires atom attribute molecule"); + mol_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else error->all(FLERR,"Illegal delete_atoms command"); } diff --git a/src/dump.cpp b/src/dump.cpp index b42797833b..647fd3d38d 100644 --- a/src/dump.cpp +++ b/src/dump.cpp @@ -912,16 +912,12 @@ void Dump::modify_params(int narg, char **arg) while (iarg < narg) { if (strcmp(arg[iarg],"append") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); - if (strcmp(arg[iarg+1],"yes") == 0) append_flag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) append_flag = 0; - else error->all(FLERR,"Illegal dump_modify command"); + append_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"buffer") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); - if (strcmp(arg[iarg+1],"yes") == 0) buffer_flag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) buffer_flag = 0; - else error->all(FLERR,"Illegal dump_modify command"); + buffer_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); if (buffer_flag && buffer_allow == 0) error->all(FLERR,"Dump_modify buffer yes not allowed for this style"); iarg += 2; @@ -935,9 +931,7 @@ void Dump::modify_params(int narg, char **arg) } else if (strcmp(arg[iarg],"header") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); - if (strcmp(arg[iarg+1],"yes") == 0) write_header_flag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) write_header_flag = 0; - else error->all(FLERR,"Illegal dump_modify command"); + header_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"every") == 0) { @@ -960,8 +954,7 @@ void Dump::modify_params(int narg, char **arg) } else if (strcmp(arg[iarg],"fileper") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); if (!multiproc) - error->all(FLERR,"Cannot use dump_modify fileper " - "without % in dump file name"); + error->all(FLERR,"Cannot use dump_modify fileper without % in dump file name"); int nper = utils::inumeric(FLERR,arg[iarg+1],false,lmp); if (nper <= 0) error->all(FLERR,"Illegal dump_modify command"); @@ -986,16 +979,12 @@ void Dump::modify_params(int narg, char **arg) } else if (strcmp(arg[iarg],"first") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); - if (strcmp(arg[iarg+1],"yes") == 0) first_flag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) first_flag = 0; - else error->all(FLERR,"Illegal dump_modify command"); + first_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"flush") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); - if (strcmp(arg[iarg+1],"yes") == 0) flush_flag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) flush_flag = 0; - else error->all(FLERR,"Illegal dump_modify command"); + flush_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"format") == 0) { @@ -1032,8 +1021,7 @@ void Dump::modify_params(int narg, char **arg) } else if (strcmp(arg[iarg],"maxfiles") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); if (!multifile) - error->all(FLERR,"Cannot use dump_modify maxfiles " - "without * in dump file name"); + error->all(FLERR,"Cannot use dump_modify maxfiles without * in dump file name"); // wipe out existing storage if (maxfiles > 0) { for (int idx=0; idx < numfiles; ++idx) @@ -1053,8 +1041,7 @@ void Dump::modify_params(int narg, char **arg) } else if (strcmp(arg[iarg],"nfile") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); if (!multiproc) - error->all(FLERR,"Cannot use dump_modify nfile " - "without % in dump file name"); + error->all(FLERR,"Cannot use dump_modify nfile without % in dump file name"); int nfile = utils::inumeric(FLERR,arg[iarg+1],false,lmp); if (nfile <= 0) error->all(FLERR,"Illegal dump_modify command"); nfile = MIN(nfile,nprocs); @@ -1090,9 +1077,7 @@ void Dump::modify_params(int narg, char **arg) } else if (strcmp(arg[iarg],"pbc") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); - if (strcmp(arg[iarg+1],"yes") == 0) pbcflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) pbcflag = 0; - else error->all(FLERR,"Illegal dump_modify command"); + pbcflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"sort") == 0) { @@ -1117,16 +1102,12 @@ void Dump::modify_params(int narg, char **arg) } else if (strcmp(arg[iarg],"time") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); - if (strcmp(arg[iarg+1],"yes") == 0) time_flag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) time_flag = 0; - else error->all(FLERR,"Illegal dump_modify command"); + time_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"units") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal dump_modify command"); - if (strcmp(arg[iarg+1],"yes") == 0) unit_flag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) unit_flag = 0; - else error->all(FLERR,"Illegal dump_modify command"); + unit_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else { diff --git a/src/dump_atom.cpp b/src/dump_atom.cpp index 4d3660f9de..0dbd3b3278 100644 --- a/src/dump_atom.cpp +++ b/src/dump_atom.cpp @@ -116,15 +116,11 @@ int DumpAtom::modify_param(int narg, char **arg) { if (strcmp(arg[0],"scale") == 0) { if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); - if (strcmp(arg[1],"yes") == 0) scale_flag = 1; - else if (strcmp(arg[1],"no") == 0) scale_flag = 0; - else error->all(FLERR,"Illegal dump_modify command"); + scale_flag = utils::logical(FLERR,arg[1],false,lmp); return 2; } else if (strcmp(arg[0],"image") == 0) { if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); - if (strcmp(arg[1],"yes") == 0) image_flag = 1; - else if (strcmp(arg[1],"no") == 0) image_flag = 0; - else error->all(FLERR,"Illegal dump_modify command"); + image_flag = utils::logical(FLERR,arg[1],false,lmp); return 2; } return 0; diff --git a/src/dump_image.cpp b/src/dump_image.cpp index f6ca49851d..c073d152f8 100644 --- a/src/dump_image.cpp +++ b/src/dump_image.cpp @@ -47,7 +47,7 @@ using namespace MathConst; enum{NUMERIC,ATOM,TYPE,ELEMENT,ATTRIBUTE}; enum{SPHERE,LINE,TRI}; // also in some Body and Fix child classes enum{STATIC,DYNAMIC}; -enum{NO,YES}; +enum{NO=0,YES=1}; /* ---------------------------------------------------------------------- */ @@ -146,9 +146,7 @@ DumpImage::DumpImage(LAMMPS *lmp, int narg, char **arg) : while (iarg < narg) { if (strcmp(arg[iarg],"atom") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal dump image command"); - if (strcmp(arg[iarg+1],"yes") == 0) atomflag = YES; - else if (strcmp(arg[iarg+1],"no") == 0) atomflag = NO; - else error->all(FLERR,"Illegal dump image command"); + atomflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"adiam") == 0) { @@ -290,18 +288,14 @@ DumpImage::DumpImage(LAMMPS *lmp, int narg, char **arg) : } else if (strcmp(arg[iarg],"box") == 0) { if (iarg+3 > narg) error->all(FLERR,"Illegal dump image command"); - if (strcmp(arg[iarg+1],"yes") == 0) boxflag = YES; - else if (strcmp(arg[iarg+1],"no") == 0) boxflag = NO; - else error->all(FLERR,"Illegal dump image command"); + boxflag = utils::logical(FLERR,arg[iarg+1],false,lmp); boxdiam = utils::numeric(FLERR,arg[iarg+2],false,lmp); if (boxdiam < 0.0) error->all(FLERR,"Illegal dump image command"); iarg += 3; } else if (strcmp(arg[iarg],"axes") == 0) { if (iarg+3 > narg) error->all(FLERR,"Illegal dump image command"); - if (strcmp(arg[iarg+1],"yes") == 0) axesflag = YES; - else if (strcmp(arg[iarg+1],"no") == 0) axesflag = NO; - else error->all(FLERR,"Illegal dump image command"); + axesflag = utils::logical(FLERR,arg[iarg+1],false,lmp); axeslen = utils::numeric(FLERR,arg[iarg+2],false,lmp); axesdiam = utils::numeric(FLERR,arg[iarg+3],false,lmp); if (axeslen < 0.0 || axesdiam < 0.0) @@ -310,9 +304,7 @@ DumpImage::DumpImage(LAMMPS *lmp, int narg, char **arg) : } else if (strcmp(arg[iarg],"subbox") == 0) { if (iarg+3 > narg) error->all(FLERR,"Illegal dump image command"); - if (strcmp(arg[iarg+1],"yes") == 0) subboxflag = YES; - else if (strcmp(arg[iarg+1],"no") == 0) subboxflag = NO; - else error->all(FLERR,"Illegal dump image command"); + subboxflag = utils::logical(FLERR,arg[iarg+1],false,lmp); subboxdiam = utils::numeric(FLERR,arg[iarg+2],false,lmp); if (subboxdiam < 0.0) error->all(FLERR,"Illegal dump image command"); iarg += 3; @@ -327,9 +319,7 @@ DumpImage::DumpImage(LAMMPS *lmp, int narg, char **arg) : } else if (strcmp(arg[iarg],"ssao") == 0) { if (iarg+4 > narg) error->all(FLERR,"Illegal dump image command"); - if (strcmp(arg[iarg+1],"yes") == 0) image->ssao = YES; - else if (strcmp(arg[iarg+1],"no") == 0) image->ssao = NO; - else error->all(FLERR,"Illegal dump image command"); + image->ssao = utils::logical(FLERR,arg[iarg+1],false,lmp); int seed = utils::inumeric(FLERR,arg[iarg+2],false,lmp); if (seed <= 0) error->all(FLERR,"Illegal dump image command"); image->seed = seed; diff --git a/src/exceptions.h b/src/exceptions.h index d05e14eeb7..1df6c5d1a3 100644 --- a/src/exceptions.h +++ b/src/exceptions.h @@ -35,8 +35,8 @@ class LAMMPSAbortException : public LAMMPSException { public: MPI_Comm universe; - LAMMPSAbortException(const std::string &msg, MPI_Comm universe) : - LAMMPSException(msg), universe(universe) + LAMMPSAbortException(const std::string &msg, MPI_Comm _universe) : + LAMMPSException(msg), universe(_universe) { } }; diff --git a/src/fix.cpp b/src/fix.cpp index 8f5b60535c..996cd9b7d5 100644 --- a/src/fix.cpp +++ b/src/fix.cpp @@ -137,27 +137,19 @@ void Fix::modify_params(int narg, char **arg) while (iarg < narg) { if (strcmp(arg[iarg],"dynamic/dof") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix_modify command"); - if (strcmp(arg[iarg+1],"no") == 0) dynamic = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) dynamic = 1; - else error->all(FLERR,"Illegal fix_modify command"); + dynamic = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"energy") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix_modify command"); - if (strcmp(arg[iarg+1],"no") == 0) thermo_energy = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) { - if (energy_global_flag == 0 && energy_peratom_flag == 0) + thermo_energy = utils::logical(FLERR,arg[iarg+1],false,lmp); + if (thermo_energy && !energy_global_flag && !energy_peratom_flag) error->all(FLERR,"Illegal fix_modify command"); - thermo_energy = 1; - } else error->all(FLERR,"Illegal fix_modify command"); iarg += 2; } else if (strcmp(arg[iarg],"virial") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix_modify command"); - if (strcmp(arg[iarg+1],"no") == 0) thermo_virial = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) { - if (virial_global_flag == 0 && virial_peratom_flag == 0) - error->all(FLERR,"Illegal fix_modify command"); - thermo_virial = 1; - } else error->all(FLERR,"Illegal fix_modify command"); + thermo_virial = utils::logical(FLERR,arg[iarg+1],false,lmp); + if (thermo_virial && !virial_global_flag && !virial_peratom_flag) + error->all(FLERR,"Illegal fix_modify command"); iarg += 2; } else if (strcmp(arg[iarg],"respa") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix_modify command"); diff --git a/src/fix_adapt.cpp b/src/fix_adapt.cpp index 358cf8045f..766dc9cd74 100644 --- a/src/fix_adapt.cpp +++ b/src/fix_adapt.cpp @@ -158,21 +158,15 @@ nadapt(0), id_fix_diam(nullptr), id_fix_chg(nullptr), adapt(nullptr) while (iarg < narg) { if (strcmp(arg[iarg],"reset") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix adapt command"); - if (strcmp(arg[iarg+1],"no") == 0) resetflag = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) resetflag = 1; - else error->all(FLERR,"Illegal fix adapt command"); + resetflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"scale") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix adapt command"); - if (strcmp(arg[iarg+1],"no") == 0) scaleflag = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) scaleflag = 1; - else error->all(FLERR,"Illegal fix adapt command"); + scaleflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"mass") == 0) { if (iarg+2 > narg)error->all(FLERR,"Illegal fix adapt command"); - if (strcmp(arg[iarg+1],"no") == 0) massflag = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) massflag = 1; - else error->all(FLERR,"Illegal fix adapt command"); + massflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else error->all(FLERR,"Illegal fix adapt command"); } diff --git a/src/fix_box_relax.cpp b/src/fix_box_relax.cpp index e80a4db593..7988657339 100644 --- a/src/fix_box_relax.cpp +++ b/src/fix_box_relax.cpp @@ -196,21 +196,15 @@ FixBoxRelax::FixBoxRelax(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else if (strcmp(arg[iarg],"scalexy") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix box/relax command"); - if (strcmp(arg[iarg+1],"yes") == 0) scalexy = 1; - else if (strcmp(arg[iarg+1],"no") == 0) scalexy = 0; - else error->all(FLERR,"Illegal fix box/relax command"); + scalexy = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"scalexz") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix box/relax command"); - if (strcmp(arg[iarg+1],"yes") == 0) scalexz = 1; - else if (strcmp(arg[iarg+1],"no") == 0) scalexz = 0; - else error->all(FLERR,"Illegal fix box/relax command"); + scalexz = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"scaleyz") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix box/relax command"); - if (strcmp(arg[iarg+1],"yes") == 0) scaleyz = 1; - else if (strcmp(arg[iarg+1],"no") == 0) scaleyz = 0; - else error->all(FLERR,"Illegal fix box/relax command"); + scaleyz = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"fixedpoint") == 0) { if (iarg+4 > narg) error->all(FLERR,"Illegal fix box/relax command"); diff --git a/src/fix_deform.cpp b/src/fix_deform.cpp index 4d923ae7ff..71429ac0f8 100644 --- a/src/fix_deform.cpp +++ b/src/fix_deform.cpp @@ -1008,9 +1008,7 @@ void FixDeform::options(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg],"flip") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix deform command"); - if (strcmp(arg[iarg+1],"yes") == 0) flipflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) flipflag = 0; - else error->all(FLERR,"Illegal fix deform command"); + flipflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else error->all(FLERR,"Illegal fix deform command"); } diff --git a/src/fix_evaporate.cpp b/src/fix_evaporate.cpp index ceb9f52818..531dcf9ffd 100644 --- a/src/fix_evaporate.cpp +++ b/src/fix_evaporate.cpp @@ -14,19 +14,20 @@ #include "fix_evaporate.h" -#include #include "atom.h" #include "atom_vec.h" -#include "molecule.h" -#include "update.h" -#include "domain.h" -#include "region.h" #include "comm.h" +#include "domain.h" +#include "error.h" #include "force.h" #include "group.h" -#include "random_park.h" #include "memory.h" -#include "error.h" +#include "molecule.h" +#include "random_park.h" +#include "region.h" +#include "update.h" + +#include using namespace LAMMPS_NS; using namespace FixConst; @@ -69,9 +70,7 @@ FixEvaporate::FixEvaporate(LAMMPS *lmp, int narg, char **arg) : while (iarg < narg) { if (strcmp(arg[iarg],"molecule") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix evaporate command"); - if (strcmp(arg[iarg+1],"no") == 0) molflag = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) molflag = 1; - else error->all(FLERR,"Illegal fix evaporate command"); + molflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else error->all(FLERR,"Illegal fix evaporate command"); } diff --git a/src/fix_halt.cpp b/src/fix_halt.cpp index 3e207baae7..263386e2b0 100644 --- a/src/fix_halt.cpp +++ b/src/fix_halt.cpp @@ -34,7 +34,7 @@ using namespace FixConst; enum{BONDMAX,TLIMIT,DISKFREE,VARIABLE}; enum{LT,LE,GT,GE,EQ,NEQ,XOR}; enum{HARD,SOFT,CONTINUE}; -enum{NOMSG,YESMSG}; +enum{NOMSG=0,YESMSG=1}; /* ---------------------------------------------------------------------- */ @@ -102,9 +102,7 @@ FixHalt::FixHalt(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else if (strcmp(arg[iarg],"message") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix halt command"); - if (strcmp(arg[iarg+1],"no") == 0) msgflag = NOMSG; - else if (strcmp(arg[iarg+1],"yes") == 0) msgflag = YESMSG; - else error->all(FLERR,"Illegal fix halt command"); + msgflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"path") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix halt command"); diff --git a/src/fix_langevin.cpp b/src/fix_langevin.cpp index ef1cb4eeaf..6e770689dc 100644 --- a/src/fix_langevin.cpp +++ b/src/fix_langevin.cpp @@ -128,9 +128,7 @@ FixLangevin::FixLangevin(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else if (strcmp(arg[iarg],"omega") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix langevin command"); - if (strcmp(arg[iarg+1],"no") == 0) oflag = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) oflag = 1; - else error->all(FLERR,"Illegal fix langevin command"); + oflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"scale") == 0) { if (iarg+3 > narg) error->all(FLERR,"Illegal fix langevin command"); @@ -142,15 +140,11 @@ FixLangevin::FixLangevin(LAMMPS *lmp, int narg, char **arg) : iarg += 3; } else if (strcmp(arg[iarg],"tally") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix langevin command"); - if (strcmp(arg[iarg+1],"no") == 0) tallyflag = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) tallyflag = 1; - else error->all(FLERR,"Illegal fix langevin command"); + tallyflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"zero") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix langevin command"); - if (strcmp(arg[iarg+1],"no") == 0) zeroflag = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) zeroflag = 1; - else error->all(FLERR,"Illegal fix langevin command"); + zeroflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else error->all(FLERR,"Illegal fix langevin command"); } diff --git a/src/fix_nh.cpp b/src/fix_nh.cpp index c906000ec5..91be322d82 100644 --- a/src/fix_nh.cpp +++ b/src/fix_nh.cpp @@ -17,23 +17,25 @@ ------------------------------------------------------------------------- */ #include "fix_nh.h" -#include -#include + #include "atom.h" +#include "comm.h" +#include "compute.h" +#include "domain.h" +#include "error.h" +#include "fix_deform.h" #include "force.h" #include "group.h" -#include "comm.h" -#include "neighbor.h" #include "irregular.h" -#include "modify.h" -#include "fix_deform.h" -#include "compute.h" #include "kspace.h" -#include "update.h" -#include "respa.h" -#include "domain.h" #include "memory.h" -#include "error.h" +#include "modify.h" +#include "neighbor.h" +#include "respa.h" +#include "update.h" + +#include +#include using namespace LAMMPS_NS; using namespace FixConst; @@ -297,9 +299,7 @@ FixNH::FixNH(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else if (strcmp(arg[iarg],"mtk") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); - if (strcmp(arg[iarg+1],"yes") == 0) mtk_flag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) mtk_flag = 0; - else error->all(FLERR,"Illegal fix nvt/npt/nph command"); + mtk_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"tloop") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); @@ -318,27 +318,19 @@ FixNH::FixNH(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else if (strcmp(arg[iarg],"scalexy") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); - if (strcmp(arg[iarg+1],"yes") == 0) scalexy = 1; - else if (strcmp(arg[iarg+1],"no") == 0) scalexy = 0; - else error->all(FLERR,"Illegal fix nvt/npt/nph command"); + scalexy = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"scalexz") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); - if (strcmp(arg[iarg+1],"yes") == 0) scalexz = 1; - else if (strcmp(arg[iarg+1],"no") == 0) scalexz = 0; - else error->all(FLERR,"Illegal fix nvt/npt/nph command"); + scalexz = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"scaleyz") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); - if (strcmp(arg[iarg+1],"yes") == 0) scaleyz = 1; - else if (strcmp(arg[iarg+1],"no") == 0) scaleyz = 0; - else error->all(FLERR,"Illegal fix nvt/npt/nph command"); + scaleyz = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"flip") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); - if (strcmp(arg[iarg+1],"yes") == 0) flipflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) flipflag = 0; - else error->all(FLERR,"Illegal fix nvt/npt/nph command"); + flipflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"update") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix nvt/npt/nph command"); diff --git a/src/fix_print.cpp b/src/fix_print.cpp index fa1eba4842..df5b5f77ff 100644 --- a/src/fix_print.cpp +++ b/src/fix_print.cpp @@ -64,14 +64,12 @@ FixPrint::FixPrint(LAMMPS *lmp, int narg, char **arg) : else fp = fopen(arg[iarg+1],"a"); if (fp == nullptr) error->one(FLERR,"Cannot open fix print file {}: {}", - arg[iarg+1], utils::getsyserror()); + arg[iarg+1], utils::getsyserror()); } iarg += 2; } else if (strcmp(arg[iarg],"screen") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix print command"); - if (strcmp(arg[iarg+1],"yes") == 0) screenflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) screenflag = 0; - else error->all(FLERR,"Illegal fix print command"); + screenflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"title") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix print command"); diff --git a/src/fix_property_atom.cpp b/src/fix_property_atom.cpp index 8fcb0f2af0..f90d83af4b 100644 --- a/src/fix_property_atom.cpp +++ b/src/fix_property_atom.cpp @@ -151,9 +151,7 @@ FixPropertyAtom::FixPropertyAtom(LAMMPS *lmp, int narg, char **arg) : while (iarg < narg) { if (strcmp(arg[iarg],"ghost") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix property/atom command"); - if (strcmp(arg[iarg+1],"no") == 0) border = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) border = 1; - else error->all(FLERR,"Illegal fix property/atom command"); + border = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else error->all(FLERR,"Illegal fix property/atom command"); } diff --git a/src/fix_store_state.cpp b/src/fix_store_state.cpp index e4d1634a07..cd29e785ec 100644 --- a/src/fix_store_state.cpp +++ b/src/fix_store_state.cpp @@ -231,9 +231,7 @@ FixStoreState::FixStoreState(LAMMPS *lmp, int narg, char **arg) : while (iarg < narg) { if (strcmp(arg[iarg],"com") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix store/state command"); - if (strcmp(arg[iarg+1],"no") == 0) comflag = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) comflag = 1; - else error->all(FLERR,"Illegal fix store/state command"); + comflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else error->all(FLERR,"Illegal fix store/state command"); } @@ -246,16 +244,13 @@ FixStoreState::FixStoreState(LAMMPS *lmp, int narg, char **arg) : if (icompute < 0) error->all(FLERR,"Compute ID for fix store/state does not exist"); if (modify->compute[icompute]->peratom_flag == 0) - error->all(FLERR,"Fix store/state compute " - "does not calculate per-atom values"); + error->all(FLERR,"Fix store/state compute does not calculate per-atom values"); if (argindex[i] == 0 && modify->compute[icompute]->size_peratom_cols != 0) - error->all(FLERR,"Fix store/state compute does not " - "calculate a per-atom vector"); + error->all(FLERR,"Fix store/state compute does not calculate a per-atom vector"); if (argindex[i] && modify->compute[icompute]->size_peratom_cols == 0) error->all(FLERR, - "Fix store/state compute does not " - "calculate a per-atom array"); + "Fix store/state compute does not calculate a per-atom array"); if (argindex[i] && argindex[i] > modify->compute[icompute]->size_peratom_cols) error->all(FLERR, diff --git a/src/fix_wall.cpp b/src/fix_wall.cpp index bec669ff10..0c3623857e 100644 --- a/src/fix_wall.cpp +++ b/src/fix_wall.cpp @@ -128,15 +128,11 @@ FixWall::FixWall(LAMMPS *lmp, int narg, char **arg) : iarg += 2; } else if (strcmp(arg[iarg],"fld") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix wall command"); - if (strcmp(arg[iarg+1],"no") == 0) fldflag = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) fldflag = 1; - else error->all(FLERR,"Illegal fix wall command"); + fldflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"pbc") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix wall command"); - if (strcmp(arg[iarg+1],"yes") == 0) pbcflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) pbcflag = 0; - else error->all(FLERR,"Illegal fix wall command"); + pbcflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else error->all(FLERR,"Illegal fix wall command"); } diff --git a/src/force.cpp b/src/force.cpp index 62d9738206..6b7e9033ca 100644 --- a/src/force.cpp +++ b/src/force.cpp @@ -811,15 +811,11 @@ void Force::set_special(int narg, char **arg) iarg += 4; } else if (strcmp(arg[iarg],"angle") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal special_bonds command"); - if (strcmp(arg[iarg+1],"no") == 0) special_angle = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) special_angle = 1; - else error->all(FLERR,"Illegal special_bonds command"); + special_angle = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"dihedral") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal special_bonds command"); - if (strcmp(arg[iarg+1],"no") == 0) special_dihedral = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) special_dihedral = 1; - else error->all(FLERR,"Illegal special_bonds command"); + special_dihedral = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else error->all(FLERR,"Illegal special_bonds command"); } diff --git a/src/input.cpp b/src/input.cpp index f67438d635..833dbaa6df 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -1068,19 +1068,14 @@ void Input::partition() { if (narg < 3) error->all(FLERR,"Illegal partition command"); - int yesflag = 0; - if (strcmp(arg[0],"yes") == 0) yesflag = 1; - else if (strcmp(arg[0],"no") == 0) yesflag = 0; - else error->all(FLERR,"Illegal partition command"); - int ilo,ihi; + int yesflag = utils::logical(FLERR,arg[0],false,lmp); utils::bounds(FLERR,arg[1],1,universe->nworlds,ilo,ihi,error); // new command starts at the 3rd argument, // which must not be another partition command - if (strcmp(arg[2],"partition") == 0) - error->all(FLERR,"Illegal partition command"); + if (strcmp(arg[2],"partition") == 0) error->all(FLERR,"Illegal partition command"); char *cmd = strstr(line,arg[2]); @@ -1123,21 +1118,16 @@ void Input::print() if (strcmp(arg[iarg],"file") == 0) fp = fopen(arg[iarg+1],"w"); else fp = fopen(arg[iarg+1],"a"); if (fp == nullptr) - error->one(FLERR,"Cannot open print file {}: {}", - arg[iarg+1], utils::getsyserror()); + error->one(FLERR,"Cannot open print file {}: {}", arg[iarg+1], utils::getsyserror()); } iarg += 2; } else if (strcmp(arg[iarg],"screen") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal print command"); - if (strcmp(arg[iarg+1],"yes") == 0) screenflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) screenflag = 0; - else error->all(FLERR,"Illegal print command"); + screenflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"universe") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal print command"); - if (strcmp(arg[iarg+1],"yes") == 0) universeflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) universeflag = 0; - else error->all(FLERR,"Illegal print command"); + universeflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else error->all(FLERR,"Illegal print command"); } @@ -1632,16 +1622,10 @@ void Input::newton() int newton_pair=1,newton_bond=1; if (narg == 1) { - if (strcmp(arg[0],"off") == 0) newton_pair = newton_bond = 0; - else if (strcmp(arg[0],"on") == 0) newton_pair = newton_bond = 1; - else error->all(FLERR,"Illegal newton command"); + newton_pair = newton_bond = utils::logical(FLERR,arg[0],false,lmp); } else if (narg == 2) { - if (strcmp(arg[0],"off") == 0) newton_pair = 0; - else if (strcmp(arg[0],"on") == 0) newton_pair= 1; - else error->all(FLERR,"Illegal newton command"); - if (strcmp(arg[1],"off") == 0) newton_bond = 0; - else if (strcmp(arg[1],"on") == 0) newton_bond = 1; - else error->all(FLERR,"Illegal newton command"); + newton_pair = utils::logical(FLERR,arg[0],false,lmp); + newton_bond = utils::logical(FLERR,arg[1],false,lmp); } else error->all(FLERR,"Illegal newton command"); force->newton_pair = newton_pair; @@ -1838,11 +1822,13 @@ void Input::suffix() { if (narg < 1) error->all(FLERR,"Illegal suffix command"); - if (strcmp(arg[0],"off") == 0) lmp->suffix_enable = 0; - else if (strcmp(arg[0],"on") == 0) { - if (!lmp->suffix) - error->all(FLERR,"May only enable suffixes after defining one"); + const std::string firstarg = arg[0]; + + if ((firstarg == "off") || (firstarg == "no") || (firstarg == "false")) { + lmp->suffix_enable = 0; + } else if ((firstarg == "on") || (firstarg == "yes") || (firstarg == "true")) { lmp->suffix_enable = 1; + if (!lmp->suffix) error->all(FLERR,"May only enable suffixes after defining one"); } else { lmp->suffix_enable = 1; @@ -1850,7 +1836,7 @@ void Input::suffix() delete[] lmp->suffix2; lmp->suffix = lmp->suffix2 = nullptr; - if (strcmp(arg[0],"hybrid") == 0) { + if (firstarg == "hybrid") { if (narg != 3) error->all(FLERR,"Illegal suffix command"); lmp->suffix = utils::strdup(arg[1]); lmp->suffix2 = utils::strdup(arg[2]); diff --git a/src/kspace.cpp b/src/kspace.cpp index a18a9ca702..fb995fca8a 100644 --- a/src/kspace.cpp +++ b/src/kspace.cpp @@ -480,8 +480,7 @@ void KSpace::modify_params(int narg, char **arg) if (nx_pppm_6 == 0 && ny_pppm_6 == 0 && nz_pppm_6 == 0) gridflag_6 = 0; else if (nx_pppm_6 <= 0 || ny_pppm_6 <= 0 || nz_pppm_6 == 0) - error->all(FLERR,"Kspace_modify mesh/disp parameters must be all " - "zero or all positive"); + error->all(FLERR,"Kspace_modify mesh/disp parameters must be all zero or all positive"); else gridflag_6 = 1; iarg += 4; } else if (strcmp(arg[iarg],"order") == 0) { @@ -499,9 +498,7 @@ void KSpace::modify_params(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg],"overlap") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal kspace_modify command"); - if (strcmp(arg[iarg+1],"yes") == 0) overlap_allowed = 1; - else if (strcmp(arg[iarg+1],"no") == 0) overlap_allowed = 0; - else error->all(FLERR,"Illegal kspace_modify command"); + overlap_allowed = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"force") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal kspace_modify command"); @@ -535,21 +532,15 @@ void KSpace::modify_params(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg],"compute") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal kspace_modify command"); - if (strcmp(arg[iarg+1],"yes") == 0) compute_flag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) compute_flag = 0; - else error->all(FLERR,"Illegal kspace_modify command"); + compute_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"fftbench") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal kspace_modify command"); - if (strcmp(arg[iarg+1],"yes") == 0) fftbench = 1; - else if (strcmp(arg[iarg+1],"no") == 0) fftbench = 0; - else error->all(FLERR,"Illegal kspace_modify command"); + fftbench = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"collective") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal kspace_modify command"); - if (strcmp(arg[iarg+1],"yes") == 0) collective_flag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) collective_flag = 0; - else error->all(FLERR,"Illegal kspace_modify command"); + collective_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"diff") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal kspace_modify command"); @@ -559,9 +550,7 @@ void KSpace::modify_params(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg],"cutoff/adjust") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal kspace_modify command"); - if (strcmp(arg[iarg+1],"yes") == 0) adjust_cutoff_flag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) adjust_cutoff_flag = 0; - else error->all(FLERR,"Illegal kspace_modify command"); + adjust_cutoff_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"kmax/ewald") == 0) { if (iarg+4 > narg) error->all(FLERR,"Illegal kspace_modify command"); @@ -598,15 +587,11 @@ void KSpace::modify_params(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg],"pressure/scalar") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal kspace_modify command"); - if (strcmp(arg[iarg+1],"yes") == 0) scalar_pressure_flag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) scalar_pressure_flag = 0; - else error->all(FLERR,"Illegal kspace_modify command"); + scalar_pressure_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"disp/auto") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal kspace_modify command"); - if (strcmp(arg[iarg+1],"yes") == 0) auto_disp_flag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) auto_disp_flag = 0; - else error->all(FLERR,"Illegal kspace_modify command"); + auto_disp_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else { int n = modify_param(narg-iarg,&arg[iarg]); diff --git a/src/lammps.cpp b/src/lammps.cpp index 89c59bec3d..d9bb56d882 100644 --- a/src/lammps.cpp +++ b/src/lammps.cpp @@ -266,8 +266,11 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) : strcmp(arg[iarg],"-k") == 0) { if (iarg+2 > narg) error->universe_all(FLERR,"Invalid command-line argument"); - if (strcmp(arg[iarg+1],"on") == 0) kokkosflag = 1; - else if (strcmp(arg[iarg+1],"off") == 0) kokkosflag = 0; + const std::string kokkosarg = arg[iarg+1]; + if ((kokkosarg == "on") || (kokkosarg == "yes") || (kokkosarg == "true")) + kokkosflag = 1; + else if ((kokkosarg == "off") || (kokkosarg == "no") || (kokkosarg == "false")) + kokkosflag = 0; else error->universe_all(FLERR,"Invalid command-line argument"); iarg += 2; // delimit any extra args for the Kokkos instantiation diff --git a/src/lammpsplugin.h b/src/lammpsplugin.h index 93bf418893..5df0172763 100644 --- a/src/lammpsplugin.h +++ b/src/lammpsplugin.h @@ -15,8 +15,9 @@ #define LMP_LAMMPSPLUGIN_H // C style API and data structure required for dynamic loading - +#ifdef __cplusplus extern "C" { +#endif typedef void *(lammpsplugin_factory1) (void *); typedef void *(lammpsplugin_factory2) (void *, int, char **); @@ -41,6 +42,9 @@ typedef void (*lammpsplugin_initfunc)(void *, void *, void *); // to load a plugin; uses C bindings void lammpsplugin_init(void *, void *, void *); + +#ifdef __cplusplus } +#endif #endif diff --git a/src/min.cpp b/src/min.cpp index ab8b1a5235..4780cf31eb 100644 --- a/src/min.cpp +++ b/src/min.cpp @@ -705,15 +705,11 @@ void Min::modify_params(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg],"halfstepback") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal min_modify command"); - if (strcmp(arg[iarg+1],"yes") == 0) halfstepback_flag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) halfstepback_flag = 0; - else error->all(FLERR,"Illegal min_modify command"); + halfstepback_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"initialdelay") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal min_modify command"); - if (strcmp(arg[iarg+1],"yes") == 0) delaystep_start_flag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) delaystep_start_flag = 0; - else error->all(FLERR,"Illegal min_modify command"); + delaystep_start_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"vdfmax") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal min_modify command"); diff --git a/src/neighbor.cpp b/src/neighbor.cpp index 64691c5048..74bb3bf762 100644 --- a/src/neighbor.cpp +++ b/src/neighbor.cpp @@ -2410,15 +2410,11 @@ void Neighbor::modify_params(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg],"check") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal neigh_modify command"); - if (strcmp(arg[iarg+1],"yes") == 0) dist_check = 1; - else if (strcmp(arg[iarg+1],"no") == 0) dist_check = 0; - else error->all(FLERR,"Illegal neigh_modify command"); + dist_check = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"once") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal neigh_modify command"); - if (strcmp(arg[iarg+1],"yes") == 0) build_once = 1; - else if (strcmp(arg[iarg+1],"no") == 0) build_once = 0; - else error->all(FLERR,"Illegal neigh_modify command"); + build_once = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"page") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal neigh_modify command"); @@ -2438,9 +2434,7 @@ void Neighbor::modify_params(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg],"cluster") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal neigh_modify command"); - if (strcmp(arg[iarg+1],"yes") == 0) cluster_check = 1; - else if (strcmp(arg[iarg+1],"no") == 0) cluster_check = 0; - else error->all(FLERR,"Illegal neigh_modify command"); + cluster_check = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"include") == 0) { @@ -2527,6 +2521,7 @@ void Neighbor::modify_params(int narg, char **arg) int i; // Invalidate old user cutoffs + comm->ncollections_cutoff = 0; interval_collection_flag = 1; custom_collection_flag = 1; @@ -2558,9 +2553,10 @@ void Neighbor::modify_params(int narg, char **arg) error->all(FLERR,"Invalid collection/type command"); int ntypes = atom->ntypes; - int n, nlo, nhi, i, j, k; + int nlo, nhi, i, k; // Invalidate old user cutoffs + comm->ncollections_cutoff = 0; interval_collection_flag = 0; custom_collection_flag = 1; @@ -2568,10 +2564,12 @@ void Neighbor::modify_params(int narg, char **arg) memory->create(type2collection,ntypes+1,"neigh:type2collection"); // Erase previous mapping + for (i = 1; i <= ntypes; i++) type2collection[i] = -1; // For each custom range, define mapping for types in interval + for (i = 0; i < ncollections; i++){ std::vector words = Tokenizer(arg[iarg+2+i], ",").as_vector(); for (const auto &word : words) { @@ -2585,6 +2583,7 @@ void Neighbor::modify_params(int narg, char **arg) } // Check for undefined atom type + for (i = 1; i <= ntypes; i++){ if (type2collection[i] == -1) { error->all(FLERR,"Type missing in collection/type commnd"); diff --git a/src/pair.cpp b/src/pair.cpp index 38a21481cd..6805166150 100644 --- a/src/pair.cpp +++ b/src/pair.cpp @@ -167,9 +167,7 @@ void Pair::modify_params(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg],"shift") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal pair_modify command"); - if (strcmp(arg[iarg+1],"yes") == 0) offset_flag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) offset_flag = 0; - else error->all(FLERR,"Illegal pair_modify command"); + offset_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"table") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal pair_modify command"); @@ -193,15 +191,11 @@ void Pair::modify_params(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg],"tail") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal pair_modify command"); - if (strcmp(arg[iarg+1],"yes") == 0) tail_flag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) tail_flag = 0; - else error->all(FLERR,"Illegal pair_modify command"); + tail_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"compute") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal pair_modify command"); - if (strcmp(arg[iarg+1],"yes") == 0) compute_flag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) compute_flag = 0; - else error->all(FLERR,"Illegal pair_modify command"); + compute_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"nofdotr") == 0) { no_virial_fdotr_compute = 1; diff --git a/src/pair_hybrid.cpp b/src/pair_hybrid.cpp index 582cebdfb5..b5daa111da 100644 --- a/src/pair_hybrid.cpp +++ b/src/pair_hybrid.cpp @@ -921,8 +921,7 @@ void PairHybrid::modify_params(int narg, char **arg) again: if (iarg < narg && strcmp(arg[iarg],"special") == 0) { - if (narg < iarg+5) - error->all(FLERR,"Illegal pair_modify special command"); + if (narg < iarg+5) error->all(FLERR,"Illegal pair_modify special command"); modify_special(m,narg-iarg,&arg[iarg+1]); iarg += 5; goto again; @@ -932,13 +931,8 @@ again: // set flag to register TALLY computes accordingly if (iarg < narg && strcmp(arg[iarg],"compute/tally") == 0) { - if (narg < iarg+2) - error->all(FLERR,"Illegal pair_modify compute/tally command"); - if (strcmp(arg[iarg+1],"yes") == 0) { - compute_tally[m] = 1; - } else if (strcmp(arg[iarg+1],"no") == 0) { - compute_tally[m] = 0; - } else error->all(FLERR,"Illegal pair_modify compute/tally command"); + if (narg < iarg+2) error->all(FLERR,"Illegal pair_modify compute/tally command"); + compute_tally[m] = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; goto again; } diff --git a/src/read_dump.cpp b/src/read_dump.cpp index 4a7a483cb0..c09bd38c87 100644 --- a/src/read_dump.cpp +++ b/src/read_dump.cpp @@ -1217,32 +1217,26 @@ int ReadDump::fields_and_keywords(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg],"box") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal read_dump command"); - if (strcmp(arg[iarg+1],"yes") == 0) boxflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) boxflag = 0; - else error->all(FLERR,"Illegal read_dump command"); + boxflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"replace") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal read_dump command"); - if (strcmp(arg[iarg+1],"yes") == 0) replaceflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) replaceflag = 0; - else error->all(FLERR,"Illegal read_dump command"); + replaceflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"purge") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal read_dump command"); - if (strcmp(arg[iarg+1],"yes") == 0) purgeflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) purgeflag = 0; - else error->all(FLERR,"Illegal read_dump command"); + purgeflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"trim") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal read_dump command"); - if (strcmp(arg[iarg+1],"yes") == 0) trimflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) trimflag = 0; - else error->all(FLERR,"Illegal read_dump command"); + trimflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"add") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal read_dump command"); if (strcmp(arg[iarg+1],"yes") == 0) addflag = YESADD; else if (strcmp(arg[iarg+1],"no") == 0) addflag = NOADD; + else if (strcmp(arg[iarg+1],"true") == 0) addflag = YESADD; + else if (strcmp(arg[iarg+1],"false") == 0) addflag = NOADD; else if (strcmp(arg[iarg+1],"keep") == 0) addflag = KEEPADD; else error->all(FLERR,"Illegal read_dump command"); iarg += 2; @@ -1257,15 +1251,11 @@ int ReadDump::fields_and_keywords(int narg, char **arg) iarg += 3; } else if (strcmp(arg[iarg],"scaled") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal read_dump command"); - if (strcmp(arg[iarg+1],"yes") == 0) scaleflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) scaleflag = 0; - else error->all(FLERR,"Illegal read_dump command"); + scaleflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"wrapped") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal read_dump command"); - if (strcmp(arg[iarg+1],"yes") == 0) wrapflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) wrapflag = 0; - else error->all(FLERR,"Illegal read_dump command"); + wrapflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"format") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal read_dump command"); diff --git a/src/rerun.cpp b/src/rerun.cpp index f9bb507a11..ce21fbc2b8 100644 --- a/src/rerun.cpp +++ b/src/rerun.cpp @@ -106,11 +106,7 @@ void Rerun::command(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg],"post") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal rerun command"); - if (strcmp(arg[iarg+1],"yes") == 0) { - postflag = 1; - } else if (strcmp(arg[iarg+1],"no") == 0) { - postflag = 0; - } else error->all(FLERR,"Illegal rerun command"); + postflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"dump") == 0) { break; diff --git a/src/reset_atom_ids.cpp b/src/reset_atom_ids.cpp index 3aea800b6f..822490ffc8 100644 --- a/src/reset_atom_ids.cpp +++ b/src/reset_atom_ids.cpp @@ -69,9 +69,7 @@ void ResetIDs::command(int narg, char **arg) while (iarg < narg) { if (strcmp(arg[iarg],"sort") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal reset_atom_ids command"); - if (strcmp(arg[iarg+1],"yes") == 0) sortflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) sortflag = 0; - else error->all(FLERR,"Illegal reset_atom_ids command"); + sortflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else error->all(FLERR,"Illegal reset_atom_ids command"); } diff --git a/src/reset_mol_ids.cpp b/src/reset_mol_ids.cpp index 3ddef738d2..424b4bcb6c 100644 --- a/src/reset_mol_ids.cpp +++ b/src/reset_mol_ids.cpp @@ -77,15 +77,11 @@ void ResetMolIDs::command(int narg, char **arg) while (iarg < narg) { if (strcmp(arg[iarg],"compress") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal reset_mol_ids command"); - if (strcmp(arg[iarg+1],"yes") == 0) compressflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) compressflag = 0; - else error->all(FLERR,"Illegal reset_mol_ids command"); + compressflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"single") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal reset_mol_ids command"); - if (strcmp(arg[iarg+1],"yes") == 0) singleflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) singleflag = 0; - else error->all(FLERR,"Illegal reset_mol_ids command"); + singleflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"offset") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal reset_mol_ids command"); diff --git a/src/run.cpp b/src/run.cpp index 2d8b4816a4..a026580c83 100644 --- a/src/run.cpp +++ b/src/run.cpp @@ -77,15 +77,11 @@ void Run::command(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg],"pre") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal run command"); - if (strcmp(arg[iarg+1],"no") == 0) preflag = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) preflag = 1; - else error->all(FLERR,"Illegal run command"); + preflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"post") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal run command"); - if (strcmp(arg[iarg+1],"no") == 0) postflag = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) postflag = 1; - else error->all(FLERR,"Illegal run command"); + postflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; // all remaining args are commands diff --git a/src/thermo.cpp b/src/thermo.cpp index eaf208c2eb..434012870b 100644 --- a/src/thermo.cpp +++ b/src/thermo.cpp @@ -556,16 +556,12 @@ void Thermo::modify_params(int narg, char **arg) } else if (strcmp(arg[iarg],"norm") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal thermo_modify command"); normuserflag = 1; - if (strcmp(arg[iarg+1],"no") == 0) normuser = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) normuser = 1; - else error->all(FLERR,"Illegal thermo_modify command"); + normuser = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"flush") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal thermo_modify command"); - if (strcmp(arg[iarg+1],"no") == 0) flushflag = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) flushflag = 1; - else error->all(FLERR,"Illegal thermo_modify command"); + flushflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"line") == 0) { diff --git a/src/tokenizer.cpp b/src/tokenizer.cpp index 538cd716ad..43660d68ec 100644 --- a/src/tokenizer.cpp +++ b/src/tokenizer.cpp @@ -49,8 +49,8 @@ TokenizerException::TokenizerException(const std::string &msg, const std::string * \param str string to be processed * \param separators string with separator characters (default: " \t\r\n\f") */ -Tokenizer::Tokenizer(const std::string &str, const std::string &separators) : - text(str), separators(separators), start(0), ntokens(std::string::npos) +Tokenizer::Tokenizer(const std::string &str, const std::string &_separators) : + text(str), separators(_separators), start(0), ntokens(std::string::npos) { // replace known UTF-8 characters with ASCII equivalents if (utils::has_utf8(text)) text = utils::utf8_subst(text); diff --git a/src/utils.cpp b/src/utils.cpp index b2a1e801f7..2feba5db97 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -25,6 +25,7 @@ #include "tokenizer.h" #include "update.h" +#include #include #include #include @@ -347,6 +348,47 @@ std::string utils::check_packages_for_style(const std::string &style, const std: return errmsg; } +/* ---------------------------------------------------------------------- + read a boolean value from a string + transform to lower case before checking + generate an error if is not a legitimate boolean + called by various commands to check validity of their arguments +------------------------------------------------------------------------- */ + +int utils::logical(const char *file, int line, const char *str, bool do_abort, LAMMPS *lmp) +{ + int n = 0; + + if (str) n = strlen(str); + if (n == 0) { + const char msg[] = "Expected boolean parameter instead of NULL or empty string " + "in input script or data file"; + if (do_abort) + lmp->error->one(file, line, msg); + else + lmp->error->all(file, line, msg); + } + + // convert to ascii and lowercase + std::string buf(str); + if (has_utf8(buf)) buf = utf8_subst(buf); + + int rv = 0; + if ((buf == "yes") || (buf == "on") || (buf == "true") || (buf == "1")) { + rv = 1; + } else if ((buf == "no") || (buf == "off") || (buf == "false") || (buf == "0")) { + rv = 0; + } else { + std::string msg("Expected boolean parameter instead of '"); + msg += buf + "' in input script or data file"; + if (do_abort) + lmp->error->one(file, line, msg); + else + lmp->error->all(file, line, msg); + } + return rv; +} + /* ---------------------------------------------------------------------- read a floating point value from a string generate an error if not a legitimate floating point value diff --git a/src/utils.h b/src/utils.h index 37d52f2614..4dd4eea090 100644 --- a/src/utils.h +++ b/src/utils.h @@ -158,6 +158,19 @@ namespace utils { std::string check_packages_for_style(const std::string &style, const std::string &name, LAMMPS *lmp); + /*! Convert a string to a boolean while checking whether it is a valid boolean term. + * Valid terms are 'yes', 'no', 'true', 'false', 'on', 'off', and '1', '0'. Only + * lower case is accepted. + * + * \param file name of source file for error message + * \param line line number in source file for error message + * \param str string to be converted to logical + * \param do_abort determines whether to call Error::one() or Error::all() + * \param lmp pointer to top-level LAMMPS class instance + * \return 1 if string resolves to "true", otherwise 0 */ + + int logical(const char *file, int line, const char *str, bool do_abort, LAMMPS *lmp); + /*! Convert a string to a floating point number while checking * if it is a valid floating point or integer number * diff --git a/src/velocity.cpp b/src/velocity.cpp index a42c820d8c..4a449d00e7 100644 --- a/src/velocity.cpp +++ b/src/velocity.cpp @@ -35,6 +35,7 @@ using namespace LAMMPS_NS; enum{CREATE,SET,SCALE,RAMP,ZERO}; enum{ALL,LOCAL,GEOM}; +enum{UNIFORM,GAUSSIAN}; enum{NONE,CONSTANT,EQUAL,ATOM}; #define WARMUP 100 @@ -83,7 +84,7 @@ void Velocity::command(int narg, char **arg) // set defaults temperature = nullptr; - dist_flag = 0; + dist_flag = UNIFORM; sum_flag = 0; momentum_flag = 1; rotation_flag = 0; @@ -148,11 +149,12 @@ void Velocity::init_external(const char *extgroup) groupbit = group->bitmask[igroup]; temperature = nullptr; - dist_flag = 0; + dist_flag = UNIFORM; sum_flag = 0; momentum_flag = 1; rotation_flag = 0; loop_flag = ALL; + rfix = -1; scale_flag = 1; bias_flag = 0; } @@ -274,11 +276,11 @@ void Velocity::create(double t_desired, int seed) int natoms = static_cast (atom->natoms); for (i = 1; i <= natoms; i++) { - if (dist_flag == 0) { + if (dist_flag == UNIFORM) { vx = random->uniform() - 0.5; vy = random->uniform() - 0.5; vz = random->uniform() - 0.5; - } else { + } else { // GAUSSIAN vx = random->gaussian(); vy = random->gaussian(); vz = random->gaussian(); @@ -309,11 +311,11 @@ void Velocity::create(double t_desired, int seed) for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - if (dist_flag == 0) { + if (dist_flag == UNIFORM) { vx = random->uniform() - 0.5; vy = random->uniform() - 0.5; vz = random->uniform() - 0.5; - } else { + } else { // GAUSSIAN vx = random->gaussian(); vy = random->gaussian(); vz = random->gaussian(); @@ -334,11 +336,11 @@ void Velocity::create(double t_desired, int seed) for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { random->reset(seed,x[i]); - if (dist_flag == 0) { + if (dist_flag == UNIFORM) { vx = random->uniform() - 0.5; vy = random->uniform() - 0.5; vz = random->uniform() - 0.5; - } else { + } else { // GAUSSIAN vx = random->gaussian(); vy = random->gaussian(); vz = random->gaussian(); @@ -823,27 +825,21 @@ void Velocity::options(int narg, char **arg) while (iarg < narg) { if (strcmp(arg[iarg],"dist") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command"); - if (strcmp(arg[iarg+1],"uniform") == 0) dist_flag = 0; - else if (strcmp(arg[iarg+1],"gaussian") == 0) dist_flag = 1; + if (strcmp(arg[iarg+1],"uniform") == 0) dist_flag = UNIFORM; + else if (strcmp(arg[iarg+1],"gaussian") == 0) dist_flag = GAUSSIAN; else error->all(FLERR,"Illegal velocity command"); iarg += 2; } else if (strcmp(arg[iarg],"sum") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command"); - if (strcmp(arg[iarg+1],"no") == 0) sum_flag = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) sum_flag = 1; - else error->all(FLERR,"Illegal velocity command"); + sum_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"mom") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command"); - if (strcmp(arg[iarg+1],"no") == 0) momentum_flag = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) momentum_flag = 1; - else error->all(FLERR,"Illegal velocity command"); + momentum_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"rot") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command"); - if (strcmp(arg[iarg+1],"no") == 0) rotation_flag = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) rotation_flag = 1; - else error->all(FLERR,"Illegal velocity command"); + rotation_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"temp") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command"); @@ -855,9 +851,7 @@ void Velocity::options(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg],"bias") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command"); - if (strcmp(arg[iarg+1],"no") == 0) bias_flag = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) bias_flag = 1; - else error->all(FLERR,"Illegal velocity command"); + bias_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"loop") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command"); diff --git a/src/version.h b/src/version.h index 6b4ecca26b..c1b2b627a8 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define LAMMPS_VERSION "20 Sep 2021" +#define LAMMPS_VERSION "29 Sep 2021" diff --git a/tools/singularity/README.md b/tools/singularity/README.md index 3f7b69d409..bd13d75ad7 100644 --- a/tools/singularity/README.md +++ b/tools/singularity/README.md @@ -10,12 +10,6 @@ workstation, e.g. when bugs are reported that can only be reproduced on a specific OS or with specific (mostly older) versions of tools, compilers, or libraries. -Ready-to-use container images built from some these definition files are -occasionally uploaded to the container library at sylabs.io. They -can be found here: https://cloud.sylabs.io/library/lammps/default/lammps_development# -and will be signed with a GPG key that has the fingerprint: -EEA103764C6C633EDC8AC428D9B44E93BF0C375A - Here is a workflow for testing a compilation of LAMMPS with a locally built CentOS 7.x singularity container. @@ -30,34 +24,3 @@ cmake -C ../cmake/presets/most.cmake ../cmake make ``` -And here is the equivalent workflow for testing a compilation of LAMMPS -using a pre-built Ubuntu 18.04LTS singularity container. - -``` -cd some/work/directory -git clone --depth 500 git://github.com/lammps/lammps.git lammps -mkdir build-ubuntu18 -cd build-ubuntu18 -singularity pull library://lammps/default/lammps_development:ubuntu18.04 -singularity exec lammps_development_ubuntu18.04.sif bash --login -cmake -C ../cmake/presets/most.cmake ../cmake -make -``` - -| Currently available: | Description | -| ------------------------------ | ---------------------------------------------- | -| centos7.def | CentOS 7.x with EPEL enabled, no LaTeX | -| centos8.def | CentOS 8.x with EPEL enabled | -| fedora34_mingw.def | Fedora 34 with MinGW cross-compiler toolchain | -| ubuntu16.04.def | Ubuntu 16.04LTS with MPI == OpenMPI, no LaTeX | -| ubuntu18.04.def | Ubuntu 18.04LTS with MPI == OpenMPI | -| ubuntu18.04_amd_rocm.def | Ubuntu 18.04LTS with AMD ROCm toolkit | -| ubuntu18.04_gpu.def | Ubuntu 18.04LTS with -"- plus Nvidia CUDA 11.0 | -| ubuntu18.04_nvidia.def | Ubuntu 18.04LTS with Nvidia CUDA 11.0 toolkit | -| ubuntu18.04_intel_opencl.def | Ubuntu 18.04LTS with Intel OpenCL runtime | -| ubuntu20.04.def | Ubuntu 20.04LTS with MPI == OpenMPI | -| ubuntu20.04_amd_rocm.def | Ubuntu 20.04LTS with AMD ROCm toolkit | -| ubuntu20.04_gpu.def | Ubuntu 20.04LTS with -"- plus Nvidia CUDA 11.0 | -| ubuntu20.04_nvidia.def | Ubuntu 20.04LTS with Nvidia CUDA 11.0 toolkit | -| ubuntu20.04_intel_opencl.def | Ubuntu 20.04LTS with Intel OpenCL runtime | -| ------------------------------ | ---------------------------------------------- | diff --git a/tools/swig/CMakeLists.txt b/tools/swig/CMakeLists.txt index 204b351ed6..966837dc2f 100644 --- a/tools/swig/CMakeLists.txt +++ b/tools/swig/CMakeLists.txt @@ -90,7 +90,15 @@ if(BUILD_SWIG_TCL) # build loadable Tcl module set_property(SOURCE lammps.i PROPERTY SWIG_MODULE_NAME tcllammps) swig_add_library(tcllammps TYPE MODULE LANGUAGE tcl SOURCES lammps.i) - find_package(TCL REQUIRED) + find_package(TCL) + if(NOT TCL_FOUND) + message(FATAL_ERROR "Tcl development headers and libraries are required") + endif() + find_package(TclStub) + if(TCL_STUB_LIBRARY) + target_compile_definitions(tcllammps PRIVATE USE_TCL_STUBS) + target_link_libraries(tcllammps PRIVATE ${TCL_STUB_LIBRARY}) + endif() target_include_directories(tcllammps PRIVATE ${TCL_INCLUDE_PATH}) swig_link_libraries(tcllammps PRIVATE lammps ${TCL_LIBRARY}) # build extended Tcl shell binary diff --git a/unittest/commands/test_reset_ids.cpp b/unittest/commands/test_reset_ids.cpp index bc9d39dc37..221859e5c3 100644 --- a/unittest/commands/test_reset_ids.cpp +++ b/unittest/commands/test_reset_ids.cpp @@ -637,10 +637,10 @@ TEST_F(ResetIDsTest, DeathTests) TEST_FAILURE(".*ERROR: Illegal reset_mol_ids command.*", command("reset_mol_ids all compress");); - TEST_FAILURE(".*ERROR: Illegal reset_mol_ids command.*", + TEST_FAILURE(".*ERROR: Expected boolean parameter instead of 'xxx'.*", command("reset_mol_ids all compress xxx");); TEST_FAILURE(".*ERROR: Illegal reset_mol_ids command.*", command("reset_mol_ids all single");); - TEST_FAILURE(".*ERROR: Illegal reset_mol_ids command.*", + TEST_FAILURE(".*ERROR: Expected boolean parameter instead of 'xxx'.*", command("reset_mol_ids all single xxx");); } diff --git a/unittest/commands/test_simple_commands.cpp b/unittest/commands/test_simple_commands.cpp index 8b57c26af1..31acf6d460 100644 --- a/unittest/commands/test_simple_commands.cpp +++ b/unittest/commands/test_simple_commands.cpp @@ -160,7 +160,8 @@ TEST_F(SimpleCommandsTest, Partition) BEGIN_HIDE_OUTPUT(); command("echo none"); END_HIDE_OUTPUT(); - TEST_FAILURE(".*ERROR: Illegal partition command .*", command("partition xxx 1 echo none");); + TEST_FAILURE(".*ERROR: Expected boolean parameter instead of 'xxx'.*", + command("partition xxx 1 echo none");); TEST_FAILURE(".*ERROR: Numeric index 2 is out of bounds.*", command("partition yes 2 echo none");); @@ -248,6 +249,8 @@ TEST_F(SimpleCommandsTest, Suffix) ASSERT_EQ(lmp->suffix2, nullptr); TEST_FAILURE(".*ERROR: May only enable suffixes after defining one.*", command("suffix on");); + TEST_FAILURE(".*ERROR: May only enable suffixes after defining one.*", command("suffix yes");); + TEST_FAILURE(".*ERROR: May only enable suffixes after defining one.*", command("suffix true");); BEGIN_HIDE_OUTPUT(); command("suffix one"); @@ -271,6 +274,26 @@ TEST_F(SimpleCommandsTest, Suffix) END_HIDE_OUTPUT(); ASSERT_EQ(lmp->suffix_enable, 0); + BEGIN_HIDE_OUTPUT(); + command("suffix yes"); + END_HIDE_OUTPUT(); + ASSERT_EQ(lmp->suffix_enable, 1); + + BEGIN_HIDE_OUTPUT(); + command("suffix no"); + END_HIDE_OUTPUT(); + ASSERT_EQ(lmp->suffix_enable, 0); + + BEGIN_HIDE_OUTPUT(); + command("suffix true"); + END_HIDE_OUTPUT(); + ASSERT_EQ(lmp->suffix_enable, 1); + + BEGIN_HIDE_OUTPUT(); + command("suffix false"); + END_HIDE_OUTPUT(); + ASSERT_EQ(lmp->suffix_enable, 0); + BEGIN_HIDE_OUTPUT(); command("suffix on"); END_HIDE_OUTPUT(); diff --git a/unittest/formats/CMakeLists.txt b/unittest/formats/CMakeLists.txt index b4c637edfb..93b48ac1b4 100644 --- a/unittest/formats/CMakeLists.txt +++ b/unittest/formats/CMakeLists.txt @@ -7,6 +7,10 @@ add_executable(test_image_flags test_image_flags.cpp) target_link_libraries(test_image_flags PRIVATE lammps GTest::GMock GTest::GTest) add_test(NAME ImageFlags COMMAND test_image_flags WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) +add_executable(test_input_convert test_input_convert.cpp) +target_link_libraries(test_input_convert PRIVATE lammps GTest::GMockMain GTest::GMock GTest::GTest) +add_test(NAME InputConvert COMMAND test_input_convert WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + add_executable(test_molecule_file test_molecule_file.cpp) target_link_libraries(test_molecule_file PRIVATE lammps GTest::GMock GTest::GTest) add_test(NAME MoleculeFile COMMAND test_molecule_file WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/unittest/formats/test_dump_atom.cpp b/unittest/formats/test_dump_atom.cpp index b11dd4e800..8a3dab44a4 100644 --- a/unittest/formats/test_dump_atom.cpp +++ b/unittest/formats/test_dump_atom.cpp @@ -120,7 +120,7 @@ TEST_F(DumpAtomTest, format_line_run0) TEST_F(DumpAtomTest, no_scale_run0) { auto dump_file = "dump_no_scale_run0.melt"; - generate_dump(dump_file, "scale no", 0); + generate_dump(dump_file, "scale off", 0); ASSERT_FILE_EXISTS(dump_file); auto lines = read_lines(dump_file); @@ -135,7 +135,7 @@ TEST_F(DumpAtomTest, no_scale_run0) TEST_F(DumpAtomTest, no_buffer_no_scale_run0) { auto dump_file = "dump_no_buffer_no_scale_run0.melt"; - generate_dump(dump_file, "buffer no scale no", 0); + generate_dump(dump_file, "buffer false scale false", 0); ASSERT_FILE_EXISTS(dump_file); auto lines = read_lines(dump_file); @@ -150,7 +150,7 @@ TEST_F(DumpAtomTest, no_buffer_no_scale_run0) TEST_F(DumpAtomTest, no_buffer_with_scale_run0) { auto dump_file = "dump_no_buffer_with_scale_run0.melt"; - generate_dump(dump_file, "buffer no scale yes", 0); + generate_dump(dump_file, "buffer 0 scale 1", 0); ASSERT_FILE_EXISTS(dump_file); auto lines = read_lines(dump_file); @@ -165,7 +165,7 @@ TEST_F(DumpAtomTest, no_buffer_with_scale_run0) TEST_F(DumpAtomTest, with_image_run0) { auto dump_file = "dump_with_image_run0.melt"; - generate_dump(dump_file, "scale no image yes", 0); + generate_dump(dump_file, "scale no image on", 0); ASSERT_FILE_EXISTS(dump_file); auto lines = read_lines(dump_file); @@ -178,7 +178,7 @@ TEST_F(DumpAtomTest, with_image_run0) TEST_F(DumpAtomTest, with_units_run0) { auto dump_file = "dump_with_units_run0.melt"; - generate_dump(dump_file, "scale no units yes", 0); + generate_dump(dump_file, "scale false units 1", 0); ASSERT_FILE_EXISTS(dump_file); auto lines = read_lines(dump_file); @@ -193,7 +193,7 @@ TEST_F(DumpAtomTest, with_units_run0) TEST_F(DumpAtomTest, with_time_run0) { auto dump_file = "dump_with_time_run0.melt"; - generate_dump(dump_file, "scale no time yes", 0); + generate_dump(dump_file, "scale off time true", 0); ASSERT_FILE_EXISTS(dump_file); auto lines = read_lines(dump_file); @@ -207,7 +207,7 @@ TEST_F(DumpAtomTest, with_time_run0) TEST_F(DumpAtomTest, with_units_run1) { auto dump_file = "dump_with_units_run1.melt"; - generate_dump(dump_file, "scale no units yes", 1); + generate_dump(dump_file, "scale 0 units on", 1); ASSERT_FILE_EXISTS(dump_file); auto lines = read_lines(dump_file); @@ -222,7 +222,7 @@ TEST_F(DumpAtomTest, with_units_run1) TEST_F(DumpAtomTest, no_buffer_with_scale_and_image_run0) { auto dump_file = "dump_no_buffer_with_scale_and_image_run0.melt"; - generate_dump(dump_file, "buffer no scale yes image yes", 0); + generate_dump(dump_file, "buffer 0 scale 1 image true", 0); ASSERT_FILE_EXISTS(dump_file); auto lines = read_lines(dump_file); @@ -253,7 +253,7 @@ TEST_F(DumpAtomTest, triclinic_with_units_run0) { auto dump_file = "dump_triclinic_with_units_run0.melt"; enable_triclinic(); - generate_dump(dump_file, "units yes", 0); + generate_dump(dump_file, "units on", 0); ASSERT_FILE_EXISTS(dump_file); auto lines = read_lines(dump_file); @@ -271,7 +271,7 @@ TEST_F(DumpAtomTest, triclinic_with_time_run0) { auto dump_file = "dump_triclinic_with_time_run0.melt"; enable_triclinic(); - generate_dump(dump_file, "time yes", 0); + generate_dump(dump_file, "time on", 0); ASSERT_FILE_EXISTS(dump_file); auto lines = read_lines(dump_file); @@ -548,7 +548,8 @@ TEST_F(DumpAtomTest, dump_modify_scale_invalid) command("dump id all atom 1 dump.txt"); END_HIDE_OUTPUT(); - TEST_FAILURE(".*Illegal dump_modify command.*", command("dump_modify id scale true");); + TEST_FAILURE(".*Expected boolean parameter instead of 'xxx'.*", + command("dump_modify id scale xxx");); } TEST_F(DumpAtomTest, dump_modify_image_invalid) @@ -557,7 +558,8 @@ TEST_F(DumpAtomTest, dump_modify_image_invalid) command("dump id all atom 1 dump.txt"); END_HIDE_OUTPUT(); - TEST_FAILURE(".*Illegal dump_modify command.*", command("dump_modify id image true");); + TEST_FAILURE(".*Expected boolean parameter instead of 'xxx'.*", + command("dump_modify id image xxx");); } TEST_F(DumpAtomTest, dump_modify_invalid) diff --git a/unittest/formats/test_input_convert.cpp b/unittest/formats/test_input_convert.cpp new file mode 100644 index 0000000000..0ff6878b13 --- /dev/null +++ b/unittest/formats/test_input_convert.cpp @@ -0,0 +1,179 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, 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 "../testing/core.h" +#include "gmock/gmock.h" +#include "gtest/gtest.h" + +#include "library.h" +#include "utils.h" + +// whether to print verbose output (i.e. not capturing LAMMPS screen output). +bool verbose = false; + +using LAMMPS_NS::utils::split_words; + +namespace LAMMPS_NS { +using ::testing::Eq; + +class InputConvertTest : public LAMMPSTest { +protected: + void SetUp() override + { + testbinary = "InputConvertTest"; + LAMMPSTest::SetUp(); + ASSERT_NE(lmp, nullptr); + } + + void TearDown() override { LAMMPSTest::TearDown(); } +}; + +TEST_F(InputConvertTest, logical) +{ + EXPECT_EQ(utils::logical(FLERR, "yes", false, lmp), 1); + EXPECT_EQ(utils::logical(FLERR, "true", false, lmp), 1); + EXPECT_EQ(utils::logical(FLERR, "on", false, lmp), 1); + EXPECT_EQ(utils::logical(FLERR, "1", false, lmp), 1); + EXPECT_EQ(utils::logical(FLERR, "no", false, lmp), 0); + EXPECT_EQ(utils::logical(FLERR, "false", false, lmp), 0); + EXPECT_EQ(utils::logical(FLERR, "off", false, lmp), 0); + EXPECT_EQ(utils::logical(FLERR, "0", false, lmp), 0); + + TEST_FAILURE(".*ERROR: Expected boolean parameter instead of.*", + utils::logical(FLERR, "YES", false, lmp);); + TEST_FAILURE(".*ERROR: Expected boolean parameter instead of.*", + utils::logical(FLERR, "Yes", false, lmp);); + TEST_FAILURE(".*ERROR: Expected boolean parameter instead of.*", + utils::logical(FLERR, "On", false, lmp);); + TEST_FAILURE(".*ERROR: Expected boolean parameter instead of.*", + utils::logical(FLERR, "ON", false, lmp);); + TEST_FAILURE(".*ERROR: Expected boolean parameter instead of.*", + utils::logical(FLERR, "TRUE", false, lmp);); + TEST_FAILURE(".*ERROR: Expected boolean parameter instead of.*", + utils::logical(FLERR, "True", false, lmp);); + TEST_FAILURE(".*ERROR: Expected boolean parameter instead of.*", + utils::logical(FLERR, "NO", false, lmp);); + TEST_FAILURE(".*ERROR: Expected boolean parameter instead of.*", + utils::logical(FLERR, "No", false, lmp);); + TEST_FAILURE(".*ERROR: Expected boolean parameter instead of.*", + utils::logical(FLERR, "Off", false, lmp);); + TEST_FAILURE(".*ERROR: Expected boolean parameter instead of.*", + utils::logical(FLERR, "OFF", false, lmp);); + TEST_FAILURE(".*ERROR: Expected boolean parameter instead of.*", + utils::logical(FLERR, "FALSE", false, lmp);); + TEST_FAILURE(".*ERROR: Expected boolean parameter instead of.*", + utils::logical(FLERR, "False", false, lmp);); + TEST_FAILURE(".*ERROR: Expected boolean parameter instead of.*", + utils::logical(FLERR, "yay", false, lmp);); + TEST_FAILURE(".*ERROR: Expected boolean parameter instead of.*", + utils::logical(FLERR, "xxx", false, lmp);); + TEST_FAILURE(".*ERROR: Expected boolean parameter instead of.*", + utils::logical(FLERR, "none", false, lmp);); + TEST_FAILURE(".*ERROR: Expected boolean parameter instead of.*", + utils::logical(FLERR, "5", false, lmp);); +} + +TEST_F(InputConvertTest, numeric) +{ + EXPECT_DOUBLE_EQ(utils::numeric(FLERR, "0", false, lmp), 0); + EXPECT_DOUBLE_EQ(utils::numeric(FLERR, "0.1", false, lmp), 0.1); + EXPECT_DOUBLE_EQ(utils::numeric(FLERR, "-.232", false, lmp), -0.232); + EXPECT_DOUBLE_EQ(utils::numeric(FLERR, ".2e5", false, lmp), 20000.0); + EXPECT_DOUBLE_EQ(utils::numeric(FLERR, "2.5e-10", false, lmp), 2.5e-10); + EXPECT_DOUBLE_EQ(utils::numeric(FLERR, "+0.3", false, lmp), 0.3); + EXPECT_DOUBLE_EQ(utils::numeric(FLERR, "10000000000", false, lmp), 1e10); + EXPECT_DOUBLE_EQ(utils::numeric(FLERR, "2.56E+3", false, lmp), 2560); + + TEST_FAILURE(".*ERROR: Expected floating point.*", utils::numeric(FLERR, "yay", false, lmp);); + TEST_FAILURE(".*ERROR: Expected floating point.*", utils::numeric(FLERR, "", false, lmp);); + TEST_FAILURE(".*ERROR: Expected floating point.*", utils::numeric(FLERR, nullptr, false, lmp);); + TEST_FAILURE(".*ERROR: Expected floating point.*", + utils::numeric(FLERR, "2.56D+3", false, lmp);); +} + +TEST_F(InputConvertTest, inumeric) +{ + EXPECT_EQ(utils::inumeric(FLERR, "0", false, lmp), 0); + EXPECT_EQ(utils::inumeric(FLERR, "-1", false, lmp), -1); + EXPECT_EQ(utils::inumeric(FLERR, "10000", false, lmp), 10000); + EXPECT_EQ(utils::inumeric(FLERR, "-532410", false, lmp), -532410); + EXPECT_EQ(utils::inumeric(FLERR, "-0", false, lmp), 0); + EXPECT_EQ(utils::inumeric(FLERR, "0100", false, lmp), 100); + + TEST_FAILURE(".*ERROR: Expected integer.*", utils::inumeric(FLERR, "yay", false, lmp);); + TEST_FAILURE(".*ERROR: Expected integer.*", utils::inumeric(FLERR, "0.1", false, lmp);); + TEST_FAILURE(".*ERROR: Expected integer.*", utils::inumeric(FLERR, "1.1", false, lmp);); + TEST_FAILURE(".*ERROR: Expected integer.*", utils::inumeric(FLERR, "1e5", false, lmp);); + TEST_FAILURE(".*ERROR: Expected integer.*", utils::inumeric(FLERR, "0x05", false, lmp);); + TEST_FAILURE(".*ERROR: Expected integer.*", utils::inumeric(FLERR, "", false, lmp);); + TEST_FAILURE(".*ERROR: Expected integer.*", utils::inumeric(FLERR, nullptr, false, lmp);); +} + +TEST_F(InputConvertTest, bnumeric) +{ + EXPECT_EQ(utils::bnumeric(FLERR, "0", false, lmp), 0); + EXPECT_EQ(utils::bnumeric(FLERR, "-1", false, lmp), -1); + EXPECT_EQ(utils::bnumeric(FLERR, "10000", false, lmp), 10000); + EXPECT_EQ(utils::bnumeric(FLERR, "-532410", false, lmp), -532410); + EXPECT_EQ(utils::bnumeric(FLERR, "-0", false, lmp), 0); + EXPECT_EQ(utils::bnumeric(FLERR, "0100", false, lmp), 100); + + TEST_FAILURE(".*ERROR: Expected integer.*", utils::bnumeric(FLERR, "yay", false, lmp);); + TEST_FAILURE(".*ERROR: Expected integer.*", utils::bnumeric(FLERR, "0.1", false, lmp);); + TEST_FAILURE(".*ERROR: Expected integer.*", utils::bnumeric(FLERR, "1.1", false, lmp);); + TEST_FAILURE(".*ERROR: Expected integer.*", utils::bnumeric(FLERR, "1e5", false, lmp);); + TEST_FAILURE(".*ERROR: Expected integer.*", utils::bnumeric(FLERR, "0x05", false, lmp);); + TEST_FAILURE(".*ERROR: Expected integer.*", utils::bnumeric(FLERR, "", false, lmp);); + TEST_FAILURE(".*ERROR: Expected integer.*", utils::bnumeric(FLERR, nullptr, false, lmp);); +} + +TEST_F(InputConvertTest, tnumeric) +{ + EXPECT_EQ(utils::tnumeric(FLERR, "0", false, lmp), 0); + EXPECT_EQ(utils::tnumeric(FLERR, "-1", false, lmp), -1); + EXPECT_EQ(utils::tnumeric(FLERR, "10000", false, lmp), 10000); + EXPECT_EQ(utils::tnumeric(FLERR, "-532410", false, lmp), -532410); + EXPECT_EQ(utils::tnumeric(FLERR, "-0", false, lmp), 0); + EXPECT_EQ(utils::tnumeric(FLERR, "0100", false, lmp), 100); + + TEST_FAILURE(".*ERROR: Expected integer.*", utils::tnumeric(FLERR, "yay", false, lmp);); + TEST_FAILURE(".*ERROR: Expected integer.*", utils::tnumeric(FLERR, "0.1", false, lmp);); + TEST_FAILURE(".*ERROR: Expected integer.*", utils::tnumeric(FLERR, "1.1", false, lmp);); + TEST_FAILURE(".*ERROR: Expected integer.*", utils::tnumeric(FLERR, "1e5", false, lmp);); + TEST_FAILURE(".*ERROR: Expected integer.*", utils::tnumeric(FLERR, "0x05", false, lmp);); + TEST_FAILURE(".*ERROR: Expected integer.*", utils::tnumeric(FLERR, "", false, lmp);); + TEST_FAILURE(".*ERROR: Expected integer.*", utils::tnumeric(FLERR, nullptr, false, lmp);); +} + +} // namespace LAMMPS_NS + +int main(int argc, char **argv) +{ + lammps_mpi_init(); + ::testing::InitGoogleMock(&argc, argv); + + // handle arguments passed via environment variable + if (const char *var = getenv("TEST_ARGS")) { + auto env = split_words(var); + for (auto arg : env) { + if (arg == "-v") { + verbose = true; + } + } + } + if ((argc > 1) && (strcmp(argv[1], "-v") == 0)) verbose = true; + + int rv = RUN_ALL_TESTS(); + lammps_mpi_finalize(); + return rv; +} diff --git a/unittest/python/python-capabilities.py b/unittest/python/python-capabilities.py index 8f72c39670..4c14cac37d 100644 --- a/unittest/python/python-capabilities.py +++ b/unittest/python/python-capabilities.py @@ -166,9 +166,9 @@ class PythonCapabilities(unittest.TestCase): self.assertIn('single',settings['GPU']['precision']) if self.cmake_cache['PKG_KOKKOS']: - if self.cmake_cache['Kokkos_ENABLE_OPENMP']: + if 'Kokkos_ENABLE_OPENMP' in self.cmake_cache and self.cmake_cache['Kokkos_ENABLE_OPENMP']: self.assertIn('openmp',settings['KOKKOS']['api']) - if self.cmake_cache['Kokkos_ENABLE_SERIAL']: + if 'Kokkos_ENABLE_SERIAL' in self.cmake_cache and self.cmake_cache['Kokkos_ENABLE_SERIAL']: self.assertIn('serial',settings['KOKKOS']['api']) self.assertIn('double',settings['KOKKOS']['precision'])