diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 1b4cae3aaa..ed37fa80b9 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -37,7 +37,7 @@ src/MESONT/* @iafoss src/ML-HDNNP/* @singraber src/ML-IAP/* @athomps src/ML-PACE/* @yury-lysogorskiy -src/ML-POD/* @exapde @rohskopf +src/ML-POD/* @exapde src/MOFFF/* @hheenen src/MOLFILE/* @akohlmey src/NETCDF/* @pastewka @@ -65,9 +65,12 @@ src/MANYBODY/pair_nb3b_screened.* @flodesani src/REPLICA/*_grem.* @dstelter92 src/EXTRA-COMPUTE/compute_stress_mop*.* @RomainVermorel src/EXTRA-COMPUTE/compute_born_matrix.* @Bibobu @athomps +src/EXTRA-FIX/fix_deform_pressure.* @jtclemm src/MISC/*_tracker.* @jtclemm src/MC/fix_gcmc.* @athomps src/MC/fix_sgcmc.* @athomps +src/REAXFF/compute_reaxff_atom.* @rbberger +src/KOKKOS/compute_reaxff_atom_kokkos.* @rbberger src/REPLICA/fix_pimd_langevin.* @Yi-FanLi # core LAMMPS classes diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml index 00a4596cc8..c0c3e3f89a 100644 --- a/.github/workflows/coverity.yml +++ b/.github/workflows/coverity.yml @@ -25,7 +25,7 @@ jobs: - name: Cache Coverity id: cache-coverity - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ./download/ key: ${{ runner.os }}-download-${{ hashFiles('**/coverity_tool.*') }} diff --git a/.github/workflows/unittest-macos.yml b/.github/workflows/unittest-macos.yml index 6970faceaa..f9c2a838d6 100644 --- a/.github/workflows/unittest-macos.yml +++ b/.github/workflows/unittest-macos.yml @@ -32,7 +32,7 @@ jobs: run: mkdir build - name: Set up ccache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ${{ env.CCACHE_DIR }} key: macos-ccache-${{ github.sha }} diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index f7e9b314bd..f87c92396f 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -120,6 +120,19 @@ if((CMAKE_CXX_COMPILER_ID STREQUAL "NVHPC") OR (CMAKE_CXX_COMPILER_ID STREQUAL " set(CMAKE_TUNE_DEFAULT "-Minform=severe") endif() +# this hack is required to compile fmt lib with CrayClang version 15.0.2 +# CrayClang is only directly recognized by version 3.28 and later +if(CMAKE_VERSION VERSION_LESS 3.28) + get_filename_component(_exe "${CMAKE_CXX_COMPILER}" NAME) + if((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND (_exe STREQUAL "crayCC")) + set(CMAKE_TUNE_DEFAULT "-DFMT_STATIC_THOUSANDS_SEPARATOR") + endif() +else() + if(CMAKE_CXX_COMPILER_ID STREQUAL "CrayClang") + set(CMAKE_TUNE_DEFAULT "-DFMT_STATIC_THOUSANDS_SEPARATOR") + endif() +endif() + # silence nvcc warnings if((PKG_KOKKOS) AND (Kokkos_ENABLE_CUDA) AND NOT (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")) set(CMAKE_TUNE_DEFAULT "${CMAKE_TUNE_DEFAULT} -Xcudafe --diag_suppress=unrecognized_pragma") @@ -209,6 +222,10 @@ endif() add_executable(lmp ${MAIN_SOURCES}) target_link_libraries(lmp PRIVATE lammps) set_target_properties(lmp PROPERTIES OUTPUT_NAME ${LAMMPS_BINARY}) +# re-export all symbols for plugins +if(PKG_PLUGIN AND (NOT ((CMAKE_SYSTEM_NAME STREQUAL "Windows")))) + set_target_properties(lmp PROPERTIES ENABLE_EXPORTS TRUE) +endif() install(TARGETS lmp EXPORT LAMMPS_Targets DESTINATION ${CMAKE_INSTALL_BINDIR}) option(CMAKE_VERBOSE_MAKEFILE "Generate verbose Makefiles" OFF) @@ -415,6 +432,7 @@ if(BUILD_OMP) (CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM") OR (CMAKE_CXX_COMPILER_ID STREQUAL "XLClang") OR ((CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 10.0)) OR ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 10.0)) OR + ((CMAKE_CXX_COMPILER_ID STREQUAL "CrayClang") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 10.0)) OR ((CMAKE_CXX_COMPILER_ID STREQUAL "Intel") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.0))) # GCC 9.x and later plus Clang 10.x and later implement strict OpenMP 4.0 semantics for consts. # Intel 18.0 was tested to support both, so we switch to OpenMP 4+ from 19.x onward to be safe. @@ -425,6 +443,21 @@ if(BUILD_OMP) target_compile_definitions(lammps PRIVATE -DLAMMPS_OMP_COMPAT=${LAMMPS_OMP_COMPAT_LEVEL}) target_link_libraries(lammps PRIVATE OpenMP::OpenMP_CXX) target_link_libraries(lmp PRIVATE OpenMP::OpenMP_CXX) + + # this hack is required to correctly link with OpenMP support when using CrayClang version 15.0.2 + # CrayClang is only directly recognized by version 3.28 and later + if(CMAKE_VERSION VERSION_LESS 3.28) + get_filename_component(_exe "${CMAKE_CXX_COMPILER}" NAME) + if((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND (_exe STREQUAL "crayCC")) + set(CMAKE_SHARED_LINKER_FLAGS_${BTYPE} "${CMAKE_SHARED_LINKER_FLAGS_${BTYPE} -fopenmp") + set(CMAKE_STATIC_LINKER_FLAGS_${BTYPE} "${CMAKE_STATIC_LINKER_FLAGS_${BTYPE} -fopenmp") + endif() + else() + if(CMAKE_CXX_COMPILER_ID STREQUAL "CrayClang") + set(CMAKE_SHARED_LINKER_FLAGS_${BTYPE} "${CMAKE_SHARED_LINKER_FLAGS_${BTYPE} -fopenmp") + set(CMAKE_STATIC_LINKER_FLAGS_${BTYPE} "${CMAKE_STATIC_LINKER_FLAGS_${BTYPE} -fopenmp") + endif() + endif() endif() # lower C++ standard for fmtlib sources when using Intel classic compiler @@ -539,12 +572,12 @@ endforeach() ######################################################################## # Basic system tests (standard libraries, headers, functions, types) # ######################################################################## -foreach(HEADER cmath) - check_include_file_cxx(${HEADER} FOUND_${HEADER}) - if(NOT FOUND_${HEADER}) - message(FATAL_ERROR "Could not find needed header - ${HEADER}") - endif(NOT FOUND_${HEADER}) -endforeach(HEADER) +if (NOT ((CMAKE_CXX_COMPILER_ID STREQUAL "Intel") OR (CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM"))) + check_include_file_cxx(cmath FOUND_CMATH) + if(NOT FOUND_CMATH) + message(FATAL_ERROR "Could not find the required 'cmath' header") + endif(NOT FOUND_CMATH) +endif() # make the standard math library overrideable and autodetected (for systems that don't have it) find_library(STANDARD_MATH_LIB m DOC "Standard Math library") @@ -971,14 +1004,15 @@ if(PKG_KOKKOS) endif() endif() if(PKG_KSPACE) - if (LMP_HEFFTE) + if (FFT_USE_HEFFTE) message(STATUS "<<< FFT settings >>> -- Primary FFT lib: heFFTe") - if (HEFFTE_BACKEND) - message(STATUS "heFFTe backend: ${HEFFTE_BACKEND}") + if (FFT_HEFFTE_BACKEND) + message(STATUS "heFFTe backend: ${FFT_HEFFTE_BACKEND}") else() message(STATUS "heFFTe backend: stock (builtin FFT implementation, tested for corrected but not optimized for production)") endif() + message(STATUS "Using distributed FFT algorithms from heFTTe") if(FFT_SINGLE) message(STATUS "Using single precision FFTs") else() @@ -997,28 +1031,10 @@ if(PKG_KSPACE) else() message(STATUS "Using non-threaded FFTs") endif() - if (FFT_HEFFTE) - message(STATUS "Using distributed algorithms from heFTTe") - else() - message(STATUS "Using builtin distributed algorithms") - endif() - if(PKG_KOKKOS) - if(Kokkos_ENABLE_CUDA) - if(FFT STREQUAL "KISS") - message(STATUS "Kokkos FFT: KISS") - else() - message(STATUS "Kokkos FFT: cuFFT") - endif() - elseif(Kokkos_ENABLE_HIP) - if(FFT STREQUAL "KISS") - message(STATUS "Kokkos FFT: KISS") - else() - message(STATUS "Kokkos FFT: hipFFT") - endif() - else() - message(STATUS "Kokkos FFT: ${FFT}") - endif() - endif() + message(STATUS "Using builtin distributed FFT algorithms") + endif() + if(PKG_KOKKOS) + message(STATUS "Kokkos FFT: ${FFT_KOKKOS}") endif() endif() if(BUILD_DOC) diff --git a/cmake/Modules/DetectHIPInstallation.cmake b/cmake/Modules/DetectHIPInstallation.cmake index 0b425435b6..dfa9904723 100644 --- a/cmake/Modules/DetectHIPInstallation.cmake +++ b/cmake/Modules/DetectHIPInstallation.cmake @@ -1,11 +1,3 @@ -if(NOT DEFINED HIP_PATH) - if(NOT DEFINED ENV{HIP_PATH}) - message(FATAL_ERROR "HIP support requires HIP_PATH to be defined.\n" - "Either pass the HIP_PATH as a CMake option via -DHIP_PATH=... or set the HIP_PATH environment variable.") - else() - set(HIP_PATH $ENV{HIP_PATH} CACHE PATH "Path to HIP installation") - endif() -endif() if(NOT DEFINED ROCM_PATH) if(NOT DEFINED ENV{ROCM_PATH}) set(ROCM_PATH "/opt/rocm" CACHE PATH "Path to ROCm installation") @@ -13,4 +5,4 @@ if(NOT DEFINED ROCM_PATH) set(ROCM_PATH $ENV{ROCM_PATH} CACHE PATH "Path to ROCm installation") endif() endif() -list(APPEND CMAKE_PREFIX_PATH ${HIP_PATH} ${ROCM_PATH}) +list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}) diff --git a/cmake/Modules/ExternalCMakeProject.cmake b/cmake/Modules/ExternalCMakeProject.cmake index 75c33ab99e..7e3681dc28 100644 --- a/cmake/Modules/ExternalCMakeProject.cmake +++ b/cmake/Modules/ExternalCMakeProject.cmake @@ -43,5 +43,5 @@ function(ExternalCMakeProject target url hash basedir cmakedir cmakefile) "${CMAKE_BINARY_DIR}/_deps/${target}-src/${cmakedir}/CMakeLists.txt") endif() add_subdirectory("${CMAKE_BINARY_DIR}/_deps/${target}-src/${cmakedir}" - "${CMAKE_BINARY_DIR}/_deps/${target}-build") + "${CMAKE_BINARY_DIR}/_deps/${target}-build" EXCLUDE_FROM_ALL) endfunction(ExternalCMakeProject) diff --git a/cmake/Modules/OpenCLLoader.cmake b/cmake/Modules/OpenCLLoader.cmake index 23ca81a5f2..4b5c5a1200 100644 --- a/cmake/Modules/OpenCLLoader.cmake +++ b/cmake/Modules/OpenCLLoader.cmake @@ -1,6 +1,6 @@ message(STATUS "Downloading and building OpenCL loader library") -set(OPENCL_LOADER_URL "${LAMMPS_THIRDPARTY_URL}/opencl-loader-2022.01.04.tar.gz" CACHE STRING "URL for OpenCL loader tarball") -set(OPENCL_LOADER_MD5 "8d3a801e87a2c6653bf0e27707063914" CACHE STRING "MD5 checksum of OpenCL loader tarball") +set(OPENCL_LOADER_URL "${LAMMPS_THIRDPARTY_URL}/opencl-loader-2024.02.09.tar.gz" CACHE STRING "URL for OpenCL loader tarball") +set(OPENCL_LOADER_MD5 "f3573cf9daa3558ba46fd5866517f38f" CACHE STRING "MD5 checksum of OpenCL loader tarball") mark_as_advanced(OPENCL_LOADER_URL) mark_as_advanced(OPENCL_LOADER_MD5) @@ -8,4 +8,3 @@ set(INSTALL_LIBOPENCL OFF CACHE BOOL "" FORCE) include(ExternalCMakeProject) ExternalCMakeProject(opencl_loader ${OPENCL_LOADER_URL} ${OPENCL_LOADER_MD5} opencl-loader . "") -add_library(OpenCL::OpenCL ALIAS OpenCL) diff --git a/cmake/Modules/Packages/GPU.cmake b/cmake/Modules/Packages/GPU.cmake index 4c3288df84..6d0ce303a5 100644 --- a/cmake/Modules/Packages/GPU.cmake +++ b/cmake/Modules/Packages/GPU.cmake @@ -1,3 +1,10 @@ + +# Silence CMake warnings about FindCUDA being obsolete. +# We may need to eventually rewrite this section to use enable_language(CUDA) +if(POLICY CMP0146) + cmake_policy(SET CMP0146 OLD) +endif() + set(GPU_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/GPU) set(GPU_SOURCES ${GPU_SOURCES_DIR}/gpu_extra.h ${GPU_SOURCES_DIR}/fix_gpu.h diff --git a/cmake/Modules/Packages/INTEL.cmake b/cmake/Modules/Packages/INTEL.cmake index 006a23e7ac..e6755bf23b 100644 --- a/cmake/Modules/Packages/INTEL.cmake +++ b/cmake/Modules/Packages/INTEL.cmake @@ -111,6 +111,9 @@ if(PKG_KSPACE) list(APPEND INTEL_SOURCES ${INTEL_SOURCES_DIR}/verlet_lrt_intel.cpp) RegisterIntegrateStyle(${INTEL_SOURCES_DIR}/verlet_lrt_intel.h) endif() +if(PKG_ML-SNAP) + list(APPEND INTEL_SOURCES ${INTEL_SOURCES_DIR}/sna_intel.cpp) +endif() target_sources(lammps PRIVATE ${INTEL_SOURCES}) target_include_directories(lammps PRIVATE ${INTEL_SOURCES_DIR}) diff --git a/cmake/Modules/Packages/KOKKOS.cmake b/cmake/Modules/Packages/KOKKOS.cmake index 30c46504ed..9324ea95c4 100644 --- a/cmake/Modules/Packages/KOKKOS.cmake +++ b/cmake/Modules/Packages/KOKKOS.cmake @@ -45,8 +45,8 @@ if(DOWNLOAD_KOKKOS) list(APPEND KOKKOS_LIB_BUILD_ARGS "-DCMAKE_CXX_EXTENSIONS=${CMAKE_CXX_EXTENSIONS}") list(APPEND KOKKOS_LIB_BUILD_ARGS "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}") include(ExternalProject) - set(KOKKOS_URL "https://github.com/kokkos/kokkos/archive/4.2.00.tar.gz" CACHE STRING "URL for KOKKOS tarball") - set(KOKKOS_MD5 "731647b61a4233f568d583702e9cd6d1" CACHE STRING "MD5 checksum of KOKKOS tarball") + set(KOKKOS_URL "https://github.com/kokkos/kokkos/archive/4.2.01.tar.gz" CACHE STRING "URL for KOKKOS tarball") + set(KOKKOS_MD5 "16b9b09ae947d434dfb58fc5c87c2b76" CACHE STRING "MD5 checksum of KOKKOS tarball") mark_as_advanced(KOKKOS_URL) mark_as_advanced(KOKKOS_MD5) GetFallbackURL(KOKKOS_URL KOKKOS_FALLBACK) @@ -71,7 +71,7 @@ if(DOWNLOAD_KOKKOS) add_dependencies(LAMMPS::KOKKOSCORE kokkos_build) add_dependencies(LAMMPS::KOKKOSCONTAINERS kokkos_build) elseif(EXTERNAL_KOKKOS) - find_package(Kokkos 4.2.00 REQUIRED CONFIG) + find_package(Kokkos 4.2.01 REQUIRED CONFIG) target_link_libraries(lammps PRIVATE Kokkos::kokkos) else() set(LAMMPS_LIB_KOKKOS_SRC_DIR ${LAMMPS_LIB_SOURCE_DIR}/kokkos) @@ -126,16 +126,36 @@ if(PKG_KSPACE) list(APPEND KOKKOS_PKG_SOURCES ${KOKKOS_PKG_SOURCES_DIR}/fft3d_kokkos.cpp ${KOKKOS_PKG_SOURCES_DIR}/grid3d_kokkos.cpp ${KOKKOS_PKG_SOURCES_DIR}/remap_kokkos.cpp) + set(FFT_KOKKOS "KISS" CACHE STRING "FFT library for Kokkos-enabled KSPACE package") + set(FFT_KOKKOS_VALUES KISS FFTW3 MKL HIPFFT CUFFT) + set_property(CACHE FFT_KOKKOS PROPERTY STRINGS ${FFT_KOKKOS_VALUES}) + validate_option(FFT_KOKKOS FFT_KOKKOS_VALUES) + string(TOUPPER ${FFT_KOKKOS} FFT_KOKKOS) + if(Kokkos_ENABLE_CUDA) - if(NOT (FFT STREQUAL "KISS")) - target_compile_definitions(lammps PRIVATE -DFFT_CUFFT) - target_link_libraries(lammps PRIVATE cufft) + if(NOT ((FFT_KOKKOS STREQUAL "KISS") OR (FFT_KOKKOS STREQUAL "CUFFT"))) + message(FATAL_ERROR "The CUDA backend of Kokkos requires either KISS FFT or CUFFT.") + elseif(FFT_KOKKOS STREQUAL "KISS") + message(WARNING "Using KISS FFT with the CUDA backend of Kokkos may be sub-optimal.") + target_compile_definitions(lammps PRIVATE -DFFT_KOKKOS_KISS) + elseif(FFT_KOKKOS STREQUAL "CUFFT") + find_library(CUFFT_LIBRARY cufft) + if (CUFFT_LIBRARY STREQUAL "CUFFT_LIBRARY-NOTFOUND") + message(FATAL_ERROR "Required cuFFT library not found. Check your environment or set CUFFT_LIBRARY to its location") + endif() + target_compile_definitions(lammps PRIVATE -DFFT_KOKKOS_CUFFT) + target_link_libraries(lammps PRIVATE ${CUFFT_LIBRARY}) endif() elseif(Kokkos_ENABLE_HIP) - if(NOT (FFT STREQUAL "KISS")) + if(NOT ((FFT_KOKKOS STREQUAL "KISS") OR (FFT_KOKKOS STREQUAL "HIPFFT"))) + message(FATAL_ERROR "The HIP backend of Kokkos requires either KISS FFT or HIPFFT.") + elseif(FFT_KOKKOS STREQUAL "KISS") + message(WARNING "Using KISS FFT with the HIP backend of Kokkos may be sub-optimal.") + target_compile_definitions(lammps PRIVATE -DFFT_KOKKOS_KISS) + elseif(FFT_KOKKOS STREQUAL "HIPFFT") include(DetectHIPInstallation) find_package(hipfft REQUIRED) - target_compile_definitions(lammps PRIVATE -DFFT_HIPFFT) + target_compile_definitions(lammps PRIVATE -DFFT_KOKKOS_HIPFFT) target_link_libraries(lammps PRIVATE hip::hipfft) endif() endif() diff --git a/cmake/Modules/Packages/KSPACE.cmake b/cmake/Modules/Packages/KSPACE.cmake index 9c9c879cd4..1fdd898144 100644 --- a/cmake/Modules/Packages/KSPACE.cmake +++ b/cmake/Modules/Packages/KSPACE.cmake @@ -48,10 +48,15 @@ endif() option(FFT_USE_HEFFTE "Use heFFTe as the distributed FFT engine, overrides the FFT option." OFF) if(FFT_USE_HEFFTE) - # if FFT_HEFFTE is enabled, switch the builtin FFT engine with Heffte - set(FFT_HEFFTE_BACKEND_VALUES FFTW MKL) - set(FFT_HEFFTE_BACKEND "" CACHE STRING "Select heFFTe backend, e.g., FFTW or MKL") + # if FFT_HEFFTE is enabled, use the heFFTe parallel engine instead of the builtin fftMPI engine + + # map standard FFT choices to available heFFTe backends: FFTW3 -> FFTW, KISS -> BUILTIN + set(FFT_HEFFTE_BACKEND_VALUES FFTW MKL BUILTIN) + string(REPLACE FFTW3 FFTW FFT_HEFFTE_BACKEND_DEFAULT ${FFT}) + string(REPLACE KISS BUILTIN FFT_HEFFTE_BACKEND_DEFAULT ${FFT_HEFFTE_BACKEND_DEFAULT}) + set(FFT_HEFFTE_BACKEND "${FFT_HEFFTE_BACKEND_DEFAULT}" CACHE STRING "Select heFFTe backend, e.g., FFTW or MKL") set_property(CACHE FFT_HEFFTE_BACKEND PROPERTY STRINGS ${FFT_HEFFTE_BACKEND_VALUES}) + validate_option(FFT_HEFFTE_BACKEND FFT_HEFFTE_BACKEND_VALUES) if(FFT_HEFFTE_BACKEND STREQUAL "FFTW") # respect the backend choice, FFTW or MKL set(HEFFTE_COMPONENTS "FFTW") @@ -60,24 +65,38 @@ if(FFT_USE_HEFFTE) set(HEFFTE_COMPONENTS "MKL") set(Heffte_ENABLE_MKL "ON" CACHE BOOL "Enables MKL backend for heFFTe") else() + set(HEFFTE_COMPONENTS "BUILTIN") message(WARNING "FFT_HEFFTE_BACKEND not selected, defaulting to the builtin 'stock' backend, which is intended for testing and is not optimized for production runs") endif() find_package(Heffte 2.4.0 QUIET COMPONENTS ${HEFFTE_COMPONENTS}) if (NOT Heffte_FOUND) # download and build + if(BUILD_SHARED_LIBS) + set(BUILD_SHARED_LIBS_WAS_ON YES) + set(BUILD_SHARED_LIBS OFF) + endif() + if(CMAKE_REQUEST_PIC) + set(CMAKE_POSITION_INDEPENDENT_CODE ON) + endif() + set(Heffte_ENABLE_${FFT_HEFFTE_BACKEND} ON) include(FetchContent) FetchContent_Declare(HEFFTE_PROJECT # using v2.4.0 URL "https://github.com/icl-utk-edu/heffte/archive/refs/tags/v2.4.0.tar.gz" URL_HASH SHA256=02310fb4f9688df02f7181667e61c3adb7e38baf79611d80919d47452ff7881d ) FetchContent_Populate(HEFFTE_PROJECT) - add_subdirectory(${heffte_project_SOURCE_DIR} ${heffte_project_BINARY_DIR}) - set_target_properties(lmp PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") - set_target_properties(lammps PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") - add_library(Heffte::Heffte INTERFACE IMPORTED GLOBAL) - target_link_libraries(Heffte::Heffte INTERFACE Heffte) - endif() + # fixup git hash to show "(unknown)" to avoid compilation failures. + file(READ ${heffte_project_SOURCE_DIR}/include/heffte_config.cmake.h HEFFTE_CFG_FILE_TEXT) + string(REPLACE "@Heffte_GIT_HASH@" "(unknown)" HEFFTE_CFG_FILE_TEXT "${HEFFTE_CFG_FILE_TEXT}") + file(WRITE ${heffte_project_SOURCE_DIR}/include/heffte_config.cmake.h "${HEFFTE_CFG_FILE_TEXT}") + + add_subdirectory(${heffte_project_SOURCE_DIR} ${heffte_project_BINARY_DIR} EXCLUDE_FROM_ALL) + add_library(Heffte::Heffte ALIAS Heffte) + if(BUILD_SHARED_LIBS_WAS_ON) + set(BUILD_SHARED_LIBS ON) + endif() + endif() target_compile_definitions(lammps PRIVATE -DFFT_HEFFTE "-DFFT_HEFFTE_${FFT_HEFFTE_BACKEND}") target_link_libraries(lammps PRIVATE Heffte::Heffte) endif() diff --git a/cmake/Modules/Packages/MDI.cmake b/cmake/Modules/Packages/MDI.cmake index 447b941d99..b21e508b87 100644 --- a/cmake/Modules/Packages/MDI.cmake +++ b/cmake/Modules/Packages/MDI.cmake @@ -8,8 +8,8 @@ option(DOWNLOAD_MDI "Download and compile the MDI library instead of using an al if(DOWNLOAD_MDI) message(STATUS "MDI download requested - we will build our own") - set(MDI_URL "https://github.com/MolSSI-MDI/MDI_Library/archive/v1.4.16.tar.gz" CACHE STRING "URL for MDI tarball") - set(MDI_MD5 "407db44e2d79447ab5c1233af1965f65" CACHE STRING "MD5 checksum for MDI tarball") + set(MDI_URL "https://github.com/MolSSI-MDI/MDI_Library/archive/v1.4.26.tar.gz" CACHE STRING "URL for MDI tarball") + set(MDI_MD5 "3124bb85259471e2a53a891f04bf697a" CACHE STRING "MD5 checksum for MDI tarball") mark_as_advanced(MDI_URL) mark_as_advanced(MDI_MD5) GetFallbackURL(MDI_URL MDI_FALLBACK) diff --git a/cmake/Modules/Packages/ML-QUIP.cmake b/cmake/Modules/Packages/ML-QUIP.cmake index a90b77190f..5cb5a0967e 100644 --- a/cmake/Modules/Packages/ML-QUIP.cmake +++ b/cmake/Modules/Packages/ML-QUIP.cmake @@ -18,7 +18,9 @@ if(DOWNLOAD_QUIP) set(temp "${temp}F77FLAGS += -fpp -fixed -fPIC\n") set(temp "${temp}F95_PRE_FILENAME_FLAG = -Tf\n") elseif(CMAKE_Fortran_COMPILER_ID STREQUAL GNU) - set(temp "${temp}FPP=${CMAKE_Fortran_COMPILER} -E -x f95-cpp-input\nOPTIM=${CMAKE_Fortran_FLAGS_${BTYPE}}\n") + # quip library uses GNU fortran extensions. If any more restrictive standards are set, reset them + string(REGEX REPLACE -std=f[0-9]+ -std=gnu _fopt "${CMAKE_Fortran_FLAGS_${BTYPE}}") + set(temp "${temp}FPP=${CMAKE_Fortran_COMPILER} -E -x f95-cpp-input\nOPTIM=${_fopt} -fmax-stack-var-size=6553600\n") set(temp "${temp}DEFINES += -DGETARG_F2003 -DGETENV_F2003 -DGFORTRAN -DFORTRAN_UNDERSCORE\n") set(temp "${temp}F95FLAGS += -x f95-cpp-input -ffree-line-length-none -ffree-form -fno-second-underscore -fPIC\n") set(temp "${temp}F77FLAGS += -x f77-cpp-input -fno-second-underscore -fPIC\n") @@ -56,7 +58,7 @@ if(DOWNLOAD_QUIP) GIT_SUBMODULES "src/fox;src/GAP" 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 + BUILD_COMMAND env QUIP_ARCH=lammps make -j1 libquip INSTALL_COMMAND "" BUILD_IN_SOURCE YES BUILD_BYPRODUCTS /build/lammps/${CMAKE_STATIC_LIBRARY_PREFIX}quip${CMAKE_STATIC_LIBRARY_SUFFIX} diff --git a/cmake/Modules/Packages/PLUMED.cmake b/cmake/Modules/Packages/PLUMED.cmake index b90bff4b9c..b1a4f3cc72 100644 --- a/cmake/Modules/Packages/PLUMED.cmake +++ b/cmake/Modules/Packages/PLUMED.cmake @@ -21,9 +21,9 @@ else() set(PLUMED_CONFIG_OMP "--disable-openmp") endif() -set(PLUMED_URL "https://github.com/plumed/plumed2/releases/download/v2.8.2/plumed-src-2.8.2.tgz" +set(PLUMED_URL "https://github.com/plumed/plumed2/releases/download/v2.8.3/plumed-src-2.8.3.tgz" CACHE STRING "URL for PLUMED tarball") -set(PLUMED_MD5 "599092b6a0aa6fff992612537ad98994" CACHE STRING "MD5 checksum of PLUMED tarball") +set(PLUMED_MD5 "76d23cd394eba9e6530316ed1184e219" CACHE STRING "MD5 checksum of PLUMED tarball") mark_as_advanced(PLUMED_URL) mark_as_advanced(PLUMED_MD5) diff --git a/cmake/presets/kokkos-cuda.cmake b/cmake/presets/kokkos-cuda.cmake index c3ee081898..878ce0c566 100644 --- a/cmake/presets/kokkos-cuda.cmake +++ b/cmake/presets/kokkos-cuda.cmake @@ -9,5 +9,8 @@ set(BUILD_OMP ON CACHE BOOL "" FORCE) get_filename_component(NVCC_WRAPPER_CMD ${CMAKE_CURRENT_SOURCE_DIR}/../lib/kokkos/bin/nvcc_wrapper ABSOLUTE) set(CMAKE_CXX_COMPILER ${NVCC_WRAPPER_CMD} CACHE FILEPATH "" FORCE) +# If KSPACE is also enabled, use CUFFT for FFTs +set(FFT_KOKKOS "CUFFT" CACHE STRING "" FORCE) + # hide deprecation warnings temporarily for stable release set(Kokkos_ENABLE_DEPRECATION_WARNINGS OFF CACHE BOOL "" FORCE) diff --git a/cmake/presets/kokkos-hip.cmake b/cmake/presets/kokkos-hip.cmake index 827a37152b..38bf27092f 100644 --- a/cmake/presets/kokkos-hip.cmake +++ b/cmake/presets/kokkos-hip.cmake @@ -12,6 +12,9 @@ set(BUILD_OMP ON CACHE BOOL "" FORCE) set(CMAKE_CXX_COMPILER hipcc CACHE STRING "" FORCE) set(CMAKE_TUNE_FLAGS "-munsafe-fp-atomics" CACHE STRING "" FORCE) +# If KSPACE is also enabled, use CUFFT for FFTs +set(FFT_KOKKOS "HIPFFT" CACHE STRING "" FORCE) + # hide deprecation warnings temporarily for stable release set(Kokkos_ENABLE_DEPRECATION_WARNINGS OFF CACHE BOOL "" FORCE) diff --git a/doc/Makefile b/doc/Makefile index b652c515e1..f9f8336665 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -100,6 +100,7 @@ html: xmlgen $(VENV) $(SPHINXCONFIG)/conf.py $(ANCHORCHECK) $(MATHJAX) env LC_ALL=C grep -n ' :[a-z]\+`' $(RSTDIR)/*.rst ;\ env LC_ALL=C grep -n ' `[^`]\+<[a-z][^`]\+`[^_]' $(RSTDIR)/*.rst ;\ env LC_ALL=C grep -n ':\(ref\|doc\):[^`]' $(RSTDIR)/*.rst ;\ + env LC_ALL=C grep -n '\(ref\|doc\)`[^`]' $(RSTDIR)/*.rst ;\ $(PYTHON) $(BUILDDIR)/utils/check-styles.py -s ../src -d src ;\ echo "############################################" ;\ deactivate ;\ @@ -182,6 +183,7 @@ pdf: xmlgen $(VENV) $(SPHINXCONFIG)/conf.py $(ANCHORCHECK) env LC_ALL=C grep -n ' :[a-z]\+`' $(RSTDIR)/*.rst ;\ env LC_ALL=C grep -n ' `[^`]\+<[a-z][^`]\+`[^_]' $(RSTDIR)/*.rst ;\ env LC_ALL=C grep -n ':\(ref\|doc\):[^`]' $(RSTDIR)/*.rst ;\ + env LC_ALL=C grep -n '\(ref\|doc\)`[^`]' $(RSTDIR)/*.rst ;\ $(PYTHON) utils/check-styles.py -s ../src -d src ;\ echo "############################################" ;\ deactivate ;\ @@ -231,6 +233,7 @@ role_check : @( env LC_ALL=C grep -n ' :[a-z]\+`' $(RSTDIR)/*.rst && exit 1 || : ) @( env LC_ALL=C grep -n ' `[^`]\+<[a-z][^`]\+`[^_]' $(RSTDIR)/*.rst && exit 1 || : ) @( env LC_ALL=C grep -n ':\(ref\|doc\):[^`]' $(RSTDIR)/*.rst && exit 1 || : ) + @( env LC_ALL=C grep -n '\(ref\|doc\)`[^`]' $(RSTDIR)/*.rst && exit 1 || : ) link_check : $(VENV) html @(\ diff --git a/doc/lammps.1 b/doc/lammps.1 index 100ea9b663..0c7c9a0354 100644 --- a/doc/lammps.1 +++ b/doc/lammps.1 @@ -1,7 +1,7 @@ -.TH LAMMPS "1" "21 November 2023" "2023-11-21" +.TH LAMMPS "1" "7 February 2024" "2024-02-07" .SH NAME .B LAMMPS -\- Molecular Dynamics Simulator. Version 21 November 2023 +\- Molecular Dynamics Simulator. Version 7 February 2024 .SH SYNOPSIS .B lmp diff --git a/doc/src/Bibliography.rst b/doc/src/Bibliography.rst index 4ed8e73dfe..9778340c94 100644 --- a/doc/src/Bibliography.rst +++ b/doc/src/Bibliography.rst @@ -877,6 +877,9 @@ Bibliography **(PLUMED)** G.A. Tribello, M. Bonomi, D. Branduardi, C. Camilloni and G. Bussi, Comp. Phys. Comm 185, 604 (2014) +**(Pavlov)** +D Pavlov, V Galigerov, D Kolotinskii, V Nikolskiy, V Stegailov, International Journal of High Performance Computing Applications, 38, 34-49 (2024). + **(Paquay)** Paquay and Kusters, Biophys. J., 110, 6, (2016). preprint available at `arXiv:1411.3019 `_. diff --git a/doc/src/Build_development.rst b/doc/src/Build_development.rst index c674b2c258..4d8bf0d07f 100644 --- a/doc/src/Build_development.rst +++ b/doc/src/Build_development.rst @@ -122,32 +122,39 @@ Code Coverage and Unit Testing (CMake only) ------------------------------------------- The LAMMPS code is subject to multiple levels of automated testing -during development: integration testing (i.e. whether the code compiles -on various platforms and with a variety of settings), unit testing -(i.e. whether certain individual parts of the code produce the expected -results for given inputs), run testing (whether selected complete input -decks run without crashing for multiple configurations), and regression -testing (i.e. whether selected input examples reproduce the same -results over a given number of steps and operations within a given -error margin). The status of this automated testing can be viewed on -`https://ci.lammps.org `_. +during development: + +- Integration testing (i.e. whether the code compiles + on various platforms and with a variety of compilers and settings), +- Unit testing (i.e. whether certain functions or classes of the code + produce the expected results for given inputs), +- Run testing (i.e. whether selected input decks can run to completion + without crashing for multiple configurations), +- Regression testing (i.e. whether selected input examples reproduce the + same results over a given number of steps and operations within a + given error margin). + +The status of this automated testing can be viewed on `https://ci.lammps.org +`_. The scripts and inputs for integration, run, and regression testing are maintained in a `separate repository `_ -of the LAMMPS project on GitHub. +of the LAMMPS project on GitHub. A few tests are also run as GitHub +Actions and their configuration files are in the ``.github/workflows/`` +folder of the LAMMPS git tree. -The unit testing facility is integrated into the CMake build process -of the LAMMPS source code distribution itself. It can be enabled by +The unit testing facility is integrated into the CMake build process of +the LAMMPS source code distribution itself. It can be enabled by setting ``-D ENABLE_TESTING=on`` during the CMake configuration step. -It requires the `YAML `_ library and development -headers (if those are not found locally a recent version will be -downloaded and compiled along with LAMMPS and the test program) to -compile and will download and compile a specific recent version of the -`Googletest `_ C++ test framework -for implementing the tests. +It requires the `YAML `_ library and matching +development headers to compile (if those are not found locally a recent +version of that library will be downloaded and compiled along with +LAMMPS and the test programs) and will download and compile a specific +version of the `GoogleTest `_ C++ +test framework that is used to implement the tests. -.. admonition:: Software version requirements for testing +.. admonition:: Software version and LAMMPS configuration requirements :class: note The compiler and library version requirements for the testing @@ -155,7 +162,7 @@ for implementing the tests. example the default GNU C++ and Fortran compilers of RHEL/CentOS 7.x (version 4.8.x) are not sufficient. The CMake configuration will try to detect incompatible versions and either skip incompatible tests or - stop with an error. Also the number of tests will depend on + stop with an error. Also the number of available tests will depend on installed LAMMPS packages, development environment, operating system, and configuration settings. @@ -234,12 +241,31 @@ will be skipped if prerequisite features are not available in LAMMPS. time. Preference is given to parts of the code base that are easy to test or commonly used. -Tests for styles of the same kind of style (e.g. pair styles or bond -styles) are performed with the same test executable using different -input files in YAML format. So to add a test for another style of the -same kind it may be sufficient to add a suitable YAML file. -:doc:`Detailed instructions for adding tests ` are -provided in the Programmer Guide part of the manual. +Tests as shown by the ``ctest`` program are command lines defined in the +``CMakeLists.txt`` files in the ``unittest`` directory tree. A few +tests simply execute LAMMPS with specific command line flags and check +the output to the screen for expected content. A large number of unit +tests are special tests programs using the `GoogleTest framework +`_ and linked to the LAMMPS +library that test individual functions or create a LAMMPS class +instance, execute one or more commands and check data inside the LAMMPS +class hierarchy. There are also tests for the C-library, Fortran, and +Python module interfaces to LAMMPS. The Python tests use the Python +"unittest" module in a similar fashion than the others use `GoogleTest`. +These special test programs are structured to perform multiple +individual tests internally and each of those contains several checks +(aka assertions) for internal data being changed as expected. + +Tests for force computing or modifying styles (e.g. styles for non-bonded +and bonded interactions and selected fixes) are run by using a more generic +test program that reads its input from files in YAML format. The YAML file +provides the information on how to customized the test program to test +a specific style and - if needed - with specific settings. +To add a test for another, similar style (e.g. a new pair style) it is +usually sufficient to add a suitable YAML file. :doc:`Detailed +instructions for adding tests ` are provided in the +Programmer Guide part of the manual. A description of what happens +during the tests is given below. Unit tests for force styles ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/doc/src/Build_settings.rst b/doc/src/Build_settings.rst index 7fb7539506..34100871ce 100644 --- a/doc/src/Build_settings.rst +++ b/doc/src/Build_settings.rst @@ -44,7 +44,7 @@ require use of an FFT library to compute 1d FFTs. The KISS FFT library is included with LAMMPS, but other libraries can be faster. LAMMPS can use them if they are available on your system. -.. versionadded:: TBD +.. versionadded:: 7Feb2024 Alternatively, LAMMPS can use the `heFFTe `_ library for the MPI @@ -59,15 +59,19 @@ libraries and better pipelining for packing and communication. .. code-block:: bash -D FFT=value # FFTW3 or MKL or KISS, default is FFTW3 if found, else KISS + -D FFT_KOKKOS=value # FFTW3 or MKL or KISS or CUFFT or HIPFFT, default is KISS -D FFT_SINGLE=value # yes or no (default), no = double precision -D FFT_PACK=value # array (default) or pointer or memcpy -D FFT_USE_HEFFTE=value # yes or no (default), yes links to heFFTe .. note:: - The values for the FFT variable must be in upper-case. This is - an exception to the rule that all CMake variables can be specified - with lower-case values. + When the Kokkos variant of a package is compiled and selected at run time, + the FFT library selected by the FFT_KOKKOS variable applies. Otherwise, + the FFT library selected by the FFT variable applies. + The same FFT settings apply to both. FFT_KOKKOS must be compatible with the + Kokkos back end - for example, when using the CUDA back end of Kokkos, + you must use either CUFFT or KISS. Usually these settings are all that is needed. If FFTW3 is selected, then CMake will try to detect, if threaded FFTW @@ -106,6 +110,8 @@ libraries and better pipelining for packing and communication. FFT_INC = -DFFT_FFTW3 # -DFFT_FFTW3, -DFFT_FFTW (same as -DFFT_FFTW3), -DFFT_MKL, or -DFFT_KISS # default is KISS if not specified + FFT_INC = -DFFT_KOKKOS_CUFFT # -DFFT_KOKKOS_{FFTW,FFTW3,MKL,CUFFT,HIPFFT,KISS} + # default is KISS if not specified FFT_INC = -DFFT_SINGLE # do not specify for double precision FFT_INC = -DFFT_FFTW_THREADS # enable using threaded FFTW3 libraries FFT_INC = -DFFT_MKL_THREADS # enable using threaded FFTs with MKL libraries @@ -116,6 +122,8 @@ libraries and better pipelining for packing and communication. FFT_INC = -I/usr/local/include FFT_PATH = -L/usr/local/lib + FFT_LIB = -lhipfft # hipFFT either precision + FFT_LIB = -lcufft # cuFFT either precision FFT_LIB = -lfftw3 # FFTW3 double precision FFT_LIB = -lfftw3 -lfftw3_omp # FFTW3 double precision with threads (needs -DFFT_FFTW_THREADS) FFT_LIB = -lfftw3 -lfftw3f # FFTW3 single precision @@ -178,6 +186,11 @@ The Intel MKL math library is part of the Intel compiler suite. It can be used with the Intel or GNU compiler (see the ``FFT_LIB`` setting above). +The cuFFT and hipFFT FFT libraries are packaged with NVIDIA's CUDA and +AMD's HIP installations, respectively. These FFT libraries require the +Kokkos acceleration package to be enabled and the Kokkos back end to be +GPU-resident (i.e., HIP or CUDA). + Performing 3d FFTs in parallel can be time-consuming due to data access and required communication. This cost can be reduced by performing single-precision FFTs instead of double precision. Single precision @@ -189,11 +202,11 @@ generally less than the difference in precision. Using the ``-DFFT_SINGLE`` setting trades off a little accuracy for reduced memory use and parallel communication costs for transposing 3d FFT data. -When using ``-DFFT_SINGLE`` with FFTW3, you may need to build the FFTW -library a second time with support for single-precision. +When using ``-DFFT_SINGLE`` with FFTW3, you may need to ensure that +the FFTW3 installation includes support for single-precision. -For FFTW3, do the following, which should produce the additional -library ``libfftw3f.a`` or ``libfftw3f.so``\ . +When compiler FFTW3 from source, you can do the following, which should +produce the additional libraries ``libfftw3f.a`` and/or ``libfftw3f.so``\ . .. code-block:: bash diff --git a/doc/src/Commands_bond.rst b/doc/src/Commands_bond.rst index aaf706b5df..ef36b6b7c4 100644 --- a/doc/src/Commands_bond.rst +++ b/doc/src/Commands_bond.rst @@ -124,7 +124,7 @@ OPT. * * * :doc:`charmm (iko) ` - * :doc:`charmmfsw ` + * :doc:`charmmfsw (k) ` * :doc:`class2 (ko) ` * :doc:`cosine/shift/exp (o) ` * :doc:`fourier (io) ` diff --git a/doc/src/Commands_fix.rst b/doc/src/Commands_fix.rst index e89e302673..a7648218fa 100644 --- a/doc/src/Commands_fix.rst +++ b/doc/src/Commands_fix.rst @@ -61,6 +61,7 @@ OPT. * :doc:`controller ` * :doc:`damping/cundall ` * :doc:`deform (k) ` + * :doc:`deform/pressure ` * :doc:`deposit ` * :doc:`dpd/energy (k) ` * :doc:`drag ` @@ -262,6 +263,7 @@ OPT. * :doc:`wall/body/polyhedron ` * :doc:`wall/colloid ` * :doc:`wall/ees ` + * :doc:`wall/flow (k) ` * :doc:`wall/gran (k) ` * :doc:`wall/gran/region ` * :doc:`wall/harmonic ` diff --git a/doc/src/Commands_pair.rst b/doc/src/Commands_pair.rst index e7761e7bee..9bbe216dec 100644 --- a/doc/src/Commands_pair.rst +++ b/doc/src/Commands_pair.rst @@ -146,7 +146,7 @@ OPT. * :doc:`lj/charmm/coul/long/soft (o) ` * :doc:`lj/charmm/coul/msm (o) ` * :doc:`lj/charmmfsw/coul/charmmfsh ` - * :doc:`lj/charmmfsw/coul/long ` + * :doc:`lj/charmmfsw/coul/long (k) ` * :doc:`lj/class2 (gko) ` * :doc:`lj/class2/coul/cut (ko) ` * :doc:`lj/class2/coul/cut/soft ` @@ -256,6 +256,7 @@ OPT. * :doc:`rann ` * :doc:`reaxff (ko) ` * :doc:`rebo (io) ` + * :doc:`rebomos (o) ` * :doc:`resquared (go) ` * :doc:`saip/metal (t) ` * :doc:`sdpd/taitwater/isothermal ` diff --git a/doc/src/Commands_removed.rst b/doc/src/Commands_removed.rst index 98a52fc2d7..0ade07af64 100644 --- a/doc/src/Commands_removed.rst +++ b/doc/src/Commands_removed.rst @@ -129,7 +129,7 @@ USER-REAXC. USER-REAXC package ------------------ -.. deprecated:: TBD +.. deprecated:: 7Feb2024 The USER-REAXC package has been renamed to :ref:`REAXFF `. In the process also the pair style and related fixes were renamed to use diff --git a/doc/src/Developer_updating.rst b/doc/src/Developer_updating.rst index cd61eaa5a1..83491ac095 100644 --- a/doc/src/Developer_updating.rst +++ b/doc/src/Developer_updating.rst @@ -18,6 +18,7 @@ Available topics in mostly chronological order are: - `Setting flags in the constructor`_ - `Rename of pack/unpack_comm() to pack/unpack_forward_comm()`_ - `Use ev_init() to initialize variables derived from eflag and vflag`_ +- `Use utils::count_words() functions instead of atom->count_words()`_ - `Use utils::numeric() functions instead of force->numeric()`_ - `Use utils::open_potential() function to open potential files`_ - `Use symbolic Atom and AtomVec constants instead of numerical values`_ @@ -130,6 +131,41 @@ Not applying this change will not cause a compilation error, but can lead to inconsistent behavior and incorrect tallying of energy or virial. +Use utils::count_words() functions instead of atom->count_words() +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. versionchanged:: 2Jun2020 + +The "count_words()" functions for parsing text have been moved from the +Atom class to the :doc:`utils namespace `. The +"count_words()" function in "utils" uses the Tokenizer class internally +to split a line into words and count them, thus it will not modify the +argument string as the function in the Atoms class did and thus had a +variant using a copy buffer. Unlike the old version, the new version +does not remove comments. For that you can use the +:cpp:func:`utils::trim_comment() function +` as shown in the example below. + +Old: + +.. code-block:: c++ + + nwords = atom->count_words(line); + int nwords = atom->count_words(buf); + +New: + +.. code-block:: c++ + + nwords = utils::count_words(line); + int nwords = utils::count_words(utils::trim_comment(buf)); + +.. seealso:: + + :cpp:func:`utils::count_words() `, + :cpp:func:`utils::trim_comments() ` + + Use utils::numeric() functions instead of force->numeric() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -137,11 +173,12 @@ Use utils::numeric() functions instead of force->numeric() The "numeric()" conversion functions (including "inumeric()", "bnumeric()", and "tnumeric()") have been moved from the Force class to -the utils namespace. Also they take an additional argument that selects -whether the ``Error::all()`` or ``Error::one()`` function should be -called in case of an error. The former should be used when *all* MPI -processes call the conversion function and the latter *must* be used -when they are called from only one or a subset of the MPI processes. +the :doc:`utils namespace `. Also they take an +additional argument that selects whether the ``Error::all()`` or +``Error::one()`` function should be called in case of an error. The +former should be used when *all* MPI processes call the conversion +function and the latter *must* be used when they are called from only +one or a subset of the MPI processes. Old: diff --git a/doc/src/Fortran.rst b/doc/src/Fortran.rst index 76fdff753a..64fca57a02 100644 --- a/doc/src/Fortran.rst +++ b/doc/src/Fortran.rst @@ -315,6 +315,10 @@ of the contents of the :f:mod:`LIBLAMMPS` Fortran interface to LAMMPS. :ftype extract_variable: function :f set_variable: :f:subr:`set_variable` :ftype set_variable: subroutine + :f set_string_variable: :f:subr:`set_set_string_variable` + :ftype set_string_variable: subroutine + :f set_internal_variable: :f:subr:`set_internal_variable` + :ftype set_internal_variable: subroutine :f gather_atoms: :f:subr:`gather_atoms` :ftype gather_atoms: subroutine :f gather_atoms_concat: :f:subr:`gather_atoms_concat` @@ -1398,7 +1402,28 @@ Procedures Bound to the :f:type:`lammps` Derived Type Set the value of a string-style variable. - .. versionadded:: 3Nov2022 + .. deprecated:: 7Feb2024 + + This function assigns a new value from the string *str* to the string-style + variable *name*\ . If *name* does not exist or is not a string-style + variable, an error is generated. + + .. warning:: + + This subroutine is deprecated and :f:subr:`set_string_variable` + should be used instead. + + :p character(len=*) name: name of the variable + :p character(len=*) str: new value to assign to the variable + :to: :cpp:func:`lammps_set_variable` + +-------- + +.. f:subroutine:: set_string_variable(name, str) + + Set the value of a string-style variable. + + .. versionadded:: 7Feb2024 This function assigns a new value from the string *str* to the string-style variable *name*\ . If *name* does not exist or is not a string-style @@ -1406,7 +1431,23 @@ Procedures Bound to the :f:type:`lammps` Derived Type :p character(len=*) name: name of the variable :p character(len=*) str: new value to assign to the variable - :to: :cpp:func:`lammps_set_variable` + :to: :cpp:func:`lammps_set_string_variable` + +-------- + +.. f:subroutine:: set_internal_variable(name, val) + + Set the value of a internal-style variable. + + .. versionadded:: 7Feb2024 + + This function assigns a new value from the floating-point number *val* to + the internal-style variable *name*\ . If *name* does not exist or is not + an internal-style variable, an error is generated. + + :p character(len=*) name: name of the variable + :p read(c_double) val: new value to assign to the variable + :to: :cpp:func:`lammps_set_internal_variable` -------- diff --git a/doc/src/Howto_cmake.rst b/doc/src/Howto_cmake.rst index 42324cf2f1..8b710d1065 100644 --- a/doc/src/Howto_cmake.rst +++ b/doc/src/Howto_cmake.rst @@ -349,6 +349,8 @@ Some common LAMMPS specific variables - when set to ``name`` the LAMMPS executable and library will be called ``lmp_name`` and ``liblammps_name.a`` * - ``FFT`` - select which FFT library to use: ``FFTW3``, ``MKL``, ``KISS`` (default, unless FFTW3 is found) + * - ``FFT_KOKKOS`` + - select which FFT library to use in Kokkos-enabled styles: ``FFTW3``, ``MKL``, ``HIPFFT``, ``CUFFT``, ``KISS`` (default) * - ``FFT_SINGLE`` - select whether to use single precision FFTs (default: ``off``) * - ``WITH_JPEG`` diff --git a/doc/src/Howto_granular.rst b/doc/src/Howto_granular.rst index c22cab66bc..b0c801be11 100644 --- a/doc/src/Howto_granular.rst +++ b/doc/src/Howto_granular.rst @@ -45,10 +45,15 @@ atoms, and should be used for granular system instead of the fix style To model heat conduction, one must add the temperature and heatflow atom variables with: + * :doc:`fix property/atom ` + a temperature integration fix + * :doc:`fix heat/flow ` + and a heat conduction option defined in both + * :doc:`pair_style granular ` * :doc:`fix wall/gran ` diff --git a/doc/src/Howto_structured_data.rst b/doc/src/Howto_structured_data.rst index 29c65a7a34..8b9c3dbc80 100644 --- a/doc/src/Howto_structured_data.rst +++ b/doc/src/Howto_structured_data.rst @@ -52,8 +52,8 @@ JSON "ke": 2.4962152903997174569 } -YAML format thermo_style output -=============================== +YAML format thermo_style or dump_style output +============================================= Extracting data from log file ----------------------------- @@ -112,6 +112,9 @@ of that run: Number of runs: 2 TotEng = -4.62140097780047 +Extracting data from dump file +------------------------------ + .. versionadded:: 4May2022 YAML format output has been added to multiple commands in LAMMPS, diff --git a/doc/src/Library_objects.rst b/doc/src/Library_objects.rst index db21817cfd..7c0ca824d7 100644 --- a/doc/src/Library_objects.rst +++ b/doc/src/Library_objects.rst @@ -9,6 +9,8 @@ fixes, or variables in LAMMPS using the following functions: - :cpp:func:`lammps_extract_variable_datatype` - :cpp:func:`lammps_extract_variable` - :cpp:func:`lammps_set_variable` +- :cpp:func:`lammps_set_string_variable` +- :cpp:func:`lammps_set_internal_variable` - :cpp:func:`lammps_variable_info` ----------------------- @@ -38,6 +40,16 @@ fixes, or variables in LAMMPS using the following functions: ----------------------- +.. doxygenfunction:: lammps_set_string_variable + :project: progguide + +----------------------- + +.. doxygenfunction:: lammps_set_internal_variable + :project: progguide + +----------------------- + .. doxygenfunction:: lammps_variable_info :project: progguide diff --git a/doc/src/Modify_style.rst b/doc/src/Modify_style.rst index e02c2ce59f..496415237c 100644 --- a/doc/src/Modify_style.rst +++ b/doc/src/Modify_style.rst @@ -96,6 +96,39 @@ list all non-conforming lines. By adding the `-f` flag to the command line, they will modify the flagged files to try to remove the detected issues. +Constants (strongly preferred) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Global or per-file constants should be declared as `static constexpr` +variables rather than via the pre-processor with `#define`. The name of +constants should be all uppercase. This has multiple advantages: + +- constants are easily identified as such by their all upper case name +- rather than a pure text substitution during pre-processing, `constexpr + variables` have a type associated with them and are processed later in + the parsing process where the syntax checks and type specific + processing (e.g. via overloads) can be applied to them. +- compilers can emit a warning if the constant is not used and thus can + be removed (we regularly check for and remove dead code like this) +- there are no unexpected substitutions and thus confusing syntax errors + when compiling leading to, for instance, conflicts so that LAMMPS + cannot be compiled with certain combinations of packages (this *has* + happened multiple times in the past). + +Pre-processor defines should be limited to macros (but consider C++ +templates) and conditional compilation. If a per-processor define must +be used, it should be defined at the top of the .cpp file after the +include statements and at all cost it should be avoided to put them into +header files. + +Some sets of commonly used constants are provided in the ``MathConst`` +and ``EwaldConst`` namespaces and implemented in the files +``math_const.h`` and ``ewald_const.h``, respectively. + +There are always exceptions, special cases, and legacy code in LAMMPS, +so please contact the LAMMPS developers if you are not sure. + + Placement of braces (strongly preferred) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/doc/src/Speed_kokkos.rst b/doc/src/Speed_kokkos.rst index 1cae518f96..41ae4a4dfb 100644 --- a/doc/src/Speed_kokkos.rst +++ b/doc/src/Speed_kokkos.rst @@ -20,11 +20,28 @@ including Sikandar Mashayak (UIUC), Ray Shan (Sandia), and Dan Ibanez (Sandia). For more information on developing using Kokkos abstractions see the `Kokkos Wiki `_. -Kokkos currently provides support for 4 modes of execution (per MPI +.. note:: + + The Kokkos library is under active development and tracking the + availability of accelerator hardware, so is the KOKKOS package in + LAMMPS. This means that only a certain range of versions of the + Kokkos library are compatible with the KOKKOS package of a certain + range of LAMMPS versions. For that reason LAMMPS comes with a + bundled version of the Kokkos library that has been validated on + multiple platforms and may contain selected back-ported bug fixes + from upstream Kokkos versions. While it is possible to build LAMMPS + with an external version of Kokkos, it is untested and may result in + incorrect execution or crashes. + +Kokkos currently provides full support for 4 modes of execution (per MPI task). These are Serial (MPI-only for CPUs and Intel Phi), OpenMP -(threading for many-core CPUs and Intel Phi), CUDA (for NVIDIA -GPUs) and HIP (for AMD GPUs). You choose the mode at build time to -produce an executable compatible with a specific hardware. +(threading for many-core CPUs and Intel Phi), CUDA (for NVIDIA GPUs) and +HIP (for AMD GPUs). Additional modes (e.g. OpenMP target, Intel data +center GPUs) are under development. You choose the mode at build time +to produce an executable compatible with a specific hardware. + +The following compatibility notes have been last updated for LAMMPS +version 23 November 2023 and Kokkos version 4.2. .. admonition:: C++17 support :class: note @@ -54,22 +71,22 @@ produce an executable compatible with a specific hardware. :class: note Kokkos with CUDA currently implicitly assumes that the MPI library is - GPU-aware. This is not always the case, especially when using + GPU-aware. This is not always the case, especially when using pre-compiled MPI libraries provided by a Linux distribution. This is not a problem when using only a single GPU with a single MPI - rank. When running with multiple MPI ranks, you may see segmentation + rank. When running with multiple MPI ranks, you may see segmentation faults without GPU-aware MPI support. These can be avoided by adding the flags :doc:`-pk kokkos gpu/aware off ` to the LAMMPS command line or by using the command :doc:`package kokkos gpu/aware off ` in the input file. -.. admonition:: AMD GPU support +.. admonition:: Intel Data Center GPU support :class: note - To build with Kokkos the HIPCC compiler from the AMD ROCm software - version 3.5 or later is required. Supporting this Kokkos mode in - LAMMPS is still work in progress. Please contact the LAMMPS developers - if you run into problems. + Support for Kokkos with Intel Data Center GPU accelerators (formerly + known under the code name "Ponte Vecchio") in LAMMPS is still a work + in progress. Only a subset of the functionality works correctly. + Please contact the LAMMPS developers if you run into problems. Building LAMMPS with the KOKKOS package """"""""""""""""""""""""""""""""""""""" @@ -292,6 +309,10 @@ one or more nodes, each with two GPUs: settings. Experimenting with its options can provide a speed-up for specific calculations. For example: +.. code-block:: bash + + mpirun -np 2 lmp_kokkos_cuda_openmpi -k on g 2 -sf kk -pk kokkos newton on neigh half binsize 2.8 -in in.lj # Newton on, half neighbor list, set binsize = neighbor ghost cutoff + .. note:: The default binsize for :doc:`atom sorting ` on GPUs @@ -302,9 +323,15 @@ one or more nodes, each with two GPUs: frequent sorting than default (e.g. sorting every 100 time steps instead of 1000) may improve performance. -.. code-block:: bash +.. note:: - mpirun -np 2 lmp_kokkos_cuda_openmpi -k on g 2 -sf kk -pk kokkos newton on neigh half binsize 2.8 -in in.lj # Newton on, half neighbor list, set binsize = neighbor ghost cutoff + When running on GPUs with many MPI ranks (tens of thousands and + more), the creation of the atom map (required for molecular systems) + on the GPU can slow down significantly or run out of GPU memory and + thus slow down the whole calculation or cause a crash. You can use + the "-pk kokkos atom/map no" :doc:`command-line switch ` + of the :doc:`package kokkos atom/map no ` command to create + the atom map on the CPU instead. .. note:: @@ -416,15 +443,22 @@ Generally speaking, the following rules of thumb apply: performance of a KOKKOS style is a bit slower than the OPENMP package. * When running large number of atoms per GPU, KOKKOS is typically faster - than the GPU package when compiled for double precision. The benefit + than the GPU package when compiled for double precision. The benefit of using single or mixed precision with the GPU package depends significantly on the hardware in use and the simulated system and pair style. -* When running on Intel hardware, KOKKOS is not as fast as +* When running on Intel Phi hardware, KOKKOS is not as fast as the INTEL package, which is optimized for x86 hardware (not just from Intel) and compilation with the Intel compilers. The INTEL package also can increase the vector length of vector instructions by switching to single or mixed precision mode. +* The KOKKOS package by default assumes that you are using exactly one + MPI rank per GPU. When trying to use multiple MPI ranks per GPU it is + mandatory to enable `CUDA Multi-Process Service (MPS) + `_ to get good + performance. In this case it is better to not use all available + MPI ranks in order to avoid competing with the MPS daemon for + CPU resources. See the `Benchmark page `_ of the LAMMPS website for performance of the KOKKOS package on different diff --git a/doc/src/angle_charmm.rst b/doc/src/angle_charmm.rst index 425ed7e4f1..655b860a28 100644 --- a/doc/src/angle_charmm.rst +++ b/doc/src/angle_charmm.rst @@ -70,7 +70,9 @@ for more info. Related commands """""""""""""""" -:doc:`angle_coeff ` +:doc:`angle_coeff `, :doc:`pair_style lj/charmm variants `, +:doc:`dihedral_style charmm `, +:doc:`dihedral_style charmmfsw `, :doc:`fix cmap ` Default """"""" diff --git a/doc/src/angle_lepton.rst b/doc/src/angle_lepton.rst index 20fa5b1fee..e03e5cf456 100644 --- a/doc/src/angle_lepton.rst +++ b/doc/src/angle_lepton.rst @@ -11,7 +11,16 @@ Syntax .. code-block:: LAMMPS - angle_style lepton + angle_style style args + +* style = *lepton* +* args = optional arguments + +.. parsed-literal:: + + args = *auto_offset* or *no_offset* + *auto_offset* = offset the potential energy so that the value at theta0 is 0.0 (default) + *no_offset* = do not offset the potential energy Examples """""""" @@ -19,6 +28,7 @@ Examples .. code-block:: LAMMPS angle_style lepton + angle_style lepton no_offset angle_coeff 1 120.0 "k*theta^2; k=250.0" angle_coeff 2 90.0 "k2*theta^2 + k3*theta^3 + k4*theta^4; k2=300.0; k3=-100.0; k4=50.0" @@ -41,6 +51,13 @@ angle coefficient. For example `"200.0*theta^2"` represents a U_{angle,i} = K (\theta_i - \theta_0)^2 = K \theta^2 \qquad \theta = \theta_i - \theta_0 +.. versionchanged:: 7Feb2024 + +By default the potential energy U is shifted so that the value U is 0.0 +for $theta = theta_0$. This is equivalent to using the optional keyword +*auto_offset*. When using the keyword *no_offset* instead, the +potential energy is not shifted. + The `Lepton library `_, that the *lepton* angle style interfaces with, evaluates this expression string at run time to compute the pairwise energy. It also creates an diff --git a/doc/src/atom_style.rst b/doc/src/atom_style.rst index b5ee0f07ff..60a85e0bcb 100644 --- a/doc/src/atom_style.rst +++ b/doc/src/atom_style.rst @@ -49,248 +49,221 @@ Examples Description """"""""""" -Define what style of atoms to use in a simulation. This determines -what attributes are associated with the atoms. This command must be -used before a simulation is setup via a :doc:`read_data `, -:doc:`read_restart `, or :doc:`create_box ` -command. +The *atom_style* command selects which per-atom attributes are +associated with atoms in a LAMMPS simulation and thus stored and +communicated with those atoms as well as read from and stored in data +and restart files. Different models (e.g. :doc:`pair styles +`) require access to specific per-atom attributes and thus +require a specific atom style. For example, to compute Coulomb +interactions, the atom must have a "charge" (aka "q") attribute. + +A number of distinct atom styles exist that combine attributes. Some +atom styles are a superset of other atom styles. Further attributes +may be added to atoms either via using a hybrid style which provides a +union of the attributes of the sub-styles, or via the :doc:`fix +property/atom ` command. The *atom_style* command +must be used before a simulation is setup via a :doc:`read_data +`, :doc:`read_restart `, or :doc:`create_box +` command. .. note:: - Many of the atom styles discussed here are only enabled if - LAMMPS was built with a specific package, as listed below in the - Restrictions section. + Many of the atom styles discussed here are only enabled if LAMMPS was + built with a specific package, as listed below in the Restrictions + section. -Once a style is assigned, it cannot be changed, so use a style general -enough to encompass all attributes. E.g. with style *bond*, angular -terms cannot be used or added later to the model. It is OK to use a -style more general than needed, though it may be slightly inefficient. +Once a style is selected and the simulation box defined, it cannot be +changed but only augmented with the :doc:`fix property/atom +` command. So one should select an atom style +general enough to encompass all attributes required. E.g. with atom +style *bond*, it is not possible to define angles and use angle styles. -The choice of style affects what quantities are stored by each atom, -what quantities are communicated between processors to enable forces -to be computed, and what quantities are listed in the data file read -by the :doc:`read_data ` command. +It is OK to use a style more general than needed, though it may be +slightly inefficient because it will allocate and communicate +additional unused data. -These are the additional attributes of each style and the typical -kinds of physical systems they are used to model. All styles store -coordinates, velocities, atom IDs and types. See the +Atom style attributes +""""""""""""""""""""" + +The atom style *atomic* has the minimum subset of per-atom attributes +and is also the default setting. It encompasses the following per-atom +attributes (name of the vector or array in the :doc:`Atom class +` is given in parenthesis): atom-ID (tag), type (type), +position (x), velocities (v), forces (f), image flags (image), group +membership (mask). Since all atom styles are a superset of atom style +*atomic*\ , they all include these attributes. + +This table lists all the available atom styles, which attributes they +provide, which :doc:`package ` is required to use them, and +what the typical applications are that use them. See the :doc:`read_data `, :doc:`create_atoms `, and -:doc:`set ` commands for info on how to set these various -quantities. +:doc:`set ` commands for details on how to set these various +quantities. More information about many of the styles is provided in +the Additional Information section below. -+--------------+-----------------------------------------------------+--------------------------------------+ -| *amoeba* | molecular + charge + 1/5 neighbors | AMOEBA/HIPPO polarized force fields | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *angle* | bonds and angles | bead-spring polymers with stiffness | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *atomic* | only the default values | coarse-grain liquids, solids, metals | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *body* | mass, inertia moments, quaternion, angular momentum | arbitrary bodies | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *bond* | bonds | bead-spring polymers | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *charge* | charge | atomic system with charges | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *dielectric* | normx normy normz area/patch ed em epsilon curv | system with surface polarization | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *dipole* | charge and dipole moment | system with dipolar particles | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *dpd* | internal temperature and internal energies | DPD particles | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *edpd* | temperature and heat capacity | eDPD particles | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *electron* | charge and spin and eradius | electronic force field | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *ellipsoid* | shape, quaternion, angular momentum | aspherical particles | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *full* | molecular + charge | bio-molecules | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *line* | end points, angular velocity | rigid bodies | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *mdpd* | density | mDPD particles | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *molecular* | bonds, angles, dihedrals, impropers | uncharged molecules | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *oxdna* | nucleotide polarity | coarse-grained DNA and RNA models | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *peri* | mass, volume | mesoscopic Peridynamic models | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *smd* | volume, kernel diameter, contact radius, mass | solid and fluid SPH particles | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *sph* | rho, esph, cv | SPH particles | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *sphere* | diameter, mass, angular velocity | granular models | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *bpm/sphere* | diameter, mass, angular velocity, quaternion | granular bonded particle models (BPM)| -+--------------+-----------------------------------------------------+--------------------------------------+ -| *spin* | magnetic moment | system with magnetic particles | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *tdpd* | chemical concentration | tDPD particles | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *template* | template index, template atom | small molecules with fixed topology | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *tri* | corner points, angular momentum | rigid bodies | -+--------------+-----------------------------------------------------+--------------------------------------+ -| *wavepacket* | charge, spin, eradius, etag, cs_re, cs_im | AWPMD | -+--------------+-----------------------------------------------------+--------------------------------------+ +.. list-table:: + :header-rows: 1 + :widths: auto + + * - Atom style + - Attributes + - Required package + - Applications + * - *amoeba* + - *full* + "1-5 special neighbor data" + - :ref:`AMOEBA ` + - AMOEBA/HIPPO force fields + * - *angle* + - *bond* + "angle data" + - :ref:`MOLECULE ` + - bead-spring polymers with stiffness + * - *atomic* + - tag, type, x, v, f, image, mask + - + - atomic liquids, solids, metals + * - *body* + - *atomic* + radius, rmass, angmom, torque, body + - :ref:`BODY ` + - arbitrary bodies, see :doc:`body howto ` + * - *bond* + - *atomic* + molecule, nspecial, special + "bond data" + - :ref:`MOLECULE ` + - bead-spring polymers + * - *bpm/sphere* + - *bond* + radius, rmass, omega, torque, quat + - :ref:`BPM ` + - granular bonded particle models, see :doc:`BPM howto ` + * - *charge* + - *atomic* + q + - + - atomic systems with charges + * - *dielectric* + - *full* + mu, area, ed, em, epsilon, curvature, q_scaled + - :ref:`DIELECTRIC ` + - systems with surface polarization + * - *dipole* + - *charge* + mu + - :ref:`DIPOLE ` + - atomic systems with charges and point dipoles + * - *dpd* + - *atomic* + rho + "reactive DPD data" + - :ref:`DPD-REACT ` + - reactive DPD + * - *edpd* + - *atomic* + "eDPD data" + - :ref:`DPD-MESO ` + - Energy conservative DPD (eDPD) + * - *electron* + - *charge* + espin, eradius, ervel, erforce + - :ref:`EFF ` + - Electron force field systems + * - *ellipsoid* + - *atomic* + rmass, angmom, torque, ellipsoid + - + - aspherical particles + * - *full* + - *molecular* + q + - :ref:`MOLECULE ` + - molecular force fields + * - *line* + - *atomic* + molecule, radius, rmass, omega, torque, line + - + - 2-d rigid body particles + * - *mdpd* + - *atomic* + rho, drho, vest + - :ref:`DPD-MESO ` + - Many-body DPD (mDPD) + * - *molecular* + - *angle* + "dihedral and improper data" + - :ref:`MOLECULE ` + - apolar and uncharged molecules + * - *oxdna* + - *atomic* + id5p + - :ref:`CG-DNA ` + - coarse-grained DNA and RNA models + * - *peri* + - *atomic* + rmass, vfrac, s0, x0 + - :ref:`PERI ` + - mesoscopic Peridynamics models + * - *smd* + - *atomic* + molecule, radius, rmass + "smd data" + - :ref:`MACHDYN ` + - Smooth Mach Dynamics models + * - *sph* + - *atomic* + "sph data" + - :ref:`SPH ` + - Smoothed particle hydrodynamics models + * - *sphere* + - *atomic* + radius, rmass, omega, torque + - + - finite size spherical particles, e.g. granular models + * - *spin* + - *atomic* + "magnetic moment data" + - :ref:`SPIN ` + - magnetic particles + * - *tdpd* + - *atomic* + cc, cc_flux, vest + - :ref:`DPD-MESO ` + - Transport DPD (tDPD) + * - *template* + - *atomic* + molecule, molindex, molatom + - :ref:`MOLECULE ` + - molecular systems where attributes are taken from :doc:`molecule files ` + * - *tri* + - *sphere* + molecule, angmom, tri + - + - 3-d triangulated rigid body LJ particles + * - *wavepacket* + - *charge* + "wavepacket data" + - :ref:`AWPMD ` + - Antisymmetrized wave packet MD .. note:: - It is possible to add some attributes, such as a molecule ID, to - atom styles that do not have them via the :doc:`fix property/atom - ` command. This command also allows new custom - attributes consisting of extra integer or floating-point values to - be added to atoms. See the :doc:`fix property/atom - ` page for examples of cases where this is - useful and details on how to initialize, access, and output the - custom values. + It is possible to add some attributes, such as a molecule ID and + charge, to atom styles that do not have them built in using the + :doc:`fix property/atom ` command. This command + also allows new custom-named attributes consisting of extra integer + or floating-point values or vectors to be added to atoms. See the + :doc:`fix property/atom ` page for examples of + cases where this is useful and details on how to initialize, + access, and output these custom values. -All of the above styles define point particles, except the *sphere*, -*bpm/sphere*, *ellipsoid*, *electron*, *peri*, *wavepacket*, *line*, -*tri*, and *body* styles, which define finite-size particles. See the -:doc:`Howto spherical ` page for an overview of using -finite-size particle models with LAMMPS. +---------- -All of the point-particle styles assign mass to particles on a -per-type basis, using the :doc:`mass ` command, The finite-size -particle styles assign mass to individual particles on a per-particle -basis. +Particle size and mass +"""""""""""""""""""""" -For the *sphere* and *bpm/sphere* styles, the particles are spheres -and each stores a per-particle diameter and mass. If the diameter > -0.0, the particle is a finite-size sphere. If the diameter = 0.0, it -is a point particle. Note that by use of the *disc* keyword with the -:doc:`fix nve/sphere `, :doc:`fix nvt/sphere -`, :doc:`fix nph/sphere `, -:doc:`fix npt/sphere ` commands for the *sphere* style, -spheres can be effectively treated as 2d discs for a 2d simulation if -desired. See also the :doc:`set density/disc ` command. These -styles take an optional 0 or 1 argument. A value of 0 means the -radius of each sphere is constant for the duration of the simulation. -A value of 1 means the radii may vary dynamically during the simulation, -e.g. due to use of the :doc:`fix adapt ` command. +All of the atom styles define point particles unless they (1) define +finite-size spherical particles via the *radius* attribute, or (2) +define finite-size aspherical particles (e.g. the *body*, *ellipsoid*, +*line*, and *tri* styles). Most of these styles can also be used with +mixtures of point and finite-size particles. -For the *ellipsoid* style, the particles are ellipsoids and each -stores a flag which indicates whether it is a finite-size ellipsoid or -a point particle. If it is an ellipsoid, it also stores a shape -vector with the 3 diameters of the ellipsoid and a quaternion 4-vector -with its orientation. +Note that the *radius* property may need to be provided as a +*diameter* (e.g. in :doc:`molecule files ` or :doc:`data +files `). See the :doc:`Howto spherical ` +page for an overview of using finite-size spherical and aspherical +particle models with LAMMPS. -For the *dielectric* style, each particle can be either a physical -particle (e.g. an ion), or an interface particle representing a boundary -element between two regions of different dielectric constant. For -interface particles, in addition to the properties associated with -atom_style full, each particle also should be assigned a normal unit -vector (defined by normx, normy, normz), an area (area/patch), the -difference and mean of the dielectric constants of two sides of the -interface along the direction of the normal vector (ed and em), the -local dielectric constant at the boundary element (epsilon), and a mean -local curvature (curv). Physical particles must be assigned these -values, as well, but only their local dielectric constants will be used; -see documentation for associated :doc:`pair styles ` -and :doc:`fixes `. The distinction between the physical -and interface particles is only meaningful when :doc:`fix polarize -` commands are applied to the interface particles. This -style is part of the DIELECTRIC package. +Unless an atom style defines the per-atom *rmass* attribute, particle +masses are defined on a per-type basis, using the :doc:`mass ` +command. This means each particle's mass is indexed by its atom +*type*. -For the *dipole* style, a point dipole is defined for each point -particle. Note that if you wish the particles to be finite-size -spheres as in a Stockmayer potential for a dipolar fluid, so that the -particles can rotate due to dipole-dipole interactions, then you need -to use atom_style hybrid sphere dipole, which will assign both a -diameter and dipole moment to each particle. +A few styles define the per-atom *rmass* attribute which can also be +added using the :doc:`fix property/atom ` command. +In this case each particle stores its own mass. Atom styles that have +a per-atom rmass may define it indirectly through setting particle +diameter and density on a per-particle basis. If both per-type mass +and per-atom *rmass* are defined (e.g. in a hybrid style), the +per-atom mass will take precedence in any operation which which works +with both flavors of mass. -For the *electron* style, the particles representing electrons are 3d -Gaussians with a specified position and bandwidth or uncertainty in -position, which is represented by the eradius = electron size. +---------- -For the *peri* style, the particles are spherical and each stores a -per-particle mass and volume. - -The *bpm/sphere* style is part of the BPM package. - -The *oxdna* style is for coarse-grained nucleotides and stores the -3'-to-5' polarity of the nucleotide strand, which is set through -the bond topology in the data file. The first (second) atom in a -bond definition is understood to point towards the 3'-end (5'-end) -of the strand. Note that this style is part of the CG-DNA package. - -The *dpd* style is for dissipative particle dynamics (DPD) particles. -Note that it is part of the DPD-REACT package, and is not for use with -the :doc:`pair_style dpd or dpd/stat ` commands, which can -simply use atom_style atomic. Atom_style dpd extends DPD particle -properties with internal temperature (dpdTheta), internal conductive -energy (uCond), internal mechanical energy (uMech), and internal -chemical energy (uChem). - -The *edpd* style is for energy-conserving dissipative particle -dynamics (eDPD) particles which store a temperature (edpd_temp), and -heat capacity(edpd_cv). - -The *mdpd* style is for many-body dissipative particle dynamics (mDPD) -particles which store a density (rho) for considering -density-dependent many-body interactions. - -The *tdpd* style is for transport dissipative particle dynamics (tDPD) -particles which store a set of chemical concentration. An integer -"cc_species" is required to specify the number of chemical species -involved in a tDPD system. - -The *sph* style is for smoothed particle hydrodynamics (SPH) -particles which store a density (rho), energy (esph), and heat capacity -(cv). - -The *smd* style is for a general formulation of Smooth Particle -Hydrodynamics. Both fluids and solids can be modeled. Particles -store the mass and volume of an integration point, a kernel diameter -used for calculating the field variables (e.g. stress and deformation) -and a contact radius for calculating repulsive forces which prevent -individual physical bodies from penetrating each other. - -For the *spin* style, a magnetic spin is associated to each atom. -Those spins have a norm (their magnetic moment) and a direction. - -The *wavepacket* style is similar to *electron*, but the electrons may -consist of several Gaussian wave packets, summed up with coefficients -cs= (cs_re,cs_im). Each of the wave packets is treated as a separate -particle in LAMMPS, wave packets belonging to the same electron must -have identical *etag* values. - -For the *line* style, the particles are idealized line segments and -each stores a per-particle mass and length and orientation (i.e. the -end points of the line segment). - -For the *tri* style, the particles are planar triangles and each -stores a per-particle mass and size and orientation (i.e. the corner -points of the triangle). - -The *template* style allows molecular topology (bonds,angles,etc) to be -defined via a molecule template using the :doc:`molecule ` -command. The template stores one or more molecules with a single copy -of the topology info (bonds,angles,etc) of each. Individual atoms -only store a template index and template atom to identify which -molecule and which atom-within-the-molecule they represent. Using the -*template* style instead of the *bond*, *angle*, *molecular* styles -can save memory for systems comprised of a large number of small -molecules, all of a single type (or small number of types). See the -paper by Grime and Voth, in :ref:`(Grime) `, for examples of how this -can be advantageous for large-scale coarse-grained systems. -The ``examples/template`` directory has a few demo inputs and examples -showing the use of the *template* atom style versus *molecular*. - -.. note:: - - When using the *template* style with a :doc:`molecule template - ` that contains multiple molecules, you should ensure the - atom types, bond types, angle_types, etc in all the molecules are - consistent. E.g. if one molecule represents H2O and another CO2, - then you probably do not want each molecule file to define 2 atom - types and a single bond type, because they will conflict with each - other when a mixture system of H2O and CO2 molecules is defined, - e.g. by the :doc:`read_data ` command. Rather the H2O - molecule should define atom types 1 and 2, and bond type 1. And - the CO2 molecule should define atom types 3 and 4 (or atom types 3 - and 2 if a single oxygen type is desired), and bond type 2. +Additional information about specific atom styles +""""""""""""""""""""""""""""""""""""""""""""""""" For the *body* style, the particles are arbitrary bodies with internal attributes defined by the "style" of the bodies, which is specified by @@ -309,6 +282,148 @@ Note that there may be additional arguments required along with the *bstyle* specification, in the atom_style body command. These arguments are described on the :doc:`Howto body ` doc page. +For the *dielectric* style, each particle can be either a physical +particle (e.g. an ion), or an interface particle representing a boundary +element between two regions of different dielectric constant. For +interface particles, in addition to the properties associated with +atom_style full, each particle also should be assigned a normal unit +vector (defined by normx, normy, normz), an area (area/patch), the +difference and mean of the dielectric constants of two sides of the +interface along the direction of the normal vector (ed and em), the +local dielectric constant at the boundary element (epsilon), and a mean +local curvature (curv). Physical particles must be assigned these +values, as well, but only their local dielectric constants will be used; +see documentation for associated :doc:`pair styles ` +and :doc:`fixes `. The distinction between the physical +and interface particles is only meaningful when :doc:`fix polarize +` commands are applied to the interface particles. This +style is part of the DIELECTRIC package. + +For the *dipole* style, a point dipole vector mu is defined for each +point particle. Note that if you wish the particles to be finite-size +spheres as in a Stockmayer potential for a dipolar fluid, so that the +particles can rotate due to dipole-dipole interactions, then you need +to use the command `atom_style hybrid sphere dipole`, which will +assign both a diameter and dipole moment to each particle. This also +requires using an integrator with a "/sphere" suffix like :doc:`fix +nve/sphere ` or :doc:`fix nvt/sphere ` +and the "update dipole" or "update dlm" parameters to the fix +commands. + +The *dpd* style is for reactive dissipative particle dynamics (DPD) +particles. Note that it is part of the DPD-REACT package, and is not +required for use with the :doc:`pair_style dpd or dpd/stat ` +commands, which only require the attributes from atom_style *atomic*. +Atom_style *dpd* extends DPD particle properties with internal +temperature (dpdTheta), internal conductive energy (uCond), internal +mechanical energy (uMech), and internal chemical energy (uChem). + +The *edpd* style is for energy-conserving dissipative particle +dynamics (eDPD) particles which store a temperature (edpd_temp), and +heat capacity (edpd_cv). + +For the *electron* style, the particles representing electrons are 3d +Gaussians with a specified position and bandwidth or uncertainty in +position, which is represented by the eradius = electron size. + +For the *ellipsoid* style, particles can be ellipsoids which each +stores a shape vector with the 3 diameters of the ellipsoid and a +quaternion 4-vector with its orientation. Each particle stores a flag +in the ellipsoid vector which indicates whether it is an ellipsoid (1) +or a point particle (0). + +For the *line* style, particles can be are idealized line segments +which store a per-particle mass and length and orientation (i.e. the +end points of the line segment). Each particle stores a flag in the +line vector which indicates whether it is a line segment (1) or a +point particle (0). + +The *mdpd* style is for many-body dissipative particle dynamics (mDPD) +particles which store a density (rho) for considering density-dependent +many-body interactions. + +The *oxdna* style is for coarse-grained nucleotides and stores the +3'-to-5' polarity of the nucleotide strand, which is set through +the bond topology in the data file. The first (second) atom in a +bond definition is understood to point towards the 3'-end (5'-end) +of the strand. + +For the *peri* style, the particles are spherical and each stores a +per-particle mass and volume. + +The *smd* style is for Smooth Particle Mach dynamics. Both fluids and +solids can be modeled. Particles store the mass and volume of an +integration point, a kernel diameter used for calculating the field +variables (e.g. stress and deformation) and a contact radius for +calculating repulsive forces which prevent individual physical bodies +from penetrating each other. + +The *sph* style is for smoothed particle hydrodynamics (SPH) particles +which store a density (rho), energy (esph), and heat capacity (cv). + +For the *spin* style, a magnetic spin is associated with each atom. +Those spins have a norm (their magnetic moment) and a direction. + +The *tdpd* style is for transport dissipative particle dynamics (tDPD) +particles which store a set of chemical concentration. An integer +"cc_species" is required to specify the number of chemical species +involved in a tDPD system. + +The *wavepacket* style is similar to the *electron* style, but the +electrons may consist of several Gaussian wave packets, summed up with +coefficients cs= (cs_re,cs_im). Each of the wave packets is treated +as a separate particle in LAMMPS, wave packets belonging to the same +electron must have identical *etag* values. + +The *sphere* and *bpm/sphere* styles allow particles to be either point +particles or finite-size particles. If the *radius* attribute is > +0.0, the particle is a finite-size sphere. If the diameter = 0.0, it +is a point particle. Note that by using the *disc* keyword with the +:doc:`fix nve/sphere `, :doc:`fix nvt/sphere +`, :doc:`fix nph/sphere `, :doc:`fix +npt/sphere ` commands for the *sphere* style, spheres +can be effectively treated as 2d discs for a 2d simulation if desired. +See also the :doc:`set density/disc ` command. These styles also +take an optional 0 or 1 argument. A value of 0 means the radius of +each sphere is constant for the duration of the simulation (this is +the default). A value of 1 means the radii may vary dynamically +during the simulation, e.g. due to use of the :doc:`fix adapt +` command. + +The *template* style allows molecular topology (bonds,angles,etc) to be +defined via a molecule template using the :doc:`molecule ` +command. The template stores one or more molecules with a single copy +of the topology info (bonds,angles,etc) of each. Individual atoms only +store a template index and template atom to identify which molecule and +which atom-within-the-molecule they represent. Using the *template* +style instead of the *bond*, *angle*, *molecular* styles can save memory +for systems comprised of a large number of small molecules, all of a +single type (or small number of types). See the paper by Grime and +Voth, in :ref:`(Grime) `, for examples of how this can be +advantageous for large-scale coarse-grained systems. The +``examples/template`` directory has a few demo inputs and examples +showing the use of the *template* atom style versus *molecular*. + +.. note:: + + When using the *template* style with a :doc:`molecule template + ` that contains multiple molecules, you should ensure the + atom types, bond types, angle_types, etc in all the molecules are + consistent. E.g. if one molecule represents H2O and another CO2, + then you probably do not want each molecule file to define 2 atom + types and a single bond type, because they will conflict with each + other when a mixture system of H2O and CO2 molecules is defined, + e.g. by the :doc:`read_data ` command. Rather the H2O + molecule should define atom types 1 and 2, and bond type 1. And + the CO2 molecule should define atom types 3 and 4 (or atom types 3 + and 2 if a single oxygen type is desired), and bond type 2. + +For the *tri* style, particles can be planar triangles which each +stores a per-particle mass and size and orientation (i.e. the corner +points of the triangle). Each particle stores a flag in the tri +vector which indicates whether it is a triangle (1) or a point +particle (0). + ---------- Typically, simulations require only a single (non-hybrid) atom style. @@ -326,11 +441,12 @@ dipole". When a hybrid style is used, atoms store and communicate the union of all quantities implied by the individual styles. When using the *hybrid* style, you cannot combine the *template* style -with another molecular style that stores bond,angle,etc info on a +with another molecular style that stores bond, angle, etc info on a per-atom basis. -LAMMPS can be extended with new atom styles as well as new body -styles; see the :doc:`Modify ` doc page. +LAMMPS can be extended with new atom styles as well as new body styles; +see the corresponding manual page on :doc:`modifying & extending LAMMPS +`. ---------- @@ -346,54 +462,20 @@ This command cannot be used after the simulation box is defined by a Many of the styles listed above are only enabled if LAMMPS was built with a specific package, as listed below. See the :doc:`Build package -` page for more info. - -The *amoeba* style is part of the AMOEBA package. - -The *angle*, *bond*, *full*, *molecular*, and *template* styles are -part of the MOLECULE package. - -The *line* and *tri* styles are part of the ASPHERE package. - -The *body* style is part of the BODY package. - -The *dipole* style is part of the DIPOLE package. - -The *peri* style is part of the PERI package for Peridynamics. - -The *oxdna* style is part of the CG-DNA package for coarse-grained -simulation of DNA and RNA. - -The *electron* style is part of the EFF package for :doc:`electronic -force fields `. - -The *dpd* style is part of the DPD-REACT package for dissipative -particle dynamics (DPD). - -The *edpd*, *mdpd*, and *tdpd* styles are part of the DPD-MESO package -for energy-conserving dissipative particle dynamics (eDPD), many-body -dissipative particle dynamics (mDPD), and transport dissipative particle -dynamics (tDPD), respectively. - -The *sph* style is part of the SPH package for smoothed particle -hydrodynamics (SPH). See `this PDF guide -`_ to using SPH in LAMMPS. - -The *spin* style is part of the SPIN package. - -The *wavepacket* style is part of the AWPMD package for the -:doc:`antisymmetrized wave packet MD method `. +` page for more info. The table above lists which package +is required for individual atom styles. Related commands """""""""""""""" -:doc:`read_data `, :doc:`pair_style ` +:doc:`read_data `, :doc:`pair_style `, +:doc:`fix property/atom `, :doc:`set ` Default """"""" -The default atom style is atomic. If atom_style sphere is used its -default argument is 0. +The default atom style is *atomic*. If atom_style *sphere* or +*bpm/sphere* is used, its default argument is 0. ---------- diff --git a/doc/src/bond_lepton.rst b/doc/src/bond_lepton.rst index adfd30627d..5425b8695c 100644 --- a/doc/src/bond_lepton.rst +++ b/doc/src/bond_lepton.rst @@ -11,7 +11,16 @@ Syntax .. code-block:: LAMMPS - bond_style lepton + bond_style style args + +* style = *lepton* +* args = optional arguments + +.. parsed-literal:: + + args = *auto_offset* or *no_offset* + *auto_offset* = offset the potential energy so that the value at r0 is 0.0 (default) + *no_offset* = do not offset the potential energy Examples """""""" @@ -19,6 +28,7 @@ Examples .. code-block:: LAMMPS bond_style lepton + bond_style lepton no_offset bond_coeff 1 1.5 "k*r^2; k=250.0" bond_coeff 2 1.1 "k2*r^2 + k3*r^3 + k4*r^4; k2=300.0; k3=-100.0; k4=50.0" @@ -40,6 +50,13 @@ constant *K* of 200.0 energy units: U_{bond,i} = K (r_i - r_0)^2 = K r^2 \qquad r = r_i - r_0 +.. versionchanged:: 7Feb2024 + +By default the potential energy U is shifted so that he value U is 0.0 +for $r = r_0$. This is equivalent to using the optional keyword +*auto_offset*. When using the keyword *no_offset* instead, the +potential energy is not shifted. + The `Lepton library `_, that the *lepton* bond style interfaces with, evaluates this expression string at run time to compute the pairwise energy. It also creates an analytical diff --git a/doc/src/compute_adf.rst b/doc/src/compute_adf.rst index fc1ad1ae0a..a43a10207c 100644 --- a/doc/src/compute_adf.rst +++ b/doc/src/compute_adf.rst @@ -204,8 +204,23 @@ angles per atom satisfying the ADF criteria. Restrictions """""""""""" -This compute is part of the EXTRA-COMPUTE package. It is only enabled if -LAMMPS was built with that package. See the :doc:`Build package ` page for more info. +This compute is part of the EXTRA-COMPUTE package. It is only enabled +if LAMMPS was built with that package. See the :doc:`Build package +` page for more info. + +By default, the ADF is not computed for distances longer than the +largest force cutoff, since the neighbor list creation will only contain +pairs up to that distance (plus neighbor list skin). If you use outer +cutoffs larger than that, you must use :doc:`neighbor style 'bin' or +'nsq' `. + +If you want an ADF for a larger outer cutoff, you can also use the +:doc:`rerun ` command to post-process a dump file, use :doc:`pair +style zero ` and set the force cutoff to be larger in the +rerun script. Note that in the rerun context, the force cutoff is +arbitrary and with pair style zero you are not computing any forces, and +since you are not running dynamics you are not changing the model that +generated the trajectory. The ADF is not computed for neighbors outside the force cutoff, since processors (in parallel) don't know about atom coordinates for diff --git a/doc/src/compute_ave_sphere_atom.rst b/doc/src/compute_ave_sphere_atom.rst index ecb67ae7b5..4640b8534a 100644 --- a/doc/src/compute_ave_sphere_atom.rst +++ b/doc/src/compute_ave_sphere_atom.rst @@ -102,6 +102,8 @@ This compute is part of the EXTRA-COMPUTE package. It is only enabled if LAMMPS was built with that package. See the :doc:`Build package ` page for more info. +This compute requires :doc:`neighbor styles 'bin' or 'nsq' `. + Related commands """""""""""""""" diff --git a/doc/src/compute_composition_atom.rst b/doc/src/compute_composition_atom.rst index e973eaa234..c3e6fb7c60 100644 --- a/doc/src/compute_composition_atom.rst +++ b/doc/src/compute_composition_atom.rst @@ -107,6 +107,8 @@ This compute is part of the EXTRA-COMPUTE package. It is only enabled if LAMMPS was built with that package. See the :doc:`Build package ` page for more info. +This compute requires :doc:`neighbor styles 'bin' or 'nsq' `. + Related commands """""""""""""""" diff --git a/doc/src/compute_efield_wolf_atom.rst b/doc/src/compute_efield_wolf_atom.rst index 1a709dc9f2..93bfa55151 100644 --- a/doc/src/compute_efield_wolf_atom.rst +++ b/doc/src/compute_efield_wolf_atom.rst @@ -106,6 +106,8 @@ Restrictions This compute is part of the EXTRA-COMPUTE package. It is only enabled if LAMMPS was built with that package. +This compute requires :doc:`neighbor styles 'bin' or 'nsq' `. + Related commands """""""""""""""" diff --git a/doc/src/compute_fabric.rst b/doc/src/compute_fabric.rst index b38ffafa48..77586e617a 100644 --- a/doc/src/compute_fabric.rst +++ b/doc/src/compute_fabric.rst @@ -64,7 +64,7 @@ tangential force tensor. The contact tensor is calculated as .. math:: - C_{ab} = \frac{15}{2} (\phi_{ab} - \mathrm{Tr}(\phi) \delta_{ab}) + C_{ab} = \frac{15}{2} (\phi_{ab} - \frac{1}{3} \mathrm{Tr}(\phi) \delta_{ab}) where :math:`a` and :math:`b` are the :math:`x`, :math:`y`, :math:`z` directions, :math:`\delta_{ab}` is the Kronecker delta function, and @@ -83,7 +83,7 @@ The branch tensor is calculated as .. math:: - B_{ab} = \frac{15}{6 \mathrm{Tr}(D)} (D_{ab} - \mathrm{Tr}(D) \delta_{ab}) + B_{ab} = \frac{15}{2\, \mathrm{Tr}(D)} (D_{ab} - \frac{1}{3} \mathrm{Tr}(D) \delta_{ab}) where the tensor :math:`D` is defined as @@ -101,7 +101,7 @@ The normal force fabric tensor is calculated as .. math:: - F^n_{ab} = \frac{15}{6\, \mathrm{Tr}(N)} (N_{ab} - \mathrm{Tr}(N) \delta_{ab}) + F^n_{ab} = \frac{15}{2\, \mathrm{Tr}(N)} (N_{ab} - \frac{1}{3} \mathrm{Tr}(N) \delta_{ab}) where the tensor :math:`N` is defined as @@ -119,7 +119,7 @@ as .. math:: - F^t_{ab} = \frac{15}{9\, \mathrm{Tr}(N)} (T_{ab} - \mathrm{Tr}(T) \delta_{ab}) + F^t_{ab} = \frac{5}{\mathrm{Tr}(N)} (T_{ab} - \frac{1}{3} \mathrm{Tr}(T) \delta_{ab}) where the tensor :math:`T` is defined as diff --git a/doc/src/compute_pace.rst b/doc/src/compute_pace.rst index c510319dfc..b18903f554 100644 --- a/doc/src/compute_pace.rst +++ b/doc/src/compute_pace.rst @@ -36,7 +36,7 @@ Examples Description """"""""""" -.. versionadded:: TBD +.. versionadded:: 7Feb2024 This compute calculates a set of quantities related to the atomic cluster expansion (ACE) descriptors of the atoms in a group. ACE diff --git a/doc/src/compute_pressure.rst b/doc/src/compute_pressure.rst index 52195ec5f8..03dfbb841b 100644 --- a/doc/src/compute_pressure.rst +++ b/doc/src/compute_pressure.rst @@ -153,7 +153,8 @@ Related commands Default """"""" -none +By default the compute includes contributions from the keywords: +``ke pair bond angle dihedral improper kspace fix`` ---------- diff --git a/doc/src/compute_property_atom.rst b/doc/src/compute_property_atom.rst index b03d6eb74e..4484c3b697 100644 --- a/doc/src/compute_property_atom.rst +++ b/doc/src/compute_property_atom.rst @@ -23,8 +23,9 @@ Syntax spx, spy, spz, sp, fmx, fmy, fmz, nbonds, radius, diameter, omegax, omegay, omegaz, + temperature, heatflow, angmomx, angmomy, angmomz, - shapex,shapey, shapez, + shapex, shapey, shapez, quatw, quati, quatj, quatk, tqx, tqy, tqz, end1x, end1y, end1z, end2x, end2y, end2z, corner1x, corner1y, corner1z, @@ -56,6 +57,8 @@ Syntax *nbonds* = number of bonds assigned to an atom *radius,diameter* = radius,diameter of spherical particle *omegax,omegay,omegaz* = angular velocity of spherical particle + *temperature* = internal temperature of spherical particle + *heatflow* = internal heat flow of spherical particle *angmomx,angmomy,angmomz* = angular momentum of aspherical particle *shapex,shapey,shapez* = 3 diameters of aspherical particle *quatw,quati,quatj,quatk* = quaternion components for aspherical or body particles diff --git a/doc/src/compute_rattlers_atom.rst b/doc/src/compute_rattlers_atom.rst index cf4e888657..ba14a1fd44 100644 --- a/doc/src/compute_rattlers_atom.rst +++ b/doc/src/compute_rattlers_atom.rst @@ -32,7 +32,7 @@ Examples Description """"""""""" -.. versionadded:: TBD +.. versionadded:: 7Feb2024 Define a compute that identifies rattlers in a system. Rattlers are often identified in granular or glassy packings as under-coordinated atoms that diff --git a/doc/src/compute_rdf.rst b/doc/src/compute_rdf.rst index ed73800f82..85e758016e 100644 --- a/doc/src/compute_rdf.rst +++ b/doc/src/compute_rdf.rst @@ -176,22 +176,29 @@ also numbers :math:`\ge 0.0`. Restrictions """""""""""" -The RDF is not computed for distances longer than the force cutoff, -since processors (in parallel) do not know about atom coordinates for -atoms further away than that distance. If you want an RDF for larger -distances, you can use the :doc:`rerun ` command to post-process -a dump file and set the cutoff for the potential to be longer in the +By default, the RDF is not computed for distances longer than the +largest force cutoff, since the neighbor list creation will only contain +pairs up to that distance (plus neighbor list skin). This distance can +be increased using the *cutoff* keyword but this keyword is only valid +with :doc:`neighbor styles 'bin' and 'nsq' `. + +If you want an RDF for larger distances, you can also use the +:doc:`rerun ` command to post-process a dump file, use :doc:`pair +style zero ` and set the force cutoff to be longer in the rerun script. Note that in the rerun context, the force cutoff is -arbitrary, since you are not running dynamics and thus are not changing -your model. The definition of :math:`g(r)` used by LAMMPS is only appropriate -for characterizing atoms that are uniformly distributed throughout the -simulation cell. In such cases, the coordination number is still -correct and meaningful. As an example, if a large simulation cell -contains only one atom of type *itypeN* and one of *jtypeN*, then :math:`g(r)` -will register an arbitrarily large spike at whatever distance they -happen to be at, and zero everywhere else. -The function :math:`\text{coord}(r)` will show a step -change from zero to one at the location of the spike in :math:`g(r)`. +arbitrary and with pair style zero you are not computing any forces, and +you are not running dynamics you are not changing the model that +generated the trajectory. + +The definition of :math:`g(r)` used by LAMMPS is only appropriate for +characterizing atoms that are uniformly distributed throughout the +simulation cell. In such cases, the coordination number is still correct +and meaningful. As an example, if a large simulation cell contains only +one atom of type *itypeN* and one of *jtypeN*, then :math:`g(r)` will +register an arbitrarily large spike at whatever distance they happen to +be at, and zero everywhere else. The function :math:`\text{coord}(r)` +will show a step change from zero to one at the location of the spike in +:math:`g(r)`. .. note:: diff --git a/doc/src/compute_reaxff_atom.rst b/doc/src/compute_reaxff_atom.rst index 997ad02e9f..deab29feea 100644 --- a/doc/src/compute_reaxff_atom.rst +++ b/doc/src/compute_reaxff_atom.rst @@ -40,7 +40,7 @@ Examples Description """"""""""" -.. versionadded:: TBD +.. versionadded:: 7Feb2024 Define a computation that extracts bond information computed by the ReaxFF potential specified by :doc:`pair_style reaxff `. diff --git a/doc/src/compute_reduce.rst b/doc/src/compute_reduce.rst index 604b1c1571..c599761c39 100644 --- a/doc/src/compute_reduce.rst +++ b/doc/src/compute_reduce.rst @@ -56,8 +56,9 @@ Examples compute 1 all reduce sum c_force compute 1 all reduce/region subbox sum c_force compute 2 all reduce min c_press[2] f_ave v_myKE - compute 2 all reduce min c_press[*] f_ave v_myKE + compute 2 all reduce min c_press[*] f_ave v_myKE inputs peratom compute 3 fluid reduce max c_index[1] c_index[2] c_dist replace 1 3 replace 2 3 + compute 4 all reduce max c_bond inputs local Description """"""""""" diff --git a/doc/src/compute_slcsa_atom.rst b/doc/src/compute_slcsa_atom.rst index 6b2708c4d9..7338b92d59 100644 --- a/doc/src/compute_slcsa_atom.rst +++ b/doc/src/compute_slcsa_atom.rst @@ -32,7 +32,7 @@ Examples Description """"""""""" -.. versionadded:: TBD +.. versionadded:: 7Feb2024 Define a computation that performs the Supervised Learning Crystal Structure Analysis (SL-CSA) from :ref:`(Lafourcade) ` diff --git a/doc/src/compute_stress_atom.rst b/doc/src/compute_stress_atom.rst index ffd0d2ffb4..0fac47a6c0 100644 --- a/doc/src/compute_stress_atom.rst +++ b/doc/src/compute_stress_atom.rst @@ -289,7 +289,8 @@ Related commands Default """"""" -none +By default the compute includes contributions from the keywords: +``ke pair bond angle dihedral improper kspace fix`` ---------- diff --git a/doc/src/compute_stress_mop.rst b/doc/src/compute_stress_mop.rst index 74d4c618e7..6630c7171f 100644 --- a/doc/src/compute_stress_mop.rst +++ b/doc/src/compute_stress_mop.rst @@ -132,10 +132,13 @@ size does not change in time, and axis-aligned planes. The method only works with two-body pair interactions, because it requires the class method ``Pair::single()`` to be implemented, which is not possible for manybody potentials. In particular, compute -*stress/mop/profile* and *stress/mop* do not work with more than two-body pair -interactions, long range (kspace) interactions and +*stress/mop/profile* and *stress/mop* do not work with more than two-body +pair interactions, long range (kspace) interactions and improper intramolecular interactions. +The impact of fixes that affect the stress (e.g. fix langevin) is +also not included in the stress computed here. + Related commands """""""""""""""" diff --git a/doc/src/create_atoms.rst b/doc/src/create_atoms.rst index 5d1e7c872c..7f67670506 100644 --- a/doc/src/create_atoms.rst +++ b/doc/src/create_atoms.rst @@ -268,6 +268,12 @@ molecule can be specified in the molecule file. See the required to be in this file are the coordinates and types of atoms in the molecule. +.. note:: + + If you are using the *mol* keyword in combination with the + :doc:`atom style template ` command, they must use + the same molecule template-ID. + Using a lattice to add molecules, e.g. via the *box* or *region* or *single* styles, is exactly the same as adding atoms on lattice points, except that entire molecules are added at each point, i.e. on @@ -536,6 +542,11 @@ command. A rotation vector specified for a single molecule must be in the z-direction for a 2d model. +For :doc:`molecule templates ` that are created from multiple +files, i.e. contain multiple molecule *sets*, only the first set is +used. To create multiple molecules the files currently need to be +merged and different molecule IDs assigned with a Molecules section. + Related commands """""""""""""""" diff --git a/doc/src/dihedral_charmm.rst b/doc/src/dihedral_charmm.rst index cc792693a2..a5652bc74e 100644 --- a/doc/src/dihedral_charmm.rst +++ b/doc/src/dihedral_charmm.rst @@ -3,6 +3,7 @@ .. index:: dihedral_style charmm/kk .. index:: dihedral_style charmm/omp .. index:: dihedral_style charmmfsw +.. index:: dihedral_style charmmfsw/kk dihedral_style charmm command ============================= @@ -12,6 +13,8 @@ Accelerator Variants: *charmm/intel*, *charmm/kk*, *charmm/omp* dihedral_style charmmfsw command ================================ +Accelerator Variants: *charmmfsw/kk* + Syntax """""" @@ -144,7 +147,9 @@ for more info. Related commands """""""""""""""" -:doc:`dihedral_coeff ` +:doc:`dihedral_coeff `, +:doc:`pair_style lj/charmm variants `, +:doc:`angle_style charmm `, :doc:`fix cmap ` Default """"""" diff --git a/doc/src/dump.rst b/doc/src/dump.rst index 2d1598e493..82faba6c81 100644 --- a/doc/src/dump.rst +++ b/doc/src/dump.rst @@ -104,7 +104,6 @@ Syntax q, mux, muy, muz, mu, radius, diameter, omegax, omegay, omegaz, angmomx, angmomy, angmomz, tqx, tqy, tqz, - heatflow, temperature, c_ID, c_ID[I], f_ID, f_ID[I], v_name, i_name, d_name, i2_name[I], d2_name[I] @@ -131,8 +130,6 @@ Syntax omegax,omegay,omegaz = angular velocity of spherical particle angmomx,angmomy,angmomz = angular momentum of aspherical particle tqx,tqy,tqz = torque on finite-size particles - heatflow = rate of heat flow into particle - temperature = temperature of particle c_ID = per-atom vector calculated by a compute with ID c_ID[I] = Ith column of per-atom array calculated by a compute with ID, I can include wildcard (see below) f_ID = per-atom vector calculated by a fix with ID diff --git a/doc/src/fix.rst b/doc/src/fix.rst index 69a7212487..4cd21353c7 100644 --- a/doc/src/fix.rst +++ b/doc/src/fix.rst @@ -226,6 +226,7 @@ accelerated styles exist. * :doc:`controller ` - apply control loop feedback mechanism * :doc:`damping/cundall ` - Cundall non-viscous damping for granular simulations * :doc:`deform ` - change the simulation box size/shape +* :doc:`deform/pressure ` - change the simulation box size/shape with additional loading conditions * :doc:`deposit ` - add new atoms above a surface * :doc:`dpd/energy ` - constant energy dissipative particle dynamics * :doc:`drag ` - drag atoms towards a defined coordinate @@ -427,6 +428,7 @@ accelerated styles exist. * :doc:`wall/body/polyhedron ` - time integration for body particles of style :doc:`rounded/polyhedron ` * :doc:`wall/colloid ` - Lennard-Jones wall interacting with finite-size particles * :doc:`wall/ees ` - wall for ellipsoidal particles +* :doc:`wall/flow ` - flow boundary conditions * :doc:`wall/gran ` - frictional wall(s) for granular simulations * :doc:`wall/gran/region ` - :doc:`fix wall/region ` equivalent for use with granular particles * :doc:`wall/harmonic ` - harmonic spring wall diff --git a/doc/src/fix_balance.rst b/doc/src/fix_balance.rst index 0672a05470..0a0ea64c6a 100644 --- a/doc/src/fix_balance.rst +++ b/doc/src/fix_balance.rst @@ -14,15 +14,15 @@ Syntax * balance = style name of this fix command * Nfreq = perform dynamic load balancing every this many steps * thresh = imbalance threshold that must be exceeded to perform a re-balance -* style = *shift* or *rcb* - +* style = *shift* or *rcb* or *report* .. parsed-literal:: - shift args = dimstr Niter stopthresh + *shift* args = dimstr Niter stopthresh dimstr = sequence of letters containing *x* or *y* or *z*, each not more than once Niter = # of times to iterate within each dimension of dimstr sequence stopthresh = stop balancing when this imbalance threshold is reached *rcb* args = none + *report* args = none * zero or more keyword/arg pairs may be appended * keyword = *weight* or *out* @@ -70,6 +70,13 @@ re-balancing is performed periodically during the simulation. To perform "static" balancing, before or between runs, see the :doc:`balance ` command. +.. versionadded:: TBD + +The *report* balance style only computes the load imbalance but +does not attempt any re-balancing. This way the load imbalance +information can be used otherwise, for instance for stopping a +run with :doc:`fix halt `. + Load-balancing is typically most useful if the particles in the simulation box have a spatially-varying density distribution or where the computational cost varies significantly between different diff --git a/doc/src/fix_charge_regulation.rst b/doc/src/fix_charge_regulation.rst index bc2651a55b..091eeae417 100644 --- a/doc/src/fix_charge_regulation.rst +++ b/doc/src/fix_charge_regulation.rst @@ -253,11 +253,11 @@ built with that package. See the :doc:`Build package ` page for more info. The :doc:`atom_style `, used must contain the charge -property, for example, the style could be *charge* or *full*. Only -usable for 3D simulations. Atoms specified as free ions cannot be part -of rigid bodies or molecules and cannot have bonding interactions. The -scheme is limited to integer charges, any atoms with non-integer charges -will not be considered by the fix. +property and have per atom type masses, for example, the style could be +*charge* or *full*. Only usable for 3D simulations. Atoms specified as +free ions cannot be part of rigid bodies or molecules and cannot have +bonding interactions. The scheme is limited to integer charges, any +atoms with non-integer charges will not be considered by the fix. All interaction potentials used must be continuous, otherwise the MD integration and the particle exchange MC moves do not correspond to the diff --git a/doc/src/fix_deform.rst b/doc/src/fix_deform.rst index ee010f5645..9146b987c8 100644 --- a/doc/src/fix_deform.rst +++ b/doc/src/fix_deform.rst @@ -4,6 +4,9 @@ fix deform command ================== +:doc:`fix deform/pressure ` command +======================================================== + Accelerator Variants: *deform/kk* Syntax @@ -11,18 +14,18 @@ Syntax .. code-block:: LAMMPS - fix ID group-ID deform N parameter args ... keyword value ... + fix ID group-ID fix_style N parameter style args ... keyword value ... * ID, group-ID are documented in :doc:`fix ` command -* deform = style name of this fix command +* fix_style = *deform* or *deform/pressure* * N = perform box deformation every this many timesteps -* one or more parameter/arg pairs may be appended +* one or more parameter/style/args sequences of arguments may be appended .. parsed-literal:: parameter = *x* or *y* or *z* or *xy* or *xz* or *yz* *x*, *y*, *z* args = style value(s) - style = *final* or *delta* or *scale* or *vel* or *erate* or *trate* or *volume* or *wiggle* or *variable* + style = *final* or *delta* or *scale* or *vel* or *erate* or *trate* or *volume* or *wiggle* or *variable* or *pressure* or *pressure/mean* *final* values = lo hi lo hi = box boundaries at end of run (distance units) *delta* values = dlo dhi @@ -43,8 +46,15 @@ Syntax *variable* values = v_name1 v_name2 v_name1 = variable with name1 for box length change as function of time v_name2 = variable with name2 for change rate as function of time + *pressure* values = target gain (ONLY available in :doc:`fix deform/pressure ` command) + target = target pressure (pressure units) + gain = proportional gain constant (1/(time * pressure) or 1/time units) + *pressure/mean* values = target gain (ONLY available in :doc:`fix deform/pressure ` command) + target = target pressure (pressure units) + gain = proportional gain constant (1/(time * pressure) or 1/time units) + *xy*, *xz*, *yz* args = style value - style = *final* or *delta* or *vel* or *erate* or *trate* or *wiggle* + style = *final* or *delta* or *vel* or *erate* or *trate* or *wiggle* or *variable* *final* value = tilt tilt = tilt factor at end of run (distance units) *delta* value = dtilt @@ -62,9 +72,12 @@ Syntax *variable* values = v_name1 v_name2 v_name1 = variable with name1 for tilt change as function of time v_name2 = variable with name2 for change rate as function of time + *pressure* values = target gain (ONLY available in :doc:`fix deform/pressure ` command) + target = target pressure (pressure units) + gain = proportional gain constant (1/(time * pressure) or 1/time units) * zero or more keyword/value pairs may be appended -* keyword = *remap* or *flip* or *units* +* keyword = *remap* or *flip* or *units* or *couple* or *vol/balance/p* or *max/rate* or *normalize/pressure* .. parsed-literal:: @@ -77,6 +90,15 @@ Syntax *units* value = *lattice* or *box* lattice = distances are defined in lattice units box = distances are defined in simulation box units + *couple* value = *none* or *xyz* or *xy* or *yz* or *xz* (ONLY available in :doc:`fix deform/pressure ` command) + couple pressure values of various dimensions + *vol/balance/p* value = *yes* or *no* (ONLY available in :doc:`fix deform/pressure ` command) + Modifies the behavior of the *volume* option to try and balance pressures + *max/rate* value = *rate* (ONLY available in :doc:`fix deform/pressure ` command) + rate = maximum strain rate for pressure control + *normalize/pressure* value = *yes* or *no* (ONLY available in :doc:`fix deform/pressure ` command) + Modifies pressure controls such that the deviation in pressure is normalized by the target pressure + Examples """""""" @@ -88,6 +110,8 @@ Examples fix 1 all deform 1 xy erate 0.001 remap v fix 1 all deform 10 y delta -0.5 0.5 xz vel 1.0 +See examples for :doc:`fix deform/pressure ` on its doc page + Description """"""""""" @@ -95,29 +119,46 @@ Change the volume and/or shape of the simulation box during a dynamics run. Orthogonal simulation boxes have 3 adjustable parameters (x,y,z). Triclinic (non-orthogonal) simulation boxes have 6 adjustable parameters (x,y,z,xy,xz,yz). Any or all of them can be -adjusted independently and simultaneously by this command. +adjusted independently and simultaneously. -This fix can be used to perform non-equilibrium MD (NEMD) simulations -of a continuously strained system. See the :doc:`fix nvt/sllod ` and :doc:`compute temp/deform ` commands for more details. Note -that simulation of a continuously extended system (extensional flow) -can be modeled using the :ref:`UEF package ` and its :doc:`fix commands `. +The fix deform command allows use of all the arguments listed above, +except those flagged as available ONLY for the :doc:`fix +deform/pressure ` command, which are +pressure-based controls. The fix deform/pressure command allows use +of all the arguments listed above. + +The rest of this doc page explains the options common to both +commands. The :doc:`fix deform/pressure ` doc +page explains the options available ONLY with the fix deform/pressure +command. Note that a simulation can define only a single deformation +command: fix deform or fix deform/pressure. + +Both these fixes can be used to perform non-equilibrium MD (NEMD) +simulations of a continuously strained system. See the :doc:`fix +nvt/sllod ` and :doc:`compute temp/deform +` commands for more details. Note that +simulation of a continuously extended system (extensional flow) can be +modeled using the :ref:`UEF package ` and its :doc:`fix +commands `. For the *x*, *y*, *z* parameters, the associated dimension cannot be shrink-wrapped. For the *xy*, *yz*, *xz* parameters, the associated -second dimension cannot be shrink-wrapped. Dimensions not varied by this -command can be periodic or non-periodic. Dimensions corresponding to -unspecified parameters can also be controlled by a :doc:`fix npt ` or :doc:`fix nph ` command. +second dimension cannot be shrink-wrapped. Dimensions not varied by +this command can be periodic or non-periodic. Dimensions +corresponding to unspecified parameters can also be controlled by a +:doc:`fix npt ` or :doc:`fix nph ` command. The size and shape of the simulation box at the beginning of the -simulation run were either specified by the -:doc:`create_box ` or :doc:`read_data ` or -:doc:`read_restart ` command used to setup the simulation -initially if it is the first run, or they are the values from the end -of the previous run. The :doc:`create_box `, :doc:`read data `, and :doc:`read_restart ` commands -specify whether the simulation box is orthogonal or non-orthogonal -(triclinic) and explain the meaning of the xy,xz,yz tilt factors. If -fix deform changes the xy,xz,yz tilt factors, then the simulation box -must be triclinic, even if its initial tilt factors are 0.0. +simulation run were either specified by the :doc:`create_box +` or :doc:`read_data ` or :doc:`read_restart +` command used to setup the simulation initially if it +is the first run, or they are the values from the end of the previous +run. The :doc:`create_box `, :doc:`read data +`, and :doc:`read_restart ` commands specify +whether the simulation box is orthogonal or non-orthogonal (triclinic) +and explain the meaning of the xy,xz,yz tilt factors. If fix deform +changes the xy,xz,yz tilt factors, then the simulation box must be +triclinic, even if its initial tilt factors are 0.0. As described below, the desired simulation box size and shape at the end of the run are determined by the parameters of the fix deform @@ -258,21 +299,22 @@ of the units keyword below. The *variable* style changes the specified box length dimension by evaluating a variable, which presumably is a function of time. The -variable with *name1* must be an :doc:`equal-style variable ` -and should calculate a change in box length in units of distance. -Note that this distance is in box units, not lattice units; see the -discussion of the *units* keyword below. The formula associated with -variable *name1* can reference the current timestep. Note that it -should return the "change" in box length, not the absolute box length. -This means it should evaluate to 0.0 when invoked on the initial -timestep of the run following the definition of fix deform. It should -evaluate to a value > 0.0 to dilate the box at future times, or a -value < 0.0 to compress the box. +variable with *name1* must be an :doc:`equal-style variable +` and should calculate a change in box length in units of +distance. Note that this distance is in box units, not lattice units; +see the discussion of the *units* keyword below. The formula +associated with variable *name1* can reference the current timestep. +Note that it should return the "change" in box length, not the +absolute box length. This means it should evaluate to 0.0 when +invoked on the initial timestep of the run following the definition of +fix deform. It should evaluate to a value > 0.0 to dilate the box at +future times, or a value < 0.0 to compress the box. -The variable *name2* must also be an :doc:`equal-style variable ` and should calculate the rate of box length -change, in units of distance/time, i.e. the time-derivative of the -*name1* variable. This quantity is used internally by LAMMPS to reset -atom velocities when they cross periodic boundaries. It is computed +The variable *name2* must also be an :doc:`equal-style variable +` and should calculate the rate of box length change, in +units of distance/time, i.e. the time-derivative of the *name1* +variable. This quantity is used internally by LAMMPS to reset atom +velocities when they cross periodic boundaries. It is computed internally for the other styles, but you must provide it when using an arbitrary variable. @@ -414,12 +456,13 @@ can reference the current timestep. Note that it should return the should evaluate to 0.0 when invoked on the initial timestep of the run following the definition of fix deform. -The variable *name2* must also be an :doc:`equal-style variable ` and should calculate the rate of tilt change, -in units of distance/time, i.e. the time-derivative of the *name1* -variable. This quantity is used internally by LAMMPS to reset atom -velocities when they cross periodic boundaries. It is computed -internally for the other styles, but you must provide it when using an -arbitrary variable. +The variable *name2* must also be an :doc:`equal-style variable +` and should calculate the rate of tilt change, in units of +distance/time, i.e. the time-derivative of the *name1* variable. This +quantity is used internally by LAMMPS to reset atom velocities when +they cross periodic boundaries. It is computed internally for the +other styles, but you must provide it when using an arbitrary +variable. Here is an example of using the *variable* style to perform the same box deformation as the *wiggle* style formula listed above, where we @@ -510,33 +553,40 @@ box without explicit remapping of their coordinates. .. note:: For non-equilibrium MD (NEMD) simulations using "remap v" it is - usually desirable that the fluid (or flowing material, e.g. granular - particles) stream with a velocity profile consistent with the - deforming box. As mentioned above, using a thermostat such as :doc:`fix nvt/sllod ` or :doc:`fix lavgevin ` - (with a bias provided by :doc:`compute temp/deform `), will typically accomplish - that. If you do not use a thermostat, then there is no driving force - pushing the atoms to flow in a manner consistent with the deforming - box. E.g. for a shearing system the box deformation velocity may vary + usually desirable that the fluid (or flowing material, + e.g. granular particles) stream with a velocity profile consistent + with the deforming box. As mentioned above, using a thermostat + such as :doc:`fix nvt/sllod ` or :doc:`fix lavgevin + ` (with a bias provided by :doc:`compute temp/deform + `), will typically accomplish that. If you do + not use a thermostat, then there is no driving force pushing the + atoms to flow in a manner consistent with the deforming box. + E.g. for a shearing system the box deformation velocity may vary from 0 at the bottom to 10 at the top of the box. But the stream - velocity profile of the atoms may vary from -5 at the bottom to +5 at - the top. You can monitor these effects using the :doc:`fix ave/chunk `, :doc:`compute temp/deform `, and :doc:`compute temp/profile ` commands. One way to induce - atoms to stream consistent with the box deformation is to give them an + velocity profile of the atoms may vary from -5 at the bottom to +5 + at the top. You can monitor these effects using the :doc:`fix + ave/chunk `, :doc:`compute temp/deform + `, and :doc:`compute temp/profile + ` commands. One way to induce atoms to + stream consistent with the box deformation is to give them an initial velocity profile, via the :doc:`velocity ramp ` - command, that matches the box deformation rate. This also typically - helps the system come to equilibrium more quickly, even if a - thermostat is used. + command, that matches the box deformation rate. This also + typically helps the system come to equilibrium more quickly, even + if a thermostat is used. .. note:: If a :doc:`fix rigid ` is defined for rigid bodies, and *remap* is set to *x*, then the center-of-mass coordinates of rigid - bodies will be remapped to the changing simulation box. This will be - done regardless of whether atoms in the rigid bodies are in the fix - deform group or not. The velocity of the centers of mass are not - remapped even if *remap* is set to *v*, since :doc:`fix nvt/sllod ` does not currently do anything special + bodies will be remapped to the changing simulation box. This will + be done regardless of whether atoms in the rigid bodies are in the + fix deform group or not. The velocity of the centers of mass are + not remapped even if *remap* is set to *v*, since :doc:`fix + nvt/sllod ` does not currently do anything special for rigid particles. If you wish to perform a NEMD simulation of rigid particles, you can either thermostat them independently or - include a background fluid and thermostat the fluid via :doc:`fix nvt/sllod `. + include a background fluid and thermostat the fluid via :doc:`fix + nvt/sllod `. The *flip* keyword allows the tilt factors for a triclinic box to exceed half the distance of the parallel box length, as discussed @@ -568,7 +618,8 @@ command if you want to include lattice spacings in a variable formula. Restart, fix_modify, output, run start/stop, minimize info """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" -This fix will restore the initial box settings from :doc:`binary restart files `, which allows the fix to be properly continue +This fix will restore the initial box settings from :doc:`binary +restart files `, which allows the fix to be properly continue deformation, when using the start/stop options of the :doc:`run ` command. None of the :doc:`fix_modify ` options are relevant to this fix. No global or per-atom quantities are stored by @@ -586,12 +637,14 @@ Restrictions You cannot apply x, y, or z deformations to a dimension that is shrink-wrapped via the :doc:`boundary ` command. -You cannot apply xy, yz, or xz deformations to a second dimension (y in -xy) that is shrink-wrapped via the :doc:`boundary ` command. +You cannot apply xy, yz, or xz deformations to a second dimension (y +in xy) that is shrink-wrapped via the :doc:`boundary ` +command. Related commands """""""""""""""" +:doc:`fix deform/pressure `, :doc:`change_box ` Default diff --git a/doc/src/fix_deform_pressure.rst b/doc/src/fix_deform_pressure.rst new file mode 100644 index 0000000000..f85ad37238 --- /dev/null +++ b/doc/src/fix_deform_pressure.rst @@ -0,0 +1,319 @@ +.. index:: fix deform/pressure + +fix deform/pressure command +=========================== + +Syntax +"""""" + +.. parsed-literal:: + + fix ID group-ID deform/pressure N parameter style args ... keyword value ... + +* ID, group-ID are documented in :doc:`fix ` command +* deform/pressure = style name of this fix command +* N = perform box deformation every this many timesteps +* one or more parameter/arg sequences may be appended + + .. parsed-literal:: + + parameter = *x* or *y* or *z* or *xy* or *xz* or *yz* or *box* + *x*, *y*, *z* args = style value(s) + style = *final* or *delta* or *scale* or *vel* or *erate* or *trate* or *volume* or *wiggle* or *variable* or *pressure* or *pressure/mean* + *pressure* values = target gain + target = target pressure (pressure units) + gain = proportional gain constant (1/(time * pressure) or 1/time units) + *pressure/mean* values = target gain + target = target pressure (pressure units) + gain = proportional gain constant (1/(time * pressure) or 1/time units) + NOTE: All other styles are documented by the :doc:`fix deform ` command + + *xy*, *xz*, *yz* args = style value + style = *final* or *delta* or *vel* or *erate* or *trate* or *wiggle* or *variable* or *pressure* + *pressure* values = target gain + target = target pressure (pressure units) + gain = proportional gain constant (1/(time * pressure) or 1/time units) + NOTE: All other styles are documented by the :doc:`fix deform ` command + + *box* = style value + style = *volume* or *pressure* + *volume* value = none = isotropically adjust system to preserve volume of system + *pressure* values = target gain + target = target mean pressure (pressure units) + gain = proportional gain constant (1/(time * pressure) or 1/time units) + +* zero or more keyword/value pairs may be appended +* keyword = *remap* or *flip* or *units* or *couple* or *vol/balance/p* or *max/rate* or *normalize/pressure* + + .. parsed-literal:: + + *couple* value = *none* or *xyz* or *xy* or *yz* or *xz* + couple pressure values of various dimensions + *vol/balance/p* value = *yes* or *no* + Modifies the behavior of the *volume* option to try and balance pressures + *max/rate* value = *rate* + rate = maximum strain rate for pressure control + *normalize/pressure* value = *yes* or *no* + Modifies pressure controls such that the deviation in pressure is normalized by the target pressure + NOTE: All other keywords are documented by the :doc:`fix deform ` command + +Examples +"""""""" + +.. code-block:: LAMMPS + + fix 1 all deform/pressure 1 x pressure 2.0 0.1 normalize/pressure yes max/rate 0.001 + fix 1 all deform/pressure 1 x trate 0.1 y volume z volume vol/balance/p yes + fix 1 all deform/pressure 1 x trate 0.1 y pressure/mean 0.0 1.0 z pressure/mean 0.0 1.0 + +Description +""""""""""" + +.. versionadded:: TBD + +This fix is an extension of the :doc:`fix deform ` +command, which allows all of its options to be used as well as new +pressure-based controls implemented by this command. + +All arguments described on the :doc:`fix deform ` doc page +also apply to this fix unless otherwise noted below. The rest of this +doc page explains the arguments specific to this fix. Note that a +simulation can define only a single deformation command: fix deform or +fix deform/pressure. + +---------- + +For the *x*, *y*, and *z* parameters, this is the meaning of the +styles and values provided by this fix. + +The *pressure* style adjusts a dimension's box length to control the +corresponding component of the pressure tensor. This option attempts to +maintain a specified target pressure using a linear controller where the +box length :math:`L` evolves according to the equation + +.. parsed-literal:: + + \frac{d L(t)}{dt} = L(t) k (P_t - P) + +where :math:`k` is a proportional gain constant, :math:`P_t` is the target +pressure, and :math:`P` is the current pressure along that dimension. This +approach is similar to the method used to control the pressure by +:doc:`fix press/berendsen `. The target pressure +accepts either a constant numeric value or a LAMMPS :ref:`variable `. +Notably, this variable can be a function of time or other components of +the pressure tensor. By default, :math:`k` has units of 1/(time * pressure) +although this will change if the *normalize/pressure* option is set as +:ref:`discussed below `. There is no proven method +to choosing an appropriate value of :math:`k` as it will depend on the +specific details of a simulation. Testing different values is recommended. + +By default, there is no limit on the resulting strain rate in any dimension. +A maximum limit can be applied using the :ref:`max/rate ` +option. Akin to :doc:`fix nh `, pressures in different dimensions +can be coupled using the :ref:`couple ` option. This means +the instantaneous pressure along coupled dimensions are averaged and the box +strains identically along the coupled dimensions. + +The *pressure/mean* style changes a dimension's box length to maintain +a constant mean pressure defined as the trace of the pressure tensor. +This option has identical arguments to the *pressure* style and a similar +functional equation, except the current and target pressures refer to the +mean trace of the pressure tensor. All options for the *pressure* style +also apply to the *pressure/mean* style except for the +:ref:`couple ` option. + +Note that while this style can be identical to coupled *pressure* styles, +it is generally not the same. For instance in 2D, a coupled *pressure* +style in the *x* and *y* dimensions would be equivalent to using the +*pressure/mean* style with identical settings in each dimension. However, +it would not be the same if settings (e.g. gain constants) were used in +the *x* and *y* dimensions or if the *pressure/mean* command was only applied +along one dimension. + +---------- + +For the *xy*, *xz*, and *yz* parameters, this is the meaning of the +styles and values provided by this fix. Note that changing the +tilt factors of a triclinic box does not change its volume. + +The *pressure* style adjusts a tilt factor to control the corresponding +off-diagonal component of the pressure tensor. This option attempts to +maintain a specified target value using a linear controller where the +tilt factor T evolves according to the equation + +.. parsed-literal:: + + \frac{d T(t)}{dt} = L(t) k (P - P_t) + +where :math:`k` is a proportional gain constant, :math:`P_t` is the +target pressure, :math:`P` is the current pressure, and :math:`L` is +the perpendicular box length. The target pressure accepts either a +constant numeric value or a LAMMPS :ref:`variable +`. Notably, this variable can be a function of time or other +components of the pressure tensor. By default, :math:`k` has units of +1/(time * pressure) although this will change if the +*normalize/pessure* option is set as :ref:`discussed below +`. There is no proven method to choosing an +appropriate value of :math:`k` as it will depend on the specific +details of a simulation and testing different values is +recommended. One can also apply a maximum limit to the magnitude of +the applied strain using the :ref:`max/rate ` option. + +---------- + +The *box* parameter provides an additional control over the *x*, *y*, +and *z* box lengths by isotropically dilating or contracting the box +to either maintain a fixed mean pressure or volume. This isotropic +scaling is applied after the box is deformed by the above *x*, *y*, +*z*, *xy*, *xz*, and *yz* styles, acting as a second deformation +step. This parameter will change the overall strain rate in the *x*, +*y*, or *z* dimensions. This parameter can only be used in +combination with the *x*, *y*, or *z* commands: *vel*, *erate*, +*trate*, *pressure*, or *wiggle*. This is the meaning of its styles +and values. + +The *volume* style isotropically scales box lengths to maintain a constant +box volume in response to deformation from other parameters. This style +may be useful in scenarios where one wants to apply a constant deviatoric +pressure using *pressure* styles in the *x*, *y*, and *z* dimensions ( +deforming the shape of the box), while maintaining a constant volume. + +The *pressure* style isotropically scales box lengths in an attempt to +maintain a target mean pressure (the trace of the pressure tensor) of the +system. This is accomplished by isotropically scaling all box lengths +:math:`L` by an additional factor of :math:`k (P_t - P_m)` where :math:`k` +is the proportional gain constant, :math:`P_t` is the target pressure, and +:math:`P_m` is the current mean pressure. This style may be useful in +scenarios where one wants to apply a constant deviatoric strain rate +using various strain-based styles (e.g. *trate*) along the *x*, *y*, and *z* +dimensions (deforming the shape of the box), while maintaining a mean pressure. + +---------- + +The optional keywords provided by this fix are described below. + +.. _deform_normalize: + +The *normalize/pressure* keyword changes how box dimensions evolve when +using the *pressure* or *pressure/mean* deformation styles. If the +*deform/normalize* value is set to *yes*, then the deviation from the +target pressure is normalized by the absolute value of the target +pressure such that the proportional gain constant scales a percentage +error and has units of 1/time. If the target pressure is ever zero, this +will produce an error unless the *max/rate* keyword is defined, +described below, which will cap the divergence. + +.. _deform_max_rate: + +The *max/rate* keyword sets an upper threshold, *rate*, that limits the +maximum magnitude of the instantaneous strain rate applied in any dimension. +This keyword only applies to the *pressure* and *pressure/mean* options. If +a pressure-controlled rate is used for both *box* and either *x*, *y*, or +*z*, then this threshold will apply separately to each individual controller +such that the cumulative strain rate on a box dimension may be up to twice +the value of *rate*. + +.. _deform_couple: + +The *couple* keyword allows two or three of the diagonal components of +the pressure tensor to be "coupled" together for the *pressure* option. +The value specified with the keyword determines which are coupled. For +example, *xz* means the *Pxx* and *Pzz* components of the stress tensor +are coupled. *Xyz* means all 3 diagonal components are coupled. Coupling +means two things: the instantaneous stress will be computed as an average +of the corresponding diagonal components, and the coupled box dimensions +will be changed together in lockstep, meaning coupled dimensions will be +dilated or contracted by the same percentage every timestep. If a *pressure* +style is defined for more than one coupled dimension, the target pressures +and gain constants must be identical. Alternatively, if a *pressure* +style is only defined for one of the coupled dimensions, its settings are +copied to other dimensions with undefined styles. *Couple xyz* can be used +for a 2d simulation; the *z* dimension is simply ignored. + +.. _deform_balance: + +The *vol/balance/p* keyword modifies the behavior of the *volume* style when +applied to two of the *x*, *y*, and *z* dimensions. Instead of straining +the two dimensions in lockstep, the two dimensions are allowed to +separately dilate or contract in a manner to maintain a constant +volume while simultaneously trying to keep the pressure along each +dimension equal using a method described in :ref:`(Huang2014) `. + +---------- + +If any pressure controls are used, this fix computes a temperature and +pressure each timestep. To do this, the fix creates its own computes +of style "temp" and "pressure", as if these commands had been issued: + +.. code-block:: LAMMPS + + compute fix-ID_temp group-ID temp + compute fix-ID_press group-ID pressure fix-ID_temp + +See the :doc:`compute temp ` and :doc:`compute pressure +` commands for details. Note that the IDs of the +new computes are the fix-ID + underscore + "temp" or fix_ID ++ underscore + "press", and the group for the new computes is the same +as the fix group. + +Note that these are NOT the computes used by thermodynamic output (see +the :doc:`thermo_style ` command) with ID = +*thermo_temp* and *thermo_press*. This means you can change the +attributes of this fix's temperature or pressure via the +:doc:`compute_modify ` command or print this +temperature or pressure during thermodynamic output via the +:doc:`thermo_style custom ` command using the +appropriate compute-ID. It also means that changing attributes of +*thermo_temp* or *thermo_press* will have no effect on this fix. + +Restart, fix_modify, output, run start/stop, minimize info +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +This fix will restore the initial box settings from :doc:`binary +restart files `, which allows the fix to be properly continue +deformation, when using the start/stop options of the :doc:`run ` +command. No global or per-atom quantities are stored by this fix for +access by various :doc:`output commands `. + +If any pressure controls are used, the :doc:`fix_modify ` +*temp* and *press* options are supported by this fix, unlike in +:doc:`fix deform `. You can use them to assign a +:doc:`compute ` you have defined to this fix which will be +used in its temperature and pressure calculations. If you do this, +note that the kinetic energy derived from the compute temperature +should be consistent with the virial term computed using all atoms for +the pressure. LAMMPS will warn you if you choose to compute +temperature on a subset of atoms. + +This fix can perform deformation over multiple runs, using the *start* +and *stop* keywords of the :doc:`run ` command. See the +:doc:`run ` command for details of how to do this. + +This fix is not invoked during :doc:`energy minimization `. + +Restrictions +"""""""""""" + +You cannot apply x, y, or z deformations to a dimension that is +shrink-wrapped via the :doc:`boundary ` command. + +You cannot apply xy, yz, or xz deformations to a second dimension (y +in xy) that is shrink-wrapped via the :doc:`boundary ` +command. + +Related commands +"""""""""""""""" + +:doc:`fix deform `, :doc:`change_box ` + +Default +""""""" + +The option defaults are normalize/pressure = no. + +---------- + +.. _Huang2014: + +**(Huang2014)** X. Huang, "Exploring critical-state behavior using DEM", +Doctoral dissertation, Imperial College. (2014). https://doi.org/10.25560/25316 diff --git a/doc/src/fix_electrode.rst b/doc/src/fix_electrode.rst index 3d543f08d2..8a7a44454d 100644 --- a/doc/src/fix_electrode.rst +++ b/doc/src/fix_electrode.rst @@ -45,7 +45,7 @@ Syntax rng_v = integer used to initialize random number generator * zero or more keyword/value pairs may be appended -* keyword = *algo* or *symm* or *couple* or *etypes* or *ffield* or *write_mat* or *write_inv* or *read_mat* or *read_inv* +* keyword = *algo* or *symm* or *couple* or *etypes* or *ffield* or *write_mat* or *write_inv* or *read_mat* or *read_inv* or *qtotal* or *eta* .. parsed-literal:: @@ -68,6 +68,10 @@ Syntax filename = file from which to read elastance matrix *read_inv* value = filename filename = file from which to read inverted matrix + *qtotal* value = number or *v_* equal-style variable + add overall potential so that all electrode charges add up to *qtotal* + *eta* value = d_propname + d_propname = a custom double vector defined via fix property/atom Examples """""""" @@ -249,6 +253,26 @@ be enabled if any electrode particle has the same type as any electrolyte particle (which would be unusual in a typical simulation) and the fix will issue an error in that case. +.. versionadded:: TBD + +The keyword *qtotal* causes *fix electrode/conp* and *fix electrode/thermo* +to add an overall potential to all electrodes so that the total charge on +the electrodes is a specified amount (which may be an equal-style variable). +For example, if a user wanted to simulate a solution of excess cations +such that the total electrolyte charge is +2, setting *qtotal -2* would cause +the total electrode charge to be -2, so that the simulation box remains overall +electroneutral. Since *fix electrode/conq* constrains the total charges of +individual electrodes, and since *symm on* constrains the total charge of all +electrodes to be zero, either option is incompatible with the *qtotal* keyword +(even if *qtotal* is set to zero). + +.. versionadded:: TBD + +The keyword *eta* takes the name of a custom double vector defined via fix +property/atom. The values will be used instead of the standard eta value. The +property/atom fix must be for vector of double values and use the *ghost on* +option. + Restart, fix_modify, output, run start/stop, minimize info """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" diff --git a/doc/src/fix_gcmc.rst b/doc/src/fix_gcmc.rst index 13ae509684..a21e85d803 100644 --- a/doc/src/fix_gcmc.rst +++ b/doc/src/fix_gcmc.rst @@ -440,8 +440,11 @@ This fix is part of the MC package. It is only enabled if LAMMPS was built with that package. See the :doc:`Build package ` doc page for more info. +This fix style requires an :doc:`atom style ` with per atom +type masses. + Do not set "neigh_modify once yes" or else this fix will never be -called. Reneighboring is required. +called. Reneighboring is **required**. Only usable for 3D simulations. diff --git a/doc/src/fix_indent.rst b/doc/src/fix_indent.rst index 15790e15d0..e041f9f29b 100644 --- a/doc/src/fix_indent.rst +++ b/doc/src/fix_indent.rst @@ -8,33 +8,44 @@ Syntax .. code-block:: LAMMPS - fix ID group-ID indent K keyword values ... + fix ID group-ID indent K gstyle args keyword value ... * ID, group-ID are documented in :doc:`fix ` command * indent = style name of this fix command * K = force constant for indenter surface (force/distance\^2 units) -* one or more keyword/value pairs may be appended -* keyword = *sphere* or *cylinder* or *plane* or *side* or *units* +* gstyle = *sphere* or *cylinder* or *cone* or *plane* .. parsed-literal:: *sphere* args = x y z R - x,y,z = position of center of indenter (distance units) + x, y, z = position of center of indenter (distance units) R = sphere radius of indenter (distance units) - any of x,y,z,R can be a variable (see below) + any of x, y, z, R can be a variable (see below) *cylinder* args = dim c1 c2 R dim = *x* or *y* or *z* = axis of cylinder - c1,c2 = coords of cylinder axis in other 2 dimensions (distance units) + c1, c2 = coords of cylinder axis in other 2 dimensions (distance units) R = cylinder radius of indenter (distance units) any of c1,c2,R can be a variable (see below) + *cone* args = dim c1 c2 radlo radhi lo hi + dim = *x* or *y* or *z* = axis of cone + c1, c2 = coords of cone axis in other 2 dimensions (distance units) + radlo,radhi = cone radii at lo and hi end (distance units) + lo,hi = bounds of cone in dim (distance units) + any of c1, c2, radlo, radhi, lo, hi can be a variable (see below) *plane* args = dim pos side dim = *x* or *y* or *z* = plane perpendicular to this dimension pos = position of plane in dimension x, y, or z (distance units) pos can be a variable (see below) side = *lo* or *hi* + +* zero or more keyword/value pairs may be appended +* keyword = *side* or *units* + + .. parsed-literal:: + *side* value = *in* or *out* - *in* = the indenter acts on particles inside the sphere or cylinder - *out* = the indenter acts on particles outside the sphere or cylinder + *in* = the indenter acts on particles inside the sphere or cylinder or cone + *out* = the indenter acts on particles outside the sphere or cylinder or cone *units* value = *lattice* or *box* lattice = the geometry is defined in lattice units box = the geometry is defined in simulation box units @@ -53,12 +64,12 @@ Description Insert an indenter within a simulation box. The indenter repels all atoms in the group that touch it, so it can be used to push into a -material or as an obstacle in a flow. Or it can be used as a +material or as an obstacle in a flow. Alternatively, it can be used as a constraining wall around a simulation; see the discussion of the *side* keyword below. -The indenter can either be spherical or cylindrical or planar. You -must set one of those 3 keywords. +The *gstyle* geometry of the indenter can either be a sphere, a +cylinder, a cone, or a plane. A spherical indenter exerts a force of magnitude @@ -75,15 +86,20 @@ A cylindrical indenter exerts the same force, except that *r* is the distance from the atom to the center axis of the cylinder. The cylinder extends infinitely along its axis. -Spherical and cylindrical indenters account for periodic boundaries in -two ways. First, the center point of a spherical indenter (x,y,z) or -axis of a cylindrical indenter (c1,c2) is remapped back into the -simulation box, if the box is periodic in a particular dimension. -This occurs every timestep if the indenter geometry is specified with -a variable (see below), e.g. it is moving over time. Second, the -calculation of distance to the indenter center or axis accounts for -periodic boundaries. Both of these mean that an indenter can -effectively move through and straddle one or more periodic boundaries. +A conical indenter is similar to a cylindrical indenter except that it +has a finite length (between *lo* and *hi*), and that two different +radii (one at each end, *radlo* and *radhi*) can be defined. + +Spherical, cylindrical, and conical indenters account for periodic +boundaries in two ways. First, the center point of a spherical +indenter (x,y,z) or axis of a cylindrical/conical indenter (c1,c2) is +remapped back into the simulation box, if the box is periodic in a +particular dimension. This occurs every timestep if the indenter +geometry is specified with a variable (see below), e.g. it is moving +over time. Second, the calculation of distance to the indenter center +or axis accounts for periodic boundaries. Both of these mean that an +indenter can effectively move through and straddle one or more +periodic boundaries. A planar indenter is really an axis-aligned infinite-extent wall exerting the same force on atoms in the system, where *R* is the @@ -97,9 +113,13 @@ is specified as *hi*\ . Any of the 4 quantities defining a spherical indenter's geometry can be specified as an equal-style :doc:`variable `, namely *x*, -*y*, *z*, or *R*\ . Similarly, for a cylindrical indenter, any of *c1*, -*c2*, or *R*, can be a variable. For a planar indenter, *pos* can be -a variable. If the value is a variable, it should be specified as +*y*, *z*, or *R*\ . For a cylindrical indenter, any of the 3 +quantities *c1*, *c2*, or *R*, can be a variable. For a conical +indenter, any of the 6 quantities *c1*, *c2*, *radlo*, *radhi*, *lo*, +or *hi* can be a variable. For a planar indenter, the single value +*pos* can be a variable. + +If any of these values is a variable, it should be specified as v_name, where name is the variable name. In this case, the variable will be evaluated each timestep, and its value used to define the indenter geometry. @@ -110,7 +130,8 @@ command keywords for the simulation box parameters and timestep and elapsed time. Thus it is easy to specify indenter properties that change as a function of time or span consecutive runs in a continuous fashion. For the latter, see the *start* and *stop* keywords of the -:doc:`run ` command and the *elaplong* keyword of :doc:`thermo_style custom ` for details. +:doc:`run ` command and the *elaplong* keyword of +:doc:`thermo_style custom ` for details. For example, if a spherical indenter's x-position is specified as v_x, then this variable definition will keep it's center at a relative @@ -141,12 +162,13 @@ rate. If the *side* keyword is specified as *out*, which is the default, then particles outside the indenter are pushed away from its outer -surface, as described above. This only applies to spherical or -cylindrical indenters. If the *side* keyword is specified as *in*, -the action of the indenter is reversed. Particles inside the indenter -are pushed away from its inner surface. In other words, the indenter -is now a containing wall that traps the particles inside it. If the -radius shrinks over time, it will squeeze the particles. +surface, as described above. This only applies to spherical, +cylindrical, and conical indenters. If the *side* keyword is +specified as *in*, the action of the indenter is reversed. Particles +inside the indenter are pushed away from its inner surface. In other +words, the indenter is now a containing wall that traps the particles +inside it. If the radius shrinks over time, it will squeeze the +particles. The *units* keyword determines the meaning of the distance units used to define the indenter geometry. A *box* value selects standard @@ -166,10 +188,10 @@ lattice spacings in a variable formula. The force constant *K* is not affected by the *units* keyword. It is always in force/distance\^2 units where force and distance are defined -by the :doc:`units ` command. If you wish K to be scaled by the -lattice spacing, you can define K with a variable whose formula -contains *xlat*, *ylat*, *zlat* keywords of the -:doc:`thermo_style ` command, e.g. +by the :doc:`units ` command. If you wish K to be scaled by +the lattice spacing, you can define K with a variable whose formula +contains *xlat*, *ylat*, *zlat* keywords of the :doc:`thermo_style +` command, e.g. .. code-block:: LAMMPS diff --git a/doc/src/fix_neb.rst b/doc/src/fix_neb.rst index ccd0f9b83d..51066675b8 100644 --- a/doc/src/fix_neb.rst +++ b/doc/src/fix_neb.rst @@ -109,7 +109,7 @@ Note that in this case the specified *Kspring* is in force/distance units. With a value of *ideal*, the spring force is computed as suggested in -ref`(WeinanE) ` +:ref:`(WeinanE) ` .. math:: @@ -120,18 +120,18 @@ and :math:`RD_{ideal}` is the ideal *RD* for which all the images are equally spaced. I.e. :math:`RD_{ideal} = (i-1) \cdot meanDist` when the climbing replica is off, where *i* is the replica number). The *meanDist* is the average distance between replicas. Note that in this -case the specified *Kspring* is in force units. When the climbing replica -is on, :math:`RD_{ideal}` and :math:`meanDist` are calculated separately -each side of the climbing image. Note that the *ideal* form of nudging -can often be more effective at keeping the replicas equally spaced before -climbing, then equally spaced either side of the climbing image whilst -climbing. +case the specified *Kspring* is in force units. When the climbing +replica is on, :math:`RD_{ideal}` and :math:`meanDist` are calculated +separately each side of the climbing image. Note that the *ideal* form +of nudging can often be more effective at keeping the replicas equally +spaced before climbing, then equally spaced either side of the climbing +image whilst climbing. -With a value of *equal* the spring force is computed as for *ideal* -when the climbing replica is off, promoting equidistance. When the climbing +With a value of *equal* the spring force is computed as for *ideal* when +the climbing replica is off, promoting equidistance. When the climbing replica is on, the spring force is computed to promote equidistant -absolute differences in energy, rather than distance, each side of -the climbing image: +absolute differences in energy, rather than distance, each side of the +climbing image: .. math:: @@ -143,23 +143,22 @@ where *ED* is the cumulative sum of absolute energy differences: ED = \sum_{i`. +*meanEdist* is the average absolute energy difference between replicas +up to the climbing image or from the climbing image to the final image, +for images before or after the climbing image +respectively. :math:`ED_{ideal}` is the corresponding cumulative sum of +average absolute energy differences in each case, in close analogy to +*ideal*. This form of nudging is to aid schemes which integrate forces +along, or near to, NEB pathways such as :doc:`fix_pafi `. ---------- -The keyword *perp* specifies if and how a perpendicular nudging force -is computed. It adds a spring force perpendicular to the path in -order to prevent the path from becoming too strongly kinked. It can +The keyword *perp* specifies if and how a perpendicular nudging force is +computed. It adds a spring force perpendicular to the path in order to +prevent the path from becoming too strongly kinked. It can significantly improve the convergence of the NEB calculation when the -resolution is poor. I.e. when few replicas are used; see -:ref:`(Maras) ` for details. +resolution is poor. I.e. when few replicas are used; see :ref:`(Maras) +` for details. The perpendicular spring force is given by @@ -181,10 +180,10 @@ force is added. By default, no additional forces act on the first and last replicas during the NEB relaxation, so these replicas simply relax toward their -respective local minima. By using the key word *end*, additional -forces can be applied to the first and/or last replicas, to enable -them to relax toward a MEP while constraining their energy E to the -target energy ETarget. +respective local minima. By using the key word *end*, additional forces +can be applied to the first and/or last replicas, to enable them to +relax toward a MEP while constraining their energy E to the target +energy ETarget. If :math:`E_{Target} > E`, the interatomic force :math:`F_i` for the specified replica becomes: @@ -197,33 +196,33 @@ specified replica becomes: The "spring" constant on the difference in energies is the specified *Kspring3* value. -When *estyle* is specified as *first*, the force is applied to the -first replica. When *estyle* is specified as *last*, the force is -applied to the last replica. Note that the *end* keyword can be used -twice to add forces to both the first and last replicas. +When *estyle* is specified as *first*, the force is applied to the first +replica. When *estyle* is specified as *last*, the force is applied to +the last replica. Note that the *end* keyword can be used twice to add +forces to both the first and last replicas. For both these *estyle* settings, the target energy *ETarget* is set to the initial energy of the replica (at the start of the NEB calculation). If the *estyle* is specified as *last/efirst* or *last/efirst/middle*, -force is applied to the last replica, but the target energy *ETarget* -is continuously set to the energy of the first replica, as it evolves +force is applied to the last replica, but the target energy *ETarget* is +continuously set to the energy of the first replica, as it evolves during the NEB relaxation. The difference between these two *estyle* options is as follows. When *estyle* is specified as *last/efirst*, no change is made to the -inter-replica force applied to the intermediate replicas (neither -first or last). If the initial path is too far from the MEP, an -intermediate replica may relax "faster" and reach a lower energy than -the last replica. In this case the intermediate replica will be -relaxing toward its own local minima. This behavior can be prevented -by specifying *estyle* as *last/efirst/middle* which will alter the -inter-replica force applied to intermediate replicas by removing the -contribution of the gradient to the inter-replica force. This will -only be done if a particular intermediate replica has a lower energy -than the first replica. This should effectively prevent the -intermediate replicas from over-relaxing. +inter-replica force applied to the intermediate replicas (neither first +or last). If the initial path is too far from the MEP, an intermediate +replica may relax "faster" and reach a lower energy than the last +replica. In this case the intermediate replica will be relaxing toward +its own local minima. This behavior can be prevented by specifying +*estyle* as *last/efirst/middle* which will alter the inter-replica +force applied to intermediate replicas by removing the contribution of +the gradient to the inter-replica force. This will only be done if a +particular intermediate replica has a lower energy than the first +replica. This should effectively prevent the intermediate replicas from +over-relaxing. After converging a NEB calculation using an *estyle* of *last/efirst/middle*, you should check that all intermediate replicas @@ -237,9 +236,10 @@ target energy. Restart, fix_modify, output, run start/stop, minimize info """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" -No information about this fix is written to :doc:`binary restart files `. None of the :doc:`fix_modify ` options -are relevant to this fix. No global or per-atom quantities are stored -by this fix for access by various :doc:`output commands `. +No information about this fix is written to :doc:`binary restart files +`. None of the :doc:`fix_modify ` options are +relevant to this fix. No global or per-atom quantities are stored by +this fix for access by various :doc:`output commands `. No parameter of this fix can be used with the *start/stop* keywords of the :doc:`run ` command. diff --git a/doc/src/fix_nonaffine_displacement.rst b/doc/src/fix_nonaffine_displacement.rst index 363b0a747a..0a271ebc32 100644 --- a/doc/src/fix_nonaffine_displacement.rst +++ b/doc/src/fix_nonaffine_displacement.rst @@ -44,7 +44,7 @@ Examples Description """"""""""" -.. versionadded:: TBD +.. versionadded:: 7Feb2024 This fix computes different metrics of the nonaffine displacement of particles. The first metric, *d2min* calculates the :math:`D^2_\mathrm{min}` @@ -86,8 +86,8 @@ Both of these methods require defining a reference state. With the *fixed* refer style, the user picks a specific timestep *nstep* at which particle positions are saved. If peratom data is accessed from this compute prior to this timestep, it will simply be zeroed. The *update* reference style implies the reference state will be updated every -*nstep* timesteps. The *offset* reference only applies to the *d2min* metric and will -update the reference state *nstep* timesteps before a multiple of *nevery* timesteps. +*nstep* timesteps. The *offset* reference will update the reference state *nstep* +timesteps before a multiple of *nevery* timesteps. ---------- diff --git a/doc/src/fix_property_atom.rst b/doc/src/fix_property_atom.rst index b177fe9a96..d20358b7a7 100644 --- a/doc/src/fix_property_atom.rst +++ b/doc/src/fix_property_atom.rst @@ -22,6 +22,8 @@ Syntax *mol* = molecule IDs *q* = charge *rmass* = per-atom mass + *temperature* = internal temperature of atom + *heatflow* = internal heat flow of atom i_name = new integer vector referenced by name d_name = new floating-point vector referenced by name i2_name = new integer array referenced by name @@ -59,14 +61,18 @@ these properties for each atom in the system when a data file is read. This fix augments the set of per-atom properties with new custom ones. This can be useful in several scenarios. -If the atom style does not define molecule IDs, per-atom charge, or -per-atom mass, they can be added using the *mol*\ , *q* or *rmass* +If the atom style does not define molecule IDs, per-atom charge, +per-atom mass, internal temperature, or internal heat flow, they can +be added using the *mol*\ , *q*, *rmass*, *temperature*, or *heatflow* keywords. This could be useful to define "molecules" to use as rigid bodies with the :doc:`fix rigid ` command, or to carry around an extra flag with atoms (stored as a molecule ID) that can be used by various commands like :doc:`compute chunk/atom ` to group atoms without having to use the group command (which is limited to a total of 32 groups including *all*\ ). +For finite-size particles, an internal temperature and heat flow can +be used to model heat conduction as in the +:doc:`GRANULAR package `. Another application is to use the *rmass* flag in order to have per-atom masses instead of per-type masses. This could be used to @@ -85,9 +91,10 @@ properties that are not needed such as bond lists, which incurs some overhead when there are no bonds. In the future, we may add additional existing per-atom properties to -fix property/atom, similar to *mol*\ , *q* or *rmass*\ , which -"turn-on" specific properties defined by some atom styles, so they can -be easily used by atom styles that do not define them. +fix property/atom, similar to *mol*\ , *q*, *rmass*\ , *temperature*\ , +or *heatflow* which "turn-on" specific properties defined by some atom +styles, so they can be easily used by atom styles that do not define +them. More generally, the *i_name* and *d_name* options allow one or more new custom per-atom vectors to be defined. Likewise the *i2_name* and diff --git a/doc/src/fix_sgcmc.rst b/doc/src/fix_sgcmc.rst index 63cfaf22da..bcdbdf2736 100644 --- a/doc/src/fix_sgcmc.rst +++ b/doc/src/fix_sgcmc.rst @@ -155,6 +155,9 @@ This fix is part of the MC package. It is only enabled if LAMMPS was built with that package. See the :doc:`Build package ` page for more info. +This fix style requires an :doc:`atom style ` with per atom +type masses. + At present the fix provides optimized subroutines for EAM type potentials (see above) that calculate potential energy changes due to *local* atom type swaps very efficiently. Other potentials are diff --git a/doc/src/fix_ttm.rst b/doc/src/fix_ttm.rst index ccf7f16554..5a7f864686 100644 --- a/doc/src/fix_ttm.rst +++ b/doc/src/fix_ttm.rst @@ -96,11 +96,11 @@ each processor, which is acceptable when the overall grid is reasonably small. For larger grids you should use fix *ttm/grid* instead. Fix *ttm/mod* adds options to account for external heat sources (e.g. at -a surface) and for specifying parameters that allow the electronic -heat capacity to depend strongly on electronic temperature. It is -more expensive computationally than fix *ttm* because it treats the -thermal diffusion equation as non-linear. More details on fix *ttm/mod* -are given below. +a surface) and for specifying parameters that allow the electronic heat +capacity to depend strongly on electronic temperature. It is more +expensive computationally than fix *ttm* because it treats the thermal +diffusion equation as non-linear. More details on fix *ttm/mod* are +given below. Heat transfer between the electronic and atomic subsystems is carried out via an inhomogeneous Langevin thermostat. Only atoms in the fix @@ -303,15 +303,15 @@ The current fix ttm/mod implementation allows TTM simulations with a vacuum. The vacuum region is defined as the grid cells with zero electronic temperature. The numerical scheme does not allow energy exchange with such cells. Since the material can expand to previously -unoccupied region in some simulations, the vacuum border can be -allowed to move. It is controlled by the *surface_movement* parameter -in the *init_file*. If it is set to 1, then "vacuum" cells can be -changed to "electron-filled" cells with the temperature *T_e_min* if -atoms move into them (currently only implemented for the case of -1-dimensional motion of flat surface normal to the X axis). The -initial borders of vacuum can be set in the *init_file* via *lsurface* -and *rsurface* parameters. In this case, electronic pressure gradient -is calculated as +unoccupied region in some simulations, the vacuum border can be allowed +to move. It is controlled by the *surface_movement* parameter in the +*init_file*. If it is set to 1, then "vacuum" cells can be changed to +"electron-filled" cells with the temperature *T_e_min* if atoms move +into them (currently only implemented for the case of 1-dimensional +motion of a flat surface normal to the X axis). The initial locations of +the interfaces of the electron density to the vacuum can be set in the +*init_file* via *lsurface* and *rsurface* parameters. In this case, +electronic pressure gradient is calculated as .. math:: diff --git a/doc/src/fix_wall_flow.rst b/doc/src/fix_wall_flow.rst new file mode 100644 index 0000000000..b40ba9697f --- /dev/null +++ b/doc/src/fix_wall_flow.rst @@ -0,0 +1,175 @@ +.. index:: fix wall/flow +.. index:: fix wall/flow/kk + +fix wall/flow command +===================== + +Accelerator Variants: *wall/flow/kk* + +Syntax +"""""" + +.. code-block:: LAMMPS + + fix ID group-ID wall/flow axis vflow T seed N coords ... keyword value + +* ID, group-ID are documented in :doc:`fix ` command +* wall/flow = style name of this fix command +* axis = flow axis (*x*, *y*, or *z*) +* vflow = generated flow velocity in *axis* direction (velocity units) +* T = flow temperature (temperature units) +* seed = random seed for stochasticity (positive integer) +* N = number of walls +* coords = list of N wall positions along the *axis* direction in ascending order (distance units) +* zero or more keyword/value pairs may be appended +* keyword = *units* + + .. parsed-literal:: + + *units* value = *lattice* or *box* + *lattice* = wall positions are defined in lattice units + *box* = the wall positions are defined in simulation box units + +Examples +"""""""" + +.. code-block:: LAMMPS + + fix 1 all wall/flow x 0.4 1.5 593894 4 2.0 4.0 6.0 8.0 + +Description +""""""""""" + +.. versionadded:: TBD + +This fix implements flow boundary conditions (FBC) introduced in +:ref:`(Pavlov1) ` and :ref:`(Pavlov2) `. +The goal is to generate a stationary flow with a shifted Maxwell +velocity distribution: + +.. math:: + + f_a(v_a) \propto \exp{\left(-\frac{m (v_a-v_{\text{flow}})^2}{2 kB T}\right)} + +where :math:`v_a` is the component of velocity along the specified +*axis* argument (a = x,y,z), :math:`v_{\text{flow}}` is the flow +velocity specified as the *vflow* argument, *T* is the specified flow +temperature, *m* is the particle mass, and *kB* is the Boltzmann +constant. + +This is achieved by defining a series of *N* transparent walls along +the flow *axis* direction. Each wall is at the specified position +listed in the *coords* argument. Note that an additional transparent +wall is defined by the code at the boundary of the (periodic) +simulation domain in the *axis* direction. So there are effectively +N+1 walls. + +Each time a particle in the specified group passes through one of the +transparent walls, its velocity is re-assigned. Particles not in the +group do not interact with the wall. This can be used, for example, to +add obstacles composed of atoms, or to simulate a solution of complex +molecules in a one-atom liquid (note that the fix has been tested for +one-atom systems only). + +Conceptually, the velocity re-assignment represents creation of a new +particle within the system with simultaneous removal of the particle +which passed through the wall. The velocity components in directions +parallel to the wall are re-assigned according to the standard Maxwell +velocity distribution for the specified temperature *T*. The velocity +component perpendicular to the wall is re-assigned according to the +shifted Maxwell distribution defined above: + +.. math:: + + f_{\text{a generated}}(v_a) \propto v_a f_a(v_a) + +It can be shown that for an ideal-gas scenario this procedure makes +the velocity distribution of particles between walls exactly as +desired. + +Since in most cases simulated systems are not an ideal gas, multiple +walls can be defined, since a single wall may not be sufficient for +maintaining a stationary flow without "congestion" which can manifest +itself as regions in the flow with increased particle density located +upstream from static obstacles. + +For the same reason, the actual temperature and velocity of the +generated flow may differ from what is requested. The degree of +discrepancy is determined by how different from an ideal gas the +simulated system is. Therefore, a calibration procedure may be +required for such a system as described in :ref:`(Pavlov) +`. + +Note that the interactions between particles on different sides of a +transparent wall are not disabled or neglected. Likewise particle +positions are not altered by the velocity reassignment. This removes +the need to modify the force field to work correctly in cases when a +particle is close to a wall. + +For example, if particle positions were uniformly redistributed across +the surface of a wall, two particles could end up too close to each +other, potentially causing the simulation to explode. However due to +this compromise, some collective phenomena such as regions with +increased/decreased density or collective movements are not fully +removed when particles cross a wall. This unwanted consequence can +also be potentially mitigated by using more multiple walls. + +.. note:: + + When the specified flow has a high velocity, a lost atoms error can + occur (see :doc:`error messages `). If this + happens, you should ensure the checks for neighbor list rebuilds, + set via the :doc:`neigh_modify ` command, are as + conservative as possible (every timestep if needed). Those are the + default settings. + +Restart, fix_modify, output, run start/stop, minimize info +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +No information about this fix is written to :doc:`binary restart files +`. + +None of the :doc:`fix_modify ` options are relevant to +this fix. + +No global or per-atom quantities are stored by this fix for access by +various :doc:`output commands `. + +No parameter of this fix can be used with the *start/stop* keywords of +the :doc:`run ` command. + +This fix is not invoked during :doc:`energy minimization `. + +Restrictions +"""""""""""" + +Fix *wall_flow* is part of the EXTRA-FIX package. It is only enabled +if LAMMPS was built with that package. See the :doc:`Build package +` page for more info. + +Flow boundary conditions should not be used with rigid bodies such as +those defined by a "fix rigid" command. + +This fix can only be used with periodic boundary conditions along the +flow axis. The size of the box in this direction must not change. Also, +the fix is designed to work only in an orthogonal simulation box. + +Related commands +"""""""""""""""" + +:doc:`fix wall/reflect ` command + +Default +""""""" + +The default for the units keyword is lattice. + +---------- + +.. _fbc-Pavlov1: + +**(Pavlov1)** Pavlov, Kolotinskii, Stegailov, "GPU-Based Molecular Dynamics of Turbulent Liquid Flows with OpenMM", Proceedings of PPAM-2022, LNCS (Springer), vol. 13826, pp. 346-358 (2023) + +.. _fbc-Pavlov2: + +**(Pavlov2)** Pavlov, Galigerov, Kolotinskii, Nikolskiy, Stegailov, "GPU-based Molecular Dynamics of Fluid Flows: Reaching for Turbulence", Int. J. High Perf. Comp. Appl., (2024) diff --git a/doc/src/fix_widom.rst b/doc/src/fix_widom.rst index ff66095db5..43e081800f 100644 --- a/doc/src/fix_widom.rst +++ b/doc/src/fix_widom.rst @@ -195,8 +195,11 @@ doc page for more info. Do not set "neigh_modify once yes" or else this fix will never be called. Reneighboring is **required**. -Can be run in parallel, but aspects of the GCMC part will not scale well -in parallel. Only usable for 3D simulations. +This fix style requires an :doc:`atom style ` with per atom +type masses. + +Can be run in parallel, but some aspects of the insertion procedure +will not scale well in parallel. Only usable for 3D simulations. Related commands diff --git a/doc/src/info.rst b/doc/src/info.rst index 958542e3c8..b06fa4fc5d 100644 --- a/doc/src/info.rst +++ b/doc/src/info.rst @@ -10,7 +10,7 @@ Syntax info args -* args = one or more of the following keywords: *out*, *all*, *system*, *memory*, *communication*, *computes*, *dumps*, *fixes*, *groups*, *regions*, *variables*, *coeffs*, *styles*, *time*, *accelerator*, or *configuration* +* args = one or more of the following keywords: *out*, *all*, *system*, *memory*, *communication*, *computes*, *dumps*, *fixes*, *groups*, *regions*, *variables*, *coeffs*, *styles*, *time*, *accelerator*, *fft* or *configuration* * *out* values = *screen*, *log*, *append* filename, *overwrite* filename * *styles* values = *all*, *angle*, *atom*, *bond*, *compute*, *command*, *dump*, *dihedral*, *fix*, *improper*, *integrate*, *kspace*, *minimize*, *pair*, *region* @@ -92,6 +92,13 @@ The *accelerator* category prints out information about compile time settings of included accelerator support for the GPU, KOKKOS, INTEL, and OPENMP packages. +.. versionadded:: 7Feb2024 + +The *fft* category prints out information about the included 3d-FFT +support. This lists the 3d-FFT engine, FFT precision, FFT library +used by the FFT engine. If the KOKKOS package is included, the settings +used for the KOKKOS package are displayed as well. + The *styles* category prints the list of styles available in the current LAMMPS binary. It supports one of the following options to control which category of styles is printed out: diff --git a/doc/src/kspace_style.rst b/doc/src/kspace_style.rst index 38a6fce375..e7d5e93d72 100644 --- a/doc/src/kspace_style.rst +++ b/doc/src/kspace_style.rst @@ -450,7 +450,10 @@ relative RMS error. For the KOKKOS package, the *pppm/kk* style performs charge assignment and force interpolation calculations, along with the FFTs themselves, on the GPU or (optionally) threaded on the CPU when - using OpenMP and FFTW3. + using OpenMP and FFTW3. The specific FFT library is selected using + the FFT_KOKKOS CMake parameter. See the + :doc:`Build settings ` doc page for how to select a + 3rd-party FFT library. ---------- diff --git a/doc/src/molecule.rst b/doc/src/molecule.rst index b930a9fc65..1fe3f36eaa 100644 --- a/doc/src/molecule.rst +++ b/doc/src/molecule.rst @@ -126,14 +126,50 @@ molecule (header keyword = inertia). Format of a molecule file """"""""""""""""""""""""" -The format of an individual molecule file is similar but -(not identical) to the data file read by the :doc:`read_data ` -commands, and is as follows. +The format of an individual molecule file looks similar but is +different than that of a data file read by the :doc:`read_data ` +commands. Here is a simple example for a TIP3P water molecule: + +.. code-block:: + + # Water molecule. TIP3P geometry + # header section: + 3 atoms + 2 bonds + 1 angles + + # body section: + Coords + + 1 0.00000 -0.06556 0.00000 + 2 0.75695 0.52032 0.00000 + 3 -0.75695 0.52032 0.00000 + + Types + + 1 1 # O + 2 2 # H + 3 2 # H + + Charges + + 1 -0.834 + 2 0.417 + 3 0.417 + + Bonds + + 1 1 1 2 + 2 1 1 3 + + Angles + + 1 1 2 1 3 A molecule file has a header and a body. The header appears first. The -first line of the header and thus of the molecule file is *always* skipped; -it typically contains a description of the file or a comment from the software -that created the file. +first line of the header and thus of the molecule file is *always* +skipped; it typically contains a description of the file or a comment +from the software that created the file. Then lines are read one line at a time. Lines can have a trailing comment starting with '#' that is ignored. There *must* be at least one @@ -158,25 +194,62 @@ appear if the value(s) are different than the default, except when defining a *body* particle, which requires setting the number of *atoms* to 1, and setting the *inertia* in a specific section (see below). -* N *atoms* = # of atoms N in molecule, default = 0 -* Nb *bonds* = # of bonds Nb in molecule, default = 0 -* Na *angles* = # of angles Na in molecule, default = 0 -* Nd *dihedrals* = # of dihedrals Nd in molecule, default = 0 -* Ni *impropers* = # of impropers Ni in molecule, default = 0 -* Nf *fragments* = # of fragments Nf in molecule, default = 0 -* Ninteger Ndouble *body* = # of integer and floating-point values - in body particle, default = 0 -* Mtotal *mass* = total mass of molecule -* Xc Yc Zc *com* = coordinates of center-of-mass of molecule -* Ixx Iyy Izz Ixy Ixz Iyz *inertia* = 6 components of inertia tensor of molecule + .. list-table:: + :header-rows: 1 + :widths: auto -For *mass*, *com*, and *inertia*, the default is for LAMMPS to -calculate this quantity itself if needed, assuming the molecules -consist of a set of point particles or finite-size particles (with a -non-zero diameter) that do not overlap. If finite-size particles in -the molecule do overlap, LAMMPS will not account for the overlap -effects when calculating any of these 3 quantities, so you should -pre-compute them yourself and list the values in the file. + * - Number(s) + - Keyword + - Meaning + - Default Value + * - N + - atoms + - # of atoms N in molecule + - 0 + * - Nb + - bonds + - # of bonds Nb in molecule + - 0 + * - Na + - angles + - # of angles Na in molecule + - 0 + * - Nd + - dihedrals + - # of dihedrals Nd in molecule + - 0 + * - Ni + - impropers + - # of impropers Ni in molecule + - 0 + * - Nf + - fragments + - # of fragments Nf in molecule + - 0 + * - Ninteger Ndouble + - body + - # of integer and floating-point values in body particle + - 0 + * - Mtotal + - mass + - total mass of molecule + - computed + * - Xc Yc Zc + - com + - coordinates of center-of-mass of molecule + - computed + * - Ixx Iyy Izz Ixy Ixz Iyz + - inertia + - 6 components of inertia tensor of molecule + - computed + +For *mass*, *com*, and *inertia*, the default is for LAMMPS to calculate +this quantity itself if needed, assuming the molecules consist of a set +of point particles or finite-size particles (with a non-zero diameter) +that do **not** overlap. If finite-size particles in the molecule +**do** overlap, LAMMPS will not account for the overlap effects when +calculating any of these 3 quantities, so you should pre-compute them +yourself and list the values in the file. The mass and center-of-mass coordinates (Xc,Yc,Zc) are self-explanatory. The 6 moments of inertia (ixx,iyy,izz,ixy,ixz,iyz) @@ -188,7 +261,7 @@ internally. These are the allowed section keywords for the body of the file. -* *Coords, Types, Molecules, Fragments, Charges, Diameters, Masses* = atom-property sections +* *Coords, Types, Molecules, Fragments, Charges, Diameters, Dipoles, Masses* = atom-property sections * *Bonds, Angles, Dihedrals, Impropers* = molecular topology sections * *Special Bond Counts, Special Bonds* = special neighbor info * *Shake Flags, Shake Atoms, Shake Bond Types* = SHAKE info @@ -303,6 +376,21 @@ not listed, the default diameter of each atom in the molecule is 1.0. ---------- +.. versionadded:: 7Feb2024 + +*Dipoles* section: + +* one line per atom +* line syntax: ID mux muy muz +* mux,muy,muz = x-, y-, and z-component of point dipole vector of atom + +This section is only allowed for :doc:`atom styles ` that +support particles with point dipoles, e.g. atom_style dipole. If not +listed, the default dipole component of each atom in the molecule is set +to 0.0. + +---------- + *Masses* section: * one line per atom diff --git a/doc/src/neb.rst b/doc/src/neb.rst index 0bc5de010b..b626796b6b 100644 --- a/doc/src/neb.rst +++ b/doc/src/neb.rst @@ -10,7 +10,7 @@ Syntax neb etol ftol N1 N2 Nevery file-style arg keyword values -* etol = stopping tolerance for energy (energy units) +* etol = stopping tolerance for energy (dimensionless) * ftol = stopping tolerance for force (force units) * N1 = max # of iterations (timesteps) to run initial NEB * N2 = max # of iterations (timesteps) to run barrier-climbing NEB @@ -89,10 +89,11 @@ potentials, and the starting configuration when the neb command is issued should be the same for every replica. In a NEB calculation each replica is connected to other replicas by -inter-replica nudging forces. These forces are imposed by the :doc:`fix neb ` command, which must be used in conjunction with the -neb command. The group used to define the fix neb command defines the -NEB atoms which are the only ones that inter-replica springs are -applied to. If the group does not include all atoms, then non-NEB +inter-replica nudging forces. These forces are imposed by the +:doc:`fix neb ` command, which must be used in conjunction +with the neb command. The group used to define the fix neb command +defines the NEB atoms which are the only ones that inter-replica springs +are applied to. If the group does not include all atoms, then non-NEB atoms have no inter-replica springs and the forces they feel and their motion is computed in the usual way due only to other atoms within their replica. Conceptually, the non-NEB atoms provide a background @@ -445,7 +446,7 @@ Related commands """""""""""""""" :doc:`prd `, :doc:`temper `, :doc:`fix langevin `, -:doc:`fix viscous ` +:doc:`fix viscous `, :doc:`fix neb ` Default """"""" diff --git a/doc/src/package.rst b/doc/src/package.rst index 212a06258c..2fe4baaae7 100644 --- a/doc/src/package.rst +++ b/doc/src/package.rst @@ -74,7 +74,7 @@ Syntax *no_affinity* values = none *kokkos* args = keyword value ... zero or more keyword/value pairs may be appended - keywords = *neigh* or *neigh/qeq* or *neigh/thread* or *neigh/transpose* or *newton* or *binsize* or *comm* or *comm/exchange* or *comm/forward* or *comm/pair/forward* or *comm/fix/forward* or *comm/reverse* or *comm/pair/reverse* or *sort* or *gpu/aware* or *pair/only* + keywords = *neigh* or *neigh/qeq* or *neigh/thread* or *neigh/transpose* or *newton* or *binsize* or *comm* or *comm/exchange* or *comm/forward* or *comm/pair/forward* or *comm/fix/forward* or *comm/reverse* or *comm/pair/reverse* or *sort* or *atom/map* or *gpu/aware* or *pair/only* *neigh* value = *full* or *half* full = full neighbor list half = half neighbor list built in thread-safe manner @@ -108,6 +108,9 @@ Syntax *sort* value = *no* or *device* *no* = perform atom sorting in non-KOKKOS mode *device* = perform atom sorting on device (e.g. on GPU) + *atom/map* value = *no* or *device* + *no* = build atom map in non-KOKKOS mode + *device* = build atom map on device (e.g. on GPU) *gpu/aware* = *off* or *on* *off* = do not use GPU-aware MPI *on* = use GPU-aware MPI (default) @@ -566,15 +569,19 @@ performing the exchange pack/unpack on the host CPU can give speedup since it reduces the number of CUDA kernel launches. The *sort* keyword determines whether the host or device performs atom -sorting, see the :doc:`atom_modify sort ` command. The -value options for the *sort* keyword are *no* or *device* similar to the -*comm* keywords above. If a value of *host* is used it will be -automatically be changed to *no* since the *sort* keyword does not -support *host* mode. The value of *no* will also always be used when -running on the CPU, i.e. setting the value to *device* will have no -effect if the simulation is running on the CPU. Not all fix styles with -extra atom data support *device* mode and in that case a warning will be -given and atom sorting will run in *no* mode instead. +sorting, see the :doc:`atom_modify sort ` command. The value +options for the *sort* keyword are *no* or *device* similar to the *comm* +keywords above. If a value of *host* is used it will be automatically be +changed to *no* since the *sort* keyword does not support *host* mode. Not +all fix styles with extra atom data support *device* mode and in that case +a warning will be given and atom sorting will run in *no* mode instead. + +.. versionadded:: TBD + +The *atom/map* keyword determines whether the host or device builds the +atom_map, see the :doc:`atom_modify map ` command. The +value options for the *atom/map* keyword are identical to the *sort* +keyword above. The *gpu/aware* keyword chooses whether GPU-aware MPI will be used. When this keyword is set to *on*, buffers in GPU memory are passed directly @@ -593,12 +600,13 @@ for OpenMPI 1.8 (or later versions), Mvapich2 1.9 (or later) when the Spectrum MPI when the "-gpu" flag is used. The *pair/only* keyword can change how the KOKKOS suffix "kk" is applied -when using an accelerator device. By default device acceleration is -always used for all available styles. With *pair/only* set to *on* the -suffix setting will choose device acceleration only for pair styles and -run all other force computations on the host CPU. -The *comm* flags will also automatically be changed to *no*\ . This can -result in better performance for certain configurations and system sizes. +when using an accelerator device. By default device acceleration is always +used for all available styles. With *pair/only* set to *on* the suffix +setting will choose device acceleration only for pair styles and run all +other force computations on the host CPU. The *comm* flags, along with the +*sort* and *atom/map* keywords will also automatically be changed to *no*\ . +This can result in better performance for certain configurations and +system sizes. ---------- @@ -684,18 +692,18 @@ Restrictions This command cannot be used after the simulation box is defined by a :doc:`read_data ` or :doc:`create_box ` command. -The gpu style of this command can only be invoked if LAMMPS was built +The *gpu* style of this command can only be invoked if LAMMPS was built with the GPU package. See the :doc:`Build package ` doc page for more info. -The intel style of this command can only be invoked if LAMMPS was +The *intel* style of this command can only be invoked if LAMMPS was built with the INTEL package. See the :doc:`Build package ` page for more info. -The kk style of this command can only be invoked if LAMMPS was built +The *kokkos* style of this command can only be invoked if LAMMPS was built with the KOKKOS package. See the :doc:`Build package ` doc page for more info. -The omp style of this command can only be invoked if LAMMPS was built +The *omp* style of this command can only be invoked if LAMMPS was built with the OPENMP package. See the :doc:`Build package ` doc page for more info. @@ -704,19 +712,27 @@ Related commands :doc:`suffix `, :doc:`-pk command-line switch ` -Default -""""""" +Defaults +"""""""" -For the GPU package, the default is Ngpu = 0 and the option defaults are neigh -= yes, newton = off, binsize = 0.0, split = 1.0, gpuID = 0 to Ngpu-1, tpa = 1, -omp = 0, and platform=-1. These settings are made automatically if the "-sf -gpu" :doc:`command-line switch ` is used. If it is not used, you -must invoke the package gpu command in your input script or via the "-pk gpu" -:doc:`command-line switch `. +For the GPU package, the default parameters and settings are: -For the INTEL package, the default is Nphi = 1 and the option defaults are omp -= 0, mode = mixed, lrt = no, balance = -1, tpc = 4, tptask = 240, pppm_table = -yes. The default ghost option is determined by the pair style being used. +.. parsed-literal:: + + Ngpu = 0, neigh = yes, newton = off, binsize = 0.0, split = 1.0, gpuID = 0 to Ngpu-1, tpa = 1, omp = 0, platform=-1. + +These settings are made automatically if the "-sf gpu" +:doc:`command-line switch ` is used. If it is not used, +you must invoke the package gpu command in your input script or via the +"-pk gpu" :doc:`command-line switch `. + +For the INTEL package, the default parameters and settings are: + +.. parsed-literal:: + + Nphi = 1, omp = 0, mode = mixed, lrt = no, balance = -1, tpc = 4, tptask = 240, pppm_table = yes + +The default ghost option is determined by the pair style being used. This value is output to the screen in the offload report at the end of each run. Note that all of these settings, except "omp" and "mode", are ignored if LAMMPS was not built with Xeon Phi co-processor support. These settings are @@ -724,20 +740,35 @@ made automatically if the "-sf intel" :doc:`command-line switch ` is used. If it is not used, you must invoke the package intel command in your input script or via the "-pk intel" :doc:`command-line switch `. -For the KOKKOS package, the option defaults for GPUs are neigh = full, -neigh/qeq = full, newton = off, binsize for GPUs = 2x LAMMPS default value, -comm = device, sort = device, neigh/transpose = off, gpu/aware = on. When -LAMMPS can safely detect that GPU-aware MPI is not available, the default value -of gpu/aware becomes "off". For CPUs or Xeon Phis, the option defaults are -neigh = half, neigh/qeq = half, newton = on, binsize = 0.0, comm = no, and sort -= no. For GPUs, option neigh/thread = on when there are 16k atoms or less on an MPI -rank, otherwise it is "off". These settings are made automatically by the -required "-k on" :doc:`command-line switch `. You can change them -by using the package kokkos command in your input script or via the :doc:`-pk -kokkos command-line switch `. +For the KOKKOS package when using GPUs, the option defaults are: -For the OMP package, the default is Nthreads = 0 and the option defaults are -neigh = yes. These settings are made automatically if the "-sf omp" -:doc:`command-line switch ` is used. If it is not used, you must -invoke the package omp command in your input script or via the "-pk omp" -:doc:`command-line switch `. +.. parsed-literal:: + + neigh = full, neigh/qeq = full, newton = off, binsize = 2x LAMMPS default value, comm = device, sort = device, atom/map = device, neigh/transpose = off, gpu/aware = on + +For GPUs, option neigh/thread = on when there are 16k atoms or less on +an MPI rank, otherwise it is "off". When LAMMPS can safely detect that +GPU-aware MPI is not available, the default value of gpu/aware becomes +"off". + +For the KOKKOS package when using CPUs or Xeon Phis, the option defaults are: + +.. parsed-literal:: + + neigh = half, neigh/qeq = half, newton = on, binsize = 0.0, comm = no, sort = no, atom/map = no + +These settings are made automatically by +the required "-k on" :doc:`command-line switch `. You can +change them by using the package kokkos command in your input script or +via the :doc:`-pk kokkos command-line switch `. + +For the OMP package, the defaults are + +.. parsed-literal:: + + Nthreads = 0, neigh = yes + +These settings are made automatically if the "-sf omp" +:doc:`command-line switch ` is used. If it is not used, +you must invoke the package omp command in your input script or via the +"-pk omp" :doc:`command-line switch `. diff --git a/doc/src/pair_airebo.rst b/doc/src/pair_airebo.rst index 9a1e4e5518..ce574cc734 100644 --- a/doc/src/pair_airebo.rst +++ b/doc/src/pair_airebo.rst @@ -156,7 +156,7 @@ pair_coeff command: The first 2 arguments must be \* \* so as to span all LAMMPS atom types. The first three C arguments map LAMMPS atom types 1,2,3 to the C element in the AIREBO file. The final H argument maps LAMMPS atom -type 4 to the H element in the SW file. If a mapping value is +type 4 to the H element in the AIREBO file. If a mapping value is specified as NULL, the mapping is not performed. This can be used when a *airebo* potential is used as part of the *hybrid* pair style. The NULL values are placeholders for atom types that will be used with @@ -222,12 +222,12 @@ enabled if LAMMPS was built with that package. See the :doc:`Build package ` setting to be "on" for pair interactions. -The CH.airebo and CH.airebo-m potential files provided with LAMMPS -(see the potentials directory) are parameterized for metal :doc:`units `. -You can use the AIREBO, AIREBO-M or REBO potential with any LAMMPS units, -but you would need to create your own AIREBO or AIREBO-M potential file -with coefficients listed in the appropriate units, if your simulation -does not use "metal" units. +The CH.airebo and CH.airebo-m potential files provided with LAMMPS (see +the potentials directory) are parameterized for metal :doc:`units +`. You can use the pair styles with *any* LAMMPS units, but you +would need to create your own AIREBO or AIREBO-M potential file with +coefficients listed in the appropriate units, if your simulation does +not use "metal" units. The pair styles provided here **only** support potential files parameterized for the elements carbon and hydrogen (designated with "C" and "H" in the diff --git a/doc/src/pair_charmm.rst b/doc/src/pair_charmm.rst index 8ff6508dea..30b03ad872 100644 --- a/doc/src/pair_charmm.rst +++ b/doc/src/pair_charmm.rst @@ -16,6 +16,7 @@ .. index:: pair_style lj/charmm/coul/msm/omp .. index:: pair_style lj/charmmfsw/coul/charmmfsh .. index:: pair_style lj/charmmfsw/coul/long +.. index:: pair_style lj/charmmfsw/coul/long/kk pair_style lj/charmm/coul/charmm command ======================================== @@ -43,6 +44,8 @@ pair_style lj/charmmfsw/coul/charmmfsh command pair_style lj/charmmfsw/coul/long command ========================================= +Accelerator Variants: *lj/charmmfsw/coul/long/kk* + Syntax """""" @@ -281,7 +284,9 @@ page for more info. Related commands """""""""""""""" -:doc:`pair_coeff ` +:doc:`pair_coeff `, :doc:`angle_style charmm `, +:doc:`dihedral_style charmm `, +:doc:`dihedral_style charmmfsw `, :doc:`fix cmap ` Default """"""" diff --git a/doc/src/pair_dsmc.rst b/doc/src/pair_dsmc.rst index edac1d7a65..09bb5d90af 100644 --- a/doc/src/pair_dsmc.rst +++ b/doc/src/pair_dsmc.rst @@ -138,8 +138,12 @@ This pair style can only be used via the *pair* keyword of the Restrictions """""""""""" -This style is part of the MC package. It is only enabled if LAMMPS -was built with that package. See the :doc:`Build package ` page for more info. +This pair style is part of the MC package. It is only enabled if LAMMPS +was built with that package. See the :doc:`Build package +` page for more info. + +This pair style requires an :doc:`atom style ` with per +atom type masses. Related commands """""""""""""""" diff --git a/doc/src/pair_lepton.rst b/doc/src/pair_lepton.rst index 21e619a3d9..5b5dc698e7 100644 --- a/doc/src/pair_lepton.rst +++ b/doc/src/pair_lepton.rst @@ -72,7 +72,7 @@ interactions between particles which depend on the distance and have a cutoff. The potential function must be provided as an expression string using "r" as the distance variable. With pair style *lepton/coul* one may additionally reference the charges of the two atoms of the pair with -"qi" and "qj", respectively. With pair style *lepton/coul* one may +"qi" and "qj", respectively. With pair style *lepton/sphere* one may instead reference the radii of the two atoms of the pair with "radi" and "radj", respectively; this is half of the diameter that can be set in :doc:`data files ` or the :doc:`set command `. @@ -166,8 +166,8 @@ mixing. Thus, expressions for *all* I,J pairs must be specified explicitly. Only pair style *lepton* supports the :doc:`pair_modify shift ` -option for shifting the energy of the pair interaction so that it is -0 at the cutoff, pair styles *lepton/coul* and *lepton/sphere* do *not*. +option for shifting the potential energy of the pair interaction so that +it is 0 at the cutoff, pair styles *lepton/coul* and *lepton/sphere* do *not*. The :doc:`pair_modify table ` options are not relevant for the these pair styles. diff --git a/doc/src/pair_meam.rst b/doc/src/pair_meam.rst index 57c40aa6ee..bafa9fb3c9 100644 --- a/doc/src/pair_meam.rst +++ b/doc/src/pair_meam.rst @@ -427,8 +427,8 @@ package. They are only enabled if LAMMPS was built with that package. See the :doc:`Build package ` page for more info. The maximum number of elements, that can be read from the MEAM library -file, is determined at compile time. The default is 5. If you need -support for more elements, you have to change the the constant 'maxelt' +file, is determined at compile time. The default is 8. If you need +support for more elements, you have to change the the constant 'MAXELT' at the beginning of the file ``src/MEAM/meam.h`` and update/recompile LAMMPS. There is no limit on the number of atoms types. diff --git a/doc/src/pair_rebomos.rst b/doc/src/pair_rebomos.rst new file mode 100644 index 0000000000..9f4b8006c1 --- /dev/null +++ b/doc/src/pair_rebomos.rst @@ -0,0 +1,150 @@ +.. index:: pair_style rebomos +.. index:: pair_style rebomos/omp + +pair_style rebomos command +========================== + +Accelerator Variants: *rebomos/omp* + +Syntax +"""""" + +.. code-block:: LAMMPS + + pair_style rebomos + +* rebomos = name of this pair style + +Examples +"""""""" + +.. code-block:: LAMMPS + + pair_style rebomos + pair_coeff * * ../potentials/MoS.rebomos Mo S + +Example input scripts available: examples/threebody/ + +Description +""""""""""" + +.. versionadded:: TBD + +The *rebomos* pair style computes the interactions between molybdenum +and sulfur atoms :ref:`(Stewart) ` utilizing an adaptive +interatomic reactive empirical bond order potential that is similar in +form to the AIREBO potential :ref:`(Stuart) `. The potential +is based on an earlier parameterizations for :math:`\text{MoS}_2` +developed by :ref:`(Liang) `. + +The REBOMoS potential consists of two terms: + +.. math:: + + E & = \frac{1}{2} \sum_i \sum_{j \neq i} + \left[ E^{\text{REBO}}_{ij} + E^{\text{LJ}}_{ij} \right] \\ + +The :math:`E^{\text{REBO}}` term describes the covalently bonded +interactions between Mo and S atoms while the :math:`E^{\text{LJ}}` term +describes longer range dispersion forces between layers. A cubic spline +function is applied to smoothly switch between covalent bonding at short +distances to dispersion interactions at longer distances. This allows +the model to capture bond formation and breaking events which may occur +between adjacent MoS2 layers, edges, defects, and more. + +---------- + +Only a single pair_coeff command is used with the *rebomos* pair style +which specifies an REBOMoS potential file with parameters for Mo and S. +These are mapped to LAMMPS atom types by specifying N additional +arguments after the filename in the pair_coeff command, where N is the +number of LAMMPS atom types: + +* filename +* :math:`N` element names = mapping of REBOMoS elements to atom types + +See the :doc:`pair_coeff ` page for alternate ways +to specify the path for the potential file. + +As an example, if your LAMMPS simulation has three atom types and you want +the first two to be Mo, and the third to be S, you would use the following +pair_coeff command: + +.. code-block:: LAMMPS + + pair_coeff * * MoS.rebomos Mo Mo S + +The first 2 arguments must be \* \* so as to span all LAMMPS atom types. +The first two Mo arguments map LAMMPS atom types 1 and 2 to the Mo +element in the REBOMoS file. The final S argument maps LAMMPS atom type +3 to the S element in the REBOMoS file. If a mapping value is specified +as NULL, the mapping is not performed. This can be used when a +*rebomos* potential is used as part of the *hybrid* pair style. The +NULL values are placeholders for atom types that will be used with other +potentials. + +---------- + +.. include:: accel_styles.rst + +---------- + +Mixing, shift, table, tail correction, restart, rRESPA info +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +This pair style does not support the :doc:`pair_modify ` +mix, shift, table, and tail options. + +This pair style does not write their information to :doc:`binary restart +files `, since it is stored in potential files. Thus, you need +to re-specify the pair_style and pair_coeff commands in an input script +that reads a restart file. + +This pair styles can only be used via the *pair* keyword of the +:doc:`run_style respa ` command. It does not support the +*inner*, *middle*, *outer* keywords. + +Restrictions +"""""""""""" + +This pair style is part of the MANYBODY package. It is only enabled if +LAMMPS was built with that package. See the :doc:`Build package +` page for more info. + +These pair potentials require the :doc:`newton ` setting to be +"on" for pair interactions. + +The MoS.rebomos potential file provided with LAMMPS (see the potentials +directory) is parameterized for metal :doc:`units `. You can use +the *rebomos* pair style with any LAMMPS units setting, but you would +need to create your own REBOMoS potential file with coefficients listed +in the appropriate units. + +The pair style provided here **only** supports potential files parameterized +for the elements molybdenum and sulfur (designated with "Mo" and "S" in the +*pair_coeff* command. Using potential files for other elements will trigger +an error. + +Related commands +"""""""""""""""" + +:doc:`pair_coeff `, :doc:`pair style rebo ` + +Default +""""""" + +none + +---------- + +.. _Stewart: + +**(Steward)** Stewart, Spearot, Modelling Simul. Mater. Sci. Eng. 21, 045003, (2013). + +.. _Stuart2: + +**(Stuart)** Stuart, Tutein, Harrison, J Chem Phys, 112, 6472-6486, (2000). + +.. _Liang: + +**(Liang)** Liang, Phillpot, Sinnott Phys. Rev. B79 245110, (2009), Erratum: Phys. Rev. B85 199903(E), (2012) diff --git a/doc/src/pair_style.rst b/doc/src/pair_style.rst index a2467bff2b..53bf269e1c 100644 --- a/doc/src/pair_style.rst +++ b/doc/src/pair_style.rst @@ -333,6 +333,7 @@ accelerated styles exist. * :doc:`rann ` - * :doc:`reaxff ` - ReaxFF potential * :doc:`rebo ` - second generation REBO potential of Brenner +* :doc:`rebomos ` - REBOMoS potential for MoS2 * :doc:`resquared ` - Everaers RE-Squared ellipsoidal potential * :doc:`saip/metal ` - interlayer potential for hetero-junctions formed with hexagonal 2D materials and metal surfaces * :doc:`sdpd/taitwater/isothermal ` - smoothed dissipative particle dynamics for water at isothermal conditions diff --git a/doc/src/processors.rst b/doc/src/processors.rst index 921bbcc667..a11febb1c2 100644 --- a/doc/src/processors.rst +++ b/doc/src/processors.rst @@ -25,6 +25,8 @@ Syntax *numa* params = none *custom* params = infile infile = file containing grid layout + *numa_nodes* arg = Nn + Nn = number of numa domains per node *map* arg = *cart* or *cart/reorder* or *xyz* or *xzy* or *yxz* or *yzx* or *zxy* or *zyx* cart = use MPI_Cart() methods to map processors to 3d grid with reorder = 0 cart/reorder = use MPI_Cart() methods to map processors to 3d grid with reorder = 1 @@ -159,24 +161,28 @@ surface-to-volume ratio of each processor's subdomain. The *numa* style operates similar to the *twolevel* keyword except that it auto-detects which cores are running on which nodes. -Currently, it does this in only 2 levels, but it may be extended in -the future to account for socket topology and other non-uniform memory -access (NUMA) costs. It also uses a different algorithm than the -*twolevel* keyword for doing the two-level factorization of the -simulation box into a 3d processor grid to minimize off-node -communication, and it does its own MPI-based mapping of nodes and +It will also subdivide the cores into numa domains. Currently, the +number of numa domains is not autodetected and must be specified using +the *numa_nodes* keyword; otherwise, the default value is used. The +*numa* style uses a different algorithm than the *twolevel* keyword for +doing the two-level factorization of the simulation box into a 3d +processor grid to minimize off-node communication and communication +across numa domains. It does its own MPI-based mapping of nodes and cores to the regular 3d grid. Thus it may produce a different layout of the processors than the *twolevel* options. The *numa* style will give an error if the number of MPI processes is not divisible by the number of cores used per node, or any of the Px -or Py of Pz values is greater than 1. +or Py or Pz values is greater than 1. .. note:: Unlike the *twolevel* style, the *numa* style does not require - any particular ordering of MPI ranks i norder to work correctly. This + any particular ordering of MPI ranks in order to work correctly. This is because it auto-detects which processes are running on which nodes. + However, it assumes that the lowest ranks are in the first numa + domain, and so forth. MPI rank orderings that do not preserve this + property might result in more intranode communication between CPUs. The *custom* style uses the file *infile* to define both the 3d factorization and the mapping of processors to the grid. @@ -207,6 +213,14 @@ any order, but no processor ID should appear more than once. ---------- +The *numa_nodes* keyword is used to specifiy the number of numa domains +per node. It is currently only used by the *numa* style for two-level +factorization to reduce the amount of MPI communications between CPUs. +A good setting for this will typically be equal to the number of CPU +sockets per node. + +---------- + The *map* keyword affects how the P processor IDs (from 0 to P-1) are mapped to the 3d grid of processors. It is only used by the *onelevel* and *twolevel* grid settings. @@ -356,5 +370,5 @@ Related commands Default """"""" -The option defaults are Px Py Pz = \* \* \*, grid = onelevel, and map = -cart. +The option defaults are Px Py Pz = \* \* \*, grid = onelevel, map = +cart, and numa_nodes = 2. diff --git a/doc/src/variable.rst b/doc/src/variable.rst index a70ac25836..1cd96543f5 100644 --- a/doc/src/variable.rst +++ b/doc/src/variable.rst @@ -706,7 +706,7 @@ library. Ceil() is the smallest integer not less than its argument. Floor() if the largest integer not greater than its argument. Round() is the nearest integer to its argument. -.. versionadded:: TBD +.. versionadded:: 7Feb2024 The ternary(x,y,z) function is the equivalent of the ternary operator (? and :) in C or C++. It takes 3 arguments. The first argument is a @@ -1155,7 +1155,7 @@ variable by using the :doc:`compute property/atom Custom atom properties ---------------------- -.. versionadded:: TBD +.. versionadded:: 7Feb2024 Custom atom properties refer to per-atom integer and floating point vectors or arrays that have been added via the :doc:`fix property/atom diff --git a/doc/utils/sphinx-config/false_positives.txt b/doc/utils/sphinx-config/false_positives.txt index 55ac81e04b..030c80d30c 100644 --- a/doc/utils/sphinx-config/false_positives.txt +++ b/doc/utils/sphinx-config/false_positives.txt @@ -125,6 +125,7 @@ antisymmetry anton Antonelli api +apolar Apoorva Appl Appshaw @@ -799,6 +800,7 @@ dlabel dlambda DLAMMPS dll +dlm dlopen dm dmax @@ -1016,6 +1018,7 @@ Ercolessi Erdmann erf erfc +erforce Erhart erorate erose @@ -1767,6 +1770,7 @@ Kolafa Kollman kolmogorov Kolmogorov +Kolotinskii Kondor konglt Koning @@ -2236,8 +2240,10 @@ Mohd Mohles mol Mol +molatom molfile Molfile +molindex MolPairStyle moltemplate momb @@ -2261,6 +2267,7 @@ morris Morriss morse Morteza +MoS Mosayebi Moseler Moskalev @@ -2570,6 +2577,7 @@ ns Ns Nsample Nskip +nspecial Nspecies nsq Nstart @@ -2768,6 +2776,7 @@ PEigenDense Peng peptide peratom +Perf Pergamon pergrid peri @@ -3064,6 +3073,7 @@ reaxff ReaxFF REAXFF rebo +rebomos recurse recursing Ree @@ -3591,6 +3601,7 @@ tesselation tesselations Tetot tex +textrm tfac tfmc tfMC @@ -3791,6 +3802,7 @@ unimodal uninstall unitarg unitless +unittest Universite unix unmaintained @@ -3877,7 +3889,10 @@ Verlet versa Verstraelen ves +vf vflag +vflow +vfrac vhi vibrational Vij diff --git a/examples/ASPHERE/dimer/in.dimer b/examples/ASPHERE/dimer/in.dimer index 224db9937d..468ebffcdc 100644 --- a/examples/ASPHERE/dimer/in.dimer +++ b/examples/ASPHERE/dimer/in.dimer @@ -1,104 +1,104 @@ # SRD diffusion demo - dimer particles -units lj -atom_style sphere -atom_modify map array first big -dimension 2 +units lj +atom_style sphere +atom_modify map array first big +dimension 2 # read in clusters of rigid bodies -fix molprop all property/atom mol -read_data data.dimer fix molprop NULL Molecules +fix molprop all property/atom mol ghost yes +read_data data.dimer fix molprop NULL Molecules + +set type 1 mass 1.0 +group big type 1 +velocity big create 1.44 87287 loop geom -set type 1 mass 1.0 -group big type 1 -velocity big create 1.44 87287 loop geom - # equilibrate big particles -pair_style soft 1.12 -pair_coeff 1 1 0.0 -pair_coeff 2 2 0.0 0.0 -pair_coeff 1 2 0.0 0.0 +pair_style soft 1.12 +pair_coeff 1 1 0.0 +pair_coeff 2 2 0.0 0.0 +pair_coeff 1 2 0.0 0.0 variable prefactor equal ramp(0,60) fix soft all adapt 1 pair soft a * * v_prefactor -fix 1 big rigid molecule -fix 2 all enforce2d +fix 1 big rigid molecule +fix 2 all enforce2d -#dump 1 all atom 10 dump.dimer.equil +#dump 1 all atom 10 dump.dimer.equil -thermo 100 -run 1000 +thermo 100 +run 1000 -#undump 1 +#undump 1 unfix soft -unfix 1 -unfix 2 +unfix 1 +unfix 2 # add small particles as hi density lattice -region plane block INF INF INF INF -0.001 0.001 units box -lattice sq 85.0 -create_atoms 2 region plane +region plane block INF INF INF INF -0.001 0.001 units box +lattice sq 85.0 +create_atoms 2 region plane -set type 2 mass 0.1 -group small type 2 -velocity small create 1.0 593849 loop geom +set type 2 mass 0.1 +group small type 2 +velocity small create 1.0 593849 loop geom # delete overlaps # must set 1-2 cutoff to non-zero value -pair_style lj/cut 2.5 -pair_coeff 1 1 1.0 1.0 -pair_coeff 2 2 0.0 1.0 0.0 -pair_coeff 1 2 0.0 1.0 0.5 +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 +pair_coeff 2 2 0.0 1.0 0.0 +pair_coeff 1 2 0.0 1.0 0.5 -delete_atoms overlap 0.5 small big +delete_atoms overlap 0.5 small big # SRD run -reset_timestep 0 +reset_timestep 0 -neighbor 0.3 multi -neigh_modify delay 0 every 1 check yes +neighbor 0.3 multi +neigh_modify delay 0 every 1 check yes -comm_modify mode multi group big vel yes -neigh_modify include big +comm_modify mode multi group big vel yes +neigh_modify include big # no pairwise interactions with small particles -pair_style lj/cut 2.5 -pair_coeff 1 1 1.0 1.0 -pair_coeff 2 2 0.0 1.0 0.0 -pair_coeff 1 2 0.0 1.0 0.0 +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 +pair_coeff 2 2 0.0 1.0 0.0 +pair_coeff 1 2 0.0 1.0 0.0 # use fix SRD to push small particles out from inside big ones # if comment out, big particles won't see SRD particles -timestep 0.001 +timestep 0.001 -fix 1 big rigid molecule -fix 2 small srd 20 big 1.0 0.25 49894 shift yes 54979 & - search 0.2 collision slip inside ignore overlap yes -fix 3 all enforce2d +fix 1 big rigid molecule +fix 2 small srd 20 big 1.0 0.25 49894 shift yes 54979 & + search 0.2 collision slip inside ignore overlap yes +fix 3 all enforce2d # diagnostics -compute tbig big temp/sphere -variable pebig equal pe*atoms/count(big) -variable ebig equal etotal*atoms/count(big) -thermo_style custom step temp f_2[8] etotal v_pebig v_ebig press & - f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] & - f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] f_2[12] +compute tbig big temp/sphere +variable pebig equal pe*atoms/count(big) +variable ebig equal etotal*atoms/count(big) +thermo_style custom step temp f_2[8] etotal v_pebig v_ebig press & + f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] & + f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] f_2[12] -thermo_modify temp tbig -thermo 1000 +thermo_modify temp tbig +thermo 1000 -#dump 1 all atom 1000 dump.dimer +#dump 1 all atom 1000 dump.dimer -#dump 1 all image 1000 image.*.jpg type type zoom 1.6 -#dump_modify 1 pad 6 adiam 1 1 adiam 2 0.2 +#dump 1 all image 1000 image.*.jpg type type zoom 1.6 +#dump_modify 1 pad 6 adiam 1 1 adiam 2 0.2 -run 100000 +run 10000 diff --git a/examples/ASPHERE/dimer/in.dimer.mp b/examples/ASPHERE/dimer/in.dimer.mp index a637acaf87..1b54cc5eac 100644 --- a/examples/ASPHERE/dimer/in.dimer.mp +++ b/examples/ASPHERE/dimer/in.dimer.mp @@ -1,105 +1,105 @@ # SRD viscosity demo - dimer particles -units lj -atom_style sphere -atom_modify map array first big -dimension 2 +units lj +atom_style sphere +atom_modify map array first big +dimension 2 # read in clusters of rigid bodies -fix molprop all property/atom mol -read_data data.dimer fix molprop NULL Molecules +fix molprop all property/atom mol ghost yes +read_data data.dimer fix molprop NULL Molecules -set type 1 mass 1.0 -group big type 1 -velocity big create 1.44 87287 loop geom +set type 1 mass 1.0 +group big type 1 +velocity big create 1.44 87287 loop geom # equilibrate big particles -pair_style soft 1.12 -pair_coeff 1 1 0.0 -pair_coeff 2 2 0.0 0.0 -pair_coeff 1 2 0.0 0.0 +pair_style soft 1.12 +pair_coeff 1 1 0.0 +pair_coeff 2 2 0.0 0.0 +pair_coeff 1 2 0.0 0.0 variable prefactor equal ramp(0,60) fix soft all adapt 1 pair soft a * * v_prefactor -fix 1 big rigid molecule -fix 2 all enforce2d +fix 1 big rigid molecule +fix 2 all enforce2d -#dump 1 all atom 10 dump.dimer.equil +#dump 1 all atom 10 dump.dimer.equil -thermo 100 -run 1000 +thermo 100 +run 1000 -#undump 1 +#undump 1 unfix soft -unfix 1 -unfix 2 +unfix 1 +unfix 2 # add small particles as hi density lattice -region plane block INF INF INF INF -0.001 0.001 units box -lattice sq 85.0 -create_atoms 2 region plane +region plane block INF INF INF INF -0.001 0.001 units box +lattice sq 85.0 +create_atoms 2 region plane -set type 2 mass 0.1 -group small type 2 -velocity small create 1.0 593849 loop geom +set type 2 mass 0.1 +group small type 2 +velocity small create 1.0 593849 loop geom # delete overlaps # must set 1-2 cutoff to non-zero value -pair_style lj/cut 2.5 -pair_coeff 1 1 1.0 1.0 -pair_coeff 2 2 0.0 1.0 0.0 -pair_coeff 1 2 0.0 1.0 0.5 +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 +pair_coeff 2 2 0.0 1.0 0.0 +pair_coeff 1 2 0.0 1.0 0.5 -delete_atoms overlap 0.5 small big +delete_atoms overlap 0.5 small big # SRD run -reset_timestep 0 +reset_timestep 0 -neighbor 0.3 multi -neigh_modify delay 0 every 1 check yes +neighbor 0.3 multi +neigh_modify delay 0 every 1 check yes -comm_modify mode multi group big vel yes -neigh_modify include big +comm_modify mode multi group big vel yes +neigh_modify include big # no pairwise interactions with small particles -pair_style lj/cut 2.5 -pair_coeff 1 1 1.0 1.0 -pair_coeff 2 2 0.0 1.0 0.0 -pair_coeff 1 2 0.0 1.0 0.0 +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 +pair_coeff 2 2 0.0 1.0 0.0 +pair_coeff 1 2 0.0 1.0 0.0 # use fix SRD to push small particles out from inside big ones # if comment out, big particles won't see SRD particles -timestep 0.001 +timestep 0.001 -fix 1 big rigid molecule -fix 2 small srd 20 big 1.0 0.25 49894 shift yes 54979 & - search 0.2 collision slip inside ignore overlap yes -fix 3 small viscosity 10 x y 50 -fix 4 all enforce2d +fix 1 big rigid molecule +fix 2 small srd 20 big 1.0 0.25 49894 shift yes 54979 & + search 0.2 collision slip inside ignore overlap yes +fix 3 small viscosity 10 x y 50 +fix 4 all enforce2d # diagnostics -compute tbig big temp/sphere -variable pebig equal pe*atoms/count(big) -variable ebig equal etotal*atoms/count(big) -thermo_style custom step temp f_2[8] etotal v_pebig v_ebig press & - f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] & - f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] f_2[12] +compute tbig big temp/sphere +variable pebig equal pe*atoms/count(big) +variable ebig equal etotal*atoms/count(big) +thermo_style custom step temp f_2[8] etotal v_pebig v_ebig press & + f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] & + f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] f_2[12] -thermo_modify temp tbig -thermo 1000 +thermo_modify temp tbig +thermo 1000 -#dump 1 all atom 500 dump.dimer.mp +#dump 1 all atom 500 dump.dimer.mp -#dump 1 all image 500 image.*.jpg type type zoom 1.6 -#dump_modify 1 pad 6 adiam 1 1 adiam 2 0.2 +#dump 1 all image 500 image.*.jpg type type zoom 1.6 +#dump_modify 1 pad 6 adiam 1 1 adiam 2 0.2 -run 50000 +run 25000 diff --git a/examples/ASPHERE/dimer/log.1Feb14.dimer.g++.8 b/examples/ASPHERE/dimer/log.1Feb14.dimer.g++.8 deleted file mode 100644 index e6cf1630da..0000000000 --- a/examples/ASPHERE/dimer/log.1Feb14.dimer.g++.8 +++ /dev/null @@ -1,286 +0,0 @@ -LAMMPS (1 Feb 2014) -# SRD diffusion demo - dimer particles - -units lj -atom_style sphere -atom_modify map array first big -dimension 2 - -# read in clusters of rigid bodies - -fix molprop all property/atom mol -read_data data.dimer fix molprop NULL Molecules - orthogonal box = (-9.34165 -9.34165 -0.5) to (9.34165 9.34165 0.5) - 4 by 2 by 1 MPI processor grid - reading atoms ... - 200 atoms - -set type 1 mass 1.0 - 200 settings made for mass -group big type 1 -200 atoms in group big -velocity big create 1.44 87287 loop geom - -# equilibrate big particles - -pair_style soft 1.12 -pair_coeff 1 1 0.0 -pair_coeff 2 2 0.0 0.0 -pair_coeff 1 2 0.0 0.0 - -variable prefactor equal ramp(0,60) -fix soft all adapt 1 pair soft a * * v_prefactor - -fix 1 big rigid molecule -100 rigid bodies with 200 atoms -fix 2 all enforce2d - -#dump 1 all atom 10 dump.dimer.equil - -thermo 100 -run 1000 -Memory usage per processor = 3.1029 Mbytes -Step Temp E_pair E_mol TotEng Press - 0 3.4028231 0 0 0.83369167 -0.55065517 - 100 9.5167872 2.392105 0 4.7237178 2.8319556 - 200 13.564465 3.0352634 0 6.3585572 3.6388732 - 300 13.133051 4.3835112 0 7.6011086 4.060051 - 400 14.584346 5.5141254 0 9.0872901 4.4231056 - 500 15.331515 6.6554832 0 10.411704 4.847642 - 600 16.953755 7.4794317 0 11.633102 5.2020696 - 700 16.503256 8.8572339 0 12.900532 5.6694613 - 800 17.006131 9.877343 0 14.043845 5.5483363 - 900 17.305927 11.081594 0 15.321546 6.2908201 - 1000 18.122491 12.126462 0 16.566472 5.7536055 -Loop time of 0.185949 on 8 procs for 1000 steps with 200 atoms - -Pair time (%) = 0.00187448 (1.00806) -Neigh time (%) = 0.000561714 (0.30208) -Comm time (%) = 0.0652371 (35.0833) -Outpt time (%) = 0.00209856 (1.12857) -Other time (%) = 0.116177 (62.4779) - -Nlocal: 25 ave 30 max 20 min -Histogram: 1 0 1 1 0 0 3 1 0 1 -Nghost: 28.375 ave 36 max 22 min -Histogram: 1 0 1 2 1 0 2 0 0 1 -Neighs: 33.125 ave 45 max 22 min -Histogram: 1 0 2 1 0 1 1 0 1 1 - -Total # of neighbors = 265 -Ave neighs/atom = 1.325 -Neighbor list builds = 99 -Dangerous builds = 96 - -#undump 1 -unfix soft -unfix 1 -unfix 2 - -# add small particles as hi density lattice - -region plane block INF INF INF INF -0.001 0.001 units box -lattice sq 85.0 -Lattice spacing in x,y,z = 0.108465 0.108465 0.108465 -create_atoms 2 region plane -Created 29929 atoms - -set type 2 mass 0.1 - 29929 settings made for mass -group small type 2 -29929 atoms in group small -velocity small create 1.0 593849 loop geom - -# delete overlaps -# must set 1-2 cutoff to non-zero value - -pair_style lj/cut 2.5 -pair_coeff 1 1 1.0 1.0 -pair_coeff 2 2 0.0 1.0 0.0 -pair_coeff 1 2 0.0 1.0 0.5 - -delete_atoms overlap 0.5 small big -Deleted 12759 atoms, new total = 17370 - -# SRD run - -reset_timestep 0 - -neighbor 0.3 bin -neigh_modify delay 0 every 1 check yes - -communicate multi group big vel yes -neigh_modify include big - -# no pairwise interactions with small particles - -pair_style lj/cut 2.5 -pair_coeff 1 1 1.0 1.0 -pair_coeff 2 2 0.0 1.0 0.0 -pair_coeff 1 2 0.0 1.0 0.0 - -# use fix SRD to push small particles out from inside big ones -# if comment out, big particles won't see SRD particles - -timestep 0.001 - -fix 1 big rigid molecule -100 rigid bodies with 200 atoms -fix 2 small srd 20 big 1.0 0.25 49894 shift yes 54979 search 0.2 collision slip inside ignore overlap yes -fix 3 all enforce2d - -# diagnostics - -compute tbig big temp/sphere -variable pebig equal pe*atoms/count(big) -variable ebig equal etotal*atoms/count(big) -thermo_style custom step temp f_2[8] etotal v_pebig v_ebig press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] f_2[12] - -thermo_modify temp tbig -WARNING: Temperature for thermo pressure is not for group all (../thermo.cpp:439) -thermo 1000 - -#dump 1 all atom 1000 dump.dimer - -#dump 1 all image 1000 image.*.jpg type type zoom 1.6 -#dump_modify 1 pad 6 adiam 1 1 adiam 2 0.2 - -run 100000 -SRD info: - SRD/big particles = 17170 200 - big particle diameter max/min = 1 1 - SRD temperature & lamda = 1 0.0632456 - SRD max distance & max velocity = 0.252982 12.6491 - SRD grid counts: 75 75 1 - SRD grid size: request, actual (xyz) = 0.25, 0.249111 0.249111 1 - SRD per actual grid cell = 5.5499 - SRD viscosity = 0.235551 - big/SRD mass density ratio = 0.142367 - # of rescaled SRD velocities = 0 - ave/max small velocity = 4.20347 7.72323 - ave/max big velocity = 2.64047 6.60911 -Memory usage per processor = 7.0395 Mbytes -Step Temp 2[8] TotEng pebig ebig Press 2[1] 2[2] 2[3] 2[4] 2[5] 2[6] 2[7] 2[8] 2[9] 2[10] 2[11] 2[12] - 0 6.9744766 0 0.30175295 21.011259 26.207244 2.7219331 0 0 0 0 0 0 0 0 0 0 0 0 - 1000 1.1941672 3369 0.24718395 20.578272 21.467926 9.8944086 13658 56 56 2 664 40320 5625 3369 1.1358997 0 4 0 - 2000 1.3247909 3390 0.24717547 20.48022 21.467189 6.5341926 13389 48 48 3 1988 40320 5625 3390 1.1814916 0 144 0 - 3000 1.386904 3355 0.24769415 20.478993 21.512237 6.1207029 13507 45 45 0 2871 40320 5625 3355 1.1657697 0 144 0 - 4000 1.1567347 3376 0.24573733 20.48052 21.342287 3.5540965 13475 46 46 0 3731 40320 5625 3376 1.1485984 0 144 0 - 5000 1.2565155 3376 0.24620928 20.447172 21.383276 2.5808161 13267 55 55 0 4559 40320 5625 3376 1.1778096 0 144 0 - 6000 1.1489985 3375 0.24520477 20.440031 21.296035 7.8204262 13362 59 59 0 5354 40320 5625 3375 1.1530517 0 144 0 - 7000 1.1608248 3399 0.24587989 20.489854 21.354669 7.9622779 13333 59 59 2 6254 40320 5625 3399 1.1809325 0 144 0 - 8000 1.1749441 3374 0.24700359 20.576929 21.452262 6.7498405 13495 64 64 0 7134 40320 5625 3374 1.1445035 0 144 0 - 9000 1.1285085 3405 0.24536183 20.468936 21.309675 5.8959937 13333 60 60 0 8008 40320 5625 3405 1.162836 0 144 0 - 10000 1.1462675 3425 0.24564758 20.480523 21.334492 7.0047543 13487 45 45 0 8967 40320 5625 3425 1.1881074 0 144 0 - 11000 1.2854766 3388 0.246088 20.415062 21.372742 7.8508136 13491 60 60 1 9833 40320 5625 3388 1.1698514 0 144 0 - 12000 1.2926536 3360 0.24602616 20.404345 21.367372 7.9286141 13142 64 64 1 11029 40320 5625 3360 1.1658039 0 161 0 - 13000 1.2289767 3412 0.24595657 20.44574 21.361328 2.2809592 13162 56 56 1 12018 40320 5625 3412 1.1665531 0 161 0 - 14000 1.3518235 3380 0.24629055 20.383226 21.390334 8.0062608 13310 59 59 7 13146 40320 5625 3380 1.1733296 0 161 0 - 15000 1.2971143 3355 0.24671134 20.46053 21.42688 9.7871945 12967 60 60 3 14084 40320 5625 3355 1.1703643 0 161 0 - 16000 1.4160948 3384 0.2478594 20.471598 21.526589 7.3141215 13123 56 56 1 14929 40320 5625 3384 1.1666782 0 161 0 - 17000 1.3172038 3391 0.247377 20.503375 21.484692 6.1541908 12957 54 54 0 15778 40320 5625 3391 1.1639931 0 161 0 - 18000 0.98748293 3369 0.2443499 20.486114 21.221789 4.0981146 13355 50 50 1 17031 40320 5625 3369 1.2083414 0 192 0 - 19000 1.4619261 3367 0.24867817 20.508564 21.597699 11.68547 13519 58 58 0 18334 40320 5625 3367 1.1667505 0 192 0 - 20000 1.44087 3391 0.24747923 20.420123 21.493571 4.0409936 13594 67 67 0 19303 40320 5625 3391 1.1869387 0 192 0 - 21000 1.1155365 3377 0.24474418 20.424957 21.256032 8.4985692 13423 52 52 0 20245 40320 5625 3377 1.1726608 0 192 0 - 22000 1.2045785 3382 0.24466159 20.351448 21.248859 7.0518674 13271 62 62 0 21128 40320 5625 3382 1.1658557 0 192 0 - 23000 1.2634616 3378 0.24571326 20.398918 21.340197 6.8382109 13246 61 61 1 22067 40320 5625 3378 1.170196 0 192 0 - 24000 1.365723 3375 0.24749053 20.477089 21.494552 5.9584152 13017 46 46 1 23017 40320 5625 3375 1.1841192 0 192 0 - 25000 1.1421045 3367 0.24497142 20.4249 21.275768 10.381661 13049 66 66 1 23907 40320 5625 3367 1.1856767 0 192 0 - 26000 1.4008939 3340 0.24678624 20.389719 21.433385 7.3799658 12971 53 53 5 24850 40320 5625 3340 1.1713233 0 192 0 - 27000 1.1835022 3379 0.24522732 20.416284 21.297993 7.2251705 12717 46 46 1 25723 40320 5625 3379 1.1798333 0 192 0 - 28000 1.0496668 3398 0.24461816 20.463086 21.245087 6.5485338 13385 60 60 0 26990 40320 5625 3398 1.1765205 0 192 0 - 29000 1.1779927 3453 0.24501083 20.401586 21.27919 4.8540048 13157 77 77 2 28023 40320 5625 3453 1.1741595 0 192 0 - 30000 1.2277637 3375 0.24554215 20.410652 21.325336 10.087705 12939 72 72 1 28855 40320 5625 3375 1.1627414 0 192 0 - 31000 1.1575066 3397 0.24504213 20.419566 21.281909 6.4849648 12977 66 66 0 29745 40320 5625 3397 1.1575018 0 192 0 - 32000 1.1752733 3381 0.2451073 20.41199 21.287569 7.2784509 12971 48 48 0 30561 40320 5625 3381 1.1790395 0 192 0 - 33000 1.1743895 3370 0.24485514 20.390748 21.265669 9.084299 12810 64 64 0 31342 40320 5625 3370 1.1429061 0 192 0 - 34000 1.2975876 3377 0.24608262 20.405573 21.372276 10.624304 12610 60 60 1 32140 40320 5625 3377 1.1685718 0 192 0 - 35000 1.7701252 3356 0.2497356 20.370794 21.689537 7.107766 12983 45 45 8 33862 40320 5625 3356 1.1720964 0 242 0 - 36000 1.2711521 3393 0.24675748 20.483878 21.430887 8.7087273 13175 60 60 0 34920 40320 5625 3393 1.1796212 0 242 0 - 37000 1.1140649 3373 0.24450996 20.405711 21.23569 8.0025138 12964 50 50 1 35770 40320 5625 3373 1.1772234 0 242 0 - 38000 1.3128798 3379 0.24583813 20.372946 21.351041 5.0554655 12939 56 56 1 36679 40320 5625 3379 1.1702949 0 242 0 - 39000 1.2093703 3365 0.24536578 20.409037 21.310018 5.6243735 12873 62 62 3 37511 40320 5625 3365 1.1751064 0 242 0 - 40000 1.2095402 3365 0.24485106 20.364207 21.265315 3.9565189 12876 54 54 1 38503 40320 5625 3365 1.1637516 0 242 0 - 41000 1.1146238 3350 0.24476111 20.427107 21.257502 6.5033046 12656 53 53 0 39313 40320 5625 3350 1.1553197 0 242 0 - 42000 1.2302245 3370 0.24452048 20.320087 21.236604 10.7363 12676 52 52 1 40108 40320 5625 3370 1.1492163 0 242 0 - 43000 1.2749689 3404 0.24511103 20.338041 21.287893 9.18604 13057 72 72 1 41014 40320 5625 3404 1.1572511 0 242 0 - 44000 1.1989211 3385 0.24450633 20.342179 21.235375 7.6714085 13086 52 53 1 41840 40320 5625 3385 1.1530041 0 242 0 - 45000 1.6465972 3370 0.249994 20.485264 21.711979 7.4908607 12894 58 58 7 43545 40320 5625 3370 1.1978571 0 361 0 - 46000 1.3082316 3412 0.24665637 20.447473 21.422106 8.9900563 13136 53 53 4 44510 40320 5625 3412 1.1686573 0 361 0 - 47000 1.2163258 3355 0.24493724 20.366636 21.272799 6.9309438 13020 56 56 0 45414 40320 5625 3355 1.1620943 0 361 0 - 48000 1.349966 3362 0.24683156 20.431596 21.437321 8.8527164 13044 64 64 1 46260 40320 5625 3362 1.1683452 0 361 0 - 49000 1.3903769 3347 0.24726403 20.439051 21.474881 5.9250552 13103 58 59 2 49229 40320 5625 3347 1.1924538 0 578 0 - 50000 1.2737918 3349 0.24563843 20.384723 21.333698 7.2419874 12892 41 41 1 50225 40320 5625 3349 1.1803233 0 578 0 - 51000 1.2229799 3355 0.24504936 20.371417 21.282537 8.5556146 12912 63 63 0 51096 40320 5625 3355 1.1333843 0 578 0 - 52000 1.2326547 3386 0.24596384 20.443632 21.361959 6.1757404 12790 66 66 1 52114 40320 5625 3386 1.1685608 0 578 0 - 53000 1.3695441 3389 0.24696147 20.428294 21.448604 8.7464732 12997 60 60 1 53115 40320 5625 3389 1.1631228 0 578 0 - 54000 1.0711204 3400 0.24322154 20.325806 21.12379 8.7228921 13005 56 56 0 53913 40320 5625 3400 1.1250986 0 578 0 - 55000 1.3412565 3360 0.24617922 20.381429 21.380665 6.9489559 12960 46 46 0 55249 40320 5625 3360 1.176467 0 578 0 - 56000 1.3910761 3355 0.2467942 20.397725 21.434077 6.6762734 12966 65 65 2 56653 40320 5625 3355 1.1715559 0 578 0 - 57000 1.1177307 3388 0.24424738 20.380176 21.212885 5.5073089 13153 62 62 1 57550 40320 5625 3388 1.1576307 0 578 0 - 58000 1.3136279 3365 0.24661231 20.439627 21.418279 9.1390284 12799 52 52 1 58366 40320 5625 3365 1.159026 0 578 0 - 59000 1.2667621 3374 0.24556104 20.383238 21.326976 3.4246418 13127 54 54 1 59170 40320 5625 3374 1.1461442 0 578 0 - 60000 1.1903121 3326 0.24492127 20.384629 21.271412 6.9439977 13078 47 47 2 60105 40320 5625 3326 1.1665886 0 578 0 - 61000 1.209313 3362 0.2455341 20.423699 21.324637 9.1212002 13225 61 61 4 61358 40320 5625 3362 1.1725894 0 578 0 - 62000 1.1720074 3366 0.24476301 20.384522 21.257667 7.7592884 13187 53 54 2 62257 40320 5625 3366 1.1599665 0 578 0 - 63000 1.2155508 3386 0.24486685 20.361101 21.266686 5.7864126 13090 42 42 0 63137 40320 5625 3386 1.1724234 0 578 0 - 64000 1.1967326 3379 0.2451834 20.402613 21.294179 4.8815049 13033 48 48 4 64152 40320 5625 3379 1.1818756 0 578 0 - 65000 1.1732378 3386 0.24500733 20.404824 21.278887 11.381026 12998 59 59 0 65071 40320 5625 3386 1.1625543 0 578 0 - 66000 1.1960739 3385 0.24407516 20.306852 21.197927 12.17249 12994 61 61 0 65941 40320 5625 3385 1.1826516 0 578 0 - 67000 1.3468331 3366 0.24657491 20.41164 21.415031 7.8115623 12894 62 62 1 66788 40320 5625 3366 1.1750424 0 578 0 - 68000 1.0742924 3369 0.24347736 20.345661 21.146009 9.5240252 13065 68 68 2 67665 40320 5625 3369 1.1561575 0 578 0 - 69000 1.1411254 3380 0.2450544 20.432836 21.282975 8.0392218 13134 49 49 1 68471 40320 5625 3380 1.1405485 0 578 0 - 70000 1.1585312 3388 0.24435206 20.358871 21.221977 7.5303626 13113 59 59 0 69320 40320 5625 3388 1.1726416 0 578 0 - 71000 1.3418857 3382 0.24598802 20.364355 21.36406 9.2840877 13265 68 68 0 70522 40320 5625 3382 1.1696767 0 578 0 - 72000 1.1547857 3388 0.24328952 20.26938 21.129695 7.9643121 13270 50 50 1 71384 40320 5625 3388 1.1647353 0 578 0 - 73000 1.1114283 3385 0.24397276 20.36102 21.189034 13.168935 13110 62 62 0 72335 40320 5625 3385 1.1625358 0 578 0 - 74000 1.6120075 3370 0.25009739 20.520013 21.720959 12.065782 12902 51 51 9 73743 40320 5625 3370 1.1873738 0 578 0 - 75000 1.3271087 3353 0.24600453 20.376798 21.365493 7.5902315 13076 51 51 1 74746 40320 5625 3353 1.1706259 0 578 0 - 76000 1.1908626 3386 0.2451628 20.405197 21.292389 6.8084086 13124 58 58 1 75702 40320 5625 3386 1.1765809 0 578 0 - 77000 1.042536 3391 0.24320847 20.345966 21.122655 6.4883579 12846 57 57 0 76930 40320 5625 3391 1.1769829 0 578 0 - 78000 1.3791243 3355 0.24628683 20.362563 21.390011 9.2397346 12897 56 56 12 78068 40320 5625 3355 1.1905167 0 578 0 - 79000 1.2058397 3391 0.2453076 20.406614 21.304965 9.7949819 13020 51 51 1 79065 40320 5625 3391 1.1777257 0 578 0 - 80000 1.0634737 3383 0.24440921 20.434652 21.22694 7.5296946 12973 61 61 2 80029 40320 5625 3383 1.1648017 0 578 0 - 81000 1.3768966 3373 0.24730623 20.452758 21.478546 7.1508584 13297 56 56 1 81172 40320 5625 3373 1.1740603 0 578 0 - 82000 1.3348382 3375 0.24680945 20.440946 21.4354 9.3251946 12822 56 56 2 82447 40320 5625 3375 1.1573749 0 578 0 - 83000 1.2042501 3393 0.24484972 20.368032 21.265198 7.5283729 12990 51 51 0 83344 40320 5625 3393 1.1833162 0 578 0 - 84000 1.1985223 3405 0.24537841 20.418216 21.311115 7.848856 13189 60 60 0 84147 40320 5625 3405 1.173911 0 578 0 - 85000 1.1811593 3391 0.24418657 20.32764 21.207604 8.3169438 13303 51 51 0 85022 40320 5625 3391 1.1586027 0 578 0 - 86000 1.2595689 3385 0.24556774 20.389179 21.327558 8.3808674 12966 56 56 1 85962 40320 5625 3385 1.1617838 0 578 0 - 87000 1.1419322 3356 0.24399697 20.340397 21.191137 6.8911116 13166 63 63 0 86753 40320 5625 3356 1.1729274 0 578 0 - 88000 1.275219 3380 0.24586129 20.403015 21.353053 6.838563 12963 56 56 0 87729 40320 5625 3380 1.1511968 0 578 0 - 89000 1.2794858 3366 0.24507826 20.33183 21.285047 9.3370019 12889 64 64 1 88575 40320 5625 3366 1.1660311 0 578 0 - 90000 1.0549593 3402 0.24289618 20.309589 21.095533 4.9944605 13076 59 59 1 89560 40320 5625 3402 1.1744335 0 578 0 - 91000 1.214812 3402 0.24442304 20.323106 21.228141 7.5681019 13229 44 44 1 90440 40320 5625 3402 1.1696689 0 578 0 - 92000 1.2019714 3374 0.24469176 20.356011 21.25148 7.6728432 13331 64 64 2 91243 40320 5625 3374 1.1678246 0 578 0 - 93000 1.0964004 3364 0.24364709 20.343931 21.16075 5.9650235 13086 55 55 0 92088 40320 5625 3364 1.1570838 0 578 0 - 94000 1.1722133 3393 0.24332541 20.259513 21.132812 7.1743779 13206 66 66 0 92858 40320 5625 3393 1.154328 0 578 0 - 95000 1.2413711 3373 0.24549874 20.396744 21.321566 8.131371 12967 61 61 1 93789 40320 5625 3373 1.1635681 0 578 0 - 96000 1.1702409 3363 0.24528289 20.430989 21.302819 11.399295 12776 63 63 0 94571 40320 5625 3363 1.1367365 0 578 0 - 97000 1.0696537 3368 0.242673 20.279258 21.07615 8.537175 13054 55 55 0 95403 40320 5625 3368 1.1648141 0 578 0 - 98000 1.1635952 3369 0.24486659 20.399785 21.266664 8.6714443 12750 70 70 0 96296 40320 5625 3369 1.1686272 0 578 0 - 99000 1.1286255 3397 0.24343772 20.30174 21.142566 6.7153212 12810 44 45 1 97021 40320 5625 3397 1.137818 0 578 0 - 100000 1.2847818 3367 0.24509282 20.329149 21.286312 8.7486629 13260 64 64 0 97855 40320 5625 3367 1.1597138 0 578 0 -Loop time of 20.8136 on 8 procs for 100000 steps with 17370 atoms - -Pair time (%) = 0.322913 (1.55145) -Neigh time (%) = 1.11753 (5.36921) -Comm time (%) = 1.72335 (8.27991) -Outpt time (%) = 0.00594518 (0.0285638) -Other time (%) = 17.6439 (84.7709) - -Nlocal: 2171.25 ave 2428 max 1747 min -Histogram: 1 0 0 0 1 1 2 1 0 2 -Nghost: 61.25 ave 69 max 54 min -Histogram: 1 1 0 1 1 1 0 2 0 1 -Neighs: 175.625 ave 225 max 132 min -Histogram: 1 1 1 1 1 0 1 0 0 2 - -Total # of neighbors = 1405 -Ave neighs/atom = 0.0808866 -Neighbor list builds = 5156 -Dangerous builds = 1 - -Please see the log.cite file for references relevant to this simulation - diff --git a/examples/ASPHERE/dimer/log.1Feb14.dimer.mp.g++.8 b/examples/ASPHERE/dimer/log.1Feb14.dimer.mp.g++.8 deleted file mode 100644 index 78fce92b49..0000000000 --- a/examples/ASPHERE/dimer/log.1Feb14.dimer.mp.g++.8 +++ /dev/null @@ -1,237 +0,0 @@ -LAMMPS (1 Feb 2014) -# SRD viscosity demo - dimer particles - -units lj -atom_style sphere -atom_modify map array first big -dimension 2 - -# read in clusters of rigid bodies - -fix molprop all property/atom mol -read_data data.dimer fix molprop NULL Molecules - orthogonal box = (-9.34165 -9.34165 -0.5) to (9.34165 9.34165 0.5) - 4 by 2 by 1 MPI processor grid - reading atoms ... - 200 atoms - -set type 1 mass 1.0 - 200 settings made for mass -group big type 1 -200 atoms in group big -velocity big create 1.44 87287 loop geom - -# equilibrate big particles - -pair_style soft 1.12 -pair_coeff 1 1 0.0 -pair_coeff 2 2 0.0 0.0 -pair_coeff 1 2 0.0 0.0 - -variable prefactor equal ramp(0,60) -fix soft all adapt 1 pair soft a * * v_prefactor - -fix 1 big rigid molecule -100 rigid bodies with 200 atoms -fix 2 all enforce2d - -#dump 1 all atom 10 dump.dimer.equil - -thermo 100 -run 1000 -Memory usage per processor = 3.1029 Mbytes -Step Temp E_pair E_mol TotEng Press - 0 3.4028231 0 0 0.83369167 -0.55065517 - 100 9.5167872 2.392105 0 4.7237178 2.8319556 - 200 13.564465 3.0352634 0 6.3585572 3.6388732 - 300 13.133051 4.3835112 0 7.6011086 4.060051 - 400 14.584346 5.5141254 0 9.0872901 4.4231056 - 500 15.331515 6.6554832 0 10.411704 4.847642 - 600 16.953755 7.4794317 0 11.633102 5.2020696 - 700 16.503256 8.8572339 0 12.900532 5.6694613 - 800 17.006131 9.877343 0 14.043845 5.5483363 - 900 17.305927 11.081594 0 15.321546 6.2908201 - 1000 18.122491 12.126462 0 16.566472 5.7536055 -Loop time of 0.0603173 on 8 procs for 1000 steps with 200 atoms - -Pair time (%) = 0.00182396 (3.02395) -Neigh time (%) = 0.000557959 (0.92504) -Comm time (%) = 0.0127766 (21.1823) -Outpt time (%) = 0.000280827 (0.465583) -Other time (%) = 0.0448779 (74.4031) - -Nlocal: 25 ave 30 max 20 min -Histogram: 1 0 1 1 0 0 3 1 0 1 -Nghost: 28.375 ave 36 max 22 min -Histogram: 1 0 1 2 1 0 2 0 0 1 -Neighs: 33.125 ave 45 max 22 min -Histogram: 1 0 2 1 0 1 1 0 1 1 - -Total # of neighbors = 265 -Ave neighs/atom = 1.325 -Neighbor list builds = 99 -Dangerous builds = 96 - -#undump 1 -unfix soft -unfix 1 -unfix 2 - -# add small particles as hi density lattice - -region plane block INF INF INF INF -0.001 0.001 units box -lattice sq 85.0 -Lattice spacing in x,y,z = 0.108465 0.108465 0.108465 -create_atoms 2 region plane -Created 29929 atoms - -set type 2 mass 0.1 - 29929 settings made for mass -group small type 2 -29929 atoms in group small -velocity small create 1.0 593849 loop geom - -# delete overlaps -# must set 1-2 cutoff to non-zero value - -pair_style lj/cut 2.5 -pair_coeff 1 1 1.0 1.0 -pair_coeff 2 2 0.0 1.0 0.0 -pair_coeff 1 2 0.0 1.0 0.5 - -delete_atoms overlap 0.5 small big -Deleted 12759 atoms, new total = 17370 - -# SRD run - -reset_timestep 0 - -neighbor 0.3 bin -neigh_modify delay 0 every 1 check yes - -communicate multi group big vel yes -neigh_modify include big - -# no pairwise interactions with small particles - -pair_style lj/cut 2.5 -pair_coeff 1 1 1.0 1.0 -pair_coeff 2 2 0.0 1.0 0.0 -pair_coeff 1 2 0.0 1.0 0.0 - -# use fix SRD to push small particles out from inside big ones -# if comment out, big particles won't see SRD particles - -timestep 0.001 - -fix 1 big rigid molecule -100 rigid bodies with 200 atoms -fix 2 small srd 20 big 1.0 0.25 49894 shift yes 54979 search 0.2 collision slip inside ignore overlap yes -fix 3 small viscosity 10 x y 50 -fix 4 all enforce2d - -# diagnostics - -compute tbig big temp/sphere -variable pebig equal pe*atoms/count(big) -variable ebig equal etotal*atoms/count(big) -thermo_style custom step temp f_2[8] etotal v_pebig v_ebig press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] f_2[12] - -thermo_modify temp tbig -WARNING: Temperature for thermo pressure is not for group all (../thermo.cpp:439) -thermo 1000 - -#dump 1 all atom 500 dump.dimer.mp - -#dump 1 all image 500 image.*.jpg type type zoom 1.6 -#dump_modify 1 pad 6 adiam 1 1 adiam 2 0.2 - -run 50000 -SRD info: - SRD/big particles = 17170 200 - big particle diameter max/min = 1 1 - SRD temperature & lamda = 1 0.0632456 - SRD max distance & max velocity = 0.252982 12.6491 - SRD grid counts: 75 75 1 - SRD grid size: request, actual (xyz) = 0.25, 0.249111 0.249111 1 - SRD per actual grid cell = 5.5499 - SRD viscosity = 0.235551 - big/SRD mass density ratio = 0.142367 - # of rescaled SRD velocities = 0 - ave/max small velocity = 4.20347 7.72323 - ave/max big velocity = 2.64047 6.60911 -Memory usage per processor = 7.0395 Mbytes -Step Temp 2[8] TotEng pebig ebig Press 2[1] 2[2] 2[3] 2[4] 2[5] 2[6] 2[7] 2[8] 2[9] 2[10] 2[11] 2[12] - 0 6.9744766 0 0.30175295 21.011259 26.207244 2.7219331 0 0 0 0 0 0 0 0 0 0 0 0 - 1000 1.906187 3319 0.25279446 20.53509 21.955199 9.3471734 14560 77 77 9 6051 40320 5625 3319 1.2073941 0 1062 0 - 2000 1.6009081 3420 0.25060769 20.572601 21.765278 12.835365 13521 63 63 1 7515 40320 5625 3420 1.1621445 0 1062 0 - 3000 1.8288965 3342 0.25195284 20.519576 21.882104 7.1720562 13550 62 62 1 8561 40320 5625 3342 1.1411375 0 1062 0 - 4000 1.8940522 3383 0.25185767 20.462769 21.873838 7.3011842 13210 55 55 0 9536 40320 5625 3383 1.1541274 0 1062 0 - 5000 1.7848964 3377 0.25063675 20.438054 21.767801 5.7235852 13258 60 60 1 10628 40320 5625 3377 1.1401366 0 1062 0 - 6000 2.0436442 3393 0.2528503 20.437534 21.960048 4.3266887 13369 65 65 1 11693 40320 5625 3393 1.1363335 0 1062 0 - 7000 2.0248598 3377 0.25304247 20.468218 21.976738 9.1535003 13126 69 69 2 12819 40320 5625 3377 1.1556137 0 1062 0 - 8000 1.9627172 3397 0.25201977 20.425693 21.887917 7.9563872 13216 58 58 3 14113 40320 5625 3397 1.144738 0 1062 0 - 9000 2.4805409 3385 0.25688024 20.462046 22.310049 6.0178529 13031 42 42 1 15329 40320 5625 3385 1.1667813 0 1062 0 - 10000 2.534712 3377 0.25802283 20.520922 22.409283 5.8494568 12804 49 50 1 16835 40320 5625 3377 1.1559636 0 1062 0 - 11000 2.4295377 3368 0.25671703 20.485869 22.295874 7.0797587 13097 56 56 2 18180 40320 5625 3368 1.1634145 0 1062 0 - 12000 2.5699389 3377 0.25784825 20.479516 22.39412 10.440503 13263 63 63 5 19848 40320 5625 3377 1.1714081 0 1062 0 - 13000 2.5416625 3359 0.25893582 20.595038 22.488576 6.823793 12926 57 57 1 21307 40320 5625 3359 1.1478982 0 1062 0 - 14000 2.9400702 3353 0.26140738 20.512878 22.703231 10.592709 12848 67 67 0 22782 40320 5625 3353 1.1642018 0 1062 0 - 15000 2.7315042 3364 0.26050572 20.589951 22.624922 7.6633608 12640 49 49 0 24273 40320 5625 3364 1.1532394 0 1062 0 - 16000 2.7176527 3389 0.25840703 20.418 22.442651 8.0150175 13019 59 59 1 25970 40320 5625 3389 1.1555937 0 1062 0 - 17000 2.883266 3355 0.26040537 20.468173 22.616206 6.053208 12916 54 54 1 27532 40320 5625 3355 1.1363169 0 1062 0 - 18000 2.8072496 3369 0.26013039 20.500924 22.592325 5.7179969 12989 45 45 0 29011 40320 5625 3369 1.1341799 0 1062 0 - 19000 2.8007066 3372 0.2602809 20.51887 22.605396 8.9063895 12817 59 59 1 30504 40320 5625 3372 1.1253001 0 1062 0 - 20000 3.0147455 3352 0.26233709 20.537991 22.783977 10.01786 13099 63 63 2 32100 40320 5625 3352 1.1263738 0 1062 0 - 21000 2.5502874 3354 0.25762968 20.475174 22.375138 7.4525361 12917 55 55 3 33904 40320 5625 3354 1.1432482 0 1062 0 - 22000 2.5643661 3357 0.25754499 20.45733 22.367782 9.5567227 12893 58 58 0 35500 40320 5625 3357 1.1309581 0 1062 0 - 23000 2.8451307 3387 0.26090715 20.540164 22.659786 7.8308779 12735 65 65 2 37080 40320 5625 3387 1.1666359 0 1062 0 - 24000 2.6241046 3341 0.25916876 20.553849 22.508807 9.7905794 12815 54 54 1 38864 40320 5625 3341 1.1422596 0 1062 0 - 25000 2.6054468 3374 0.25897446 20.550874 22.491932 9.4099539 13094 59 59 4 40505 40320 5625 3374 1.1887482 0 1062 0 - 26000 3.1370949 3356 0.26301193 20.50545 22.842586 9.930938 12785 59 59 0 42126 40320 5625 3356 1.1539158 0 1062 0 - 27000 2.757373 3361 0.26029623 20.552484 22.606727 7.4336931 12687 59 59 2 43728 40320 5625 3361 1.1408006 0 1062 0 - 28000 2.9939441 3393 0.26250984 20.568491 22.79898 9.201853 12802 66 66 0 45174 40320 5625 3393 1.1429688 0 1062 0 - 29000 3.1611971 3376 0.26252235 20.444974 22.800066 8.2146139 13042 48 48 0 46696 40320 5625 3376 1.1370708 0 1062 0 - 30000 2.2624796 3374 0.25475303 20.439753 22.125301 9.3304907 13249 53 53 1 48164 40320 5625 3374 1.1062325 0 1062 0 - 31000 2.6864602 3393 0.2607928 20.648442 22.649855 7.6108593 13028 58 58 0 49556 40320 5625 3393 1.1154125 0 1062 0 - 32000 2.8404087 3377 0.26037369 20.497351 22.613455 6.9017135 13055 63 63 1 51004 40320 5625 3377 1.1320087 0 1062 0 - 33000 2.8467378 3365 0.26095982 20.543541 22.664361 7.194747 13306 58 58 0 52481 40320 5625 3365 1.1312548 0 1062 0 - 34000 3.0833296 3382 0.26259198 20.509033 22.806114 7.44833 12988 59 60 1 54049 40320 5625 3382 1.1447344 0 1062 0 - 35000 3.1068536 3382 0.26441995 20.650266 22.964872 9.3804156 13139 54 54 0 55749 40320 5625 3382 1.1272861 0 1062 0 - 36000 2.6998442 3369 0.25864735 20.452138 22.463522 6.3327985 13317 52 52 0 57348 40320 5625 3369 1.1312386 0 1062 0 - 37000 2.600171 3376 0.25882039 20.541424 22.478551 9.3909788 12841 57 57 0 58880 40320 5625 3376 1.1319429 0 1062 0 - 38000 2.3962821 3367 0.25728672 20.560122 22.345352 7.4364329 13039 66 66 0 60627 40320 5625 3367 1.1468141 0 1062 0 - 39000 2.8548804 3422 0.26044489 20.492753 22.619638 6.0832552 13249 50 50 0 62327 40320 5625 3422 1.1442726 0 1062 0 - 40000 2.7721124 3375 0.25927374 20.452701 22.517924 10.368128 13197 55 55 1 63903 40320 5625 3375 1.140807 0 1062 0 - 41000 3.0463159 3378 0.26123216 20.418508 22.688013 10.179554 13030 64 64 0 65629 40320 5625 3378 1.1277894 0 1062 0 - 42000 2.9625288 3388 0.26205988 20.552817 22.759901 8.8326646 12958 64 64 0 67242 40320 5625 3388 1.159201 0 1062 0 - 43000 2.7524867 3347 0.2592403 20.464417 22.51502 10.30221 12815 65 65 2 68734 40320 5625 3347 1.1444123 0 1062 0 - 44000 2.8779981 3354 0.26009923 20.44551 22.589618 12.127509 12743 67 67 3 70309 40320 5625 3354 1.1467915 0 1062 0 - 45000 2.7833999 3365 0.25968205 20.479753 22.553386 8.6942365 12909 46 47 0 71846 40320 5625 3365 1.1480348 0 1062 0 - 46000 2.6564678 3370 0.25935897 20.546258 22.525327 9.2618375 12923 61 61 1 73491 40320 5625 3370 1.1528284 0 1062 0 - 47000 2.821625 3414 0.25999655 20.47859 22.5807 7.5359036 12861 55 55 2 75201 40320 5625 3414 1.1395745 0 1062 0 - 48000 2.9301623 3351 0.26139433 20.519127 22.702098 9.5177842 13037 49 49 2 76819 40320 5625 3351 1.1472505 0 1062 0 - 49000 2.528824 3390 0.25834586 20.553364 22.437338 8.953785 13127 49 49 0 78450 40320 5625 3390 1.1495903 0 1062 0 - 50000 3.0054471 3375 0.261046 20.432787 22.671845 7.9749959 13089 56 56 2 80717 40320 5625 3375 1.1574724 0 1062 0 -Loop time of 10.5055 on 8 procs for 50000 steps with 17370 atoms - -Pair time (%) = 0.156617 (1.49081) -Neigh time (%) = 0.556925 (5.30126) -Comm time (%) = 0.902042 (8.58637) -Outpt time (%) = 0.00305247 (0.0290559) -Other time (%) = 8.88688 (84.5925) - -Nlocal: 2171.25 ave 2567 max 1849 min -Histogram: 2 0 0 1 1 2 1 0 0 1 -Nghost: 62.625 ave 71 max 57 min -Histogram: 2 0 1 0 2 2 0 0 0 1 -Neighs: 168.25 ave 232 max 120 min -Histogram: 1 0 1 2 2 1 0 0 0 1 - -Total # of neighbors = 1346 -Ave neighs/atom = 0.0774899 -Neighbor list builds = 2599 -Dangerous builds = 17 - -Please see the log.cite file for references relevant to this simulation - diff --git a/examples/ASPHERE/dimer/log.1Feb24.dimer.g++.1 b/examples/ASPHERE/dimer/log.1Feb24.dimer.g++.1 new file mode 100644 index 0000000000..b74a5c42a9 --- /dev/null +++ b/examples/ASPHERE/dimer/log.1Feb24.dimer.g++.1 @@ -0,0 +1,312 @@ +LAMMPS (21 Nov 2023 - Development - patch_21Nov2023-665-g17f869bf5e) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# SRD diffusion demo - dimer particles + +units lj +atom_style sphere +atom_modify map array first big +dimension 2 + +# read in clusters of rigid bodies + +fix molprop all property/atom mol ghost yes +read_data data.dimer fix molprop NULL Molecules +Reading data file ... + orthogonal box = (-9.341652 -9.341652 -0.5) to (9.341652 9.341652 0.5) + 1 by 1 by 1 MPI processor grid + reading atoms ... + 200 atoms + read_data CPU = 0.001 seconds + +set type 1 mass 1.0 +Setting atom values ... + 200 settings made for mass +group big type 1 +200 atoms in group big +velocity big create 1.44 87287 loop geom + +# equilibrate big particles + +pair_style soft 1.12 +pair_coeff 1 1 0.0 +pair_coeff 2 2 0.0 0.0 +pair_coeff 1 2 0.0 0.0 + +variable prefactor equal ramp(0,60) +fix soft all adapt 1 pair soft a * * v_prefactor + +fix 1 big rigid molecule + 100 rigid bodies with 200 atoms +fix 2 all enforce2d + +#dump 1 all atom 10 dump.dimer.equil + +thermo 100 +run 1000 +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 1.42 + ghost atom cutoff = 1.42 + binsize = 0.71, bins = 27 27 2 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair soft, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/2d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 5.557 | 5.557 | 5.557 Mbytes + Step Temp E_pair E_mol TotEng Press + 0 3.4028231 0 0 0.83369167 -0.55065517 + 100 9.5167872 2.392105 0 4.7237178 2.8319556 + 200 13.564465 3.0352634 0 6.3585572 3.6388732 + 300 13.133051 4.3835112 0 7.6011086 4.060051 + 400 14.576837 5.5141059 0 9.0854309 4.422762 + 500 15.227825 6.6472106 0 10.378028 4.8598912 + 600 16.93219 7.454865 0 11.603251 5.2908894 + 700 16.573769 8.7323442 0 12.792918 5.3544684 + 800 17.482599 9.7221047 0 14.005341 5.6200973 + 900 18.548144 10.739353 0 15.283649 4.7817995 + 1000 18.068079 12.058417 0 16.485096 6.5773091 +Loop time of 0.0511113 on 1 procs for 1000 steps with 200 atoms + +Performance: 8452141.519 tau/day, 19565.142 timesteps/s, 3.913 Matom-step/s +99.6% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.0095507 | 0.0095507 | 0.0095507 | 0.0 | 18.69 +Neigh | 0.0042239 | 0.0042239 | 0.0042239 | 0.0 | 8.26 +Comm | 0.002203 | 0.002203 | 0.002203 | 0.0 | 4.31 +Output | 8.8531e-05 | 8.8531e-05 | 8.8531e-05 | 0.0 | 0.17 +Modify | 0.03336 | 0.03336 | 0.03336 | 0.0 | 65.27 +Other | | 0.001685 | | | 3.30 + +Nlocal: 200 ave 200 max 200 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 64 ave 64 max 64 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 275 ave 275 max 275 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 275 +Ave neighs/atom = 1.375 +Neighbor list builds = 193 +Dangerous builds = 0 + +#undump 1 +unfix soft +unfix 1 +unfix 2 + +# add small particles as hi density lattice + +region plane block INF INF INF INF -0.001 0.001 units box +lattice sq 85.0 +Lattice spacing in x,y,z = 0.10846523 0.10846523 0.10846523 +create_atoms 2 region plane +Created 29929 atoms + using lattice units in orthogonal box = (-9.341652 -9.341652 -0.5) to (9.341652 9.341652 0.5) + create_atoms CPU = 0.007 seconds + +set type 2 mass 0.1 +Setting atom values ... + 29929 settings made for mass +group small type 2 +29929 atoms in group small +velocity small create 1.0 593849 loop geom + +# delete overlaps +# must set 1-2 cutoff to non-zero value + +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 +pair_coeff 2 2 0.0 1.0 0.0 +pair_coeff 1 2 0.0 1.0 0.5 + +delete_atoms overlap 0.5 small big +System init for delete_atoms ... +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 2.8 + ghost atom cutoff = 2.8 + binsize = 1.4, bins = 14 14 1 + 2 neighbor lists, perpetual/occasional/extra = 1 1 0 + (1) command delete_atoms, occasional + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/2d + bin: standard + (2) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/2d + bin: standard +WARNING: Delete_atoms cutoff > minimum neighbor cutoff (src/delete_atoms.cpp:312) +Deleted 12776 atoms, new total = 17353 + +# SRD run + +reset_timestep 0 + +neighbor 0.3 multi +neigh_modify delay 0 every 1 check yes + +comm_modify mode multi group big vel yes +neigh_modify include big + +# no pairwise interactions with small particles + +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 +pair_coeff 2 2 0.0 1.0 0.0 +pair_coeff 1 2 0.0 1.0 0.0 + +# use fix SRD to push small particles out from inside big ones +# if comment out, big particles won't see SRD particles + +timestep 0.001 + +fix 1 big rigid molecule + 100 rigid bodies with 200 atoms +fix 2 small srd 20 big 1.0 0.25 49894 shift yes 54979 search 0.2 collision slip inside ignore overlap yes +fix 3 all enforce2d + +# diagnostics + +compute tbig big temp/sphere +variable pebig equal pe*atoms/count(big) +variable ebig equal etotal*atoms/count(big) +thermo_style custom step temp f_2[8] etotal v_pebig v_ebig press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] f_2[12] + +thermo_modify temp tbig +WARNING: Temperature for thermo pressure is not for group all (src/thermo.cpp:530) +thermo 1000 + +#dump 1 all atom 1000 dump.dimer + +#dump 1 all image 1000 image.*.jpg type type zoom 1.6 +#dump_modify 1 pad 6 adiam 1 1 adiam 2 0.2 + +run 10000 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- neighbor multi command: doi:10.1016/j.cpc.2008.03.005, doi:10.1007/s40571-020-00361-2 + +@Article{Intveld08, + author = {in 't Veld, P. J. and S. J.~Plimpton and G. S. Grest}, + title = {Accurate and Efficient Methods for Modeling Colloidal + Mixtures in an Explicit Solvent using Molecular Dynamics}, + journal = {Comput.\ Phys.\ Commut.}, + year = 2008, + volume = 179, + pages = {320--329} +} + +@article{Shire2020, + author = {Shire, Tom and Hanley, Kevin J. and Stratford, Kevin}, + title = {{DEM} Simulations of Polydisperse Media: Efficient Contact + Detection Applied to Investigate the Quasi-Static Limit}, + journal = {Computational Particle Mechanics}, + year = {2020} +@article{Monti2022, + author = {Monti, Joseph M. and Clemmer, Joel T. and Srivastava, + Ishan and Silbert, Leonardo E. and Grest, Gary S. + and Lechman, Jeremy B.}, + title = {Large-scale frictionless jamming with power-law particle + size distributions}, + journal = {Phys. Rev. E}, + volume = {106} + issue = {3} + year = {2022} +} + +- fix srd command: doi:10.1063/1.3419070 + +@Article{Petersen10, + author = {M. K. Petersen and J. B. Lechman and S. J. Plimpton and + G. S. Grest and in 't Veld, P. J. and P. R. Schunk}, + title = {Mesoscale Hydrodynamics via Stochastic Rotation + Dynamics: Comparison with {L}ennard-{J}ones Fluid}, + journal = {J.~Chem.\ Phys.}, + year = 2010, + volume = 132, + pages = 174106 +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +SRD info: + SRD/big particles = 17153 200 + big particle diameter max/min = 1 1 + SRD temperature & lamda = 1 0.063245553 + SRD max distance & max velocity = 0.25298221 12.649111 + SRD grid counts: 75 75 1 + SRD grid size: request, actual (xyz) = 0.25, 0.24911072 0.24911072 1 + SRD per actual grid cell = 5.544404 + SRD viscosity = 0.23553122 + big/SRD mass density ratio = 0.14250828 + # of rescaled SRD velocities = 0 + ave/max small velocity = 4.191188 7.6900178 + ave/max big velocity = 2.6813242 7.1846104 +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 2.8 + ghost atom cutoff = 2.8 + binsize = 18.683304, bins = 1 1 1 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/multi/atomonly/newton + stencil: half/multi/2d + bin: multi +Per MPI rank memory allocation (min/avg/max) = 26.77 | 26.77 | 26.77 Mbytes + Step Temp f_2[8] TotEng v_pebig v_ebig Press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] f_2[12] + 0 6.8392143 0 0.297476 20.71529 25.810505 4.0555741 0 0 0 0 0 0 0 0 0 0 0 0 + 1000 1.2285566 3375 0.24673495 20.492683 21.407958 5.237464 13477 54 54 1 652 16900 5625 3375 1.1653557 0 15 0 + 2000 1.3561011 3395 0.24763991 20.476182 21.486477 9.2878509 13435 67 67 0 1504 16900 5625 3395 1.1651182 0 15 0 + 3000 1.2445369 3352 0.24713723 20.515681 21.442861 8.0289529 13186 62 63 2 2379 16900 5625 3352 1.1746721 0 15 0 + 4000 1.1058201 3389 0.24596239 20.51709 21.340926 10.003266 13466 66 66 0 3264 16900 5625 3389 1.1671415 0 15 0 + 5000 1.0584198 3407 0.24539623 20.503281 21.291804 9.1119405 13254 64 64 0 4189 16900 5625 3407 1.1687685 0 15 0 + 6000 1.3335611 3360 0.24737788 20.470239 21.463742 8.6885126 13281 62 62 1 5031 16900 5625 3360 1.1568996 0 15 0 + 7000 1.1384759 3401 0.24570869 20.47075 21.318914 9.1801119 13059 47 47 1 5878 16900 5625 3401 1.182474 0 15 0 + 8000 1.2982334 3397 0.24667224 20.435333 21.402517 6.5904007 13405 56 56 0 6729 16900 5625 3397 1.169017 0 24 0 + 9000 1.0456752 3381 0.24504517 20.482316 21.261344 10.497413 13205 81 81 2 7706 16900 5625 3381 1.1694675 0 24 0 + 10000 1.2222547 3394 0.24653264 20.479825 21.390405 8.7495888 13296 68 68 1 8581 16900 5625 3394 1.1613437 0 24 0 +Loop time of 7.18514 on 1 procs for 10000 steps with 17353 atoms + +Performance: 120248.165 tau/day, 1391.761 timesteps/s, 24.151 Matom-step/s +99.8% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.14497 | 0.14497 | 0.14497 | 0.0 | 2.02 +Neigh | 0.031835 | 0.031835 | 0.031835 | 0.0 | 0.44 +Comm | 0.094201 | 0.094201 | 0.094201 | 0.0 | 1.31 +Output | 0.00082765 | 0.00082765 | 0.00082765 | 0.0 | 0.01 +Modify | 6.8507 | 6.8507 | 6.8507 | 0.0 | 95.35 +Other | | 0.06259 | | | 0.87 + +Nlocal: 17353 ave 17353 max 17353 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 128 ave 128 max 128 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 1334 ave 1334 max 1334 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 1334 +Ave neighs/atom = 0.076874316 +Neighbor list builds = 500 +Dangerous builds = 0 +Total wall time: 0:00:07 diff --git a/examples/ASPHERE/dimer/log.1Feb24.dimer.g++.4 b/examples/ASPHERE/dimer/log.1Feb24.dimer.g++.4 new file mode 100644 index 0000000000..447feb886d --- /dev/null +++ b/examples/ASPHERE/dimer/log.1Feb24.dimer.g++.4 @@ -0,0 +1,312 @@ +LAMMPS (21 Nov 2023 - Development - patch_21Nov2023-665-g17f869bf5e) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# SRD diffusion demo - dimer particles + +units lj +atom_style sphere +atom_modify map array first big +dimension 2 + +# read in clusters of rigid bodies + +fix molprop all property/atom mol ghost yes +read_data data.dimer fix molprop NULL Molecules +Reading data file ... + orthogonal box = (-9.341652 -9.341652 -0.5) to (9.341652 9.341652 0.5) + 2 by 2 by 1 MPI processor grid + reading atoms ... + 200 atoms + read_data CPU = 0.001 seconds + +set type 1 mass 1.0 +Setting atom values ... + 200 settings made for mass +group big type 1 +200 atoms in group big +velocity big create 1.44 87287 loop geom + +# equilibrate big particles + +pair_style soft 1.12 +pair_coeff 1 1 0.0 +pair_coeff 2 2 0.0 0.0 +pair_coeff 1 2 0.0 0.0 + +variable prefactor equal ramp(0,60) +fix soft all adapt 1 pair soft a * * v_prefactor + +fix 1 big rigid molecule + 100 rigid bodies with 200 atoms +fix 2 all enforce2d + +#dump 1 all atom 10 dump.dimer.equil + +thermo 100 +run 1000 +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 1.42 + ghost atom cutoff = 1.42 + binsize = 0.71, bins = 27 27 2 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair soft, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/2d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 5.553 | 5.553 | 5.553 Mbytes + Step Temp E_pair E_mol TotEng Press + 0 3.4028231 0 0 0.83369167 -0.55065517 + 100 9.5167872 2.392105 0 4.7237178 2.8319556 + 200 13.564465 3.0352634 0 6.3585572 3.6388732 + 300 13.133051 4.3835112 0 7.6011086 4.060051 + 400 14.576837 5.5141059 0 9.0854309 4.422762 + 500 15.227825 6.6472106 0 10.378028 4.8598912 + 600 16.93219 7.454865 0 11.603251 5.2908894 + 700 16.573769 8.7323442 0 12.792918 5.3544684 + 800 17.482599 9.7221047 0 14.005341 5.6200973 + 900 18.548144 10.739353 0 15.283649 4.7817995 + 1000 18.068079 12.058417 0 16.485096 6.5773093 +Loop time of 0.0424792 on 4 procs for 1000 steps with 200 atoms + +Performance: 10169676.521 tau/day, 23540.918 timesteps/s, 4.708 Matom-step/s +98.0% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.0022758 | 0.0023448 | 0.002442 | 0.1 | 5.52 +Neigh | 0.0011082 | 0.0011236 | 0.0011582 | 0.1 | 2.64 +Comm | 0.0099484 | 0.010092 | 0.010247 | 0.1 | 23.76 +Output | 9.551e-05 | 0.00010604 | 0.00013381 | 0.0 | 0.25 +Modify | 0.026025 | 0.026222 | 0.026405 | 0.1 | 61.73 +Other | | 0.00259 | | | 6.10 + +Nlocal: 50 ave 55 max 47 min +Histogram: 2 0 0 0 0 1 0 0 0 1 +Nghost: 33.75 ave 38 max 32 min +Histogram: 2 1 0 0 0 0 0 0 0 1 +Neighs: 68.75 ave 77 max 64 min +Histogram: 2 0 0 1 0 0 0 0 0 1 + +Total # of neighbors = 275 +Ave neighs/atom = 1.375 +Neighbor list builds = 193 +Dangerous builds = 0 + +#undump 1 +unfix soft +unfix 1 +unfix 2 + +# add small particles as hi density lattice + +region plane block INF INF INF INF -0.001 0.001 units box +lattice sq 85.0 +Lattice spacing in x,y,z = 0.10846523 0.10846523 0.10846523 +create_atoms 2 region plane +Created 29929 atoms + using lattice units in orthogonal box = (-9.341652 -9.341652 -0.5) to (9.341652 9.341652 0.5) + create_atoms CPU = 0.002 seconds + +set type 2 mass 0.1 +Setting atom values ... + 29929 settings made for mass +group small type 2 +29929 atoms in group small +velocity small create 1.0 593849 loop geom + +# delete overlaps +# must set 1-2 cutoff to non-zero value + +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 +pair_coeff 2 2 0.0 1.0 0.0 +pair_coeff 1 2 0.0 1.0 0.5 + +delete_atoms overlap 0.5 small big +System init for delete_atoms ... +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 2.8 + ghost atom cutoff = 2.8 + binsize = 1.4, bins = 14 14 1 + 2 neighbor lists, perpetual/occasional/extra = 1 1 0 + (1) command delete_atoms, occasional + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/2d + bin: standard + (2) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/2d + bin: standard +WARNING: Delete_atoms cutoff > minimum neighbor cutoff (src/delete_atoms.cpp:312) +Deleted 12776 atoms, new total = 17353 + +# SRD run + +reset_timestep 0 + +neighbor 0.3 multi +neigh_modify delay 0 every 1 check yes + +comm_modify mode multi group big vel yes +neigh_modify include big + +# no pairwise interactions with small particles + +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 +pair_coeff 2 2 0.0 1.0 0.0 +pair_coeff 1 2 0.0 1.0 0.0 + +# use fix SRD to push small particles out from inside big ones +# if comment out, big particles won't see SRD particles + +timestep 0.001 + +fix 1 big rigid molecule + 100 rigid bodies with 200 atoms +fix 2 small srd 20 big 1.0 0.25 49894 shift yes 54979 search 0.2 collision slip inside ignore overlap yes +fix 3 all enforce2d + +# diagnostics + +compute tbig big temp/sphere +variable pebig equal pe*atoms/count(big) +variable ebig equal etotal*atoms/count(big) +thermo_style custom step temp f_2[8] etotal v_pebig v_ebig press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] f_2[12] + +thermo_modify temp tbig +WARNING: Temperature for thermo pressure is not for group all (src/thermo.cpp:530) +thermo 1000 + +#dump 1 all atom 1000 dump.dimer + +#dump 1 all image 1000 image.*.jpg type type zoom 1.6 +#dump_modify 1 pad 6 adiam 1 1 adiam 2 0.2 + +run 10000 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- neighbor multi command: doi:10.1016/j.cpc.2008.03.005, doi:10.1007/s40571-020-00361-2 + +@Article{Intveld08, + author = {in 't Veld, P. J. and S. J.~Plimpton and G. S. Grest}, + title = {Accurate and Efficient Methods for Modeling Colloidal + Mixtures in an Explicit Solvent using Molecular Dynamics}, + journal = {Comput.\ Phys.\ Commut.}, + year = 2008, + volume = 179, + pages = {320--329} +} + +@article{Shire2020, + author = {Shire, Tom and Hanley, Kevin J. and Stratford, Kevin}, + title = {{DEM} Simulations of Polydisperse Media: Efficient Contact + Detection Applied to Investigate the Quasi-Static Limit}, + journal = {Computational Particle Mechanics}, + year = {2020} +@article{Monti2022, + author = {Monti, Joseph M. and Clemmer, Joel T. and Srivastava, + Ishan and Silbert, Leonardo E. and Grest, Gary S. + and Lechman, Jeremy B.}, + title = {Large-scale frictionless jamming with power-law particle + size distributions}, + journal = {Phys. Rev. E}, + volume = {106} + issue = {3} + year = {2022} +} + +- fix srd command: doi:10.1063/1.3419070 + +@Article{Petersen10, + author = {M. K. Petersen and J. B. Lechman and S. J. Plimpton and + G. S. Grest and in 't Veld, P. J. and P. R. Schunk}, + title = {Mesoscale Hydrodynamics via Stochastic Rotation + Dynamics: Comparison with {L}ennard-{J}ones Fluid}, + journal = {J.~Chem.\ Phys.}, + year = 2010, + volume = 132, + pages = 174106 +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +SRD info: + SRD/big particles = 17153 200 + big particle diameter max/min = 1 1 + SRD temperature & lamda = 1 0.063245553 + SRD max distance & max velocity = 0.25298221 12.649111 + SRD grid counts: 75 75 1 + SRD grid size: request, actual (xyz) = 0.25, 0.24911072 0.24911072 1 + SRD per actual grid cell = 5.544404 + SRD viscosity = 0.23553122 + big/SRD mass density ratio = 0.14250828 + # of rescaled SRD velocities = 0 + ave/max small velocity = 4.191188 7.6900178 + ave/max big velocity = 2.6813242 7.1846103 +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 2.8 + ghost atom cutoff = 2.8 + binsize = 18.683304, bins = 1 1 1 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/multi/atomonly/newton + stencil: half/multi/2d + bin: multi +Per MPI rank memory allocation (min/avg/max) = 13.2 | 13.21 | 13.22 Mbytes + Step Temp f_2[8] TotEng v_pebig v_ebig Press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] f_2[12] + 0 6.8392143 0 0.297476 20.71529 25.810505 4.0555746 0 0 0 0 0 0 0 0 0 0 0 0 + 1000 1.1648085 3389 0.24643931 20.514525 21.382307 5.5927686 13390 59 59 0 1015 28224 5625 3389 1.1513276 0 111 0 + 2000 1.1870311 3385 0.24701637 20.548037 21.432375 5.9269821 13271 57 57 2 1878 28224 5625 3385 1.1619099 0 111 0 + 3000 1.1362839 3365 0.24577276 20.477942 21.324474 5.1621045 13244 59 60 1 2778 28224 5625 3365 1.1807679 0 111 0 + 4000 1.3023748 3390 0.24679509 20.442907 21.413176 5.6127077 13413 65 65 1 3705 28224 5625 3390 1.1726946 0 111 0 + 5000 1.195496 3387 0.2458055 20.43667 21.327314 6.1843476 13248 51 51 1 4638 28224 5625 3387 1.1730279 0 111 0 + 6000 1.2389419 3387 0.24546635 20.374876 21.297888 5.5909826 13184 54 54 1 5494 28224 5625 3387 1.1859134 0 111 0 + 7000 1.2068912 3378 0.24564722 20.414447 21.313581 8.5604547 13188 57 57 1 6428 28224 5625 3378 1.1499181 0 111 0 + 8000 1.1014154 3374 0.24514746 20.449665 21.270219 7.3483529 13179 63 63 0 7591 28224 5625 3374 1.1769322 0 121 0 + 9000 1.356464 3388 0.24749513 20.463349 21.473915 7.6809833 13138 50 50 2 8485 28224 5625 3388 1.1448659 0 121 0 + 10000 1.1632951 3402 0.24560819 20.44354 21.310195 9.5738599 13323 64 67 0 9304 28224 5625 3402 1.1550136 0 121 0 +Loop time of 2.47185 on 4 procs for 10000 steps with 17353 atoms + +Performance: 349536.432 tau/day, 4045.561 timesteps/s, 70.203 Matom-step/s +99.4% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.037524 | 0.039903 | 0.042215 | 1.1 | 1.61 +Neigh | 0.01053 | 0.010805 | 0.011068 | 0.2 | 0.44 +Comm | 0.14536 | 0.14822 | 0.15102 | 0.6 | 6.00 +Output | 0.00051847 | 0.00054674 | 0.0006272 | 0.0 | 0.02 +Modify | 2.2276 | 2.2334 | 2.2381 | 0.3 | 90.35 +Other | | 0.03895 | | | 1.58 + +Nlocal: 4338.25 ave 4488 max 4277 min +Histogram: 2 1 0 0 0 0 0 0 0 1 +Nghost: 76.75 ave 85 max 69 min +Histogram: 2 0 0 0 0 0 0 0 1 1 +Neighs: 331.25 ave 355 max 306 min +Histogram: 1 0 0 1 0 0 1 0 0 1 + +Total # of neighbors = 1325 +Ave neighs/atom = 0.076355673 +Neighbor list builds = 507 +Dangerous builds = 0 +Total wall time: 0:00:02 diff --git a/examples/ASPHERE/dimer/log.1Feb24.dimer.mp.g++.1 b/examples/ASPHERE/dimer/log.1Feb24.dimer.mp.g++.1 new file mode 100644 index 0000000000..8c426db53c --- /dev/null +++ b/examples/ASPHERE/dimer/log.1Feb24.dimer.mp.g++.1 @@ -0,0 +1,328 @@ +LAMMPS (21 Nov 2023 - Development - patch_21Nov2023-665-g17f869bf5e) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# SRD viscosity demo - dimer particles + +units lj +atom_style sphere +atom_modify map array first big +dimension 2 + +# read in clusters of rigid bodies + +fix molprop all property/atom mol ghost yes +read_data data.dimer fix molprop NULL Molecules +Reading data file ... + orthogonal box = (-9.341652 -9.341652 -0.5) to (9.341652 9.341652 0.5) + 1 by 1 by 1 MPI processor grid + reading atoms ... + 200 atoms + read_data CPU = 0.001 seconds + +set type 1 mass 1.0 +Setting atom values ... + 200 settings made for mass +group big type 1 +200 atoms in group big +velocity big create 1.44 87287 loop geom + +# equilibrate big particles + +pair_style soft 1.12 +pair_coeff 1 1 0.0 +pair_coeff 2 2 0.0 0.0 +pair_coeff 1 2 0.0 0.0 + +variable prefactor equal ramp(0,60) +fix soft all adapt 1 pair soft a * * v_prefactor + +fix 1 big rigid molecule + 100 rigid bodies with 200 atoms +fix 2 all enforce2d + +#dump 1 all atom 10 dump.dimer.equil + +thermo 100 +run 1000 +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 1.42 + ghost atom cutoff = 1.42 + binsize = 0.71, bins = 27 27 2 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair soft, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/2d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 5.557 | 5.557 | 5.557 Mbytes + Step Temp E_pair E_mol TotEng Press + 0 3.4028231 0 0 0.83369167 -0.55065517 + 100 9.5167872 2.392105 0 4.7237178 2.8319556 + 200 13.564465 3.0352634 0 6.3585572 3.6388732 + 300 13.133051 4.3835112 0 7.6011086 4.060051 + 400 14.576837 5.5141059 0 9.0854309 4.422762 + 500 15.227825 6.6472106 0 10.378028 4.8598912 + 600 16.93219 7.454865 0 11.603251 5.2908894 + 700 16.573769 8.7323442 0 12.792918 5.3544684 + 800 17.482599 9.7221047 0 14.005341 5.6200973 + 900 18.548144 10.739353 0 15.283649 4.7817995 + 1000 18.068079 12.058417 0 16.485096 6.5773091 +Loop time of 0.0502552 on 1 procs for 1000 steps with 200 atoms + +Performance: 8596132.389 tau/day, 19898.455 timesteps/s, 3.980 Matom-step/s +99.4% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.0095071 | 0.0095071 | 0.0095071 | 0.0 | 18.92 +Neigh | 0.0042809 | 0.0042809 | 0.0042809 | 0.0 | 8.52 +Comm | 0.0022049 | 0.0022049 | 0.0022049 | 0.0 | 4.39 +Output | 0.0001259 | 0.0001259 | 0.0001259 | 0.0 | 0.25 +Modify | 0.032467 | 0.032467 | 0.032467 | 0.0 | 64.60 +Other | | 0.00167 | | | 3.32 + +Nlocal: 200 ave 200 max 200 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 64 ave 64 max 64 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 275 ave 275 max 275 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 275 +Ave neighs/atom = 1.375 +Neighbor list builds = 193 +Dangerous builds = 0 + +#undump 1 +unfix soft +unfix 1 +unfix 2 + +# add small particles as hi density lattice + +region plane block INF INF INF INF -0.001 0.001 units box +lattice sq 85.0 +Lattice spacing in x,y,z = 0.10846523 0.10846523 0.10846523 +create_atoms 2 region plane +Created 29929 atoms + using lattice units in orthogonal box = (-9.341652 -9.341652 -0.5) to (9.341652 9.341652 0.5) + create_atoms CPU = 0.006 seconds + +set type 2 mass 0.1 +Setting atom values ... + 29929 settings made for mass +group small type 2 +29929 atoms in group small +velocity small create 1.0 593849 loop geom + +# delete overlaps +# must set 1-2 cutoff to non-zero value + +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 +pair_coeff 2 2 0.0 1.0 0.0 +pair_coeff 1 2 0.0 1.0 0.5 + +delete_atoms overlap 0.5 small big +System init for delete_atoms ... +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 2.8 + ghost atom cutoff = 2.8 + binsize = 1.4, bins = 14 14 1 + 2 neighbor lists, perpetual/occasional/extra = 1 1 0 + (1) command delete_atoms, occasional + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/2d + bin: standard + (2) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/2d + bin: standard +WARNING: Delete_atoms cutoff > minimum neighbor cutoff (src/delete_atoms.cpp:312) +Deleted 12776 atoms, new total = 17353 + +# SRD run + +reset_timestep 0 + +neighbor 0.3 multi +neigh_modify delay 0 every 1 check yes + +comm_modify mode multi group big vel yes +neigh_modify include big + +# no pairwise interactions with small particles + +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 +pair_coeff 2 2 0.0 1.0 0.0 +pair_coeff 1 2 0.0 1.0 0.0 + +# use fix SRD to push small particles out from inside big ones +# if comment out, big particles won't see SRD particles + +timestep 0.001 + +fix 1 big rigid molecule + 100 rigid bodies with 200 atoms +fix 2 small srd 20 big 1.0 0.25 49894 shift yes 54979 search 0.2 collision slip inside ignore overlap yes +fix 3 small viscosity 10 x y 50 +fix 4 all enforce2d + +# diagnostics + +compute tbig big temp/sphere +variable pebig equal pe*atoms/count(big) +variable ebig equal etotal*atoms/count(big) +thermo_style custom step temp f_2[8] etotal v_pebig v_ebig press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] f_2[12] + +thermo_modify temp tbig +WARNING: Temperature for thermo pressure is not for group all (src/thermo.cpp:530) +thermo 1000 + +#dump 1 all atom 500 dump.dimer.mp + +#dump 1 all image 500 image.*.jpg type type zoom 1.6 +#dump_modify 1 pad 6 adiam 1 1 adiam 2 0.2 + +run 25000 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- neighbor multi command: doi:10.1016/j.cpc.2008.03.005, doi:10.1007/s40571-020-00361-2 + +@Article{Intveld08, + author = {in 't Veld, P. J. and S. J.~Plimpton and G. S. Grest}, + title = {Accurate and Efficient Methods for Modeling Colloidal + Mixtures in an Explicit Solvent using Molecular Dynamics}, + journal = {Comput.\ Phys.\ Commut.}, + year = 2008, + volume = 179, + pages = {320--329} +} + +@article{Shire2020, + author = {Shire, Tom and Hanley, Kevin J. and Stratford, Kevin}, + title = {{DEM} Simulations of Polydisperse Media: Efficient Contact + Detection Applied to Investigate the Quasi-Static Limit}, + journal = {Computational Particle Mechanics}, + year = {2020} +@article{Monti2022, + author = {Monti, Joseph M. and Clemmer, Joel T. and Srivastava, + Ishan and Silbert, Leonardo E. and Grest, Gary S. + and Lechman, Jeremy B.}, + title = {Large-scale frictionless jamming with power-law particle + size distributions}, + journal = {Phys. Rev. E}, + volume = {106} + issue = {3} + year = {2022} +} + +- fix srd command: doi:10.1063/1.3419070 + +@Article{Petersen10, + author = {M. K. Petersen and J. B. Lechman and S. J. Plimpton and + G. S. Grest and in 't Veld, P. J. and P. R. Schunk}, + title = {Mesoscale Hydrodynamics via Stochastic Rotation + Dynamics: Comparison with {L}ennard-{J}ones Fluid}, + journal = {J.~Chem.\ Phys.}, + year = 2010, + volume = 132, + pages = 174106 +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +SRD info: + SRD/big particles = 17153 200 + big particle diameter max/min = 1 1 + SRD temperature & lamda = 1 0.063245553 + SRD max distance & max velocity = 0.25298221 12.649111 + SRD grid counts: 75 75 1 + SRD grid size: request, actual (xyz) = 0.25, 0.24911072 0.24911072 1 + SRD per actual grid cell = 5.544404 + SRD viscosity = 0.23553122 + big/SRD mass density ratio = 0.14250828 + # of rescaled SRD velocities = 0 + ave/max small velocity = 4.191188 7.6900178 + ave/max big velocity = 2.6813242 7.1846104 +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 2.8 + ghost atom cutoff = 2.8 + binsize = 18.683304, bins = 1 1 1 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/multi/atomonly/newton + stencil: half/multi/2d + bin: multi +Per MPI rank memory allocation (min/avg/max) = 26.77 | 26.77 | 26.77 Mbytes + Step Temp f_2[8] TotEng v_pebig v_ebig Press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] f_2[12] + 0 6.8392143 0 0.297476 20.71529 25.810505 4.0555741 0 0 0 0 0 0 0 0 0 0 0 0 + 1000 1.3421139 3394 0.24797209 20.515424 21.515299 5.9986227 13474 52 52 1 704 16900 5625 3394 1.1328453 0 14 0 + 2000 1.3372296 3366 0.24694513 20.429958 21.426194 9.640193 13302 74 74 0 1516 16900 5625 3366 1.1634167 0 14 0 + 3000 1.4022742 3360 0.24799552 20.472637 21.517331 5.9446731 13483 47 47 0 2989 16900 5625 3360 1.1774442 0 217 0 + 4000 1.6325677 3376 0.25066282 20.532497 21.74876 6.9698781 13206 61 61 2 4198 16900 5625 3376 1.1749717 0 217 0 + 5000 2.0992887 3391 0.25484065 20.547279 22.111249 10.648531 13414 62 69 1 6389 16900 5625 3391 1.1862903 0 412 0 + 6000 1.7584548 3388 0.25126127 20.490636 21.800684 8.68036 13456 58 58 0 7672 16900 5625 3388 1.1553986 0 412 0 + 7000 2.2384486 3343 0.25650382 20.58791 22.255554 12.008146 13187 59 59 0 8879 16900 5625 3343 1.1728994 0 412 0 + 8000 2.4981644 3380 0.25734806 20.467672 22.328804 6.7156077 13383 51 51 0 10085 16900 5625 3380 1.156205 0 412 0 + 9000 2.4321991 3384 0.25838085 20.606426 22.418415 9.9820399 12847 55 55 0 11445 16900 5625 3384 1.156145 0 412 0 + 10000 2.2560205 3387 0.25541566 20.480404 22.161139 10.87418 13022 66 66 0 12863 16900 5625 3387 1.1559136 0 412 0 + 11000 2.2321955 3378 0.25533735 20.491359 22.154345 8.510825 13175 70 70 1 14273 16900 5625 3378 1.1470284 0 412 0 + 12000 2.2715125 3377 0.25469529 20.40636 22.098637 9.0604601 13146 68 68 0 15742 16900 5625 3377 1.171755 0 412 0 + 13000 2.3766974 3364 0.25667348 20.499635 22.270275 10.766786 12829 60 60 1 17214 16900 5625 3364 1.130354 0 412 0 + 14000 2.5659704 3347 0.25802994 20.47632 22.387967 8.2568074 13090 66 66 1 18767 16900 5625 3347 1.1609852 0 412 0 + 15000 2.3235671 3400 0.25603152 20.483517 22.214574 5.4785711 13389 50 50 0 20173 16900 5625 3400 1.149754 0 412 0 + 16000 2.6335413 3373 0.25956137 20.558854 22.520843 4.7121947 13027 58 58 1 21668 16900 5625 3373 1.1308267 0 412 0 + 17000 2.5603168 3410 0.25744829 20.430065 22.337501 6.1898616 13218 51 51 1 23170 16900 5625 3410 1.1285699 0 412 0 + 18000 2.7801428 3362 0.26002524 20.489884 22.56109 8.9919312 13002 57 57 3 24829 16900 5625 3362 1.1610153 0 412 0 + 19000 2.7869738 3364 0.26033026 20.51126 22.587555 9.6539159 13085 46 46 0 26476 16900 5625 3364 1.1431913 0 412 0 + 20000 2.678182 3383 0.2586317 20.444934 22.44018 7.3468277 12939 42 42 0 27992 16900 5625 3383 1.143534 0 412 0 + 21000 2.8094503 3375 0.26088069 20.542272 22.635313 8.2257869 13449 52 52 0 29570 16900 5625 3375 1.1375499 0 412 0 + 22000 3.2220363 3377 0.26464914 20.561866 22.962283 6.6329375 13178 65 65 6 31203 16900 5625 3377 1.1683184 0 412 0 + 23000 3.2268368 3339 0.26414495 20.514543 22.918536 4.6879815 12589 51 51 0 32929 16900 5625 3339 1.1378613 0 412 0 + 24000 2.6062461 3380 0.25967238 20.588821 22.530474 10.036449 12745 53 54 0 34460 16900 5625 3380 1.1396017 0 412 0 + 25000 3.2519674 3373 0.26376614 20.462953 22.885669 7.7592712 12856 52 52 1 36172 16900 5625 3373 1.1858891 0 412 0 +Loop time of 20.7208 on 1 procs for 25000 steps with 17353 atoms + +Performance: 104243.242 tau/day, 1206.519 timesteps/s, 20.937 Matom-step/s +99.7% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.39343 | 0.39343 | 0.39343 | 0.0 | 1.90 +Neigh | 0.09039 | 0.09039 | 0.09039 | 0.0 | 0.44 +Comm | 0.26483 | 0.26483 | 0.26483 | 0.0 | 1.28 +Output | 0.0021023 | 0.0021023 | 0.0021023 | 0.0 | 0.01 +Modify | 19.785 | 19.785 | 19.785 | 0.0 | 95.49 +Other | | 0.1847 | | | 0.89 + +Nlocal: 17353 ave 17353 max 17353 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 146 ave 146 max 146 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 1326 ave 1326 max 1326 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 1326 +Ave neighs/atom = 0.0764133 +Neighbor list builds = 1290 +Dangerous builds = 0 +Total wall time: 0:00:21 diff --git a/examples/ASPHERE/dimer/log.1Feb24.dimer.mp.g++.4 b/examples/ASPHERE/dimer/log.1Feb24.dimer.mp.g++.4 new file mode 100644 index 0000000000..0cced46f26 --- /dev/null +++ b/examples/ASPHERE/dimer/log.1Feb24.dimer.mp.g++.4 @@ -0,0 +1,328 @@ +LAMMPS (21 Nov 2023 - Development - patch_21Nov2023-665-g17f869bf5e) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# SRD viscosity demo - dimer particles + +units lj +atom_style sphere +atom_modify map array first big +dimension 2 + +# read in clusters of rigid bodies + +fix molprop all property/atom mol ghost yes +read_data data.dimer fix molprop NULL Molecules +Reading data file ... + orthogonal box = (-9.341652 -9.341652 -0.5) to (9.341652 9.341652 0.5) + 2 by 2 by 1 MPI processor grid + reading atoms ... + 200 atoms + read_data CPU = 0.001 seconds + +set type 1 mass 1.0 +Setting atom values ... + 200 settings made for mass +group big type 1 +200 atoms in group big +velocity big create 1.44 87287 loop geom + +# equilibrate big particles + +pair_style soft 1.12 +pair_coeff 1 1 0.0 +pair_coeff 2 2 0.0 0.0 +pair_coeff 1 2 0.0 0.0 + +variable prefactor equal ramp(0,60) +fix soft all adapt 1 pair soft a * * v_prefactor + +fix 1 big rigid molecule + 100 rigid bodies with 200 atoms +fix 2 all enforce2d + +#dump 1 all atom 10 dump.dimer.equil + +thermo 100 +run 1000 +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 1.42 + ghost atom cutoff = 1.42 + binsize = 0.71, bins = 27 27 2 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair soft, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/2d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 5.553 | 5.553 | 5.553 Mbytes + Step Temp E_pair E_mol TotEng Press + 0 3.4028231 0 0 0.83369167 -0.55065517 + 100 9.5167872 2.392105 0 4.7237178 2.8319556 + 200 13.564465 3.0352634 0 6.3585572 3.6388732 + 300 13.133051 4.3835112 0 7.6011086 4.060051 + 400 14.576837 5.5141059 0 9.0854309 4.422762 + 500 15.227825 6.6472106 0 10.378028 4.8598912 + 600 16.93219 7.454865 0 11.603251 5.2908894 + 700 16.573769 8.7323442 0 12.792918 5.3544684 + 800 17.482599 9.7221047 0 14.005341 5.6200973 + 900 18.548144 10.739353 0 15.283649 4.7817995 + 1000 18.068079 12.058417 0 16.485096 6.5773093 +Loop time of 0.0421376 on 4 procs for 1000 steps with 200 atoms + +Performance: 10252121.014 tau/day, 23731.762 timesteps/s, 4.746 Matom-step/s +99.2% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.002222 | 0.0023177 | 0.0024199 | 0.2 | 5.50 +Neigh | 0.0010943 | 0.0011428 | 0.001174 | 0.1 | 2.71 +Comm | 0.0097533 | 0.009878 | 0.010001 | 0.1 | 23.44 +Output | 9.4323e-05 | 0.0001028 | 0.00012783 | 0.0 | 0.24 +Modify | 0.02557 | 0.026225 | 0.026638 | 0.3 | 62.24 +Other | | 0.002471 | | | 5.86 + +Nlocal: 50 ave 55 max 47 min +Histogram: 2 0 0 0 0 1 0 0 0 1 +Nghost: 33.75 ave 38 max 32 min +Histogram: 2 1 0 0 0 0 0 0 0 1 +Neighs: 68.75 ave 77 max 64 min +Histogram: 2 0 0 1 0 0 0 0 0 1 + +Total # of neighbors = 275 +Ave neighs/atom = 1.375 +Neighbor list builds = 193 +Dangerous builds = 0 + +#undump 1 +unfix soft +unfix 1 +unfix 2 + +# add small particles as hi density lattice + +region plane block INF INF INF INF -0.001 0.001 units box +lattice sq 85.0 +Lattice spacing in x,y,z = 0.10846523 0.10846523 0.10846523 +create_atoms 2 region plane +Created 29929 atoms + using lattice units in orthogonal box = (-9.341652 -9.341652 -0.5) to (9.341652 9.341652 0.5) + create_atoms CPU = 0.002 seconds + +set type 2 mass 0.1 +Setting atom values ... + 29929 settings made for mass +group small type 2 +29929 atoms in group small +velocity small create 1.0 593849 loop geom + +# delete overlaps +# must set 1-2 cutoff to non-zero value + +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 +pair_coeff 2 2 0.0 1.0 0.0 +pair_coeff 1 2 0.0 1.0 0.5 + +delete_atoms overlap 0.5 small big +System init for delete_atoms ... +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 2.8 + ghost atom cutoff = 2.8 + binsize = 1.4, bins = 14 14 1 + 2 neighbor lists, perpetual/occasional/extra = 1 1 0 + (1) command delete_atoms, occasional + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/2d + bin: standard + (2) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/2d + bin: standard +WARNING: Delete_atoms cutoff > minimum neighbor cutoff (src/delete_atoms.cpp:312) +Deleted 12776 atoms, new total = 17353 + +# SRD run + +reset_timestep 0 + +neighbor 0.3 multi +neigh_modify delay 0 every 1 check yes + +comm_modify mode multi group big vel yes +neigh_modify include big + +# no pairwise interactions with small particles + +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 +pair_coeff 2 2 0.0 1.0 0.0 +pair_coeff 1 2 0.0 1.0 0.0 + +# use fix SRD to push small particles out from inside big ones +# if comment out, big particles won't see SRD particles + +timestep 0.001 + +fix 1 big rigid molecule + 100 rigid bodies with 200 atoms +fix 2 small srd 20 big 1.0 0.25 49894 shift yes 54979 search 0.2 collision slip inside ignore overlap yes +fix 3 small viscosity 10 x y 50 +fix 4 all enforce2d + +# diagnostics + +compute tbig big temp/sphere +variable pebig equal pe*atoms/count(big) +variable ebig equal etotal*atoms/count(big) +thermo_style custom step temp f_2[8] etotal v_pebig v_ebig press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] f_2[12] + +thermo_modify temp tbig +WARNING: Temperature for thermo pressure is not for group all (src/thermo.cpp:530) +thermo 1000 + +#dump 1 all atom 500 dump.dimer.mp + +#dump 1 all image 500 image.*.jpg type type zoom 1.6 +#dump_modify 1 pad 6 adiam 1 1 adiam 2 0.2 + +run 25000 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- neighbor multi command: doi:10.1016/j.cpc.2008.03.005, doi:10.1007/s40571-020-00361-2 + +@Article{Intveld08, + author = {in 't Veld, P. J. and S. J.~Plimpton and G. S. Grest}, + title = {Accurate and Efficient Methods for Modeling Colloidal + Mixtures in an Explicit Solvent using Molecular Dynamics}, + journal = {Comput.\ Phys.\ Commut.}, + year = 2008, + volume = 179, + pages = {320--329} +} + +@article{Shire2020, + author = {Shire, Tom and Hanley, Kevin J. and Stratford, Kevin}, + title = {{DEM} Simulations of Polydisperse Media: Efficient Contact + Detection Applied to Investigate the Quasi-Static Limit}, + journal = {Computational Particle Mechanics}, + year = {2020} +@article{Monti2022, + author = {Monti, Joseph M. and Clemmer, Joel T. and Srivastava, + Ishan and Silbert, Leonardo E. and Grest, Gary S. + and Lechman, Jeremy B.}, + title = {Large-scale frictionless jamming with power-law particle + size distributions}, + journal = {Phys. Rev. E}, + volume = {106} + issue = {3} + year = {2022} +} + +- fix srd command: doi:10.1063/1.3419070 + +@Article{Petersen10, + author = {M. K. Petersen and J. B. Lechman and S. J. Plimpton and + G. S. Grest and in 't Veld, P. J. and P. R. Schunk}, + title = {Mesoscale Hydrodynamics via Stochastic Rotation + Dynamics: Comparison with {L}ennard-{J}ones Fluid}, + journal = {J.~Chem.\ Phys.}, + year = 2010, + volume = 132, + pages = 174106 +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +SRD info: + SRD/big particles = 17153 200 + big particle diameter max/min = 1 1 + SRD temperature & lamda = 1 0.063245553 + SRD max distance & max velocity = 0.25298221 12.649111 + SRD grid counts: 75 75 1 + SRD grid size: request, actual (xyz) = 0.25, 0.24911072 0.24911072 1 + SRD per actual grid cell = 5.544404 + SRD viscosity = 0.23553122 + big/SRD mass density ratio = 0.14250828 + # of rescaled SRD velocities = 0 + ave/max small velocity = 4.191188 7.6900178 + ave/max big velocity = 2.6813242 7.1846103 +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 2.8 + ghost atom cutoff = 2.8 + binsize = 18.683304, bins = 1 1 1 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/multi/atomonly/newton + stencil: half/multi/2d + bin: multi +Per MPI rank memory allocation (min/avg/max) = 13.2 | 13.21 | 13.22 Mbytes + Step Temp f_2[8] TotEng v_pebig v_ebig Press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] f_2[12] + 0 6.8392143 0 0.297476 20.71529 25.810505 4.0555746 0 0 0 0 0 0 0 0 0 0 0 0 + 1000 1.2739082 3360 0.24704957 20.486195 21.435256 3.6693454 13497 46 46 2 816 28224 5625 3360 1.1564821 0 54 0 + 2000 1.3843858 3380 0.24759985 20.451634 21.483001 5.2299666 13363 70 70 0 1671 28224 5625 3380 1.170199 0 54 0 + 3000 1.3942166 3373 0.24823326 20.499268 21.537959 7.7943821 13214 59 59 2 2600 28224 5625 3373 1.1539593 0 54 0 + 4000 1.6387342 3366 0.24966206 20.441071 21.661928 4.3859226 13280 49 49 2 3568 28224 5625 3366 1.176006 0 54 0 + 5000 1.8677297 3388 0.25278915 20.541792 21.933251 5.9053775 13238 68 68 2 4553 28224 5625 3388 1.1728833 0 54 0 + 6000 1.8884914 3372 0.25216944 20.472555 21.879481 7.5864922 13142 62 62 1 5645 28224 5625 3372 1.1733967 0 54 0 + 7000 2.0575519 3387 0.25374609 20.483403 22.016279 6.9842803 13101 41 41 0 6805 28224 5625 3387 1.1503024 0 54 0 + 8000 1.9800593 3373 0.252975 20.474232 21.949376 8.3493951 13176 63 64 1 8166 28224 5625 3373 1.1621339 0 67 0 + 9000 2.2288114 3403 0.25526729 20.487802 22.148267 6.7676677 12866 61 61 1 9360 28224 5625 3403 1.1446891 0 67 0 + 10000 2.4854456 3339 0.25713924 20.45903 22.310687 9.3781009 12692 65 65 1 10680 28224 5625 3339 1.1417733 0 67 0 + 11000 2.5850677 3335 0.25820147 20.476975 22.402851 9.9421534 12954 70 70 2 11964 28224 5625 3335 1.1497985 0 67 0 + 12000 2.5087529 3358 0.25746572 20.469992 22.339013 9.9566718 12959 58 58 0 13462 28224 5625 3358 1.1365643 0 98 0 + 13000 2.5480838 3371 0.25761214 20.453395 22.351717 8.6628089 13142 54 54 3 14985 28224 5625 3371 1.1510123 0 98 0 + 14000 2.946645 3384 0.26176446 20.516743 22.711994 8.5668798 12579 53 53 0 16336 28224 5625 3384 1.1546089 0 98 0 + 15000 4.025292 3338 0.27188564 20.591315 23.590157 9.8722859 12824 50 50 15 18115 28224 5625 3338 1.164518 0 122 0 + 16000 2.2744945 3376 0.25598709 20.516221 22.21072 9.1890215 13020 52 52 0 19689 28224 5625 3376 1.1439385 0 122 0 + 17000 2.3857021 3353 0.25662954 20.489114 22.266462 10.24809 12776 51 51 0 21158 28224 5625 3353 1.1435041 0 122 0 + 18000 2.9678193 3330 0.26255063 20.56918 22.780206 8.6799225 12810 49 49 2 23066 28224 5625 3330 1.1567395 0 133 0 + 19000 2.7464034 3368 0.2613984 20.634162 22.680232 9.5420188 12746 47 47 3 24675 28224 5625 3368 1.1426658 0 133 0 + 20000 2.8228684 3367 0.26137363 20.575046 22.678083 8.0865322 12886 51 51 0 26119 28224 5625 3367 1.1484398 0 133 0 + 21000 2.8903033 3389 0.26173565 20.556218 22.709494 11.038294 13152 41 41 1 27685 28224 5625 3389 1.1398936 0 133 0 + 22000 2.8279828 3331 0.26058759 20.503035 22.609882 8.3647396 12895 57 57 1 29333 28224 5625 3331 1.1551348 0 133 0 + 23000 2.9320035 3376 0.26178899 20.529779 22.714121 7.1841698 13077 54 54 1 30908 28224 5625 3376 1.1453809 0 133 0 + 24000 2.8508425 3366 0.26104722 20.525884 22.649762 10.680819 13019 58 58 4 32831 28224 5625 3366 1.1391852 0 154 0 + 25000 2.7878254 3333 0.25961 20.448132 22.525062 11.149479 12960 57 57 1 34494 28224 5625 3333 1.172964 0 154 0 +Loop time of 6.5335 on 4 procs for 25000 steps with 17353 atoms + +Performance: 330603.792 tau/day, 3826.433 timesteps/s, 66.400 Matom-step/s +99.3% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.097519 | 0.10401 | 0.10744 | 1.2 | 1.59 +Neigh | 0.027038 | 0.028067 | 0.028678 | 0.4 | 0.43 +Comm | 0.39354 | 0.39697 | 0.40246 | 0.6 | 6.08 +Output | 0.0013442 | 0.0014045 | 0.0015827 | 0.3 | 0.02 +Modify | 5.8667 | 5.8905 | 5.9143 | 0.8 | 90.16 +Other | | 0.1126 | | | 1.72 + +Nlocal: 4338.25 ave 4476 max 4199 min +Histogram: 1 1 0 0 0 0 0 0 1 1 +Nghost: 78.5 ave 83 max 75 min +Histogram: 1 0 1 0 0 1 0 0 0 1 +Neighs: 328 ave 352 max 309 min +Histogram: 1 0 0 2 0 0 0 0 0 1 + +Total # of neighbors = 1312 +Ave neighs/atom = 0.075606523 +Neighbor list builds = 1274 +Dangerous builds = 0 +Total wall time: 0:00:06 diff --git a/examples/ASPHERE/ellipsoid/in.ellipsoid b/examples/ASPHERE/ellipsoid/in.ellipsoid index 1ee59597da..de972e02f6 100644 --- a/examples/ASPHERE/ellipsoid/in.ellipsoid +++ b/examples/ASPHERE/ellipsoid/in.ellipsoid @@ -116,4 +116,4 @@ thermo 1000 #dump 2 all image 1000 image.*.jpg type type zoom 1.6 #dump_modify 2 pad 6 adiam 1 1 adiam 2 0.2 -run 100000 +run 10000 diff --git a/examples/ASPHERE/ellipsoid/in.ellipsoid.mp b/examples/ASPHERE/ellipsoid/in.ellipsoid.mp index 31fe79eb58..9af32cd2d5 100644 --- a/examples/ASPHERE/ellipsoid/in.ellipsoid.mp +++ b/examples/ASPHERE/ellipsoid/in.ellipsoid.mp @@ -117,4 +117,4 @@ thermo 1000 #dump 1 all image 500 image.*.jpg type type zoom 1.6 #dump_modify 1 pad 6 adiam 1 1 adiam 2 0.2 -run 50000 +run 10000 diff --git a/examples/ASPHERE/ellipsoid/log.1Feb14.ellipsoid.g++.8 b/examples/ASPHERE/ellipsoid/log.1Feb14.ellipsoid.g++.8 deleted file mode 100644 index 1b9fc31a5a..0000000000 --- a/examples/ASPHERE/ellipsoid/log.1Feb14.ellipsoid.g++.8 +++ /dev/null @@ -1,190 +0,0 @@ -LAMMPS (1 Feb 2014) -# SRD diffusion demo - ellipsoids - -units lj -atom_style ellipsoid -atom_modify first big -dimension 2 - -# create big ellipsoidal particles - -lattice sq 0.14 -Lattice spacing in x,y,z = 2.67261 2.67261 2.67261 -region box block 0 10 0 10 -0.5 0.5 -create_box 2 box -Created orthogonal box = (0 0 -1.33631) to (26.7261 26.7261 1.33631) - 4 by 2 by 1 MPI processor grid -create_atoms 1 region box -Created 100 atoms - -set type 1 mass 1.0 - 100 settings made for mass -set type 1 shape 3.0 1.0 1.0 - 100 settings made for shape -group big type 1 -100 atoms in group big -set group big quat/random 29898 - 100 settings made for quat/random - -velocity big create 1.44 87287 loop geom - -# equilibrate big particles - -pair_style gayberne 1.0 3.0 1.0 4.0 -pair_coeff 1 1 1.0 1.0 1 1 1 1 1 1 -pair_coeff 1 2 1.0 1.0 1 1 1 1 1 1 0.0 -pair_coeff 2 2 1.0 1.0 1 1 1 1 1 1 0.0 - -neighbor 0.3 bin -neigh_modify delay 0 every 1 check yes - -fix 1 big nve/asphere -fix 2 all enforce2d - -compute rot big temp/asphere - -#dump 1 all custom 10 dump.ellipsoid.equil id type x y z # quatw quati quatj quatk - -thermo_style custom step temp c_rot epair etotal press -thermo 100 - -run 1000 -Memory usage per processor = 3.31932 Mbytes -Step Temp rot E_pair TotEng Press - 0 1.44 0.95677852 2.7038078 4.1294078 10.518912 - 100 2.5524145 2.801098 -0.37027046 2.1566199 0.84703874 - 200 2.6266386 2.7938164 -0.35322565 2.2471465 1.004886 - 300 2.9987557 2.9499545 -0.58917376 2.3795944 0.73081788 - 400 2.8557446 2.8208128 -0.39904801 2.4281391 0.91808964 - 500 2.4399047 2.8255746 -0.40056447 2.0149412 1.0538908 - 600 2.854258 2.9166789 -0.53424483 2.2914706 0.8117508 - 700 2.9593679 2.8231211 -0.40051714 2.5292571 1.1630889 - 800 2.7632971 2.9060854 -0.52075339 2.2149107 0.77106814 - 900 2.9905601 2.8869672 -0.49099457 2.4696599 0.69616725 - 1000 2.8470146 2.9004954 -0.51281252 2.305732 0.68820531 -Loop time of 0.0485955 on 8 procs for 1000 steps with 100 atoms - -Pair time (%) = 0.0201517 (41.4682) -Neigh time (%) = 0.000492364 (1.01319) -Comm time (%) = 0.0191883 (39.4858) -Outpt time (%) = 0.000273198 (0.562188) -Other time (%) = 0.00848994 (17.4706) - -Nlocal: 12.5 ave 16 max 8 min -Histogram: 1 1 0 0 0 3 0 0 1 2 -Nghost: 34.125 ave 42 max 28 min -Histogram: 1 0 2 2 0 1 0 1 0 1 -Neighs: 46.125 ave 65 max 20 min -Histogram: 1 0 1 0 1 2 0 0 1 2 - -Total # of neighbors = 369 -Ave neighs/atom = 3.69 -Neighbor list builds = 174 -Dangerous builds = 0 - -#undump 1 -unfix 1 -unfix 2 - -# add small particles as hi density lattice - -region plane block INF INF INF INF -0.001 0.001 units box -lattice sq 120.0 -Lattice spacing in x,y,z = 0.0912871 0.0912871 0.0912871 -create_atoms 2 region plane -Created 85849 atoms - -set type 2 mass 0.01 - 85849 settings made for mass -group small type 2 -85849 atoms in group small -velocity small create 1.0 593849 loop geom - -# delete overlaps -# must set 1-2 cutoff to non-zero value - -pair_style lj/cut 2.5 -pair_coeff 1 1 1.0 1.0 -pair_coeff 2 2 0.0 1.0 0.0 -pair_coeff 1 2 0.0 1.0 2.0 - -neigh_modify one 10000 - -delete_atoms overlap 1.6 small big -Deleted 71060 atoms, new total = 14889 - -# SRD run - -reset_timestep 0 - -neighbor 0.3 bin -neigh_modify delay 0 every 1 check yes - -communicate multi group big vel yes -neigh_modify include big - -# no pairwise interactions with small particles - -pair_style gayberne 1.0 3.0 1.0 4.0 -pair_coeff 1 1 1.0 1.0 1 1 1 1 1 1 -pair_coeff 1 2 1.0 1.0 1 1 1 1 1 1 0.0 -pair_coeff 2 2 1.0 1.0 1 1 1 1 1 1 0.0 - -# use fix SRD to push small particles out from inside big ones -# if comment out, big particles won't see SRD particles - -timestep 0.0005 - -fix 1 big nve/asphere -fix 2 small srd 20 big 1.0 0.25 49894 shift yes 54979 collision noslip search 0.2 inside ignore exact no bounce 50 -fix 3 all enforce2d - -# diagnostics - -compute tbig big temp/asphere -variable pebig equal pe*atoms/count(big) -variable ebig equal etotal*atoms/count(big) -thermo_style custom step temp c_rot f_2[9] etotal v_pebig v_ebig press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] f_2[12] - -thermo_modify temp tbig -WARNING: Temperature for thermo pressure is not for group all (../thermo.cpp:439) -thermo 1000 - -#dump 1 all custom 1000 dump.ellipsoid id type x y z # quatw quati quatj quatk - -#dump 1 all image 1000 image.*.jpg type type zoom 1.6 -#dump_modify 1 pad 6 adiam 1 1 adiam 2 0.2 - -run 100000 -SRD info: - SRD/big particles = 14789 100 - big particle diameter max/min = 3 1 - SRD temperature & lamda = 1 0.1 - SRD max distance & max velocity = 0.4 40 - SRD grid counts: 107 107 1 - SRD grid size: request, actual (xyz) = 0.25, 0.249777 0.249777 2.67261 - SRD per actual grid cell = 1.92757 - SRD viscosity = 0.688101 - big/SRD mass density ratio = 1.37367 - # of rescaled SRD velocities = 0 - ave/max small velocity = 13.3093 24.3359 - ave/max big velocity = 2.08028 5.05671 -Memory usage per processor = 10.9077 Mbytes -Step Temp rot 2[9] TotEng pebig ebig Press 2[1] 2[2] 2[3] 2[4] 2[5] 2[6] 2[7] 2[8] 2[9] 2[10] 2[11] 2[12] - 0 2.9004954 2.9004954 0 0.025582146 -0.51281252 3.8089257 0.89865242 0 0 0 0 0 0 0 0 0 0 0 0 - 1000 3.3106106 3.3106106 1.0635866 0.029956176 -0.47263474 4.4601751 1.8111247 14000 35 160 0 224946 98040 11449 4182 1.0635866 1047 50 0 - 2000 2.2814487 2.2814487 1.2237286 0.017972589 -0.72341981 2.6759388 1.3454977 15318 47 276 0 528340 98040 11449 4136 1.2237286 2383 50 0 - 3000 4.2476485 4.2476485 1.2992612 0.038526442 -0.59279435 5.7362019 1.6896403 16506 63 410 0 830594 98040 11449 4172 1.2992612 3834 50 0 - 4000 2.4798681 2.4798681 1.3453264 0.022837826 -0.29467953 3.4003239 2.0765724 17201 51 403 0 1185573 98040 11449 4233 1.3453264 5456 50 0 - 5000 3.0852629 3.0852629 1.3915904 0.02760985 -0.48621111 4.1108305 1.2676357 17540 61 591 0 1594856 98040 11449 4306 1.3915904 7419 50 0 - 6000 6.7201122 6.7201122 1.3649223 0.064627842 -0.39052776 9.6224394 2.5524159 17997 59 564 0 2010250 98040 11449 4213 1.3649223 9280 50 0 - 7000 2.720343 2.720343 1.3909677 0.024282471 -0.43789405 3.6154171 1.5288376 17922 64 342 0 2392388 98040 11449 4228 1.3909677 10947 50 0 - 8000 1.9181626 1.9181626 1.3514483 0.014305579 -0.72810462 2.1299577 0.89423917 18188 42 260 0 2751626 98040 11449 4236 1.3514483 12556 50 0 - 9000 2.9090186 2.9090186 1.3688847 0.02558926 -0.52445278 3.8099849 1.1756318 18536 63 440 0 3112508 98040 11449 4227 1.3688847 14164 50 0 - 10000 1.9647403 1.9647403 1.3979066 0.015375037 -0.63827389 2.2891892 0.65597214 18817 60 466 0 3501352 98040 11449 4257 1.3979066 16016 50 0 - 11000 1.9989051 1.9989051 1.3872043 0.016191243 -0.56765443 2.4107142 0.80582429 18756 58 767 0 3856028 98040 11449 4254 1.3872043 17611 50 0 - 12000 1.7538755 1.7538755 1.4594883 0.013930543 -0.53915598 2.0741185 1.0563875 18602 58 335 0 4248666 98040 11449 4251 1.4594883 19350 50 0 - 13000 13.730871 13.730871 1.4864545 0.13447802 -0.43656501 20.022433 3.6701166 19144 74 681 0 4708523 98040 11449 4104 1.4864545 21589 50 0 - 14000 5.1078782 5.1078782 1.3637807 0.049721182 -0.20775172 7.4029868 2.559935 18494 65 713 0 5139143 98040 11449 4167 1.3637807 23555 50 0 - 15000 2.5843962 2.5843962 1.3450247 0.022294373 -0.53134114 3.3194092 1.1069147 18489 52 260 0 5489252 98040 11449 4262 1.3450247 25209 50 0 -ERROR: Lost atoms: original 14889 current 14819 (../thermo.cpp:392) diff --git a/examples/ASPHERE/ellipsoid/log.1Feb14.ellipsoid.mp.g++.8 b/examples/ASPHERE/ellipsoid/log.1Feb14.ellipsoid.mp.g++.8 deleted file mode 100644 index 052f3116f6..0000000000 --- a/examples/ASPHERE/ellipsoid/log.1Feb14.ellipsoid.mp.g++.8 +++ /dev/null @@ -1,247 +0,0 @@ -LAMMPS (1 Feb 2014) -# SRD viscosity demo - ellipsoids - -units lj -atom_style ellipsoid -atom_modify first big -dimension 2 - -# create big ellipsoidal particles - -lattice sq 0.14 -Lattice spacing in x,y,z = 2.67261 2.67261 2.67261 -region box block 0 10 0 10 -0.5 0.5 -create_box 2 box -Created orthogonal box = (0 0 -1.33631) to (26.7261 26.7261 1.33631) - 4 by 2 by 1 MPI processor grid -create_atoms 1 region box -Created 100 atoms - -set type 1 mass 1.0 - 100 settings made for mass -set type 1 shape 3.0 1.0 1.0 - 100 settings made for shape -group big type 1 -100 atoms in group big -set group big quat/random 29898 - 100 settings made for quat/random - -velocity big create 1.44 87287 loop geom - -# equilibrate big particles - -pair_style gayberne 1.0 3.0 1.0 4.0 -pair_coeff 1 1 1.0 1.0 1 1 1 1 1 1 -pair_coeff 1 2 1.0 1.0 1 1 1 1 1 1 0.0 -pair_coeff 2 2 1.0 1.0 1 1 1 1 1 1 0.0 - -neighbor 0.3 bin -neigh_modify delay 0 every 1 check yes - -fix 1 big nve/asphere -fix 2 all enforce2d - -compute rot big temp/asphere - -#dump 1 all custom 10 dump.ellipsoid.equil id type x y z # quatw quati quatj quatk - -thermo_style custom step temp c_rot epair etotal press -thermo 100 - -run 1000 -Memory usage per processor = 3.31932 Mbytes -Step Temp rot E_pair TotEng Press - 0 1.44 0.95677852 2.7038078 4.1294078 10.518912 - 100 2.5524145 2.801098 -0.37027046 2.1566199 0.84703874 - 200 2.6266386 2.7938164 -0.35322565 2.2471465 1.004886 - 300 2.9987557 2.9499545 -0.58917376 2.3795944 0.73081788 - 400 2.8557446 2.8208128 -0.39904801 2.4281391 0.91808964 - 500 2.4399047 2.8255746 -0.40056447 2.0149412 1.0538908 - 600 2.854258 2.9166789 -0.53424483 2.2914706 0.8117508 - 700 2.9593679 2.8231211 -0.40051714 2.5292571 1.1630889 - 800 2.7632971 2.9060854 -0.52075339 2.2149107 0.77106814 - 900 2.9905601 2.8869672 -0.49099457 2.4696599 0.69616725 - 1000 2.8470146 2.9004954 -0.51281252 2.305732 0.68820531 -Loop time of 0.0581853 on 8 procs for 1000 steps with 100 atoms - -Pair time (%) = 0.0202803 (34.8546) -Neigh time (%) = 0.000480682 (0.826122) -Comm time (%) = 0.0264942 (45.5342) -Outpt time (%) = 0.000326395 (0.560958) -Other time (%) = 0.0106037 (18.2241) - -Nlocal: 12.5 ave 16 max 8 min -Histogram: 1 1 0 0 0 3 0 0 1 2 -Nghost: 34.125 ave 42 max 28 min -Histogram: 1 0 2 2 0 1 0 1 0 1 -Neighs: 46.125 ave 65 max 20 min -Histogram: 1 0 1 0 1 2 0 0 1 2 - -Total # of neighbors = 369 -Ave neighs/atom = 3.69 -Neighbor list builds = 174 -Dangerous builds = 0 - -#undump 1 -unfix 1 -unfix 2 - -# add small particles as hi density lattice - -region plane block INF INF INF INF -0.001 0.001 units box -lattice sq 120.0 -Lattice spacing in x,y,z = 0.0912871 0.0912871 0.0912871 -create_atoms 2 region plane -Created 85849 atoms - -set type 2 mass 0.01 - 85849 settings made for mass -group small type 2 -85849 atoms in group small -velocity small create 1.0 593849 loop geom - -# delete overlaps -# must set 1-2 cutoff to non-zero value - -pair_style lj/cut 2.5 -pair_coeff 1 1 1.0 1.0 -pair_coeff 2 2 0.0 1.0 0.0 -pair_coeff 1 2 0.0 1.0 2.0 - -neigh_modify one 10000 - -delete_atoms overlap 1.6 small big -Deleted 71060 atoms, new total = 14889 - -# SRD run - -reset_timestep 0 - -neighbor 0.3 bin -neigh_modify delay 0 every 1 check yes - -communicate multi group big vel yes -neigh_modify include big - -# no pairwise interactions with small particles - -pair_style gayberne 1.0 3.0 1.0 4.0 -pair_coeff 1 1 1.0 1.0 1 1 1 1 1 1 -pair_coeff 1 2 1.0 1.0 1 1 1 1 1 1 0.0 -pair_coeff 2 2 1.0 1.0 1 1 1 1 1 1 0.0 - -# use fix SRD to push small particles out from inside big ones -# if comment out, big particles won't see SRD particles - -timestep 0.0005 - -fix 1 big nve/asphere -fix 2 small srd 20 big 1.0 0.25 49894 shift yes 54979 collision noslip search 0.2 inside ignore exact no bounce 50 -fix 3 small viscosity 20 x y 50 -fix 4 all enforce2d - -# diagnostics - -compute tbig big temp/asphere -variable pebig equal pe*atoms/count(big) -variable ebig equal etotal*atoms/count(big) -thermo_style custom step temp c_rot f_2[9] etotal v_pebig v_ebig press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] f_2[12] - -thermo_modify temp tbig -WARNING: Temperature for thermo pressure is not for group all (../thermo.cpp:439) -thermo 1000 - -#dump 1 all custom 500 dump.ellipsoid.mp id type x y z # quatw quati quatj quatk - -#dump 1 all image 500 image.*.jpg type type zoom 1.6 -#dump_modify 1 pad 6 adiam 1 1 adiam 2 0.2 - -run 50000 -SRD info: - SRD/big particles = 14789 100 - big particle diameter max/min = 3 1 - SRD temperature & lamda = 1 0.1 - SRD max distance & max velocity = 0.4 40 - SRD grid counts: 107 107 1 - SRD grid size: request, actual (xyz) = 0.25, 0.249777 0.249777 2.67261 - SRD per actual grid cell = 1.92757 - SRD viscosity = 0.688101 - big/SRD mass density ratio = 1.37367 - # of rescaled SRD velocities = 0 - ave/max small velocity = 13.3093 24.3359 - ave/max big velocity = 2.08028 5.05671 -Memory usage per processor = 10.9077 Mbytes -Step Temp rot 2[9] TotEng pebig ebig Press 2[1] 2[2] 2[3] 2[4] 2[5] 2[6] 2[7] 2[8] 2[9] 2[10] 2[11] 2[12] - 0 2.9004954 2.9004954 0 0.025582146 -0.51281252 3.8089257 0.89865242 0 0 0 0 0 0 0 0 0 0 0 0 - 1000 3.1663129 3.1663129 1.0612788 0.028825811 -0.42593131 4.291875 1.8917479 14347 45 319 0 247730 98040 11449 4128 1.0612788 1160 50 0 - 2000 2.3854865 2.3854865 1.2711805 0.019550917 -0.6434388 2.910936 1.4342405 15199 41 151 0 526468 98040 11449 4191 1.2711805 2321 50 0 - 3000 2.6796789 2.6796789 1.2494843 0.023573743 -0.48282696 3.5098946 1.6090734 16441 52 230 0 827117 98040 11449 4203 1.2494843 3659 50 0 - 4000 2.7945661 2.7945661 1.3021617 0.024256529 -0.5523488 3.6115547 1.2702377 16935 52 474 0 1127934 98040 11449 4215 1.3021617 4966 50 0 - 5000 2.7061959 2.7061959 1.338483 0.023736966 -0.498035 3.5341969 1.2801942 17578 49 277 0 1435089 98040 11449 4261 1.338483 6351 50 0 - 6000 3.2698703 3.2698703 1.3285507 0.029840303 -0.42918398 4.4429227 1.4528039 17882 63 228 0 1776449 98040 11449 4252 1.3285507 7935 50 0 - 7000 3.9340641 3.9340641 1.3823898 0.035368008 -0.59581277 5.2659427 1.1321242 18069 49 462 0 2090062 98040 11449 4265 1.3823898 9343 50 0 - 8000 3.6037728 3.6037728 1.4150583 0.032400676 -0.54548483 4.8241367 1.2091317 18275 56 369 0 2486575 98040 11449 4229 1.4150583 11121 50 0 - 9000 105.15275 105.15275 1.3630934 1.0504642 -0.27397996 156.40361 23.278069 18139 107 732 0 2861341 98040 11449 4217 1.3630934 12781 50 0 - 10000 3.5224307 3.5224307 1.3897056 0.0324883 -0.4112387 4.837183 1.6093705 19100 61 347 0 3248400 98040 11449 4204 1.3897056 14424 50 0 - 11000 4.1949959 4.1949959 1.421272 0.03853305 -0.51335814 5.7371858 1.3586332 18670 52 590 0 3722041 98040 11449 4263 1.421272 16373 50 0 - 12000 3.1692742 3.1692742 1.3999982 0.028463927 -0.48422456 4.237994 1.1713046 18787 61 323 0 4117517 98040 11449 4202 1.3999982 18125 50 0 - 13000 3.5868757 3.5868757 1.3193021 0.032298734 -0.53548629 4.8089585 1.0664078 18572 67 224 0 4417636 98040 11449 4277 1.3193021 19546 50 0 - 14000 3.708681 3.708681 1.317797 0.033355183 -0.55968141 4.9662533 1.3959088 18284 67 207 0 4675359 98040 11449 4253 1.317797 20631 50 0 - 15000 3.7410393 3.7410393 1.4017441 0.033377852 -0.60452027 4.9696283 1.2506767 18385 51 189 0 4956150 98040 11449 4275 1.4017441 21763 50 0 - 16000 5.3298522 5.3298522 1.3456075 0.049673767 -0.54555257 7.3959272 1.841432 18693 63 549 0 5301393 98040 11449 4196 1.3456075 23216 50 0 - 17000 3.7425275 3.7425275 1.321554 0.036608704 -0.12569607 5.4506699 2.3767421 18377 68 526 0 5637038 98040 11449 4261 1.321554 24829 50 0 - 18000 6.1904009 6.1904009 1.3905006 0.05857936 -0.50181651 8.7218809 1.7936734 18422 63 522 0 6049781 98040 11449 4280 1.3905006 26646 50 0 - 19000 3.1770374 3.1770374 1.3694174 0.028096405 -0.55051202 4.1832737 0.98036773 18342 54 343 0 6383253 98040 11449 4239 1.3694174 28038 50 0 - 20000 3.5793112 3.5793112 1.3160294 0.031413769 -0.65597761 4.677196 1.0713128 18739 60 272 0 6692090 98040 11449 4262 1.3160294 29389 50 0 - 21000 3.2300481 3.2300481 1.3407923 0.027955254 -0.65051393 4.1622578 0.89783071 18582 55 456 0 6999361 98040 11449 4237 1.3407923 30653 50 0 - 22000 3.5879886 3.5879886 1.3790201 0.031692391 -0.6274228 4.7186802 0.97752405 18768 63 552 0 7350833 98040 11449 4308 1.3790201 32120 50 0 - 23000 3.5666316 3.5666316 1.4123826 0.031275136 -0.6577261 4.656555 0.99950405 18864 49 231 0 7741276 98040 11449 4265 1.4123826 33939 50 0 - 24000 3.7306353 3.7306353 1.3854831 0.032426295 -0.7306956 4.827951 0.93575015 18488 63 552 0 8096740 98040 11449 4238 1.3854831 35503 50 0 - 25000 4.2971901 4.2971901 1.4207289 0.038358698 -0.69158669 5.7112265 1.0308127 18922 58 430 0 8518804 98040 11449 4254 1.4207289 37429 50 0 - 26000 9.514164 9.514164 1.4209186 0.09200552 -0.47740255 13.698702 2.4102159 18934 63 570 0 8931705 98040 11449 4233 1.4209186 39132 50 0 - 27000 3.9153535 3.9153535 1.3814961 0.036650525 -0.37698007 5.4568967 1.4531475 19153 65 553 0 9277922 98040 11449 4299 1.3814961 40660 50 0 - 28000 3.6560048 3.6560048 1.3520603 0.033100525 -0.51910991 4.9283372 1.3474705 19529 59 447 0 9642607 98040 11449 4278 1.3520603 42335 50 0 - 29000 14.835118 14.835118 1.3981622 0.14535835 -0.4619207 21.642405 3.6917556 19265 52 102 0 9937354 98040 11449 4224 1.3981622 43664 50 0 - 30000 5.3595251 5.3595251 1.3636194 0.050893845 -0.40810785 7.5775845 1.7023989 19065 43 131 0 10261222 98040 11449 4170 1.3636194 45193 50 0 - 31000 5.1821698 5.1821698 1.3180039 0.049074014 -0.41480304 7.30663 1.6943582 19142 58 282 0 10584027 98040 11449 4228 1.3180039 46636 50 0 - 32000 4.3056534 4.3056534 1.3508467 0.040670309 -0.36002116 6.0554024 1.7875405 19065 36 284 0 10933981 98040 11449 4286 1.3508467 48240 50 0 - 33000 3.8277999 3.8277999 1.3770405 0.034411971 -0.57982354 5.1235984 1.1046562 18838 71 729 0 11329901 98040 11449 4257 1.3770405 50046 50 0 - 34000 4.6562056 4.6562056 1.3938501 0.043777831 -0.41966518 6.5180812 1.3815841 18914 61 269 0 11758952 98040 11449 4221 1.3938501 51773 50 0 - 35000 3.4251492 3.4251492 1.3813031 0.031876928 -0.35731644 4.7461558 1.4152845 18838 60 283 0 12159425 98040 11449 4238 1.3813031 53477 50 0 - 36000 4.2565688 4.2565688 1.3474871 0.039214915 -0.5035788 5.8387088 1.1222014 18765 56 240 0 12568711 98040 11449 4249 1.3474871 55170 50 0 - 37000 5.3745505 5.3745505 1.4215553 0.053606226 -0.02664916 7.981431 2.8011643 19103 58 504 0 12941065 98040 11449 4270 1.4215553 56743 50 0 - 38000 4.0346121 4.0346121 1.4354472 0.036753623 -0.53932498 5.472247 1.1475792 18829 62 623 0 13351480 98040 11449 4226 1.4354472 58443 50 0 - 39000 4.0471971 4.0471971 1.417888 0.037884509 -0.3896991 5.6406246 1.3824278 19047 70 579 0 13752101 98040 11449 4219 1.417888 60208 50 0 - 40000 4.1611575 4.1611575 1.3712048 0.039505792 -0.31810741 5.8820173 1.6615204 18811 65 378 0 14143802 98040 11449 4313 1.3712048 61793 50 0 - 41000 4.852673 4.852673 1.3719985 0.044831688 -0.5554927 6.67499 1.2744313 18899 53 414 0 14505662 98040 11449 4274 1.3719985 63358 50 0 - 42000 4.8338875 4.8338875 1.3595624 0.045465888 -0.43307636 6.7694161 1.6297026 18708 46 360 0 14839866 98040 11449 4224 1.3595624 64895 50 0 - 43000 5.0243115 5.0243115 1.4371431 0.047111836 -0.47174292 7.0144813 1.5899963 18704 55 291 0 15195383 98040 11449 4209 1.4371431 66440 50 0 - 44000 7.2748224 7.2748224 1.3693754 0.069498669 -0.49182853 10.347657 1.9007074 18751 73 423 0 15572639 98040 11449 4253 1.3693754 68148 50 0 - 45000 5.4888002 5.4888002 1.3501677 0.050885254 -0.60200685 7.5763055 1.2841374 18662 51 314 0 15972088 98040 11449 4227 1.3501677 69998 50 0 - 46000 3.2144774 3.2144774 1.3342547 0.028194354 -0.59171403 4.1978573 0.9459541 18948 50 534 0 16308430 98040 11449 4253 1.3342547 71549 50 0 - 47000 4.0640905 4.0640905 1.3473081 0.036715084 -0.58898597 5.4665088 1.2043249 19188 57 236 0 16670321 98040 11449 4239 1.3473081 73216 50 0 - 48000 3.7843815 3.7843815 1.3413467 0.034360184 -0.52284075 5.1158877 1.1195984 19477 57 283 0 17000588 98040 11449 4307 1.3413467 74662 50 0 - 49000 4.3042567 4.3042567 1.354248 0.039635615 -0.51199566 5.9013468 1.410884 19628 68 456 0 17319627 98040 11449 4277 1.354248 75983 50 0 - 50000 4.015575 4.015575 1.3058373 0.036258162 -0.58472888 5.3984778 0.84500807 19257 63 416 0 17675269 98040 11449 4254 1.3058373 77468 50 0 -Loop time of 11.9502 on 8 procs for 50000 steps with 14889 atoms - -Pair time (%) = 1.09132 (9.13222) -Neigh time (%) = 0.959464 (8.02883) -Comm time (%) = 1.19057 (9.96277) -Outpt time (%) = 0.00310364 (0.0259714) -Other time (%) = 8.70577 (72.8502) - -Nlocal: 1861.12 ave 1979 max 1606 min -Histogram: 1 0 0 0 1 1 1 0 0 4 -Nghost: 35 ave 39 max 32 min -Histogram: 1 0 2 0 3 1 0 0 0 1 -Neighs: 46 ave 61 max 31 min -Histogram: 1 1 0 1 1 0 2 0 1 1 - -Total # of neighbors = 368 -Ave neighs/atom = 0.0247162 -Neighbor list builds = 2624 -Dangerous builds = 0 - -Please see the log.cite file for references relevant to this simulation - diff --git a/examples/ASPHERE/ellipsoid/log.1Feb24.ellipsoid.g++.1 b/examples/ASPHERE/ellipsoid/log.1Feb24.ellipsoid.g++.1 new file mode 100644 index 0000000000..bb4e063020 --- /dev/null +++ b/examples/ASPHERE/ellipsoid/log.1Feb24.ellipsoid.g++.1 @@ -0,0 +1,346 @@ +LAMMPS (21 Nov 2023 - Development - patch_21Nov2023-665-g17f869bf5e) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# SRD diffusion demo - ellipsoids + +units lj +atom_style ellipsoid +atom_modify first big +dimension 2 + +# create big ellipsoidal particles + +lattice sq 0.14 +Lattice spacing in x,y,z = 2.6726124 2.6726124 2.6726124 +region box block 0 10 0 10 -0.5 0.5 +create_box 2 box +Created orthogonal box = (0 0 -1.3363062) to (26.726124 26.726124 1.3363062) + 1 by 1 by 1 MPI processor grid +create_atoms 1 region box +Created 100 atoms + using lattice units in orthogonal box = (0 0 -1.3363062) to (26.726124 26.726124 1.3363062) + create_atoms CPU = 0.000 seconds + +set type 1 mass 1.0 +Setting atom values ... + 100 settings made for mass +set type 1 shape 3.0 1.0 1.0 +Setting atom values ... + 100 settings made for shape +group big type 1 +100 atoms in group big +set group big quat/random 29898 +Setting atom values ... + 100 settings made for quat/random + +velocity big create 1.44 87287 loop geom + +# equilibrate big particles + +pair_style gayberne 1.0 3.0 1.0 4.0 +pair_coeff 1 1 1.0 1.0 1 1 1 1 1 1 +pair_coeff 1 2 1.0 1.0 1 1 1 1 1 1 0.0 +pair_coeff 2 2 1.0 1.0 1 1 1 1 1 1 0.0 + +neighbor 0.3 bin +neigh_modify delay 0 every 1 check yes + +fix 1 big nve/asphere +fix 2 all enforce2d + +compute rot big temp/asphere +compute 0 all property/atom quatw quati quatj quatk shapex shapey shapez + +#dump 1 all custom 10 dump.ellipsoid.equil id type x y z c_0[*] +#dump_modify 1 colname c_0[1] quatw colname c_0[2] quati colname c_0[3] quatj colname c_0[4] quatk # colname c_0[5] shapex colname c_0[6] shapey colname c_0[7] shapez + +thermo_style custom step temp c_rot epair etotal press +thermo 100 + +run 1000 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- pair gayberne command: doi:10.1063/1.3058435 + +@Article{Brown09, + author = {W. M. Brown and M. K. Petersen and S. J. Plimpton and G. S. Grest}, + title = {Liquid Crystal Nanodroplets in Solution}, + journal = {J.~Chem.\ Phys.}, + year = 2009, + volume = 130, + number = 4, + pages = {044901} +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 4.3 + ghost atom cutoff = 4.3 + binsize = 2.15, bins = 13 13 2 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair gayberne, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/2d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 4.611 | 4.611 | 4.611 Mbytes + Step Temp c_rot E_pair TotEng Press + 0 1.44 0.95677852 2.7038078 4.1294078 10.518912 + 100 2.5524145 2.801098 -0.37027046 2.1566199 0.84703874 + 200 2.6266386 2.7938164 -0.35322565 2.2471465 1.004886 + 300 2.9987557 2.9499545 -0.58917376 2.3795944 0.73081788 + 400 2.8557446 2.8208128 -0.39904801 2.4281391 0.91808964 + 500 2.4399047 2.8255746 -0.40056447 2.0149412 1.0538908 + 600 2.854258 2.9166789 -0.53424483 2.2914706 0.8117508 + 700 2.9593679 2.8231211 -0.40051715 2.5292571 1.1630889 + 800 2.7632972 2.9060854 -0.52075351 2.2149107 0.7710678 + 900 2.9905597 2.8869667 -0.49099378 2.4696603 0.69616841 + 1000 2.8470138 2.9005012 -0.51282088 2.3057228 0.68817567 +Loop time of 0.192737 on 1 procs for 1000 steps with 100 atoms + +Performance: 2241395.423 tau/day, 5188.415 timesteps/s, 518.842 katom-step/s +99.4% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.17225 | 0.17225 | 0.17225 | 0.0 | 89.37 +Neigh | 0.0025287 | 0.0025287 | 0.0025287 | 0.0 | 1.31 +Comm | 0.0023396 | 0.0023396 | 0.0023396 | 0.0 | 1.21 +Output | 0.00025405 | 0.00025405 | 0.00025405 | 0.0 | 0.13 +Modify | 0.013955 | 0.013955 | 0.013955 | 0.0 | 7.24 +Other | | 0.001413 | | | 0.73 + +Nlocal: 100 ave 100 max 100 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 77 ave 77 max 77 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 369 ave 369 max 369 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 369 +Ave neighs/atom = 3.69 +Neighbor list builds = 174 +Dangerous builds = 0 + +#undump 1 +unfix 1 +unfix 2 + +# add small particles as hi density lattice + +region plane block INF INF INF INF -0.001 0.001 units box +lattice sq 120.0 +Lattice spacing in x,y,z = 0.091287093 0.091287093 0.091287093 +create_atoms 2 region plane +Created 85849 atoms + using lattice units in orthogonal box = (0 0 -1.3363062) to (26.726124 26.726124 1.3363062) + create_atoms CPU = 0.015 seconds + +set type 2 mass 0.01 +Setting atom values ... + 85849 settings made for mass +group small type 2 +85849 atoms in group small +velocity small create 1.0 593849 loop geom + +# delete overlaps +# must set 1-2 cutoff to non-zero value + +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 +pair_coeff 2 2 0.0 1.0 0.0 +pair_coeff 1 2 0.0 1.0 2.0 + +neigh_modify one 10000 + +delete_atoms overlap 1.6 small big +System init for delete_atoms ... +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 10000, page size: 100000 + master list distance cutoff = 2.8 + ghost atom cutoff = 2.8 + binsize = 1.4, bins = 20 20 2 + 2 neighbor lists, perpetual/occasional/extra = 1 1 0 + (1) command delete_atoms, occasional + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/2d + bin: standard + (2) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/2d + bin: standard +WARNING: Delete_atoms cutoff > minimum neighbor cutoff (src/delete_atoms.cpp:312) +Deleted 71060 atoms, new total = 14889 + +# SRD run + +reset_timestep 0 + +neighbor 0.3 multi +neigh_modify delay 0 every 1 check yes + +comm_modify mode multi group big vel yes +neigh_modify include big + +# no pairwise interactions with small particles + +pair_style gayberne 1.0 3.0 1.0 4.0 +pair_coeff 1 1 1.0 1.0 1 1 1 1 1 1 +pair_coeff 1 2 1.0 1.0 1 1 1 1 1 1 0.0 +pair_coeff 2 2 1.0 1.0 1 1 1 1 1 1 0.0 + +# use fix SRD to push small particles out from inside big ones +# if comment out, big particles won't see SRD particles + +timestep 0.0005 + +fix 1 big nve/asphere +fix 2 small srd 20 big 1.0 0.25 49894 shift yes 54979 collision noslip search 0.2 inside ignore exact no bounce 50 +fix 3 all enforce2d + +# diagnostics + +compute tbig big temp/asphere +variable pebig equal pe*atoms/count(big) +variable ebig equal etotal*atoms/count(big) +thermo_style custom step temp c_rot f_2[9] etotal v_pebig v_ebig press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] f_2[12] + +thermo_modify temp tbig +WARNING: Temperature for thermo pressure is not for group all (src/thermo.cpp:530) +thermo 1000 + +#dump 1 all custom 1000 dump.ellipsoid id type x y z c_0[*] +#dump_modify 1 colname c_0[1] quatw colname c_0[2] quati colname c_0[3] quatj colname c_0[4] quatk # colname c_0[5] shapex colname c_0[6] shapey colname c_0[7] shapez + +#dump 2 all image 1000 image.*.jpg type type zoom 1.6 +#dump_modify 2 pad 6 adiam 1 1 adiam 2 0.2 + +run 10000 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- neighbor multi command: doi:10.1016/j.cpc.2008.03.005, doi:10.1007/s40571-020-00361-2 + +@Article{Intveld08, + author = {in 't Veld, P. J. and S. J.~Plimpton and G. S. Grest}, + title = {Accurate and Efficient Methods for Modeling Colloidal + Mixtures in an Explicit Solvent using Molecular Dynamics}, + journal = {Comput.\ Phys.\ Commut.}, + year = 2008, + volume = 179, + pages = {320--329} +} + +@article{Shire2020, + author = {Shire, Tom and Hanley, Kevin J. and Stratford, Kevin}, + title = {{DEM} Simulations of Polydisperse Media: Efficient Contact + Detection Applied to Investigate the Quasi-Static Limit}, + journal = {Computational Particle Mechanics}, + year = {2020} +@article{Monti2022, + author = {Monti, Joseph M. and Clemmer, Joel T. and Srivastava, + Ishan and Silbert, Leonardo E. and Grest, Gary S. + and Lechman, Jeremy B.}, + title = {Large-scale frictionless jamming with power-law particle + size distributions}, + journal = {Phys. Rev. E}, + volume = {106} + issue = {3} + year = {2022} +} + +- fix srd command: doi:10.1063/1.3419070 + +@Article{Petersen10, + author = {M. K. Petersen and J. B. Lechman and S. J. Plimpton and + G. S. Grest and in 't Veld, P. J. and P. R. Schunk}, + title = {Mesoscale Hydrodynamics via Stochastic Rotation + Dynamics: Comparison with {L}ennard-{J}ones Fluid}, + journal = {J.~Chem.\ Phys.}, + year = 2010, + volume = 132, + pages = 174106 +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +SRD info: + SRD/big particles = 14789 100 + big particle diameter max/min = 3 1 + SRD temperature & lamda = 1 0.1 + SRD max distance & max velocity = 0.4 40 + SRD grid counts: 107 107 1 + SRD grid size: request, actual (xyz) = 0.25, 0.24977686 0.24977686 2.6726124 + SRD per actual grid cell = 1.9275711 + SRD viscosity = 0.68810145 + big/SRD mass density ratio = 1.3736715 + # of rescaled SRD velocities = 0 + ave/max small velocity = 13.30933 24.335888 + ave/max big velocity = 2.0802836 5.05672 +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 10000, page size: 100000 + master list distance cutoff = 4.3 + ghost atom cutoff = 4.3 + binsize = 26.726124, bins = 1 1 1 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair gayberne, perpetual + attributes: half, newton on + pair build: half/multi/atomonly/newton + stencil: half/multi/2d + bin: multi +Per MPI rank memory allocation (min/avg/max) = 43.23 | 43.23 | 43.23 Mbytes + Step Temp c_rot f_2[9] TotEng v_pebig v_ebig Press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] f_2[12] + 0 2.9005012 2.9005012 0 0.025582147 -0.51282088 3.8089259 0.8986241 0 0 0 0 0 0 0 0 0 0 0 0 + 1000 2.1884096 2.1884096 0.81792923 0.016786763 -0.7613492 2.4993811 1.1765894 13834 35 35 0 241 38416 11449 4172 0.81792923 16 50 0 + 2000 1.2708697 1.2708697 0.90821156 0.0069438942 -0.8597194 1.0338764 0.9801188 14658 35 35 0 372 38416 11449 4281 0.90821156 16 50 0 + 3000 1.1130928 1.1130928 0.9590586 0.0052557024 -0.8759868 0.78252152 0.70461705 15267 28 28 0 519 38416 11449 4292 0.9590586 16 50 0 + 4000 0.8649005 0.8649005 0.9947477 0.0026217985 -0.89834217 0.39035958 0.77420962 15681 36 36 0 698 38416 11449 4339 0.9947477 16 50 0 + 5000 1.1743692 1.1743692 0.98116608 0.0069116456 -0.72073526 1.0290749 0.8829165 15974 37 37 0 881 38416 11449 4328 0.98116608 16 50 0 + 6000 1.0190814 1.0190814 1.0138428 0.0048088112 -0.80244733 0.7159839 0.79743882 16092 36 36 0 1090 38416 11449 4319 1.0138428 16 50 0 + 7000 1.0824823 1.0824823 1.0415165 0.0049127988 -0.88143205 0.73146661 0.48157537 16178 46 46 0 1328 38416 11449 4370 1.0415165 23 50 0 + 8000 1.0482457 1.0482457 1.0336952 0.0051802902 -0.79059275 0.7712934 0.75744414 16622 33 33 0 1579 38416 11449 4340 1.0336952 24 50 0 + 9000 0.98889815 0.98889815 1.0126005 0.00397567 -0.88152073 0.59193751 0.52056685 16877 41 41 0 1811 38416 11449 4370 1.0126005 27 50 0 + 10000 0.96559538 0.96559538 1.0234124 0.0045683795 -0.7585511 0.68018602 0.70666049 16833 32 32 0 2038 38416 11449 4330 1.0234124 27 50 0 +Loop time of 9.04639 on 1 procs for 10000 steps with 14889 atoms + +Performance: 47753.873 tau/day, 1105.414 timesteps/s, 16.459 Matom-step/s +99.7% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 1.862 | 1.862 | 1.862 | 0.0 | 20.58 +Neigh | 0.018395 | 0.018395 | 0.018395 | 0.0 | 0.20 +Comm | 0.060502 | 0.060502 | 0.060502 | 0.0 | 0.67 +Output | 0.00092704 | 0.00092704 | 0.00092704 | 0.0 | 0.01 +Modify | 7.0482 | 7.0482 | 7.0482 | 0.0 | 77.91 +Other | | 0.05636 | | | 0.62 + +Nlocal: 14889 ave 14889 max 14889 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 79 ave 79 max 79 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 416 ave 416 max 416 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 416 +Ave neighs/atom = 0.02794009 +Neighbor list builds = 500 +Dangerous builds = 0 +Total wall time: 0:00:11 diff --git a/examples/ASPHERE/ellipsoid/log.1Feb24.ellipsoid.g++.4 b/examples/ASPHERE/ellipsoid/log.1Feb24.ellipsoid.g++.4 new file mode 100644 index 0000000000..7a4f323cfe --- /dev/null +++ b/examples/ASPHERE/ellipsoid/log.1Feb24.ellipsoid.g++.4 @@ -0,0 +1,346 @@ +LAMMPS (21 Nov 2023 - Development - patch_21Nov2023-665-g17f869bf5e) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# SRD diffusion demo - ellipsoids + +units lj +atom_style ellipsoid +atom_modify first big +dimension 2 + +# create big ellipsoidal particles + +lattice sq 0.14 +Lattice spacing in x,y,z = 2.6726124 2.6726124 2.6726124 +region box block 0 10 0 10 -0.5 0.5 +create_box 2 box +Created orthogonal box = (0 0 -1.3363062) to (26.726124 26.726124 1.3363062) + 2 by 2 by 1 MPI processor grid +create_atoms 1 region box +Created 100 atoms + using lattice units in orthogonal box = (0 0 -1.3363062) to (26.726124 26.726124 1.3363062) + create_atoms CPU = 0.001 seconds + +set type 1 mass 1.0 +Setting atom values ... + 100 settings made for mass +set type 1 shape 3.0 1.0 1.0 +Setting atom values ... + 100 settings made for shape +group big type 1 +100 atoms in group big +set group big quat/random 29898 +Setting atom values ... + 100 settings made for quat/random + +velocity big create 1.44 87287 loop geom + +# equilibrate big particles + +pair_style gayberne 1.0 3.0 1.0 4.0 +pair_coeff 1 1 1.0 1.0 1 1 1 1 1 1 +pair_coeff 1 2 1.0 1.0 1 1 1 1 1 1 0.0 +pair_coeff 2 2 1.0 1.0 1 1 1 1 1 1 0.0 + +neighbor 0.3 bin +neigh_modify delay 0 every 1 check yes + +fix 1 big nve/asphere +fix 2 all enforce2d + +compute rot big temp/asphere +compute 0 all property/atom quatw quati quatj quatk shapex shapey shapez + +#dump 1 all custom 10 dump.ellipsoid.equil id type x y z c_0[*] +#dump_modify 1 colname c_0[1] quatw colname c_0[2] quati colname c_0[3] quatj colname c_0[4] quatk # colname c_0[5] shapex colname c_0[6] shapey colname c_0[7] shapez + +thermo_style custom step temp c_rot epair etotal press +thermo 100 + +run 1000 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- pair gayberne command: doi:10.1063/1.3058435 + +@Article{Brown09, + author = {W. M. Brown and M. K. Petersen and S. J. Plimpton and G. S. Grest}, + title = {Liquid Crystal Nanodroplets in Solution}, + journal = {J.~Chem.\ Phys.}, + year = 2009, + volume = 130, + number = 4, + pages = {044901} +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 4.3 + ghost atom cutoff = 4.3 + binsize = 2.15, bins = 13 13 2 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair gayberne, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/2d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 4.61 | 4.61 | 4.61 Mbytes + Step Temp c_rot E_pair TotEng Press + 0 1.44 0.95677852 2.7038078 4.1294078 10.518912 + 100 2.5524145 2.801098 -0.37027046 2.1566199 0.84703874 + 200 2.6266386 2.7938164 -0.35322565 2.2471465 1.004886 + 300 2.9987557 2.9499545 -0.58917376 2.3795944 0.73081788 + 400 2.8557446 2.8208128 -0.39904801 2.4281391 0.91808964 + 500 2.4399047 2.8255746 -0.40056447 2.0149412 1.0538908 + 600 2.854258 2.9166789 -0.53424483 2.2914706 0.8117508 + 700 2.9593679 2.8231211 -0.40051715 2.5292571 1.1630889 + 800 2.7632972 2.9060855 -0.52075354 2.2149107 0.77106773 + 900 2.9905599 2.8869667 -0.49099386 2.4696604 0.69616823 + 1000 2.8470131 2.9005016 -0.51282147 2.3057215 0.68817329 +Loop time of 0.0666302 on 4 procs for 1000 steps with 100 atoms + +Performance: 6483542.632 tau/day, 15008.201 timesteps/s, 1.501 Matom-step/s +99.0% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.039208 | 0.042833 | 0.045871 | 1.2 | 64.29 +Neigh | 0.00065929 | 0.00071982 | 0.00076852 | 0.0 | 1.08 +Comm | 0.013998 | 0.017169 | 0.02087 | 1.9 | 25.77 +Output | 0.00018817 | 0.00020663 | 0.00025962 | 0.0 | 0.31 +Modify | 0.0035046 | 0.0035933 | 0.003701 | 0.1 | 5.39 +Other | | 0.002109 | | | 3.16 + +Nlocal: 25 ave 27 max 24 min +Histogram: 2 0 0 1 0 0 0 0 0 1 +Nghost: 42.25 ave 45 max 38 min +Histogram: 1 0 0 0 0 0 0 2 0 1 +Neighs: 92.25 ave 104 max 85 min +Histogram: 1 0 1 1 0 0 0 0 0 1 + +Total # of neighbors = 369 +Ave neighs/atom = 3.69 +Neighbor list builds = 174 +Dangerous builds = 0 + +#undump 1 +unfix 1 +unfix 2 + +# add small particles as hi density lattice + +region plane block INF INF INF INF -0.001 0.001 units box +lattice sq 120.0 +Lattice spacing in x,y,z = 0.091287093 0.091287093 0.091287093 +create_atoms 2 region plane +Created 85849 atoms + using lattice units in orthogonal box = (0 0 -1.3363062) to (26.726124 26.726124 1.3363062) + create_atoms CPU = 0.004 seconds + +set type 2 mass 0.01 +Setting atom values ... + 85849 settings made for mass +group small type 2 +85849 atoms in group small +velocity small create 1.0 593849 loop geom + +# delete overlaps +# must set 1-2 cutoff to non-zero value + +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 +pair_coeff 2 2 0.0 1.0 0.0 +pair_coeff 1 2 0.0 1.0 2.0 + +neigh_modify one 10000 + +delete_atoms overlap 1.6 small big +System init for delete_atoms ... +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 10000, page size: 100000 + master list distance cutoff = 2.8 + ghost atom cutoff = 2.8 + binsize = 1.4, bins = 20 20 2 + 2 neighbor lists, perpetual/occasional/extra = 1 1 0 + (1) command delete_atoms, occasional + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/2d + bin: standard + (2) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/2d + bin: standard +WARNING: Delete_atoms cutoff > minimum neighbor cutoff (src/delete_atoms.cpp:312) +Deleted 71060 atoms, new total = 14889 + +# SRD run + +reset_timestep 0 + +neighbor 0.3 multi +neigh_modify delay 0 every 1 check yes + +comm_modify mode multi group big vel yes +neigh_modify include big + +# no pairwise interactions with small particles + +pair_style gayberne 1.0 3.0 1.0 4.0 +pair_coeff 1 1 1.0 1.0 1 1 1 1 1 1 +pair_coeff 1 2 1.0 1.0 1 1 1 1 1 1 0.0 +pair_coeff 2 2 1.0 1.0 1 1 1 1 1 1 0.0 + +# use fix SRD to push small particles out from inside big ones +# if comment out, big particles won't see SRD particles + +timestep 0.0005 + +fix 1 big nve/asphere +fix 2 small srd 20 big 1.0 0.25 49894 shift yes 54979 collision noslip search 0.2 inside ignore exact no bounce 50 +fix 3 all enforce2d + +# diagnostics + +compute tbig big temp/asphere +variable pebig equal pe*atoms/count(big) +variable ebig equal etotal*atoms/count(big) +thermo_style custom step temp c_rot f_2[9] etotal v_pebig v_ebig press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] f_2[12] + +thermo_modify temp tbig +WARNING: Temperature for thermo pressure is not for group all (src/thermo.cpp:530) +thermo 1000 + +#dump 1 all custom 1000 dump.ellipsoid id type x y z c_0[*] +#dump_modify 1 colname c_0[1] quatw colname c_0[2] quati colname c_0[3] quatj colname c_0[4] quatk # colname c_0[5] shapex colname c_0[6] shapey colname c_0[7] shapez + +#dump 2 all image 1000 image.*.jpg type type zoom 1.6 +#dump_modify 2 pad 6 adiam 1 1 adiam 2 0.2 + +run 10000 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- neighbor multi command: doi:10.1016/j.cpc.2008.03.005, doi:10.1007/s40571-020-00361-2 + +@Article{Intveld08, + author = {in 't Veld, P. J. and S. J.~Plimpton and G. S. Grest}, + title = {Accurate and Efficient Methods for Modeling Colloidal + Mixtures in an Explicit Solvent using Molecular Dynamics}, + journal = {Comput.\ Phys.\ Commut.}, + year = 2008, + volume = 179, + pages = {320--329} +} + +@article{Shire2020, + author = {Shire, Tom and Hanley, Kevin J. and Stratford, Kevin}, + title = {{DEM} Simulations of Polydisperse Media: Efficient Contact + Detection Applied to Investigate the Quasi-Static Limit}, + journal = {Computational Particle Mechanics}, + year = {2020} +@article{Monti2022, + author = {Monti, Joseph M. and Clemmer, Joel T. and Srivastava, + Ishan and Silbert, Leonardo E. and Grest, Gary S. + and Lechman, Jeremy B.}, + title = {Large-scale frictionless jamming with power-law particle + size distributions}, + journal = {Phys. Rev. E}, + volume = {106} + issue = {3} + year = {2022} +} + +- fix srd command: doi:10.1063/1.3419070 + +@Article{Petersen10, + author = {M. K. Petersen and J. B. Lechman and S. J. Plimpton and + G. S. Grest and in 't Veld, P. J. and P. R. Schunk}, + title = {Mesoscale Hydrodynamics via Stochastic Rotation + Dynamics: Comparison with {L}ennard-{J}ones Fluid}, + journal = {J.~Chem.\ Phys.}, + year = 2010, + volume = 132, + pages = 174106 +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +SRD info: + SRD/big particles = 14789 100 + big particle diameter max/min = 3 1 + SRD temperature & lamda = 1 0.1 + SRD max distance & max velocity = 0.4 40 + SRD grid counts: 107 107 1 + SRD grid size: request, actual (xyz) = 0.25, 0.24977686 0.24977686 2.6726124 + SRD per actual grid cell = 1.9275711 + SRD viscosity = 0.68810145 + big/SRD mass density ratio = 1.3736715 + # of rescaled SRD velocities = 0 + ave/max small velocity = 13.30933 24.335888 + ave/max big velocity = 2.080284 5.0567191 +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 10000, page size: 100000 + master list distance cutoff = 4.3 + ghost atom cutoff = 4.3 + binsize = 26.726124, bins = 1 1 1 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair gayberne, perpetual + attributes: half, newton on + pair build: half/multi/atomonly/newton + stencil: half/multi/2d + bin: multi +Per MPI rank memory allocation (min/avg/max) = 16.89 | 16.9 | 16.91 Mbytes + Step Temp c_rot f_2[9] TotEng v_pebig v_ebig Press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] f_2[12] + 0 2.9005016 2.9005016 0 0.025582147 -0.51282147 3.8089259 0.89862191 0 0 0 0 0 0 0 0 0 0 0 0 + 1000 2.7138279 2.7138279 0.82437872 0.023781703 -0.50274582 3.5408578 1.6816604 13758 32 34 0 274 66564 11449 4238 0.82437872 24 50 0 + 2000 1.3183118 1.3183118 0.91362053 0.0077748292 -0.80669023 1.1575943 1.1678425 14118 23 23 0 414 66564 11449 4269 0.91362053 24 50 0 + 3000 1.3117991 1.3117991 0.96889539 0.0065133847 -0.98480276 0.96977785 0.51801823 14675 35 36 0 588 66564 11449 4291 0.96889539 26 50 0 + 4000 1.1034132 1.1034132 0.95899765 0.0042496304 -1.0113582 0.63272747 0.6382343 15146 38 38 0 776 66564 11449 4309 0.95899765 26 50 0 + 5000 1.0814177 1.0814177 1.0037423 0.0047549676 -0.90334518 0.70796713 0.76138491 15275 40 40 0 973 66564 11449 4285 1.0037423 26 50 0 + 6000 1.0515425 1.0515425 0.98728204 0.0041039749 -0.95575757 0.61104083 0.61253791 15685 34 34 0 1205 66564 11449 4328 0.98728204 26 50 0 + 7000 0.96229389 0.96229389 1.0146054 0.0031968892 -0.95783307 0.47598483 0.4469161 15944 43 43 0 1412 66564 11449 4391 1.0146054 27 50 0 + 8000 0.98798058 0.98798058 0.99692702 0.0037348841 -0.91600418 0.55608689 0.50558822 16250 43 43 0 1637 66564 11449 4330 0.99692702 27 50 0 + 9000 1.0120554 1.0120554 1.0099521 0.0039518454 -0.91957229 0.58839026 0.4092229 16367 43 44 0 1899 66564 11449 4309 1.0099521 27 50 0 + 10000 1.104152 1.104152 0.9993147 0.0053713858 -0.84544079 0.79974564 0.5119979 16331 50 50 0 2108 66564 11449 4353 0.9993147 27 50 0 +Loop time of 2.95619 on 4 procs for 10000 steps with 14889 atoms + +Performance: 146134.205 tau/day, 3382.736 timesteps/s, 50.366 Matom-step/s +99.2% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.48773 | 0.52727 | 0.62879 | 8.1 | 17.84 +Neigh | 0.0070094 | 0.0072204 | 0.0076255 | 0.3 | 0.24 +Comm | 0.12898 | 0.22553 | 0.265 | 11.8 | 7.63 +Output | 0.0005957 | 0.00064777 | 0.00075264 | 0.0 | 0.02 +Modify | 2.1317 | 2.1512 | 2.166 | 0.9 | 72.77 +Other | | 0.04427 | | | 1.50 + +Nlocal: 3722.25 ave 3968 max 3389 min +Histogram: 1 0 0 0 1 0 0 0 1 1 +Nghost: 39.75 ave 44 max 35 min +Histogram: 1 0 0 0 1 0 1 0 0 1 +Neighs: 101 ave 125 max 86 min +Histogram: 1 0 1 1 0 0 0 0 0 1 + +Total # of neighbors = 404 +Ave neighs/atom = 0.027134126 +Neighbor list builds = 500 +Dangerous builds = 0 +Total wall time: 0:00:03 diff --git a/examples/ASPHERE/ellipsoid/log.1Feb24.ellipsoid.mp.g++.1 b/examples/ASPHERE/ellipsoid/log.1Feb24.ellipsoid.mp.g++.1 new file mode 100644 index 0000000000..d7d2b9831f --- /dev/null +++ b/examples/ASPHERE/ellipsoid/log.1Feb24.ellipsoid.mp.g++.1 @@ -0,0 +1,347 @@ +LAMMPS (21 Nov 2023 - Development - patch_21Nov2023-665-g17f869bf5e) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# SRD viscosity demo - ellipsoids + +units lj +atom_style ellipsoid +atom_modify first big +dimension 2 + +# create big ellipsoidal particles + +lattice sq 0.14 +Lattice spacing in x,y,z = 2.6726124 2.6726124 2.6726124 +region box block 0 10 0 10 -0.5 0.5 +create_box 2 box +Created orthogonal box = (0 0 -1.3363062) to (26.726124 26.726124 1.3363062) + 1 by 1 by 1 MPI processor grid +create_atoms 1 region box +Created 100 atoms + using lattice units in orthogonal box = (0 0 -1.3363062) to (26.726124 26.726124 1.3363062) + create_atoms CPU = 0.000 seconds + +set type 1 mass 1.0 +Setting atom values ... + 100 settings made for mass +set type 1 shape 3.0 1.0 1.0 +Setting atom values ... + 100 settings made for shape +group big type 1 +100 atoms in group big +set group big quat/random 29898 +Setting atom values ... + 100 settings made for quat/random + +velocity big create 1.44 87287 loop geom + +# equilibrate big particles + +pair_style gayberne 1.0 3.0 1.0 4.0 +pair_coeff 1 1 1.0 1.0 1 1 1 1 1 1 +pair_coeff 1 2 1.0 1.0 1 1 1 1 1 1 0.0 +pair_coeff 2 2 1.0 1.0 1 1 1 1 1 1 0.0 + +neighbor 0.3 bin +neigh_modify delay 0 every 1 check yes + +fix 1 big nve/asphere +fix 2 all enforce2d + +compute rot big temp/asphere +compute 0 all property/atom quatw quati quatj quatk shapex shapey shapez + +#dump 1 all custom 10 dump.ellipsoid.equil id type x y z c_0[*] +#dump_modify 1 colname c_0[1] quatw colname c_0[2] quati colname c_0[3] quatj colname c_0[4] quatk # colname c_0[5] shapex colname c_0[6] shapey colname c_0[7] shapez + +thermo_style custom step temp c_rot epair etotal press +thermo 100 + +run 1000 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- pair gayberne command: doi:10.1063/1.3058435 + +@Article{Brown09, + author = {W. M. Brown and M. K. Petersen and S. J. Plimpton and G. S. Grest}, + title = {Liquid Crystal Nanodroplets in Solution}, + journal = {J.~Chem.\ Phys.}, + year = 2009, + volume = 130, + number = 4, + pages = {044901} +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 4.3 + ghost atom cutoff = 4.3 + binsize = 2.15, bins = 13 13 2 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair gayberne, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/2d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 4.611 | 4.611 | 4.611 Mbytes + Step Temp c_rot E_pair TotEng Press + 0 1.44 0.95677852 2.7038078 4.1294078 10.518912 + 100 2.5524145 2.801098 -0.37027046 2.1566199 0.84703874 + 200 2.6266386 2.7938164 -0.35322565 2.2471465 1.004886 + 300 2.9987557 2.9499545 -0.58917376 2.3795944 0.73081788 + 400 2.8557446 2.8208128 -0.39904801 2.4281391 0.91808964 + 500 2.4399047 2.8255746 -0.40056447 2.0149412 1.0538908 + 600 2.854258 2.9166789 -0.53424483 2.2914706 0.8117508 + 700 2.9593679 2.8231211 -0.40051715 2.5292571 1.1630889 + 800 2.7632972 2.9060854 -0.52075351 2.2149107 0.7710678 + 900 2.9905597 2.8869667 -0.49099378 2.4696603 0.69616841 + 1000 2.8470138 2.9005012 -0.51282088 2.3057228 0.68817567 +Loop time of 0.192844 on 1 procs for 1000 steps with 100 atoms + +Performance: 2240155.241 tau/day, 5185.545 timesteps/s, 518.554 katom-step/s +99.7% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.17225 | 0.17225 | 0.17225 | 0.0 | 89.32 +Neigh | 0.0025614 | 0.0025614 | 0.0025614 | 0.0 | 1.33 +Comm | 0.0024746 | 0.0024746 | 0.0024746 | 0.0 | 1.28 +Output | 0.0001406 | 0.0001406 | 0.0001406 | 0.0 | 0.07 +Modify | 0.014112 | 0.014112 | 0.014112 | 0.0 | 7.32 +Other | | 0.001306 | | | 0.68 + +Nlocal: 100 ave 100 max 100 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 77 ave 77 max 77 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 369 ave 369 max 369 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 369 +Ave neighs/atom = 3.69 +Neighbor list builds = 174 +Dangerous builds = 0 + +#undump 1 +unfix 1 +unfix 2 + +# add small particles as hi density lattice + +region plane block INF INF INF INF -0.001 0.001 units box +lattice sq 120.0 +Lattice spacing in x,y,z = 0.091287093 0.091287093 0.091287093 +create_atoms 2 region plane +Created 85849 atoms + using lattice units in orthogonal box = (0 0 -1.3363062) to (26.726124 26.726124 1.3363062) + create_atoms CPU = 0.015 seconds + +set type 2 mass 0.01 +Setting atom values ... + 85849 settings made for mass +group small type 2 +85849 atoms in group small +velocity small create 1.0 593849 loop geom + +# delete overlaps +# must set 1-2 cutoff to non-zero value + +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 +pair_coeff 2 2 0.0 1.0 0.0 +pair_coeff 1 2 0.0 1.0 2.0 + +neigh_modify one 10000 + +delete_atoms overlap 1.6 small big +System init for delete_atoms ... +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 10000, page size: 100000 + master list distance cutoff = 2.8 + ghost atom cutoff = 2.8 + binsize = 1.4, bins = 20 20 2 + 2 neighbor lists, perpetual/occasional/extra = 1 1 0 + (1) command delete_atoms, occasional + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/2d + bin: standard + (2) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/2d + bin: standard +WARNING: Delete_atoms cutoff > minimum neighbor cutoff (src/delete_atoms.cpp:312) +Deleted 71060 atoms, new total = 14889 + +# SRD run + +reset_timestep 0 + +neighbor 0.3 multi +neigh_modify delay 0 every 1 check yes + +comm_modify mode multi group big vel yes +neigh_modify include big + +# no pairwise interactions with small particles + +pair_style gayberne 1.0 3.0 1.0 4.0 +pair_coeff 1 1 1.0 1.0 1 1 1 1 1 1 +pair_coeff 1 2 1.0 1.0 1 1 1 1 1 1 0.0 +pair_coeff 2 2 1.0 1.0 1 1 1 1 1 1 0.0 + +# use fix SRD to push small particles out from inside big ones +# if comment out, big particles won't see SRD particles + +timestep 0.0005 + +fix 1 big nve/asphere +fix 2 small srd 20 big 1.0 0.25 49894 shift yes 54979 collision noslip search 0.2 inside ignore exact no bounce 50 +fix 3 small viscosity 20 x y 50 +fix 4 all enforce2d + +# diagnostics + +compute tbig big temp/asphere +variable pebig equal pe*atoms/count(big) +variable ebig equal etotal*atoms/count(big) +thermo_style custom step temp c_rot f_2[9] etotal v_pebig v_ebig press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] f_2[12] + +thermo_modify temp tbig +WARNING: Temperature for thermo pressure is not for group all (src/thermo.cpp:530) +thermo 1000 + +#dump 1 all custom 500 dump.ellipsoid id type x y z c_0[*] +#dump_modify 1 colname c_0[1] quatw colname c_0[2] quati colname c_0[3] quatj colname c_0[4] quatk # colname c_0[5] shapex colname c_0[6] shapey colname c_0[7] shapez + +#dump 1 all image 500 image.*.jpg type type zoom 1.6 +#dump_modify 1 pad 6 adiam 1 1 adiam 2 0.2 + +run 10000 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- neighbor multi command: doi:10.1016/j.cpc.2008.03.005, doi:10.1007/s40571-020-00361-2 + +@Article{Intveld08, + author = {in 't Veld, P. J. and S. J.~Plimpton and G. S. Grest}, + title = {Accurate and Efficient Methods for Modeling Colloidal + Mixtures in an Explicit Solvent using Molecular Dynamics}, + journal = {Comput.\ Phys.\ Commut.}, + year = 2008, + volume = 179, + pages = {320--329} +} + +@article{Shire2020, + author = {Shire, Tom and Hanley, Kevin J. and Stratford, Kevin}, + title = {{DEM} Simulations of Polydisperse Media: Efficient Contact + Detection Applied to Investigate the Quasi-Static Limit}, + journal = {Computational Particle Mechanics}, + year = {2020} +@article{Monti2022, + author = {Monti, Joseph M. and Clemmer, Joel T. and Srivastava, + Ishan and Silbert, Leonardo E. and Grest, Gary S. + and Lechman, Jeremy B.}, + title = {Large-scale frictionless jamming with power-law particle + size distributions}, + journal = {Phys. Rev. E}, + volume = {106} + issue = {3} + year = {2022} +} + +- fix srd command: doi:10.1063/1.3419070 + +@Article{Petersen10, + author = {M. K. Petersen and J. B. Lechman and S. J. Plimpton and + G. S. Grest and in 't Veld, P. J. and P. R. Schunk}, + title = {Mesoscale Hydrodynamics via Stochastic Rotation + Dynamics: Comparison with {L}ennard-{J}ones Fluid}, + journal = {J.~Chem.\ Phys.}, + year = 2010, + volume = 132, + pages = 174106 +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +SRD info: + SRD/big particles = 14789 100 + big particle diameter max/min = 3 1 + SRD temperature & lamda = 1 0.1 + SRD max distance & max velocity = 0.4 40 + SRD grid counts: 107 107 1 + SRD grid size: request, actual (xyz) = 0.25, 0.24977686 0.24977686 2.6726124 + SRD per actual grid cell = 1.9275711 + SRD viscosity = 0.68810145 + big/SRD mass density ratio = 1.3736715 + # of rescaled SRD velocities = 0 + ave/max small velocity = 13.30933 24.335888 + ave/max big velocity = 2.0802836 5.05672 +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 10000, page size: 100000 + master list distance cutoff = 4.3 + ghost atom cutoff = 4.3 + binsize = 26.726124, bins = 1 1 1 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair gayberne, perpetual + attributes: half, newton on + pair build: half/multi/atomonly/newton + stencil: half/multi/2d + bin: multi +Per MPI rank memory allocation (min/avg/max) = 43.23 | 43.23 | 43.23 Mbytes + Step Temp c_rot f_2[9] TotEng v_pebig v_ebig Press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] f_2[12] + 0 2.9005012 2.9005012 0 0.025582147 -0.51282088 3.8089259 0.8986241 0 0 0 0 0 0 0 0 0 0 0 0 + 1000 2.3102693 2.3102693 0.82371999 0.019779507 -0.49733043 2.9449709 1.9807143 13954 30 30 0 277 38416 11449 4255 0.82371999 15 50 0 + 2000 1.5312119 1.5312119 0.90846884 0.008532096 -1.011162 1.2703438 0.58038663 14523 37 37 0 439 38416 11449 4257 0.90846884 20 50 0 + 3000 1.3603443 1.3603443 0.95241399 0.0085403252 -0.75534393 1.271569 1.2262133 14864 34 35 0 599 38416 11449 4287 0.95241399 20 50 0 + 4000 2.2408861 2.2408861 0.99089404 0.016876315 -0.82620566 2.5127146 1.2664088 15457 35 35 0 809 38416 11449 4272 0.99089404 21 50 0 + 5000 1.7110067 1.7110067 0.99729333 0.011146301 -0.88982716 1.6595728 0.97334407 15555 36 36 0 1026 38416 11449 4324 0.99729333 24 50 0 + 6000 1.684666 1.684666 1.0235606 0.009751253 -1.0582882 1.4518641 0.62435255 15752 45 46 0 1256 38416 11449 4303 1.0235606 24 50 0 + 7000 2.1142261 2.1142261 1.0160206 0.014786886 -0.94857757 2.2016194 0.7761903 16144 30 30 0 1492 38416 11449 4401 1.0160206 27 50 0 + 8000 2.5622926 2.5622926 1.0125365 0.019933518 -0.84991443 2.9679015 0.93716383 16302 43 43 0 1720 38416 11449 4346 1.0125365 27 50 0 + 9000 2.6593623 2.6593623 1.0110535 0.020725053 -0.87669675 3.0857531 0.97818336 16856 44 44 0 2000 38416 11449 4298 1.0110535 30 50 0 + 10000 2.7567851 2.7567851 1.0379053 0.021598993 -0.8917358 3.2158741 0.74950846 16770 50 53 0 2284 38416 11449 4316 1.0379053 30 50 0 +Loop time of 9.02679 on 1 procs for 10000 steps with 14889 atoms + +Performance: 47857.551 tau/day, 1107.814 timesteps/s, 16.494 Matom-step/s +99.8% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 1.8454 | 1.8454 | 1.8454 | 0.0 | 20.44 +Neigh | 0.018708 | 0.018708 | 0.018708 | 0.0 | 0.21 +Comm | 0.059853 | 0.059853 | 0.059853 | 0.0 | 0.66 +Output | 0.00081453 | 0.00081453 | 0.00081453 | 0.0 | 0.01 +Modify | 7.0469 | 7.0469 | 7.0469 | 0.0 | 78.07 +Other | | 0.05507 | | | 0.61 + +Nlocal: 14889 ave 14889 max 14889 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 75 ave 75 max 75 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 382 ave 382 max 382 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 382 +Ave neighs/atom = 0.025656525 +Neighbor list builds = 500 +Dangerous builds = 0 +Total wall time: 0:00:11 diff --git a/examples/ASPHERE/ellipsoid/log.1Feb24.ellipsoid.mp.g++.4 b/examples/ASPHERE/ellipsoid/log.1Feb24.ellipsoid.mp.g++.4 new file mode 100644 index 0000000000..b5a10d0871 --- /dev/null +++ b/examples/ASPHERE/ellipsoid/log.1Feb24.ellipsoid.mp.g++.4 @@ -0,0 +1,347 @@ +LAMMPS (21 Nov 2023 - Development - patch_21Nov2023-665-g17f869bf5e) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# SRD viscosity demo - ellipsoids + +units lj +atom_style ellipsoid +atom_modify first big +dimension 2 + +# create big ellipsoidal particles + +lattice sq 0.14 +Lattice spacing in x,y,z = 2.6726124 2.6726124 2.6726124 +region box block 0 10 0 10 -0.5 0.5 +create_box 2 box +Created orthogonal box = (0 0 -1.3363062) to (26.726124 26.726124 1.3363062) + 2 by 2 by 1 MPI processor grid +create_atoms 1 region box +Created 100 atoms + using lattice units in orthogonal box = (0 0 -1.3363062) to (26.726124 26.726124 1.3363062) + create_atoms CPU = 0.001 seconds + +set type 1 mass 1.0 +Setting atom values ... + 100 settings made for mass +set type 1 shape 3.0 1.0 1.0 +Setting atom values ... + 100 settings made for shape +group big type 1 +100 atoms in group big +set group big quat/random 29898 +Setting atom values ... + 100 settings made for quat/random + +velocity big create 1.44 87287 loop geom + +# equilibrate big particles + +pair_style gayberne 1.0 3.0 1.0 4.0 +pair_coeff 1 1 1.0 1.0 1 1 1 1 1 1 +pair_coeff 1 2 1.0 1.0 1 1 1 1 1 1 0.0 +pair_coeff 2 2 1.0 1.0 1 1 1 1 1 1 0.0 + +neighbor 0.3 bin +neigh_modify delay 0 every 1 check yes + +fix 1 big nve/asphere +fix 2 all enforce2d + +compute rot big temp/asphere +compute 0 all property/atom quatw quati quatj quatk shapex shapey shapez + +#dump 1 all custom 10 dump.ellipsoid.equil id type x y z c_0[*] +#dump_modify 1 colname c_0[1] quatw colname c_0[2] quati colname c_0[3] quatj colname c_0[4] quatk # colname c_0[5] shapex colname c_0[6] shapey colname c_0[7] shapez + +thermo_style custom step temp c_rot epair etotal press +thermo 100 + +run 1000 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- pair gayberne command: doi:10.1063/1.3058435 + +@Article{Brown09, + author = {W. M. Brown and M. K. Petersen and S. J. Plimpton and G. S. Grest}, + title = {Liquid Crystal Nanodroplets in Solution}, + journal = {J.~Chem.\ Phys.}, + year = 2009, + volume = 130, + number = 4, + pages = {044901} +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 4.3 + ghost atom cutoff = 4.3 + binsize = 2.15, bins = 13 13 2 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair gayberne, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/2d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 4.61 | 4.61 | 4.61 Mbytes + Step Temp c_rot E_pair TotEng Press + 0 1.44 0.95677852 2.7038078 4.1294078 10.518912 + 100 2.5524145 2.801098 -0.37027046 2.1566199 0.84703874 + 200 2.6266386 2.7938164 -0.35322565 2.2471465 1.004886 + 300 2.9987557 2.9499545 -0.58917376 2.3795944 0.73081788 + 400 2.8557446 2.8208128 -0.39904801 2.4281391 0.91808964 + 500 2.4399047 2.8255746 -0.40056447 2.0149412 1.0538908 + 600 2.854258 2.9166789 -0.53424483 2.2914706 0.8117508 + 700 2.9593679 2.8231211 -0.40051715 2.5292571 1.1630889 + 800 2.7632972 2.9060855 -0.52075354 2.2149107 0.77106773 + 900 2.9905599 2.8869667 -0.49099386 2.4696604 0.69616823 + 1000 2.8470131 2.9005016 -0.51282147 2.3057215 0.68817329 +Loop time of 0.0905036 on 4 procs for 1000 steps with 100 atoms + +Performance: 4773291.472 tau/day, 11049.286 timesteps/s, 1.105 Matom-step/s +99.3% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.039039 | 0.053443 | 0.065528 | 5.0 | 59.05 +Neigh | 0.00068257 | 0.00086692 | 0.0010442 | 0.0 | 0.96 +Comm | 0.016567 | 0.028689 | 0.043189 | 6.8 | 31.70 +Output | 0.00016989 | 0.00018594 | 0.0002316 | 0.0 | 0.21 +Modify | 0.0035809 | 0.0043052 | 0.0050755 | 1.0 | 4.76 +Other | | 0.003013 | | | 3.33 + +Nlocal: 25 ave 27 max 24 min +Histogram: 2 0 0 1 0 0 0 0 0 1 +Nghost: 42.25 ave 45 max 38 min +Histogram: 1 0 0 0 0 0 0 2 0 1 +Neighs: 92.25 ave 104 max 85 min +Histogram: 1 0 1 1 0 0 0 0 0 1 + +Total # of neighbors = 369 +Ave neighs/atom = 3.69 +Neighbor list builds = 174 +Dangerous builds = 0 + +#undump 1 +unfix 1 +unfix 2 + +# add small particles as hi density lattice + +region plane block INF INF INF INF -0.001 0.001 units box +lattice sq 120.0 +Lattice spacing in x,y,z = 0.091287093 0.091287093 0.091287093 +create_atoms 2 region plane +Created 85849 atoms + using lattice units in orthogonal box = (0 0 -1.3363062) to (26.726124 26.726124 1.3363062) + create_atoms CPU = 0.007 seconds + +set type 2 mass 0.01 +Setting atom values ... + 85849 settings made for mass +group small type 2 +85849 atoms in group small +velocity small create 1.0 593849 loop geom + +# delete overlaps +# must set 1-2 cutoff to non-zero value + +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 +pair_coeff 2 2 0.0 1.0 0.0 +pair_coeff 1 2 0.0 1.0 2.0 + +neigh_modify one 10000 + +delete_atoms overlap 1.6 small big +System init for delete_atoms ... +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 10000, page size: 100000 + master list distance cutoff = 2.8 + ghost atom cutoff = 2.8 + binsize = 1.4, bins = 20 20 2 + 2 neighbor lists, perpetual/occasional/extra = 1 1 0 + (1) command delete_atoms, occasional + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/2d + bin: standard + (2) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/2d + bin: standard +WARNING: Delete_atoms cutoff > minimum neighbor cutoff (src/delete_atoms.cpp:312) +Deleted 71060 atoms, new total = 14889 + +# SRD run + +reset_timestep 0 + +neighbor 0.3 multi +neigh_modify delay 0 every 1 check yes + +comm_modify mode multi group big vel yes +neigh_modify include big + +# no pairwise interactions with small particles + +pair_style gayberne 1.0 3.0 1.0 4.0 +pair_coeff 1 1 1.0 1.0 1 1 1 1 1 1 +pair_coeff 1 2 1.0 1.0 1 1 1 1 1 1 0.0 +pair_coeff 2 2 1.0 1.0 1 1 1 1 1 1 0.0 + +# use fix SRD to push small particles out from inside big ones +# if comment out, big particles won't see SRD particles + +timestep 0.0005 + +fix 1 big nve/asphere +fix 2 small srd 20 big 1.0 0.25 49894 shift yes 54979 collision noslip search 0.2 inside ignore exact no bounce 50 +fix 3 small viscosity 20 x y 50 +fix 4 all enforce2d + +# diagnostics + +compute tbig big temp/asphere +variable pebig equal pe*atoms/count(big) +variable ebig equal etotal*atoms/count(big) +thermo_style custom step temp c_rot f_2[9] etotal v_pebig v_ebig press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] f_2[12] + +thermo_modify temp tbig +WARNING: Temperature for thermo pressure is not for group all (src/thermo.cpp:530) +thermo 1000 + +#dump 1 all custom 500 dump.ellipsoid id type x y z c_0[*] +#dump_modify 1 colname c_0[1] quatw colname c_0[2] quati colname c_0[3] quatj colname c_0[4] quatk # colname c_0[5] shapex colname c_0[6] shapey colname c_0[7] shapez + +#dump 1 all image 500 image.*.jpg type type zoom 1.6 +#dump_modify 1 pad 6 adiam 1 1 adiam 2 0.2 + +run 10000 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- neighbor multi command: doi:10.1016/j.cpc.2008.03.005, doi:10.1007/s40571-020-00361-2 + +@Article{Intveld08, + author = {in 't Veld, P. J. and S. J.~Plimpton and G. S. Grest}, + title = {Accurate and Efficient Methods for Modeling Colloidal + Mixtures in an Explicit Solvent using Molecular Dynamics}, + journal = {Comput.\ Phys.\ Commut.}, + year = 2008, + volume = 179, + pages = {320--329} +} + +@article{Shire2020, + author = {Shire, Tom and Hanley, Kevin J. and Stratford, Kevin}, + title = {{DEM} Simulations of Polydisperse Media: Efficient Contact + Detection Applied to Investigate the Quasi-Static Limit}, + journal = {Computational Particle Mechanics}, + year = {2020} +@article{Monti2022, + author = {Monti, Joseph M. and Clemmer, Joel T. and Srivastava, + Ishan and Silbert, Leonardo E. and Grest, Gary S. + and Lechman, Jeremy B.}, + title = {Large-scale frictionless jamming with power-law particle + size distributions}, + journal = {Phys. Rev. E}, + volume = {106} + issue = {3} + year = {2022} +} + +- fix srd command: doi:10.1063/1.3419070 + +@Article{Petersen10, + author = {M. K. Petersen and J. B. Lechman and S. J. Plimpton and + G. S. Grest and in 't Veld, P. J. and P. R. Schunk}, + title = {Mesoscale Hydrodynamics via Stochastic Rotation + Dynamics: Comparison with {L}ennard-{J}ones Fluid}, + journal = {J.~Chem.\ Phys.}, + year = 2010, + volume = 132, + pages = 174106 +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +SRD info: + SRD/big particles = 14789 100 + big particle diameter max/min = 3 1 + SRD temperature & lamda = 1 0.1 + SRD max distance & max velocity = 0.4 40 + SRD grid counts: 107 107 1 + SRD grid size: request, actual (xyz) = 0.25, 0.24977686 0.24977686 2.6726124 + SRD per actual grid cell = 1.9275711 + SRD viscosity = 0.68810145 + big/SRD mass density ratio = 1.3736715 + # of rescaled SRD velocities = 0 + ave/max small velocity = 13.30933 24.335888 + ave/max big velocity = 2.080284 5.0567191 +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 10000, page size: 100000 + master list distance cutoff = 4.3 + ghost atom cutoff = 4.3 + binsize = 26.726124, bins = 1 1 1 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair gayberne, perpetual + attributes: half, newton on + pair build: half/multi/atomonly/newton + stencil: half/multi/2d + bin: multi +Per MPI rank memory allocation (min/avg/max) = 16.89 | 16.9 | 16.91 Mbytes + Step Temp c_rot f_2[9] TotEng v_pebig v_ebig Press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] f_2[12] + 0 2.9005016 2.9005016 0 0.025582147 -0.51282147 3.8089259 0.89862191 0 0 0 0 0 0 0 0 0 0 0 0 + 1000 2.5269102 2.5269102 0.8207596 0.022784455 -0.37271861 3.3923775 2.0963085 13925 34 34 0 322 66564 11449 4235 0.8207596 24 50 0 + 2000 1.3685596 1.3685596 0.89115879 0.0089112146 -0.71236311 1.3267907 1.3970875 14444 25 25 0 454 66564 11449 4278 0.89115879 25 50 0 + 3000 1.5234001 1.5234001 0.9828293 0.0090168318 -0.92735003 1.3425161 0.70104224 14946 37 37 0 608 66564 11449 4331 0.9828293 27 50 0 + 4000 2.2536932 2.2536932 0.97648579 0.017005211 -0.82609701 2.5319058 1.190307 15428 43 43 0 827 66564 11449 4346 0.97648579 32 50 0 + 5000 1.8106358 1.8106358 1.0143347 0.012032652 -0.90630586 1.7915415 0.83451531 15438 26 26 0 1039 66564 11449 4314 1.0143347 32 50 0 + 6000 1.9880605 1.9880605 1.0142917 0.013767418 -0.91237924 2.0498309 0.87383026 15688 37 37 0 1279 66564 11449 4353 1.0142917 32 50 0 + 7000 2.4772098 2.4772098 0.99457682 0.018062012 -1.0017896 2.689253 0.74369504 15723 38 38 0 1521 66564 11449 4293 0.99457682 32 50 0 + 8000 2.5749419 2.5749419 1.0337514 0.019908918 -0.87242464 2.9642389 1.0460672 15932 33 34 0 1805 66564 11449 4320 1.0337514 32 50 0 + 9000 2.4877578 2.4877578 1.0366259 0.019125113 -0.85922105 2.847538 0.95616808 16292 52 53 0 2099 66564 11449 4291 1.0366259 33 50 0 + 10000 2.8498311 2.8498311 1.0117104 0.022669267 -0.87102125 3.3752271 0.98313087 16736 38 38 0 2415 66564 11449 4366 1.0117104 35 50 0 +Loop time of 3.0339 on 4 procs for 10000 steps with 14889 atoms + +Performance: 142390.919 tau/day, 3296.086 timesteps/s, 49.075 Matom-step/s +99.1% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.46168 | 0.52303 | 0.69055 | 13.4 | 17.24 +Neigh | 0.0068493 | 0.0072892 | 0.0081958 | 0.6 | 0.24 +Comm | 0.12806 | 0.2911 | 0.34961 | 17.5 | 9.59 +Output | 0.00055286 | 0.00057977 | 0.00065772 | 0.0 | 0.02 +Modify | 2.1454 | 2.1674 | 2.1833 | 0.9 | 71.44 +Other | | 0.04447 | | | 1.47 + +Nlocal: 3722.25 ave 4163 max 3210 min +Histogram: 1 0 0 0 0 1 1 0 0 1 +Nghost: 46.25 ave 49 max 43 min +Histogram: 1 0 0 1 0 0 0 0 1 1 +Neighs: 102.5 ave 143 max 79 min +Histogram: 2 0 0 0 1 0 0 0 0 1 + +Total # of neighbors = 410 +Ave neighs/atom = 0.027537108 +Neighbor list builds = 500 +Dangerous builds = 0 +Total wall time: 0:00:03 diff --git a/examples/ASPHERE/line/in.line b/examples/ASPHERE/line/in.line index 815eacfa35..f4c672f19c 100644 --- a/examples/ASPHERE/line/in.line +++ b/examples/ASPHERE/line/in.line @@ -1,44 +1,44 @@ # Aspherical shear demo - 2d line box and triangle mixture, implicit solvent -units lj -atom_style line -dimension 2 +units lj +atom_style line +dimension 2 -read_data data.line +read_data data.line -velocity all create 1.44 320984 loop geom +velocity all create 1.44 320984 loop geom -neighbor 0.3 bin -neigh_modify delay 0 every 1 check yes -neigh_modify exclude molecule/intra all +neighbor 0.3 bin +neigh_modify delay 0 every 1 check yes +neigh_modify exclude molecule/intra all -pair_style line/lj 2.5 -pair_coeff * * 1.0 1.0 1.0 0.25 2.5 +pair_style line/lj 2.5 +pair_coeff * * 1.0 1.0 1.0 0.25 2.5 -fix 2 all rigid molecule langevin 2.0 2.0 1.0 492983 +fix 2 all rigid molecule langevin 2.0 2.0 1.0 492983 -fix 3 all deform 1 x scale 0.3 y scale 0.3 -fix 4 all enforce2d +fix 3 all deform 1 x scale 0.3 y scale 0.3 +fix 4 all enforce2d -compute 10 all property/atom end1x end1y end2x end2y +compute 10 all property/atom end1x end1y end2x end2y -#dump 1 all custom 500 dump1.atom id type x y z ix iy iz -#dump 2 all custom 500 dump1.line id type & -# c_10[1] c_10[2] c_10[3] c_10[4] +#dump 1 all custom 500 dump1.atom id type x y z ix iy iz +#dump 2 all custom 500 dump1.line id type & +# c_10[1] c_10[2] c_10[3] c_10[4] -timestep 0.004 +timestep 0.004 -compute 1 all erotate/asphere -compute 2 all ke -compute 3 all pe -variable toteng equal (c_1+c_2+c_3)/atoms +compute 1 all erotate/asphere +compute 2 all ke +compute 3 all pe +variable toteng equal (c_1+c_2+c_3)/atoms compute_modify thermo_temp extra/dof -350 -thermo 1000 -thermo_style custom step f_2 pe ke c_1 c_2 c_3 v_toteng +thermo 1000 +thermo_style custom step f_2 pe ke c_1 c_2 c_3 v_toteng -run 10000 +run 10000 #undump 1 #undump 2 @@ -46,10 +46,10 @@ unfix 3 change_box all triclinic -#dump 1 all custom 500 dump2.atom id type x y z ix iy iz -#dump 2 all custom 500 dump2.line id type & -# c_10[1] c_10[2] c_10[3] c_10[4] +#dump 1 all custom 500 dump2.atom id type x y z ix iy iz +#dump 2 all custom 500 dump2.line id type & +# c_10[1] c_10[2] c_10[3] c_10[4] -fix 3 all deform 1 xy erate 0.01 units box +fix 3 all deform 1 xy erate 0.01 units box -run 100000 +run 10000 diff --git a/examples/ASPHERE/line/in.line.srd b/examples/ASPHERE/line/in.line.srd index a32bde0b76..6a99ce6bb1 100644 --- a/examples/ASPHERE/line/in.line.srd +++ b/examples/ASPHERE/line/in.line.srd @@ -1,107 +1,107 @@ # Aspherical shear demo - 2d line boxes, solvated by SRD particles -units lj -atom_style line -atom_modify first big -dimension 2 +units lj +atom_style line +atom_modify first big +dimension 2 -read_data data.line.srd +read_data data.line.srd # add small particles as hi density lattice -lattice sq 0.4 -region plane block INF INF INF INF -0.001 0.001 -lattice sq 10.0 -create_atoms 2 region plane +lattice sq 0.4 +region plane block INF INF INF INF -0.001 0.001 +lattice sq 10.0 +create_atoms 2 region plane -group big type 1 -group small type 2 -set group small mass 0.01 +group big type 1 +group small type 2 +set group small mass 0.01 # delete overlaps # must set 1-2 cutoff to non-zero value -pair_style lj/cut 1.5 -pair_coeff 1 1 1.0 1.0 -pair_coeff 2 2 0.0 1.0 0.0 -pair_coeff 1 2 0.0 1.0 +pair_style lj/cut 1.5 +pair_coeff 1 1 1.0 1.0 +pair_coeff 2 2 0.0 1.0 0.0 +pair_coeff 1 2 0.0 1.0 -delete_atoms overlap 1.5 small big +delete_atoms overlap 1.5 small big # SRD run -reset_timestep 0 +reset_timestep 0 -velocity small create 1.44 87287 loop geom +velocity small create 1.44 87287 loop geom -neighbor 0.3 multi -neigh_modify delay 0 every 1 check yes -neigh_modify exclude molecule/intra big include big +neighbor 0.3 multi +neigh_modify delay 0 every 1 check yes +neigh_modify exclude molecule/intra big include big -comm_modify mode multi group big vel yes -neigh_modify include big +comm_modify mode multi group big vel yes +neigh_modify include big # no pairwise interactions with small particles -pair_style line/lj 2.5 -pair_coeff 1 1 1.0 1.0 1.0 1.0 2.5 -pair_coeff 2 2 0.0 0.0 0.0 1.0 0.0 -pair_coeff 1 2 1.0 0.0 0.0 1.0 0.0 +pair_style line/lj 2.5 +pair_coeff 1 1 1.0 1.0 1.0 1.0 2.5 +pair_coeff 2 2 0.0 0.0 0.0 1.0 0.0 +pair_coeff 1 2 1.0 0.0 0.0 1.0 0.0 # use fix SRD to push small particles out from inside big ones # if comment out, big particles won't see SRD particles -timestep 0.001 +timestep 0.001 -fix 1 big rigid molecule -fix 2 small srd 20 big 1.0 0.25 49894 & - search 0.2 cubic warn 0.0001 shift yes 49829 & - overlap yes collision noslip +fix 1 big rigid molecule +fix 2 small srd 20 big 1.0 0.25 49894 & + search 0.2 cubic warn 0.0001 shift yes 49829 & + overlap yes collision noslip -fix 3 all deform 1 x scale 0.35 y scale 0.35 -fix 4 all enforce2d +fix 3 all deform 1 x scale 0.35 y scale 0.35 +fix 4 all enforce2d # diagnostics -compute tsmall small temp/deform -compute tbig big temp -variable pebig equal pe*atoms/count(big) -variable ebig equal etotal*atoms/count(big) +compute tsmall small temp/deform +compute tbig big temp +variable pebig equal pe*atoms/count(big) +variable ebig equal etotal*atoms/count(big) compute_modify tbig extra/dof -350 -compute 1 big erotate/asphere -compute 2 all ke -compute 3 all pe -variable toteng equal (c_1+c_2+c_3)/atoms +compute 1 big erotate/asphere +compute 2 all ke +compute 3 all pe +variable toteng equal (c_1+c_2+c_3)/atoms -thermo 1000 -thermo_style custom step c_tsmall f_2[9] c_1 etotal & - v_pebig v_ebig press -thermo_modify temp tbig +thermo 1000 +thermo_style custom step c_tsmall f_2[9] c_1 etotal & + v_pebig v_ebig press +thermo_modify temp tbig -compute 10 big property/atom end1x end1y end2x end2y +compute 10 big property/atom end1x end1y end2x end2y -#dump 1 all custom 500 dump1.atom.srd id type x y z ix iy iz -#dump 2 all custom 500 dump1.line.srd id type & -# c_10[1] c_10[2] c_10[3] c_10[4] +#dump 1 all custom 500 dump1.atom.srd id type x y z ix iy iz +#dump 2 all custom 500 dump1.line.srd id type & +# c_10[1] c_10[2] c_10[3] c_10[4] -run 10000 +run 10000 #undump 1 #undump 2 -unfix 3 +unfix 3 change_box all triclinic -fix 2 small srd 20 big 1.0 0.25 49894 & - search 0.2 cubic warn 0.0001 shift yes 49829 & - overlap yes collision noslip tstat yes +fix 2 small srd 20 big 1.0 0.25 49894 & + search 0.2 cubic warn 0.0001 shift yes 49829 & + overlap yes collision noslip tstat yes -#dump 1 all custom 500 dump2.atom.srd id type x y z ix iy iz -#dump 2 all custom 500 dump2.line.srd id type & -# c_10[1] c_10[2] c_10[3] c_10[4] +#dump 1 all custom 500 dump2.atom.srd id type x y z ix iy iz +#dump 2 all custom 500 dump2.line.srd id type & +# c_10[1] c_10[2] c_10[3] c_10[4] -fix 3 all deform 1 xy erate 0.05 units box remap v +fix 3 all deform 1 xy erate 0.05 units box remap v -run 40000 +run 40000 diff --git a/examples/ASPHERE/poly/in.poly b/examples/ASPHERE/poly/in.poly index 68bd2a6bbc..41bec14075 100644 --- a/examples/ASPHERE/poly/in.poly +++ b/examples/ASPHERE/poly/in.poly @@ -1,114 +1,114 @@ # SRD diffusion demo - poydisperse spheres -units lj -atom_style sphere -atom_modify first big -dimension 2 +units lj +atom_style sphere +atom_modify first big +dimension 2 # create big particles with 3 different types and diameters -lattice sq 0.3 -region box block 0 10 0 10 -0.5 0.5 -create_box 4 box -create_atoms 1 region box +lattice sq 0.3 +region box block 0 10 0 10 -0.5 0.5 +create_box 4 box +create_atoms 1 region box -group big type 1 -set group big type/fraction 2 0.33 394895 -set group big type/fraction 3 0.5 989894 -group big type 2 3 +group big type 1 +set group big type/fraction 2 0.33 394895 +set group big type/fraction 3 0.5 989894 +group big type 2 3 -set type 1*3 mass 1.0 -velocity big create 1.44 87287 loop geom +set type 1*3 mass 1.0 +velocity big create 1.44 87287 loop geom # equilibrate big particles, repulsive only to prevent aggregation -pair_style lj/cut 1.12 -pair_coeff 1 1 1.0 1.0 1.12 -pair_coeff 2 2 1.0 2.0 2.24 -pair_coeff 3 3 1.0 1.5 1.68 -pair_coeff 4 4 0.0 1.0 0.0 +pair_style lj/cut 1.12 +pair_coeff 1 1 1.0 1.0 1.12 +pair_coeff 2 2 1.0 2.0 2.24 +pair_coeff 3 3 1.0 1.5 1.68 +pair_coeff 4 4 0.0 1.0 0.0 -neighbor 0.3 bin -neigh_modify delay 0 every 1 check yes +neighbor 0.3 bin +neigh_modify delay 0 every 1 check yes -fix 1 big nve -fix 2 all enforce2d +fix 1 big nve +fix 2 all enforce2d -#dump 1 all atom 10 dump.poly.equil +#dump 1 all atom 10 dump.poly.equil -run 1000 +run 1000 -#undump 1 -unfix 1 -unfix 2 +#undump 1 +unfix 1 +unfix 2 # add small particles as hi density lattice -region plane block INF INF INF INF -0.001 0.001 units box -lattice sq 250.0 -create_atoms 4 region plane +region plane block INF INF INF INF -0.001 0.001 units box +lattice sq 250.0 +create_atoms 4 region plane -set type 4 mass 0.1 -group small type 4 -velocity small create 1.0 593849 loop geom +set type 4 mass 0.1 +group small type 4 +velocity small create 1.0 593849 loop geom # delete overlaps # must set *-4 cutoffs to non-zero values -pair_style lj/cut 2.5 -pair_coeff 1 1 1.0 1.0 -pair_coeff 2 2 1.0 2.0 -pair_coeff 3 3 1.0 1.5 -pair_coeff 1 4 0.0 1.0 0.5 -pair_coeff 2 4 0.0 1.0 1.0 -pair_coeff 3 4 0.0 1.0 0.75 -pair_coeff 4 4 0.0 1.0 0.0 +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 +pair_coeff 2 2 1.0 2.0 +pair_coeff 3 3 1.0 1.5 +pair_coeff 1 4 0.0 1.0 0.5 +pair_coeff 2 4 0.0 1.0 1.0 +pair_coeff 3 4 0.0 1.0 0.75 +pair_coeff 4 4 0.0 1.0 0.0 -delete_atoms overlap 1.0 small big +delete_atoms overlap 1.0 small big # SRD run -reset_timestep 0 +reset_timestep 0 -neighbor 0.3 multi -neigh_modify delay 0 every 1 check yes +neighbor 0.3 multi +neigh_modify delay 0 every 1 check yes -comm_modify mode multi group big vel yes -neigh_modify include big +comm_modify mode multi group big vel yes +neigh_modify include big # no pairwise interactions with small particles -pair_style lj/cut 1.12 -pair_coeff 1 1 1.0 1.0 1.12 -pair_coeff 2 2 1.0 2.0 2.24 -pair_coeff 3 3 1.0 1.5 1.68 -pair_coeff 4 4 0.0 1.0 0.0 +pair_style lj/cut 1.12 +pair_coeff 1 1 1.0 1.0 1.12 +pair_coeff 2 2 1.0 2.0 2.24 +pair_coeff 3 3 1.0 1.5 1.68 +pair_coeff 4 4 0.0 1.0 0.0 # use fix SRD to push small particles out from inside big ones # if comment out, big particles won't see SRD particles -timestep 0.001 +timestep 0.001 -fix 1 big nve -fix 2 small srd 20 big 1.0 0.25 49894 shift yes 54979 & +fix 1 big nve +fix 2 small srd 20 big 1.0 0.25 49894 shift yes 54979 & search 0.2 inside ignore -fix 3 all enforce2d +fix 3 all enforce2d # diagnostics -compute tbig big temp/sphere -variable pebig equal pe*atoms/count(big) -variable ebig equal etotal*atoms/count(big) -thermo_style custom step temp f_2[8] etotal v_pebig v_ebig press & - f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] & - f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] +compute tbig big temp/sphere +variable pebig equal pe*atoms/count(big) +variable ebig equal etotal*atoms/count(big) +thermo_style custom step temp f_2[8] etotal v_pebig v_ebig press & + f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] & + f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] -thermo_modify temp tbig -thermo 1000 +thermo_modify temp tbig +thermo 1000 -#dump 1 all atom 1000 dump.poly +#dump 1 all atom 1000 dump.poly -#dump 1 all image 1000 image.*.jpg type type zoom 1.6 -#dump_modify 1 pad 6 adiam 1 1 adiam 2 2.0 adiam 3 1.5 adiam 4 0.1 +#dump 1 all image 1000 image.*.jpg type type zoom 1.6 +#dump_modify 1 pad 6 adiam 1 1 adiam 2 2.0 adiam 3 1.5 adiam 4 0.1 -run 100000 +run 10000 diff --git a/examples/ASPHERE/poly/in.poly.mp b/examples/ASPHERE/poly/in.poly.mp index 8fa5d24a55..259ef2ab48 100644 --- a/examples/ASPHERE/poly/in.poly.mp +++ b/examples/ASPHERE/poly/in.poly.mp @@ -1,115 +1,115 @@ # SRD viscosity demo - poydisperse spheres -units lj -atom_style sphere -atom_modify first big -dimension 2 +units lj +atom_style sphere +atom_modify first big +dimension 2 # create big particles with 3 different types and diameters -lattice sq 0.3 -region box block 0 10 0 10 -0.5 0.5 -create_box 4 box -create_atoms 1 region box +lattice sq 0.3 +region box block 0 10 0 10 -0.5 0.5 +create_box 4 box +create_atoms 1 region box -group big type 1 -set group big type/fraction 2 0.33 394895 -set group big type/fraction 3 0.5 989894 -group big type 2 3 +group big type 1 +set group big type/fraction 2 0.33 394895 +set group big type/fraction 3 0.5 989894 +group big type 2 3 -set type 1*3 mass 1.0 -velocity big create 1.44 87287 loop geom +set type 1*3 mass 1.0 +velocity big create 1.44 87287 loop geom # equilibrate big particles, repulsive only to prevent aggregation -pair_style lj/cut 1.12 -pair_coeff 1 1 1.0 1.0 1.12 -pair_coeff 2 2 1.0 2.0 2.24 -pair_coeff 3 3 1.0 1.5 1.68 -pair_coeff 4 4 0.0 1.0 0.0 +pair_style lj/cut 1.12 +pair_coeff 1 1 1.0 1.0 1.12 +pair_coeff 2 2 1.0 2.0 2.24 +pair_coeff 3 3 1.0 1.5 1.68 +pair_coeff 4 4 0.0 1.0 0.0 -neighbor 0.3 bin -neigh_modify delay 0 every 1 check yes +neighbor 0.3 bin +neigh_modify delay 0 every 1 check yes -fix 1 big nve -fix 2 all enforce2d +fix 1 big nve +fix 2 all enforce2d -#dump 1 all atom 10 dump.poly.equil +#dump 1 all atom 10 dump.poly.equil -run 1000 +run 1000 -#undump 1 -unfix 1 -unfix 2 +#undump 1 +unfix 1 +unfix 2 # add small particles as hi density lattice -region plane block INF INF INF INF -0.001 0.001 units box -lattice sq 250.0 -create_atoms 4 region plane +region plane block INF INF INF INF -0.001 0.001 units box +lattice sq 250.0 +create_atoms 4 region plane -set type 4 mass 0.1 -group small type 4 -velocity small create 1.0 593849 loop geom +set type 4 mass 0.1 +group small type 4 +velocity small create 1.0 593849 loop geom # delete overlaps # must set *-4 cutoffs to non-zero values -pair_style lj/cut 2.5 -pair_coeff 1 1 1.0 1.0 -pair_coeff 2 2 1.0 2.0 -pair_coeff 3 3 1.0 1.5 -pair_coeff 1 4 0.0 1.0 0.5 -pair_coeff 2 4 0.0 1.0 1.0 -pair_coeff 3 4 0.0 1.0 0.75 -pair_coeff 4 4 0.0 1.0 0.0 +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 +pair_coeff 2 2 1.0 2.0 +pair_coeff 3 3 1.0 1.5 +pair_coeff 1 4 0.0 1.0 0.5 +pair_coeff 2 4 0.0 1.0 1.0 +pair_coeff 3 4 0.0 1.0 0.75 +pair_coeff 4 4 0.0 1.0 0.0 -delete_atoms overlap 1.0 small big +delete_atoms overlap 1.0 small big # SRD run -reset_timestep 0 +reset_timestep 0 -neighbor 0.3 multi -neigh_modify delay 0 every 1 check yes +neighbor 0.3 multi +neigh_modify delay 0 every 1 check yes -comm_modify mode multi group big vel yes -neigh_modify include big +comm_modify mode multi group big vel yes +neigh_modify include big # no pairwise interactions with small particles -pair_style lj/cut 1.12 -pair_coeff 1 1 1.0 1.0 1.12 -pair_coeff 2 2 1.0 2.0 2.24 -pair_coeff 3 3 1.0 1.5 1.68 -pair_coeff 4 4 0.0 1.0 0.0 +pair_style lj/cut 1.12 +pair_coeff 1 1 1.0 1.0 1.12 +pair_coeff 2 2 1.0 2.0 2.24 +pair_coeff 3 3 1.0 1.5 1.68 +pair_coeff 4 4 0.0 1.0 0.0 # use fix SRD to push small particles out from inside big ones # if comment out, big particles won't see SRD particles -timestep 0.001 +timestep 0.001 -fix 1 big nve -fix 2 small srd 20 big 1.0 0.25 49894 shift yes 54979 & - search 0.2 inside ignore -fix 3 small viscosity 10 x y 50 -fix 4 all enforce2d +fix 1 big nve +fix 2 small srd 20 big 1.0 0.25 49894 shift yes 54979 & + search 0.2 inside ignore +fix 3 small viscosity 10 x y 50 +fix 4 all enforce2d # diagnostics -compute tbig big temp/sphere -variable pebig equal pe*atoms/count(big) -variable ebig equal etotal*atoms/count(big) -thermo_style custom step temp f_2[8] etotal v_pebig v_ebig press & - f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] & - f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] +compute tbig big temp/sphere +variable pebig equal pe*atoms/count(big) +variable ebig equal etotal*atoms/count(big) +thermo_style custom step temp f_2[8] etotal v_pebig v_ebig press & + f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] & + f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] -thermo_modify temp tbig -thermo 1000 +thermo_modify temp tbig +thermo 1000 -#dump 1 all atom 500 dump.poly.mp +#dump 1 all atom 500 dump.poly.mp -#dump 1 all image 500 image.*.jpg type type zoom 1.6 -#dump_modify 1 pad 6 adiam 1 1 adiam 2 2.0 adiam 3 1.5 adiam 4 0.1 +#dump 1 all image 500 image.*.jpg type type zoom 1.6 +#dump_modify 1 pad 6 adiam 1 1 adiam 2 2.0 adiam 3 1.5 adiam 4 0.1 -run 50000 +run 10000 diff --git a/examples/ASPHERE/poly/log.1Feb14.poly.g++.8 b/examples/ASPHERE/poly/log.1Feb14.poly.g++.8 deleted file mode 100644 index 7a145a73db..0000000000 --- a/examples/ASPHERE/poly/log.1Feb14.poly.g++.8 +++ /dev/null @@ -1,288 +0,0 @@ -LAMMPS (1 Feb 2014) -# SRD diffusion demo - poydisperse spheres - -units lj -atom_style sphere -atom_modify first big -dimension 2 - -# create big particles with 3 different types and diameters - -lattice sq 0.3 -Lattice spacing in x,y,z = 1.82574 1.82574 1.82574 -region box block 0 10 0 10 -0.5 0.5 -create_box 4 box -Created orthogonal box = (0 0 -0.912871) to (18.2574 18.2574 0.912871) - 2 by 4 by 1 MPI processor grid -create_atoms 1 region box -Created 100 atoms - -group big type 1 -100 atoms in group big -set group big type/fraction 2 0.33 394895 - 35 settings made for type/fraction -set group big type/fraction 3 0.5 989894 - 57 settings made for type/fraction -group big type 2 3 -100 atoms in group big - -set type 1*3 mass 1.0 - 100 settings made for mass -velocity big create 1.44 87287 loop geom - -# equilibrate big particles, repulsive only to prevent aggregation - -pair_style lj/cut 1.12 -pair_coeff 1 1 1.0 1.0 1.12 -pair_coeff 2 2 1.0 2.0 2.24 -pair_coeff 3 3 1.0 1.5 1.68 -pair_coeff 4 4 0.0 1.0 0.0 - -neighbor 0.3 bin -neigh_modify delay 0 every 1 check yes - -fix 1 big nve -fix 2 all enforce2d - -#dump 1 all atom 10 dump.poly.equil - -run 1000 -Memory usage per processor = 2.7472 Mbytes -Step Temp E_pair E_mol TotEng Press - 0 1.44 -0.16013916 0 1.2654608 1.1298975 - 1000 1.3367862 -0.30816328 0 1.0152551 1.5440006 -Loop time of 0.0221665 on 8 procs for 1000 steps with 100 atoms - -Pair time (%) = 0.000323534 (1.45957) -Neigh time (%) = 0.000274181 (1.23692) -Comm time (%) = 0.0146933 (66.2864) -Outpt time (%) = 2.864e-05 (0.129204) -Other time (%) = 0.00684676 (30.8879) - -Nlocal: 12.5 ave 18 max 10 min -Histogram: 1 3 1 1 0 1 0 0 0 1 -Nghost: 27.75 ave 31 max 24 min -Histogram: 1 0 1 0 2 2 0 0 0 2 -Neighs: 19 ave 30 max 16 min -Histogram: 4 1 2 0 0 0 0 0 0 1 - -Total # of neighbors = 152 -Ave neighs/atom = 1.52 -Neighbor list builds = 115 -Dangerous builds = 0 - -#undump 1 -unfix 1 -unfix 2 - -# add small particles as hi density lattice - -region plane block INF INF INF INF -0.001 0.001 units box -lattice sq 250.0 -Lattice spacing in x,y,z = 0.0632456 0.0632456 0.0632456 -create_atoms 4 region plane -Created 83521 atoms - -set type 4 mass 0.1 - 83521 settings made for mass -group small type 4 -83521 atoms in group small -velocity small create 1.0 593849 loop geom - -# delete overlaps -# must set *-4 cutoffs to non-zero values - -pair_style lj/cut 2.5 -pair_coeff 1 1 1.0 1.0 -pair_coeff 2 2 1.0 2.0 -pair_coeff 3 3 1.0 1.5 -pair_coeff 1 4 0.0 1.0 0.5 -pair_coeff 2 4 0.0 1.0 1.0 -pair_coeff 3 4 0.0 1.0 0.75 - -delete_atoms overlap 1.0 small big -Deleted 63410 atoms, new total = 20211 - -# SRD run - -reset_timestep 0 - -neighbor 0.3 bin -neigh_modify delay 0 every 1 check yes - -communicate multi group big vel yes -neigh_modify include big - -# no pairwise interactions with small particles - -pair_style lj/cut 1.12 -pair_coeff 1 1 1.0 1.0 1.12 -pair_coeff 2 2 1.0 2.0 2.24 -pair_coeff 3 3 1.0 1.5 1.68 -pair_coeff 4 4 0.0 1.0 0.0 - -# use fix SRD to push small particles out from inside big ones -# if comment out, big particles won't see SRD particles - -timestep 0.001 - -fix 1 big nve -fix 2 small srd 20 big 1.0 0.25 49894 shift yes 54979 search 0.2 inside ignore -fix 3 all enforce2d - -# diagnostics - -compute tbig big temp/sphere -variable pebig equal pe*atoms/count(big) -variable ebig equal etotal*atoms/count(big) -thermo_style custom step temp f_2[8] etotal v_pebig v_ebig press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] - -thermo_modify temp tbig -WARNING: Temperature for thermo pressure is not for group all (../thermo.cpp:439) -thermo 1000 - -#dump 1 all atom 1000 dump.poly - -#dump 1 all image 1000 image.*.jpg type type zoom 1.6 -#dump_modify 1 pad 6 adiam 1 1 adiam 2 2.0 adiam 3 1.5 adiam 4 0.1 - -run 100000 -SRD info: - SRD/big particles = 20111 100 - big particle diameter max/min = 1 1 - SRD temperature & lamda = 1 0.0632456 - SRD max distance & max velocity = 0.252982 12.6491 - SRD grid counts: 73 73 1 - SRD grid size: request, actual (xyz) = 0.25, 0.250102 0.250102 1.82574 - SRD per actual grid cell = 4.93717 - SRD viscosity = 0.23322 - big/SRD mass density ratio = 0.161311 -WARNING: Fix srd grid size > 1/4 of big particle diameter (../fix_srd.cpp:2875) - # of rescaled SRD velocities = 0 - ave/max small velocity = 4.19344 7.74495 - ave/max big velocity = 1.43991 3.5724 -Memory usage per processor = 11.8633 Mbytes -Step Temp 2[8] TotEng pebig ebig Press 2[1] 2[2] 2[3] 2[4] 2[5] 2[6] 2[7] 2[8] 2[9] 2[10] 2[11] - 0 0.88820023 0 0.0050232797 -0.30816328 1.0152551 1.5440006 0 0 0 0 0 0 0 0 0 0 0 - 1000 0.84607633 3934 0.0065245151 0.058016014 1.3186697 4.2649214 7470 26 26 0 665 36480 5329 3934 0.95810956 0 2 - 2000 0.86586785 3944 0.0045898954 -0.36247933 0.92766376 2.1563866 7786 30 30 0 1374 36480 5329 3944 1.0799777 0 49 - 3000 0.78968677 4001 0.00417319 -0.33318986 0.84344343 1.9302042 7957 34 34 0 2129 36480 5329 4001 1.1247747 0 49 - 4000 0.7110667 4005 0.0031642256 -0.41996775 0.63952164 1.9679689 8188 24 24 0 2925 36480 5329 4005 1.1345941 0 49 - 5000 0.80379425 4052 0.0038912991 -0.41118297 0.78647047 1.6851034 8326 30 30 0 3794 36480 5329 4052 1.1310774 0 49 - 6000 0.96927432 4048 0.0054656969 -0.33954674 1.104672 1.8976158 8380 23 23 0 4643 36480 5329 4048 1.1861264 0 49 - 7000 0.75821666 4050 0.0036201309 -0.39807817 0.73166465 1.6087451 8450 51 51 0 5699 36480 5329 4050 1.1664119 0 49 - 8000 0.8712338 4035 0.0047243103 -0.343308 0.95483036 1.4707918 8458 42 42 0 6974 36480 5329 4035 1.1947807 0 91 - 9000 0.87995969 4048 0.0042778416 -0.44654537 0.86459457 1.5567027 8379 36 36 0 7965 36480 5329 4048 1.1675384 0 91 - 10000 0.83009098 4053 0.0042178709 -0.38436167 0.85247389 1.9119485 8373 34 34 0 8952 36480 5329 4053 1.1933986 0 91 - 11000 0.73595909 4015 0.0037439098 -0.33989742 0.75668162 1.6495307 8333 22 22 0 9983 36480 5329 4015 1.1959519 0 91 - 12000 0.84043443 4034 0.0041823741 -0.40694768 0.84529962 1.5115578 8566 31 31 0 11023 36480 5329 4034 1.2064988 0 91 - 13000 0.64253331 4044 0.0034868675 -0.25264383 0.7047308 1.739124 8528 31 31 0 12101 36480 5329 4044 1.1912336 0 91 - 14000 0.99330171 4042 0.0055047339 -0.36745778 1.1125618 1.8215191 8548 36 36 0 13098 36480 5329 4042 1.1819124 0 91 - 15000 0.90379859 4049 0.0049047446 -0.35536197 0.99129793 1.7159536 8459 37 37 0 14130 36480 5329 4049 1.1806762 0 91 - 16000 0.87446498 4034 0.0053318245 -0.22533777 1.0776151 2.0239395 8690 33 33 0 15176 36480 5329 4034 1.1912858 0 91 - 17000 0.95733995 4035 0.0053759665 -0.33989994 1.0865366 1.6243881 8518 27 27 0 16147 36480 5329 4035 1.2074487 0 91 - 18000 1.03543 4032 0.0052946469 -0.47268961 1.0701011 1.5444562 8464 28 28 0 17230 36480 5329 4032 1.1959755 0 91 - 19000 0.75997582 4051 0.0034371936 -0.43767278 0.6946912 1.4209137 8436 39 39 0 18276 36480 5329 4051 1.182461 0 91 - 20000 0.89615234 4037 0.0048910458 -0.34673773 0.98852926 1.5843879 8433 28 28 0 19275 36480 5329 4037 1.1850673 0 91 - 21000 0.85849578 4063 0.0044978314 -0.37010201 0.9090567 1.5445809 8504 40 40 0 20278 36480 5329 4063 1.1931031 0 91 - 22000 0.79050471 4066 0.0038260812 -0.40456274 0.77328927 1.6214277 8463 44 44 0 21287 36480 5329 4066 1.1948824 0 91 - 23000 0.89563532 4026 0.0051030186 -0.30312555 1.0313711 1.4848223 8548 35 35 0 22422 36480 5329 4026 1.1975081 0 91 - 24000 0.83528717 4036 0.0043136275 -0.37275064 0.87182725 1.5504059 8527 34 34 0 23404 36480 5329 4036 1.1755463 0 91 - 25000 0.64179358 4022 0.0035185741 -0.24513342 0.71113901 1.7238889 8452 47 47 0 24522 36480 5329 4022 1.2066339 0 91 - 26000 0.86710098 4028 0.0046099591 -0.36026164 0.93171883 1.4255297 8734 33 33 0 25524 36480 5329 4028 1.2001233 0 91 - 27000 0.8327003 4054 0.0045323379 -0.32469262 0.91603082 1.2654649 8468 34 34 0 26520 36480 5329 4054 1.1814901 0 91 - 28000 0.84396759 4049 0.0042805934 -0.39236096 0.86515074 1.2929473 8536 37 37 0 27657 36480 5329 4049 1.1897647 0 91 - 29000 0.77639299 4052 0.0038143413 -0.38590904 0.77091652 1.3627099 8637 36 36 0 28773 36480 5329 4052 1.1858017 0 91 - 30000 0.69994805 4046 0.0034430868 -0.34704032 0.69588228 1.5351247 8704 46 46 0 29818 36480 5329 4046 1.1724555 0 91 - 31000 0.73907898 4039 0.003034759 -0.48787254 0.61335514 1.2291035 8486 29 29 0 30848 36480 5329 4039 1.2063852 0 91 - 32000 0.84649298 4052 0.0044326201 -0.36539769 0.89587685 1.4591662 8513 28 28 0 31917 36480 5329 4052 1.1917883 0 91 - 33000 0.7188891 4031 0.0033440675 -0.39527528 0.67586949 1.2495703 8800 37 37 0 32938 36480 5329 4031 1.191087 0 91 - 34000 0.93588921 4054 0.0054112843 -0.30080024 1.0936747 1.3650172 8585 33 33 0 33913 36480 5329 4054 1.1840415 0 91 - 35000 0.86446961 4039 0.0053251497 -0.21179371 1.076266 1.3791947 8607 22 22 0 34865 36480 5329 4039 1.1916342 0 91 - 36000 0.90510006 4011 0.0054168442 -0.2538007 1.0947984 1.5747653 8479 31 31 0 35842 36480 5329 4011 1.1760305 0 91 - 37000 0.95332175 4058 0.0055020495 -0.30843018 1.1120192 1.4326924 8512 29 29 0 36751 36480 5329 4058 1.180738 0 91 - 38000 0.71413841 4043 0.0038380378 -0.2883604 0.77570582 1.4283837 8611 39 39 0 37689 36480 5329 4043 1.1693806 0 91 - 39000 0.81161335 4064 0.0044323475 -0.31348213 0.89582176 1.4378305 8697 28 28 0 38696 36480 5329 4064 1.1987209 0 91 - 40000 0.8294437 4062 0.0051262098 -0.19981285 1.0360583 1.6010501 8559 31 31 0 39743 36480 5329 4062 1.2092371 0 91 - 41000 0.79325147 4079 0.0045273868 -0.26691453 0.91503015 1.4080428 8775 53 53 0 40806 36480 5329 4079 1.1989619 0 91 - 42000 0.95693891 4027 0.005623893 -0.28919396 1.136645 1.5334192 8509 34 34 0 41793 36480 5329 4027 1.1931035 0 91 - 43000 0.66458435 4029 0.0035902162 -0.26461209 0.72561859 1.4253918 8559 44 44 0 42768 36480 5329 4029 1.2111853 0 91 - 44000 0.84442459 4022 0.0050980388 -0.22782802 1.0303646 1.4587515 8522 32 32 0 43812 36480 5329 4022 1.1943268 0 91 - 45000 0.96505326 4051 0.0057148128 -0.28290855 1.1550208 1.3014361 8496 32 32 0 44803 36480 5329 4051 1.1912109 0 91 - 46000 0.75345782 4064 0.0040245838 -0.30924351 0.81340864 1.7179797 8568 29 29 0 45795 36480 5329 4064 1.1975591 0 91 - 47000 0.87187806 4017 0.004406241 -0.40855293 0.89054538 1.3105257 8586 36 36 0 46822 36480 5329 4017 1.1834816 0 91 - 48000 0.83729235 4078 0.0045115864 -0.33572888 0.91183673 1.3856733 8513 38 38 0 47866 36480 5329 4078 1.1996374 0 91 - 49000 0.65112065 4048 0.0030445536 -0.35483503 0.61533473 1.2659451 8705 32 32 0 48907 36480 5329 4048 1.1907782 0 91 - 50000 0.82730473 4066 0.0045492584 -0.31323342 0.91945063 1.1803982 8562 41 41 0 49965 36480 5329 4066 1.1696702 0 91 - 51000 0.74252279 4048 0.0046741422 -0.16166808 0.94469088 1.5539445 8564 35 35 0 50948 36480 5329 4048 1.1748481 0 91 - 52000 0.85671386 4051 0.0058575179 -0.092640701 1.183863 1.6307333 8609 19 19 0 51894 36480 5329 4051 1.1770671 0 91 - 53000 0.7233951 4068 0.0043421658 -0.20026358 0.87759512 1.453924 8582 28 28 0 52893 36480 5329 4068 1.2027667 0 91 - 54000 0.72117217 4051 0.0040247209 -0.26111018 0.81343635 1.3496518 8679 25 25 0 53831 36480 5329 4051 1.1823115 0 91 - 55000 0.87940919 4044 0.0047057065 -0.35924936 0.95107033 1.240057 8559 34 34 0 54813 36480 5329 4044 1.1815144 0 91 - 56000 0.83192698 4044 0.0046298732 -0.30382753 0.93574367 1.547229 8441 37 37 0 55740 36480 5329 4044 1.1761232 0 91 - 57000 0.91043729 4058 0.0050029377 -0.34540782 1.0111437 1.4951603 8550 32 32 0 56678 36480 5329 4058 1.2024504 0 91 - 58000 0.97648852 4036 0.0053292287 -0.37787747 1.0770904 1.4058278 8554 31 31 0 57683 36480 5329 4036 1.1746239 0 91 - 59000 0.72239185 4018 0.0046615138 -0.1342253 0.94213856 1.8337414 8716 35 35 0 58640 36480 5329 4018 1.1697661 0 91 - 60000 0.73800253 4032 0.0037590001 -0.33989225 0.75973152 1.399426 8561 32 32 0 59593 36480 5329 4032 1.1958194 0 91 - 61000 0.72778603 4060 0.0042599892 -0.22341476 0.86098642 1.3778202 8541 31 31 0 60573 36480 5329 4060 1.1980875 0 91 - 62000 0.80350669 4044 0.0042316822 -0.34195968 0.85526529 1.4379455 8487 37 37 0 61608 36480 5329 4044 1.1942365 0 91 - 63000 0.90084181 4066 0.0043040273 -0.47236734 0.86988695 1.4672845 8504 32 32 0 62670 36480 5329 4066 1.1829834 0 91 - 64000 0.87220486 4059 0.0047840275 -0.33268544 0.9668998 1.5398216 8588 34 34 0 63605 36480 5329 4059 1.1884975 0 91 - 65000 0.82469157 4057 0.004405933 -0.33830733 0.89048312 1.5284565 8783 32 32 0 64693 36480 5329 4057 1.1952722 0 91 - 66000 0.88692288 4081 0.0047264561 -0.36625105 0.95526405 1.3151847 8745 36 36 0 65755 36480 5329 4081 1.1834684 0 91 - 67000 0.83322374 4031 0.0047732147 -0.27678896 0.96471442 1.5085732 8415 34 34 0 66796 36480 5329 4031 1.1969 0 91 - 68000 0.75375865 4020 0.0044379413 -0.22614806 0.89695233 1.6351001 8573 30 30 0 67876 36480 5329 4020 1.1911308 0 91 - 69000 0.91169697 4055 0.0050371842 -0.34036318 1.0180653 1.2495539 8625 20 20 0 68979 36480 5329 4055 1.1860768 0 91 - 70000 0.80502435 4075 0.0042565586 -0.33919322 0.86029306 1.3194042 8571 36 36 0 69947 36480 5329 4075 1.18994 0 91 - 71000 0.8928873 4055 0.0050586026 -0.3080079 1.0223942 1.3949364 8698 32 32 0 71037 36480 5329 4055 1.2154821 0 91 - 72000 0.95397384 4050 0.0052866702 -0.35293209 1.0684889 1.2950893 8613 35 35 0 72090 36480 5329 4050 1.1790804 0 91 - 73000 0.78742879 4053 0.004378612 -0.28830762 0.88496127 1.5168042 8624 30 30 0 73174 36480 5329 4053 1.2008591 0 91 - 74000 0.79498726 4046 0.0042999917 -0.31545969 0.86907133 1.3751647 8562 22 22 0 74250 36480 5329 4046 1.1921334 0 91 - 75000 0.88929145 4051 0.0048995187 -0.33480254 0.99024172 1.6589606 8393 33 33 0 75296 36480 5329 4051 1.1753137 0 91 - 76000 0.98366685 4045 0.0049217494 -0.47092883 0.99473478 1.5271346 8555 29 29 0 76301 36480 5329 4045 1.2031327 0 91 - 77000 0.72618119 4051 0.0035028638 -0.37404618 0.7079638 1.5178344 8565 37 37 0 77315 36480 5329 4051 1.1993308 0 91 - 78000 0.80445682 4028 0.003992176 -0.39178196 0.8068587 1.3682816 8624 32 32 0 78299 36480 5329 4028 1.2065456 0 91 - 79000 1.091703 4052 0.0063793569 -0.33730561 1.2893318 1.5717928 8677 39 39 0 79249 36480 5329 4052 1.1725194 0 91 - 80000 0.77212865 4052 0.0041275152 -0.31625959 0.8342121 1.5583982 8526 33 33 0 80284 36480 5329 4052 1.1981751 0 91 - 81000 0.80732682 4061 0.004618782 -0.26941493 0.93350203 1.5517327 8444 36 36 0 81331 36480 5329 4061 1.2095831 0 91 - 82000 0.80166933 4057 0.0042732734 -0.33081602 0.86367129 1.3937505 8476 29 29 0 82335 36480 5329 4057 1.2047807 0 91 - 83000 0.76980598 4049 0.0041331379 -0.31166241 0.83534851 1.1411979 8561 34 34 0 83375 36480 5329 4049 1.1810941 0 91 - 84000 0.85529188 4076 0.0046148117 -0.34168531 0.93269959 1.3284464 8664 27 27 0 84510 36480 5329 4076 1.192734 0 91 - 85000 0.96167157 4034 0.0053261317 -0.35642617 1.0764645 1.3195071 8557 36 36 0 85517 36480 5329 4034 1.2000123 0 91 - 86000 0.88130862 4047 0.0046646382 -0.37037981 0.94277003 1.3595079 8634 36 36 0 86578 36480 5329 4047 1.1654584 0 91 - 87000 0.68799517 4037 0.0042184867 -0.17251446 0.85259834 1.5087731 8363 40 40 0 87606 36480 5329 4037 1.1833599 0 91 - 88000 0.83191621 4041 0.0048307277 -0.26321678 0.97633838 1.4008912 8597 39 39 0 88490 36480 5329 4041 1.1607031 0 91 - 89000 0.71456519 4036 0.0039378285 -0.26882761 0.79587453 1.2251569 8397 36 36 0 89436 36480 5329 4036 1.1991362 0 91 - 90000 0.75198251 4048 0.0043377839 -0.24374445 0.87670949 1.4896261 8551 29 29 0 90453 36480 5329 4048 1.1899998 0 91 - 91000 0.83310145 4032 0.0049902932 -0.232733 1.0085882 1.4140378 8583 48 48 0 91563 36480 5329 4032 1.1953029 0 91 - 92000 0.8819465 4050 0.0058087956 -0.14008461 1.1740157 1.753218 8610 46 46 0 92618 36480 5329 4050 1.1972268 0 91 - 93000 0.76721608 4048 0.0041923848 -0.29582907 0.8473229 1.4126521 8671 32 32 0 93690 36480 5329 4048 1.2027935 0 91 - 94000 0.8942606 4050 0.0051973822 -0.28200539 1.0504429 1.5743434 8751 21 21 0 94750 36480 5329 4050 1.1804594 0 91 - 95000 0.73609582 4036 0.0035091666 -0.38754512 0.70923765 1.28494 8660 31 31 0 95713 36480 5329 4036 1.1883125 0 91 - 96000 0.79430429 4078 0.0043400156 -0.30635284 0.87716056 1.4351927 8600 38 38 0 96695 36480 5329 4078 1.1704833 0 91 - 97000 0.74817621 4044 0.0038163094 -0.34346826 0.77131429 1.255104 8377 36 36 0 97683 36480 5329 4044 1.1756023 0 91 - 98000 0.78160255 4048 0.0039385343 -0.36857064 0.79601716 1.5320263 8350 25 25 0 98631 36480 5329 4048 1.181196 0 91 - 99000 0.804448 4053 0.004503827 -0.28835905 0.91026848 1.7569548 8506 35 35 0 99687 36480 5329 4053 1.1950898 0 91 - 100000 0.74975993 4032 0.004263269 -0.255493 0.86164929 1.5983872 8621 33 33 0 100701 36480 5329 4032 1.1910217 0 91 -Loop time of 13.4746 on 8 procs for 100000 steps with 20211 atoms - -Pair time (%) = 0.0563478 (0.418178) -Neigh time (%) = 0.794382 (5.89541) -Comm time (%) = 1.23773 (9.18569) -Outpt time (%) = 0.00554895 (0.0411809) -Other time (%) = 11.3806 (84.4595) - -Nlocal: 2526.38 ave 2725 max 2337 min -Histogram: 2 0 0 1 1 1 1 0 1 1 -Nghost: 23.875 ave 27 max 21 min -Histogram: 1 1 0 2 0 2 0 0 0 2 -Neighs: 17 ave 25 max 12 min -Histogram: 3 1 0 1 1 0 0 0 0 2 - -Total # of neighbors = 136 -Ave neighs/atom = 0.00672901 -Neighbor list builds = 5008 -Dangerous builds = 0 - -Please see the log.cite file for references relevant to this simulation - diff --git a/examples/ASPHERE/poly/log.1Feb14.poly.mp.g++.8 b/examples/ASPHERE/poly/log.1Feb14.poly.mp.g++.8 deleted file mode 100644 index 388c629b17..0000000000 --- a/examples/ASPHERE/poly/log.1Feb14.poly.mp.g++.8 +++ /dev/null @@ -1,239 +0,0 @@ -LAMMPS (1 Feb 2014) -# SRD viscosity demo - poydisperse spheres - -units lj -atom_style sphere -atom_modify first big -dimension 2 - -# create big particles with 3 different types and diameters - -lattice sq 0.3 -Lattice spacing in x,y,z = 1.82574 1.82574 1.82574 -region box block 0 10 0 10 -0.5 0.5 -create_box 4 box -Created orthogonal box = (0 0 -0.912871) to (18.2574 18.2574 0.912871) - 2 by 4 by 1 MPI processor grid -create_atoms 1 region box -Created 100 atoms - -group big type 1 -100 atoms in group big -set group big type/fraction 2 0.33 394895 - 35 settings made for type/fraction -set group big type/fraction 3 0.5 989894 - 57 settings made for type/fraction -group big type 2 3 -100 atoms in group big - -set type 1*3 mass 1.0 - 100 settings made for mass -velocity big create 1.44 87287 loop geom - -# equilibrate big particles, repulsive only to prevent aggregation - -pair_style lj/cut 1.12 -pair_coeff 1 1 1.0 1.0 1.12 -pair_coeff 2 2 1.0 2.0 2.24 -pair_coeff 3 3 1.0 1.5 1.68 -pair_coeff 4 4 0.0 1.0 0.0 - -neighbor 0.3 bin -neigh_modify delay 0 every 1 check yes - -fix 1 big nve -fix 2 all enforce2d - -#dump 1 all atom 10 dump.poly.equil - -run 1000 -Memory usage per processor = 2.7472 Mbytes -Step Temp E_pair E_mol TotEng Press - 0 1.44 -0.16013916 0 1.2654608 1.1298975 - 1000 1.3367862 -0.30816328 0 1.0152551 1.5440006 -Loop time of 0.0173425 on 8 procs for 1000 steps with 100 atoms - -Pair time (%) = 0.00033614 (1.93825) -Neigh time (%) = 0.000266045 (1.53407) -Comm time (%) = 0.0115004 (66.3132) -Outpt time (%) = 2.78056e-05 (0.160332) -Other time (%) = 0.00521213 (30.0541) - -Nlocal: 12.5 ave 18 max 10 min -Histogram: 1 3 1 1 0 1 0 0 0 1 -Nghost: 27.75 ave 31 max 24 min -Histogram: 1 0 1 0 2 2 0 0 0 2 -Neighs: 19 ave 30 max 16 min -Histogram: 4 1 2 0 0 0 0 0 0 1 - -Total # of neighbors = 152 -Ave neighs/atom = 1.52 -Neighbor list builds = 115 -Dangerous builds = 0 - -#undump 1 -unfix 1 -unfix 2 - -# add small particles as hi density lattice - -region plane block INF INF INF INF -0.001 0.001 units box -lattice sq 250.0 -Lattice spacing in x,y,z = 0.0632456 0.0632456 0.0632456 -create_atoms 4 region plane -Created 83521 atoms - -set type 4 mass 0.1 - 83521 settings made for mass -group small type 4 -83521 atoms in group small -velocity small create 1.0 593849 loop geom - -# delete overlaps -# must set *-4 cutoffs to non-zero values - -pair_style lj/cut 2.5 -pair_coeff 1 1 1.0 1.0 -pair_coeff 2 2 1.0 2.0 -pair_coeff 3 3 1.0 1.5 -pair_coeff 1 4 0.0 1.0 0.5 -pair_coeff 2 4 0.0 1.0 1.0 -pair_coeff 3 4 0.0 1.0 0.75 - -delete_atoms overlap 1.0 small big -Deleted 63410 atoms, new total = 20211 - -# SRD run - -reset_timestep 0 - -neighbor 0.3 bin -neigh_modify delay 0 every 1 check yes - -communicate multi group big vel yes -neigh_modify include big - -# no pairwise interactions with small particles - -pair_style lj/cut 1.12 -pair_coeff 1 1 1.0 1.0 1.12 -pair_coeff 2 2 1.0 2.0 2.24 -pair_coeff 3 3 1.0 1.5 1.68 -pair_coeff 4 4 0.0 1.0 0.0 - -# use fix SRD to push small particles out from inside big ones -# if comment out, big particles won't see SRD particles - -timestep 0.001 - -fix 1 big nve -fix 2 small srd 20 big 1.0 0.25 49894 shift yes 54979 search 0.2 inside ignore -fix 3 small viscosity 10 x y 50 -fix 4 all enforce2d - -# diagnostics - -compute tbig big temp/sphere -variable pebig equal pe*atoms/count(big) -variable ebig equal etotal*atoms/count(big) -thermo_style custom step temp f_2[8] etotal v_pebig v_ebig press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] - -thermo_modify temp tbig -WARNING: Temperature for thermo pressure is not for group all (../thermo.cpp:439) -thermo 1000 - -#dump 1 all atom 500 dump.poly.mp - -#dump 1 all image 500 image.*.jpg type type zoom 1.6 -#dump_modify 1 pad 6 adiam 1 1 adiam 2 2.0 adiam 3 1.5 adiam 4 0.1 - -run 50000 -SRD info: - SRD/big particles = 20111 100 - big particle diameter max/min = 1 1 - SRD temperature & lamda = 1 0.0632456 - SRD max distance & max velocity = 0.252982 12.6491 - SRD grid counts: 73 73 1 - SRD grid size: request, actual (xyz) = 0.25, 0.250102 0.250102 1.82574 - SRD per actual grid cell = 4.93717 - SRD viscosity = 0.23322 - big/SRD mass density ratio = 0.161311 -WARNING: Fix srd grid size > 1/4 of big particle diameter (../fix_srd.cpp:2875) - # of rescaled SRD velocities = 0 - ave/max small velocity = 4.19344 7.74495 - ave/max big velocity = 1.43991 3.5724 -Memory usage per processor = 11.8633 Mbytes -Step Temp 2[8] TotEng pebig ebig Press 2[1] 2[2] 2[3] 2[4] 2[5] 2[6] 2[7] 2[8] 2[9] 2[10] 2[11] - 0 0.88820023 0 0.0050232797 -0.30816328 1.0152551 1.5440006 0 0 0 0 0 0 0 0 0 0 0 - 1000 0.76223471 3964 0.0058318994 0.042955471 1.1786852 3.9611295 7412 29 29 0 611 36480 5329 3964 0.97424113 0 1 - 2000 0.83394503 3951 0.0050432506 -0.22328672 1.0192914 2.7492771 7829 30 30 0 1225 36480 5329 3951 1.0832295 0 3 - 3000 0.86856945 3991 0.0048205728 -0.31988251 0.97428597 2.4105317 7961 34 34 0 2000 36480 5329 3991 1.1243219 0 6 - 4000 0.88106888 4009 0.0066731082 0.035909261 1.3487019 3.025346 8002 33 33 0 2895 36480 5329 4009 1.1359575 0 6 - 5000 1.0764198 4036 0.0070136315 -0.18634051 1.4175251 2.7617336 8117 36 36 0 3808 36480 5329 4036 1.1147743 0 6 - 6000 1.0433139 4004 0.0059532709 -0.35132214 1.2032156 2.3597383 8004 23 23 0 4845 36480 5329 4004 1.1192873 0 6 - 7000 1.1551053 4026 0.0074766715 -0.20999681 1.5111101 2.280806 8269 36 36 0 5873 36480 5329 4026 1.1704244 0 6 - 8000 1.2222713 4008 0.0078175708 -0.24117508 1.5800092 1.967726 8218 33 33 0 7077 36480 5329 4008 1.1496529 0 6 - 9000 1.2240884 4012 0.0081583857 -0.17500037 1.6488913 2.3684675 8502 27 27 0 8359 36480 5329 4012 1.1664455 0 6 - 10000 1.2071315 4035 0.0073838443 -0.30627724 1.4923488 2.124366 8376 33 33 0 9778 36480 5329 4035 1.1942304 0 6 - 11000 1.1694272 4036 0.0077950192 -0.16699527 1.5754513 2.4203067 8623 40 40 0 11210 36480 5329 4036 1.1802896 0 42 - 12000 1.0911561 4044 0.0074117515 -0.12783343 1.4979891 2.4859591 8490 30 30 0 12647 36480 5329 4044 1.171701 0 42 - 13000 1.3535072 4023 0.0091503262 -0.16735325 1.8493724 2.7718999 8320 33 33 0 14082 36480 5329 4023 1.1841757 0 42 - 14000 1.4191753 4043 0.0095368758 -0.18707328 1.927498 2.8442438 8422 25 25 0 15462 36480 5329 4043 1.1567854 0 42 - 15000 1.703769 4053 0.010892787 -0.33707457 2.2015412 2.4160876 8123 34 34 0 16985 36480 5329 4053 1.1875794 0 42 - 16000 1.4270161 4032 0.010142553 -0.076342616 2.0499114 2.9568071 8360 34 34 0 18487 36480 5329 4032 1.164586 0 42 - 17000 1.2267528 4013 0.0080642511 -0.19799584 1.6298658 2.5084784 8477 27 27 0 20101 36480 5329 4013 1.1529604 0 42 - 18000 1.4228586 4050 0.01009573 -0.079611446 2.0404479 2.8013833 8519 33 33 0 21633 36480 5329 4050 1.1549291 0 42 - 19000 1.3041379 4040 0.0082901927 -0.26763462 1.6755308 1.9403854 8483 30 30 0 23194 36480 5329 4040 1.1592747 0 42 - 20000 1.3837406 4030 0.0092446911 -0.19332904 1.8684445 2.4550531 8425 25 25 0 24761 36480 5329 4030 1.1757648 0 42 - 21000 1.7882552 4031 0.012076007 -0.22381856 2.4406817 2.4206092 8581 40 40 0 26371 36480 5329 4031 1.1591574 0 42 - 22000 1.5079803 4015 0.010373742 -0.15025377 2.0966369 2.6321039 8383 33 33 0 27989 36480 5329 4015 1.1495522 0 42 - 23000 1.3835348 4044 0.0087922321 -0.28446888 1.776998 2.2729548 8441 30 30 0 29575 36480 5329 4044 1.1616377 0 42 - 24000 1.5854836 4044 0.0099174248 -0.35795983 2.0044107 2.2250073 8462 35 35 0 31298 36480 5329 4044 1.1796851 0 42 - 25000 1.5314412 4062 0.010880793 -0.082730301 2.1991171 2.6858232 8473 28 28 0 33079 36480 5329 4062 1.1726593 0 54 - 26000 1.2896316 4070 0.0090198232 -0.098554631 1.8229965 2.3437649 8453 40 40 0 34816 36480 5329 4070 1.1764482 0 54 - 27000 1.6956611 4035 0.012064024 -0.088275024 2.43826 2.8138661 8380 32 32 0 36453 36480 5329 4035 1.1622504 0 54 - 28000 1.3560979 4043 0.0088193796 -0.23810107 1.7824848 2.1799536 8611 30 30 0 38202 36480 5329 4043 1.1681248 0 54 - 29000 1.5837646 4029 0.010790526 -0.17893612 2.1808731 2.3116753 8480 26 26 0 39846 36480 5329 4029 1.1774511 0 54 - 30000 1.6549448 4035 0.01137773 -0.16631482 2.2995529 2.6236656 8637 30 30 0 41461 36480 5329 4035 1.1538405 0 54 - 31000 1.445315 4050 0.01013447 -0.1052417 2.0482777 2.4440312 8504 38 38 0 43099 36480 5329 4050 1.1690375 0 54 - 32000 1.5572315 4037 0.010828477 -0.13173155 2.1885434 2.5911192 8453 30 30 0 44760 36480 5329 4037 1.1612147 0 54 - 33000 2.018109 4068 0.013467519 -0.28506208 2.7219203 2.5784978 8701 40 40 0 46462 36480 5329 4068 1.1727186 0 54 - 34000 1.2455134 4066 0.0083640288 -0.16536113 1.6904539 2.3054829 8428 32 32 0 48055 36480 5329 4066 1.1712016 0 54 - 35000 1.6248596 4012 0.011213824 -0.15461501 2.2664259 2.8697537 8453 31 31 0 49658 36480 5329 4012 1.1693962 0 54 - 36000 1.5485873 4039 0.01112737 -0.058442367 2.2489527 3.0386676 8529 42 42 0 51330 36480 5329 4039 1.1750818 0 54 - 37000 1.5561543 4024 0.011313246 -0.032149816 2.2865202 2.7583779 8484 45 45 0 52981 36480 5329 4024 1.1613247 0 54 - 38000 1.5174762 4043 0.010120957 -0.21549294 2.0455467 2.2489655 8528 37 37 0 54637 36480 5329 4043 1.1692017 0 54 - 39000 1.5936544 4045 0.010946409 -0.16216642 2.2123787 2.7579117 8460 35 35 0 56452 36480 5329 4045 1.1670575 0 54 - 40000 1.7884514 4051 0.011913021 -0.2570519 2.4077408 2.494169 8539 37 37 0 58163 36480 5329 4051 1.1744075 0 54 - 41000 1.4173685 4042 0.0096196931 -0.16764288 1.9442362 1.9949409 8511 42 42 0 59967 36480 5329 4042 1.1747318 0 54 - 42000 1.4946304 4055 0.0098254549 -0.24117659 1.9858227 1.9958514 8395 39 39 0 61697 36480 5329 4055 1.1745062 0 54 - 43000 1.6486882 4041 0.011190255 -0.19488288 2.2616625 2.2173122 8473 28 28 0 63447 36480 5329 4041 1.1631975 0 54 - 44000 1.7473914 4055 0.011743128 -0.23020951 2.3734036 2.3913609 8421 30 30 0 65095 36480 5329 4055 1.1567659 0 54 - 45000 1.7826681 4027 0.011993913 -0.23208563 2.4240898 2.4582759 8539 35 35 0 66749 36480 5329 4027 1.1513285 0 54 - 46000 1.3988187 4049 0.0091738733 -0.23010838 1.8541315 2.3866226 8447 38 38 0 68459 36480 5329 4049 1.1728215 0 54 - 47000 1.8402398 4064 0.01271321 -0.17249031 2.569467 2.7748374 8524 33 33 0 70139 36480 5329 4064 1.1555276 0 54 - 48000 1.5634287 4042 0.011047794 -0.096639164 2.2328696 2.7173437 8561 33 33 0 71923 36480 5329 4042 1.177462 0 54 - 49000 1.789207 4058 0.012453079 -0.14902655 2.5168918 2.9310418 8545 38 38 0 73721 36480 5329 4058 1.1581934 0 54 - 50000 1.3475703 4010 0.0092484369 -0.13867816 1.8692016 2.1619389 8664 32 32 0 75439 36480 5329 4010 1.1589691 0 54 -Loop time of 6.84 on 8 procs for 50000 steps with 20211 atoms - -Pair time (%) = 0.0295508 (0.432029) -Neigh time (%) = 0.400359 (5.8532) -Comm time (%) = 0.622996 (9.10813) -Outpt time (%) = 0.00241029 (0.0352382) -Other time (%) = 5.78468 (84.5714) - -Nlocal: 2526.38 ave 2651 max 2342 min -Histogram: 1 0 0 2 1 0 0 1 1 2 -Nghost: 24.5 ave 27 max 23 min -Histogram: 1 0 4 0 0 2 0 0 0 1 -Neighs: 17.375 ave 24 max 13 min -Histogram: 2 2 0 1 1 0 0 0 0 2 - -Total # of neighbors = 139 -Ave neighs/atom = 0.00687744 -Neighbor list builds = 2502 -Dangerous builds = 0 - -Please see the log.cite file for references relevant to this simulation - diff --git a/examples/ASPHERE/poly/log.1Feb24.poly.g++.1 b/examples/ASPHERE/poly/log.1Feb24.poly.g++.1 new file mode 100644 index 0000000000..f29a3d2a3c --- /dev/null +++ b/examples/ASPHERE/poly/log.1Feb24.poly.g++.1 @@ -0,0 +1,317 @@ +LAMMPS (21 Nov 2023 - Development - patch_21Nov2023-665-g17f869bf5e) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# SRD diffusion demo - poydisperse spheres + +units lj +atom_style sphere +atom_modify first big +dimension 2 + +# create big particles with 3 different types and diameters + +lattice sq 0.3 +Lattice spacing in x,y,z = 1.8257419 1.8257419 1.8257419 +region box block 0 10 0 10 -0.5 0.5 +create_box 4 box +Created orthogonal box = (0 0 -0.91287093) to (18.257419 18.257419 0.91287093) + 1 by 1 by 1 MPI processor grid +create_atoms 1 region box +Created 100 atoms + using lattice units in orthogonal box = (0 0 -0.91287093) to (18.257419 18.257419 0.91287093) + create_atoms CPU = 0.000 seconds + +group big type 1 +100 atoms in group big +set group big type/fraction 2 0.33 394895 +Setting atom values ... + 35 settings made for type/fraction +set group big type/fraction 3 0.5 989894 +Setting atom values ... + 57 settings made for type/fraction +group big type 2 3 +100 atoms in group big + +set type 1*3 mass 1.0 +Setting atom values ... + 100 settings made for mass +velocity big create 1.44 87287 loop geom + +# equilibrate big particles, repulsive only to prevent aggregation + +pair_style lj/cut 1.12 +pair_coeff 1 1 1.0 1.0 1.12 +pair_coeff 2 2 1.0 2.0 2.24 +pair_coeff 3 3 1.0 1.5 1.68 +pair_coeff 4 4 0.0 1.0 0.0 + +neighbor 0.3 bin +neigh_modify delay 0 every 1 check yes + +fix 1 big nve +fix 2 all enforce2d + +#dump 1 all atom 10 dump.poly.equil + +run 1000 +Generated 6 of 6 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 2.54 + ghost atom cutoff = 2.54 + binsize = 1.27, bins = 15 15 2 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/2d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 4.174 | 4.174 | 4.174 Mbytes + Step Temp E_pair E_mol TotEng Press + 0 1.44 -0.16013916 0 1.2654608 1.1298975 + 1000 1.3367862 -0.30816328 0 1.0152551 1.5440006 +Loop time of 0.00622873 on 1 procs for 1000 steps with 100 atoms + +Performance: 69356032.450 tau/day, 160546.371 timesteps/s, 16.055 Matom-step/s +99.8% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.0015709 | 0.0015709 | 0.0015709 | 0.0 | 25.22 +Neigh | 0.0014016 | 0.0014016 | 0.0014016 | 0.0 | 22.50 +Comm | 0.0012066 | 0.0012066 | 0.0012066 | 0.0 | 19.37 +Output | 6.169e-06 | 6.169e-06 | 6.169e-06 | 0.0 | 0.10 +Modify | 0.0013508 | 0.0013508 | 0.0013508 | 0.0 | 21.69 +Other | | 0.0006926 | | | 11.12 + +Nlocal: 100 ave 100 max 100 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 60 ave 60 max 60 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 152 ave 152 max 152 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 152 +Ave neighs/atom = 1.52 +Neighbor list builds = 115 +Dangerous builds = 0 + +#undump 1 +unfix 1 +unfix 2 + +# add small particles as hi density lattice + +region plane block INF INF INF INF -0.001 0.001 units box +lattice sq 250.0 +Lattice spacing in x,y,z = 0.063245553 0.063245553 0.063245553 +create_atoms 4 region plane +Created 83521 atoms + using lattice units in orthogonal box = (0 0 -0.91287093) to (18.257419 18.257419 0.91287093) + create_atoms CPU = 0.016 seconds + +set type 4 mass 0.1 +Setting atom values ... + 83521 settings made for mass +group small type 4 +83521 atoms in group small +velocity small create 1.0 593849 loop geom + +# delete overlaps +# must set *-4 cutoffs to non-zero values + +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 +pair_coeff 2 2 1.0 2.0 +pair_coeff 3 3 1.0 1.5 +pair_coeff 1 4 0.0 1.0 0.5 +pair_coeff 2 4 0.0 1.0 1.0 +pair_coeff 3 4 0.0 1.0 0.75 +pair_coeff 4 4 0.0 1.0 0.0 + +delete_atoms overlap 1.0 small big +System init for delete_atoms ... +Generated 3 of 6 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 2.8 + ghost atom cutoff = 2.8 + binsize = 1.4, bins = 14 14 2 + 2 neighbor lists, perpetual/occasional/extra = 1 1 0 + (1) command delete_atoms, occasional + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/2d + bin: standard + (2) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/2d + bin: standard +WARNING: Delete_atoms cutoff > minimum neighbor cutoff (src/delete_atoms.cpp:312) +Deleted 63410 atoms, new total = 20211 + +# SRD run + +reset_timestep 0 + +neighbor 0.3 multi +neigh_modify delay 0 every 1 check yes + +comm_modify mode multi group big vel yes +neigh_modify include big + +# no pairwise interactions with small particles + +pair_style lj/cut 1.12 +pair_coeff 1 1 1.0 1.0 1.12 +pair_coeff 2 2 1.0 2.0 2.24 +pair_coeff 3 3 1.0 1.5 1.68 +pair_coeff 4 4 0.0 1.0 0.0 + +# use fix SRD to push small particles out from inside big ones +# if comment out, big particles won't see SRD particles + +timestep 0.001 + +fix 1 big nve +fix 2 small srd 20 big 1.0 0.25 49894 shift yes 54979 search 0.2 inside ignore +fix 3 all enforce2d + +# diagnostics + +compute tbig big temp/sphere +variable pebig equal pe*atoms/count(big) +variable ebig equal etotal*atoms/count(big) +thermo_style custom step temp f_2[8] etotal v_pebig v_ebig press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] + +thermo_modify temp tbig +WARNING: Temperature for thermo pressure is not for group all (src/thermo.cpp:530) +thermo 1000 + +#dump 1 all atom 1000 dump.poly + +#dump 1 all image 1000 image.*.jpg type type zoom 1.6 +#dump_modify 1 pad 6 adiam 1 1 adiam 2 2.0 adiam 3 1.5 adiam 4 0.1 + +run 10000 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- neighbor multi command: doi:10.1016/j.cpc.2008.03.005, doi:10.1007/s40571-020-00361-2 + +@Article{Intveld08, + author = {in 't Veld, P. J. and S. J.~Plimpton and G. S. Grest}, + title = {Accurate and Efficient Methods for Modeling Colloidal + Mixtures in an Explicit Solvent using Molecular Dynamics}, + journal = {Comput.\ Phys.\ Commut.}, + year = 2008, + volume = 179, + pages = {320--329} +} + +@article{Shire2020, + author = {Shire, Tom and Hanley, Kevin J. and Stratford, Kevin}, + title = {{DEM} Simulations of Polydisperse Media: Efficient Contact + Detection Applied to Investigate the Quasi-Static Limit}, + journal = {Computational Particle Mechanics}, + year = {2020} +@article{Monti2022, + author = {Monti, Joseph M. and Clemmer, Joel T. and Srivastava, + Ishan and Silbert, Leonardo E. and Grest, Gary S. + and Lechman, Jeremy B.}, + title = {Large-scale frictionless jamming with power-law particle + size distributions}, + journal = {Phys. Rev. E}, + volume = {106} + issue = {3} + year = {2022} +} + +- fix srd command: doi:10.1063/1.3419070 + +@Article{Petersen10, + author = {M. K. Petersen and J. B. Lechman and S. J. Plimpton and + G. S. Grest and in 't Veld, P. J. and P. R. Schunk}, + title = {Mesoscale Hydrodynamics via Stochastic Rotation + Dynamics: Comparison with {L}ennard-{J}ones Fluid}, + journal = {J.~Chem.\ Phys.}, + year = 2010, + volume = 132, + pages = 174106 +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Generated 3 of 6 mixed pair_coeff terms from geometric mixing rule +SRD info: + SRD/big particles = 20111 100 + big particle diameter max/min = 1 1 + SRD temperature & lamda = 1 0.063245553 + SRD max distance & max velocity = 0.25298221 12.649111 + SRD grid counts: 73 73 1 + SRD grid size: request, actual (xyz) = 0.25, 0.25010162 0.25010162 1.8257419 + SRD per actual grid cell = 4.9371727 + SRD viscosity = 0.23321983 + big/SRD mass density ratio = 0.16131131 +WARNING: Fix srd grid size > 1/4 of big particle diameter (src/SRD/fix_srd.cpp:2830) + # of rescaled SRD velocities = 0 + ave/max small velocity = 4.1934421 7.74495 + ave/max big velocity = 1.4399093 3.5724039 +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 2.54 + ghost atom cutoff = 2.54 + binsize = 18.257419, bins = 1 1 1 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/multi/atomonly/newton + stencil: half/multi/2d + bin: multi +Per MPI rank memory allocation (min/avg/max) = 42 | 42 | 42 Mbytes + Step Temp f_2[8] TotEng v_pebig v_ebig Press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] + 0 0.88820023 0 0.0050232797 -0.30816328 1.0152551 1.5440006 0 0 0 0 0 0 0 0 0 0 0 + 1000 1.0181191 3924 0.0076572255 0.030604433 1.5476019 3.7992573 7242 26 26 0 635 15876 5329 3924 0.98110339 0 3 + 2000 0.69783736 3992 0.0027817464 -0.47755891 0.56221876 1.9887267 7740 34 34 1 1186 15876 5329 3992 1.0611575 0 24 + 3000 0.89084297 3981 0.004323119 -0.45361044 0.87374558 1.7342893 7775 24 24 0 1923 15876 5329 3981 1.1207371 0 24 + 4000 0.84391846 4036 0.0045581483 -0.33619115 0.92124735 1.8456288 8060 43 43 0 2734 15876 5329 4036 1.1481354 0 24 + 5000 0.69548234 4056 0.0030033315 -0.42926535 0.60700333 1.6113509 8260 33 33 0 3638 15876 5329 4056 1.148749 0 24 + 6000 0.71729125 4023 0.0035318938 -0.35493291 0.71383106 1.673491 8224 29 29 0 4528 15876 5329 4023 1.1602572 0 24 + 7000 0.90145513 4032 0.0047423524 -0.38469129 0.95847685 1.7537778 8382 31 31 0 5395 15876 5329 4032 1.1543513 0 24 + 8000 0.6739295 4026 0.0029910322 -0.39963744 0.60451751 1.646528 8409 35 35 0 6293 15876 5329 4026 1.1540519 0 24 + 9000 0.80563959 4041 0.0042947965 -0.33238166 0.86802133 1.6597032 8429 29 29 0 7164 15876 5329 4041 1.1880521 0 24 + 10000 0.90407954 4022 0.0046865656 -0.39987673 0.94720178 1.445708 8349 30 30 0 8189 15876 5329 4022 1.171667 0 24 +Loop time of 5.64963 on 1 procs for 10000 steps with 20211 atoms + +Performance: 152930.340 tau/day, 1770.027 timesteps/s, 35.774 Matom-step/s +99.8% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.019832 | 0.019832 | 0.019832 | 0.0 | 0.35 +Neigh | 0.020738 | 0.020738 | 0.020738 | 0.0 | 0.37 +Comm | 0.056875 | 0.056875 | 0.056875 | 0.0 | 1.01 +Output | 0.00083247 | 0.00083247 | 0.00083247 | 0.0 | 0.01 +Modify | 5.4828 | 5.4828 | 5.4828 | 0.0 | 97.05 +Other | | 0.06854 | | | 1.21 + +Nlocal: 20211 ave 20211 max 20211 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 49 ave 49 max 49 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 160 ave 160 max 160 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 160 +Ave neighs/atom = 0.0079164811 +Neighbor list builds = 500 +Dangerous builds = 0 +Total wall time: 0:00:11 diff --git a/examples/ASPHERE/poly/log.1Feb24.poly.g++.4 b/examples/ASPHERE/poly/log.1Feb24.poly.g++.4 new file mode 100644 index 0000000000..f3f42580aa --- /dev/null +++ b/examples/ASPHERE/poly/log.1Feb24.poly.g++.4 @@ -0,0 +1,317 @@ +LAMMPS (21 Nov 2023 - Development - patch_21Nov2023-665-g17f869bf5e) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# SRD diffusion demo - poydisperse spheres + +units lj +atom_style sphere +atom_modify first big +dimension 2 + +# create big particles with 3 different types and diameters + +lattice sq 0.3 +Lattice spacing in x,y,z = 1.8257419 1.8257419 1.8257419 +region box block 0 10 0 10 -0.5 0.5 +create_box 4 box +Created orthogonal box = (0 0 -0.91287093) to (18.257419 18.257419 0.91287093) + 2 by 2 by 1 MPI processor grid +create_atoms 1 region box +Created 100 atoms + using lattice units in orthogonal box = (0 0 -0.91287093) to (18.257419 18.257419 0.91287093) + create_atoms CPU = 0.000 seconds + +group big type 1 +100 atoms in group big +set group big type/fraction 2 0.33 394895 +Setting atom values ... + 35 settings made for type/fraction +set group big type/fraction 3 0.5 989894 +Setting atom values ... + 57 settings made for type/fraction +group big type 2 3 +100 atoms in group big + +set type 1*3 mass 1.0 +Setting atom values ... + 100 settings made for mass +velocity big create 1.44 87287 loop geom + +# equilibrate big particles, repulsive only to prevent aggregation + +pair_style lj/cut 1.12 +pair_coeff 1 1 1.0 1.0 1.12 +pair_coeff 2 2 1.0 2.0 2.24 +pair_coeff 3 3 1.0 1.5 1.68 +pair_coeff 4 4 0.0 1.0 0.0 + +neighbor 0.3 bin +neigh_modify delay 0 every 1 check yes + +fix 1 big nve +fix 2 all enforce2d + +#dump 1 all atom 10 dump.poly.equil + +run 1000 +Generated 6 of 6 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 2.54 + ghost atom cutoff = 2.54 + binsize = 1.27, bins = 15 15 2 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/2d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 4.172 | 4.172 | 4.172 Mbytes + Step Temp E_pair E_mol TotEng Press + 0 1.44 -0.16013916 0 1.2654608 1.1298975 + 1000 1.3367862 -0.30816328 0 1.0152551 1.5440006 +Loop time of 0.00891987 on 4 procs for 1000 steps with 100 atoms + +Performance: 48431181.463 tau/day, 112109.216 timesteps/s, 11.211 Matom-step/s +98.2% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.00039835 | 0.00043547 | 0.00047558 | 0.0 | 4.88 +Neigh | 0.00033856 | 0.00036829 | 0.00038548 | 0.0 | 4.13 +Comm | 0.0065535 | 0.0065882 | 0.0066353 | 0.0 | 73.86 +Output | 1.0991e-05 | 1.2359e-05 | 1.4677e-05 | 0.0 | 0.14 +Modify | 0.00043639 | 0.00045662 | 0.00050811 | 0.0 | 5.12 +Other | | 0.001059 | | | 11.87 + +Nlocal: 25 ave 29 max 23 min +Histogram: 2 0 0 1 0 0 0 0 0 1 +Nghost: 33.75 ave 35 max 31 min +Histogram: 1 0 0 0 0 0 0 1 0 2 +Neighs: 38 ave 46 max 34 min +Histogram: 1 2 0 0 0 0 0 0 0 1 + +Total # of neighbors = 152 +Ave neighs/atom = 1.52 +Neighbor list builds = 115 +Dangerous builds = 0 + +#undump 1 +unfix 1 +unfix 2 + +# add small particles as hi density lattice + +region plane block INF INF INF INF -0.001 0.001 units box +lattice sq 250.0 +Lattice spacing in x,y,z = 0.063245553 0.063245553 0.063245553 +create_atoms 4 region plane +Created 83521 atoms + using lattice units in orthogonal box = (0 0 -0.91287093) to (18.257419 18.257419 0.91287093) + create_atoms CPU = 0.006 seconds + +set type 4 mass 0.1 +Setting atom values ... + 83521 settings made for mass +group small type 4 +83521 atoms in group small +velocity small create 1.0 593849 loop geom + +# delete overlaps +# must set *-4 cutoffs to non-zero values + +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 +pair_coeff 2 2 1.0 2.0 +pair_coeff 3 3 1.0 1.5 +pair_coeff 1 4 0.0 1.0 0.5 +pair_coeff 2 4 0.0 1.0 1.0 +pair_coeff 3 4 0.0 1.0 0.75 +pair_coeff 4 4 0.0 1.0 0.0 + +delete_atoms overlap 1.0 small big +System init for delete_atoms ... +Generated 3 of 6 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 2.8 + ghost atom cutoff = 2.8 + binsize = 1.4, bins = 14 14 2 + 2 neighbor lists, perpetual/occasional/extra = 1 1 0 + (1) command delete_atoms, occasional + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/2d + bin: standard + (2) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/2d + bin: standard +WARNING: Delete_atoms cutoff > minimum neighbor cutoff (src/delete_atoms.cpp:312) +Deleted 63410 atoms, new total = 20211 + +# SRD run + +reset_timestep 0 + +neighbor 0.3 multi +neigh_modify delay 0 every 1 check yes + +comm_modify mode multi group big vel yes +neigh_modify include big + +# no pairwise interactions with small particles + +pair_style lj/cut 1.12 +pair_coeff 1 1 1.0 1.0 1.12 +pair_coeff 2 2 1.0 2.0 2.24 +pair_coeff 3 3 1.0 1.5 1.68 +pair_coeff 4 4 0.0 1.0 0.0 + +# use fix SRD to push small particles out from inside big ones +# if comment out, big particles won't see SRD particles + +timestep 0.001 + +fix 1 big nve +fix 2 small srd 20 big 1.0 0.25 49894 shift yes 54979 search 0.2 inside ignore +fix 3 all enforce2d + +# diagnostics + +compute tbig big temp/sphere +variable pebig equal pe*atoms/count(big) +variable ebig equal etotal*atoms/count(big) +thermo_style custom step temp f_2[8] etotal v_pebig v_ebig press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] + +thermo_modify temp tbig +WARNING: Temperature for thermo pressure is not for group all (src/thermo.cpp:530) +thermo 1000 + +#dump 1 all atom 1000 dump.poly + +#dump 1 all image 1000 image.*.jpg type type zoom 1.6 +#dump_modify 1 pad 6 adiam 1 1 adiam 2 2.0 adiam 3 1.5 adiam 4 0.1 + +run 10000 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- neighbor multi command: doi:10.1016/j.cpc.2008.03.005, doi:10.1007/s40571-020-00361-2 + +@Article{Intveld08, + author = {in 't Veld, P. J. and S. J.~Plimpton and G. S. Grest}, + title = {Accurate and Efficient Methods for Modeling Colloidal + Mixtures in an Explicit Solvent using Molecular Dynamics}, + journal = {Comput.\ Phys.\ Commut.}, + year = 2008, + volume = 179, + pages = {320--329} +} + +@article{Shire2020, + author = {Shire, Tom and Hanley, Kevin J. and Stratford, Kevin}, + title = {{DEM} Simulations of Polydisperse Media: Efficient Contact + Detection Applied to Investigate the Quasi-Static Limit}, + journal = {Computational Particle Mechanics}, + year = {2020} +@article{Monti2022, + author = {Monti, Joseph M. and Clemmer, Joel T. and Srivastava, + Ishan and Silbert, Leonardo E. and Grest, Gary S. + and Lechman, Jeremy B.}, + title = {Large-scale frictionless jamming with power-law particle + size distributions}, + journal = {Phys. Rev. E}, + volume = {106} + issue = {3} + year = {2022} +} + +- fix srd command: doi:10.1063/1.3419070 + +@Article{Petersen10, + author = {M. K. Petersen and J. B. Lechman and S. J. Plimpton and + G. S. Grest and in 't Veld, P. J. and P. R. Schunk}, + title = {Mesoscale Hydrodynamics via Stochastic Rotation + Dynamics: Comparison with {L}ennard-{J}ones Fluid}, + journal = {J.~Chem.\ Phys.}, + year = 2010, + volume = 132, + pages = 174106 +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Generated 3 of 6 mixed pair_coeff terms from geometric mixing rule +SRD info: + SRD/big particles = 20111 100 + big particle diameter max/min = 1 1 + SRD temperature & lamda = 1 0.063245553 + SRD max distance & max velocity = 0.25298221 12.649111 + SRD grid counts: 73 73 1 + SRD grid size: request, actual (xyz) = 0.25, 0.25010162 0.25010162 1.8257419 + SRD per actual grid cell = 4.9371727 + SRD viscosity = 0.23321983 + big/SRD mass density ratio = 0.16131131 +WARNING: Fix srd grid size > 1/4 of big particle diameter (src/SRD/fix_srd.cpp:2830) + # of rescaled SRD velocities = 0 + ave/max small velocity = 4.1934421 7.74495 + ave/max big velocity = 1.4399093 3.5724039 +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 2.54 + ghost atom cutoff = 2.54 + binsize = 18.257419, bins = 1 1 1 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/multi/atomonly/newton + stencil: half/multi/2d + bin: multi +Per MPI rank memory allocation (min/avg/max) = 19.17 | 19.17 | 19.18 Mbytes + Step Temp f_2[8] TotEng v_pebig v_ebig Press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] + 0 0.88820023 0 0.0050232797 -0.30816328 1.0152551 1.5440006 0 0 0 0 0 0 0 0 0 0 0 + 1000 0.98459665 3968 0.0086216557 0.27547381 1.7425228 4.4010488 7403 34 34 0 663 25600 5329 3968 0.98292304 0 5 + 2000 0.74381104 4003 0.0041077507 -0.27806095 0.8302175 2.6170187 7746 32 32 0 1272 25600 5329 4003 1.0631936 0 5 + 3000 0.86305095 3969 0.0048953507 -0.29654658 0.98939933 2.1215334 7834 35 35 0 1974 25600 5329 3969 1.1209619 0 5 + 4000 0.8262932 4022 0.0049907905 -0.2224882 1.0086887 2.079935 8196 27 27 0 2753 25600 5329 4022 1.1040604 0 5 + 5000 0.85908819 4038 0.0043301633 -0.40487209 0.87516931 1.7917343 8347 28 28 0 3622 25600 5329 4038 1.1575336 0 5 + 6000 0.8048766 4024 0.0047529981 -0.2386377 0.96062844 1.8195477 8103 26 26 0 4536 25600 5329 4024 1.1818796 0 5 + 7000 0.84561126 4047 0.0039459142 -0.46245206 0.79750871 1.4432235 8154 20 20 0 5483 25600 5329 4047 1.1817402 0 5 + 8000 0.81543891 4037 0.0037591562 -0.45524091 0.75976306 1.7501338 8377 27 27 0 6472 25600 5329 4037 1.168956 0 5 + 9000 0.71960112 4045 0.0035243955 -0.3598901 0.71231557 1.7333111 8440 30 30 0 7386 25600 5329 4045 1.1765277 0 5 + 10000 1.0831334 4043 0.0053045911 -0.54175788 1.0721109 1.7434822 8283 33 33 0 8331 25600 5329 4043 1.1696048 0 5 +Loop time of 1.82855 on 4 procs for 10000 steps with 20211 atoms + +Performance: 472504.837 tau/day, 5468.806 timesteps/s, 110.530 Matom-step/s +99.3% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.0057481 | 0.0069625 | 0.0087051 | 1.3 | 0.38 +Neigh | 0.0067658 | 0.0070766 | 0.0076303 | 0.4 | 0.39 +Comm | 0.10613 | 0.10693 | 0.10786 | 0.2 | 5.85 +Output | 0.00053606 | 0.00059075 | 0.00063891 | 0.0 | 0.03 +Modify | 1.6117 | 1.6525 | 1.6763 | 1.9 | 90.37 +Other | | 0.05449 | | | 2.98 + +Nlocal: 5052.75 ave 5483 max 4509 min +Histogram: 1 0 0 0 0 1 1 0 0 1 +Nghost: 27 ave 28 max 26 min +Histogram: 2 0 0 0 0 0 0 0 0 2 +Neighs: 39.5 ave 55 max 26 min +Histogram: 1 0 0 1 0 1 0 0 0 1 + +Total # of neighbors = 158 +Ave neighs/atom = 0.0078175251 +Neighbor list builds = 500 +Dangerous builds = 0 +Total wall time: 0:00:03 diff --git a/examples/ASPHERE/poly/log.1Feb24.poly.mp.g++.1 b/examples/ASPHERE/poly/log.1Feb24.poly.mp.g++.1 new file mode 100644 index 0000000000..1804a3220d --- /dev/null +++ b/examples/ASPHERE/poly/log.1Feb24.poly.mp.g++.1 @@ -0,0 +1,318 @@ +LAMMPS (21 Nov 2023 - Development - patch_21Nov2023-665-g17f869bf5e) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# SRD viscosity demo - poydisperse spheres + +units lj +atom_style sphere +atom_modify first big +dimension 2 + +# create big particles with 3 different types and diameters + +lattice sq 0.3 +Lattice spacing in x,y,z = 1.8257419 1.8257419 1.8257419 +region box block 0 10 0 10 -0.5 0.5 +create_box 4 box +Created orthogonal box = (0 0 -0.91287093) to (18.257419 18.257419 0.91287093) + 1 by 1 by 1 MPI processor grid +create_atoms 1 region box +Created 100 atoms + using lattice units in orthogonal box = (0 0 -0.91287093) to (18.257419 18.257419 0.91287093) + create_atoms CPU = 0.000 seconds + +group big type 1 +100 atoms in group big +set group big type/fraction 2 0.33 394895 +Setting atom values ... + 35 settings made for type/fraction +set group big type/fraction 3 0.5 989894 +Setting atom values ... + 57 settings made for type/fraction +group big type 2 3 +100 atoms in group big + +set type 1*3 mass 1.0 +Setting atom values ... + 100 settings made for mass +velocity big create 1.44 87287 loop geom + +# equilibrate big particles, repulsive only to prevent aggregation + +pair_style lj/cut 1.12 +pair_coeff 1 1 1.0 1.0 1.12 +pair_coeff 2 2 1.0 2.0 2.24 +pair_coeff 3 3 1.0 1.5 1.68 +pair_coeff 4 4 0.0 1.0 0.0 + +neighbor 0.3 bin +neigh_modify delay 0 every 1 check yes + +fix 1 big nve +fix 2 all enforce2d + +#dump 1 all atom 10 dump.poly.equil + +run 1000 +Generated 6 of 6 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 2.54 + ghost atom cutoff = 2.54 + binsize = 1.27, bins = 15 15 2 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/2d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 4.174 | 4.174 | 4.174 Mbytes + Step Temp E_pair E_mol TotEng Press + 0 1.44 -0.16013916 0 1.2654608 1.1298975 + 1000 1.3367862 -0.30816328 0 1.0152551 1.5440006 +Loop time of 0.00627198 on 1 procs for 1000 steps with 100 atoms + +Performance: 68877814.583 tau/day, 159439.386 timesteps/s, 15.944 Matom-step/s +97.2% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.0016224 | 0.0016224 | 0.0016224 | 0.0 | 25.87 +Neigh | 0.0014238 | 0.0014238 | 0.0014238 | 0.0 | 22.70 +Comm | 0.0011671 | 0.0011671 | 0.0011671 | 0.0 | 18.61 +Output | 6.058e-06 | 6.058e-06 | 6.058e-06 | 0.0 | 0.10 +Modify | 0.0013659 | 0.0013659 | 0.0013659 | 0.0 | 21.78 +Other | | 0.0006868 | | | 10.95 + +Nlocal: 100 ave 100 max 100 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 60 ave 60 max 60 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 152 ave 152 max 152 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 152 +Ave neighs/atom = 1.52 +Neighbor list builds = 115 +Dangerous builds = 0 + +#undump 1 +unfix 1 +unfix 2 + +# add small particles as hi density lattice + +region plane block INF INF INF INF -0.001 0.001 units box +lattice sq 250.0 +Lattice spacing in x,y,z = 0.063245553 0.063245553 0.063245553 +create_atoms 4 region plane +Created 83521 atoms + using lattice units in orthogonal box = (0 0 -0.91287093) to (18.257419 18.257419 0.91287093) + create_atoms CPU = 0.017 seconds + +set type 4 mass 0.1 +Setting atom values ... + 83521 settings made for mass +group small type 4 +83521 atoms in group small +velocity small create 1.0 593849 loop geom + +# delete overlaps +# must set *-4 cutoffs to non-zero values + +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 +pair_coeff 2 2 1.0 2.0 +pair_coeff 3 3 1.0 1.5 +pair_coeff 1 4 0.0 1.0 0.5 +pair_coeff 2 4 0.0 1.0 1.0 +pair_coeff 3 4 0.0 1.0 0.75 +pair_coeff 4 4 0.0 1.0 0.0 + +delete_atoms overlap 1.0 small big +System init for delete_atoms ... +Generated 3 of 6 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 2.8 + ghost atom cutoff = 2.8 + binsize = 1.4, bins = 14 14 2 + 2 neighbor lists, perpetual/occasional/extra = 1 1 0 + (1) command delete_atoms, occasional + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/2d + bin: standard + (2) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/2d + bin: standard +WARNING: Delete_atoms cutoff > minimum neighbor cutoff (src/delete_atoms.cpp:312) +Deleted 63410 atoms, new total = 20211 + +# SRD run + +reset_timestep 0 + +neighbor 0.3 multi +neigh_modify delay 0 every 1 check yes + +comm_modify mode multi group big vel yes +neigh_modify include big + +# no pairwise interactions with small particles + +pair_style lj/cut 1.12 +pair_coeff 1 1 1.0 1.0 1.12 +pair_coeff 2 2 1.0 2.0 2.24 +pair_coeff 3 3 1.0 1.5 1.68 +pair_coeff 4 4 0.0 1.0 0.0 + +# use fix SRD to push small particles out from inside big ones +# if comment out, big particles won't see SRD particles + +timestep 0.001 + +fix 1 big nve +fix 2 small srd 20 big 1.0 0.25 49894 shift yes 54979 search 0.2 inside ignore +fix 3 small viscosity 10 x y 50 +fix 4 all enforce2d + +# diagnostics + +compute tbig big temp/sphere +variable pebig equal pe*atoms/count(big) +variable ebig equal etotal*atoms/count(big) +thermo_style custom step temp f_2[8] etotal v_pebig v_ebig press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] + +thermo_modify temp tbig +WARNING: Temperature for thermo pressure is not for group all (src/thermo.cpp:530) +thermo 1000 + +#dump 1 all atom 500 dump.poly.mp + +#dump 1 all image 500 image.*.jpg type type zoom 1.6 +#dump_modify 1 pad 6 adiam 1 1 adiam 2 2.0 adiam 3 1.5 adiam 4 0.1 + +run 10000 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- neighbor multi command: doi:10.1016/j.cpc.2008.03.005, doi:10.1007/s40571-020-00361-2 + +@Article{Intveld08, + author = {in 't Veld, P. J. and S. J.~Plimpton and G. S. Grest}, + title = {Accurate and Efficient Methods for Modeling Colloidal + Mixtures in an Explicit Solvent using Molecular Dynamics}, + journal = {Comput.\ Phys.\ Commut.}, + year = 2008, + volume = 179, + pages = {320--329} +} + +@article{Shire2020, + author = {Shire, Tom and Hanley, Kevin J. and Stratford, Kevin}, + title = {{DEM} Simulations of Polydisperse Media: Efficient Contact + Detection Applied to Investigate the Quasi-Static Limit}, + journal = {Computational Particle Mechanics}, + year = {2020} +@article{Monti2022, + author = {Monti, Joseph M. and Clemmer, Joel T. and Srivastava, + Ishan and Silbert, Leonardo E. and Grest, Gary S. + and Lechman, Jeremy B.}, + title = {Large-scale frictionless jamming with power-law particle + size distributions}, + journal = {Phys. Rev. E}, + volume = {106} + issue = {3} + year = {2022} +} + +- fix srd command: doi:10.1063/1.3419070 + +@Article{Petersen10, + author = {M. K. Petersen and J. B. Lechman and S. J. Plimpton and + G. S. Grest and in 't Veld, P. J. and P. R. Schunk}, + title = {Mesoscale Hydrodynamics via Stochastic Rotation + Dynamics: Comparison with {L}ennard-{J}ones Fluid}, + journal = {J.~Chem.\ Phys.}, + year = 2010, + volume = 132, + pages = 174106 +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Generated 3 of 6 mixed pair_coeff terms from geometric mixing rule +SRD info: + SRD/big particles = 20111 100 + big particle diameter max/min = 1 1 + SRD temperature & lamda = 1 0.063245553 + SRD max distance & max velocity = 0.25298221 12.649111 + SRD grid counts: 73 73 1 + SRD grid size: request, actual (xyz) = 0.25, 0.25010162 0.25010162 1.8257419 + SRD per actual grid cell = 4.9371727 + SRD viscosity = 0.23321983 + big/SRD mass density ratio = 0.16131131 +WARNING: Fix srd grid size > 1/4 of big particle diameter (src/SRD/fix_srd.cpp:2830) + # of rescaled SRD velocities = 0 + ave/max small velocity = 4.1934421 7.74495 + ave/max big velocity = 1.4399093 3.5724039 +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 2.54 + ghost atom cutoff = 2.54 + binsize = 18.257419, bins = 1 1 1 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/multi/atomonly/newton + stencil: half/multi/2d + bin: multi +Per MPI rank memory allocation (min/avg/max) = 42 | 42 | 42 Mbytes + Step Temp f_2[8] TotEng v_pebig v_ebig Press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] + 0 0.88820023 0 0.0050232797 -0.30816328 1.0152551 1.5440006 0 0 0 0 0 0 0 0 0 0 0 + 1000 0.9260989 3936 0.007125623 0.060272296 1.4401597 3.9323 7454 34 34 0 666 15876 5329 3936 0.98459206 0 28 + 2000 0.90353395 4000 0.0052889652 -0.27731283 1.0689528 2.6405627 7698 23 23 0 1382 15876 5329 4000 1.0797162 0 46 + 3000 0.90859187 3993 0.0052873224 -0.28518115 1.0686207 2.2965966 7968 31 31 0 2142 15876 5329 3993 1.1267833 0 46 + 4000 0.84755099 4048 0.005174979 -0.21693597 1.045915 2.3794577 8137 36 36 0 3087 15876 5329 4048 1.1357649 0 46 + 5000 0.970415 4034 0.0070498808 -0.021066942 1.4248514 2.7424457 8202 29 29 0 4119 15876 5329 4034 1.1354594 0 46 + 6000 1.3230208 4023 0.0094580142 -0.059741745 1.9115593 3.1405056 8259 36 36 0 5151 15876 5329 4023 1.1508111 0 46 + 7000 1.2356555 4022 0.0076141503 -0.30223075 1.5388959 2.2740088 8336 33 33 0 6277 15876 5329 4022 1.1814599 0 46 + 8000 1.0470467 4044 0.0077098735 -0.001857114 1.5582425 2.97413 8285 40 40 0 7399 15876 5329 4044 1.1644871 0 46 + 9000 1.0827168 4054 0.0062150407 -0.35712609 1.2561219 2.0991523 8454 31 31 0 8664 15876 5329 4054 1.1744383 0 46 + 10000 1.3953419 4031 0.0091083246 -0.23817595 1.8408835 2.4493963 8468 34 34 0 10227 15876 5329 4031 1.1657737 0 62 +Loop time of 5.74914 on 1 procs for 10000 steps with 20211 atoms + +Performance: 150283.390 tau/day, 1739.391 timesteps/s, 35.155 Matom-step/s +99.7% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.021224 | 0.021224 | 0.021224 | 0.0 | 0.37 +Neigh | 0.020586 | 0.020586 | 0.020586 | 0.0 | 0.36 +Comm | 0.057881 | 0.057881 | 0.057881 | 0.0 | 1.01 +Output | 0.00093386 | 0.00093386 | 0.00093386 | 0.0 | 0.02 +Modify | 5.579 | 5.579 | 5.579 | 0.0 | 97.04 +Other | | 0.06951 | | | 1.21 + +Nlocal: 20211 ave 20211 max 20211 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 50 ave 50 max 50 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 141 ave 141 max 141 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 141 +Ave neighs/atom = 0.006976399 +Neighbor list builds = 503 +Dangerous builds = 0 +Total wall time: 0:00:11 diff --git a/examples/ASPHERE/poly/log.1Feb24.poly.mp.g++.4 b/examples/ASPHERE/poly/log.1Feb24.poly.mp.g++.4 new file mode 100644 index 0000000000..a0a63e284c --- /dev/null +++ b/examples/ASPHERE/poly/log.1Feb24.poly.mp.g++.4 @@ -0,0 +1,318 @@ +LAMMPS (21 Nov 2023 - Development - patch_21Nov2023-665-g17f869bf5e) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# SRD viscosity demo - poydisperse spheres + +units lj +atom_style sphere +atom_modify first big +dimension 2 + +# create big particles with 3 different types and diameters + +lattice sq 0.3 +Lattice spacing in x,y,z = 1.8257419 1.8257419 1.8257419 +region box block 0 10 0 10 -0.5 0.5 +create_box 4 box +Created orthogonal box = (0 0 -0.91287093) to (18.257419 18.257419 0.91287093) + 2 by 2 by 1 MPI processor grid +create_atoms 1 region box +Created 100 atoms + using lattice units in orthogonal box = (0 0 -0.91287093) to (18.257419 18.257419 0.91287093) + create_atoms CPU = 0.000 seconds + +group big type 1 +100 atoms in group big +set group big type/fraction 2 0.33 394895 +Setting atom values ... + 35 settings made for type/fraction +set group big type/fraction 3 0.5 989894 +Setting atom values ... + 57 settings made for type/fraction +group big type 2 3 +100 atoms in group big + +set type 1*3 mass 1.0 +Setting atom values ... + 100 settings made for mass +velocity big create 1.44 87287 loop geom + +# equilibrate big particles, repulsive only to prevent aggregation + +pair_style lj/cut 1.12 +pair_coeff 1 1 1.0 1.0 1.12 +pair_coeff 2 2 1.0 2.0 2.24 +pair_coeff 3 3 1.0 1.5 1.68 +pair_coeff 4 4 0.0 1.0 0.0 + +neighbor 0.3 bin +neigh_modify delay 0 every 1 check yes + +fix 1 big nve +fix 2 all enforce2d + +#dump 1 all atom 10 dump.poly.equil + +run 1000 +Generated 6 of 6 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 2.54 + ghost atom cutoff = 2.54 + binsize = 1.27, bins = 15 15 2 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/2d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 4.172 | 4.172 | 4.172 Mbytes + Step Temp E_pair E_mol TotEng Press + 0 1.44 -0.16013916 0 1.2654608 1.1298975 + 1000 1.3367862 -0.30816328 0 1.0152551 1.5440006 +Loop time of 0.00883083 on 4 procs for 1000 steps with 100 atoms + +Performance: 48919544.759 tau/day, 113239.687 timesteps/s, 11.324 Matom-step/s +99.6% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.00040021 | 0.00044336 | 0.00050371 | 0.0 | 5.02 +Neigh | 0.00033682 | 0.00036617 | 0.00038566 | 0.0 | 4.15 +Comm | 0.006519 | 0.0065578 | 0.0066015 | 0.0 | 74.26 +Output | 1.1215e-05 | 1.2252e-05 | 1.4089e-05 | 0.0 | 0.14 +Modify | 0.00043326 | 0.00044482 | 0.00046058 | 0.0 | 5.04 +Other | | 0.001006 | | | 11.40 + +Nlocal: 25 ave 29 max 23 min +Histogram: 2 0 0 1 0 0 0 0 0 1 +Nghost: 33.75 ave 35 max 31 min +Histogram: 1 0 0 0 0 0 0 1 0 2 +Neighs: 38 ave 46 max 34 min +Histogram: 1 2 0 0 0 0 0 0 0 1 + +Total # of neighbors = 152 +Ave neighs/atom = 1.52 +Neighbor list builds = 115 +Dangerous builds = 0 + +#undump 1 +unfix 1 +unfix 2 + +# add small particles as hi density lattice + +region plane block INF INF INF INF -0.001 0.001 units box +lattice sq 250.0 +Lattice spacing in x,y,z = 0.063245553 0.063245553 0.063245553 +create_atoms 4 region plane +Created 83521 atoms + using lattice units in orthogonal box = (0 0 -0.91287093) to (18.257419 18.257419 0.91287093) + create_atoms CPU = 0.006 seconds + +set type 4 mass 0.1 +Setting atom values ... + 83521 settings made for mass +group small type 4 +83521 atoms in group small +velocity small create 1.0 593849 loop geom + +# delete overlaps +# must set *-4 cutoffs to non-zero values + +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 +pair_coeff 2 2 1.0 2.0 +pair_coeff 3 3 1.0 1.5 +pair_coeff 1 4 0.0 1.0 0.5 +pair_coeff 2 4 0.0 1.0 1.0 +pair_coeff 3 4 0.0 1.0 0.75 +pair_coeff 4 4 0.0 1.0 0.0 + +delete_atoms overlap 1.0 small big +System init for delete_atoms ... +Generated 3 of 6 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 2.8 + ghost atom cutoff = 2.8 + binsize = 1.4, bins = 14 14 2 + 2 neighbor lists, perpetual/occasional/extra = 1 1 0 + (1) command delete_atoms, occasional + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/2d + bin: standard + (2) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/2d + bin: standard +WARNING: Delete_atoms cutoff > minimum neighbor cutoff (src/delete_atoms.cpp:312) +Deleted 63410 atoms, new total = 20211 + +# SRD run + +reset_timestep 0 + +neighbor 0.3 multi +neigh_modify delay 0 every 1 check yes + +comm_modify mode multi group big vel yes +neigh_modify include big + +# no pairwise interactions with small particles + +pair_style lj/cut 1.12 +pair_coeff 1 1 1.0 1.0 1.12 +pair_coeff 2 2 1.0 2.0 2.24 +pair_coeff 3 3 1.0 1.5 1.68 +pair_coeff 4 4 0.0 1.0 0.0 + +# use fix SRD to push small particles out from inside big ones +# if comment out, big particles won't see SRD particles + +timestep 0.001 + +fix 1 big nve +fix 2 small srd 20 big 1.0 0.25 49894 shift yes 54979 search 0.2 inside ignore +fix 3 small viscosity 10 x y 50 +fix 4 all enforce2d + +# diagnostics + +compute tbig big temp/sphere +variable pebig equal pe*atoms/count(big) +variable ebig equal etotal*atoms/count(big) +thermo_style custom step temp f_2[8] etotal v_pebig v_ebig press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] + +thermo_modify temp tbig +WARNING: Temperature for thermo pressure is not for group all (src/thermo.cpp:530) +thermo 1000 + +#dump 1 all atom 500 dump.poly.mp + +#dump 1 all image 500 image.*.jpg type type zoom 1.6 +#dump_modify 1 pad 6 adiam 1 1 adiam 2 2.0 adiam 3 1.5 adiam 4 0.1 + +run 10000 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- neighbor multi command: doi:10.1016/j.cpc.2008.03.005, doi:10.1007/s40571-020-00361-2 + +@Article{Intveld08, + author = {in 't Veld, P. J. and S. J.~Plimpton and G. S. Grest}, + title = {Accurate and Efficient Methods for Modeling Colloidal + Mixtures in an Explicit Solvent using Molecular Dynamics}, + journal = {Comput.\ Phys.\ Commut.}, + year = 2008, + volume = 179, + pages = {320--329} +} + +@article{Shire2020, + author = {Shire, Tom and Hanley, Kevin J. and Stratford, Kevin}, + title = {{DEM} Simulations of Polydisperse Media: Efficient Contact + Detection Applied to Investigate the Quasi-Static Limit}, + journal = {Computational Particle Mechanics}, + year = {2020} +@article{Monti2022, + author = {Monti, Joseph M. and Clemmer, Joel T. and Srivastava, + Ishan and Silbert, Leonardo E. and Grest, Gary S. + and Lechman, Jeremy B.}, + title = {Large-scale frictionless jamming with power-law particle + size distributions}, + journal = {Phys. Rev. E}, + volume = {106} + issue = {3} + year = {2022} +} + +- fix srd command: doi:10.1063/1.3419070 + +@Article{Petersen10, + author = {M. K. Petersen and J. B. Lechman and S. J. Plimpton and + G. S. Grest and in 't Veld, P. J. and P. R. Schunk}, + title = {Mesoscale Hydrodynamics via Stochastic Rotation + Dynamics: Comparison with {L}ennard-{J}ones Fluid}, + journal = {J.~Chem.\ Phys.}, + year = 2010, + volume = 132, + pages = 174106 +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Generated 3 of 6 mixed pair_coeff terms from geometric mixing rule +SRD info: + SRD/big particles = 20111 100 + big particle diameter max/min = 1 1 + SRD temperature & lamda = 1 0.063245553 + SRD max distance & max velocity = 0.25298221 12.649111 + SRD grid counts: 73 73 1 + SRD grid size: request, actual (xyz) = 0.25, 0.25010162 0.25010162 1.8257419 + SRD per actual grid cell = 4.9371727 + SRD viscosity = 0.23321983 + big/SRD mass density ratio = 0.16131131 +WARNING: Fix srd grid size > 1/4 of big particle diameter (src/SRD/fix_srd.cpp:2830) + # of rescaled SRD velocities = 0 + ave/max small velocity = 4.1934421 7.74495 + ave/max big velocity = 1.4399093 3.5724039 +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 2.54 + ghost atom cutoff = 2.54 + binsize = 18.257419, bins = 1 1 1 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/multi/atomonly/newton + stencil: half/multi/2d + bin: multi +Per MPI rank memory allocation (min/avg/max) = 19.17 | 19.17 | 19.18 Mbytes + Step Temp f_2[8] TotEng v_pebig v_ebig Press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] + 0 0.88820023 0 0.0050232797 -0.30816328 1.0152551 1.5440006 0 0 0 0 0 0 0 0 0 0 0 + 1000 0.83735494 3964 0.0071370659 0.19481352 1.4424724 3.9770741 7472 25 25 0 603 25600 5329 3964 0.96475118 0 2 + 2000 0.89694821 3981 0.0057098818 -0.18242861 1.1540242 3.1251883 7672 28 28 0 1238 25600 5329 3981 1.0589985 0 2 + 3000 0.99778172 3975 0.0051822049 -0.43931933 1.0473754 1.8970896 7814 24 24 0 1968 25600 5329 3975 1.1192504 0 3 + 4000 0.90067439 4030 0.0045096255 -0.43056442 0.91144042 1.8769981 8104 33 33 0 2911 25600 5329 4030 1.1382082 0 3 + 5000 0.90625848 4018 0.0055622776 -0.22613322 1.1241919 2.1866405 8287 26 26 0 3900 25600 5329 4018 1.1429442 0 3 + 6000 1.1284139 4022 0.0065653291 -0.354418 1.3269187 2.0312152 8268 35 35 0 5013 25600 5329 4022 1.1559733 0 3 + 7000 1.0073477 4043 0.0063924548 -0.2089691 1.291979 2.3332058 8433 39 39 0 6093 25600 5329 4043 1.1308958 0 3 + 8000 1.0621801 4050 0.00731979 -0.10324558 1.4794028 2.6610716 8353 40 40 0 7194 25600 5329 4050 1.1539521 0 3 + 9000 1.3173319 4046 0.0085268497 -0.23946297 1.7233616 2.4074596 8290 33 33 0 8498 25600 5329 4046 1.1601502 0 3 + 10000 1.1754738 4009 0.0074264713 -0.25049186 1.5009641 2.4237351 8305 30 30 0 9811 25600 5329 4009 1.1489476 0 43 +Loop time of 1.85719 on 4 procs for 10000 steps with 20211 atoms + +Performance: 465218.852 tau/day, 5384.477 timesteps/s, 108.826 Matom-step/s +99.3% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.0056791 | 0.0069765 | 0.0089852 | 1.6 | 0.38 +Neigh | 0.006991 | 0.0073805 | 0.0079507 | 0.4 | 0.40 +Comm | 0.10756 | 0.10836 | 0.10942 | 0.2 | 5.83 +Output | 0.00052479 | 0.0005511 | 0.00062567 | 0.0 | 0.03 +Modify | 1.6443 | 1.6772 | 1.7031 | 1.7 | 90.31 +Other | | 0.0567 | | | 3.05 + +Nlocal: 5052.75 ave 5381 max 4651 min +Histogram: 1 0 0 0 1 0 0 1 0 1 +Nghost: 28.5 ave 30 max 26 min +Histogram: 1 0 0 0 0 0 0 2 0 1 +Neighs: 34.75 ave 55 max 26 min +Histogram: 2 0 1 0 0 0 0 0 0 1 + +Total # of neighbors = 139 +Ave neighs/atom = 0.006877443 +Neighbor list builds = 501 +Dangerous builds = 0 +Total wall time: 0:00:03 diff --git a/examples/ASPHERE/star/in.star b/examples/ASPHERE/star/in.star index a098810199..db76c890e8 100644 --- a/examples/ASPHERE/star/in.star +++ b/examples/ASPHERE/star/in.star @@ -1,111 +1,111 @@ # SRD diffusion demo - rigid star particles -units lj -atom_style sphere -atom_modify map array first big -dimension 2 +units lj +atom_style sphere +atom_modify map array first big +dimension 2 # read in clusters of rigid bodies -fix molprop all property/atom mol -read_data data.star fix molprop NULL Molecules +fix molprop all property/atom mol ghost yes +read_data data.star fix molprop NULL Molecules + +set type 1 mass 1.0 +group big type 1 +velocity big create 1.44 87287 loop geom -set type 1 mass 1.0 -group big type 1 -velocity big create 1.44 87287 loop geom - # equilibrate big particles -pair_style soft 1.12 -pair_coeff 1 1 0.0 -pair_coeff 2 2 0.0 0.0 -pair_coeff 1 2 0.0 0.0 +pair_style soft 1.12 +pair_coeff 1 1 0.0 +pair_coeff 2 2 0.0 0.0 +pair_coeff 1 2 0.0 0.0 variable prefactor equal ramp(0,60) fix soft all adapt 1 pair soft a * * v_prefactor -neighbor 0.3 bin -neigh_modify delay 0 every 1 check yes +neighbor 0.3 bin +neigh_modify delay 0 every 1 check yes -fix 1 big rigid molecule -fix 2 all enforce2d +fix 1 big rigid molecule +fix 2 all enforce2d -#dump 1 all atom 10 dump.star.equil +#dump 1 all atom 10 dump.star.equil -compute tbig all temp/sphere -thermo_modify temp tbig +compute tbig all temp/sphere +thermo_modify temp tbig -thermo 100 -run 1000 +thermo 100 +run 1000 -#undump 1 +#undump 1 unfix soft -unfix 1 -unfix 2 +unfix 1 +unfix 2 # add small particles as hi density lattice -region plane block INF INF INF INF -0.001 0.001 units box -lattice sq 85.0 -create_atoms 2 region plane +region plane block INF INF INF INF -0.001 0.001 units box +lattice sq 85.0 +create_atoms 2 region plane -set type 2 mass 0.1 -group small type 2 -velocity small create 1.0 593849 loop geom +set type 2 mass 0.1 +group small type 2 +velocity small create 1.0 593849 loop geom # delete overlaps # must set 1-2 cutoff to non-zero value -pair_style lj/cut 2.5 -pair_coeff 1 1 1.0 1.0 -pair_coeff 2 2 0.0 1.0 0.0 -pair_coeff 1 2 0.0 1.0 0.5 +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 +pair_coeff 2 2 0.0 1.0 0.0 +pair_coeff 1 2 0.0 1.0 0.5 -delete_atoms overlap 0.5 small big +delete_atoms overlap 0.5 small big # SRD run -reset_timestep 0 +reset_timestep 0 -neighbor 0.3 multi -neigh_modify delay 0 every 1 check yes +neighbor 0.3 multi +neigh_modify delay 0 every 1 check yes -comm_modify mode multi group big vel yes -neigh_modify include big +comm_modify mode multi group big vel yes +neigh_modify include big # no pairwise interactions with small particles -pair_style lj/cut 2.5 -pair_coeff 1 1 1.0 1.0 -pair_coeff 2 2 0.0 1.0 0.0 -pair_coeff 1 2 0.0 1.0 0.0 +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 +pair_coeff 2 2 0.0 1.0 0.0 +pair_coeff 1 2 0.0 1.0 0.0 # use fix SRD to push small particles out from inside big ones # if comment out, big particles won't see SRD particles -timestep 0.001 +timestep 0.001 -fix 1 big rigid molecule -fix 2 small srd 20 big 1.0 0.25 49894 shift yes 54979 & - search 0.2 collision slip inside ignore overlap yes -fix 3 all enforce2d +fix 1 big rigid molecule +fix 2 small srd 20 big 1.0 0.25 49894 shift yes 54979 & + search 0.2 collision slip inside ignore overlap yes +fix 3 all enforce2d # diagnostics uncompute tbig -compute tbig big temp/sphere -variable pebig equal pe*atoms/count(big) -variable ebig equal etotal*atoms/count(big) -thermo_style custom step temp f_2[8] etotal v_pebig v_ebig press & - f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] & - f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] f_2[12] +compute tbig big temp/sphere +variable pebig equal pe*atoms/count(big) +variable ebig equal etotal*atoms/count(big) +thermo_style custom step temp f_2[8] etotal v_pebig v_ebig press & + f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] & + f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] f_2[12] -thermo_modify temp tbig -thermo 1000 +thermo_modify temp tbig +thermo 1000 -#dump 1 all atom 1000 dump.star +#dump 1 all atom 1000 dump.star -#dump 1 all image 1000 image.*.jpg type type zoom 1.6 -#dump_modify 1 pad 6 adiam 1 1 adiam 2 0.2 +#dump 1 all image 1000 image.*.jpg type type zoom 1.6 +#dump_modify 1 pad 6 adiam 1 1 adiam 2 0.2 -run 100000 +run 10000 diff --git a/examples/ASPHERE/star/in.star.mp b/examples/ASPHERE/star/in.star.mp index 53cb924e42..781b2f48fd 100644 --- a/examples/ASPHERE/star/in.star.mp +++ b/examples/ASPHERE/star/in.star.mp @@ -1,112 +1,112 @@ # SRD viscosity demo - rigid star particles -units lj -atom_style sphere -atom_modify map array first big -dimension 2 +units lj +atom_style sphere +atom_modify map array first big +dimension 2 # read in clusters of rigid bodies -fix molprop all property/atom mol -read_data data.star fix molprop NULL Molecules +fix molprop all property/atom mol ghost yes +read_data data.star fix molprop NULL Molecules + +set type 1 mass 1.0 +group big type 1 +velocity big create 1.44 87287 loop geom -set type 1 mass 1.0 -group big type 1 -velocity big create 1.44 87287 loop geom - # equilibrate big particles -pair_style soft 1.12 -pair_coeff 1 1 0.0 -pair_coeff 2 2 0.0 0.0 -pair_coeff 1 2 0.0 0.0 +pair_style soft 1.12 +pair_coeff 1 1 0.0 +pair_coeff 2 2 0.0 0.0 +pair_coeff 1 2 0.0 0.0 variable prefactor equal ramp(0,60) fix soft all adapt 1 pair soft a * * v_prefactor -neighbor 0.3 bin -neigh_modify delay 0 every 1 check yes +neighbor 0.3 bin +neigh_modify delay 0 every 1 check yes -fix 1 big rigid molecule -fix 2 all enforce2d +fix 1 big rigid molecule +fix 2 all enforce2d -#dump 1 all atom 10 dump.star.equil +#dump 1 all atom 10 dump.star.equil -compute tbig all temp/sphere -thermo_modify temp tbig +compute tbig all temp/sphere +thermo_modify temp tbig -thermo 100 -run 1000 +thermo 100 +run 1000 -#undump 1 +#undump 1 unfix soft -unfix 1 -unfix 2 +unfix 1 +unfix 2 # add small particles as hi density lattice -region plane block INF INF INF INF -0.001 0.001 units box -lattice sq 85.0 -create_atoms 2 region plane +region plane block INF INF INF INF -0.001 0.001 units box +lattice sq 85.0 +create_atoms 2 region plane -set type 2 mass 0.1 -group small type 2 -velocity small create 1.0 593849 loop geom +set type 2 mass 0.1 +group small type 2 +velocity small create 1.0 593849 loop geom # delete overlaps # must set 1-2 cutoff to non-zero value -pair_style lj/cut 2.5 -pair_coeff 1 1 1.0 1.0 -pair_coeff 2 2 0.0 1.0 0.0 -pair_coeff 1 2 0.0 1.0 0.5 +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 +pair_coeff 2 2 0.0 1.0 0.0 +pair_coeff 1 2 0.0 1.0 0.5 -delete_atoms overlap 0.5 small big +delete_atoms overlap 0.5 small big # SRD run -reset_timestep 0 +reset_timestep 0 -neighbor 0.3 multi -neigh_modify delay 0 every 1 check yes +neighbor 0.3 multi +neigh_modify delay 0 every 1 check yes -comm_modify mode multi group big vel yes -neigh_modify include big +comm_modify mode multi group big vel yes +neigh_modify include big # no pairwise interactions with small particles -pair_style lj/cut 2.5 -pair_coeff 1 1 1.0 1.0 -pair_coeff 2 2 0.0 1.0 0.0 -pair_coeff 1 2 0.0 1.0 0.0 +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 +pair_coeff 2 2 0.0 1.0 0.0 +pair_coeff 1 2 0.0 1.0 0.0 # use fix SRD to push small particles out from inside big ones # if comment out, big particles won't see SRD particles -timestep 0.001 +timestep 0.001 -fix 1 big rigid molecule -fix 2 small srd 20 big 1.0 0.25 49894 shift yes 54979 & - search 0.2 collision slip inside ignore overlap yes -fix 3 small viscosity 10 x y 50 -fix 4 all enforce2d +fix 1 big rigid molecule +fix 2 small srd 20 big 1.0 0.25 49894 shift yes 54979 & + search 0.2 collision slip inside ignore overlap yes +fix 3 small viscosity 10 x y 50 +fix 4 all enforce2d # diagnostics uncompute tbig -compute tbig big temp/sphere -variable pebig equal pe*atoms/count(big) -variable ebig equal etotal*atoms/count(big) -thermo_style custom step temp f_2[8] etotal v_pebig v_ebig press & - f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] & - f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] f_2[12] +compute tbig big temp/sphere +variable pebig equal pe*atoms/count(big) +variable ebig equal etotal*atoms/count(big) +thermo_style custom step temp f_2[8] etotal v_pebig v_ebig press & + f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] & + f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] f_2[12] -thermo_modify temp tbig -thermo 1000 +thermo_modify temp tbig +thermo 1000 -#dump 1 all atom 1000 dump.star.mp +#dump 1 all atom 1000 dump.star.mp -#dump 1 all image 1000 image.*.jpg type type zoom 1.6 -#dump_modify 1 pad 6 adiam 1 1 adiam 2 0.2 +#dump 1 all image 1000 image.*.jpg type type zoom 1.6 +#dump_modify 1 pad 6 adiam 1 1 adiam 2 0.2 -run 100000 +run 10000 diff --git a/examples/ASPHERE/star/log.1Feb14.star.g++.8 b/examples/ASPHERE/star/log.1Feb14.star.g++.8 deleted file mode 100644 index 3ccc04ff26..0000000000 --- a/examples/ASPHERE/star/log.1Feb14.star.g++.8 +++ /dev/null @@ -1,290 +0,0 @@ -LAMMPS (1 Feb 2014) -# SRD diffusion demo - rigid star particles - -units lj -atom_style sphere -atom_modify map array first big -dimension 2 - -# read in clusters of rigid bodies - -fix molprop all property/atom mol -read_data data.star fix molprop NULL Molecules - orthogonal box = (-13.2934 -13.2934 -0.5) to (13.2934 13.2934 0.5) - 4 by 2 by 1 MPI processor grid - reading atoms ... - 270 atoms - -set type 1 mass 1.0 - 270 settings made for mass -group big type 1 -270 atoms in group big -velocity big create 1.44 87287 loop geom - -# equilibrate big particles - -pair_style soft 1.12 -pair_coeff 1 1 0.0 -pair_coeff 2 2 0.0 0.0 -pair_coeff 1 2 0.0 0.0 - -variable prefactor equal ramp(0,60) -fix soft all adapt 1 pair soft a * * v_prefactor - -neighbor 0.3 bin -neigh_modify delay 0 every 1 check yes - -fix 1 big rigid molecule -30 rigid bodies with 270 atoms -fix 2 all enforce2d - -#dump 1 all atom 10 dump.star.equil - -thermo 100 -run 1000 -Memory usage per processor = 2.64859 Mbytes -Step Temp E_pair E_mol TotEng Press - 0 0 0 0 0 0.24721146 - 100 0 3.291475 0 3.291475 0.69158089 - 200 0 4.6176595 0 4.6176595 0.71737945 - 300 0 7.0921814 0 7.0921814 1.2163497 - 400 0 8.3666709 0 8.3666709 0.50645957 - 500 0 10.630838 0 10.630838 0.72764487 - 600 0 12.42157 0 12.42157 1.0130599 - 700 0 14.349074 0 14.349074 0.74795509 - 800 0 16.464746 0 16.464746 1.054549 - 900 0 18.253108 0 18.253108 0.51551753 - 1000 0 20.699563 0 20.699563 1.8084662 -Loop time of 0.040709 on 8 procs for 1000 steps with 270 atoms - -Pair time (%) = 0.00249004 (6.11668) -Neigh time (%) = 0.000995547 (2.44552) -Comm time (%) = 0.0116902 (28.7165) -Outpt time (%) = 0.000232756 (0.571755) -Other time (%) = 0.0253005 (62.1496) - -Nlocal: 33.75 ave 42 max 22 min -Histogram: 1 0 1 0 0 2 0 1 1 2 -Nghost: 23.375 ave 30 max 14 min -Histogram: 1 0 1 0 0 2 1 0 1 2 -Neighs: 52.25 ave 69 max 27 min -Histogram: 1 0 1 0 1 0 1 1 1 2 - -Total # of neighbors = 418 -Ave neighs/atom = 1.54815 -Neighbor list builds = 176 -Dangerous builds = 0 - -#undump 1 -unfix soft -unfix 1 -unfix 2 - -# add small particles as hi density lattice - -region plane block INF INF INF INF -0.001 0.001 units box -lattice sq 85.0 -Lattice spacing in x,y,z = 0.108465 0.108465 0.108465 -create_atoms 2 region plane -Created 60025 atoms - -set type 2 mass 0.1 - 60025 settings made for mass -group small type 2 -60025 atoms in group small -velocity small create 1.0 593849 loop geom - -# delete overlaps -# must set 1-2 cutoff to non-zero value - -pair_style lj/cut 2.5 -pair_coeff 1 1 1.0 1.0 -pair_coeff 2 2 0.0 1.0 0.0 -pair_coeff 1 2 0.0 1.0 0.5 - -delete_atoms overlap 0.5 small big -Deleted 16305 atoms, new total = 43990 - -# SRD run - -reset_timestep 0 - -neighbor 0.3 bin -neigh_modify delay 0 every 1 check yes - -communicate multi group big vel yes -neigh_modify include big - -# no pairwise interactions with small particles - -pair_style lj/cut 2.5 -pair_coeff 1 1 1.0 1.0 -pair_coeff 2 2 0.0 1.0 0.0 -pair_coeff 1 2 0.0 1.0 0.0 - -# use fix SRD to push small particles out from inside big ones -# if comment out, big particles won't see SRD particles - -timestep 0.001 - -fix 1 big rigid molecule -30 rigid bodies with 270 atoms -fix 2 small srd 20 big 1.0 0.25 49894 shift yes 54979 search 0.2 collision slip inside ignore overlap yes -fix 3 all enforce2d - -# diagnostics - -compute tbig big temp/sphere -variable pebig equal pe*atoms/count(big) -variable ebig equal etotal*atoms/count(big) -thermo_style custom step temp f_2[8] etotal v_pebig v_ebig press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] f_2[12] - -thermo_modify temp tbig -WARNING: Temperature for thermo pressure is not for group all (../thermo.cpp:439) -thermo 1000 - -#dump 1 all atom 1000 dump.star - -#dump 1 all image 1000 image.*.jpg type type zoom 1.6 -#dump_modify 1 pad 6 adiam 1 1 adiam 2 0.2 - -run 100000 -SRD info: - SRD/big particles = 43720 270 - big particle diameter max/min = 1 1 - SRD temperature & lamda = 1 0.0632456 - SRD max distance & max velocity = 0.252982 12.6491 - SRD grid counts: 106 106 1 - SRD grid size: request, actual (xyz) = 0.25, 0.250819 0.250819 1 - SRD per actual grid cell = 5.55866 - SRD viscosity = 0.235582 - big/SRD mass density ratio = 0.144099 -WARNING: Fix srd grid size > 1/4 of big particle diameter (../fix_srd.cpp:2875) - # of rescaled SRD velocities = 0 - ave/max small velocity = 4.19085 7.72582 - ave/max big velocity = 2.20262 5.4168 -Memory usage per processor = 7.83759 Mbytes -Step Temp 2[8] TotEng pebig ebig Press 2[1] 2[2] 2[3] 2[4] 2[5] 2[6] 2[7] 2[8] 2[9] 2[10] 2[11] 2[12] - 0 18.299191 0 0.25067776 37.859815 40.841906 5.7680841 0 0 0 0 0 0 0 0 0 0 0 0 - 1000 1.3155168 8201 0.22979575 37.225304 37.439685 8.9588433 14577 56 56 0 687 57680 11236 8201 1.0283377 0 5 0 - 2000 0.82290815 8187 0.22918912 37.206746 37.340849 6.0607727 14326 56 56 0 1524 57680 11236 8187 1.0127464 0 5 0 - 3000 0.99928391 8168 0.22921842 37.182777 37.345623 10.268998 14389 68 68 0 2274 57680 11236 8168 1.023497 0 5 0 - 4000 1.0348458 8200 0.22920437 37.174693 37.343335 9.8954805 14335 51 51 0 3047 57680 11236 8200 1.0156984 0 5 0 - 5000 1.1496765 8199 0.22939095 37.186379 37.373733 8.0143223 14444 74 74 0 3868 57680 11236 8199 1.0104858 0 5 0 - 6000 0.91767381 8225 0.2292466 37.200668 37.350215 8.6189298 14131 61 61 0 4594 57680 11236 8225 1.0147272 0 5 0 - 7000 0.74806752 8203 0.22888634 37.169611 37.291518 9.8613421 14121 53 53 1 5322 57680 11236 8203 1.0198289 0 19 0 - 8000 1.1177867 8213 0.22924801 37.168286 37.350444 7.911691 14380 62 62 0 6024 57680 11236 8213 1.0066799 0 19 0 - 9000 1.1258411 8209 0.22939703 37.191253 37.374723 6.7377179 14350 51 51 0 6821 57680 11236 8209 1.0081225 0 19 0 - 10000 1.0597344 8182 0.22919436 37.169006 37.341703 9.7769156 14372 48 48 0 7543 57680 11236 8182 1.0099373 0 19 0 - 11000 1.3337199 8159 0.22943046 37.162823 37.38017 6.0897666 14359 58 58 0 8245 57680 11236 8159 1.0046221 0 19 0 - 12000 1.0280975 8184 0.22894286 37.133186 37.300728 2.555317 14162 51 51 0 8935 57680 11236 8184 1.0010306 0 19 0 - 13000 1.2318533 8190 0.22921487 37.144299 37.345045 6.1739989 14285 64 64 0 9634 57680 11236 8190 1.0138112 0 19 0 - 14000 1.1851991 8215 0.22915708 37.142485 37.335629 7.8380175 14151 66 66 0 10407 57680 11236 8215 1.0008011 0 19 0 - 15000 0.89853218 8214 0.22897294 37.159201 37.305628 4.0743953 14077 61 61 0 11069 57680 11236 8214 1.0041341 0 19 0 - 16000 1.0295974 8176 0.22891205 37.127921 37.295708 8.7527117 14000 48 48 0 11832 57680 11236 8176 1.0089653 0 23 0 - 17000 1.1793664 8219 0.22906268 37.128056 37.320249 5.2583304 14268 57 57 0 12490 57680 11236 8219 1.0157079 0 23 0 - 18000 0.90486919 8180 0.22891008 37.147927 37.295387 4.8498125 13939 64 64 0 13154 57680 11236 8180 0.99700921 0 23 0 - 19000 0.81486319 8219 0.22881911 37.147773 37.280566 1.6338041 13934 59 59 1 13861 57680 11236 8219 1.0099189 0 23 0 - 20000 1.0146287 8180 0.22896254 37.138587 37.303934 2.1682593 14057 45 45 0 14593 57680 11236 8180 1.0009466 0 23 0 - 21000 1.3031463 8164 0.22920646 37.131309 37.343674 6.570906 13944 65 65 0 15323 57680 11236 8164 0.98955239 0 23 0 - 22000 1.1258162 8174 0.22915084 37.151147 37.334613 9.0817519 14052 56 56 0 16042 57680 11236 8174 1.0083228 0 23 0 - 23000 1.1421222 8217 0.22906722 37.134865 37.320989 8.0529401 14143 66 66 0 16797 57680 11236 8217 1.0111161 0 23 0 - 24000 0.77402445 8168 0.22883056 37.156294 37.282431 6.8609899 14258 62 62 0 17559 57680 11236 8168 1.0080535 0 23 0 - 25000 0.94006632 8215 0.22879533 37.123496 37.276692 3.8570839 14446 48 48 0 18267 57680 11236 8215 1.0087899 0 23 0 - 26000 1.2808563 8192 0.22933112 37.155253 37.363985 5.3591484 13960 54 54 1 19004 57680 11236 8192 1.0101851 0 79 0 - 27000 1.0266075 8171 0.22898652 37.140542 37.307841 2.9961422 14049 56 56 1 19683 57680 11236 8171 0.99950217 0 79 0 - 28000 0.98185838 8199 0.22867129 37.096475 37.256481 12.080529 14106 61 62 0 20417 57680 11236 8199 1.0026548 0 79 0 - 29000 0.96921352 8192 0.22861802 37.089856 37.247802 8.257635 13891 63 64 0 21169 57680 11236 8192 1.0128041 0 79 0 - 30000 1.0107665 8223 0.22866616 37.090929 37.255646 9.4280788 14021 61 61 1 21863 57680 11236 8223 1.0034994 0 79 0 - 31000 1.1859435 8195 0.22877222 37.079661 37.272926 7.3863353 14093 78 78 0 22480 57680 11236 8195 0.9945582 0 79 0 - 32000 1.2951374 8172 0.22897044 37.094161 37.30522 6.4322363 13792 52 52 0 23151 57680 11236 8172 1.0026092 0 79 0 - 33000 0.82899919 8176 0.22823894 37.050944 37.186041 0.60210493 13797 62 62 0 23903 57680 11236 8176 1.0051075 0 79 0 - 34000 0.96685714 8165 0.22828901 37.036637 37.194199 8.1409866 13837 50 50 0 24591 57680 11236 8165 1.0157895 0 79 0 - 35000 0.95645753 8206 0.22833008 37.045022 37.200889 8.9956195 14130 63 63 0 25340 57680 11236 8206 1.0030424 0 79 0 - 36000 1.2933379 8197 0.22879201 37.065383 37.27615 8.3938627 13978 80 80 0 26085 57680 11236 8197 1.0094497 0 79 0 - 37000 1.1511434 8176 0.22861016 37.058929 37.246523 4.9481995 13856 49 49 1 26759 57680 11236 8176 1.0063722 0 79 0 - 38000 0.93310274 8181 0.22837532 37.056199 37.20826 5.9575015 13949 51 51 0 27445 57680 11236 8181 1.0152607 0 79 0 - 39000 1.0352467 8215 0.22861437 37.078501 37.247208 9.8519532 14109 69 69 0 28245 57680 11236 8215 1.005523 0 79 0 - 40000 1.2696427 8193 0.22885162 37.078957 37.285862 8.4680587 13931 54 55 0 28960 57680 11236 8193 1.0014074 0 79 0 - 41000 1.3270531 8193 0.22909573 37.109374 37.325634 4.3731598 14115 62 62 0 29668 57680 11236 8193 1.0022493 0 79 0 - 42000 1.3650738 8183 0.22911257 37.105921 37.328377 6.6345101 13659 52 52 0 30400 57680 11236 8183 1.0145834 0 79 0 - 43000 1.0780084 8209 0.22855316 37.06156 37.237235 5.5147087 14062 52 52 0 31092 57680 11236 8209 1.0031365 0 79 0 - 44000 0.96146724 8193 0.22846546 37.066263 37.222946 9.7967735 13699 56 56 0 31771 57680 11236 8193 1.0072364 0 79 0 - 45000 1.1733618 8200 0.2286481 37.061489 37.252703 9.8058881 13967 51 52 0 32532 57680 11236 8200 1.0068663 0 79 0 - 46000 0.94784989 8211 0.22845052 37.066048 37.220513 5.8834756 13944 34 35 0 33213 57680 11236 8211 1.0080225 0 79 0 - 47000 1.2354771 8207 0.22859598 37.042876 37.244213 6.1458407 13851 56 56 0 33886 57680 11236 8207 1.0151781 0 79 0 - 48000 1.0834097 8164 0.22835968 37.029157 37.205712 6.7378814 13944 56 56 0 34578 57680 11236 8164 1.0128575 0 79 0 - 49000 0.9386786 8208 0.22837254 37.054838 37.207808 5.0809383 13618 53 53 0 35328 57680 11236 8208 1.0045622 0 79 0 - 50000 1.047176 8154 0.22859126 37.072791 37.243442 4.8016981 13847 55 55 0 36059 57680 11236 8154 1.0005378 0 79 0 - 51000 1.0943417 8222 0.22844191 37.040773 37.21911 7.9359541 13897 61 61 0 36711 57680 11236 8222 1.0036343 0 79 0 - 52000 1.2811259 8200 0.22871149 37.054255 37.263031 4.9958687 13744 56 56 0 37402 57680 11236 8200 1.0049188 0 79 0 - 53000 1.0997162 8218 0.22853173 37.05453 37.233743 4.6772882 13967 65 65 0 38082 57680 11236 8218 1.0054533 0 79 0 - 54000 0.97625718 8185 0.2283994 37.05309 37.212184 5.9026406 13741 69 69 0 38761 57680 11236 8185 0.99393606 0 79 0 - 55000 0.97919465 8192 0.22835234 37.044944 37.204516 6.8419755 13990 58 58 0 39453 57680 11236 8192 1.0103052 0 79 0 - 56000 0.86300824 8181 0.22842164 37.075169 37.215808 6.8288348 13751 57 57 0 40118 57680 11236 8181 0.99683099 0 79 0 - 57000 0.89429559 8181 0.22851743 37.085677 37.231414 9.378853 13746 72 72 0 40730 57680 11236 8181 1.0086882 0 79 0 - 58000 1.0853441 8172 0.22857719 37.064279 37.24115 7.4580035 13869 58 58 1 41462 57680 11236 8172 1.0092141 0 79 0 - 59000 1.0149632 8199 0.22868187 37.092803 37.258205 8.2913359 13720 54 54 0 42159 57680 11236 8199 1.0082738 0 79 0 - 60000 0.99214038 8241 0.22871146 37.101344 37.263026 7.9905647 13776 67 67 0 42858 57680 11236 8241 1.0027929 0 79 0 - 61000 0.95721926 8211 0.2285241 37.07651 37.232501 11.837258 13907 62 62 0 43565 57680 11236 8211 1.0201117 0 79 0 - 62000 1.1457294 8195 0.22866514 37.068769 37.25548 9.7934944 13796 40 40 1 44292 57680 11236 8195 1.005192 0 79 0 - 63000 1.1096177 8193 0.22863037 37.068989 37.249815 8.0809047 13984 54 55 0 44986 57680 11236 8193 1.0076438 0 79 0 - 64000 1.1643495 8168 0.22860016 37.055147 37.244893 4.7376475 13857 50 50 1 45657 57680 11236 8168 1.002011 0 79 0 - 65000 1.2172585 8201 0.22845803 37.023368 37.221736 8.9744616 13610 53 53 0 46295 57680 11236 8201 1.0033999 0 79 0 - 66000 0.99924611 8189 0.22807344 36.996237 37.159077 8.5854786 13849 49 49 0 46944 57680 11236 8189 1.015528 0 79 0 - 67000 1.2543542 8165 0.22831075 36.993327 37.19774 5.0081411 13906 57 58 1 47666 57680 11236 8165 1.0189753 0 79 0 - 68000 1.0360874 8205 0.22812149 36.99806 37.166904 2.2431831 13650 52 52 0 48363 57680 11236 8205 1.0076864 0 79 0 - 69000 0.69755552 8218 0.22766249 36.978446 37.092121 4.2769033 13654 51 51 0 49044 57680 11236 8218 1.009863 0 79 0 - 70000 0.90921994 8167 0.22796236 36.992809 37.140978 9.3555738 13927 52 52 0 49793 57680 11236 8167 1.0015807 0 79 0 - 71000 0.95608837 8177 0.22797832 36.987772 37.143579 8.0740708 13612 63 63 0 50464 57680 11236 8177 1.0097491 0 79 0 - 72000 1.0374855 8192 0.22803745 36.98414 37.153212 4.4789755 13561 52 52 0 51127 57680 11236 8192 0.99496724 0 79 0 - 73000 0.90636338 8214 0.22783374 36.97232 37.120024 9.3364171 13598 53 53 0 51799 57680 11236 8214 1.0078219 0 79 0 - 74000 1.1869638 8179 0.22834625 37.010094 37.203525 4.8292929 13771 51 51 0 52500 57680 11236 8179 0.98865277 0 79 0 - 75000 1.0177351 8188 0.22826506 37.024443 37.190296 5.1808505 13508 55 55 0 53183 57680 11236 8188 0.99903558 0 79 0 - 76000 1.062496 8230 0.22820987 37.008158 37.181305 8.1032524 13769 58 58 0 53864 57680 11236 8230 0.99397021 0 79 0 - 77000 0.9762027 8131 0.22831271 37.038975 37.19806 10.309798 13787 47 47 0 54553 57680 11236 8131 1.0066289 0 79 0 - 78000 1.0688533 8160 0.22855677 37.06364 37.237824 7.4800503 13224 58 58 0 55248 57680 11236 8160 1.0073477 0 79 0 - 79000 1.2598513 8151 0.22844942 37.015024 37.220333 7.4724924 13859 63 63 0 55911 57680 11236 8151 1.0065168 0 79 0 - 80000 1.1044575 8176 0.22834306 37.023019 37.203005 3.0142586 13579 62 62 0 56611 57680 11236 8176 1.0008704 0 79 0 - 81000 1.2756491 8205 0.22853748 37.026797 37.23468 6.434309 13702 52 52 0 57313 57680 11236 8205 1.0058366 0 79 0 - 82000 1.1276926 8193 0.22857049 37.056287 37.240059 11.825248 13621 63 63 0 58011 57680 11236 8193 1.0113537 0 79 0 - 83000 0.96941691 8173 0.22824759 37.029471 37.18745 2.9152799 13478 48 49 0 58712 57680 11236 8173 1.0168819 0 79 0 - 84000 1.0770325 8186 0.22821292 37.006285 37.181802 5.0626072 13733 60 61 0 59433 57680 11236 8186 1.0177757 0 79 0 - 85000 1.1959489 8175 0.2284266 37.021719 37.216615 5.3844747 13964 55 55 0 60226 57680 11236 8175 1.007371 0 79 0 - 86000 1.035779 8204 0.22845952 37.053185 37.221979 7.5428558 13713 64 64 0 60982 57680 11236 8204 1.0110801 0 79 0 - 87000 1.1878573 8204 0.22836412 37.012859 37.206436 3.1124447 13655 47 47 0 61668 57680 11236 8204 1.0034968 0 79 0 - 88000 0.98402924 8206 0.22815704 37.012337 37.172698 10.613422 13947 56 56 0 62325 57680 11236 8206 1.0081468 0 79 0 - 89000 0.83763529 8199 0.22807071 37.022127 37.158631 5.4628281 13966 50 50 0 63012 57680 11236 8199 0.99956322 0 79 0 - 90000 1.1976672 8187 0.22849599 37.032745 37.227921 5.5583762 13903 43 43 0 63697 57680 11236 8187 1.0047573 0 79 0 - 91000 0.94863742 8188 0.22818061 37.021945 37.176537 5.157692 13859 46 46 0 64382 57680 11236 8188 1.0041894 0 79 0 - 92000 1.2038427 8172 0.22846103 37.026042 37.222224 6.685059 13675 57 57 0 65081 57680 11236 8172 1.0036906 0 79 0 - 93000 0.95835618 8210 0.22828548 37.037446 37.193622 8.0038227 13826 57 58 0 65761 57680 11236 8210 1.0076646 0 79 0 - 94000 1.2451267 8197 0.22856138 37.035665 37.238575 3.6305666 13918 62 62 0 66462 57680 11236 8197 1.0110913 0 79 0 - 95000 0.82128549 8206 0.22809174 37.028218 37.162057 8.7024273 13817 44 44 0 67185 57680 11236 8206 1.0032224 0 79 0 - 96000 0.83473128 8199 0.22820935 37.04519 37.18122 8.1258155 14167 54 54 0 67912 57680 11236 8199 1.0035561 0 79 0 - 97000 0.98924493 8196 0.22847944 37.064014 37.225225 8.9964529 14039 48 51 0 68608 57680 11236 8196 1.0007515 0 79 0 - 98000 1.1749668 8211 0.22879851 37.085733 37.27721 7.0283734 13850 58 59 0 69305 57680 11236 8211 0.99525651 0 79 0 - 99000 1.3269705 8163 0.22890919 37.078994 37.295241 9.7962294 13885 63 63 0 69994 57680 11236 8163 1.011015 0 107 0 - 100000 1.0020436 8171 0.22867221 37.093336 37.256632 4.9455304 14102 55 56 0 70707 57680 11236 8171 1.0072865 0 107 0 -Loop time of 33.9872 on 8 procs for 100000 steps with 43990 atoms - -Pair time (%) = 0.379981 (1.11801) -Neigh time (%) = 2.01801 (5.93757) -Comm time (%) = 2.30255 (6.77476) -Outpt time (%) = 0.00694308 (0.0204285) -Other time (%) = 29.2797 (86.1492) - -Nlocal: 5498.75 ave 6445 max 4431 min -Histogram: 1 0 0 2 1 1 0 1 1 1 -Nghost: 62.5 ave 70 max 57 min -Histogram: 3 0 0 1 1 0 1 0 1 1 -Neighs: 207 ave 365 max 92 min -Histogram: 1 1 1 1 2 0 1 0 0 1 - -Total # of neighbors = 1656 -Ave neighs/atom = 0.0376449 -Neighbor list builds = 5000 -Dangerous builds = 0 - -Please see the log.cite file for references relevant to this simulation - diff --git a/examples/ASPHERE/star/log.1Feb14.star.mp.g++.8 b/examples/ASPHERE/star/log.1Feb14.star.mp.g++.8 deleted file mode 100644 index b53b8961e3..0000000000 --- a/examples/ASPHERE/star/log.1Feb14.star.mp.g++.8 +++ /dev/null @@ -1,291 +0,0 @@ -LAMMPS (1 Feb 2014) -# SRD viscosity demo - rigid star particles - -units lj -atom_style sphere -atom_modify map array first big -dimension 2 - -# read in clusters of rigid bodies - -fix molprop all property/atom mol -read_data data.star fix molprop NULL Molecules - orthogonal box = (-13.2934 -13.2934 -0.5) to (13.2934 13.2934 0.5) - 4 by 2 by 1 MPI processor grid - reading atoms ... - 270 atoms - -set type 1 mass 1.0 - 270 settings made for mass -group big type 1 -270 atoms in group big -velocity big create 1.44 87287 loop geom - -# equilibrate big particles - -pair_style soft 1.12 -pair_coeff 1 1 0.0 -pair_coeff 2 2 0.0 0.0 -pair_coeff 1 2 0.0 0.0 - -variable prefactor equal ramp(0,60) -fix soft all adapt 1 pair soft a * * v_prefactor - -neighbor 0.3 bin -neigh_modify delay 0 every 1 check yes - -fix 1 big rigid molecule -30 rigid bodies with 270 atoms -fix 2 all enforce2d - -#dump 1 all atom 10 dump.star.equil - -thermo 100 -run 1000 -Memory usage per processor = 2.64859 Mbytes -Step Temp E_pair E_mol TotEng Press - 0 0 0 0 0 0.24721146 - 100 0 3.291475 0 3.291475 0.69158089 - 200 0 4.6176595 0 4.6176595 0.71737945 - 300 0 7.0921814 0 7.0921814 1.2163497 - 400 0 8.3666709 0 8.3666709 0.50645957 - 500 0 10.630838 0 10.630838 0.72764487 - 600 0 12.42157 0 12.42157 1.0130599 - 700 0 14.349074 0 14.349074 0.74795509 - 800 0 16.464746 0 16.464746 1.054549 - 900 0 18.253108 0 18.253108 0.51551753 - 1000 0 20.699563 0 20.699563 1.8084662 -Loop time of 0.0484946 on 8 procs for 1000 steps with 270 atoms - -Pair time (%) = 0.00250834 (5.17242) -Neigh time (%) = 0.000999629 (2.06132) -Comm time (%) = 0.0154877 (31.9369) -Outpt time (%) = 0.000273734 (0.564464) -Other time (%) = 0.0292252 (60.2649) - -Nlocal: 33.75 ave 42 max 22 min -Histogram: 1 0 1 0 0 2 0 1 1 2 -Nghost: 23.375 ave 30 max 14 min -Histogram: 1 0 1 0 0 2 1 0 1 2 -Neighs: 52.25 ave 69 max 27 min -Histogram: 1 0 1 0 1 0 1 1 1 2 - -Total # of neighbors = 418 -Ave neighs/atom = 1.54815 -Neighbor list builds = 176 -Dangerous builds = 0 - -#undump 1 -unfix soft -unfix 1 -unfix 2 - -# add small particles as hi density lattice - -region plane block INF INF INF INF -0.001 0.001 units box -lattice sq 85.0 -Lattice spacing in x,y,z = 0.108465 0.108465 0.108465 -create_atoms 2 region plane -Created 60025 atoms - -set type 2 mass 0.1 - 60025 settings made for mass -group small type 2 -60025 atoms in group small -velocity small create 1.0 593849 loop geom - -# delete overlaps -# must set 1-2 cutoff to non-zero value - -pair_style lj/cut 2.5 -pair_coeff 1 1 1.0 1.0 -pair_coeff 2 2 0.0 1.0 0.0 -pair_coeff 1 2 0.0 1.0 0.5 - -delete_atoms overlap 0.5 small big -Deleted 16305 atoms, new total = 43990 - -# SRD run - -reset_timestep 0 - -neighbor 0.3 bin -neigh_modify delay 0 every 1 check yes - -communicate multi group big vel yes -neigh_modify include big - -# no pairwise interactions with small particles - -pair_style lj/cut 2.5 -pair_coeff 1 1 1.0 1.0 -pair_coeff 2 2 0.0 1.0 0.0 -pair_coeff 1 2 0.0 1.0 0.0 - -# use fix SRD to push small particles out from inside big ones -# if comment out, big particles won't see SRD particles - -timestep 0.001 - -fix 1 big rigid molecule -30 rigid bodies with 270 atoms -fix 2 small srd 20 big 1.0 0.25 49894 shift yes 54979 search 0.2 collision slip inside ignore overlap yes -fix 3 small viscosity 10 x y 50 -fix 4 all enforce2d - -# diagnostics - -compute tbig big temp/sphere -variable pebig equal pe*atoms/count(big) -variable ebig equal etotal*atoms/count(big) -thermo_style custom step temp f_2[8] etotal v_pebig v_ebig press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] f_2[12] - -thermo_modify temp tbig -WARNING: Temperature for thermo pressure is not for group all (../thermo.cpp:439) -thermo 1000 - -#dump 1 all atom 1000 dump.star.mp - -#dump 1 all image 1000 image.*.jpg type type zoom 1.6 -#dump_modify 1 pad 6 adiam 1 1 adiam 2 0.2 - -run 100000 -SRD info: - SRD/big particles = 43720 270 - big particle diameter max/min = 1 1 - SRD temperature & lamda = 1 0.0632456 - SRD max distance & max velocity = 0.252982 12.6491 - SRD grid counts: 106 106 1 - SRD grid size: request, actual (xyz) = 0.25, 0.250819 0.250819 1 - SRD per actual grid cell = 5.55866 - SRD viscosity = 0.235582 - big/SRD mass density ratio = 0.144099 -WARNING: Fix srd grid size > 1/4 of big particle diameter (../fix_srd.cpp:2875) - # of rescaled SRD velocities = 0 - ave/max small velocity = 4.19085 7.72582 - ave/max big velocity = 2.20262 5.4168 -Memory usage per processor = 7.83759 Mbytes -Step Temp 2[8] TotEng pebig ebig Press 2[1] 2[2] 2[3] 2[4] 2[5] 2[6] 2[7] 2[8] 2[9] 2[10] 2[11] 2[12] - 0 18.299191 0 0.25067776 37.859815 40.841906 5.7680841 0 0 0 0 0 0 0 0 0 0 0 0 - 1000 1.3197888 8196 0.2296966 37.208454 37.42353 7.4694369 14388 59 59 0 707 57680 11236 8196 1.0259754 0 5 0 - 2000 1.5789784 8192 0.22993088 37.204387 37.461702 7.6252927 14352 56 56 0 1521 57680 11236 8192 1.0168955 0 7 0 - 3000 1.286186 8153 0.2296947 37.213621 37.423222 8.8624394 14533 73 73 0 2299 57680 11236 8153 1.0109574 0 7 0 - 4000 2.0862082 8194 0.23044604 37.20566 37.545635 7.8064365 14228 48 48 0 3068 57680 11236 8194 1.0046224 0 7 0 - 5000 1.892401 8172 0.23019301 37.196017 37.504409 7.9041579 14290 55 55 0 3866 57680 11236 8172 1.005673 0 7 0 - 6000 2.1063411 8138 0.23041636 37.197543 37.540799 4.8468885 13803 47 47 0 4638 57680 11236 8138 1.0083722 0 7 0 - 7000 2.3549938 8174 0.23071159 37.205123 37.5889 6.5703154 13773 58 58 0 5398 57680 11236 8174 1.0039365 0 7 0 - 8000 3.0660305 8216 0.23155654 37.226914 37.726563 11.977404 13898 65 65 0 6180 57680 11236 8216 0.99586836 0 7 0 - 9000 3.1510761 8203 0.23143756 37.19367 37.707178 7.2978028 13815 54 54 0 6985 57680 11236 8203 0.99794556 0 7 0 - 10000 2.7472522 8196 0.23096076 37.181796 37.629496 11.336568 14012 59 59 0 7812 57680 11236 8196 0.99210203 0 11 0 - 11000 2.1776587 8186 0.23038876 37.181424 37.536302 9.2106614 14063 64 64 0 8627 57680 11236 8186 1.003993 0 11 0 - 12000 3.0146734 8196 0.2312123 37.179198 37.670478 5.9303705 14077 60 60 0 9436 57680 11236 8196 0.98496016 0 23 0 - 13000 3.0029829 8179 0.23150759 37.229214 37.718589 7.3329148 14116 74 74 0 10339 57680 11236 8179 1.0039911 0 23 0 - 14000 3.2942972 8191 0.23166868 37.207985 37.744833 9.6428846 14019 56 57 0 11290 57680 11236 8191 0.99410574 0 23 0 - 15000 3.8480961 8213 0.23228155 37.217589 37.844686 2.1025549 13746 68 68 0 12175 57680 11236 8213 1.0011325 0 23 0 - 16000 3.2573043 8195 0.2316418 37.209634 37.740454 8.1255708 13682 55 55 0 13104 57680 11236 8195 1.0061399 0 23 0 - 17000 3.3579037 8186 0.2315443 37.177356 37.72457 9.8606039 13833 54 54 0 14034 57680 11236 8186 1.004156 0 23 0 - 18000 4.7903055 8194 0.23307181 37.192799 37.973441 3.8090185 13914 55 55 1 15012 57680 11236 8194 0.98633014 0 23 0 - 19000 4.4696839 8183 0.23293212 37.222288 37.950681 7.1931333 13499 54 54 0 15960 57680 11236 8183 0.98359656 0 23 0 - 20000 5.0239019 8126 0.23355887 37.234085 38.052794 5.1504203 13600 58 58 0 16972 57680 11236 8126 0.98555755 0 23 0 - 21000 4.6595948 8155 0.23275722 37.162845 37.922186 9.0375076 13965 73 74 0 17966 57680 11236 8155 0.99574348 0 23 0 - 22000 4.043444 8124 0.23247599 37.217434 37.876366 3.9265975 13584 53 53 2 18989 57680 11236 8124 0.9943952 0 23 0 - 23000 4.9981028 8127 0.23314549 37.170939 37.985445 4.2352191 13589 47 47 0 19958 57680 11236 8127 0.99276741 0 47 0 - 24000 4.7542655 8145 0.23295434 37.179533 37.954302 7.365415 13753 51 51 0 20955 57680 11236 8145 0.99024306 0 47 0 - 25000 4.2987054 8177 0.23252979 37.184601 37.885131 10.735771 13536 58 58 0 21994 57680 11236 8177 0.99215977 0 47 0 - 26000 4.4136261 8170 0.23331629 37.294015 38.013272 14.25925 13842 58 58 0 22979 57680 11236 8170 0.99283174 0 47 0 - 27000 4.0546007 8173 0.23283443 37.274016 37.934766 6.22969 13877 51 51 0 23997 57680 11236 8173 0.98496361 0 47 0 - 28000 4.5919614 8151 0.23364384 37.318319 38.066638 4.9917488 13836 60 61 1 25071 57680 11236 8151 0.99390956 0 47 0 - 29000 4.8025535 8189 0.23313849 37.201667 37.984305 4.7895172 13978 46 47 0 26121 57680 11236 8189 0.99018295 0 47 0 - 30000 4.2835226 8139 0.23247583 37.178284 37.87634 8.994878 13988 61 61 0 27141 57680 11236 8139 0.98735471 0 47 0 - 31000 5.4049428 8133 0.23373767 37.201121 38.081927 7.6419291 13771 58 58 0 28207 57680 11236 8133 0.98354883 0 47 0 - 32000 5.0299584 8177 0.23336211 37.201041 38.020738 8.1206741 14036 55 55 0 29303 57680 11236 8177 0.98239013 0 47 0 - 33000 4.2993816 8158 0.23320229 37.29406 37.9947 10.745167 13583 51 51 0 30344 57680 11236 8158 0.98952524 0 47 0 - 34000 5.8334257 8179 0.23458355 37.269109 38.219741 11.094625 13921 62 62 0 31432 57680 11236 8179 0.98822406 0 47 0 - 35000 6.481318 8168 0.23501133 37.233224 38.289439 7.9397445 13942 56 56 0 32518 57680 11236 8168 0.98830425 0 47 0 - 36000 4.967891 8186 0.23366927 37.261199 38.070782 8.3979019 13952 51 51 0 33626 57680 11236 8186 0.99579665 0 47 0 - 37000 5.3458808 8145 0.2337339 37.210132 38.081312 5.4177865 13659 55 55 0 34715 57680 11236 8145 1.0009582 0 47 0 - 38000 6.3597955 8159 0.23479285 37.217431 38.253842 6.1408411 13754 55 56 0 35754 57680 11236 8159 0.98853252 0 47 0 - 39000 6.1217173 8195 0.23447066 37.203737 38.20135 9.6016075 13756 70 70 0 36807 57680 11236 8195 0.98652299 0 47 0 - 40000 5.0218059 8159 0.23370899 37.258886 38.077254 6.6460004 13603 56 56 1 37933 57680 11236 8159 0.98674585 0 47 0 - 41000 5.5873722 8138 0.23429215 37.26173 38.172265 1.4183057 13634 51 52 1 39050 57680 11236 8138 0.98833769 0 47 0 - 42000 5.5502013 8170 0.23405343 37.228895 38.133372 7.8338637 13913 72 72 0 40105 57680 11236 8170 0.99124609 0 47 0 - 43000 4.6854143 8161 0.23326283 37.241013 38.004562 7.857085 13759 48 48 0 41187 57680 11236 8161 0.99649848 0 47 0 - 44000 6.3172352 8180 0.2348893 37.240081 38.269557 12.59288 13810 55 55 0 42292 57680 11236 8180 0.99164669 0 47 0 - 45000 6.1213322 8166 0.23449878 37.208381 38.205931 6.3760889 13854 48 49 0 43406 57680 11236 8166 0.98981447 0 47 0 - 46000 5.0015874 8195 0.23354809 37.235965 38.051038 10.992836 13962 62 62 0 44527 57680 11236 8195 0.99128184 0 47 0 - 47000 5.0499615 8190 0.23376151 37.262854 38.085811 8.7985849 14105 64 64 0 45653 57680 11236 8190 0.99020272 0 47 0 - 48000 5.202255 8170 0.23400688 37.278013 38.125788 4.7389097 13754 51 51 0 46705 57680 11236 8170 0.98792999 0 47 0 - 49000 5.6144741 8167 0.23429848 37.258346 38.173297 6.3247626 13953 51 51 1 47846 57680 11236 8167 0.99270232 0 47 0 - 50000 6.3027505 8145 0.2347122 37.213588 38.240703 6.4424496 13843 59 59 0 49061 57680 11236 8145 0.99810926 0 47 0 - 51000 5.2050769 8154 0.23390178 37.26043 38.108665 6.6143765 13999 51 51 0 50075 57680 11236 8154 0.99525977 0 47 0 - 52000 5.4749884 8175 0.23418567 37.262697 38.154917 8.7256782 13916 51 51 0 51249 57680 11236 8175 0.99508289 0 47 0 - 53000 5.1367735 8158 0.23393299 37.276645 38.113748 9.3248422 13910 41 41 0 52381 57680 11236 8158 0.98956839 0 47 0 - 54000 4.8680584 8211 0.23402832 37.335968 38.129281 4.8979582 14214 63 64 0 53439 57680 11236 8211 0.98838908 0 47 0 - 55000 4.6223848 8167 0.23347097 37.285196 38.038473 6.1898955 14162 46 46 0 54504 57680 11236 8167 0.97935238 0 47 0 - 56000 4.9075747 8168 0.23409393 37.340218 38.139971 12.20686 13980 60 60 0 55540 57680 11236 8168 0.99885966 0 47 0 - 57000 4.8736147 8143 0.23354696 37.256636 38.050854 3.9348529 13857 59 59 0 56680 57680 11236 8143 0.98434054 0 47 0 - 58000 5.6134201 8162 0.23393276 37.198932 38.113711 3.7493067 13866 55 55 2 57767 57680 11236 8162 0.99041155 0 47 0 - 59000 5.440371 8197 0.23353392 37.162151 38.04873 4.1297786 13748 67 67 0 58894 57680 11236 8197 0.98824623 0 47 0 - 60000 5.2754075 8148 0.23359083 37.198307 38.058003 7.1427242 13781 55 55 0 60028 57680 11236 8148 0.9831827 0 47 0 - 61000 5.8228233 8153 0.23438274 37.23812 38.187025 8.8839625 14019 48 48 0 61204 57680 11236 8153 0.98566731 0 47 0 - 62000 5.7623285 8129 0.23480056 37.316052 38.255098 9.992341 13791 67 68 0 62385 57680 11236 8129 0.97338459 0 47 0 - 63000 6.095315 8178 0.23455792 37.222257 38.215567 10.722535 14210 54 54 0 63448 57680 11236 8178 0.98135973 0 47 0 - 64000 5.2494942 8189 0.23380158 37.236866 38.092339 4.4010329 13869 51 51 0 64538 57680 11236 8189 0.98071569 0 47 0 - 65000 5.6534858 8151 0.23405328 37.212039 38.133348 8.9144953 14065 53 53 0 65661 57680 11236 8151 0.99589337 0 47 0 - 66000 5.3999138 8165 0.23453061 37.33113 38.211116 7.3102657 13994 61 62 0 66785 57680 11236 8165 0.98715854 0 47 0 - 67000 6.3619419 8183 0.23459518 37.184875 38.221636 4.0425684 13859 49 49 0 67944 57680 11236 8183 0.98479883 0 47 0 - 68000 6.2170116 8157 0.23470153 37.225822 38.238965 9.3090925 13598 50 50 0 69121 57680 11236 8157 0.98683618 0 47 0 - 69000 6.8545121 8179 0.23542272 37.239433 38.356465 9.4175179 13911 59 59 0 70316 57680 11236 8179 0.99828763 0 47 0 - 70000 5.1476232 8154 0.23389653 37.268937 38.107809 7.6438157 13882 55 55 0 71380 57680 11236 8154 0.99088995 0 47 0 - 71000 5.9284504 8161 0.23499148 37.320087 38.286205 9.1242845 13968 60 60 0 72478 57680 11236 8161 0.98627289 0 47 0 - 72000 5.8044136 8180 0.23473312 37.298207 38.244111 6.6084298 14066 56 56 0 73653 57680 11236 8180 0.97959812 0 47 0 - 73000 5.3690655 8148 0.23424676 37.289911 38.16487 8.7025002 14433 55 55 1 74740 57680 11236 8148 0.97949605 0 47 0 - 74000 4.8144157 8192 0.23361625 37.277572 38.062144 7.6685178 14425 58 58 1 75918 57680 11236 8192 0.98949387 0 47 0 - 75000 4.9424688 8143 0.23362551 37.258213 38.063652 5.5882668 13938 42 42 0 77080 57680 11236 8143 0.99602516 0 47 0 - 76000 6.3017203 8178 0.23500247 37.261048 38.287995 5.2760401 13952 47 47 0 78240 57680 11236 8178 0.98484281 0 47 0 - 77000 5.3086333 8208 0.23389726 37.242817 38.107928 4.034731 14052 47 47 0 79331 57680 11236 8208 0.9896033 0 47 0 - 78000 6.1152265 8157 0.23546115 37.366171 38.362726 11.521489 13980 58 58 0 80446 57680 11236 8157 0.98562154 0 47 0 - 79000 6.5034669 8173 0.23569944 37.341726 38.40155 5.0939756 14030 74 74 0 81663 57680 11236 8173 0.98837711 0 47 0 - 80000 6.1688245 8182 0.23495003 37.274162 38.279451 6.3337593 14292 50 50 0 82872 57680 11236 8182 0.99316806 0 47 0 - 81000 6.3818913 8189 0.23516767 37.274899 38.314911 9.0232294 14259 56 56 0 84072 57680 11236 8189 0.98467136 0 47 0 - 82000 6.502454 8171 0.23498158 37.224932 38.284591 7.6685939 13970 63 63 0 85190 57680 11236 8171 0.99511647 0 47 0 - 83000 7.2245962 8142 0.23564338 37.215075 38.392416 6.0363083 13789 61 61 0 86416 57680 11236 8142 0.99223565 0 47 0 - 84000 6.3529888 8192 0.23477435 37.215526 38.250828 7.2109855 14062 52 52 0 87555 57680 11236 8192 0.98623425 0 47 0 - 85000 6.5185235 8177 0.23516364 37.251976 38.314254 5.266764 14325 52 53 0 88732 57680 11236 8177 0.97895516 0 47 0 - 86000 5.742959 8170 0.23432816 37.242243 38.178133 6.0834874 13922 48 48 0 89836 57680 11236 8170 0.99203022 0 47 0 - 87000 6.548676 8177 0.23495538 37.213132 38.280324 6.2502744 14147 48 48 0 91035 57680 11236 8177 0.98829721 0 47 0 - 88000 5.9500587 8193 0.23446634 37.231006 38.200645 6.2196893 13960 44 44 0 92206 57680 11236 8193 0.98956808 0 47 0 - 89000 5.0591447 8174 0.23386574 37.278339 38.102793 11.164066 14071 54 54 0 93437 57680 11236 8174 0.99827748 0 47 0 - 90000 6.4930795 8181 0.23544182 37.301445 38.359576 6.6167028 14183 63 63 1 94640 57680 11236 8181 0.99559871 0 47 0 - 91000 6.489104 8187 0.23523152 37.267829 38.325313 6.4932786 14223 51 51 1 95718 57680 11236 8187 0.99090796 0 47 0 - 92000 6.3543839 8184 0.23502776 37.256587 38.292116 7.1553807 14265 66 66 1 96903 57680 11236 8184 0.98979354 0 47 0 - 93000 5.3818591 8195 0.23393122 37.236417 38.11346 7.9445503 14327 70 70 0 98138 57680 11236 8195 1.0030252 0 47 0 - 94000 5.6818206 8171 0.2343696 37.258958 38.184885 5.7311019 13943 63 63 0 99306 57680 11236 8171 0.99691591 0 47 0 - 95000 4.8295204 8160 0.23371941 37.291918 38.078951 4.5703653 13682 48 48 1 100491 57680 11236 8160 1.0078235 0 47 0 - 96000 6.7415726 8191 0.23539566 37.253429 38.352056 11.837168 13783 53 53 1 101761 57680 11236 8191 1.0010125 0 49 0 - 97000 6.5298825 8160 0.2354153 37.291126 38.355255 7.6012271 13688 65 65 0 103010 57680 11236 8160 0.99694671 0 49 0 - 98000 6.2804965 8175 0.23496877 37.259015 38.282504 5.4636503 14041 55 55 0 104259 57680 11236 8175 1.0042653 0 49 0 - 99000 5.7684681 8173 0.2344998 37.26605 38.206096 1.7807753 14082 58 59 0 105418 57680 11236 8173 0.99124491 0 49 0 - 100000 6.1371898 8170 0.23495644 37.28036 38.280495 7.7665232 13908 53 53 0 106633 57680 11236 8170 0.98281247 0 49 0 -Loop time of 34.1892 on 8 procs for 100000 steps with 43990 atoms - -Pair time (%) = 0.361362 (1.05695) -Neigh time (%) = 2.01143 (5.88324) -Comm time (%) = 2.27139 (6.64359) -Outpt time (%) = 0.00694269 (0.0203067) -Other time (%) = 29.5381 (86.3959) - -Nlocal: 5498.75 ave 6478 max 4726 min -Histogram: 2 0 1 0 1 2 1 0 0 1 -Nghost: 52.875 ave 59 max 44 min -Histogram: 1 0 1 0 1 0 1 0 2 2 -Neighs: 186.25 ave 293 max 81 min -Histogram: 1 0 1 3 0 0 1 0 0 2 - -Total # of neighbors = 1490 -Ave neighs/atom = 0.0338713 -Neighbor list builds = 5000 -Dangerous builds = 0 - -Please see the log.cite file for references relevant to this simulation - diff --git a/examples/ASPHERE/star/log.1Feb24.star.g++.1 b/examples/ASPHERE/star/log.1Feb24.star.g++.1 new file mode 100644 index 0000000000..0fa1492dc6 --- /dev/null +++ b/examples/ASPHERE/star/log.1Feb24.star.g++.1 @@ -0,0 +1,321 @@ +LAMMPS (21 Nov 2023 - Development - patch_21Nov2023-665-g17f869bf5e) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# SRD diffusion demo - rigid star particles + +units lj +atom_style sphere +atom_modify map array first big +dimension 2 + +# read in clusters of rigid bodies + +fix molprop all property/atom mol ghost yes +read_data data.star fix molprop NULL Molecules +Reading data file ... + orthogonal box = (-13.293404 -13.293404 -0.5) to (13.293404 13.293404 0.5) + 1 by 1 by 1 MPI processor grid + reading atoms ... + 270 atoms + read_data CPU = 0.011 seconds + +set type 1 mass 1.0 +Setting atom values ... + 270 settings made for mass +group big type 1 +270 atoms in group big +velocity big create 1.44 87287 loop geom + +# equilibrate big particles + +pair_style soft 1.12 +pair_coeff 1 1 0.0 +pair_coeff 2 2 0.0 0.0 +pair_coeff 1 2 0.0 0.0 + +variable prefactor equal ramp(0,60) +fix soft all adapt 1 pair soft a * * v_prefactor + +neighbor 0.3 bin +neigh_modify delay 0 every 1 check yes + +fix 1 big rigid molecule + 30 rigid bodies with 270 atoms +fix 2 all enforce2d + +#dump 1 all atom 10 dump.star.equil + +compute tbig all temp/sphere +thermo_modify temp tbig + +thermo 100 +run 1000 +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 1.42 + ghost atom cutoff = 1.42 + binsize = 0.71, bins = 38 38 2 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair soft, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/2d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 5.562 | 5.562 | 5.562 Mbytes + Step Temp E_pair E_mol TotEng Press + 0 1.3101488 0 0 0.21350573 0.32876464 + 100 5.0954142 3.291475 0 4.1218387 1.0087565 + 200 13.041252 4.6176595 0 6.7429006 1.5291618 + 300 11.912727 7.0921814 0 9.0335147 1.9578844 + 400 17.60886 8.3666709 0 11.236263 1.602563 + 500 16.786375 10.630838 0 13.366396 1.7725508 + 600 18.470347 12.42157 0 15.431552 2.1627885 + 700 19.39794 14.349074 0 17.510219 1.9554238 + 800 19.082984 16.464746 0 19.574566 2.2424126 + 900 20.702091 18.253108 0 21.626782 1.8041661 + 1000 18.299191 20.699563 0 23.681654 2.9475408 +Loop time of 0.0585091 on 1 procs for 1000 steps with 270 atoms + +Performance: 7383466.593 tau/day, 17091.358 timesteps/s, 4.615 Matom-step/s +99.1% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.017165 | 0.017165 | 0.017165 | 0.0 | 29.34 +Neigh | 0.0058479 | 0.0058479 | 0.0058479 | 0.0 | 9.99 +Comm | 0.0028221 | 0.0028221 | 0.0028221 | 0.0 | 4.82 +Output | 0.00017384 | 0.00017384 | 0.00017384 | 0.0 | 0.30 +Modify | 0.03015 | 0.03015 | 0.03015 | 0.0 | 51.53 +Other | | 0.00235 | | | 4.02 + +Nlocal: 270 ave 270 max 270 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 73 ave 73 max 73 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 418 ave 418 max 418 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 418 +Ave neighs/atom = 1.5481481 +Neighbor list builds = 176 +Dangerous builds = 0 + +#undump 1 +unfix soft +unfix 1 +unfix 2 + +# add small particles as hi density lattice + +region plane block INF INF INF INF -0.001 0.001 units box +lattice sq 85.0 +Lattice spacing in x,y,z = 0.10846523 0.10846523 0.10846523 +create_atoms 2 region plane +Created 60025 atoms + using lattice units in orthogonal box = (-13.293404 -13.293404 -0.5) to (13.293404 13.293404 0.5) + create_atoms CPU = 0.013 seconds + +set type 2 mass 0.1 +Setting atom values ... + 60025 settings made for mass +group small type 2 +60025 atoms in group small +velocity small create 1.0 593849 loop geom + +# delete overlaps +# must set 1-2 cutoff to non-zero value + +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 +pair_coeff 2 2 0.0 1.0 0.0 +pair_coeff 1 2 0.0 1.0 0.5 + +delete_atoms overlap 0.5 small big +System init for delete_atoms ... +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 2.8 + ghost atom cutoff = 2.8 + binsize = 1.4, bins = 19 19 1 + 2 neighbor lists, perpetual/occasional/extra = 1 1 0 + (1) command delete_atoms, occasional + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/2d + bin: standard + (2) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/2d + bin: standard +WARNING: Delete_atoms cutoff > minimum neighbor cutoff (src/delete_atoms.cpp:312) +Deleted 16305 atoms, new total = 43990 + +# SRD run + +reset_timestep 0 + +neighbor 0.3 multi +neigh_modify delay 0 every 1 check yes + +comm_modify mode multi group big vel yes +neigh_modify include big + +# no pairwise interactions with small particles + +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 +pair_coeff 2 2 0.0 1.0 0.0 +pair_coeff 1 2 0.0 1.0 0.0 + +# use fix SRD to push small particles out from inside big ones +# if comment out, big particles won't see SRD particles + +timestep 0.001 + +fix 1 big rigid molecule + 30 rigid bodies with 270 atoms +fix 2 small srd 20 big 1.0 0.25 49894 shift yes 54979 search 0.2 collision slip inside ignore overlap yes +fix 3 all enforce2d + +# diagnostics + +uncompute tbig +compute tbig big temp/sphere +variable pebig equal pe*atoms/count(big) +variable ebig equal etotal*atoms/count(big) +thermo_style custom step temp f_2[8] etotal v_pebig v_ebig press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] f_2[12] +WARNING: New thermo_style command, previous thermo_modify settings will be lost (src/output.cpp:904) + +thermo_modify temp tbig +WARNING: Temperature for thermo pressure is not for group all (src/thermo.cpp:530) +thermo 1000 + +#dump 1 all atom 1000 dump.star + +#dump 1 all image 1000 image.*.jpg type type zoom 1.6 +#dump_modify 1 pad 6 adiam 1 1 adiam 2 0.2 + +run 10000 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- neighbor multi command: doi:10.1016/j.cpc.2008.03.005, doi:10.1007/s40571-020-00361-2 + +@Article{Intveld08, + author = {in 't Veld, P. J. and S. J.~Plimpton and G. S. Grest}, + title = {Accurate and Efficient Methods for Modeling Colloidal + Mixtures in an Explicit Solvent using Molecular Dynamics}, + journal = {Comput.\ Phys.\ Commut.}, + year = 2008, + volume = 179, + pages = {320--329} +} + +@article{Shire2020, + author = {Shire, Tom and Hanley, Kevin J. and Stratford, Kevin}, + title = {{DEM} Simulations of Polydisperse Media: Efficient Contact + Detection Applied to Investigate the Quasi-Static Limit}, + journal = {Computational Particle Mechanics}, + year = {2020} +@article{Monti2022, + author = {Monti, Joseph M. and Clemmer, Joel T. and Srivastava, + Ishan and Silbert, Leonardo E. and Grest, Gary S. + and Lechman, Jeremy B.}, + title = {Large-scale frictionless jamming with power-law particle + size distributions}, + journal = {Phys. Rev. E}, + volume = {106} + issue = {3} + year = {2022} +} + +- fix srd command: doi:10.1063/1.3419070 + +@Article{Petersen10, + author = {M. K. Petersen and J. B. Lechman and S. J. Plimpton and + G. S. Grest and in 't Veld, P. J. and P. R. Schunk}, + title = {Mesoscale Hydrodynamics via Stochastic Rotation + Dynamics: Comparison with {L}ennard-{J}ones Fluid}, + journal = {J.~Chem.\ Phys.}, + year = 2010, + volume = 132, + pages = 174106 +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +SRD info: + SRD/big particles = 43720 270 + big particle diameter max/min = 1 1 + SRD temperature & lamda = 1 0.063245553 + SRD max distance & max velocity = 0.25298221 12.649111 + SRD grid counts: 106 106 1 + SRD grid size: request, actual (xyz) = 0.25, 0.25081894 0.25081894 1 + SRD per actual grid cell = 5.5586635 + SRD viscosity = 0.23558168 + big/SRD mass density ratio = 0.14409881 +WARNING: Fix srd grid size > 1/4 of big particle diameter (src/SRD/fix_srd.cpp:2830) + # of rescaled SRD velocities = 0 + ave/max small velocity = 4.1908497 7.725824 + ave/max big velocity = 2.202625 5.4167964 +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 2.8 + ghost atom cutoff = 2.8 + binsize = 26.586808, bins = 1 1 1 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/multi/atomonly/newton + stencil: half/multi/2d + bin: multi +Per MPI rank memory allocation (min/avg/max) = 41.29 | 41.29 | 41.29 Mbytes + Step Temp f_2[8] TotEng v_pebig v_ebig Press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] f_2[12] + 0 18.299191 0 0.25067776 37.859815 40.841906 5.7680841 0 0 0 0 0 0 0 0 0 0 0 0 + 1000 1.2074332 8227 0.22959643 37.210444 37.407211 7.9007359 14317 47 47 0 649 28900 11236 8227 1.0260288 0 3 0 + 2000 1.2044605 8206 0.22945824 37.188414 37.384697 5.8738384 14470 63 63 0 1423 28900 11236 8206 1.018589 0 4 0 + 3000 1.1060368 8226 0.22936549 37.189341 37.369584 4.7013136 14255 51 51 0 2207 28900 11236 8226 1.0007203 0 4 0 + 4000 1.2395587 8236 0.2294891 37.187723 37.389725 5.7916781 14371 56 56 0 2916 28900 11236 8236 1.0229966 0 4 0 + 5000 1.3332555 8236 0.22962818 37.195112 37.412383 10.662157 14373 61 61 0 3740 28900 11236 8236 1.0094713 0 4 0 + 6000 1.2991744 8192 0.22957221 37.191547 37.403264 1.2016626 14145 56 58 0 4425 28900 11236 8192 1.0215234 0 4 0 + 7000 1.0110737 8147 0.22923336 37.18329 37.348057 6.2493424 14200 59 59 0 5102 28900 11236 8147 1.0163405 0 4 0 + 8000 0.79508387 8168 0.22908516 37.194343 37.323912 9.832591 14355 45 45 0 5839 28900 11236 8168 1.0063207 0 4 0 + 9000 1.0340542 8207 0.2292515 37.1825 37.351013 11.458942 14220 54 54 0 6606 28900 11236 8207 1.0074421 0 4 0 + 10000 0.96342976 8202 0.22912995 37.174206 37.33121 1.7523017 14308 53 53 0 7379 28900 11236 8202 1.0126923 0 4 0 +Loop time of 18.5504 on 1 procs for 10000 steps with 43990 atoms + +Performance: 46575.737 tau/day, 539.071 timesteps/s, 23.714 Matom-step/s +99.7% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.21961 | 0.21961 | 0.21961 | 0.0 | 1.18 +Neigh | 0.055763 | 0.055763 | 0.055763 | 0.0 | 0.30 +Comm | 0.22073 | 0.22073 | 0.22073 | 0.0 | 1.19 +Output | 0.0013822 | 0.0013822 | 0.0013822 | 0.0 | 0.01 +Modify | 17.872 | 17.872 | 17.872 | 0.0 | 96.34 +Other | | 0.1812 | | | 0.98 + +Nlocal: 43990 ave 43990 max 43990 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 138 ave 138 max 138 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 1587 ave 1587 max 1587 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 1587 +Ave neighs/atom = 0.036076381 +Neighbor list builds = 500 +Dangerous builds = 0 +Total wall time: 0:00:20 diff --git a/examples/ASPHERE/star/log.1Feb24.star.g++.4 b/examples/ASPHERE/star/log.1Feb24.star.g++.4 new file mode 100644 index 0000000000..66b9b04e63 --- /dev/null +++ b/examples/ASPHERE/star/log.1Feb24.star.g++.4 @@ -0,0 +1,321 @@ +LAMMPS (21 Nov 2023 - Development - patch_21Nov2023-665-g17f869bf5e) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# SRD diffusion demo - rigid star particles + +units lj +atom_style sphere +atom_modify map array first big +dimension 2 + +# read in clusters of rigid bodies + +fix molprop all property/atom mol ghost yes +read_data data.star fix molprop NULL Molecules +Reading data file ... + orthogonal box = (-13.293404 -13.293404 -0.5) to (13.293404 13.293404 0.5) + 2 by 2 by 1 MPI processor grid + reading atoms ... + 270 atoms + read_data CPU = 0.001 seconds + +set type 1 mass 1.0 +Setting atom values ... + 270 settings made for mass +group big type 1 +270 atoms in group big +velocity big create 1.44 87287 loop geom + +# equilibrate big particles + +pair_style soft 1.12 +pair_coeff 1 1 0.0 +pair_coeff 2 2 0.0 0.0 +pair_coeff 1 2 0.0 0.0 + +variable prefactor equal ramp(0,60) +fix soft all adapt 1 pair soft a * * v_prefactor + +neighbor 0.3 bin +neigh_modify delay 0 every 1 check yes + +fix 1 big rigid molecule + 30 rigid bodies with 270 atoms +fix 2 all enforce2d + +#dump 1 all atom 10 dump.star.equil + +compute tbig all temp/sphere +thermo_modify temp tbig + +thermo 100 +run 1000 +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 1.42 + ghost atom cutoff = 1.42 + binsize = 0.71, bins = 38 38 2 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair soft, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/2d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 5.554 | 5.554 | 5.555 Mbytes + Step Temp E_pair E_mol TotEng Press + 0 1.3101488 0 0 0.21350573 0.32876464 + 100 5.0954142 3.291475 0 4.1218387 1.0087565 + 200 13.041252 4.6176595 0 6.7429006 1.5291618 + 300 11.912727 7.0921814 0 9.0335147 1.9578844 + 400 17.60886 8.3666709 0 11.236263 1.602563 + 500 16.786375 10.630838 0 13.366396 1.7725508 + 600 18.470347 12.42157 0 15.431552 2.1627885 + 700 19.39794 14.349074 0 17.510219 1.9554238 + 800 19.082984 16.464746 0 19.574566 2.2424126 + 900 20.702091 18.253108 0 21.626782 1.8041661 + 1000 18.299191 20.699563 0 23.681654 2.9475408 +Loop time of 0.0312248 on 4 procs for 1000 steps with 270 atoms + +Performance: 13835169.963 tau/day, 32025.856 timesteps/s, 8.647 Matom-step/s +98.2% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.0026978 | 0.0031211 | 0.0033489 | 0.5 | 10.00 +Neigh | 0.0011292 | 0.0013054 | 0.0014446 | 0.3 | 4.18 +Comm | 0.010095 | 0.010474 | 0.010975 | 0.3 | 33.54 +Output | 0.00019592 | 0.00021948 | 0.00027642 | 0.0 | 0.70 +Modify | 0.013333 | 0.013668 | 0.013952 | 0.2 | 43.77 +Other | | 0.002437 | | | 7.80 + +Nlocal: 67.5 ave 80 max 54 min +Histogram: 1 1 0 0 0 0 0 0 1 1 +Nghost: 29.75 ave 33 max 26 min +Histogram: 1 0 0 0 1 0 0 1 0 1 +Neighs: 104.5 ave 135 max 72 min +Histogram: 1 0 0 1 0 0 0 1 0 1 + +Total # of neighbors = 418 +Ave neighs/atom = 1.5481481 +Neighbor list builds = 176 +Dangerous builds = 0 + +#undump 1 +unfix soft +unfix 1 +unfix 2 + +# add small particles as hi density lattice + +region plane block INF INF INF INF -0.001 0.001 units box +lattice sq 85.0 +Lattice spacing in x,y,z = 0.10846523 0.10846523 0.10846523 +create_atoms 2 region plane +Created 60025 atoms + using lattice units in orthogonal box = (-13.293404 -13.293404 -0.5) to (13.293404 13.293404 0.5) + create_atoms CPU = 0.003 seconds + +set type 2 mass 0.1 +Setting atom values ... + 60025 settings made for mass +group small type 2 +60025 atoms in group small +velocity small create 1.0 593849 loop geom + +# delete overlaps +# must set 1-2 cutoff to non-zero value + +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 +pair_coeff 2 2 0.0 1.0 0.0 +pair_coeff 1 2 0.0 1.0 0.5 + +delete_atoms overlap 0.5 small big +System init for delete_atoms ... +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 2.8 + ghost atom cutoff = 2.8 + binsize = 1.4, bins = 19 19 1 + 2 neighbor lists, perpetual/occasional/extra = 1 1 0 + (1) command delete_atoms, occasional + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/2d + bin: standard + (2) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/2d + bin: standard +WARNING: Delete_atoms cutoff > minimum neighbor cutoff (src/delete_atoms.cpp:312) +Deleted 16305 atoms, new total = 43990 + +# SRD run + +reset_timestep 0 + +neighbor 0.3 multi +neigh_modify delay 0 every 1 check yes + +comm_modify mode multi group big vel yes +neigh_modify include big + +# no pairwise interactions with small particles + +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 +pair_coeff 2 2 0.0 1.0 0.0 +pair_coeff 1 2 0.0 1.0 0.0 + +# use fix SRD to push small particles out from inside big ones +# if comment out, big particles won't see SRD particles + +timestep 0.001 + +fix 1 big rigid molecule + 30 rigid bodies with 270 atoms +fix 2 small srd 20 big 1.0 0.25 49894 shift yes 54979 search 0.2 collision slip inside ignore overlap yes +fix 3 all enforce2d + +# diagnostics + +uncompute tbig +compute tbig big temp/sphere +variable pebig equal pe*atoms/count(big) +variable ebig equal etotal*atoms/count(big) +thermo_style custom step temp f_2[8] etotal v_pebig v_ebig press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] f_2[12] +WARNING: New thermo_style command, previous thermo_modify settings will be lost (src/output.cpp:904) + +thermo_modify temp tbig +WARNING: Temperature for thermo pressure is not for group all (src/thermo.cpp:530) +thermo 1000 + +#dump 1 all atom 1000 dump.star + +#dump 1 all image 1000 image.*.jpg type type zoom 1.6 +#dump_modify 1 pad 6 adiam 1 1 adiam 2 0.2 + +run 10000 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- neighbor multi command: doi:10.1016/j.cpc.2008.03.005, doi:10.1007/s40571-020-00361-2 + +@Article{Intveld08, + author = {in 't Veld, P. J. and S. J.~Plimpton and G. S. Grest}, + title = {Accurate and Efficient Methods for Modeling Colloidal + Mixtures in an Explicit Solvent using Molecular Dynamics}, + journal = {Comput.\ Phys.\ Commut.}, + year = 2008, + volume = 179, + pages = {320--329} +} + +@article{Shire2020, + author = {Shire, Tom and Hanley, Kevin J. and Stratford, Kevin}, + title = {{DEM} Simulations of Polydisperse Media: Efficient Contact + Detection Applied to Investigate the Quasi-Static Limit}, + journal = {Computational Particle Mechanics}, + year = {2020} +@article{Monti2022, + author = {Monti, Joseph M. and Clemmer, Joel T. and Srivastava, + Ishan and Silbert, Leonardo E. and Grest, Gary S. + and Lechman, Jeremy B.}, + title = {Large-scale frictionless jamming with power-law particle + size distributions}, + journal = {Phys. Rev. E}, + volume = {106} + issue = {3} + year = {2022} +} + +- fix srd command: doi:10.1063/1.3419070 + +@Article{Petersen10, + author = {M. K. Petersen and J. B. Lechman and S. J. Plimpton and + G. S. Grest and in 't Veld, P. J. and P. R. Schunk}, + title = {Mesoscale Hydrodynamics via Stochastic Rotation + Dynamics: Comparison with {L}ennard-{J}ones Fluid}, + journal = {J.~Chem.\ Phys.}, + year = 2010, + volume = 132, + pages = 174106 +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +SRD info: + SRD/big particles = 43720 270 + big particle diameter max/min = 1 1 + SRD temperature & lamda = 1 0.063245553 + SRD max distance & max velocity = 0.25298221 12.649111 + SRD grid counts: 106 106 1 + SRD grid size: request, actual (xyz) = 0.25, 0.25081894 0.25081894 1 + SRD per actual grid cell = 5.5586635 + SRD viscosity = 0.23558168 + big/SRD mass density ratio = 0.14409881 +WARNING: Fix srd grid size > 1/4 of big particle diameter (src/SRD/fix_srd.cpp:2830) + # of rescaled SRD velocities = 0 + ave/max small velocity = 4.1908497 7.725824 + ave/max big velocity = 2.202625 5.4167964 +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 2.8 + ghost atom cutoff = 2.8 + binsize = 26.586808, bins = 1 1 1 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/multi/atomonly/newton + stencil: half/multi/2d + bin: multi +Per MPI rank memory allocation (min/avg/max) = 14.19 | 14.19 | 14.2 Mbytes + Step Temp f_2[8] TotEng v_pebig v_ebig Press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] f_2[12] + 0 18.299191 0 0.25067776 37.859815 40.841906 5.7680841 0 0 0 0 0 0 0 0 0 0 0 0 + 1000 1.4057114 8217 0.22974151 37.20177 37.430849 11.548865 14197 56 57 0 682 42436 11236 8217 1.0187465 0 3 0 + 2000 1.0468288 8223 0.22932205 37.191914 37.362508 4.8322766 14185 60 60 0 1452 42436 11236 8223 1.0271433 0 64 0 + 3000 0.89541606 8240 0.22921893 37.199787 37.345707 9.7555289 14770 60 60 0 2175 42436 11236 8240 1.0157844 0 64 0 + 4000 1.021344 8222 0.22920858 37.177579 37.344021 6.2834235 14480 50 50 0 2951 42436 11236 8222 1.0130315 0 64 0 + 5000 1.045809 8222 0.2294309 37.209813 37.380241 2.8847497 14109 59 60 0 3667 42436 11236 8222 1.0126872 0 64 0 + 6000 1.1527336 8227 0.22933212 37.176296 37.364149 5.4760843 14597 42 42 0 4418 42436 11236 8227 1.0188272 0 64 0 + 7000 1.1799559 8216 0.22941075 37.18467 37.376959 10.243848 14281 57 57 0 5154 42436 11236 8216 1.0063617 0 64 0 + 8000 1.1913762 8188 0.22940126 37.181263 37.375413 5.7338518 14497 47 47 0 5878 42436 11236 8188 1.0076169 0 64 0 + 9000 1.0587094 8230 0.22928172 37.183406 37.355936 5.7323116 14267 62 62 0 6550 42436 11236 8230 1.0108237 0 64 0 + 10000 1.0359117 8165 0.22944086 37.21305 37.381865 9.4246373 14016 52 52 0 7246 42436 11236 8165 1.0147132 0 64 0 +Loop time of 6.61179 on 4 procs for 10000 steps with 43990 atoms + +Performance: 130675.562 tau/day, 1512.449 timesteps/s, 66.533 Matom-step/s +99.2% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.041077 | 0.059027 | 0.07409 | 4.8 | 0.89 +Neigh | 0.015706 | 0.017829 | 0.019903 | 1.1 | 0.27 +Comm | 0.23742 | 0.25326 | 0.26722 | 2.1 | 3.83 +Output | 0.00073333 | 0.00077549 | 0.00084859 | 0.0 | 0.01 +Modify | 6.1477 | 6.174 | 6.2149 | 1.0 | 93.38 +Other | | 0.1069 | | | 1.62 + +Nlocal: 10997.5 ave 11924 max 10204 min +Histogram: 1 0 1 0 0 1 0 0 0 1 +Nghost: 64.25 ave 71 max 56 min +Histogram: 1 0 0 1 0 0 0 0 1 1 +Neighs: 395.5 ave 497 max 271 min +Histogram: 1 0 0 0 0 1 1 0 0 1 + +Total # of neighbors = 1582 +Ave neighs/atom = 0.035962719 +Neighbor list builds = 500 +Dangerous builds = 0 +Total wall time: 0:00:07 diff --git a/examples/ASPHERE/star/log.1Feb24.star.mp.g++.1 b/examples/ASPHERE/star/log.1Feb24.star.mp.g++.1 new file mode 100644 index 0000000000..4952b0bd30 --- /dev/null +++ b/examples/ASPHERE/star/log.1Feb24.star.mp.g++.1 @@ -0,0 +1,322 @@ +LAMMPS (21 Nov 2023 - Development - patch_21Nov2023-665-g17f869bf5e) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# SRD viscosity demo - rigid star particles + +units lj +atom_style sphere +atom_modify map array first big +dimension 2 + +# read in clusters of rigid bodies + +fix molprop all property/atom mol ghost yes +read_data data.star fix molprop NULL Molecules +Reading data file ... + orthogonal box = (-13.293404 -13.293404 -0.5) to (13.293404 13.293404 0.5) + 1 by 1 by 1 MPI processor grid + reading atoms ... + 270 atoms + read_data CPU = 0.001 seconds + +set type 1 mass 1.0 +Setting atom values ... + 270 settings made for mass +group big type 1 +270 atoms in group big +velocity big create 1.44 87287 loop geom + +# equilibrate big particles + +pair_style soft 1.12 +pair_coeff 1 1 0.0 +pair_coeff 2 2 0.0 0.0 +pair_coeff 1 2 0.0 0.0 + +variable prefactor equal ramp(0,60) +fix soft all adapt 1 pair soft a * * v_prefactor + +neighbor 0.3 bin +neigh_modify delay 0 every 1 check yes + +fix 1 big rigid molecule + 30 rigid bodies with 270 atoms +fix 2 all enforce2d + +#dump 1 all atom 10 dump.star.equil + +compute tbig all temp/sphere +thermo_modify temp tbig + +thermo 100 +run 1000 +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 1.42 + ghost atom cutoff = 1.42 + binsize = 0.71, bins = 38 38 2 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair soft, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/2d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 5.562 | 5.562 | 5.562 Mbytes + Step Temp E_pair E_mol TotEng Press + 0 1.3101488 0 0 0.21350573 0.32876464 + 100 5.0954142 3.291475 0 4.1218387 1.0087565 + 200 13.041252 4.6176595 0 6.7429006 1.5291618 + 300 11.912727 7.0921814 0 9.0335147 1.9578844 + 400 17.60886 8.3666709 0 11.236263 1.602563 + 500 16.786375 10.630838 0 13.366396 1.7725508 + 600 18.470347 12.42157 0 15.431552 2.1627885 + 700 19.39794 14.349074 0 17.510219 1.9554238 + 800 19.082984 16.464746 0 19.574566 2.2424126 + 900 20.702091 18.253108 0 21.626782 1.8041661 + 1000 18.299191 20.699563 0 23.681654 2.9475408 +Loop time of 0.0474374 on 1 procs for 1000 steps with 270 atoms + +Performance: 9106745.092 tau/day, 21080.428 timesteps/s, 5.692 Matom-step/s +98.9% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.01287 | 0.01287 | 0.01287 | 0.0 | 27.13 +Neigh | 0.0050573 | 0.0050573 | 0.0050573 | 0.0 | 10.66 +Comm | 0.0024616 | 0.0024616 | 0.0024616 | 0.0 | 5.19 +Output | 0.00025461 | 0.00025461 | 0.00025461 | 0.0 | 0.54 +Modify | 0.024714 | 0.024714 | 0.024714 | 0.0 | 52.10 +Other | | 0.00208 | | | 4.38 + +Nlocal: 270 ave 270 max 270 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 73 ave 73 max 73 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 418 ave 418 max 418 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 418 +Ave neighs/atom = 1.5481481 +Neighbor list builds = 176 +Dangerous builds = 0 + +#undump 1 +unfix soft +unfix 1 +unfix 2 + +# add small particles as hi density lattice + +region plane block INF INF INF INF -0.001 0.001 units box +lattice sq 85.0 +Lattice spacing in x,y,z = 0.10846523 0.10846523 0.10846523 +create_atoms 2 region plane +Created 60025 atoms + using lattice units in orthogonal box = (-13.293404 -13.293404 -0.5) to (13.293404 13.293404 0.5) + create_atoms CPU = 0.014 seconds + +set type 2 mass 0.1 +Setting atom values ... + 60025 settings made for mass +group small type 2 +60025 atoms in group small +velocity small create 1.0 593849 loop geom + +# delete overlaps +# must set 1-2 cutoff to non-zero value + +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 +pair_coeff 2 2 0.0 1.0 0.0 +pair_coeff 1 2 0.0 1.0 0.5 + +delete_atoms overlap 0.5 small big +System init for delete_atoms ... +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 2.8 + ghost atom cutoff = 2.8 + binsize = 1.4, bins = 19 19 1 + 2 neighbor lists, perpetual/occasional/extra = 1 1 0 + (1) command delete_atoms, occasional + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/2d + bin: standard + (2) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/2d + bin: standard +WARNING: Delete_atoms cutoff > minimum neighbor cutoff (src/delete_atoms.cpp:312) +Deleted 16305 atoms, new total = 43990 + +# SRD run + +reset_timestep 0 + +neighbor 0.3 multi +neigh_modify delay 0 every 1 check yes + +comm_modify mode multi group big vel yes +neigh_modify include big + +# no pairwise interactions with small particles + +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 +pair_coeff 2 2 0.0 1.0 0.0 +pair_coeff 1 2 0.0 1.0 0.0 + +# use fix SRD to push small particles out from inside big ones +# if comment out, big particles won't see SRD particles + +timestep 0.001 + +fix 1 big rigid molecule + 30 rigid bodies with 270 atoms +fix 2 small srd 20 big 1.0 0.25 49894 shift yes 54979 search 0.2 collision slip inside ignore overlap yes +fix 3 small viscosity 10 x y 50 +fix 4 all enforce2d + +# diagnostics + +uncompute tbig +compute tbig big temp/sphere +variable pebig equal pe*atoms/count(big) +variable ebig equal etotal*atoms/count(big) +thermo_style custom step temp f_2[8] etotal v_pebig v_ebig press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] f_2[12] +WARNING: New thermo_style command, previous thermo_modify settings will be lost (src/output.cpp:904) + +thermo_modify temp tbig +WARNING: Temperature for thermo pressure is not for group all (src/thermo.cpp:530) +thermo 1000 + +#dump 1 all atom 1000 dump.star.mp + +#dump 1 all image 1000 image.*.jpg type type zoom 1.6 +#dump_modify 1 pad 6 adiam 1 1 adiam 2 0.2 + +run 10000 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- neighbor multi command: doi:10.1016/j.cpc.2008.03.005, doi:10.1007/s40571-020-00361-2 + +@Article{Intveld08, + author = {in 't Veld, P. J. and S. J.~Plimpton and G. S. Grest}, + title = {Accurate and Efficient Methods for Modeling Colloidal + Mixtures in an Explicit Solvent using Molecular Dynamics}, + journal = {Comput.\ Phys.\ Commut.}, + year = 2008, + volume = 179, + pages = {320--329} +} + +@article{Shire2020, + author = {Shire, Tom and Hanley, Kevin J. and Stratford, Kevin}, + title = {{DEM} Simulations of Polydisperse Media: Efficient Contact + Detection Applied to Investigate the Quasi-Static Limit}, + journal = {Computational Particle Mechanics}, + year = {2020} +@article{Monti2022, + author = {Monti, Joseph M. and Clemmer, Joel T. and Srivastava, + Ishan and Silbert, Leonardo E. and Grest, Gary S. + and Lechman, Jeremy B.}, + title = {Large-scale frictionless jamming with power-law particle + size distributions}, + journal = {Phys. Rev. E}, + volume = {106} + issue = {3} + year = {2022} +} + +- fix srd command: doi:10.1063/1.3419070 + +@Article{Petersen10, + author = {M. K. Petersen and J. B. Lechman and S. J. Plimpton and + G. S. Grest and in 't Veld, P. J. and P. R. Schunk}, + title = {Mesoscale Hydrodynamics via Stochastic Rotation + Dynamics: Comparison with {L}ennard-{J}ones Fluid}, + journal = {J.~Chem.\ Phys.}, + year = 2010, + volume = 132, + pages = 174106 +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +SRD info: + SRD/big particles = 43720 270 + big particle diameter max/min = 1 1 + SRD temperature & lamda = 1 0.063245553 + SRD max distance & max velocity = 0.25298221 12.649111 + SRD grid counts: 106 106 1 + SRD grid size: request, actual (xyz) = 0.25, 0.25081894 0.25081894 1 + SRD per actual grid cell = 5.5586635 + SRD viscosity = 0.23558168 + big/SRD mass density ratio = 0.14409881 +WARNING: Fix srd grid size > 1/4 of big particle diameter (src/SRD/fix_srd.cpp:2830) + # of rescaled SRD velocities = 0 + ave/max small velocity = 4.1908497 7.725824 + ave/max big velocity = 2.202625 5.4167964 +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 2.8 + ghost atom cutoff = 2.8 + binsize = 26.586808, bins = 1 1 1 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/multi/atomonly/newton + stencil: half/multi/2d + bin: multi +Per MPI rank memory allocation (min/avg/max) = 41.29 | 41.29 | 41.29 Mbytes + Step Temp f_2[8] TotEng v_pebig v_ebig Press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] f_2[12] + 0 18.299191 0 0.25067776 37.859815 40.841906 5.7680841 0 0 0 0 0 0 0 0 0 0 0 0 + 1000 0.82328749 8250 0.22908506 37.18973 37.323895 6.0611499 14546 54 54 0 691 28900 11236 8250 1.025654 0 3 0 + 2000 1.314397 8198 0.22953802 37.183497 37.397695 7.6050033 14165 65 65 0 1503 28900 11236 8198 1.0137885 0 3 0 + 3000 1.4327928 8174 0.22973765 37.196727 37.430219 4.8441566 14378 43 43 0 2274 28900 11236 8174 1.0052401 0 5 0 + 4000 1.9637993 8194 0.23036966 37.213164 37.533191 4.9697216 14203 51 51 1 3241 28900 11236 8194 1.0129187 0 245 0 + 5000 1.6886675 8206 0.22987561 37.177507 37.452697 10.972628 14155 56 56 0 4073 28900 11236 8206 1.0024406 0 245 0 + 6000 1.7377657 8197 0.23000322 37.190296 37.473487 6.3971042 14331 57 57 0 4929 28900 11236 8197 1.0094945 0 245 0 + 7000 2.4106224 8199 0.23083719 37.216521 37.609363 5.1070917 14144 49 49 0 5822 28900 11236 8199 1.0074275 0 245 0 + 8000 2.5161884 8202 0.2306663 37.171475 37.581521 12.156127 14263 67 67 0 6667 28900 11236 8202 1.006502 0 245 0 + 9000 2.9100148 8188 0.23124828 37.202115 37.67634 6.1326598 14171 66 67 0 7443 28900 11236 8188 0.99544201 0 245 0 + 10000 3.4714177 8206 0.23192306 37.220567 37.78628 5.1293943 14100 48 49 0 8272 28900 11236 8206 1.0022763 0 245 0 +Loop time of 17.933 on 1 procs for 10000 steps with 43990 atoms + +Performance: 48179.444 tau/day, 557.632 timesteps/s, 24.530 Matom-step/s +99.7% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.22008 | 0.22008 | 0.22008 | 0.0 | 1.23 +Neigh | 0.054046 | 0.054046 | 0.054046 | 0.0 | 0.30 +Comm | 0.20917 | 0.20917 | 0.20917 | 0.0 | 1.17 +Output | 0.001317 | 0.001317 | 0.001317 | 0.0 | 0.01 +Modify | 17.275 | 17.275 | 17.275 | 0.0 | 96.33 +Other | | 0.1731 | | | 0.97 + +Nlocal: 43990 ave 43990 max 43990 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 122 ave 122 max 122 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 1569 ave 1569 max 1569 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 1569 +Ave neighs/atom = 0.035667197 +Neighbor list builds = 500 +Dangerous builds = 0 +Total wall time: 0:00:19 diff --git a/examples/ASPHERE/star/log.1Feb24.star.mp.g++.4 b/examples/ASPHERE/star/log.1Feb24.star.mp.g++.4 new file mode 100644 index 0000000000..b4482fd530 --- /dev/null +++ b/examples/ASPHERE/star/log.1Feb24.star.mp.g++.4 @@ -0,0 +1,322 @@ +LAMMPS (21 Nov 2023 - Development - patch_21Nov2023-665-g17f869bf5e) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# SRD viscosity demo - rigid star particles + +units lj +atom_style sphere +atom_modify map array first big +dimension 2 + +# read in clusters of rigid bodies + +fix molprop all property/atom mol ghost yes +read_data data.star fix molprop NULL Molecules +Reading data file ... + orthogonal box = (-13.293404 -13.293404 -0.5) to (13.293404 13.293404 0.5) + 2 by 2 by 1 MPI processor grid + reading atoms ... + 270 atoms + read_data CPU = 0.001 seconds + +set type 1 mass 1.0 +Setting atom values ... + 270 settings made for mass +group big type 1 +270 atoms in group big +velocity big create 1.44 87287 loop geom + +# equilibrate big particles + +pair_style soft 1.12 +pair_coeff 1 1 0.0 +pair_coeff 2 2 0.0 0.0 +pair_coeff 1 2 0.0 0.0 + +variable prefactor equal ramp(0,60) +fix soft all adapt 1 pair soft a * * v_prefactor + +neighbor 0.3 bin +neigh_modify delay 0 every 1 check yes + +fix 1 big rigid molecule + 30 rigid bodies with 270 atoms +fix 2 all enforce2d + +#dump 1 all atom 10 dump.star.equil + +compute tbig all temp/sphere +thermo_modify temp tbig + +thermo 100 +run 1000 +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 1.42 + ghost atom cutoff = 1.42 + binsize = 0.71, bins = 38 38 2 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair soft, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/2d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 5.554 | 5.554 | 5.555 Mbytes + Step Temp E_pair E_mol TotEng Press + 0 1.3101488 0 0 0.21350573 0.32876464 + 100 5.0954142 3.291475 0 4.1218387 1.0087565 + 200 13.041252 4.6176595 0 6.7429006 1.5291618 + 300 11.912727 7.0921814 0 9.0335147 1.9578844 + 400 17.60886 8.3666709 0 11.236263 1.602563 + 500 16.786375 10.630838 0 13.366396 1.7725508 + 600 18.470347 12.42157 0 15.431552 2.1627885 + 700 19.39794 14.349074 0 17.510219 1.9554238 + 800 19.082984 16.464746 0 19.574566 2.2424126 + 900 20.702091 18.253108 0 21.626782 1.8041661 + 1000 18.299191 20.699563 0 23.681654 2.9475408 +Loop time of 0.0311841 on 4 procs for 1000 steps with 270 atoms + +Performance: 13853197.664 tau/day, 32067.587 timesteps/s, 8.658 Matom-step/s +97.6% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.0027957 | 0.0031644 | 0.0035219 | 0.5 | 10.15 +Neigh | 0.001171 | 0.0012862 | 0.0014036 | 0.3 | 4.12 +Comm | 0.0099068 | 0.010544 | 0.011053 | 0.4 | 33.81 +Output | 0.00014281 | 0.00016091 | 0.00020823 | 0.0 | 0.52 +Modify | 0.013319 | 0.013618 | 0.014047 | 0.2 | 43.67 +Other | | 0.002411 | | | 7.73 + +Nlocal: 67.5 ave 80 max 54 min +Histogram: 1 1 0 0 0 0 0 0 1 1 +Nghost: 29.75 ave 33 max 26 min +Histogram: 1 0 0 0 1 0 0 1 0 1 +Neighs: 104.5 ave 135 max 72 min +Histogram: 1 0 0 1 0 0 0 1 0 1 + +Total # of neighbors = 418 +Ave neighs/atom = 1.5481481 +Neighbor list builds = 176 +Dangerous builds = 0 + +#undump 1 +unfix soft +unfix 1 +unfix 2 + +# add small particles as hi density lattice + +region plane block INF INF INF INF -0.001 0.001 units box +lattice sq 85.0 +Lattice spacing in x,y,z = 0.10846523 0.10846523 0.10846523 +create_atoms 2 region plane +Created 60025 atoms + using lattice units in orthogonal box = (-13.293404 -13.293404 -0.5) to (13.293404 13.293404 0.5) + create_atoms CPU = 0.003 seconds + +set type 2 mass 0.1 +Setting atom values ... + 60025 settings made for mass +group small type 2 +60025 atoms in group small +velocity small create 1.0 593849 loop geom + +# delete overlaps +# must set 1-2 cutoff to non-zero value + +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 +pair_coeff 2 2 0.0 1.0 0.0 +pair_coeff 1 2 0.0 1.0 0.5 + +delete_atoms overlap 0.5 small big +System init for delete_atoms ... +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 2.8 + ghost atom cutoff = 2.8 + binsize = 1.4, bins = 19 19 1 + 2 neighbor lists, perpetual/occasional/extra = 1 1 0 + (1) command delete_atoms, occasional + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/2d + bin: standard + (2) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/2d + bin: standard +WARNING: Delete_atoms cutoff > minimum neighbor cutoff (src/delete_atoms.cpp:312) +Deleted 16305 atoms, new total = 43990 + +# SRD run + +reset_timestep 0 + +neighbor 0.3 multi +neigh_modify delay 0 every 1 check yes + +comm_modify mode multi group big vel yes +neigh_modify include big + +# no pairwise interactions with small particles + +pair_style lj/cut 2.5 +pair_coeff 1 1 1.0 1.0 +pair_coeff 2 2 0.0 1.0 0.0 +pair_coeff 1 2 0.0 1.0 0.0 + +# use fix SRD to push small particles out from inside big ones +# if comment out, big particles won't see SRD particles + +timestep 0.001 + +fix 1 big rigid molecule + 30 rigid bodies with 270 atoms +fix 2 small srd 20 big 1.0 0.25 49894 shift yes 54979 search 0.2 collision slip inside ignore overlap yes +fix 3 small viscosity 10 x y 50 +fix 4 all enforce2d + +# diagnostics + +uncompute tbig +compute tbig big temp/sphere +variable pebig equal pe*atoms/count(big) +variable ebig equal etotal*atoms/count(big) +thermo_style custom step temp f_2[8] etotal v_pebig v_ebig press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] f_2[12] +WARNING: New thermo_style command, previous thermo_modify settings will be lost (src/output.cpp:904) + +thermo_modify temp tbig +WARNING: Temperature for thermo pressure is not for group all (src/thermo.cpp:530) +thermo 1000 + +#dump 1 all atom 1000 dump.star.mp + +#dump 1 all image 1000 image.*.jpg type type zoom 1.6 +#dump_modify 1 pad 6 adiam 1 1 adiam 2 0.2 + +run 10000 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- neighbor multi command: doi:10.1016/j.cpc.2008.03.005, doi:10.1007/s40571-020-00361-2 + +@Article{Intveld08, + author = {in 't Veld, P. J. and S. J.~Plimpton and G. S. Grest}, + title = {Accurate and Efficient Methods for Modeling Colloidal + Mixtures in an Explicit Solvent using Molecular Dynamics}, + journal = {Comput.\ Phys.\ Commut.}, + year = 2008, + volume = 179, + pages = {320--329} +} + +@article{Shire2020, + author = {Shire, Tom and Hanley, Kevin J. and Stratford, Kevin}, + title = {{DEM} Simulations of Polydisperse Media: Efficient Contact + Detection Applied to Investigate the Quasi-Static Limit}, + journal = {Computational Particle Mechanics}, + year = {2020} +@article{Monti2022, + author = {Monti, Joseph M. and Clemmer, Joel T. and Srivastava, + Ishan and Silbert, Leonardo E. and Grest, Gary S. + and Lechman, Jeremy B.}, + title = {Large-scale frictionless jamming with power-law particle + size distributions}, + journal = {Phys. Rev. E}, + volume = {106} + issue = {3} + year = {2022} +} + +- fix srd command: doi:10.1063/1.3419070 + +@Article{Petersen10, + author = {M. K. Petersen and J. B. Lechman and S. J. Plimpton and + G. S. Grest and in 't Veld, P. J. and P. R. Schunk}, + title = {Mesoscale Hydrodynamics via Stochastic Rotation + Dynamics: Comparison with {L}ennard-{J}ones Fluid}, + journal = {J.~Chem.\ Phys.}, + year = 2010, + volume = 132, + pages = 174106 +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +SRD info: + SRD/big particles = 43720 270 + big particle diameter max/min = 1 1 + SRD temperature & lamda = 1 0.063245553 + SRD max distance & max velocity = 0.25298221 12.649111 + SRD grid counts: 106 106 1 + SRD grid size: request, actual (xyz) = 0.25, 0.25081894 0.25081894 1 + SRD per actual grid cell = 5.5586635 + SRD viscosity = 0.23558168 + big/SRD mass density ratio = 0.14409881 +WARNING: Fix srd grid size > 1/4 of big particle diameter (src/SRD/fix_srd.cpp:2830) + # of rescaled SRD velocities = 0 + ave/max small velocity = 4.1908497 7.725824 + ave/max big velocity = 2.202625 5.4167964 +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 2.8 + ghost atom cutoff = 2.8 + binsize = 26.586808, bins = 1 1 1 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/multi/atomonly/newton + stencil: half/multi/2d + bin: multi +Per MPI rank memory allocation (min/avg/max) = 14.19 | 14.19 | 14.2 Mbytes + Step Temp f_2[8] TotEng v_pebig v_ebig Press f_2[1] f_2[2] f_2[3] f_2[4] f_2[5] f_2[6] f_2[7] f_2[8] f_2[9] f_2[10] f_2[11] f_2[12] + 0 18.299191 0 0.25067776 37.859815 40.841906 5.7680841 0 0 0 0 0 0 0 0 0 0 0 0 + 1000 1.3506473 8186 0.22968182 37.201018 37.421123 5.6398923 14572 54 54 0 654 42436 11236 8186 1.0228728 0 3 0 + 2000 0.99412905 8212 0.22952823 37.234094 37.3961 8.5863689 14257 69 69 0 1394 42436 11236 8212 1.0206297 0 12 0 + 3000 1.4469134 8192 0.22970951 37.189841 37.425634 8.0408437 14439 53 53 0 2178 42436 11236 8192 1.0121272 0 12 0 + 4000 1.6112802 8172 0.2303679 37.270324 37.532903 8.3379947 14098 57 57 0 2992 42436 11236 8172 1.0171443 0 12 0 + 5000 2.0436283 8191 0.23016186 37.166298 37.499334 7.1370191 14030 49 49 0 3804 42436 11236 8191 1.0054513 0 12 0 + 6000 2.2894073 8184 0.2303867 37.162878 37.535967 7.6496143 13970 50 50 0 4662 42436 11236 8184 1.0084738 0 12 0 + 7000 2.1640822 8183 0.23045121 37.193812 37.546477 7.1526683 13926 56 57 0 5445 42436 11236 8183 1.0046108 0 15 0 + 8000 2.8851243 8199 0.23121762 37.201176 37.671344 9.1644504 13849 58 58 0 6237 42436 11236 8199 1.0081629 0 15 0 + 9000 2.6422092 8180 0.23070839 37.157795 37.588377 2.4816571 13651 70 70 0 7007 42436 11236 8180 1.0089869 0 15 0 + 10000 2.7121051 8189 0.23087145 37.172972 37.614945 11.176036 13901 63 64 0 7845 42436 11236 8189 1.0023484 0 15 0 +Loop time of 6.56969 on 4 procs for 10000 steps with 43990 atoms + +Performance: 131513.146 tau/day, 1522.143 timesteps/s, 66.959 Matom-step/s +99.1% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.037869 | 0.059232 | 0.073664 | 5.4 | 0.90 +Neigh | 0.015688 | 0.017835 | 0.019891 | 1.1 | 0.27 +Comm | 0.22905 | 0.24375 | 0.26098 | 2.3 | 3.71 +Output | 0.00069058 | 0.00071614 | 0.00078869 | 0.0 | 0.01 +Modify | 6.1124 | 6.1385 | 6.1881 | 1.2 | 93.44 +Other | | 0.1096 | | | 1.67 + +Nlocal: 10997.5 ave 12305 max 10259 min +Histogram: 1 1 0 1 0 0 0 0 0 1 +Nghost: 58.25 ave 73 max 48 min +Histogram: 1 0 1 0 1 0 0 0 0 1 +Neighs: 402.75 ave 520 max 207 min +Histogram: 1 0 0 0 0 0 0 2 0 1 + +Total # of neighbors = 1611 +Ave neighs/atom = 0.03662196 +Neighbor list builds = 500 +Dangerous builds = 0 +Total wall time: 0:00:06 diff --git a/examples/ASPHERE/tri/in.tri.srd b/examples/ASPHERE/tri/in.tri.srd index 7878b9ecc2..b09ff05503 100644 --- a/examples/ASPHERE/tri/in.tri.srd +++ b/examples/ASPHERE/tri/in.tri.srd @@ -1,107 +1,107 @@ # Aspherical shear demo - 3d triangle boxes, solvated by SRD particles -units lj -atom_style tri -atom_modify first big map yes +units lj +atom_style tri +atom_modify first big map yes -read_data data.tri.srd +read_data data.tri.srd # add small particles as hi density lattice -lattice sc 0.4 -region box block INF INF INF INF INF INF -lattice sc 20.0 -create_atoms 2 region box +lattice sc 0.4 +region box block INF INF INF INF INF INF +lattice sc 20.0 +create_atoms 2 region box -group big type 1 -group small type 2 -set group small mass 0.01 +group big type 1 +group small type 2 +set group small mass 0.01 # delete overlaps # must set 1-2 cutoff to non-zero value -pair_style lj/cut 1.5 -pair_coeff 1 1 1.0 1.0 -pair_coeff 2 2 0.0 1.0 0.0 -pair_coeff 1 2 0.0 1.0 +pair_style lj/cut 1.5 +pair_coeff 1 1 1.0 1.0 +pair_coeff 2 2 0.0 1.0 0.0 +pair_coeff 1 2 0.0 1.0 -delete_atoms overlap 1.5 small big +delete_atoms overlap 1.5 small big # SRD run -reset_timestep 0 +reset_timestep 0 -velocity small create 1.44 87287 loop geom +velocity small create 1.44 87287 loop geom -neighbor 0.3 multi -neigh_modify delay 0 every 1 check yes -neigh_modify exclude molecule/intra big include big +neighbor 0.3 multi +neigh_modify delay 0 every 1 check yes +neigh_modify exclude molecule/intra big include big -comm_modify mode multi group big vel yes -neigh_modify include big +comm_modify mode multi group big vel yes +neigh_modify include big # no pairwise interactions with small particles -pair_style tri/lj 3.5 -pair_coeff 1 1 0.1 1.0 -pair_coeff 2 2 0.0 1.0 0.0 -pair_coeff 1 2 0.0 1.0 0.0 +pair_style tri/lj 3.5 +pair_coeff 1 1 0.1 1.0 +pair_coeff 2 2 0.0 1.0 0.0 +pair_coeff 1 2 0.0 1.0 0.0 # use fix SRD to push small particles out from inside big ones # if comment out, big particles won't see SRD particles -timestep 0.001 +timestep 0.001 -fix 1 big rigid/small molecule #langevin 1.0 1.0 0.1 12398 -fix 2 small srd 20 big 1.0 1.0 49894 & - search 0.2 cubic warn 0.0001 shift yes 49829 & - overlap yes collision noslip inside ignore +fix 1 big rigid/small molecule #langevin 1.0 1.0 0.1 12398 +fix 2 small srd 20 big 1.0 1.0 49894 & + search 0.2 cubic warn 0.0001 shift yes 49829 & + overlap yes collision noslip inside ignore -fix 3 all deform 1 x scale 0.8 y scale 0.8 z scale 0.8 +fix 3 all deform 1 x scale 0.8 y scale 0.8 z scale 0.8 # diagnostics -compute tsmall small temp/deform -compute tbig big temp -variable pebig equal pe*atoms/count(big) -variable ebig equal etotal*atoms/count(big) +compute tsmall small temp/deform +compute tbig big temp +variable pebig equal pe*atoms/count(big) +variable ebig equal etotal*atoms/count(big) compute_modify tbig extra/dof -4500 -compute 1 big erotate/asphere -compute 2 all ke -compute 3 all pe -variable toteng equal (c_1+c_2+c_3)/atoms +compute 1 big erotate/asphere +compute 2 all ke +compute 3 all pe +variable toteng equal (c_1+c_2+c_3)/atoms -thermo 100 -thermo_style custom step f_1 c_tsmall temp press f_2[9] f_2[4] -thermo_modify temp tbig +thermo 100 +thermo_style custom step f_1 c_tsmall temp press f_2[9] f_2[4] +thermo_modify temp tbig -compute 10 all property/atom corner1x corner1y corner1z & - corner2x corner2y corner2z corner3x corner3y corner3z +compute 10 all property/atom corner1x corner1y corner1z & + corner2x corner2y corner2z corner3x corner3y corner3z -#dump 1 all custom 500 dump1.atom.srd id type x y z ix iy iz -#dump 2 all custom 500 dump1.tri.srd id type & -# c_10[1] c_10[2] c_10[3] c_10[4] c_10[5] c_10[6] & -# c_10[7] c_10[8] c_10[9] +#dump 1 all custom 500 dump1.atom.srd id type x y z ix iy iz +#dump 2 all custom 500 dump1.tri.srd id type & +# c_10[1] c_10[2] c_10[3] c_10[4] c_10[5] c_10[6] & +# c_10[7] c_10[8] c_10[9] -run 10000 +run 1000 #undump 1 #undump 2 -unfix 3 +unfix 3 change_box all triclinic -fix 2 small srd 20 big 1.0 1.0 49894 & - search 0.2 cubic warn 0.0001 shift yes 49829 & - overlap yes collision noslip tstat yes inside ignore +fix 2 small srd 20 big 1.0 1.0 49894 & + search 0.2 cubic warn 0.0001 shift yes 49829 & + overlap yes collision noslip tstat yes inside ignore -#dump 1 all custom 500 dump2.atom.srd id type x y z ix iy iz -#dump 2 all custom 500 dump2.tri.srd id type & -# c_10[1] c_10[2] c_10[3] c_10[4] c_10[5] c_10[6] & -# c_10[7] c_10[8] c_10[9] +#dump 1 all custom 500 dump2.atom.srd id type x y z ix iy iz +#dump 2 all custom 500 dump2.tri.srd id type & +# c_10[1] c_10[2] c_10[3] c_10[4] c_10[5] c_10[6] & +# c_10[7] c_10[8] c_10[9] -fix 3 all deform 1 xy erate 0.05 units box remap v +fix 3 all deform 1 xy erate 0.05 units box remap v -run 40000 +run 2000 diff --git a/examples/ASPHERE/tri/log.15Aug23.tri.srd.g++.8 b/examples/ASPHERE/tri/log.15Aug23.tri.srd.g++.8 deleted file mode 100644 index 6103a5c9c9..0000000000 --- a/examples/ASPHERE/tri/log.15Aug23.tri.srd.g++.8 +++ /dev/null @@ -1,812 +0,0 @@ -LAMMPS (2 Aug 2023 - Development - patch_2Aug2023-114-gdad8081d55-modified) -WARNING: Using I/O redirection is unreliable with parallel runs. Better to use the -in switch to read input files. (../lammps.cpp:537) -# Aspherical shear demo - 3d triangle boxes, solvated by SRD particles - -units lj -atom_style tri -atom_modify first big map yes - -read_data data.tri.srd -Reading data file ... - orthogonal box = (-8.4373405 -8.4373405 -8.4373405) to (8.4373405 8.4373405 8.4373405) - 2 by 2 by 2 MPI processor grid - reading atoms ... - 1500 atoms - 1500 triangles - read_data CPU = 0.007 seconds - -# add small particles as hi density lattice - -lattice sc 0.4 -Lattice spacing in x,y,z = 1.3572088 1.3572088 1.3572088 -region box block INF INF INF INF INF INF -lattice sc 20.0 -Lattice spacing in x,y,z = 0.36840315 0.36840315 0.36840315 -create_atoms 2 region box -Created 91125 atoms - using lattice units in orthogonal box = (-8.4373405 -8.4373405 -8.4373405) to (8.4373405 8.4373405 8.4373405) - create_atoms CPU = 0.002 seconds - -group big type 1 -1500 atoms in group big -group small type 2 -91125 atoms in group small -set group small mass 0.01 -Setting atom values ... - 91125 settings made for mass - -# delete overlaps -# must set 1-2 cutoff to non-zero value - -pair_style lj/cut 1.5 -pair_coeff 1 1 1.0 1.0 -pair_coeff 2 2 0.0 1.0 0.0 -pair_coeff 1 2 0.0 1.0 - -delete_atoms overlap 1.5 small big -System init for delete_atoms ... -Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule -Neighbor list info ... - update: every = 1 steps, delay = 0 steps, check = yes - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 1.8 - ghost atom cutoff = 1.8 - binsize = 0.9, bins = 19 19 19 - 2 neighbor lists, perpetual/occasional/extra = 1 1 0 - (1) command delete_atoms, occasional - attributes: full, newton on - pair build: full/bin/atomonly - stencil: full/bin/3d - bin: standard - (2) pair lj/cut, perpetual - attributes: half, newton on - pair build: half/bin/atomonly/newton - stencil: half/bin/3d - bin: standard -WARNING: Delete_atoms cutoff > minimum neighbor cutoff (../delete_atoms.cpp:312) -Deleted 76354 atoms, new total = 16271 - -# SRD run - -reset_timestep 0 - -velocity small create 1.44 87287 loop geom - -neighbor 0.3 multi -neigh_modify delay 0 every 1 check yes -neigh_modify exclude molecule/intra big include big - -comm_modify mode multi group big vel yes -neigh_modify include big - -# no pairwise interactions with small particles - -pair_style tri/lj 3.5 -pair_coeff 1 1 0.1 1.0 -pair_coeff 2 2 0.0 1.0 0.0 -pair_coeff 1 2 0.0 1.0 0.0 - -# use fix SRD to push small particles out from inside big ones -# if comment out, big particles won't see SRD particles - -timestep 0.001 - -fix 1 big rigid/small molecule #langevin 1.0 1.0 0.1 12398 - create bodies CPU = 0.000 seconds - 125 rigid bodies with 1500 atoms - 1.8601881 = max distance from body owner to body atom -fix 2 small srd 20 big 1.0 1.0 49894 search 0.2 cubic warn 0.0001 shift yes 49829 overlap yes collision noslip inside ignore - -fix 3 all deform 1 x scale 0.8 y scale 0.8 z scale 0.8 - -# diagnostics - -compute tsmall small temp/deform -compute tbig big temp -variable pebig equal pe*atoms/count(big) -variable ebig equal etotal*atoms/count(big) - -compute_modify tbig extra/dof -4500 - -compute 1 big erotate/asphere -compute 2 all ke -compute 3 all pe -variable toteng equal (c_1+c_2+c_3)/atoms - -thermo 100 -thermo_style custom step f_1 c_tsmall temp press f_2[9] f_2[4] -thermo_modify temp tbig -WARNING: Temperature for thermo pressure is not for group all (../thermo.cpp:527) - -compute 10 all property/atom corner1x corner1y corner1z corner2x corner2y corner2z corner3x corner3y corner3z - -#dump 1 all custom 500 dump1.atom.srd id type x y z ix iy iz -#dump 2 all custom 500 dump1.tri.srd id type # c_10[1] c_10[2] c_10[3] c_10[4] c_10[5] c_10[6] # c_10[7] c_10[8] c_10[9] - -run 10000 - -CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE - -Your simulation uses code contributions which should be cited: - -- neighbor multi command: doi:10.1016/j.cpc.2008.03.005, doi:10.1007/s40571-020-00361-2 - -@Article{Intveld08, - author = {in 't Veld, P. J. and S. J.~Plimpton and G. S. Grest}, - title = {Accurate and Efficient Methods for Modeling Colloidal - Mixtures in an Explicit Solvent using Molecular Dynamics}, - journal = {Comput.\ Phys.\ Commut.}, - year = 2008, - volume = 179, - pages = {320--329} -} - -@article{Shire2020, - author = {Shire, Tom and Hanley, Kevin J. and Stratford, Kevin}, - title = {{DEM} Simulations of Polydisperse Media: Efficient Contact - Detection Applied to Investigate the Quasi-Static Limit}, - journal = {Computational Particle Mechanics}, - year = {2020} -@article{Monti2022, - author = {Monti, Joseph M. and Clemmer, Joel T. and Srivastava, - Ishan and Silbert, Leonardo E. and Grest, Gary S. - and Lechman, Jeremy B.}, - title = {Large-scale frictionless jamming with power-law particle - size distributions}, - journal = {Phys. Rev. E}, - volume = {106} - issue = {3} - year = {2022} -} - -- fix srd command: doi:10.1063/1.3419070 - -@Article{Petersen10, - author = {M. K. Petersen and J. B. Lechman and S. J. Plimpton and - G. S. Grest and in 't Veld, P. J. and P. R. Schunk}, - title = {Mesoscale Hydrodynamics via Stochastic Rotation - Dynamics: Comparison with {L}ennard-{J}ones Fluid}, - journal = {J.~Chem.\ Phys.}, - year = 2010, - volume = 132, - pages = 174106 -} - -CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE - -Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule -WARNING: Using compute temp/deform with inconsistent fix deform remap option (../compute_temp_deform.cpp:71) -WARNING: Using fix srd with box deformation but no SRD thermostat (../fix_srd.cpp:405) -SRD info: - SRD/big particles = 14771 1500 - big particle diameter max/min = 2.9202881 0.87320391 - SRD temperature & lamda = 1 0.2 - SRD max distance & max velocity = 0.8 40 - SRD grid counts: 17 17 17 - SRD grid size: request, actual (xyz) = 1, 0.99262829 0.99262829 0.99262829 - SRD per actual grid cell = -3.9971745 - SRD viscosity = -34.162587 - big/SRD mass density ratio = -3.3753691 -WARNING: SRD bin size for fix srd differs from user request (../fix_srd.cpp:2805) -WARNING: Fix srd grid size > 1/4 of big particle diameter (../fix_srd.cpp:2826) -WARNING: Fix srd viscosity < 0.0 due to low SRD density (../fix_srd.cpp:2828) - # of rescaled SRD velocities = 0 - ave/max small velocity = 19.970837 35.150443 - ave/max big velocity = 0 0 -Neighbor list info ... - update: every = 1 steps, delay = 0 steps, check = yes - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 3.8 - ghost atom cutoff = 3.8 - binsize = 16.874681, bins = 1 1 1 - 1 neighbor lists, perpetual/occasional/extra = 1 0 0 - (1) pair tri/lj, perpetual - attributes: half, newton on - pair build: half/multi/newton - stencil: half/multi/3d - bin: multi -Per MPI rank memory allocation (min/avg/max) = 125.9 | 126.4 | 126.7 Mbytes - Step f_1 c_tsmall Temp Press f_2[9] f_2[4] - 0 0 1.4401779 0 -0.15917996 0 0 - 100 0.36662911 1.1475389 0.24585067 1.0290503 1.1382325 18 - 200 0.73133134 1.0558153 0.49986673 0.73932383 1.049638 34 - 300 1.1229361 1.0218621 0.82641583 0.7589689 1.0205369 40 - 400 1.5826262 0.99541508 1.2201293 0.69171726 0.99190857 52 - 500 1.8834563 0.99351667 1.4778822 1.0147794 1.0005581 63 - 600 2.4225372 0.98954834 1.8740966 1.1362893 0.99760042 61 - 700 3.0172772 0.99153625 2.3351502 1.3284877 0.98731355 39 - 800 3.5307913 1.0012521 2.6477224 1.1404922 0.9846605 52 - 900 3.757064 0.99743944 2.7220653 1.4078087 0.97538456 55 - 1000 4.3165268 1.002214 3.055501 1.2252972 0.99123745 63 - 1100 4.2796945 1.0075233 3.1022956 1.1893685 1.0139864 69 - 1200 4.3719315 1.0037271 3.0054509 1.3886162 1.002661 64 - 1300 4.5628012 0.99368316 3.2690604 1.3621012 0.9810568 56 - 1400 4.6954389 0.99365088 3.1940001 1.8485712 0.99571089 71 - 1500 5.0270163 0.99455258 3.4120396 1.5992539 0.98294263 77 - 1600 5.5897797 1.0021621 3.647347 1.7796904 0.98967622 66 - 1700 5.5330194 1.0130853 3.6407996 1.8005429 1.0068955 62 - 1800 5.3606928 1.0090284 3.5863618 1.3308757 1.0214092 59 - 1900 5.6086195 1.0071865 3.7427101 1.5296314 0.99886937 55 - 2000 5.3726474 1.0064207 3.603621 1.9473142 0.99999816 54 - 2100 5.836183 1.0124553 3.7321841 1.7889397 1.0188986 59 - 2200 5.5090061 1.0113832 3.5884963 1.6617781 1.0071583 59 - 2300 5.4011211 1.0095947 3.520406 1.8937582 0.99689983 61 - 2400 5.2219281 1.0053246 3.3699458 1.7231672 0.99899754 59 - 2500 5.7695275 1.0141459 3.6211469 1.7767598 1.0143133 65 - 2600 5.4206253 1.0182828 3.521774 2.0800518 1.0081603 70 - 2700 5.1401099 1.0085209 3.4200563 2.4019836 1.0107652 59 - 2800 6.5420721 1.0159876 4.1996904 1.863842 1.0160738 61 - 2900 5.9082962 1.0106921 3.7223419 2.0586998 1.0073885 67 - 3000 5.6556123 1.0099021 3.6768976 1.921987 1.0068962 76 - 3100 5.2913762 1.0008567 3.4103831 1.9831969 0.99187526 80 - 3200 5.1032361 0.99756662 3.1967156 2.2448433 0.99743574 93 - 3300 5.2622386 1.0024934 3.3325614 2.0078097 1.0047789 86 - 3400 5.1247527 0.99810102 3.1363556 1.8907269 0.98936508 82 - 3500 4.9424333 1.0009344 3.2153968 1.9002728 0.99161849 71 - 3600 5.1243735 1.0037377 3.3117313 2.1267438 1.0078943 65 - 3700 5.5045819 1.0006119 3.5686193 2.3466538 0.99876164 68 - 3800 5.5355384 1.0022639 3.6701457 2.0383269 1.0008683 76 - 3900 6.4915796 1.0137733 4.3225864 2.6996933 1.0064787 79 - 4000 6.6631737 1.0236248 4.3057163 2.6352666 1.0255232 75 - 4100 6.2999507 1.0263876 4.0101385 2.5479077 1.0168303 79 - 4200 6.7902489 1.0247392 4.4616158 2.4926177 1.0191403 91 - 4300 6.505908 1.0182073 4.0675428 2.168754 1.0177101 74 - 4400 5.9554283 1.0115938 3.5787297 2.9258144 1.0133896 72 - 4500 6.2276609 1.0202416 3.8211204 2.5308249 1.0174385 74 - 4600 6.0485727 1.0195757 3.8217434 2.6421797 1.0201441 78 - 4700 6.511063 1.0220764 3.933486 2.8591093 1.0147269 83 - 4800 6.9478172 1.0106414 4.345402 3.3257663 1.00469 85 - 4900 6.7547045 1.0211842 4.1874576 3.6503845 1.022873 94 - 5000 7.2603949 1.0234313 4.5393985 3.4667806 1.0222306 105 - 5100 7.1899652 1.0256566 4.5421834 3.8137207 1.0317242 99 - 5200 7.1960739 1.026746 4.4288606 3.5523675 1.0242269 97 - 5300 7.1294458 1.017883 4.5799808 3.3917274 1.0145317 99 - 5400 6.2810892 1.0291953 4.0109229 2.8604571 1.0289438 97 - 5500 6.15246 1.0288734 3.8714587 3.2760394 1.0210757 89 - 5600 6.5860526 1.0192882 4.0272883 3.3124298 1.0096258 93 - 5700 7.0296116 1.0097293 4.2652722 3.6049788 1.012463 82 - 5800 6.8372302 1.0140065 4.2205065 4.3686183 1.0088542 93 - 5900 7.8887098 1.0090612 4.9724078 4.457317 1.0045137 92 - 6000 10.120663 1.0312443 6.3025192 4.72018 1.0374722 91 - 6100 9.1318265 1.0304199 5.7084296 4.244548 1.0259056 97 - 6200 8.9758903 1.0295285 5.1842704 4.870955 1.0178851 95 - 6300 9.0088218 1.022484 5.3742805 5.1554352 1.0138365 101 - 6400 10.470322 1.0287848 6.4602103 4.5461489 1.0335978 105 - 6500 11.100779 1.0347405 6.9630121 4.9840664 1.0339044 99 - 6600 10.139333 1.0476079 6.4284839 4.5523893 1.0433517 104 - 6700 8.9706766 1.0386262 5.8387485 4.247024 1.0408151 101 - 6800 7.7799532 1.0362651 4.9946283 4.6093924 1.0274763 102 - 6900 8.0866551 1.0337743 4.9942769 4.1679939 1.0454805 102 - 7000 8.0224277 1.0193598 4.9380527 3.9173115 1.0185001 109 - 7100 7.8361001 1.0211143 4.872673 5.3471479 1.024779 110 - 7200 7.8542147 1.0057183 4.8666653 4.668317 0.99980296 122 - 7300 7.9313852 1.0159181 5.0062527 4.1410294 1.0195705 114 - 7400 7.2769846 1.0155245 4.6349779 4.9138895 1.0005886 119 - 7500 7.5974523 1.0196295 4.7918247 4.2525935 1.0211412 124 - 7600 6.7835063 1.0203187 4.2674694 4.9251624 1.0218296 113 - 7700 6.4039017 1.0119494 4.1086667 5.5240525 1.0078246 118 - 7800 7.0715134 1.0149015 4.2450776 4.8796778 1.0164737 125 - 7900 6.3626535 1.02294 4.202778 4.482164 1.0235878 136 - 8000 6.2423869 1.0212553 4.0460303 5.2753307 1.0124884 132 - 8100 6.550891 1.0223318 4.2993545 5.2634985 1.0163244 143 - 8200 6.9122202 1.008347 4.3551124 5.4108909 1.0084913 142 - 8300 6.9104634 1.0103936 4.4622206 5.6762373 0.99559355 143 - 8400 6.4918879 1.0084381 4.1050732 5.8389788 1.0036021 135 - 8500 7.4377218 1.0216662 4.5229841 5.5431311 1.0260799 123 - 8600 7.572198 1.0228381 4.9058913 7.1028185 1.0015164 116 - 8700 8.204675 1.03457 5.2231696 6.4790244 1.0214635 132 - 8800 8.3118914 1.0381333 5.1795799 6.7437722 1.0290086 132 - 8900 8.2559198 1.0268665 5.218352 7.2191395 1.019804 138 - 9000 8.0403128 1.0339414 4.9310394 6.4942331 1.041527 156 - 9100 7.1773079 1.0397062 4.4993688 7.0272109 1.0388012 167 - 9200 7.1793935 1.0373589 4.3481663 7.4894459 1.0078785 157 - 9300 8.3705146 1.0248112 5.1036971 8.2173072 1.010168 156 - 9400 9.4935002 1.0252907 5.7846951 9.7466018 1.028941 170 - 9500 9.5208037 1.0371093 5.9635099 7.6444933 1.022673 165 - 9600 8.9992217 1.0292895 5.6224192 8.8071452 1.0101362 169 - 9700 8.682661 1.0422224 5.3997636 8.6827834 1.0337928 149 - 9800 7.6191562 1.0350948 4.7198842 8.6125595 1.0300395 151 - 9900 8.0910913 1.0319432 4.8843183 7.9013334 1.0272495 167 - 10000 7.4438347 1.0186098 4.7184985 8.999795 0.99762661 177 -Loop time of 162.325 on 8 procs for 10000 steps with 16271 atoms - -Performance: 5322.658 tau/day, 61.605 timesteps/s, 1.002 Matom-step/s -99.3% CPU use with 8 MPI tasks x no OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 33.647 | 64.106 | 79.639 | 169.5 | 39.49 -Neigh | 0.30808 | 0.44033 | 0.50863 | 9.8 | 0.27 -Comm | 26.611 | 43.438 | 74.998 | 215.7 | 26.76 -Output | 0.0072573 | 0.0087791 | 0.0097993 | 0.9 | 0.01 -Modify | 53.171 | 54.121 | 55.362 | 12.3 | 33.34 -Other | | 0.2104 | | | 0.13 - -Nlocal: 2033.88 ave 2601 max 1413 min -Histogram: 1 2 0 0 0 0 2 1 1 1 -Nghost: 1647.25 ave 1714 max 1617 min -Histogram: 4 0 1 0 0 1 1 0 0 1 -Neighs: 12482.8 ave 17009 max 8679 min -Histogram: 1 1 1 0 1 1 2 0 0 1 - -Total # of neighbors = 99862 -Ave neighs/atom = 6.1374224 -Neighbor list builds = 562 -Dangerous builds = 0 - -#undump 1 -#undump 2 -unfix 3 - -change_box all triclinic -Changing box ... - triclinic box = (-6.7498724 -6.7498724 -6.7498724) to (6.7498724 6.7498724 6.7498724) with tilt (0 0 0) - -fix 2 small srd 20 big 1.0 1.0 49894 search 0.2 cubic warn 0.0001 shift yes 49829 overlap yes collision noslip tstat yes inside ignore - -#dump 1 all custom 500 dump2.atom.srd id type x y z ix iy iz -#dump 2 all custom 500 dump2.tri.srd id type # c_10[1] c_10[2] c_10[3] c_10[4] c_10[5] c_10[6] # c_10[7] c_10[8] c_10[9] - -fix 3 all deform 1 xy erate 0.05 units box remap v - -run 40000 -Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule -SRD info: - SRD/big particles = 14771 1500 - big particle diameter max/min = 2.9202881 0.87320391 - SRD temperature & lamda = 1 0.2 - SRD max distance & max velocity = 0.8 40 - SRD grid counts: 13 13 13 - SRD grid size: request, actual (xyz) = 1, 1.0384419 1.0384419 1.0384419 - SRD per actual grid cell = -2.775698 - SRD viscosity = -12.180602 - big/SRD mass density ratio = -5.5653033 -WARNING: SRD bin size for fix srd differs from user request (../fix_srd.cpp:2805) -WARNING: Fix srd grid size > 1/4 of big particle diameter (../fix_srd.cpp:2826) -WARNING: Fix srd viscosity < 0.0 due to low SRD density (../fix_srd.cpp:2828) - # of rescaled SRD velocities = 1 - ave/max small velocity = 16.14994 40 - ave/max big velocity = 1.6952661 5.2200074 -Neighbor list info ... - update: every = 1 steps, delay = 0 steps, check = yes - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 3.8 - ghost atom cutoff = 3.8 - binsize = 13.499745, bins = 1 1 1 - 1 neighbor lists, perpetual/occasional/extra = 1 0 0 - (1) pair tri/lj, perpetual - attributes: half, newton on - pair build: half/multi/newton/tri - stencil: half/multi/3d/tri - bin: multi -Per MPI rank memory allocation (min/avg/max) = 106.9 | 107.5 | 107.7 Mbytes - Step f_1 c_tsmall Temp Press f_2[9] f_2[4] - 10000 7.4438347 1.0189789 4.7184481 7.9505614 0 0 - 10100 7.0770142 1.0021471 4.4491455 6.606701 1 141 - 10200 6.7628072 1.002308 4.152988 8.5190386 1 125 - 10300 6.5333319 1.0007472 4.1295404 8.2341747 1 109 - 10400 6.3237519 1.0024029 3.8636034 9.4058128 1 95 - 10500 6.6411054 1.0026261 4.2975997 7.6122304 1 82 - 10600 5.7470775 1.0004827 3.7959947 7.3091777 1 67 - 10700 5.9744919 1.0014977 3.6885649 7.5517197 1 59 - 10800 5.8028731 1.0029627 3.7553961 6.2787087 1 49 - 10900 5.3755286 1.0019318 3.5334739 7.1318348 1 41 - 11000 5.3915962 1.001463 3.483172 7.6362496 1 40 - 11100 5.8683672 1.0022459 3.6697589 6.9711866 1 33 - 11200 5.4351801 0.99956703 3.4548447 7.0745257 1 29 - 11300 4.9397513 1.0008287 3.1990325 6.0917337 1 27 - 11400 4.9159845 1.0017862 3.0005677 7.653817 1 26 - 11500 4.9243103 1.0013135 3.1799841 7.744414 1 23 - 11600 5.2036357 1.0017984 3.2963749 7.540477 1 22 - 11700 4.8991892 1.0020757 3.1773032 8.7218471 1 27 - 11800 4.9489399 1.003438 3.1679764 7.1605486 1 26 - 11900 4.82398 1.0019946 3.1939566 7.1397869 1 21 - 12000 4.3531411 1.000532 2.8321416 7.6672501 1 23 - 12100 4.8226081 1.0018898 3.0382137 6.8343432 1 25 - 12200 4.7456418 1.0032116 2.9186038 7.3067818 1 20 - 12300 4.4280468 1.0005857 2.734593 8.0365684 1 22 - 12400 4.7311239 1.0000982 2.8898839 7.9231831 1 22 - 12500 4.7261054 1.0016127 2.9090517 7.6085854 1 24 - 12600 4.7719025 1.0016702 2.9736761 7.6101796 1 26 - 12700 4.386248 1.001394 2.8508378 6.4765102 1 28 - 12800 4.3313538 1.0019737 2.6258221 6.3164681 1 19 - 12900 4.2219861 1.0007469 2.5345699 7.0901077 1 22 - 13000 4.1775643 1.0011891 2.5807017 7.3579938 1 25 - 13100 4.3060837 1.0008671 2.5974066 6.9301328 1 22 - 13200 4.3529062 0.99996469 2.7571632 6.7806287 1 21 - 13300 4.2178709 1.000673 2.7819091 7.6449064 1 18 - 13400 4.2714169 1.0021294 2.7280794 8.0986691 1 18 - 13500 4.3430969 1.0037732 2.6768429 8.1267941 1 18 - 13600 4.3664374 1.0016083 2.6470186 6.2797727 1 20 - 13700 4.4904769 1.0008993 2.7885718 7.7410193 1 22 - 13800 4.2966193 1.001532 2.73862 7.9651302 1 21 - 13900 4.4003185 1.0009984 2.7484129 8.7160439 1 24 - 14000 4.5948292 1.0011748 2.9051777 7.842121 1 22 - 14100 4.6901122 1.0001265 2.9404111 8.9953816 1 20 - 14200 4.8517518 0.99998743 2.9647625 6.6450509 1 22 - 14300 4.889628 1.0018051 3.0891097 7.2671824 1 20 - 14400 4.578862 1.0010629 2.8239776 6.1317183 1 23 - 14500 4.0865406 1.0013917 2.5119661 6.864665 1 19 - 14600 4.30688 1.0009041 2.6817814 6.9007433 1 18 - 14700 4.1295726 1.002342 2.6032093 7.1441648 1 15 - 14800 4.2176021 1.0015157 2.7332903 6.8394683 1 16 - 14900 4.2012664 0.99986345 2.6498409 7.4568241 1 15 - 15000 4.6124269 1.0014751 2.9584178 7.9341875 1 16 - 15100 4.947327 1.0010615 3.0784409 7.6241305 1 21 - 15200 5.253281 1.002095 3.3093754 8.1872718 1 25 - 15300 5.2642369 1.0017799 3.1511136 7.4668389 1 25 - 15400 5.1967916 1.0029407 3.247548 8.0840111 1 23 - 15500 5.7465412 1.001896 3.468834 9.5990471 1 15 - 15600 6.2245772 1.0021086 3.6127689 7.8242016 1 19 - 15700 5.5626191 0.99984979 3.3893723 7.8124588 1 20 - 15800 5.5945727 1.0010291 3.3442448 7.0116922 1 17 - 15900 5.4450219 1.0006248 3.3132381 8.4803413 1 15 - 16000 5.7800459 1.001449 3.5002534 8.7989456 1 19 - 16100 6.1168718 1.0008109 3.8081142 8.0119729 1 18 - 16200 5.4901649 1.0020643 3.3673653 7.3483134 1 17 - 16300 5.4051694 1.0015652 3.3560012 7.4641983 1 19 - 16400 5.4237612 1.0012686 3.3816406 7.3845086 1 14 - 16500 5.1935593 1.001754 3.3340381 7.8607712 1 16 - 16600 5.539343 1.0021073 3.4164309 8.1541097 1 12 - 16700 5.8922923 1.0013792 3.553426 7.5220576 1 14 - 16800 5.956937 1.0005959 3.7630589 8.7417987 1 13 - 16900 5.469721 1.0016219 3.5531223 8.6721994 1 13 - 17000 5.3110154 1.001142 3.4167244 7.4644182 1 15 - 17100 5.9226035 0.99918238 4.0244287 6.5172028 1 16 - 17200 5.4897042 0.99981565 3.4350691 5.6840394 1 20 - 17300 5.4302636 1.0021571 3.421473 6.4317025 1 21 - 17400 5.5559131 1.0013807 3.4951403 6.874191 1 24 - 17500 5.4068006 1.0010448 3.4506835 7.7069504 1 22 - 17600 4.9283792 1.0007628 3.1736308 7.3098058 1 20 - 17700 4.9319722 0.99935896 3.0956257 8.2120111 1 15 - 17800 4.6842391 1.00037 2.9602433 7.4116352 1 17 - 17900 4.7714682 1.0009332 2.9666778 7.5925131 1 17 - 18000 4.7233188 1.0035687 3.0991778 7.1636357 1 10 - 18100 4.6487958 1.0020255 3.10781 6.8468658 1 12 - 18200 4.6284129 1.0012617 3.089724 6.3082275 1 13 - 18300 4.7136404 0.99962415 3.1261978 7.3359556 1 15 - 18400 5.0367681 1.0011016 3.2413493 8.3910633 1 14 - 18500 4.9658104 1.0025407 3.2420827 7.4701216 1 17 - 18600 4.6100059 1.0014508 3.0216884 6.553483 1 17 - 18700 4.3246452 1.0016721 2.7810363 6.7450293 1 19 - 18800 4.9415788 1.0012406 3.1661907 7.5544034 1 18 - 18900 5.3930915 1.000138 3.2557456 7.350955 1 21 - 19000 5.1938599 1.0007364 3.2398733 6.5397956 1 22 - 19100 5.4433048 1.0019191 3.2699245 8.3625772 1 22 - 19200 6.1303261 1.0004005 3.7823203 8.0537369 1 22 - 19300 5.5762518 1.0008117 3.5689121 8.3714373 1 22 - 19400 5.1316743 0.9999834 3.099381 7.405287 1 23 - 19500 5.2064799 1.0012007 3.3059455 7.3499127 1 25 - 19600 5.1650099 1.0023314 3.3759492 7.3637616 1 21 - 19700 5.8316278 1.0023317 3.601564 7.153887 1 19 - 19800 5.6435147 1.0010657 3.4967581 6.8899334 1 21 - 19900 5.4071193 0.99961357 3.4977894 6.1068438 1 20 - 20000 5.5058495 1.000982 3.5185057 8.5657603 1 19 - 20100 5.6551271 1.0025852 3.5672369 7.8242273 1 20 - 20200 5.7196886 1.002283 3.6010925 7.1449072 1 22 - 20300 5.5593553 1.0009987 3.4363398 8.4141755 1 21 - 20400 5.5550247 1.001081 3.3950874 8.0222131 1 20 - 20500 5.4510415 0.99997273 3.5505093 7.5243655 1 18 - 20600 5.8014064 1.0007611 3.8084579 7.6583499 1 18 - 20700 5.7337315 1.0020309 3.7973684 8.7376766 1 17 - 20800 5.2512898 0.99901254 3.5027763 7.8902791 1 14 - 20900 5.3245034 1.0014504 3.3354615 6.7030716 1 17 - 21000 5.2071731 1.0020459 3.3881369 5.8616999 1 20 - 21100 5.3187535 1.0010762 3.2845672 8.1422146 1 21 - 21200 5.5298545 0.99942313 3.4393978 7.1183144 1 22 - 21300 5.8430744 1.0008652 3.719408 7.8522038 1 20 - 21400 5.8190457 1.0017046 3.5624252 7.8150165 1 20 - 21500 6.004585 1.0035276 3.9161914 7.7719377 1 21 - 21600 6.7202635 0.99970072 3.9642141 8.7934294 1 18 - 21700 6.8590346 1.0007883 4.4285217 8.9014638 1 20 - 21800 6.627638 1.0012117 4.1154082 8.3153026 1 22 - 21900 7.8281047 1.0008299 4.8842343 8.4016227 1 20 - 22000 7.200038 1.0014681 4.4141419 9.4091956 1 18 - 22100 7.7442011 1.0018051 4.7850371 8.9885489 1 15 - 22200 7.4770203 1.0033558 4.7512643 8.4898148 1 17 - 22300 8.1080801 1.0000019 5.2725185 9.2314625 1 14 - 22400 7.8068311 1.0020672 4.9055683 8.4064748 1 12 - 22500 7.4594636 1.0008427 4.6586396 8.5102986 1 11 - 22600 6.9380609 1.0024634 4.2435619 10.395118 1 16 - 22700 6.9338066 1.001056 4.3436179 7.9126284 1 18 - 22800 6.8049493 1.0020052 4.1443407 7.8228868 1 18 - 22900 6.2280158 1.0021474 3.7695343 7.3179647 1 20 - 23000 5.649403 1.0017128 3.5941976 7.2964709 1 19 - 23100 5.3203116 1.001912 3.3807399 6.6454551 1 15 - 23200 5.8172882 1.0005742 3.6625896 8.4256312 1 15 - 23300 5.9647182 1.0015466 3.9106019 8.3303303 1 14 - 23400 5.9784055 1.0034542 3.7229235 7.7934273 1 14 - 23500 5.377627 1.00192 3.5481778 6.8195124 1 17 - 23600 5.4807136 1.0014662 3.563123 7.6356376 1 18 - 23700 5.8896329 1.0013553 3.7990694 8.5513408 1 13 - 23800 6.3463707 0.9999403 3.9609397 8.5741923 1 11 - 23900 6.656669 1.0014998 4.1993183 9.0862996 1 13 - 24000 7.583723 1.0025057 4.7628652 7.5007245 1 20 - 24100 6.9868359 1.0014089 4.4369841 7.692833 1 25 - 24200 7.1966062 1.0013149 4.4384528 9.5264821 1 18 - 24300 6.7765706 1.0007065 4.3500477 9.4974154 1 16 - 24400 7.0853466 1.0013246 4.409163 9.2215823 1 17 - 24500 6.9603823 1.0004247 4.4866051 7.7870058 1 20 - 24600 6.9208291 0.99953329 4.2298144 6.5732392 1 21 - 24700 6.5005518 1.0026848 4.0003505 7.8094715 1 22 - 24800 5.8421948 1.0012055 3.6686768 7.6078157 1 26 - 24900 5.8410604 1.0023428 3.746177 6.8971309 1 22 - 25000 5.8728511 1.0001747 3.7170134 7.4456816 1 19 - 25100 6.0217168 1.000624 3.7756108 6.6542452 1 20 - 25200 6.1939015 1.0017861 3.8943084 9.395821 1 25 - 25300 6.161998 1.0010373 3.9255122 6.2228884 1 28 - 25400 5.5850406 1.0018505 3.5129832 7.2551309 1 24 - 25500 6.0286276 1.0009028 3.8580887 6.8065265 1 24 - 25600 5.6262228 1.0005097 3.4574446 7.5061246 1 21 - 25700 6.1348187 1.0009828 3.8073512 7.4818375 1 17 - 25800 6.09781 1.0026426 3.9585383 9.0915939 1 21 - 25900 6.2673667 1.0002269 3.8182813 9.2134822 1 21 - 26000 6.6001776 1.0020444 4.041386 8.0403555 1 18 - 26100 6.3063025 1.0016633 3.8649839 8.8149734 1 19 - 26200 6.0046983 1.002332 3.5380766 8.6145656 1 17 - 26300 5.9627788 1.0005401 3.56864 6.7821213 1 15 - 26400 5.0547314 0.9998295 3.2106781 9.2935351 1 15 - 26500 5.256781 1.0013131 3.2946631 8.8590275 1 15 - 26600 5.6250355 1.0023929 3.5243033 8.8985058 1 17 - 26700 6.0197165 1.0018323 3.7973947 7.3093402 1 17 - 26800 5.4556541 1.0015309 3.4295107 8.2342049 1 18 - 26900 5.420428 1.0024996 3.4374201 7.1444636 1 16 - 27000 6.165624 1.0019174 3.8726016 8.6588275 1 20 - 27100 6.7131697 1.0006541 4.266264 8.7063389 1 24 - 27200 6.4855163 1.0016139 4.2029778 7.667611 1 29 - 27300 6.0525608 1.000478 3.9169723 7.4515279 1 25 - 27400 6.1426194 1.0014522 3.9176108 6.8689671 1 24 - 27500 6.5981349 1.0001143 4.0620686 8.6804552 1 27 - 27600 6.7827138 1.0016694 4.2764286 9.3912843 1 21 - 27700 6.6368902 1.0025149 4.1452128 9.1814523 1 24 - 27800 6.9791025 1.0019486 4.3989933 7.9446882 1 24 - 27900 6.617142 1.0015736 4.360571 9.3732108 1 26 - 28000 7.2818263 1.0014101 4.6041512 8.2398587 1 28 - 28100 7.2543709 1.0007625 4.5724787 7.7373488 1 22 - 28200 7.0631847 1.0023922 4.4021705 8.3290554 1 29 - 28300 7.2999952 1.0012593 4.4655563 8.612666 1 27 - 28400 7.4124538 1.0014043 4.5011335 8.379391 1 29 - 28500 7.0350937 1.0011392 4.3528091 7.8167375 1 24 - 28600 7.9659642 1.0031684 4.8732467 8.0661929 1 30 - 28700 7.2865919 1.0010958 4.6650146 8.0325989 1 32 - 28800 7.7039529 1.0027912 4.8299888 9.5471747 1 30 - 28900 8.3288847 1.0012438 5.0785288 8.8964877 1 31 - 29000 7.9348665 1.0021794 4.9393968 9.5531767 1 31 - 29100 8.2473389 1.0013795 4.9890359 9.7697184 1 29 - 29200 8.6383362 1.0018356 4.9856954 7.6402719 1 25 - 29300 8.2504592 1.0011048 4.9631793 7.9466724 1 24 - 29400 8.0502922 1.0010516 5.2521065 8.4515028 1 26 - 29500 7.9475896 1.0012951 4.8584644 9.1225463 1 19 - 29600 8.5641641 1.0016228 5.4361335 9.2045399 1 23 - 29700 8.9932021 1.0011848 5.5727205 8.6045729 1 23 - 29800 8.0320178 1.0019073 5.2837013 8.9335413 1 22 - 29900 8.2676522 1.0012734 5.2213798 8.8966896 1 24 - 30000 9.1848984 1.001747 5.9147628 12.096129 1 27 - 30100 10.184519 0.99977427 6.4260136 11.140491 1 27 - 30200 9.271472 1.0023983 6.0252189 9.6954338 1 30 - 30300 9.0751572 1.000851 5.6010295 9.734426 1 28 - 30400 9.4581261 1.0018449 5.6987258 9.70456 1 34 - 30500 9.1574751 0.99944001 5.582217 9.300318 1 27 - 30600 8.619312 1.001388 5.3503985 8.2759155 1 26 - 30700 7.9370031 1.0026674 5.0702831 8.5368014 1 28 - 30800 7.9221619 1.0019077 5.1278637 11.046922 1 26 - 30900 9.9722884 1.0025903 6.4055506 10.167311 1 25 - 31000 8.8648667 0.99962676 5.4777514 10.142102 1 21 - 31100 8.576344 1.000906 5.3216342 8.7984921 1 18 - 31200 7.8480974 1.0010341 4.9584917 9.0696437 1 16 - 31300 8.3536183 1.0005758 5.208516 9.7971514 1 15 - 31400 8.5301933 1.0007603 5.2241536 9.0257241 1 17 - 31500 8.5196226 1.0018215 5.0576064 8.8847294 1 19 - 31600 8.1470823 1.0023147 4.9182956 9.0205413 1 20 - 31700 8.1475888 1.0005764 5.1814113 9.0603162 1 16 - 31800 7.8629717 1.0014194 4.9221218 9.366291 1 16 - 31900 7.7206559 1.0021082 4.9167636 7.4136735 1 16 - 32000 7.5152809 1.0004752 4.6330638 8.830959 1 16 - 32100 8.2693974 1.0011751 4.9094804 9.427636 1 13 - 32200 8.3067661 0.9997006 4.9036865 9.0374633 1 17 - 32300 7.2068514 1.0007866 4.3580755 8.6445065 1 17 - 32400 6.885063 1.0011887 4.1528011 8.1199454 1 16 - 32500 6.9147014 1.0020825 4.160405 7.5398034 1 19 - 32600 6.8809668 1.000971 4.3312782 8.2157688 1 16 - 32700 6.4818892 1.0000885 3.9433899 7.309605 1 22 - 32800 6.6875555 1.0018674 4.1017504 7.2327183 1 22 - 32900 7.6118502 0.99975736 4.4498951 8.5072395 1 19 - 33000 7.7576909 1.0022061 4.7239551 9.2132467 1 22 - 33100 7.8616235 1.000482 5.0031322 9.349805 1 20 - 33200 8.2620563 1.0015059 5.2482188 10.286446 1 17 - 33300 8.0217099 1.0015466 5.1166876 9.1381844 1 20 - 33400 7.6565746 1.0024855 4.7594208 9.2646824 1 22 - 33500 7.9633887 1.0010334 4.6754116 9.1085184 1 23 - 33600 7.9566834 1.0024542 4.6712679 9.2046594 1 25 - 33700 8.2639384 1.0003021 5.1326892 8.0930215 1 24 - 33800 8.5648917 1.0000947 5.2099387 8.8127486 1 21 - 33900 8.3593557 1.0002488 5.1291354 8.5938391 1 25 - 34000 8.1922068 1.0030011 5.1441189 7.1529563 1 24 - 34100 8.4260308 1.0004639 5.5876122 9.0450303 1 28 - 34200 8.3014654 1.0002204 5.1964772 8.4920822 1 33 - 34300 7.4736545 1.0010306 4.7932244 7.8442244 1 30 - 34400 7.0023126 1.0024002 4.5665168 8.4702188 1 29 - 34500 7.3797703 1.000813 4.7224014 8.4098954 1 30 - 34600 7.7158761 0.99973161 4.7441628 8.5818592 1 29 - 34700 7.6135895 1.0015768 4.6612844 7.2195952 1 28 - 34800 7.0458078 0.99992638 4.2805357 7.4162305 1 32 - 34900 7.6190708 1.0007146 4.8064968 8.2709405 1 27 - 35000 7.4614294 1.0006051 4.7807207 7.7137359 1 28 - 35100 7.7008336 1.0008263 4.6823621 7.0208513 1 26 - 35200 8.1510766 1.000271 5.1781834 7.3231692 1 24 - 35300 7.5106275 1.0010438 4.6988185 8.9418343 1 25 - 35400 7.8116652 1.0009688 4.8622216 7.4624002 1 17 - 35500 7.2159785 1.0027484 4.543984 8.3177043 1 21 - 35600 7.6978875 1.0004834 4.7021203 8.3706905 1 20 - 35700 7.7827655 1.0019919 4.775879 8.6083292 1 15 - 35800 7.8433537 1.001844 4.7506574 7.3250009 1 15 - 35900 7.9456497 1.0004336 4.7925775 7.9824359 1 18 - 36000 8.1044513 1.0022261 5.1213755 9.211699 1 16 - 36100 7.6657532 1.0025661 4.751804 8.9770412 1 19 - 36200 7.909323 1.0035462 4.8435293 10.232493 1 21 - 36300 8.4188244 1.0016775 5.4337725 9.2060079 1 24 - 36400 8.7352689 1.0011274 5.6313351 8.6202832 1 24 - 36500 8.3459273 1.0005659 5.187336 6.9333716 1 21 - 36600 7.7118105 1.0018769 4.9293347 8.2789615 1 14 - 36700 7.8069879 1.0014021 4.7782709 8.4841233 1 15 - 36800 7.862085 1.0005342 4.8680692 8.1055023 1 16 - 36900 7.9469362 1.0027815 4.9339095 9.157722 1 16 - 37000 7.9085375 1.0024851 5.0921374 8.9374239 1 16 - 37100 8.9464869 1.0005734 5.6837772 8.806998 1 16 - 37200 8.1482632 1.0021175 5.1266453 8.5772094 1 18 - 37300 7.7958072 1.0026336 4.788431 8.3233372 1 19 - 37400 7.3647655 1.0015482 4.4786134 9.6606112 1 23 - 37500 7.3071882 1.0003912 4.681549 8.6319438 1 17 - 37600 7.8672509 1.0000478 4.7981944 8.3051478 1 14 - 37700 7.9306696 0.99923102 4.9316544 9.3672856 1 15 - 37800 7.7397949 0.99948557 5.1168552 8.5978047 1 17 - 37900 7.9121039 1.0020122 4.9866234 7.640888 1 14 - 38000 7.433451 1.0007901 4.6254894 8.0853539 1 14 - 38100 7.4636908 1.0021552 4.8472833 8.1975615 1 10 - 38200 7.4453077 1.0010305 4.6910943 7.8192603 1 13 - 38300 7.0488536 1.0012587 4.5490462 8.190036 1 16 - 38400 8.0686748 1.0016782 5.0747029 7.7242015 1 15 - 38500 7.9575875 1.0007137 4.8361776 8.05268 1 15 - 38600 7.6690498 1.0027522 4.8823286 9.1926516 1 20 - 38700 7.1567 1.002374 4.5600354 10.098089 1 19 - 38800 6.9100518 1.0008695 4.4101446 7.8832032 1 19 - 38900 6.8021882 1.0017647 4.1844125 8.1858761 1 21 - 39000 8.3996464 1.0010263 4.8183813 8.0997387 1 16 - 39100 8.4533834 1.0021643 5.074254 11.291904 1 19 - 39200 8.2406701 1.002062 5.0117425 8.778159 1 24 - 39300 8.3134114 1.0008218 5.0067136 7.9871787 1 22 - 39400 7.4307571 1.0014205 4.5858283 8.8596594 1 25 - 39500 7.1146821 1.0016367 4.5021057 7.4890018 1 22 - 39600 8.0048978 0.99992107 4.9235747 7.8770845 1 24 - 39700 8.070853 1.0029024 5.0842957 9.020664 1 21 - 39800 7.6939108 1.0012543 4.8986595 8.3306129 1 20 - 39900 7.2915444 1.00267 4.5038291 8.3844384 1 20 - 40000 7.3023994 1.0020441 4.4960911 8.1023709 1 18 - 40100 7.0221648 1.0033695 4.6374149 8.3756822 1 24 - 40200 7.4114756 1.0019246 4.6733475 7.6547258 1 23 - 40300 7.5323108 1.0005472 4.8284493 8.2820085 1 26 - 40400 7.3890772 1.0010491 4.6599273 8.9203575 1 19 - 40500 7.5786764 1.0016114 4.8166885 8.6760107 1 25 - 40600 8.165763 1.0006961 5.1488995 7.9321524 1 22 - 40700 8.1277597 0.99933464 5.0441567 10.069551 1 16 - 40800 8.1050904 1.0024705 5.4408599 8.3244459 1 21 - 40900 7.805318 1.0022992 4.9965408 9.7193723 1 21 - 41000 9.0130932 1.0006842 5.7931112 6.1646073 1 20 - 41100 8.0387975 1.0017359 5.3355655 9.6123191 1 21 - 41200 8.4484723 1.0014151 5.4461007 8.5146504 1 27 - 41300 8.6181909 1.0007562 5.2963876 9.1122306 1 30 - 41400 9.6762899 1.0010931 5.950456 9.2851025 1 25 - 41500 9.9414226 1.0016186 6.1433384 10.741453 1 24 - 41600 9.3348435 1.0003483 5.9291766 11.460717 1 20 - 41700 9.6125587 1.0013661 5.8530052 9.2105722 1 19 - 41800 11.383056 1.0032034 7.1988684 10.312945 1 22 - 41900 10.884524 1.0034888 6.9126707 10.775457 1 20 - 42000 11.071218 1.0026753 7.0004189 10.740627 1 20 - 42100 11.054304 1.0008347 6.9602414 8.9885498 1 22 - 42200 22.478691 1.0020466 14.997099 12.72513 1 19 - 42300 18.303508 1.0027626 11.336523 12.638769 1 18 - 42400 15.998712 1.0030312 9.4092725 11.070501 1 24 - 42500 15.034488 1.0024472 9.3543751 11.48052 1 28 - 42600 14.538257 1.0033153 9.2523745 10.909576 1 27 - 42700 13.986613 1.001458 8.5544184 10.765136 1 29 - 42800 13.240256 1.0027899 8.2014429 10.506497 1 32 - 42900 12.784336 1.0001406 8.0823431 12.258209 1 33 - 43000 13.374145 1.0012996 8.4207155 10.32817 1 31 - 43100 13.142334 1.0022503 8.5908808 10.152205 1 32 - 43200 12.669284 1.0018944 7.8511966 10.580104 1 32 - 43300 13.155032 1.001144 8.0337768 10.6652 1 39 - 43400 12.155928 1.0019472 7.5886584 11.234772 1 35 - 43500 12.385603 1.0007639 7.8865245 9.3868914 1 32 - 43600 12.236179 1.0027456 7.7521353 10.456701 1 42 - 43700 11.49535 1.0008758 7.3633144 8.8490079 1 40 - 43800 11.469157 1.0015845 7.0035577 10.594522 1 41 - 43900 11.228266 1.0013014 7.0137223 8.0653711 1 38 - 44000 10.56742 1.0016631 6.6908938 8.1094154 1 35 - 44100 9.8964699 1.0008351 6.3550438 8.6578181 1 36 - 44200 9.041539 1.0019541 5.6721401 8.6518043 1 38 - 44300 9.0767434 1.0034191 5.7446596 8.3838528 1 38 - 44400 9.2299608 1.0019526 5.7117964 8.3106491 1 37 - 44500 9.458981 1.0030409 5.7612138 7.7679755 1 37 - 44600 8.9611997 1.0014848 5.6490756 6.9224078 1 37 - 44700 8.0853184 1.0018894 5.2288749 8.0910912 1 32 - 44800 7.9999755 1.0015853 4.8088312 7.1854304 1 30 - 44900 7.6598023 1.0009751 4.6690664 7.1999858 1 28 - 45000 7.4939315 1.0010307 4.8119666 7.9615769 1 26 - 45100 7.4690079 0.99913423 4.9704428 7.6026835 1 32 - 45200 7.7001199 1.001626 4.9315953 7.4926686 1 25 - 45300 7.8794405 1.0011648 4.8624857 8.0804457 1 26 - 45400 7.493909 1.0016257 4.7631808 8.0330626 1 26 - 45500 7.5963141 1.0005825 4.7220659 7.0971298 1 23 - 45600 7.9028612 1.0017008 4.9561022 8.440428 1 23 - 45700 7.2285584 1.0006033 4.5521456 9.385579 1 23 - 45800 7.5687284 1.0024318 4.8557498 8.3052658 1 23 - 45900 7.8938604 1.0013937 5.1393944 5.5323667 1 26 - 46000 8.318466 1.0020803 5.4761811 8.2227801 1 25 - 46100 7.9169512 1.0024598 5.0406355 8.64365 1 27 - 46200 7.5535458 1.0016318 4.8010133 9.370726 1 26 - 46300 7.8926896 1.0001525 5.18463 7.9830196 1 27 - 46400 7.487145 1.002671 4.7718312 8.300134 1 29 - 46500 7.3564658 1.0006114 4.6762189 7.34947 1 26 - 46600 7.2261291 1.0005569 4.4751221 6.5847138 1 27 - 46700 7.2943203 1.0020164 4.3335327 7.7296507 1 25 - 46800 8.5849411 1.0014634 5.4501531 9.0933014 1 25 - 46900 10.176752 1.0023799 6.0456779 9.4050423 1 16 - 47000 9.1913098 1.0029076 5.7577256 9.1826215 1 22 - 47100 9.5479771 1.0022102 6.1100973 8.9440056 1 28 - 47200 9.9944172 1.0004924 6.3649417 9.1507264 1 25 - 47300 9.3543283 1.0013246 6.0873147 10.41657 1 24 - 47400 8.594101 1.0020068 5.6864295 9.2388304 1 24 - 47500 9.3191964 1.002411 6.0537511 9.3506828 1 23 - 47600 8.1615734 1.001364 5.3757905 10.303962 1 30 - 47700 8.3615046 1.0003075 5.2727936 9.3162209 1 32 - 47800 8.3566467 1.0026031 5.4379524 7.7644422 1 33 - 47900 8.4062556 1.0006471 5.3098736 8.0181121 1 33 - 48000 8.2233307 1.0012304 4.9650027 9.2644288 1 34 - 48100 8.4495256 1.000088 4.9940422 10.01023 1 27 - 48200 8.8068097 1.0014275 5.4732649 8.410093 1 31 - 48300 8.0008187 1.0017459 4.7732764 9.25726 1 27 - 48400 7.7242529 1.0026909 4.9084505 8.7147295 1 30 - 48500 8.3752816 1.001333 5.1071228 8.2267308 1 32 - 48600 9.0777805 1.0019328 5.7331841 9.6679383 1 29 - 48700 9.3623061 1.0001767 5.7117062 8.396895 1 25 - 48800 8.1186637 1.0013185 5.2697427 8.6058372 1 27 - 48900 7.3685497 1.0007173 4.6097553 7.8047228 1 24 - 49000 7.1661421 1.0023152 4.5389038 8.8759552 1 22 - 49100 6.9857144 1.0016394 4.6489319 8.2022359 1 24 - 49200 6.7160336 1.0018413 4.2488082 8.3393245 1 25 - 49300 7.9703755 1.0010628 5.2328567 7.968278 1 28 - 49400 8.2628465 1.0010877 5.2292977 8.0196533 1 27 - 49500 8.1436558 1.0015175 5.0344712 8.0712037 1 30 - 49600 8.5182498 1.0021589 5.1029028 8.6869789 1 28 - 49700 8.3604444 1.0015016 5.0333696 9.4861656 1 25 - 49800 7.336335 1.0020055 4.6365173 8.7210022 1 30 - 49900 7.432996 1.0016415 4.7090587 8.7033033 1 29 - 50000 7.4937053 1.001014 4.7212573 9.0890363 1 29 -Loop time of 999.576 on 8 procs for 40000 steps with 16271 atoms - -Performance: 3457.466 tau/day, 40.017 timesteps/s, 651.116 katom-step/s -99.3% CPU use with 8 MPI tasks x no OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 293.48 | 403.7 | 545.29 | 357.5 | 40.39 -Neigh | 2.4176 | 3.2721 | 3.8303 | 25.2 | 0.33 -Comm | 163.58 | 305.88 | 419.83 | 416.7 | 30.60 -Output | 0.032483 | 0.034794 | 0.040514 | 1.2 | 0.00 -Modify | 281.15 | 285.67 | 293.8 | 24.3 | 28.58 -Other | | 1.023 | | | 0.10 - -Nlocal: 2033.88 ave 2657 max 1198 min -Histogram: 2 0 0 0 0 2 1 0 1 2 -Nghost: 1628.12 ave 1719 max 1569 min -Histogram: 2 0 1 1 2 1 0 0 0 1 -Neighs: 13566 ave 18212 max 8488 min -Histogram: 1 0 0 1 2 1 2 0 0 1 - -Total # of neighbors = 108528 -Ave neighs/atom = 6.6700264 -Neighbor list builds = 2447 -Dangerous builds = 2 -Total wall time: 0:19:22 diff --git a/examples/ASPHERE/tri/log.1Feb24.tri.srd.g++.1 b/examples/ASPHERE/tri/log.1Feb24.tri.srd.g++.1 new file mode 100644 index 0000000000..2686070832 --- /dev/null +++ b/examples/ASPHERE/tri/log.1Feb24.tri.srd.g++.1 @@ -0,0 +1,343 @@ +LAMMPS (21 Nov 2023 - Development - patch_21Nov2023-665-g17f869bf5e) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# Aspherical shear demo - 3d triangle boxes, solvated by SRD particles + +units lj +atom_style tri +atom_modify first big map yes + +read_data data.tri.srd +Reading data file ... + orthogonal box = (-8.4373405 -8.4373405 -8.4373405) to (8.4373405 8.4373405 8.4373405) + 1 by 1 by 1 MPI processor grid + reading atoms ... + 1500 atoms + 1500 triangles + read_data CPU = 0.013 seconds + +# add small particles as hi density lattice + +lattice sc 0.4 +Lattice spacing in x,y,z = 1.3572088 1.3572088 1.3572088 +region box block INF INF INF INF INF INF +lattice sc 20.0 +Lattice spacing in x,y,z = 0.36840315 0.36840315 0.36840315 +create_atoms 2 region box +Created 91125 atoms + using lattice units in orthogonal box = (-8.4373405 -8.4373405 -8.4373405) to (8.4373405 8.4373405 8.4373405) + create_atoms CPU = 0.014 seconds + +group big type 1 +1500 atoms in group big +group small type 2 +91125 atoms in group small +set group small mass 0.01 +Setting atom values ... + 91125 settings made for mass + +# delete overlaps +# must set 1-2 cutoff to non-zero value + +pair_style lj/cut 1.5 +pair_coeff 1 1 1.0 1.0 +pair_coeff 2 2 0.0 1.0 0.0 +pair_coeff 1 2 0.0 1.0 + +delete_atoms overlap 1.5 small big +System init for delete_atoms ... +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 1.8 + ghost atom cutoff = 1.8 + binsize = 0.9, bins = 19 19 19 + 2 neighbor lists, perpetual/occasional/extra = 1 1 0 + (1) command delete_atoms, occasional + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard + (2) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/3d + bin: standard +WARNING: Delete_atoms cutoff > minimum neighbor cutoff (src/delete_atoms.cpp:312) +Deleted 76354 atoms, new total = 16271 + +# SRD run + +reset_timestep 0 + +velocity small create 1.44 87287 loop geom + +neighbor 0.3 multi +neigh_modify delay 0 every 1 check yes +neigh_modify exclude molecule/intra big include big + +comm_modify mode multi group big vel yes +neigh_modify include big + +# no pairwise interactions with small particles + +pair_style tri/lj 3.5 +pair_coeff 1 1 0.1 1.0 +pair_coeff 2 2 0.0 1.0 0.0 +pair_coeff 1 2 0.0 1.0 0.0 + +# use fix SRD to push small particles out from inside big ones +# if comment out, big particles won't see SRD particles + +timestep 0.001 + +fix 1 big rigid/small molecule #langevin 1.0 1.0 0.1 12398 + create bodies CPU = 0.000 seconds + 125 rigid bodies with 1500 atoms + 1.8601881 = max distance from body owner to body atom +fix 2 small srd 20 big 1.0 1.0 49894 search 0.2 cubic warn 0.0001 shift yes 49829 overlap yes collision noslip inside ignore + +fix 3 all deform 1 x scale 0.8 y scale 0.8 z scale 0.8 + +# diagnostics + +compute tsmall small temp/deform +compute tbig big temp +variable pebig equal pe*atoms/count(big) +variable ebig equal etotal*atoms/count(big) + +compute_modify tbig extra/dof -4500 + +compute 1 big erotate/asphere +compute 2 all ke +compute 3 all pe +variable toteng equal (c_1+c_2+c_3)/atoms + +thermo 100 +thermo_style custom step f_1 c_tsmall temp press f_2[9] f_2[4] +thermo_modify temp tbig +WARNING: Temperature for thermo pressure is not for group all (src/thermo.cpp:530) + +compute 10 all property/atom corner1x corner1y corner1z corner2x corner2y corner2z corner3x corner3y corner3z + +#dump 1 all custom 500 dump1.atom.srd id type x y z ix iy iz +#dump 2 all custom 500 dump1.tri.srd id type # c_10[1] c_10[2] c_10[3] c_10[4] c_10[5] c_10[6] # c_10[7] c_10[8] c_10[9] + +run 1000 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- neighbor multi command: doi:10.1016/j.cpc.2008.03.005, doi:10.1007/s40571-020-00361-2 + +@Article{Intveld08, + author = {in 't Veld, P. J. and S. J.~Plimpton and G. S. Grest}, + title = {Accurate and Efficient Methods for Modeling Colloidal + Mixtures in an Explicit Solvent using Molecular Dynamics}, + journal = {Comput.\ Phys.\ Commut.}, + year = 2008, + volume = 179, + pages = {320--329} +} + +@article{Shire2020, + author = {Shire, Tom and Hanley, Kevin J. and Stratford, Kevin}, + title = {{DEM} Simulations of Polydisperse Media: Efficient Contact + Detection Applied to Investigate the Quasi-Static Limit}, + journal = {Computational Particle Mechanics}, + year = {2020} +@article{Monti2022, + author = {Monti, Joseph M. and Clemmer, Joel T. and Srivastava, + Ishan and Silbert, Leonardo E. and Grest, Gary S. + and Lechman, Jeremy B.}, + title = {Large-scale frictionless jamming with power-law particle + size distributions}, + journal = {Phys. Rev. E}, + volume = {106} + issue = {3} + year = {2022} +} + +- fix srd command: doi:10.1063/1.3419070 + +@Article{Petersen10, + author = {M. K. Petersen and J. B. Lechman and S. J. Plimpton and + G. S. Grest and in 't Veld, P. J. and P. R. Schunk}, + title = {Mesoscale Hydrodynamics via Stochastic Rotation + Dynamics: Comparison with {L}ennard-{J}ones Fluid}, + journal = {J.~Chem.\ Phys.}, + year = 2010, + volume = 132, + pages = 174106 +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +WARNING: Using compute temp/deform with inconsistent fix deform remap option (src/compute_temp_deform.cpp:71) +WARNING: Using fix srd with box deformation but no SRD thermostat (src/SRD/fix_srd.cpp:405) +SRD info: + SRD/big particles = 14771 1500 + big particle diameter max/min = 2.9202881 0.87320391 + SRD temperature & lamda = 1 0.2 + SRD max distance & max velocity = 0.8 40 + SRD grid counts: 17 17 17 + SRD grid size: request, actual (xyz) = 1, 0.99262829 0.99262829 0.99262829 + SRD per actual grid cell = -3.9971745 + SRD viscosity = -34.162587 + big/SRD mass density ratio = -3.3753691 +WARNING: SRD bin size for fix srd differs from user request (src/SRD/fix_srd.cpp:2809) +WARNING: Fix srd grid size > 1/4 of big particle diameter (src/SRD/fix_srd.cpp:2830) +WARNING: Fix srd viscosity < 0.0 due to low SRD density (src/SRD/fix_srd.cpp:2832) + # of rescaled SRD velocities = 0 + ave/max small velocity = 19.970837 35.150443 + ave/max big velocity = 0 0 +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 3.8 + ghost atom cutoff = 3.8 + binsize = 16.874681, bins = 1 1 1 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair tri/lj, perpetual + attributes: half, newton on + pair build: half/multi/atomonly/newton + stencil: half/multi/3d + bin: multi +Per MPI rank memory allocation (min/avg/max) = 381.8 | 381.8 | 381.8 Mbytes + Step f_1 c_tsmall Temp Press f_2[9] f_2[4] + 0 0 1.4502537 0 -0.15976045 0 0 + 100 0.41802172 1.152223 0.27557714 1.0421065 1.1470081 283 + 200 0.79710339 1.0669332 0.5813323 0.97699684 1.0361619 534 + 300 1.3739181 1.0275476 1.0869716 0.81001536 1.0211312 658 + 400 1.9355117 1.0155457 1.5813236 1.7798798 0.99354559 831 + 500 2.8557382 1.0005021 2.267698 3.3903849 0.98597972 927 + 600 4.7851916 1.0156689 3.730334 2.838776 0.99140534 1053 + 700 5.3647697 1.0176657 3.9593121 5.1189107 0.9972029 1218 + 800 8.23688 1.0268086 5.899689 6.8199153 0.99310516 1349 + 900 9.9330758 1.0356047 7.0260595 7.2596589 0.98360014 1607 + 1000 9.8719995 1.043178 6.9903792 10.05101 1.0045416 1805 +Loop time of 79.2664 on 1 procs for 1000 steps with 16271 atoms + +Performance: 1089.995 tau/day, 12.616 timesteps/s, 205.270 katom-step/s +99.4% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 57.961 | 57.961 | 57.961 | 0.0 | 73.12 +Neigh | 0.34589 | 0.34589 | 0.34589 | 0.0 | 0.44 +Comm | 0.28615 | 0.28615 | 0.28615 | 0.0 | 0.36 +Output | 0.0022784 | 0.0022784 | 0.0022784 | 0.0 | 0.00 +Modify | 20.644 | 20.644 | 20.644 | 0.0 | 26.04 +Other | | 0.02724 | | | 0.03 + +Nlocal: 16271 ave 16271 max 16271 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 4612 ave 4612 max 4612 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 99463 ave 99463 max 99463 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 99463 +Ave neighs/atom = 6.1129003 +Neighbor list builds = 72 +Dangerous builds = 0 + +#undump 1 +#undump 2 +unfix 3 + +change_box all triclinic +Changing box ... + triclinic box = (-6.7498724 -6.7498724 -6.7498724) to (6.7498724 6.7498724 6.7498724) with tilt (0 0 0) + +fix 2 small srd 20 big 1.0 1.0 49894 search 0.2 cubic warn 0.0001 shift yes 49829 overlap yes collision noslip tstat yes inside ignore + +#dump 1 all custom 500 dump2.atom.srd id type x y z ix iy iz +#dump 2 all custom 500 dump2.tri.srd id type # c_10[1] c_10[2] c_10[3] c_10[4] c_10[5] c_10[6] # c_10[7] c_10[8] c_10[9] + +fix 3 all deform 1 xy erate 0.05 units box remap v + +run 2000 +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +SRD info: + SRD/big particles = 14771 1500 + big particle diameter max/min = 2.9202881 0.87320391 + SRD temperature & lamda = 1 0.2 + SRD max distance & max velocity = 0.8 40 + SRD grid counts: 13 13 13 + SRD grid size: request, actual (xyz) = 1, 1.0384419 1.0384419 1.0384419 + SRD per actual grid cell = -2.775698 + SRD viscosity = -12.180602 + big/SRD mass density ratio = -5.5653033 +WARNING: SRD bin size for fix srd differs from user request (src/SRD/fix_srd.cpp:2809) +WARNING: Fix srd grid size > 1/4 of big particle diameter (src/SRD/fix_srd.cpp:2830) +WARNING: Fix srd viscosity < 0.0 due to low SRD density (src/SRD/fix_srd.cpp:2832) + # of rescaled SRD velocities = 3 + ave/max small velocity = 16.23763 40 + ave/max big velocity = 1.9825234 5.257255 +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 3.8 + ghost atom cutoff = 3.8 + binsize = 13.499745, bins = 1 1 1 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair tri/lj, perpetual + attributes: half, newton on + pair build: half/multi/atomonly/newton/tri + stencil: half/multi/3d/tri + bin: multi +Per MPI rank memory allocation (min/avg/max) = 278.4 | 278.4 | 278.4 Mbytes + Step f_1 c_tsmall Temp Press f_2[9] f_2[4] + 1000 9.8719995 1.0317167 6.98982 4.0948969 0 0 + 1100 7.6460335 1.0028444 5.2446585 6.6348814 1 1320 + 1200 6.2789381 1.0012003 4.5257435 6.3278972 1 1024 + 1300 5.5060209 1.002182 3.7063549 7.0004503 1 794 + 1400 5.4107119 1.002291 3.594515 7.9511695 1 621 + 1500 5.072582 1.0001037 3.2501353 8.6993671 1 503 + 1600 4.7912016 0.99982803 3.1208274 6.464157 1 416 + 1700 4.5518848 1.0030059 2.9084074 6.3278992 1 346 + 1800 4.368682 1.000831 2.807184 6.7382017 1 282 + 1900 4.458655 1.0012568 2.7966515 6.0124309 1 246 + 2000 4.1256128 1.0004032 2.763649 6.3707442 1 208 + 2100 3.7040346 1.0004125 2.4398152 5.4213931 1 181 + 2200 4.2347861 1.002625 2.6206986 6.6832437 1 151 + 2300 4.254984 1.0028871 2.6794167 7.1661525 1 127 + 2400 4.1017692 1.0028508 2.6371178 8.388599 1 105 + 2500 3.9285571 1.0002888 2.5002741 6.0806187 1 95 + 2600 3.6239964 1.0012152 2.2573993 6.7863124 1 80 + 2700 3.4085702 1.0023974 2.1179914 6.7351139 1 68 + 2800 3.1399303 1.0005349 2.0163219 6.4502765 1 61 + 2900 3.1277562 1.0004013 2.0453134 6.6485498 1 51 + 3000 3.0737732 1.0022962 1.997382 6.797214 1 44 +Loop time of 206.387 on 1 procs for 2000 steps with 16271 atoms + +Performance: 837.264 tau/day, 9.691 timesteps/s, 157.675 katom-step/s +99.3% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 173.6 | 173.6 | 173.6 | 0.0 | 84.12 +Neigh | 1.0077 | 1.0077 | 1.0077 | 0.0 | 0.49 +Comm | 0.58656 | 0.58656 | 0.58656 | 0.0 | 0.28 +Output | 0.0042824 | 0.0042824 | 0.0042824 | 0.0 | 0.00 +Modify | 31.128 | 31.128 | 31.128 | 0.0 | 15.08 +Other | | 0.05664 | | | 0.03 + +Nlocal: 16271 ave 16271 max 16271 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 4521 ave 4521 max 4521 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 94777 ave 94777 max 94777 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 94777 +Ave neighs/atom = 5.8249032 +Neighbor list builds = 100 +Dangerous builds = 0 +Total wall time: 0:04:47 diff --git a/examples/ASPHERE/tri/log.1Feb24.tri.srd.g++.4 b/examples/ASPHERE/tri/log.1Feb24.tri.srd.g++.4 new file mode 100644 index 0000000000..c698c9e8db --- /dev/null +++ b/examples/ASPHERE/tri/log.1Feb24.tri.srd.g++.4 @@ -0,0 +1,343 @@ +LAMMPS (21 Nov 2023 - Development - patch_21Nov2023-665-g17f869bf5e) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# Aspherical shear demo - 3d triangle boxes, solvated by SRD particles + +units lj +atom_style tri +atom_modify first big map yes + +read_data data.tri.srd +Reading data file ... + orthogonal box = (-8.4373405 -8.4373405 -8.4373405) to (8.4373405 8.4373405 8.4373405) + 1 by 2 by 2 MPI processor grid + reading atoms ... + 1500 atoms + 1500 triangles + read_data CPU = 0.010 seconds + +# add small particles as hi density lattice + +lattice sc 0.4 +Lattice spacing in x,y,z = 1.3572088 1.3572088 1.3572088 +region box block INF INF INF INF INF INF +lattice sc 20.0 +Lattice spacing in x,y,z = 0.36840315 0.36840315 0.36840315 +create_atoms 2 region box +Created 91125 atoms + using lattice units in orthogonal box = (-8.4373405 -8.4373405 -8.4373405) to (8.4373405 8.4373405 8.4373405) + create_atoms CPU = 0.005 seconds + +group big type 1 +1500 atoms in group big +group small type 2 +91125 atoms in group small +set group small mass 0.01 +Setting atom values ... + 91125 settings made for mass + +# delete overlaps +# must set 1-2 cutoff to non-zero value + +pair_style lj/cut 1.5 +pair_coeff 1 1 1.0 1.0 +pair_coeff 2 2 0.0 1.0 0.0 +pair_coeff 1 2 0.0 1.0 + +delete_atoms overlap 1.5 small big +System init for delete_atoms ... +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 1.8 + ghost atom cutoff = 1.8 + binsize = 0.9, bins = 19 19 19 + 2 neighbor lists, perpetual/occasional/extra = 1 1 0 + (1) command delete_atoms, occasional + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard + (2) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/3d + bin: standard +WARNING: Delete_atoms cutoff > minimum neighbor cutoff (src/delete_atoms.cpp:312) +Deleted 76354 atoms, new total = 16271 + +# SRD run + +reset_timestep 0 + +velocity small create 1.44 87287 loop geom + +neighbor 0.3 multi +neigh_modify delay 0 every 1 check yes +neigh_modify exclude molecule/intra big include big + +comm_modify mode multi group big vel yes +neigh_modify include big + +# no pairwise interactions with small particles + +pair_style tri/lj 3.5 +pair_coeff 1 1 0.1 1.0 +pair_coeff 2 2 0.0 1.0 0.0 +pair_coeff 1 2 0.0 1.0 0.0 + +# use fix SRD to push small particles out from inside big ones +# if comment out, big particles won't see SRD particles + +timestep 0.001 + +fix 1 big rigid/small molecule #langevin 1.0 1.0 0.1 12398 + create bodies CPU = 0.000 seconds + 125 rigid bodies with 1500 atoms + 1.8601881 = max distance from body owner to body atom +fix 2 small srd 20 big 1.0 1.0 49894 search 0.2 cubic warn 0.0001 shift yes 49829 overlap yes collision noslip inside ignore + +fix 3 all deform 1 x scale 0.8 y scale 0.8 z scale 0.8 + +# diagnostics + +compute tsmall small temp/deform +compute tbig big temp +variable pebig equal pe*atoms/count(big) +variable ebig equal etotal*atoms/count(big) + +compute_modify tbig extra/dof -4500 + +compute 1 big erotate/asphere +compute 2 all ke +compute 3 all pe +variable toteng equal (c_1+c_2+c_3)/atoms + +thermo 100 +thermo_style custom step f_1 c_tsmall temp press f_2[9] f_2[4] +thermo_modify temp tbig +WARNING: Temperature for thermo pressure is not for group all (src/thermo.cpp:530) + +compute 10 all property/atom corner1x corner1y corner1z corner2x corner2y corner2z corner3x corner3y corner3z + +#dump 1 all custom 500 dump1.atom.srd id type x y z ix iy iz +#dump 2 all custom 500 dump1.tri.srd id type # c_10[1] c_10[2] c_10[3] c_10[4] c_10[5] c_10[6] # c_10[7] c_10[8] c_10[9] + +run 1000 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- neighbor multi command: doi:10.1016/j.cpc.2008.03.005, doi:10.1007/s40571-020-00361-2 + +@Article{Intveld08, + author = {in 't Veld, P. J. and S. J.~Plimpton and G. S. Grest}, + title = {Accurate and Efficient Methods for Modeling Colloidal + Mixtures in an Explicit Solvent using Molecular Dynamics}, + journal = {Comput.\ Phys.\ Commut.}, + year = 2008, + volume = 179, + pages = {320--329} +} + +@article{Shire2020, + author = {Shire, Tom and Hanley, Kevin J. and Stratford, Kevin}, + title = {{DEM} Simulations of Polydisperse Media: Efficient Contact + Detection Applied to Investigate the Quasi-Static Limit}, + journal = {Computational Particle Mechanics}, + year = {2020} +@article{Monti2022, + author = {Monti, Joseph M. and Clemmer, Joel T. and Srivastava, + Ishan and Silbert, Leonardo E. and Grest, Gary S. + and Lechman, Jeremy B.}, + title = {Large-scale frictionless jamming with power-law particle + size distributions}, + journal = {Phys. Rev. E}, + volume = {106} + issue = {3} + year = {2022} +} + +- fix srd command: doi:10.1063/1.3419070 + +@Article{Petersen10, + author = {M. K. Petersen and J. B. Lechman and S. J. Plimpton and + G. S. Grest and in 't Veld, P. J. and P. R. Schunk}, + title = {Mesoscale Hydrodynamics via Stochastic Rotation + Dynamics: Comparison with {L}ennard-{J}ones Fluid}, + journal = {J.~Chem.\ Phys.}, + year = 2010, + volume = 132, + pages = 174106 +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +WARNING: Using compute temp/deform with inconsistent fix deform remap option (src/compute_temp_deform.cpp:71) +WARNING: Using fix srd with box deformation but no SRD thermostat (src/SRD/fix_srd.cpp:405) +SRD info: + SRD/big particles = 14771 1500 + big particle diameter max/min = 2.9202881 0.87320391 + SRD temperature & lamda = 1 0.2 + SRD max distance & max velocity = 0.8 40 + SRD grid counts: 17 17 17 + SRD grid size: request, actual (xyz) = 1, 0.99262829 0.99262829 0.99262829 + SRD per actual grid cell = -3.9971745 + SRD viscosity = -34.162587 + big/SRD mass density ratio = -3.3753691 +WARNING: SRD bin size for fix srd differs from user request (src/SRD/fix_srd.cpp:2809) +WARNING: Fix srd grid size > 1/4 of big particle diameter (src/SRD/fix_srd.cpp:2830) +WARNING: Fix srd viscosity < 0.0 due to low SRD density (src/SRD/fix_srd.cpp:2832) + # of rescaled SRD velocities = 0 + ave/max small velocity = 19.970837 35.150443 + ave/max big velocity = 0 0 +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 3.8 + ghost atom cutoff = 3.8 + binsize = 16.874681, bins = 1 1 1 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair tri/lj, perpetual + attributes: half, newton on + pair build: half/multi/atomonly/newton + stencil: half/multi/3d + bin: multi +Per MPI rank memory allocation (min/avg/max) = 184.3 | 184.9 | 185.4 Mbytes + Step f_1 c_tsmall Temp Press f_2[9] f_2[4] + 0 0 1.4502537 0 -0.15949051 0 0 + 100 0.39689465 1.1495173 0.26931663 1.0004927 1.1170389 279 + 200 0.82155086 1.0684809 0.60689485 0.81307973 1.0433122 467 + 300 1.3210872 1.0334277 1.0368935 1.0853416 0.99443391 621 + 400 1.9755695 1.0149146 1.6438403 1.7258285 0.9925525 788 + 500 3.0111365 1.0121291 2.4285289 2.5210058 0.99688885 922 + 600 4.5413799 1.014305 3.4727946 3.8290233 0.99002027 1063 + 700 6.6071849 1.0062952 4.9025772 3.9595327 0.99573591 1186 + 800 7.6256618 1.0151252 5.3662442 5.0088255 0.99640985 1371 + 900 8.1578206 1.0148959 5.7716683 6.6059298 0.96053165 1555 + 1000 10.749617 1.0282309 7.6209538 11.277602 1.0012602 1844 +Loop time of 28.4136 on 4 procs for 1000 steps with 16271 atoms + +Performance: 3040.793 tau/day, 35.194 timesteps/s, 572.647 katom-step/s +98.7% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 12.454 | 15.242 | 17.781 | 48.4 | 53.64 +Neigh | 0.093078 | 0.094516 | 0.097759 | 0.6 | 0.33 +Comm | 0.48732 | 2.9927 | 5.7363 | 107.5 | 10.53 +Output | 0.00080706 | 0.0008431 | 0.00086933 | 0.0 | 0.00 +Modify | 10.015 | 10.063 | 10.111 | 1.4 | 35.42 +Other | | 0.02046 | | | 0.07 + +Nlocal: 4067.75 ave 4467 max 3606 min +Histogram: 1 0 0 0 1 0 1 0 0 1 +Nghost: 2313.5 ave 2327 max 2296 min +Histogram: 1 0 0 0 0 1 0 1 0 1 +Neighs: 24883 ave 26066 max 24145 min +Histogram: 2 0 0 0 0 1 0 0 0 1 + +Total # of neighbors = 99532 +Ave neighs/atom = 6.1171409 +Neighbor list builds = 70 +Dangerous builds = 0 + +#undump 1 +#undump 2 +unfix 3 + +change_box all triclinic +Changing box ... + triclinic box = (-6.7498724 -6.7498724 -6.7498724) to (6.7498724 6.7498724 6.7498724) with tilt (0 0 0) + +fix 2 small srd 20 big 1.0 1.0 49894 search 0.2 cubic warn 0.0001 shift yes 49829 overlap yes collision noslip tstat yes inside ignore + +#dump 1 all custom 500 dump2.atom.srd id type x y z ix iy iz +#dump 2 all custom 500 dump2.tri.srd id type # c_10[1] c_10[2] c_10[3] c_10[4] c_10[5] c_10[6] # c_10[7] c_10[8] c_10[9] + +fix 3 all deform 1 xy erate 0.05 units box remap v + +run 2000 +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +SRD info: + SRD/big particles = 14771 1500 + big particle diameter max/min = 2.9202881 0.87320391 + SRD temperature & lamda = 1 0.2 + SRD max distance & max velocity = 0.8 40 + SRD grid counts: 13 13 13 + SRD grid size: request, actual (xyz) = 1, 1.0384419 1.0384419 1.0384419 + SRD per actual grid cell = -2.775698 + SRD viscosity = -12.180602 + big/SRD mass density ratio = -5.5653033 +WARNING: SRD bin size for fix srd differs from user request (src/SRD/fix_srd.cpp:2809) +WARNING: Fix srd grid size > 1/4 of big particle diameter (src/SRD/fix_srd.cpp:2830) +WARNING: Fix srd viscosity < 0.0 due to low SRD density (src/SRD/fix_srd.cpp:2832) + # of rescaled SRD velocities = 3 + ave/max small velocity = 16.10299 40 + ave/max big velocity = 2.0311414 11.34118 +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 3.8 + ghost atom cutoff = 3.8 + binsize = 13.499745, bins = 1 1 1 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair tri/lj, perpetual + attributes: half, newton on + pair build: half/multi/atomonly/newton/tri + stencil: half/multi/3d/tri + bin: multi +Per MPI rank memory allocation (min/avg/max) = 148.8 | 149.5 | 150 Mbytes + Step f_1 c_tsmall Temp Press f_2[9] f_2[4] + 1000 10.749616 1.0167438 7.6203704 5.4893075 0 0 + 1100 9.0727748 1.003438 6.1822573 8.6707036 1 1339 + 1200 7.1960998 1.0003968 4.8077632 6.7809972 1 1039 + 1300 6.2680889 1.0011134 4.3139658 8.2260362 1 861 + 1400 5.8199503 1.0024475 3.9876867 7.0322957 1 692 + 1500 5.399935 0.99757802 3.4552534 7.905565 1 577 + 1600 5.0830248 1.0023727 3.1330433 7.6897887 1 479 + 1700 4.8728937 1.0027203 3.0838267 7.606406 1 389 + 1800 4.8443541 1.0018057 3.115321 7.4547572 1 317 + 1900 5.0622362 1.0007126 2.9336473 6.514338 1 268 + 2000 5.022699 1.0030275 3.1244763 7.2999286 1 223 + 2100 4.4605894 1.0019457 2.9262733 8.3475145 1 196 + 2200 4.6544992 1.0023701 3.0140329 7.3670747 1 164 + 2300 4.1954825 1.0012089 2.5802739 7.5553707 1 142 + 2400 4.0806819 1.0000292 2.6492187 7.5648723 1 122 + 2500 3.7437189 0.99949605 2.3660722 8.2155316 1 104 + 2600 4.2333926 1.0002823 2.5704515 7.2839635 1 106 + 2700 3.7542455 1.001394 2.4146222 6.3785983 1 86 + 2800 3.4011329 0.99832028 2.141193 6.3869497 1 78 + 2900 3.4579019 1.0007319 2.1839274 6.241817 1 64 + 3000 3.6128019 1.0017345 2.2982426 5.8975992 1 55 +Loop time of 67.0194 on 4 procs for 2000 steps with 16271 atoms + +Performance: 2578.358 tau/day, 29.842 timesteps/s, 485.561 katom-step/s +98.8% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 36.774 | 43.583 | 50.126 | 71.5 | 65.03 +Neigh | 0.29299 | 0.3134 | 0.32399 | 2.2 | 0.47 +Comm | 0.75102 | 7.2688 | 14.075 | 174.8 | 10.85 +Output | 0.0016347 | 0.0017229 | 0.0018802 | 0.2 | 0.00 +Modify | 15.794 | 15.808 | 15.828 | 0.3 | 23.59 +Other | | 0.04379 | | | 0.07 + +Nlocal: 4067.75 ave 4560 max 3583 min +Histogram: 1 0 0 1 0 0 1 0 0 1 +Nghost: 2256.75 ave 2292 max 2241 min +Histogram: 2 1 0 0 0 0 0 0 0 1 +Neighs: 23706 ave 24669 max 22450 min +Histogram: 1 0 0 0 0 0 2 0 0 1 + +Total # of neighbors = 94824 +Ave neighs/atom = 5.8277918 +Neighbor list builds = 108 +Dangerous builds = 0 +Total wall time: 0:01:36 diff --git a/examples/COUPLE/plugin/liblammpsplugin.c b/examples/COUPLE/plugin/liblammpsplugin.c index 5228e07e9c..011c320254 100644 --- a/examples/COUPLE/plugin/liblammpsplugin.c +++ b/examples/COUPLE/plugin/liblammpsplugin.c @@ -110,6 +110,8 @@ liblammpsplugin_t *liblammpsplugin_load(const char *lib) ADDSYM(extract_variable); ADDSYM(extract_variable_datatype); ADDSYM(set_variable); + ADDSYM(set_string_variable); + ADDSYM(set_internal_variable); ADDSYM(variable_info); ADDSYM(gather_atoms); diff --git a/examples/COUPLE/plugin/liblammpsplugin.h b/examples/COUPLE/plugin/liblammpsplugin.h index 92398dfb27..1d647e8e93 100644 --- a/examples/COUPLE/plugin/liblammpsplugin.h +++ b/examples/COUPLE/plugin/liblammpsplugin.h @@ -152,9 +152,11 @@ struct _liblammpsplugin { void *(*extract_compute)(void *, const char *, int, int); void *(*extract_fix)(void *, const char *, int, int, int, int); - void *(*extract_variable)(void *, const char *, char *); + void *(*extract_variable)(void *, const char *, const char *); int (*extract_variable_datatype)(void *, const char *); - int (*set_variable)(void *, char *, char *); + int (*set_variable)(void *, const char *, const char *); + int (*set_string_variable)(void *, const char *, const char *); + int (*set_internal_variable)(void *, const char *, double); int (*variable_info)(void *, int, char *, int); void (*gather_atoms)(void *, const char *, int, int, void *); diff --git a/examples/PACKAGES/cgdna/util/generate.py b/examples/PACKAGES/cgdna/util/generate.py index cd7465acdb..e85661abb1 100644 --- a/examples/PACKAGES/cgdna/util/generate.py +++ b/examples/PACKAGES/cgdna/util/generate.py @@ -22,22 +22,26 @@ """ Import basic modules """ + +# for python2/3 compatibility +from __future__ import print_function + import sys, os, timeit from timeit import default_timer as timer start_time = timer() """ -Try to import numpy; if failed, import a local version mynumpy +Try to import numpy; if failed, import a local version mynumpy which needs to be provided """ try: import numpy as np except: - print >> sys.stderr, "numpy not found. Exiting." + print("numpy not found. Exiting.", file=sys.stderr) sys.exit(1) """ -Check that the required arguments (box offset and size in simulation units +Check that the required arguments (box offset and size in simulation units and the sequence file were provided """ try: @@ -45,8 +49,8 @@ try: box_length = float(sys.argv[2]) infile = sys.argv[3] except: - print >> sys.stderr, "Usage: %s <%s> <%s> <%s>" % (sys.argv[0], \ - "box offset", "box length", "file with sequences") + print( "Usage: %s <%s> <%s> <%s>" % (sys.argv[0], \ + "box offset", "box length", "file with sequences"), file=sys.stderr) sys.exit(1) box = np.array ([box_length, box_length, box_length]) @@ -57,8 +61,7 @@ try: inp = open (infile, 'r') inp.close() except: - print >> sys.stderr, "Could not open file '%s' for reading. \ - Aborting." % infile + print( "Could not open file '%s' for reading. Aborting." % infile, file=sys.stderr) sys.exit(2) # return parts of a string @@ -86,7 +89,7 @@ Define auxiliary variables for the construction of a helix # center of the double strand CM_CENTER_DS = POS_BASE + 0.2 -# ideal distance between base sites of two nucleotides +# ideal distance between base sites of two nucleotides # which are to be base paired in a duplex BASE_BASE = 0.3897628551303122 @@ -118,7 +121,7 @@ strandnum = [] bonds = [] -""" +""" Convert local body frame to quaternion DOF """ def exyz_to_quat (mya1, mya3): @@ -135,25 +138,25 @@ def exyz_to_quat (mya1, mya3): # compute other components from it if q0sq >= 0.25: - myquat[0] = np.sqrt(q0sq) - myquat[1] = (mya2[2] - mya3[1]) / (4.0*myquat[0]) - myquat[2] = (mya3[0] - mya1[2]) / (4.0*myquat[0]) - myquat[3] = (mya1[1] - mya2[0]) / (4.0*myquat[0]) + myquat[0] = np.sqrt(q0sq) + myquat[1] = (mya2[2] - mya3[1]) / (4.0*myquat[0]) + myquat[2] = (mya3[0] - mya1[2]) / (4.0*myquat[0]) + myquat[3] = (mya1[1] - mya2[0]) / (4.0*myquat[0]) elif q1sq >= 0.25: - myquat[1] = np.sqrt(q1sq) - myquat[0] = (mya2[2] - mya3[1]) / (4.0*myquat[1]) - myquat[2] = (mya2[0] + mya1[1]) / (4.0*myquat[1]) - myquat[3] = (mya1[2] + mya3[0]) / (4.0*myquat[1]) + myquat[1] = np.sqrt(q1sq) + myquat[0] = (mya2[2] - mya3[1]) / (4.0*myquat[1]) + myquat[2] = (mya2[0] + mya1[1]) / (4.0*myquat[1]) + myquat[3] = (mya1[2] + mya3[0]) / (4.0*myquat[1]) elif q2sq >= 0.25: - myquat[2] = np.sqrt(q2sq) - myquat[0] = (mya3[0] - mya1[2]) / (4.0*myquat[2]) - myquat[1] = (mya2[0] + mya1[1]) / (4.0*myquat[2]) - myquat[3] = (mya3[1] + mya2[2]) / (4.0*myquat[2]) + myquat[2] = np.sqrt(q2sq) + myquat[0] = (mya3[0] - mya1[2]) / (4.0*myquat[2]) + myquat[1] = (mya2[0] + mya1[1]) / (4.0*myquat[2]) + myquat[3] = (mya3[1] + mya2[2]) / (4.0*myquat[2]) elif q3sq >= 0.25: - myquat[3] = np.sqrt(q3sq) - myquat[0] = (mya1[1] - mya2[0]) / (4.0*myquat[3]) - myquat[1] = (mya3[0] + mya1[2]) / (4.0*myquat[3]) - myquat[2] = (mya3[1] + mya2[2]) / (4.0*myquat[3]) + myquat[3] = np.sqrt(q3sq) + myquat[0] = (mya1[1] - mya2[0]) / (4.0*myquat[3]) + myquat[1] = (mya3[0] + mya1[2]) / (4.0*myquat[3]) + myquat[2] = (mya3[1] + mya2[2]) / (4.0*myquat[3]) norm = 1.0/np.sqrt(myquat[0]*myquat[0] + myquat[1]*myquat[1] + \ myquat[2]*myquat[2] + myquat[3]*myquat[3]) @@ -169,62 +172,62 @@ Adds a strand to the system by appending it to the array of previous strands """ def add_strands (mynewpositions, mynewa1s, mynewa3s): overlap = False - - # This is a simple check for each of the particles where for previously - # placed particles i we check whether it overlaps with any of the + + # This is a simple check for each of the particles where for previously + # placed particles i we check whether it overlaps with any of the # newly created particles j - print >> sys.stdout, "## Checking for overlaps" + print( "## Checking for overlaps", file=sys.stdout) - for i in xrange(len(positions)): + for i in range(len(positions)): - p = positions[i] - pa1 = a1s[i] + p = positions[i] + pa1 = a1s[i] - for j in xrange (len(mynewpositions)): + for j in range (len(mynewpositions)): - q = mynewpositions[j] - qa1 = mynewa1s[j] + q = mynewpositions[j] + qa1 = mynewa1s[j] - # skip particles that are anyway too far away - dr = p - q - dr -= box * np.rint (dr / box) - if np.dot(dr, dr) > RC2: - continue + # skip particles that are anyway too far away + dr = p - q + dr -= box * np.rint(dr / box) + if np.dot(dr, dr) > RC2: + continue - # base site and backbone site of the two particles + # base site and backbone site of the two particles p_pos_back = p + pa1 * POS_BACK p_pos_base = p + pa1 * POS_BASE q_pos_back = q + qa1 * POS_BACK q_pos_base = q + qa1 * POS_BASE - # check for no overlap between the two backbone sites + # check for no overlap between the two backbone sites dr = p_pos_back - q_pos_back - dr -= box * np.rint (dr / box) + dr -= box * np.rint(dr / box) if np.dot(dr, dr) < RC2_BACK: overlap = True - # check for no overlap between the two base sites + # check for no overlap between the two base sites dr = p_pos_base - q_pos_base - dr -= box * np.rint (dr / box) + dr -= box * np.rint(dr / box) if np.dot(dr, dr) < RC2_BASE: overlap = True - # check for no overlap between backbone site of particle p - # with base site of particle q + # check for no overlap between backbone site of particle p + # with base site of particle q dr = p_pos_back - q_pos_base dr -= box * np.rint (dr / box) if np.dot(dr, dr) < RC2_BACK_BASE: overlap = True - # check for no overlap between base site of particle p and - # backbone site of particle q + # check for no overlap between base site of particle p and + # backbone site of particle q dr = p_pos_base - q_pos_back dr -= box * np.rint (dr / box) if np.dot(dr, dr) < RC2_BACK_BASE: overlap = True - # exit if there is an overlap + # exit if there is an overlap if overlap: return False @@ -237,10 +240,10 @@ def add_strands (mynewpositions, mynewa1s, mynewa3s): a1s.append (p) for p in mynewa3s: a3s.append (p) - # calculate quaternion from local body frame and append - for ia in xrange(len(mynewpositions)): - mynewquaternions = exyz_to_quat(mynewa1s[ia],mynewa3s[ia]) - quaternions.append(mynewquaternions) + # calculate quaternion from local body frame and append + for ia in range(len(mynewpositions)): + mynewquaternions = exyz_to_quat(mynewa1s[ia],mynewa3s[ia]) + quaternions.append(mynewquaternions) return True @@ -281,7 +284,7 @@ def get_rotation_matrix(axis, anglest): [olc*x*z-st*y, olc*y*z+st*x, olc*z*z+ct]]) """ -Generates the position and orientation vectors of a +Generates the position and orientation vectors of a (single or double) strand from a sequence string """ def generate_strand(bp, sequence=None, start_pos=np.array([0, 0, 0]), \ @@ -295,76 +298,75 @@ def generate_strand(bp, sequence=None, start_pos=np.array([0, 0, 0]), \ # overall direction of the helix dir = np.array(dir, dtype=float) if sequence == None: - sequence = np.random.randint(1, 5, bp) + sequence = np.random.randint(1, 5, bp) - # the elseif here is most likely redundant + # the elseif here is most likely redundant elif len(sequence) != bp: - n = bp - len(sequence) - sequence += np.random.randint(1, 5, n) - print >> sys.stderr, "sequence is too short, adding %d random bases" % n + n = bp - len(sequence) + sequence += np.random.randint(1, 5, n) + print( "sequence is too short, adding %d random bases" % n, file=sys.stderr) # normalize direction dir_norm = np.sqrt(np.dot(dir,dir)) if dir_norm < 1e-10: - print >> sys.stderr, "direction must be a valid vector, \ - defaulting to (0, 0, 1)" - dir = np.array([0, 0, 1]) + print( "direction must be a valid vector, defaulting to (0, 0, 1)", file=sys.stderr) + dir = np.array([0, 0, 1]) else: dir /= dir_norm # find a vector orthogonal to dir to act as helix direction, # if not provided switch off random orientation if perp is None or perp is False: - v1 = np.random.random_sample(3) - v1 -= dir * (np.dot(dir, v1)) - v1 /= np.sqrt(sum(v1*v1)) + v1 = np.random.random_sample(3) + v1 -= dir * (np.dot(dir, v1)) + v1 /= np.sqrt(sum(v1*v1)) else: - v1 = perp; + v1 = perp; # generate rotational matrix representing the overall rotation of the helix R0 = get_rotation_matrix(dir, rot) - + # rotation matrix corresponding to one step along the helix R = get_rotation_matrix(dir, [1, "bp"]) - # set the vector a1 (backbone to base) to v1 + # set the vector a1 (backbone to base) to v1 a1 = v1 - - # apply the global rotation to a1 + + # apply the global rotation to a1 a1 = np.dot(R0, a1) - + # set the position of the fist backbone site to start_pos rb = np.array(start_pos) - + # set a3 to the direction of the helix a3 = dir for i in range(bp): # work out the position of the centre of mass of the nucleotide - rcdm = rb - CM_CENTER_DS * a1 - - # append to newpositions - mynewpositions.append(rcdm) - mynewa1s.append(a1) - mynewa3s.append(a3) - - # if we are not at the end of the helix, we work out a1 and rb for the - # next nucleotide along the helix - if i != bp - 1: - a1 = np.dot(R, a1) - rb += a3 * BASE_BASE + rcdm = rb - CM_CENTER_DS * a1 - # if we are working on a double strand, we do a cycle similar + # append to newpositions + mynewpositions.append(rcdm) + mynewa1s.append(a1) + mynewa3s.append(a3) + + # if we are not at the end of the helix, we work out a1 and rb for the + # next nucleotide along the helix + if i != bp - 1: + a1 = np.dot(R, a1) + rb += a3 * BASE_BASE + + # if we are working on a double strand, we do a cycle similar # to the previous one but backwards if double == True: - a1 = -a1 - a3 = -dir - R = R.transpose() - for i in range(bp): - rcdm = rb - CM_CENTER_DS * a1 - mynewpositions.append (rcdm) - mynewa1s.append (a1) - mynewa3s.append (a3) - a1 = np.dot(R, a1) - rb += a3 * BASE_BASE + a1 = -a1 + a3 = -dir + R = R.transpose() + for i in range(bp): + rcdm = rb - CM_CENTER_DS * a1 + mynewpositions.append (rcdm) + mynewa1s.append (a1) + mynewa3s.append (a3) + a1 = np.dot(R, a1) + rb += a3 * BASE_BASE assert (len (mynewpositions) > 0) @@ -391,10 +393,10 @@ def read_strands(filename): try: infile = open (filename) except: - print >> sys.stderr, "Could not open file '%s'. Aborting." % filename + print( "Could not open file '%s'. Aborting." % filename, file=sys.stderr ) sys.exit(2) - # This block works out the number of nucleotides and strands by reading + # This block works out the number of nucleotides and strands by reading # the number of non-empty lines in the input file and the number of letters, # taking the possible DOUBLE keyword into account. nstrands, nnucl, nbonds = 0, 0, 0 @@ -406,30 +408,29 @@ def read_strands(filename): if line[:6] == 'DOUBLE': line = line.split()[1] length = len(line) - print >> sys.stdout, "## Found duplex of %i base pairs" % length + print( "## Found duplex of %i base pairs" % length, file=sys.stdout) nnucl += 2*length nstrands += 2 - nbonds += (2*length-2) + nbonds += (2*length-2) else: line = line.split()[0] length = len(line) - print >> sys.stdout, \ - "## Found single strand of %i bases" % length + print( "## Found single strand of %i bases" % length, file=sys.stdout) nnucl += length nstrands += 1 - nbonds += length-1 + nbonds += length-1 # rewind the sequence input file infile.seek(0) - print >> sys.stdout, "## nstrands, nnucl = ", nstrands, nnucl + print( "## nstrands, nnucl = ", nstrands, nnucl, file=sys.stdout) # generate the data file in LAMMPS format try: out = open ("data.oxdna", "w") except: - print >> sys.stderr, "Could not open data file for writing. Aborting." + print( "Could not open data file for writing. Aborting.", file=sys.stderr) sys.exit(2) - + lines = infile.readlines() nlines = len(lines) i = 1 @@ -440,115 +441,114 @@ def read_strands(filename): line = line.upper().strip() # skip empty lines - if len(line) == 0: - i += 1 - continue + if len(line) == 0: + i += 1 + continue - # block for duplexes: last argument of the generate function - # is set to 'True' + # block for duplexes: last argument of the generate function + # is set to 'True' if line[:6] == 'DOUBLE': line = line.split()[1] length = len(line) seq = [(base_to_number[x]) for x in line] - myns += 1 - for b in xrange(length): - basetype.append(seq[b]) - strandnum.append(myns) + myns += 1 + for b in range(length): + basetype.append(seq[b]) + strandnum.append(myns) - for b in xrange(length-1): - bondpair = [noffset + b, noffset + b + 1] - bonds.append(bondpair) - noffset += length + for b in range(length-1): + bondpair = [noffset + b, noffset + b + 1] + bonds.append(bondpair) + noffset += length - # create the sequence of the second strand as made of - # complementary bases - seq2 = [5-s for s in seq] - seq2.reverse() + # create the sequence of the second strand as made of + # complementary bases + seq2 = [5-s for s in seq] + seq2.reverse() - myns += 1 - for b in xrange(length): - basetype.append(seq2[b]) - strandnum.append(myns) + myns += 1 + for b in range(length): + basetype.append(seq2[b]) + strandnum.append(myns) - for b in xrange(length-1): - bondpair = [noffset + b, noffset + b + 1] - bonds.append(bondpair) - noffset += length - - print >> sys.stdout, "## Created duplex of %i bases" % (2*length) + for b in range(length-1): + bondpair = [noffset + b, noffset + b + 1] + bonds.append(bondpair) + noffset += length - # generate random position of the first nucleotide + print( "## Created duplex of %i bases" % (2*length), file=sys.stdout) + + # generate random position of the first nucleotide cdm = box_offset + np.random.random_sample(3) * box - # generate the random direction of the helix + # generate the random direction of the helix axis = np.random.random_sample(3) axis /= np.sqrt(np.dot(axis, axis)) - # use the generate function defined above to create - # the position and orientation vector of the strand + # use the generate function defined above to create + # the position and orientation vector of the strand newpositions, newa1s, newa3s = generate_strand(len(line), \ - sequence=seq, dir=axis, start_pos=cdm, double=True) + sequence=seq, dir=axis, start_pos=cdm, double=True) # generate a new position for the strand until it does not overlap - # with anything already present - start = timer() + # with anything already present + start = timer() while not add_strands(newpositions, newa1s, newa3s): cdm = box_offset + np.random.random_sample(3) * box axis = np.random.random_sample(3) axis /= np.sqrt(np.dot(axis, axis)) newpositions, newa1s, newa3s = generate_strand(len(line), \ - sequence=seq, dir=axis, start_pos=cdm, double=True) - print >> sys.stdout, "## Trying %i" % i - end = timer() - print >> sys.stdout, "## Added duplex of %i bases (line %i/%i) in %.2fs, now at %i/%i" % \ - (2*length, i, nlines, end-start, len(positions), nnucl) + sequence=seq, dir=axis, start_pos=cdm, double=True) + print( "## Trying %i" % i, file=sys.stdout) + end = timer() + print( "## Added duplex of %i bases (line %i/%i) in %.2fs, now at %i/%i" % \ + (2*length, i, nlines, end-start, len(positions), nnucl), file=sys.stdout) - # block for single strands: last argument of the generate function - # is set to 'False' + # block for single strands: last argument of the generate function + # is set to 'False' else: length = len(line) seq = [(base_to_number[x]) for x in line] - myns += 1 - for b in xrange(length): - basetype.append(seq[b]) - strandnum.append(myns) + myns += 1 + for b in range(length): + basetype.append(seq[b]) + strandnum.append(myns) - for b in xrange(length-1): - bondpair = [noffset + b, noffset + b + 1] - bonds.append(bondpair) - noffset += length + for b in range(length-1): + bondpair = [noffset + b, noffset + b + 1] + bonds.append(bondpair) + noffset += length - # generate random position of the first nucleotide + # generate random position of the first nucleotide cdm = box_offset + np.random.random_sample(3) * box - # generate the random direction of the helix + # generate the random direction of the helix axis = np.random.random_sample(3) axis /= np.sqrt(np.dot(axis, axis)) - print >> sys.stdout, \ - "## Created single strand of %i bases" % length + print("## Created single strand of %i bases" % length, file=sys.stdout) newpositions, newa1s, newa3s = generate_strand(length, \ sequence=seq, dir=axis, start_pos=cdm, double=False) - start = timer() + start = timer() while not add_strands(newpositions, newa1s, newa3s): cdm = box_offset + np.random.random_sample(3) * box axis = np.random.random_sample(3) - axis /= np.sqrt(np.dot(axis, axis)) + axis /= np.sqrt(np.dot(axis, axis)) newpositions, newa1s, newa3s = generate_strand(length, \ - sequence=seq, dir=axis, start_pos=cdm, double=False) + sequence=seq, dir=axis, start_pos=cdm, double=False) print >> sys.stdout, "## Trying %i" % (i) - end = timer() - print >> sys.stdout, "## Added single strand of %i bases (line %i/%i) in %.2fs, now at %i/%i" % \ - (length, i, nlines, end-start,len(positions), nnucl) + end = timer() + print( "## Added single strand of %i bases (line %i/%i) in %.2fs, now at %i/%i" % \ + (length, i, nlines, end-start,len(positions), nnucl), file=sys.stdout) i += 1 # sanity check if not len(positions) == nnucl: - print len(positions), nnucl + print( len(positions), nnucl ) raise AssertionError out.write('# LAMMPS data file\n') @@ -580,44 +580,41 @@ def read_strands(filename): out.write('Atoms\n') out.write('\n') - for i in xrange(nnucl): - out.write('%d %d %22.15le %22.15le %22.15le %d 1 1\n' \ - % (i+1, basetype[i], \ - positions[i][0], positions[i][1], positions[i][2], \ - strandnum[i])) + for i in range(nnucl): + out.write('%d %d %22.15le %22.15le %22.15le %d 1 1\n' \ + % (i+1, basetype[i], positions[i][0], positions[i][1], positions[i][2], strandnum[i])) out.write('\n') out.write('# Atom-ID, translational, rotational velocity\n') out.write('Velocities\n') out.write('\n') - for i in xrange(nnucl): - out.write("%d %22.15le %22.15le %22.15le %22.15le %22.15le %22.15le\n" \ - % (i+1,0.0,0.0,0.0,0.0,0.0,0.0)) + for i in range(nnucl): + out.write("%d %22.15le %22.15le %22.15le %22.15le %22.15le %22.15le\n" \ + % (i+1,0.0,0.0,0.0,0.0,0.0,0.0)) out.write('\n') out.write('# Atom-ID, shape, quaternion\n') out.write('Ellipsoids\n') out.write('\n') - for i in xrange(nnucl): - out.write(\ - "%d %22.15le %22.15le %22.15le %22.15le %22.15le %22.15le %22.15le\n" \ - % (i+1,1.1739845031423408,1.1739845031423408,1.1739845031423408, \ - quaternions[i][0],quaternions[i][1], quaternions[i][2],quaternions[i][3])) - + for i in range(nnucl): + out.write("%d %22.15le %22.15le %22.15le %22.15le %22.15le %22.15le %22.15le\n" \ + % (i+1,1.1739845031423408,1.1739845031423408,1.1739845031423408, \ + quaternions[i][0],quaternions[i][1], quaternions[i][2],quaternions[i][3])) + out.write('\n') out.write('# Bond topology\n') out.write('Bonds\n') out.write('\n') - for i in xrange(nbonds): - out.write("%d %d %d %d\n" % (i+1,1,bonds[i][0],bonds[i][1])) + for i in range(nbonds): + out.write("%d %d %d %d\n" % (i+1,1,bonds[i][0],bonds[i][1])) out.close() - print >> sys.stdout, "## Wrote data to 'data.oxdna'" - print >> sys.stdout, "## DONE" + print("## Wrote data to 'data.oxdna'", file=sys.stdout) + print("## DONE", file=sys.stdout) # call the above main() function, which executes the program read_strands (infile) @@ -627,4 +624,6 @@ runtime = end_time-start_time hours = runtime/3600 minutes = (runtime-np.rint(hours)*3600)/60 seconds = (runtime-np.rint(hours)*3600-np.rint(minutes)*60)%60 -print >> sys.stdout, "## Total runtime %ih:%im:%.2fs" % (hours,minutes,seconds) +print( "## Total runtime %ih:%im:%.2fs" % (hours,minutes,seconds), file=sys.stdout) + + diff --git a/examples/PACKAGES/cgdna/util/generate_simple.py b/examples/PACKAGES/cgdna/util/generate_simple.py index 33cf1ee7f5..7702bfc7f5 100644 --- a/examples/PACKAGES/cgdna/util/generate_simple.py +++ b/examples/PACKAGES/cgdna/util/generate_simple.py @@ -1,5 +1,8 @@ # Setup tool for oxDNA input in LAMMPS format. +# for python2/3 compatibility +from __future__ import print_function + import math,numpy as np,sys,os # system size @@ -250,59 +253,59 @@ def duplex_array(): qrot3=math.sin(0.5*twist) for letter in strand[2]: - temp1=[] - temp2=[] + temp1=[] + temp2=[] - temp1.append(nt2num[letter]) - temp2.append(compnt2num[letter]) + temp1.append(nt2num[letter]) + temp2.append(compnt2num[letter]) - temp1.append([posx1,posy1,posz1]) - temp2.append([posx2,posy2,posz2]) + temp1.append([posx1,posy1,posz1]) + temp2.append([posx2,posy2,posz2]) - vel=[0,0,0,0,0,0] - temp1.append(vel) - temp2.append(vel) + vel=[0,0,0,0,0,0] + temp1.append(vel) + temp2.append(vel) - temp1.append(shape) - temp2.append(shape) + temp1.append(shape) + temp2.append(shape) - temp1.append(quat1) - temp2.append(quat2) + temp1.append(quat1) + temp2.append(quat2) - quat1_0 = quat1[0]*qrot0 - quat1[1]*qrot1 - quat1[2]*qrot2 - quat1[3]*qrot3 - quat1_1 = quat1[0]*qrot1 + quat1[1]*qrot0 + quat1[2]*qrot3 - quat1[3]*qrot2 - quat1_2 = quat1[0]*qrot2 + quat1[2]*qrot0 + quat1[3]*qrot1 - quat1[1]*qrot3 - quat1_3 = quat1[0]*qrot3 + quat1[3]*qrot0 + quat1[1]*qrot2 + quat1[2]*qrot1 + quat1_0 = quat1[0]*qrot0 - quat1[1]*qrot1 - quat1[2]*qrot2 - quat1[3]*qrot3 + quat1_1 = quat1[0]*qrot1 + quat1[1]*qrot0 + quat1[2]*qrot3 - quat1[3]*qrot2 + quat1_2 = quat1[0]*qrot2 + quat1[2]*qrot0 + quat1[3]*qrot1 - quat1[1]*qrot3 + quat1_3 = quat1[0]*qrot3 + quat1[3]*qrot0 + quat1[1]*qrot2 + quat1[2]*qrot1 - quat1 = [quat1_0,quat1_1,quat1_2,quat1_3] + quat1 = [quat1_0,quat1_1,quat1_2,quat1_3] - posx1=axisx - dcomh*(quat1[0]**2+quat1[1]**2-quat1[2]**2-quat1[3]**2) - posy1=axisy - dcomh*(2*(quat1[1]*quat1[2]+quat1[0]*quat1[3])) - posz1=posz1+risez + posx1=axisx - dcomh*(quat1[0]**2+quat1[1]**2-quat1[2]**2-quat1[3]**2) + posy1=axisy - dcomh*(2*(quat1[1]*quat1[2]+quat1[0]*quat1[3])) + posz1=posz1+risez - quat2_0 = quat2[0]*qrot0 - quat2[1]*qrot1 - quat2[2]*qrot2 + quat2[3]*qrot3 - quat2_1 = quat2[0]*qrot1 + quat2[1]*qrot0 - quat2[2]*qrot3 - quat2[3]*qrot2 - quat2_2 = quat2[0]*qrot2 + quat2[2]*qrot0 + quat2[3]*qrot1 + quat2[1]*qrot3 - quat2_3 =-quat2[0]*qrot3 + quat2[3]*qrot0 + quat2[1]*qrot2 + quat2[2]*qrot1 + quat2_0 = quat2[0]*qrot0 - quat2[1]*qrot1 - quat2[2]*qrot2 + quat2[3]*qrot3 + quat2_1 = quat2[0]*qrot1 + quat2[1]*qrot0 - quat2[2]*qrot3 - quat2[3]*qrot2 + quat2_2 = quat2[0]*qrot2 + quat2[2]*qrot0 + quat2[3]*qrot1 + quat2[1]*qrot3 + quat2_3 =-quat2[0]*qrot3 + quat2[3]*qrot0 + quat2[1]*qrot2 + quat2[2]*qrot1 - quat2 = [quat2_0,quat2_1,quat2_2,quat2_3] + quat2 = [quat2_0,quat2_1,quat2_2,quat2_3] - posx2=axisx + dcomh*(quat1[0]**2+quat1[1]**2-quat1[2]**2-quat1[3]**2) - posy2=axisy + dcomh*(2*(quat1[1]*quat1[2]+quat1[0]*quat1[3])) - posz2=posz1 + posx2=axisx + dcomh*(quat1[0]**2+quat1[1]**2-quat1[2]**2-quat1[3]**2) + posy2=axisy + dcomh*(2*(quat1[1]*quat1[2]+quat1[0]*quat1[3])) + posz2=posz1 - if (len(nucleotide)+1 > strandstart): - topology.append([1,len(nucleotide),len(nucleotide)+1]) - comptopo.append([1,len(nucleotide)+len(strand[2]),len(nucleotide)+len(strand[2])+1]) + if (len(nucleotide)+1 > strandstart): + topology.append([1,len(nucleotide),len(nucleotide)+1]) + comptopo.append([1,len(nucleotide)+len(strand[2]),len(nucleotide)+len(strand[2])+1]) - nucleotide.append(temp1) - compstrand.append(temp2) + nucleotide.append(temp1) + compstrand.append(temp2) for ib in range(len(compstrand)): - nucleotide.append(compstrand[len(compstrand)-1-ib]) + nucleotide.append(compstrand[len(compstrand)-1-ib]) for ib in range(len(comptopo)): - topology.append(comptopo[ib]) + topology.append(comptopo[ib]) return diff --git a/examples/PACKAGES/electrode/madelung/eval.py b/examples/PACKAGES/electrode/madelung/eval.py index 2f5a355d9b..feda0e384e 100644 --- a/examples/PACKAGES/electrode/madelung/eval.py +++ b/examples/PACKAGES/electrode/madelung/eval.py @@ -1,7 +1,7 @@ #!/usr/env/python3 -import sys import os.path as op +import sys def rel_error(out, ref): @@ -49,5 +49,5 @@ for label, ref, out in out_lines: error = rel_error(out, ref) lines.append(f"{label}: {out:.5f}, {error:.5f}\n") -with open("madelung.txt", 'a') as f: +with open("madelung.txt", "a") as f: f.writelines(lines) diff --git a/examples/PACKAGES/electrode/madelung/in.eta b/examples/PACKAGES/electrode/madelung/in.eta new file mode 100644 index 0000000000..3a45bb1bf5 --- /dev/null +++ b/examples/PACKAGES/electrode/madelung/in.eta @@ -0,0 +1,14 @@ +boundary p p f +kspace_style ewald/electrode 1.0e-8 +kspace_modify slab 8.0 # ew3dc + +include "settings.mod" # styles, computes, groups and fixes + +thermo_style custom step pe c_qbot c_qtop +fix feta all property/atom d_eta ghost on +set group bot d_eta 2.0 +set group top d_eta 2.0 +fix conp bot electrode/conp 0 2 couple top 1 symm on eta d_eta write_inv inv.csv write_vec vec.csv + +run 0 + diff --git a/examples/PACKAGES/electrode/madelung/in.eta_cg b/examples/PACKAGES/electrode/madelung/in.eta_cg new file mode 100644 index 0000000000..5ac8cddf17 --- /dev/null +++ b/examples/PACKAGES/electrode/madelung/in.eta_cg @@ -0,0 +1,14 @@ +boundary p p f +kspace_style ewald/electrode 1.0e-8 +kspace_modify slab 8.0 # ew3dc + +include "settings.mod" # styles, computes, groups and fixes + +thermo_style custom step pe c_qbot c_qtop +fix feta all property/atom d_eta ghost on +set group bot d_eta 0.5 +set group top d_eta 3.0 +fix conp bot electrode/conp 0 2 couple top 1 symm on eta d_eta algo cg 1e-6 + +run 0 + diff --git a/examples/PACKAGES/electrode/madelung/in.eta_mix b/examples/PACKAGES/electrode/madelung/in.eta_mix new file mode 100644 index 0000000000..d00e008fa4 --- /dev/null +++ b/examples/PACKAGES/electrode/madelung/in.eta_mix @@ -0,0 +1,14 @@ +boundary p p f +kspace_style ewald/electrode 1.0e-8 +kspace_modify slab 8.0 # ew3dc + +include "settings.mod" # styles, computes, groups and fixes + +thermo_style custom step pe c_qbot c_qtop +fix feta all property/atom d_eta ghost on +set group bot d_eta 0.5 +set group top d_eta 3.0 +fix conp bot electrode/conp 0 2 couple top 1 symm on eta d_eta write_inv inv.csv write_vec vec.csv + +run 0 + diff --git a/examples/PACKAGES/electrode/madelung/log.19Feb2024.eta.g++.1 b/examples/PACKAGES/electrode/madelung/log.19Feb2024.eta.g++.1 new file mode 100644 index 0000000000..daf0563799 --- /dev/null +++ b/examples/PACKAGES/electrode/madelung/log.19Feb2024.eta.g++.1 @@ -0,0 +1,138 @@ +LAMMPS (21 Nov 2023 - Development - patch_21Nov2023-668-g5b6c0c6b56) + using 1 OpenMP thread(s) per MPI task +boundary p p f +kspace_style ewald/electrode 1.0e-8 +kspace_modify slab 8.0 # ew3dc + +include "settings.mod" # styles, computes, groups and fixes +# set boundary in main script because ffield is periodic +units real +# distribute electrode atoms among all processors: +if "$(extract_setting(world_size) % 2) == 0" then "processors * * 2" + +atom_style full +pair_style lj/cut/coul/long 12 + +read_data "data.au-elyt" +Reading data file ... + orthogonal box = (0 0 -10) to (1 1 10) + 1 by 1 by 1 MPI processor grid + reading atoms ... + 4 atoms +Finding 1-2 1-3 1-4 neighbors ... + special bond factors lj: 0 0 0 + special bond factors coul: 0 0 0 + 0 = max # of 1-2 neighbors + 0 = max # of 1-3 neighbors + 0 = max # of 1-4 neighbors + 1 = max # of special neighbors + special bonds CPU = 0.000 seconds + read_data CPU = 0.003 seconds + +group bot type 1 +1 atoms in group bot +group top type 2 +1 atoms in group top + +# get electrode charges +variable q atom q +compute qbot bot reduce sum v_q +compute qtop top reduce sum v_q + +compute compute_pe all pe +variable vpe equal c_compute_pe +variable charge equal c_qtop +fix fxprint all print 1 "${vpe}, ${charge}" file "out.csv" + +thermo_style custom step pe c_qbot c_qtop +fix feta all property/atom d_eta ghost on +set group bot d_eta 2.0 +Setting atom values ... + 1 settings made for d_eta +set group top d_eta 2.0 +Setting atom values ... + 1 settings made for d_eta +fix conp bot electrode/conp 0 2 couple top 1 symm on eta d_eta write_inv inv.csv write_vec vec.csv +2 atoms in group conp_group + +run 0 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- fix electrode command: + +@article{Ahrens2022 +author = {Ahrens-Iwers, Ludwig J.V. and Janssen, Mahijs and Tee, Shern R. and Mei{\ss}ner, Robert H.}, +doi = {10.1063/5.0099239}, +title = {{ELECTRODE: An electrochemistry package for LAMMPS}}, +journal = {The Journal of Chemical Physics}, +year = {2022} +volume = {157}, +pages = {084801}, +} +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +WARNING: No fixes with time integration, atoms won't move (src/verlet.cpp:60) +Ewald/electrode initialization ... + using 12-bit tables for long-range coulomb (src/kspace.cpp:342) +WARNING: For better accuracy use 'pair_modify table 0' (src/kspace.cpp:365) + G vector (1/distance) = 0.32261103 + estimated absolute RMS force accuracy = 3.8272011e-06 + estimated relative force accuracy = 1.1525502e-08 + KSpace vectors: actual max1d max3d = 52 50 515150 + kxmax kymax kzmax = 1 1 50 +Generated 3 of 3 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 14 + ghost atom cutoff = 14 + binsize = 7, bins = 1 1 3 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair lj/cut/coul/long, perpetual + attributes: half, newton on + pair build: half/bin/newton + stencil: half/bin/3d + bin: standard + (2) fix electrode/conp, perpetual, copy from (1) + attributes: half, newton on + pair build: copy + stencil: none + bin: none +WARNING: Proc sub-domain size < neighbor skin, could lead to lost atoms (src/domain.cpp:965) +139.943964815502, 0.279214485147238 +Per MPI rank memory allocation (min/avg/max) = 144.2 | 144.2 | 144.2 Mbytes + Step PotEng c_qbot c_qtop + 0 139.94396 -0.27921449 0.27921449 +Loop time of 2.191e-06 on 1 procs for 0 steps with 4 atoms + +91.3% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0 | 0 | 0 | 0.0 | 0.00 +Bond | 0 | 0 | 0 | 0.0 | 0.00 +Kspace | 0 | 0 | 0 | 0.0 | 0.00 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 0 | 0 | 0 | 0.0 | 0.00 +Output | 0 | 0 | 0 | 0.0 | 0.00 +Modify | 0 | 0 | 0 | 0.0 | 0.00 +Other | | 2.191e-06 | | |100.00 + +Nlocal: 4 ave 4 max 4 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 3596 ave 3596 max 3596 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 4790 ave 4790 max 4790 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 4790 +Ave neighs/atom = 1197.5 +Ave special neighs/atom = 0 +Neighbor list builds = 0 +Dangerous builds = 0 + +Total wall time: 0:00:00 diff --git a/examples/PACKAGES/electrode/madelung/log.19Feb2024.eta_cg.g++.1 b/examples/PACKAGES/electrode/madelung/log.19Feb2024.eta_cg.g++.1 new file mode 100644 index 0000000000..edb2e434e6 --- /dev/null +++ b/examples/PACKAGES/electrode/madelung/log.19Feb2024.eta_cg.g++.1 @@ -0,0 +1,139 @@ +LAMMPS (21 Nov 2023 - Development - patch_21Nov2023-668-g5b6c0c6b56) + using 1 OpenMP thread(s) per MPI task +boundary p p f +kspace_style ewald/electrode 1.0e-8 +kspace_modify slab 8.0 # ew3dc + +include "settings.mod" # styles, computes, groups and fixes +# set boundary in main script because ffield is periodic +units real +# distribute electrode atoms among all processors: +if "$(extract_setting(world_size) % 2) == 0" then "processors * * 2" + +atom_style full +pair_style lj/cut/coul/long 12 + +read_data "data.au-elyt" +Reading data file ... + orthogonal box = (0 0 -10) to (1 1 10) + 1 by 1 by 1 MPI processor grid + reading atoms ... + 4 atoms +Finding 1-2 1-3 1-4 neighbors ... + special bond factors lj: 0 0 0 + special bond factors coul: 0 0 0 + 0 = max # of 1-2 neighbors + 0 = max # of 1-3 neighbors + 0 = max # of 1-4 neighbors + 1 = max # of special neighbors + special bonds CPU = 0.000 seconds + read_data CPU = 0.003 seconds + +group bot type 1 +1 atoms in group bot +group top type 2 +1 atoms in group top + +# get electrode charges +variable q atom q +compute qbot bot reduce sum v_q +compute qtop top reduce sum v_q + +compute compute_pe all pe +variable vpe equal c_compute_pe +variable charge equal c_qtop +fix fxprint all print 1 "${vpe}, ${charge}" file "out.csv" + +thermo_style custom step pe c_qbot c_qtop +fix feta all property/atom d_eta ghost on +set group bot d_eta 0.5 +Setting atom values ... + 1 settings made for d_eta +set group top d_eta 3.0 +Setting atom values ... + 1 settings made for d_eta +fix conp bot electrode/conp 0 2 couple top 1 symm on eta d_eta algo cg 1e-6 +2 atoms in group conp_group + +run 0 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- fix electrode command: + +@article{Ahrens2022 +author = {Ahrens-Iwers, Ludwig J.V. and Janssen, Mahijs and Tee, Shern R. and Mei{\ss}ner, Robert H.}, +doi = {10.1063/5.0099239}, +title = {{ELECTRODE: An electrochemistry package for LAMMPS}}, +journal = {The Journal of Chemical Physics}, +year = {2022} +volume = {157}, +pages = {084801}, +} +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +WARNING: No fixes with time integration, atoms won't move (src/verlet.cpp:60) +Ewald/electrode initialization ... + using 12-bit tables for long-range coulomb (src/kspace.cpp:342) +WARNING: For better accuracy use 'pair_modify table 0' (src/kspace.cpp:365) + G vector (1/distance) = 0.32261103 + estimated absolute RMS force accuracy = 3.8272011e-06 + estimated relative force accuracy = 1.1525502e-08 + KSpace vectors: actual max1d max3d = 52 50 515150 + kxmax kymax kzmax = 1 1 50 +Generated 3 of 3 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 14 + ghost atom cutoff = 14 + binsize = 7, bins = 1 1 3 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair lj/cut/coul/long, perpetual + attributes: half, newton on + pair build: half/bin/newton + stencil: half/bin/3d + bin: standard + (2) fix electrode/conp, perpetual, copy from (1) + attributes: half, newton on + pair build: copy + stencil: none + bin: none +WARNING: Proc sub-domain size < neighbor skin, could lead to lost atoms (src/domain.cpp:965) +165.519373910316, 0.29521534552818 +Per MPI rank memory allocation (min/avg/max) = 144.2 | 144.2 | 144.2 Mbytes + Step PotEng c_qbot c_qtop + 0 165.51937 -0.29521535 0.29521535 +Loop time of 2.797e-06 on 1 procs for 0 steps with 4 atoms + +71.5% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0 | 0 | 0 | 0.0 | 0.00 +Bond | 0 | 0 | 0 | 0.0 | 0.00 +Kspace | 0 | 0 | 0 | 0.0 | 0.00 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 0 | 0 | 0 | 0.0 | 0.00 +Output | 0 | 0 | 0 | 0.0 | 0.00 +Modify | 0 | 0 | 0 | 0.0 | 0.00 +Other | | 2.797e-06 | | |100.00 + +Nlocal: 4 ave 4 max 4 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 3596 ave 3596 max 3596 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 4790 ave 4790 max 4790 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 4790 +Ave neighs/atom = 1197.5 +Ave special neighs/atom = 0 +Neighbor list builds = 0 +Dangerous builds = 0 + +Average conjugate gradient steps: 1 +Total wall time: 0:00:00 diff --git a/examples/PACKAGES/electrode/madelung/log.19Feb2024.eta_mix.g++.1 b/examples/PACKAGES/electrode/madelung/log.19Feb2024.eta_mix.g++.1 new file mode 100644 index 0000000000..51eda0d870 --- /dev/null +++ b/examples/PACKAGES/electrode/madelung/log.19Feb2024.eta_mix.g++.1 @@ -0,0 +1,138 @@ +LAMMPS (21 Nov 2023 - Development - patch_21Nov2023-668-g5b6c0c6b56) + using 1 OpenMP thread(s) per MPI task +boundary p p f +kspace_style ewald/electrode 1.0e-8 +kspace_modify slab 8.0 # ew3dc + +include "settings.mod" # styles, computes, groups and fixes +# set boundary in main script because ffield is periodic +units real +# distribute electrode atoms among all processors: +if "$(extract_setting(world_size) % 2) == 0" then "processors * * 2" + +atom_style full +pair_style lj/cut/coul/long 12 + +read_data "data.au-elyt" +Reading data file ... + orthogonal box = (0 0 -10) to (1 1 10) + 1 by 1 by 1 MPI processor grid + reading atoms ... + 4 atoms +Finding 1-2 1-3 1-4 neighbors ... + special bond factors lj: 0 0 0 + special bond factors coul: 0 0 0 + 0 = max # of 1-2 neighbors + 0 = max # of 1-3 neighbors + 0 = max # of 1-4 neighbors + 1 = max # of special neighbors + special bonds CPU = 0.000 seconds + read_data CPU = 0.003 seconds + +group bot type 1 +1 atoms in group bot +group top type 2 +1 atoms in group top + +# get electrode charges +variable q atom q +compute qbot bot reduce sum v_q +compute qtop top reduce sum v_q + +compute compute_pe all pe +variable vpe equal c_compute_pe +variable charge equal c_qtop +fix fxprint all print 1 "${vpe}, ${charge}" file "out.csv" + +thermo_style custom step pe c_qbot c_qtop +fix feta all property/atom d_eta ghost on +set group bot d_eta 0.5 +Setting atom values ... + 1 settings made for d_eta +set group top d_eta 3.0 +Setting atom values ... + 1 settings made for d_eta +fix conp bot electrode/conp 0 2 couple top 1 symm on eta d_eta write_inv inv.csv write_vec vec.csv +2 atoms in group conp_group + +run 0 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- fix electrode command: + +@article{Ahrens2022 +author = {Ahrens-Iwers, Ludwig J.V. and Janssen, Mahijs and Tee, Shern R. and Mei{\ss}ner, Robert H.}, +doi = {10.1063/5.0099239}, +title = {{ELECTRODE: An electrochemistry package for LAMMPS}}, +journal = {The Journal of Chemical Physics}, +year = {2022} +volume = {157}, +pages = {084801}, +} +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +WARNING: No fixes with time integration, atoms won't move (src/verlet.cpp:60) +Ewald/electrode initialization ... + using 12-bit tables for long-range coulomb (src/kspace.cpp:342) +WARNING: For better accuracy use 'pair_modify table 0' (src/kspace.cpp:365) + G vector (1/distance) = 0.32261103 + estimated absolute RMS force accuracy = 3.8272011e-06 + estimated relative force accuracy = 1.1525502e-08 + KSpace vectors: actual max1d max3d = 52 50 515150 + kxmax kymax kzmax = 1 1 50 +Generated 3 of 3 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 14 + ghost atom cutoff = 14 + binsize = 7, bins = 1 1 3 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair lj/cut/coul/long, perpetual + attributes: half, newton on + pair build: half/bin/newton + stencil: half/bin/3d + bin: standard + (2) fix electrode/conp, perpetual, copy from (1) + attributes: half, newton on + pair build: copy + stencil: none + bin: none +WARNING: Proc sub-domain size < neighbor skin, could lead to lost atoms (src/domain.cpp:965) +165.519373910316, 0.295215345528172 +Per MPI rank memory allocation (min/avg/max) = 144.2 | 144.2 | 144.2 Mbytes + Step PotEng c_qbot c_qtop + 0 165.51937 -0.29521535 0.29521535 +Loop time of 2.18e-06 on 1 procs for 0 steps with 4 atoms + +91.7% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0 | 0 | 0 | 0.0 | 0.00 +Bond | 0 | 0 | 0 | 0.0 | 0.00 +Kspace | 0 | 0 | 0 | 0.0 | 0.00 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 0 | 0 | 0 | 0.0 | 0.00 +Output | 0 | 0 | 0 | 0.0 | 0.00 +Modify | 0 | 0 | 0 | 0.0 | 0.00 +Other | | 2.18e-06 | | |100.00 + +Nlocal: 4 ave 4 max 4 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 3596 ave 3596 max 3596 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 4790 ave 4790 max 4790 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 4790 +Ave neighs/atom = 1197.5 +Ave special neighs/atom = 0 +Neighbor list builds = 0 +Dangerous builds = 0 + +Total wall time: 0:00:00 diff --git a/examples/PACKAGES/electrode/madelung/plate_cap.py b/examples/PACKAGES/electrode/madelung/plate_cap.py index 62d52fe102..fcca166869 100755 --- a/examples/PACKAGES/electrode/madelung/plate_cap.py +++ b/examples/PACKAGES/electrode/madelung/plate_cap.py @@ -3,7 +3,6 @@ import numpy as np from scipy.special import erf -ETA = 2 SQRT2 = np.sqrt(2) COULOMB = 332.06371 # Coulomb constant in Lammps 'real' units QE2F = 23.060549 @@ -17,14 +16,14 @@ def lattice(length): return np.array(np.meshgrid(x, y)).T.reshape(-1, 2) -def a_element(r): +def a_element(r, eta): """Coulomb contribution of two Gaussians""" - return erf(ETA / SQRT2 * r) / r + return erf(eta * r) / r -def b_element(r, q): +def b_element(r, q, eta): """Coulomb contribution of a Gaussian with a point charge""" - return q * erf(ETA * r) / r + return q * erf(eta * r) / r a = 1 # nearest neighbor distance i.e. lattice constant / sqrt(2) @@ -36,59 +35,65 @@ v = np.array([-0.5, 0.5]) * (QE2F / COULOMB) # distances to images within electrode and to opposite electrode distances = a * np.linalg.norm(lattice(LENGTH), axis=1) -opposite_distances = np.sqrt(np.square(distances) + distance_plates ** 2) +opposite_distances = np.sqrt(np.square(distances) + distance_plates**2) -# self interaction and within original box -A_11 = np.sqrt(2 / np.pi) * ETA -A_12 = erf(ETA * distance_plates / SQRT2) / distance_plates +for name, eta_elec in [("", [2.0, 2.0]), ("_eta_mix", [0.5, 3.0])]: + eta_mix = np.prod(eta_elec) / np.sqrt(np.sum(np.square(eta_elec))) + # self interaction and within original box + A_11 = np.sqrt(2 / np.pi) * eta_elec[0] + A_22 = np.sqrt(2 / np.pi) * eta_elec[1] + A_12 = erf(eta_mix * distance_plates) / distance_plates -# interaction with periodic images -A_11 += 4 * np.sum(a_element(distances)) -A_12 += 4 * np.sum(a_element(opposite_distances)) -A = np.array([[A_11, A_12], [A_12, A_11]]) -inv = np.linalg.inv(A) -e = np.array([1, 1]) -inv -= np.matmul(inv, np.matmul(np.outer(e, e), inv)) / np.dot(e, np.dot(inv, e)) + # interaction with periodic images + A_11 += 4 * np.sum(a_element(distances, eta_elec[0] / SQRT2)) + A_22 += 4 * np.sum(a_element(distances, eta_elec[1] / SQRT2)) + A_12 += 4 * np.sum(a_element(opposite_distances, eta_mix)) + A = np.array([[A_11, A_12], [A_12, A_22]]) + inv = np.linalg.inv(A) + e = np.array([1, 1]) + inv -= np.matmul(inv, np.matmul(np.outer(e, e), inv)) / np.dot(e, np.dot(inv, e)) -# electrode-electrolyte interaction -b = [] -for x in x_elec: - bi = 0 - for y, q in zip(x_elyt, q_elyt): - d = abs(y - x) - bi += b_element(d, q) - image_distances = np.sqrt(np.square(distances) + d ** 2) - bi += 4 * np.sum(b_element(image_distances, q)) - b.append(bi) -b = np.array(b) + # electrode-electrolyte interaction + b = [] + for x, eta in zip(x_elec, eta_elec): + bi = 0 + for y, q in zip(x_elyt, q_elyt): + d = abs(y - x) + bi += b_element(d, q, eta) + image_distances = np.sqrt(np.square(distances) + d**2) + bi += 4 * np.sum(b_element(image_distances, q, eta)) + b.append(bi) + b = np.array(b) -# electrolyte-electrolyte energy -elyt_11 = 4 * np.sum(1 / distances) -distance_elyt = x_elyt[1] - x_elyt[0] -elyt_12 = 1 / distance_elyt + 4 * np.sum( - 1 / np.sqrt(np.square(distances) + distance_elyt ** 2) -) -elyt = np.array([[elyt_11, elyt_12], [elyt_12, elyt_11]]) -energy_elyt = 0.5 * np.dot(q_elyt, np.dot(elyt, q_elyt)) - -# electrode charges and energy -q = np.dot(inv, v - b) -energy = COULOMB * (0.5 * np.dot(q, np.dot(A, q)) + np.dot(b, q) + energy_elyt) - -print( - "length, energy / kcal/mol, q1 / e, q2 / e, inv11 / A, inv12 / A, b1 / e/A, b2 / e/A" -) -print( - ", ".join( - [ - str(LENGTH), - f"{energy:.8f}", - f"{q[0]:.10f}", - f"{q[1]:.10f}", - f"{inv[0, 0]:.10f}", - f"{inv[0, 1]:.10f}", - f"{b[0]:.8f}", - f"{b[1]:.8f}", - ] + # electrolyte-electrolyte energy + elyt_11 = 4 * np.sum(1 / distances) + distance_elyt = x_elyt[1] - x_elyt[0] + elyt_12 = 1 / distance_elyt + 4 * np.sum( + 1 / np.sqrt(np.square(distances) + distance_elyt**2) ) -) + elyt = np.array([[elyt_11, elyt_12], [elyt_12, elyt_11]]) + energy_elyt = 0.5 * np.dot(q_elyt, np.dot(elyt, q_elyt)) + + # electrode charges and energy + q = np.dot(inv, v - b) + energy = COULOMB * (0.5 * np.dot(q, np.dot(A, q)) + np.dot(b, q) + energy_elyt) + + with open(f"plate_cap{name}.csv", "w") as f: + f.write( + "length, energy / kcal/mol, q1 / e, q2 / e, inv11 / A, inv12 / A, b1 / e/A, b2 / e/A\n" + ) + f.write( + ", ".join( + [ + str(LENGTH), + f"{energy:.8f}", + f"{q[0]:.10f}", + f"{q[1]:.10f}", + f"{inv[0, 0]:.10f}", + f"{inv[0, 1]:.10f}", + f"{b[0]:.8f}", + f"{b[1]:.8f}", + ] + ) + + "\n" + ) diff --git a/examples/PACKAGES/electrode/madelung/test.sh b/examples/PACKAGES/electrode/madelung/test.sh index edac04f5b1..a558ee6711 100644 --- a/examples/PACKAGES/electrode/madelung/test.sh +++ b/examples/PACKAGES/electrode/madelung/test.sh @@ -7,17 +7,27 @@ if [ ! -f $lmpbin ]; then fi ref_out="plate_cap.csv" -if [ ! -f $ref_out ]; then +ref_mix_out="plate_cap_eta_mix.csv" +if [ ! -f $ref_out ] || [ ! -f $ref_mix_out ]; then echo "Generating reference data" - python3 plate_cap.py > $ref_out + python3 plate_cap.py fi echo "Running Lammps inputs" +# w/o eta mixing rm -rf madelung.txt && touch madelung.txt -for file in in.*; do +for file in in.eta in.ewald-ew3dc in.ewald-ew2d in.pppm-ew3dc in.cg; do printf "\n$file\n" >> madelung.txt rm -f out.csv inv.csv vec.csv $lmpbin -i $file &> /dev/null python3 eval.py $ref_out out.csv inv.csv vec.csv done + +# with eta mixing +for file in in.eta_mix in.eta_cg; do + printf "\n$file\n" >> madelung.txt + rm -f out.csv inv.csv vec.csv + $lmpbin -i $file &> /dev/null + python3 eval.py $ref_mix_out out.csv inv.csv vec.csv +done cat madelung.txt diff --git a/examples/PACKAGES/mgpt/in.bcc0 b/examples/PACKAGES/mgpt/in.bcc0 index 2e20888fd5..c00a1ba3b2 100644 --- a/examples/PACKAGES/mgpt/in.bcc0 +++ b/examples/PACKAGES/mgpt/in.bcc0 @@ -1,9 +1,7 @@ # script for mgpt t=0 eos in bulk bcc structure -echo screen - -units electron -atom_style atomic +units electron +atom_style atomic # Atomic volume for MGPT potential in a.u. variable atomic_vol equal 121.6 @@ -12,10 +10,10 @@ variable atomic_vol equal 121.6 variable lattice_constant equal (${atomic_vol}*2.0)^(1.0/3.0) # Create bcc lattice with 5x5x5 unit cells (250 atoms) -lattice bcc ${lattice_constant} -region box block 0 5 0 5 0 5 -create_box 1 box -create_atoms 1 box +lattice bcc ${lattice_constant} +region box block 0 5 0 5 0 5 +create_box 1 box +create_atoms 1 box # Define potential for use in simulation pair_style mgpt @@ -26,20 +24,20 @@ pair_style mgpt pair_coeff * * Ta6.8x.mgpt.parmin Ta6.8x.mgpt.potin ${atomic_vol} # Create velocities at 0 K -velocity all create 0.0 87287 +velocity all create 0.0 87287 # Set neighbor list parameters -neighbor 0.1 bin -neigh_modify every 1 delay 0 check yes +neighbor 0.1 bin +neigh_modify every 1 delay 0 check yes # Set up microcanonical integrator -fix 1 all nve +fix 1 all nve # Dump coordinates to file every 50 timesteps -dump id all atom 50 dump.bcc0 +#dump id all atom 50 dump.bcc0 # Output thermodynamical data every 10 timesteps -thermo 10 +thermo 10 # Set output quantities and output format thermo_style custom step vol temp pe etotal press @@ -48,7 +46,7 @@ thermo_style custom step vol temp pe etotal press #thermo_modify format float %15.5e # Run 0 timesteps -run 0 +run 0 # Convert energy to rydbergs and pressure to gpa diff --git a/examples/PACKAGES/mgpt/in.vac0-bcc b/examples/PACKAGES/mgpt/in.vac0-bcc index 529506ab64..5be9e168e9 100644 --- a/examples/PACKAGES/mgpt/in.vac0-bcc +++ b/examples/PACKAGES/mgpt/in.vac0-bcc @@ -1,10 +1,8 @@ # script for mgpt t=0 eos with unrelaxed vacancy in bcc lattice: # input for unrelaxed vacancy formation energy at constant atomic volume -echo screen - -units electron -atom_style atomic +units electron +atom_style atomic # Atomic volume for MGPT potential in a.u. variable atomic_vol equal 121.6 @@ -16,10 +14,10 @@ variable lat_vol equal ${atomic_vol}*249/250 variable lattice_constant equal (${lat_vol}*2.0)^(1.0/3.0) # Create bcc lattice with 5x5x5 unit cells (250 atoms) -lattice bcc ${lattice_constant} -region box block 0 5 0 5 0 5 -create_box 1 box -create_atoms 1 box +lattice bcc ${lattice_constant} +region box block 0 5 0 5 0 5 +create_box 1 box +create_atoms 1 box # Remove central atom from bcc lattice to create vacancy region vacancy sphere 2.5 2.5 2.5 0.1 units lattice @@ -34,20 +32,20 @@ pair_style mgpt pair_coeff * * Ta6.8x.mgpt.parmin Ta6.8x.mgpt.potin ${atomic_vol} # Create velocities at 0 K -velocity all create 0.0 87287 +velocity all create 0.0 87287 # Set neighbor list parameters -neighbor 0.1 bin -neigh_modify every 1 delay 0 check yes +neighbor 0.1 bin +neigh_modify every 1 delay 0 check yes # Set up microcanonical integrator -fix 1 all nve +fix 1 all nve # Dump coordinates to file every 50 timesteps -dump id all atom 50 dump.vac0-bcc +# dump id all atom 50 dump.vac0-bcc # Output thermodynamical data every 10 timesteps -thermo 10 +thermo 10 # Set output quantities and output format thermo_style custom step vol temp pe etotal press @@ -56,7 +54,7 @@ thermo_style custom step vol temp pe etotal press #thermo_modify format float %15.5e # Run 0 timesteps -run 0 +run 0 # Convert energy to rydbergs and pressure to gpa diff --git a/examples/PACKAGES/mgpt/in.vacmin-bcc b/examples/PACKAGES/mgpt/in.vacmin-bcc index 85fc72ff63..abd6cd3a7f 100644 --- a/examples/PACKAGES/mgpt/in.vacmin-bcc +++ b/examples/PACKAGES/mgpt/in.vacmin-bcc @@ -1,10 +1,8 @@ # script for mgpt t=0 eos with relaxed vacancy in bcc structure: # input for relaxed vacancy formation energy at constant pressure -echo screen - -units electron -atom_style atomic +units electron +atom_style atomic # Atomic volume for MGPT potential variable atomic_vol equal 121.863 @@ -16,10 +14,10 @@ variable lat_vol equal ${atomic_vol}*249/250 variable lattice_constant equal (${lat_vol}*2.0)^(1.0/3.0) # Create bcc lattice with 5x5x5 unit cells (250 atoms) -lattice bcc ${lattice_constant} -region box block 0 5 0 5 0 5 -create_box 1 box -create_atoms 1 box +lattice bcc ${lattice_constant} +region box block 0 5 0 5 0 5 +create_box 1 box +create_atoms 1 box # Remove central atom from bcc lattice to create vacancy region vacancy sphere 2.5 2.5 2.5 0.1 units lattice @@ -34,14 +32,14 @@ pair_style mgpt pair_coeff * * Ta6.8x.mgpt.parmin Ta6.8x.mgpt.potin ${atomic_vol} # Set neighbor list parameters -neighbor 0.1 bin -neigh_modify every 1 delay 0 check yes +neighbor 0.1 bin +neigh_modify every 1 delay 0 check yes # Dump coordinates to file every 50 timesteps -dump id all atom 50 dump.vacmin-bcc +# dump id all atom 50 dump.vacmin-bcc # Output thermodynamical data every 10 timesteps -thermo 10 +thermo 10 # Set output quantities and output format thermo_style custom step vol temp pe etotal press diff --git a/examples/PACKAGES/mgpt/log.7Feb24.bcc0.g++.1 b/examples/PACKAGES/mgpt/log.7Feb24.bcc0.g++.1 new file mode 100644 index 0000000000..0425bce75f --- /dev/null +++ b/examples/PACKAGES/mgpt/log.7Feb24.bcc0.g++.1 @@ -0,0 +1,134 @@ +LAMMPS (21 Nov 2023 - Development - patch_21Nov2023-744-g031cef558e-modified) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# script for mgpt t=0 eos in bulk bcc structure + +units electron +atom_style atomic + +# Atomic volume for MGPT potential in a.u. +variable atomic_vol equal 121.6 + +# Derive lattice constant from volume +variable lattice_constant equal (${atomic_vol}*2.0)^(1.0/3.0) +variable lattice_constant equal (121.6*2.0)^(1.0/3.0) + +# Create bcc lattice with 5x5x5 unit cells (250 atoms) +lattice bcc ${lattice_constant} +lattice bcc 6.24196300283154 +Lattice spacing in x,y,z = 6.241963 6.241963 6.241963 +region box block 0 5 0 5 0 5 +create_box 1 box +Created orthogonal box = (0 0 0) to (31.209815 31.209815 31.209815) + 1 by 1 by 1 MPI processor grid +create_atoms 1 box +Created 250 atoms + using lattice units in orthogonal box = (0 0 0) to (31.209815 31.209815 31.209815) + create_atoms CPU = 0.000 seconds + +# Define potential for use in simulation +pair_style mgpt + +# Set parameters for potential: +# parameter files atomic volume +#pair_coeff * * parmin potin ${atomic_vol} +pair_coeff * * Ta6.8x.mgpt.parmin Ta6.8x.mgpt.potin ${atomic_vol} +pair_coeff * * Ta6.8x.mgpt.parmin Ta6.8x.mgpt.potin 121.6 +Reading potential file Ta6.8x.mgpt.potin with DATE: 2015-07-30 + +# Create velocities at 0 K +velocity all create 0.0 87287 + +# Set neighbor list parameters +neighbor 0.1 bin +neigh_modify every 1 delay 0 check yes + +# Set up microcanonical integrator +fix 1 all nve + +# Dump coordinates to file every 50 timesteps +#dump id all atom 50 dump.bcc0 + +# Output thermodynamical data every 10 timesteps +thermo 10 + +# Set output quantities and output format +thermo_style custom step vol temp pe etotal press + +## Example: Output floating point number with 5 digits exponential notation. +#thermo_modify format float %15.5e + +# Run 0 timesteps +run 0 +Generated 0 of 0 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 13.161827 + ghost atom cutoff = 13.161827 + binsize = 6.5809134, bins = 5 5 5 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair mgpt, perpetual + attributes: full, newton on, ghost + pair build: full/bin/ghost + stencil: full/ghost/bin/3d + bin: standard + (2) pair mgpt, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 3.755 | 3.755 | 3.755 Mbytes + Step Volume Temp PotEng TotEng Press + 0 30400 0 -74.412503 -74.412503 -1.1594626e+09 +Loop time of 1.019e-06 on 1 procs for 0 steps with 250 atoms + +98.1% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0 | 0 | 0 | 0.0 | 0.00 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 0 | 0 | 0 | 0.0 | 0.00 +Output | 0 | 0 | 0 | 0.0 | 0.00 +Modify | 0 | 0 | 0 | 0.0 | 0.00 +Other | | 1.019e-06 | | |100.00 + +Nlocal: 250 ave 250 max 250 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 1479 ave 1479 max 1479 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 8000 ave 8000 max 8000 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +FullNghs: 16000 ave 16000 max 16000 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 16000 +Ave neighs/atom = 64 +Neighbor list builds = 0 +Dangerous builds = 0 + +# Convert energy to rydbergs and pressure to gpa + +variable natoms equal "count(all)" +variable voltot equal "vol" +variable atvol equal "v_voltot/v_natoms" +variable etot equal "2.0*pe" +variable etotry equal "v_etot/v_natoms" +variable ptot equal "press" +variable ptotgpa equal "v_ptot/1.0e+09" + +print "number of atoms = ${natoms}" +number of atoms = 250 +print "atomic volume (a.u.) = ${atvol}" +atomic volume (a.u.) = 121.6 +print "total energy (ry/atom) = ${etotry}" +total energy (ry/atom) = -0.59530002488734 +print "pressure (gpa) = ${ptotgpa}" +pressure (gpa) = -1.15946260887554 +print "${natoms} ${atvol} ${etot} ${ptotgpa}" +250 121.6 -148.825006221835 -1.15946260887554 +print "${atvol} ${etotry} ${ptotgpa}" +121.6 -0.59530002488734 -1.15946260887554 +Total wall time: 0:00:00 diff --git a/examples/PACKAGES/mgpt/log.7Feb24.bcc0.g++.4 b/examples/PACKAGES/mgpt/log.7Feb24.bcc0.g++.4 new file mode 100644 index 0000000000..03195ca9c3 --- /dev/null +++ b/examples/PACKAGES/mgpt/log.7Feb24.bcc0.g++.4 @@ -0,0 +1,134 @@ +LAMMPS (21 Nov 2023 - Development - patch_21Nov2023-744-g031cef558e-modified) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# script for mgpt t=0 eos in bulk bcc structure + +units electron +atom_style atomic + +# Atomic volume for MGPT potential in a.u. +variable atomic_vol equal 121.6 + +# Derive lattice constant from volume +variable lattice_constant equal (${atomic_vol}*2.0)^(1.0/3.0) +variable lattice_constant equal (121.6*2.0)^(1.0/3.0) + +# Create bcc lattice with 5x5x5 unit cells (250 atoms) +lattice bcc ${lattice_constant} +lattice bcc 6.24196300283154 +Lattice spacing in x,y,z = 6.241963 6.241963 6.241963 +region box block 0 5 0 5 0 5 +create_box 1 box +Created orthogonal box = (0 0 0) to (31.209815 31.209815 31.209815) + 1 by 2 by 2 MPI processor grid +create_atoms 1 box +Created 250 atoms + using lattice units in orthogonal box = (0 0 0) to (31.209815 31.209815 31.209815) + create_atoms CPU = 0.000 seconds + +# Define potential for use in simulation +pair_style mgpt + +# Set parameters for potential: +# parameter files atomic volume +#pair_coeff * * parmin potin ${atomic_vol} +pair_coeff * * Ta6.8x.mgpt.parmin Ta6.8x.mgpt.potin ${atomic_vol} +pair_coeff * * Ta6.8x.mgpt.parmin Ta6.8x.mgpt.potin 121.6 +Reading potential file Ta6.8x.mgpt.potin with DATE: 2015-07-30 + +# Create velocities at 0 K +velocity all create 0.0 87287 + +# Set neighbor list parameters +neighbor 0.1 bin +neigh_modify every 1 delay 0 check yes + +# Set up microcanonical integrator +fix 1 all nve + +# Dump coordinates to file every 50 timesteps +#dump id all atom 50 dump.bcc0 + +# Output thermodynamical data every 10 timesteps +thermo 10 + +# Set output quantities and output format +thermo_style custom step vol temp pe etotal press + +## Example: Output floating point number with 5 digits exponential notation. +#thermo_modify format float %15.5e + +# Run 0 timesteps +run 0 +Generated 0 of 0 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 13.161827 + ghost atom cutoff = 13.161827 + binsize = 6.5809134, bins = 5 5 5 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair mgpt, perpetual + attributes: full, newton on, ghost + pair build: full/bin/ghost + stencil: full/ghost/bin/3d + bin: standard + (2) pair mgpt, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 3.73 | 3.73 | 3.73 Mbytes + Step Volume Temp PotEng TotEng Press + 0 30400 0 -74.412503 -74.412503 -1.1594626e+09 +Loop time of 3.56525e-06 on 4 procs for 0 steps with 250 atoms + +119.2% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0 | 0 | 0 | 0.0 | 0.00 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 0 | 0 | 0 | 0.0 | 0.00 +Output | 0 | 0 | 0 | 0.0 | 0.00 +Modify | 0 | 0 | 0 | 0.0 | 0.00 +Other | | 3.565e-06 | | |100.00 + +Nlocal: 62.5 ave 65 max 60 min +Histogram: 2 0 0 0 0 0 0 0 0 2 +Nghost: 868.5 ave 871 max 866 min +Histogram: 2 0 0 0 0 0 0 0 0 2 +Neighs: 2000 ave 2110 max 1890 min +Histogram: 2 0 0 0 0 0 0 0 0 2 +FullNghs: 4000 ave 4160 max 3840 min +Histogram: 2 0 0 0 0 0 0 0 0 2 + +Total # of neighbors = 16000 +Ave neighs/atom = 64 +Neighbor list builds = 0 +Dangerous builds = 0 + +# Convert energy to rydbergs and pressure to gpa + +variable natoms equal "count(all)" +variable voltot equal "vol" +variable atvol equal "v_voltot/v_natoms" +variable etot equal "2.0*pe" +variable etotry equal "v_etot/v_natoms" +variable ptot equal "press" +variable ptotgpa equal "v_ptot/1.0e+09" + +print "number of atoms = ${natoms}" +number of atoms = 250 +print "atomic volume (a.u.) = ${atvol}" +atomic volume (a.u.) = 121.6 +print "total energy (ry/atom) = ${etotry}" +total energy (ry/atom) = -0.595300024887348 +print "pressure (gpa) = ${ptotgpa}" +pressure (gpa) = -1.15946260887575 +print "${natoms} ${atvol} ${etot} ${ptotgpa}" +250 121.6 -148.825006221837 -1.15946260887575 +print "${atvol} ${etotry} ${ptotgpa}" +121.6 -0.595300024887348 -1.15946260887575 +Total wall time: 0:00:00 diff --git a/examples/PACKAGES/mgpt/log.7Feb24.vac0-bcc.g++.1 b/examples/PACKAGES/mgpt/log.7Feb24.vac0-bcc.g++.1 new file mode 100644 index 0000000000..88d7e11a8b --- /dev/null +++ b/examples/PACKAGES/mgpt/log.7Feb24.vac0-bcc.g++.1 @@ -0,0 +1,144 @@ +LAMMPS (21 Nov 2023 - Development - patch_21Nov2023-744-g031cef558e-modified) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# script for mgpt t=0 eos with unrelaxed vacancy in bcc lattice: +# input for unrelaxed vacancy formation energy at constant atomic volume + +units electron +atom_style atomic + +# Atomic volume for MGPT potential in a.u. +variable atomic_vol equal 121.6 + +# Derive effective lattice volume from atomic volume for 249-site cell +variable lat_vol equal ${atomic_vol}*249/250 +variable lat_vol equal 121.6*249/250 + +# Derive lattice constant from lattice volume +variable lattice_constant equal (${lat_vol}*2.0)^(1.0/3.0) +variable lattice_constant equal (121.1136*2.0)^(1.0/3.0) + +# Create bcc lattice with 5x5x5 unit cells (250 atoms) +lattice bcc ${lattice_constant} +lattice bcc 6.23362926394575 +Lattice spacing in x,y,z = 6.2336293 6.2336293 6.2336293 +region box block 0 5 0 5 0 5 +create_box 1 box +Created orthogonal box = (0 0 0) to (31.168146 31.168146 31.168146) + 1 by 1 by 1 MPI processor grid +create_atoms 1 box +Created 250 atoms + using lattice units in orthogonal box = (0 0 0) to (31.168146 31.168146 31.168146) + create_atoms CPU = 0.000 seconds + +# Remove central atom from bcc lattice to create vacancy +region vacancy sphere 2.5 2.5 2.5 0.1 units lattice +delete_atoms region vacancy +Deleted 1 atoms, new total = 249 + +# Define potential for use in simulation +pair_style mgpt + +# Set parameters for potential: +# parameter files atomic volume +#pair_coeff * * parmin potin ${atomic_vol} +pair_coeff * * Ta6.8x.mgpt.parmin Ta6.8x.mgpt.potin ${atomic_vol} +pair_coeff * * Ta6.8x.mgpt.parmin Ta6.8x.mgpt.potin 121.6 +Reading potential file Ta6.8x.mgpt.potin with DATE: 2015-07-30 + +# Create velocities at 0 K +velocity all create 0.0 87287 + +# Set neighbor list parameters +neighbor 0.1 bin +neigh_modify every 1 delay 0 check yes + +# Set up microcanonical integrator +fix 1 all nve + +# Dump coordinates to file every 50 timesteps +# dump id all atom 50 dump.vac0-bcc + +# Output thermodynamical data every 10 timesteps +thermo 10 + +# Set output quantities and output format +thermo_style custom step vol temp pe etotal press + +## Example: Output floating point number with 5 digits exponential notation. +#thermo_modify format float %15.5e + +# Run 0 timesteps +run 0 +Generated 0 of 0 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 13.161827 + ghost atom cutoff = 13.161827 + binsize = 6.5809134, bins = 5 5 5 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair mgpt, perpetual + attributes: full, newton on, ghost + pair build: full/bin/ghost + stencil: full/ghost/bin/3d + bin: standard + (2) pair mgpt, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 3.755 | 3.755 | 3.755 Mbytes + Step Volume Temp PotEng TotEng Press + 0 30278.4 0 -73.996387 -73.996387 -6.3426731e+08 +Loop time of 1.016e-06 on 1 procs for 0 steps with 249 atoms + +98.4% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0 | 0 | 0 | 0.0 | 0.00 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 0 | 0 | 0 | 0.0 | 0.00 +Output | 0 | 0 | 0 | 0.0 | 0.00 +Modify | 0 | 0 | 0 | 0.0 | 0.00 +Other | | 1.016e-06 | | |100.00 + +Nlocal: 249 ave 249 max 249 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 1479 ave 1479 max 1479 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 7936 ave 7936 max 7936 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +FullNghs: 15872 ave 15872 max 15872 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 15872 +Ave neighs/atom = 63.742972 +Neighbor list builds = 0 +Dangerous builds = 0 + +# Convert energy to rydbergs and pressure to gpa + +variable natoms equal "count(all)" +variable voltot equal "vol" +variable atvol equal "v_voltot/v_natoms" +variable etot equal "2.0*pe" +variable etotry equal "v_etot/v_natoms" +variable ptot equal "press" +variable ptotgpa equal "v_ptot/1.0e+09" + +print "number of atoms = ${natoms}" +number of atoms = 249 +print "atomic volume (a.u.) = ${atvol}" +atomic volume (a.u.) = 121.6 +print "total energy (ry/atom) = ${etotry}" +total energy (ry/atom) = -0.594348488796036 +print "pressure (gpa) = ${ptotgpa}" +pressure (gpa) = -0.634267307139553 +print "${natoms} ${atvol} ${etot} ${ptotgpa}" +249 121.6 -147.992773710213 -0.634267307139553 +print "${atvol} ${etotry} ${ptotgpa}" +121.6 -0.594348488796036 -0.634267307139553 +Total wall time: 0:00:00 diff --git a/examples/PACKAGES/mgpt/log.7Feb24.vac0-bcc.g++.4 b/examples/PACKAGES/mgpt/log.7Feb24.vac0-bcc.g++.4 new file mode 100644 index 0000000000..f78e0f1f4f --- /dev/null +++ b/examples/PACKAGES/mgpt/log.7Feb24.vac0-bcc.g++.4 @@ -0,0 +1,144 @@ +LAMMPS (21 Nov 2023 - Development - patch_21Nov2023-744-g031cef558e-modified) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# script for mgpt t=0 eos with unrelaxed vacancy in bcc lattice: +# input for unrelaxed vacancy formation energy at constant atomic volume + +units electron +atom_style atomic + +# Atomic volume for MGPT potential in a.u. +variable atomic_vol equal 121.6 + +# Derive effective lattice volume from atomic volume for 249-site cell +variable lat_vol equal ${atomic_vol}*249/250 +variable lat_vol equal 121.6*249/250 + +# Derive lattice constant from lattice volume +variable lattice_constant equal (${lat_vol}*2.0)^(1.0/3.0) +variable lattice_constant equal (121.1136*2.0)^(1.0/3.0) + +# Create bcc lattice with 5x5x5 unit cells (250 atoms) +lattice bcc ${lattice_constant} +lattice bcc 6.23362926394575 +Lattice spacing in x,y,z = 6.2336293 6.2336293 6.2336293 +region box block 0 5 0 5 0 5 +create_box 1 box +Created orthogonal box = (0 0 0) to (31.168146 31.168146 31.168146) + 1 by 2 by 2 MPI processor grid +create_atoms 1 box +Created 250 atoms + using lattice units in orthogonal box = (0 0 0) to (31.168146 31.168146 31.168146) + create_atoms CPU = 0.000 seconds + +# Remove central atom from bcc lattice to create vacancy +region vacancy sphere 2.5 2.5 2.5 0.1 units lattice +delete_atoms region vacancy +Deleted 1 atoms, new total = 249 + +# Define potential for use in simulation +pair_style mgpt + +# Set parameters for potential: +# parameter files atomic volume +#pair_coeff * * parmin potin ${atomic_vol} +pair_coeff * * Ta6.8x.mgpt.parmin Ta6.8x.mgpt.potin ${atomic_vol} +pair_coeff * * Ta6.8x.mgpt.parmin Ta6.8x.mgpt.potin 121.6 +Reading potential file Ta6.8x.mgpt.potin with DATE: 2015-07-30 + +# Create velocities at 0 K +velocity all create 0.0 87287 + +# Set neighbor list parameters +neighbor 0.1 bin +neigh_modify every 1 delay 0 check yes + +# Set up microcanonical integrator +fix 1 all nve + +# Dump coordinates to file every 50 timesteps +# dump id all atom 50 dump.vac0-bcc + +# Output thermodynamical data every 10 timesteps +thermo 10 + +# Set output quantities and output format +thermo_style custom step vol temp pe etotal press + +## Example: Output floating point number with 5 digits exponential notation. +#thermo_modify format float %15.5e + +# Run 0 timesteps +run 0 +Generated 0 of 0 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 13.161827 + ghost atom cutoff = 13.161827 + binsize = 6.5809134, bins = 5 5 5 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair mgpt, perpetual + attributes: full, newton on, ghost + pair build: full/bin/ghost + stencil: full/ghost/bin/3d + bin: standard + (2) pair mgpt, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 3.73 | 3.73 | 3.73 Mbytes + Step Volume Temp PotEng TotEng Press + 0 30278.4 0 -73.996387 -73.996387 -6.3426731e+08 +Loop time of 2.64725e-06 on 4 procs for 0 steps with 249 atoms + +37.8% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0 | 0 | 0 | 0.0 | 0.00 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 0 | 0 | 0 | 0.0 | 0.00 +Output | 0 | 0 | 0 | 0.0 | 0.00 +Modify | 0 | 0 | 0 | 0.0 | 0.00 +Other | | 2.647e-06 | | |100.00 + +Nlocal: 62.25 ave 65 max 60 min +Histogram: 2 0 0 0 0 0 0 0 1 1 +Nghost: 867.75 ave 870 max 865 min +Histogram: 1 0 1 0 0 0 0 0 0 2 +Neighs: 1984 ave 2099 max 1875 min +Histogram: 2 0 0 0 0 0 0 0 0 2 +FullNghs: 3968 ave 4149 max 3825 min +Histogram: 2 0 0 0 0 0 0 1 0 1 + +Total # of neighbors = 15872 +Ave neighs/atom = 63.742972 +Neighbor list builds = 0 +Dangerous builds = 0 + +# Convert energy to rydbergs and pressure to gpa + +variable natoms equal "count(all)" +variable voltot equal "vol" +variable atvol equal "v_voltot/v_natoms" +variable etot equal "2.0*pe" +variable etotry equal "v_etot/v_natoms" +variable ptot equal "press" +variable ptotgpa equal "v_ptot/1.0e+09" + +print "number of atoms = ${natoms}" +number of atoms = 249 +print "atomic volume (a.u.) = ${atvol}" +atomic volume (a.u.) = 121.6 +print "total energy (ry/atom) = ${etotry}" +total energy (ry/atom) = -0.594348488795831 +print "pressure (gpa) = ${ptotgpa}" +pressure (gpa) = -0.634267307088164 +print "${natoms} ${atvol} ${etot} ${ptotgpa}" +249 121.6 -147.992773710162 -0.634267307088164 +print "${atvol} ${etotry} ${ptotgpa}" +121.6 -0.594348488795831 -0.634267307088164 +Total wall time: 0:00:00 diff --git a/examples/PACKAGES/mgpt/log.7Feb24.vacmin-bcc.g++.1 b/examples/PACKAGES/mgpt/log.7Feb24.vacmin-bcc.g++.1 new file mode 100644 index 0000000000..0e68bd0802 --- /dev/null +++ b/examples/PACKAGES/mgpt/log.7Feb24.vacmin-bcc.g++.1 @@ -0,0 +1,162 @@ +LAMMPS (21 Nov 2023 - Development - patch_21Nov2023-744-g031cef558e-modified) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# script for mgpt t=0 eos with relaxed vacancy in bcc structure: +# input for relaxed vacancy formation energy at constant pressure + +units electron +atom_style atomic + +# Atomic volume for MGPT potential +variable atomic_vol equal 121.863 + +# Derive effective lattice volume from atomic volume for 249-site cell +variable lat_vol equal ${atomic_vol}*249/250 +variable lat_vol equal 121.863*249/250 + +# Derive lattice constant from lattice volume +variable lattice_constant equal (${lat_vol}*2.0)^(1.0/3.0) +variable lattice_constant equal (121.375548*2.0)^(1.0/3.0) + +# Create bcc lattice with 5x5x5 unit cells (250 atoms) +lattice bcc ${lattice_constant} +lattice bcc 6.23812011912273 +Lattice spacing in x,y,z = 6.2381201 6.2381201 6.2381201 +region box block 0 5 0 5 0 5 +create_box 1 box +Created orthogonal box = (0 0 0) to (31.190601 31.190601 31.190601) + 1 by 1 by 1 MPI processor grid +create_atoms 1 box +Created 250 atoms + using lattice units in orthogonal box = (0 0 0) to (31.190601 31.190601 31.190601) + create_atoms CPU = 0.000 seconds + +# Remove central atom from bcc lattice to create vacancy +region vacancy sphere 2.5 2.5 2.5 0.1 units lattice +delete_atoms region vacancy +Deleted 1 atoms, new total = 249 + +# Define potential for use in simulation +pair_style mgpt + +# Set parameters for potential: +# parameter files atomic volume +#pair_coeff * * parmin potin ${atomic_vol} +pair_coeff * * Ta6.8x.mgpt.parmin Ta6.8x.mgpt.potin ${atomic_vol} +pair_coeff * * Ta6.8x.mgpt.parmin Ta6.8x.mgpt.potin 121.863 +Reading potential file Ta6.8x.mgpt.potin with DATE: 2015-07-30 + +# Set neighbor list parameters +neighbor 0.1 bin +neigh_modify every 1 delay 0 check yes + +# Dump coordinates to file every 50 timesteps +# dump id all atom 50 dump.vacmin-bcc + +# Output thermodynamical data every 10 timesteps +thermo 10 + +# Set output quantities and output format +thermo_style custom step vol temp pe etotal press + +## Example: Output floating point number with 5 digits exponential notation. +#thermo_modify format float %15.5e + +# minimize total energy +min_style cg +minimize 1.0e-10 1.0e-10 5000 10000 +Generated 0 of 0 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 13.171237 + ghost atom cutoff = 13.171237 + binsize = 6.5856184, bins = 5 5 5 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair mgpt, perpetual + attributes: full, newton on, ghost + pair build: full/bin/ghost + stencil: full/ghost/bin/3d + bin: standard + (2) pair mgpt, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 4.88 | 4.88 | 4.88 Mbytes + Step Volume Temp PotEng TotEng Press + 0 30343.887 0 -73.994511 -73.994511 -1.0504398e+09 + 10 30343.887 0 -74.002332 -74.002332 -1.107516e+09 + 20 30343.887 0 -74.00485 -74.00485 -1.1316373e+09 + 30 30343.887 0 -74.005762 -74.005762 -1.143304e+09 + 40 30343.887 0 -74.006116 -74.006116 -1.149395e+09 + 50 30343.887 0 -74.006262 -74.006262 -1.1527914e+09 + 60 30343.887 0 -74.006323 -74.006323 -1.1547677e+09 + 70 30343.887 0 -74.00635 -74.00635 -1.1559529e+09 + 80 30343.887 0 -74.006361 -74.006361 -1.1566763e+09 + 90 30343.887 0 -74.006366 -74.006366 -1.1571256e+09 + 100 30343.887 0 -74.006369 -74.006369 -1.1574093e+09 + 110 30343.887 0 -74.00637 -74.00637 -1.1575908e+09 + 120 30343.887 0 -74.00637 -74.00637 -1.1577083e+09 + 130 30343.887 0 -74.00637 -74.00637 -1.1577849e+09 + 139 30343.887 0 -74.006371 -74.006371 -1.1578311e+09 +Loop time of 2.58636 on 1 procs for 139 steps with 249 atoms + +90.5% CPU use with 1 MPI tasks x 1 OpenMP threads + +Minimization stats: + Stopping criterion = energy tolerance + Energy initial, next-to-last, final = + -73.9945109564338 -74.0063705487283 -74.0063705557007 + Force two-norm initial, final = 0.036622686 8.090814e-05 + Force max component initial, final = 0.0073094815 8.0524205e-06 + Final line search alpha, max atom move = 1 8.0524205e-06 + Iterations, force evaluations = 139 139 + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 2.5671 | 2.5671 | 2.5671 | 0.0 | 99.26 +Neigh | 0.015241 | 0.015241 | 0.015241 | 0.0 | 0.59 +Comm | 0.001446 | 0.001446 | 0.001446 | 0.0 | 0.06 +Output | 0.00038428 | 0.00038428 | 0.00038428 | 0.0 | 0.01 +Modify | 0 | 0 | 0 | 0.0 | 0.00 +Other | | 0.002161 | | | 0.08 + +Nlocal: 249 ave 249 max 249 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 1479 ave 1479 max 1479 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 7936 ave 7936 max 7936 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +FullNghs: 15872 ave 15872 max 15872 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 15872 +Ave neighs/atom = 63.742972 +Neighbor list builds = 4 +Dangerous builds = 0 + +# Convert energy to rydbergs and pressure to gpa + +variable natoms equal "count(all)" +variable voltot equal "vol" +variable atvol equal "v_voltot/v_natoms" +variable etot equal "2.0*pe" +variable etotry equal "v_etot/v_natoms" +variable ptot equal "press" +variable ptotgpa equal "v_ptot/1.0e+09" + +print "number of atoms = ${natoms}" +number of atoms = 249 +print "atomic volume (a.u.) = ${atvol}" +atomic volume (a.u.) = 121.863 +print "total energy (ry/atom) = ${etotry}" +total energy (ry/atom) = -0.594428679162253 +print "pressure (gpa) = ${ptotgpa}" +pressure (gpa) = -1.15783109516516 +print "${natoms} ${atvol} ${etot} ${ptotgpa}" +249 121.863 -148.012741111401 -1.15783109516516 +print "${atvol} ${etotry} ${ptotgpa}" +121.863 -0.594428679162253 -1.15783109516516 +Total wall time: 0:00:02 diff --git a/examples/PACKAGES/mgpt/log.7Feb24.vacmin-bcc.g++.4 b/examples/PACKAGES/mgpt/log.7Feb24.vacmin-bcc.g++.4 new file mode 100644 index 0000000000..50af5c02e1 --- /dev/null +++ b/examples/PACKAGES/mgpt/log.7Feb24.vacmin-bcc.g++.4 @@ -0,0 +1,162 @@ +LAMMPS (21 Nov 2023 - Development - patch_21Nov2023-744-g031cef558e-modified) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# script for mgpt t=0 eos with relaxed vacancy in bcc structure: +# input for relaxed vacancy formation energy at constant pressure + +units electron +atom_style atomic + +# Atomic volume for MGPT potential +variable atomic_vol equal 121.863 + +# Derive effective lattice volume from atomic volume for 249-site cell +variable lat_vol equal ${atomic_vol}*249/250 +variable lat_vol equal 121.863*249/250 + +# Derive lattice constant from lattice volume +variable lattice_constant equal (${lat_vol}*2.0)^(1.0/3.0) +variable lattice_constant equal (121.375548*2.0)^(1.0/3.0) + +# Create bcc lattice with 5x5x5 unit cells (250 atoms) +lattice bcc ${lattice_constant} +lattice bcc 6.23812011912273 +Lattice spacing in x,y,z = 6.2381201 6.2381201 6.2381201 +region box block 0 5 0 5 0 5 +create_box 1 box +Created orthogonal box = (0 0 0) to (31.190601 31.190601 31.190601) + 1 by 2 by 2 MPI processor grid +create_atoms 1 box +Created 250 atoms + using lattice units in orthogonal box = (0 0 0) to (31.190601 31.190601 31.190601) + create_atoms CPU = 0.000 seconds + +# Remove central atom from bcc lattice to create vacancy +region vacancy sphere 2.5 2.5 2.5 0.1 units lattice +delete_atoms region vacancy +Deleted 1 atoms, new total = 249 + +# Define potential for use in simulation +pair_style mgpt + +# Set parameters for potential: +# parameter files atomic volume +#pair_coeff * * parmin potin ${atomic_vol} +pair_coeff * * Ta6.8x.mgpt.parmin Ta6.8x.mgpt.potin ${atomic_vol} +pair_coeff * * Ta6.8x.mgpt.parmin Ta6.8x.mgpt.potin 121.863 +Reading potential file Ta6.8x.mgpt.potin with DATE: 2015-07-30 + +# Set neighbor list parameters +neighbor 0.1 bin +neigh_modify every 1 delay 0 check yes + +# Dump coordinates to file every 50 timesteps +# dump id all atom 50 dump.vacmin-bcc + +# Output thermodynamical data every 10 timesteps +thermo 10 + +# Set output quantities and output format +thermo_style custom step vol temp pe etotal press + +## Example: Output floating point number with 5 digits exponential notation. +#thermo_modify format float %15.5e + +# minimize total energy +min_style cg +minimize 1.0e-10 1.0e-10 5000 10000 +Generated 0 of 0 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 13.171237 + ghost atom cutoff = 13.171237 + binsize = 6.5856184, bins = 5 5 5 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair mgpt, perpetual + attributes: full, newton on, ghost + pair build: full/bin/ghost + stencil: full/ghost/bin/3d + bin: standard + (2) pair mgpt, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 4.855 | 4.855 | 4.855 Mbytes + Step Volume Temp PotEng TotEng Press + 0 30343.887 0 -73.994511 -73.994511 -1.0504398e+09 + 10 30343.887 0 -74.002332 -74.002332 -1.107516e+09 + 20 30343.887 0 -74.00485 -74.00485 -1.1316373e+09 + 30 30343.887 0 -74.005762 -74.005762 -1.143304e+09 + 40 30343.887 0 -74.006116 -74.006116 -1.149395e+09 + 50 30343.887 0 -74.006262 -74.006262 -1.1527914e+09 + 60 30343.887 0 -74.006323 -74.006323 -1.1547677e+09 + 70 30343.887 0 -74.00635 -74.00635 -1.1559529e+09 + 80 30343.887 0 -74.006361 -74.006361 -1.1566763e+09 + 90 30343.887 0 -74.006366 -74.006366 -1.1571256e+09 + 100 30343.887 0 -74.006369 -74.006369 -1.1574093e+09 + 110 30343.887 0 -74.00637 -74.00637 -1.1575908e+09 + 120 30343.887 0 -74.00637 -74.00637 -1.1577083e+09 + 130 30343.887 0 -74.00637 -74.00637 -1.1577849e+09 + 139 30343.887 0 -74.006371 -74.006371 -1.1578311e+09 +Loop time of 0.972735 on 4 procs for 139 steps with 249 atoms + +89.3% CPU use with 4 MPI tasks x 1 OpenMP threads + +Minimization stats: + Stopping criterion = energy tolerance + Energy initial, next-to-last, final = + -73.9945109564331 -74.0063705487423 -74.0063705556773 + Force two-norm initial, final = 0.036622686 8.090814e-05 + Force max component initial, final = 0.0073094815 8.0524207e-06 + Final line search alpha, max atom move = 1 8.0524207e-06 + Iterations, force evaluations = 139 139 + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.9418 | 0.94514 | 0.9488 | 0.3 | 97.16 +Neigh | 0.0083827 | 0.0084423 | 0.0085002 | 0.0 | 0.87 +Comm | 0.011833 | 0.015482 | 0.01882 | 2.0 | 1.59 +Output | 0.0002579 | 0.00029089 | 0.000389 | 0.0 | 0.03 +Modify | 0 | 0 | 0 | 0.0 | 0.00 +Other | | 0.003376 | | | 0.35 + +Nlocal: 62.25 ave 68 max 59 min +Histogram: 1 1 0 1 0 0 0 0 0 1 +Nghost: 867.75 ave 871 max 862 min +Histogram: 1 0 0 0 0 0 1 0 1 1 +Neighs: 1984 ave 2211 max 1853 min +Histogram: 1 1 1 0 0 0 0 0 0 1 +FullNghs: 3968 ave 4334 max 3761 min +Histogram: 1 1 0 1 0 0 0 0 0 1 + +Total # of neighbors = 15872 +Ave neighs/atom = 63.742972 +Neighbor list builds = 4 +Dangerous builds = 0 + +# Convert energy to rydbergs and pressure to gpa + +variable natoms equal "count(all)" +variable voltot equal "vol" +variable atvol equal "v_voltot/v_natoms" +variable etot equal "2.0*pe" +variable etotry equal "v_etot/v_natoms" +variable ptot equal "press" +variable ptotgpa equal "v_ptot/1.0e+09" + +print "number of atoms = ${natoms}" +number of atoms = 249 +print "atomic volume (a.u.) = ${atvol}" +atomic volume (a.u.) = 121.863 +print "total energy (ry/atom) = ${etotry}" +total energy (ry/atom) = -0.594428679162068 +print "pressure (gpa) = ${ptotgpa}" +pressure (gpa) = -1.15783109519336 +print "${natoms} ${atvol} ${etot} ${ptotgpa}" +249 121.863 -148.012741111355 -1.15783109519336 +print "${atvol} ${etotry} ${ptotgpa}" +121.863 -0.594428679162068 -1.15783109519336 +Total wall time: 0:00:00 diff --git a/examples/PACKAGES/mgpt/log.bcc0 b/examples/PACKAGES/mgpt/log.bcc0 deleted file mode 100644 index 4e4df5da4f..0000000000 --- a/examples/PACKAGES/mgpt/log.bcc0 +++ /dev/null @@ -1,53 +0,0 @@ -LAMMPS (23 Oct 2015) -# script for mgpt t=0 eos in bulk bcc structure - -echo screen -Lattice spacing in x,y,z = 6.24196 6.24196 6.24196 -Created orthogonal box = (0 0 0) to (31.2098 31.2098 31.2098) - 1 by 1 by 1 MPI processor grid -Created 250 atoms -Reading potential file Ta6.8x.mgpt.potin with DATE: 2015-07-30 -Neighbor list info ... - 2 neighbor list requests - update every 1 steps, delay 0 steps, check yes - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 13.1618 - ghost atom cutoff = 13.1618 - binsize = 6.58091 -> bins = 5 5 5 -Memory usage per processor = 3.54482 Mbytes -Step Volume Temp PotEng TotEng Press - 0 30400 0 -74.412503 -74.412503 -1.1594626e+09 -Loop time of 1.90735e-06 on 1 procs for 0 steps with 250 atoms - -0.0% CPU use with 1 MPI tasks x no OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 0 | 0 | 0 | 0.0 | 0.00 -Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0 | 0 | 0 | 0.0 | 0.00 -Output | 0 | 0 | 0 | 0.0 | 0.00 -Modify | 0 | 0 | 0 | 0.0 | 0.00 -Other | | 1.907e-06 | | |100.00 - -Nlocal: 250 ave 250 max 250 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Nghost: 1479 ave 1479 max 1479 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 8000 ave 8000 max 8000 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -FullNghs: 16000 ave 16000 max 16000 min -Histogram: 1 0 0 0 0 0 0 0 0 0 - -Total # of neighbors = 16000 -Ave neighs/atom = 64 -Neighbor list builds = 0 -Dangerous builds = 0 -number of atoms = 250 -atomic volume (a.u.) = 121.6 -total energy (ry/atom) = -0.59530002488734 -pressure (gpa) = -1.15946260887556 -250 121.6 -148.825006221835 -1.15946260887556 -121.6 -0.59530002488734 -1.15946260887556 -Total wall time: 0:00:00 diff --git a/examples/PACKAGES/mgpt/log.vac0-bcc b/examples/PACKAGES/mgpt/log.vac0-bcc deleted file mode 100644 index 63880de450..0000000000 --- a/examples/PACKAGES/mgpt/log.vac0-bcc +++ /dev/null @@ -1,55 +0,0 @@ -LAMMPS (23 Oct 2015) -# script for mgpt t=0 eos with unrelaxed vacancy in bcc lattice: -# input for unrelaxed vacancy formation energy at constant atomic volume - -echo screen -Lattice spacing in x,y,z = 6.23363 6.23363 6.23363 -Created orthogonal box = (0 0 0) to (31.1681 31.1681 31.1681) - 1 by 1 by 1 MPI processor grid -Created 250 atoms -Deleted 1 atoms, new total = 249 -Reading potential file Ta6.8x.mgpt.potin with DATE: 2015-07-30 -Neighbor list info ... - 2 neighbor list requests - update every 1 steps, delay 0 steps, check yes - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 13.1618 - ghost atom cutoff = 13.1618 - binsize = 6.58091 -> bins = 5 5 5 -Memory usage per processor = 3.54478 Mbytes -Step Volume Temp PotEng TotEng Press - 0 30278.4 0 -73.996387 -73.996387 -6.3426731e+08 -Loop time of 1.90735e-06 on 1 procs for 0 steps with 249 atoms - -0.0% CPU use with 1 MPI tasks x no OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 0 | 0 | 0 | 0.0 | 0.00 -Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0 | 0 | 0 | 0.0 | 0.00 -Output | 0 | 0 | 0 | 0.0 | 0.00 -Modify | 0 | 0 | 0 | 0.0 | 0.00 -Other | | 1.907e-06 | | |100.00 - -Nlocal: 249 ave 249 max 249 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Nghost: 1479 ave 1479 max 1479 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 7936 ave 7936 max 7936 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -FullNghs: 15872 ave 15872 max 15872 min -Histogram: 1 0 0 0 0 0 0 0 0 0 - -Total # of neighbors = 15872 -Ave neighs/atom = 63.743 -Neighbor list builds = 0 -Dangerous builds = 0 -number of atoms = 249 -atomic volume (a.u.) = 121.6 -total energy (ry/atom) = -0.594348488796036 -pressure (gpa) = -0.634267307139601 -249 121.6 -147.992773710213 -0.634267307139601 -121.6 -0.594348488796036 -0.634267307139601 -Total wall time: 0:00:00 diff --git a/examples/PACKAGES/mgpt/log.vacmin-bcc b/examples/PACKAGES/mgpt/log.vacmin-bcc deleted file mode 100644 index 876b34eb1e..0000000000 --- a/examples/PACKAGES/mgpt/log.vacmin-bcc +++ /dev/null @@ -1,78 +0,0 @@ -LAMMPS (23 Oct 2015) -# script for mgpt t=0 eos with relaxed vacancy in bcc structure: -# input for relaxed vacancy formation energy at constant pressure - -echo screen -Lattice spacing in x,y,z = 6.23812 6.23812 6.23812 -Created orthogonal box = (0 0 0) to (31.1906 31.1906 31.1906) - 1 by 1 by 1 MPI processor grid -Created 250 atoms -Deleted 1 atoms, new total = 249 -Reading potential file Ta6.8x.mgpt.potin with DATE: 2015-07-30 -Neighbor list info ... - 2 neighbor list requests - update every 1 steps, delay 0 steps, check yes - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 13.1712 - ghost atom cutoff = 13.1712 - binsize = 6.58562 -> bins = 5 5 5 -Memory usage per processor = 4.66978 Mbytes -Step Volume Temp PotEng TotEng Press - 0 30343.887 0 -73.994511 -73.994511 -1.0504398e+09 - 10 30343.887 0 -74.002332 -74.002332 -1.107516e+09 - 20 30343.887 0 -74.00485 -74.00485 -1.1316373e+09 - 30 30343.887 0 -74.005762 -74.005762 -1.143304e+09 - 40 30343.887 0 -74.006116 -74.006116 -1.149395e+09 - 50 30343.887 0 -74.006262 -74.006262 -1.1527914e+09 - 60 30343.887 0 -74.006323 -74.006323 -1.1547677e+09 - 70 30343.887 0 -74.00635 -74.00635 -1.1559529e+09 - 80 30343.887 0 -74.006361 -74.006361 -1.1566763e+09 - 90 30343.887 0 -74.006366 -74.006366 -1.1571256e+09 - 100 30343.887 0 -74.006369 -74.006369 -1.1574093e+09 - 110 30343.887 0 -74.00637 -74.00637 -1.1575908e+09 - 120 30343.887 0 -74.00637 -74.00637 -1.1577083e+09 - 130 30343.887 0 -74.00637 -74.00637 -1.1577849e+09 - 139 30343.887 0 -74.006371 -74.006371 -1.1578311e+09 -Loop time of 4.22107 on 1 procs for 139 steps with 249 atoms - -92.1% CPU use with 1 MPI tasks x no OpenMP threads - -Minimization stats: - Stopping criterion = energy tolerance - Energy initial, next-to-last, final = - -73.9945109564 -74.0063705487 -74.0063705557 - Force two-norm initial, final = 0.0366227 8.09081e-05 - Force max component initial, final = 0.00730948 8.05242e-06 - Final line search alpha, max atom move = 1 8.05242e-06 - Iterations, force evaluations = 139 139 - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 4.1973 | 4.1973 | 4.1973 | 0.0 | 99.44 -Neigh | 0.018799 | 0.018799 | 0.018799 | 0.0 | 0.45 -Comm | 0.0017059 | 0.0017059 | 0.0017059 | 0.0 | 0.04 -Output | 0.00080252 | 0.00080252 | 0.00080252 | 0.0 | 0.02 -Modify | 0 | 0 | 0 | 0.0 | 0.00 -Other | | 0.002477 | | | 0.06 - -Nlocal: 249 ave 249 max 249 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Nghost: 1479 ave 1479 max 1479 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 7936 ave 7936 max 7936 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -FullNghs: 15872 ave 15872 max 15872 min -Histogram: 1 0 0 0 0 0 0 0 0 0 - -Total # of neighbors = 15872 -Ave neighs/atom = 63.743 -Neighbor list builds = 4 -Dangerous builds = 0 -number of atoms = 249 -atomic volume (a.u.) = 121.863 -total energy (ry/atom) = -0.594428679162064 -pressure (gpa) = -1.15783109519801 -249 121.863 -148.012741111354 -1.15783109519801 -121.863 -0.594428679162064 -1.15783109519801 -Total wall time: 0:00:04 diff --git a/examples/PACKAGES/reaction/create_atoms_polystyrene/in.grow_styrene b/examples/PACKAGES/reaction/create_atoms_polystyrene/in.grow_styrene index 7860db4e55..dcca29c026 100644 --- a/examples/PACKAGES/reaction/create_atoms_polystyrene/in.grow_styrene +++ b/examples/PACKAGES/reaction/create_atoms_polystyrene/in.grow_styrene @@ -40,7 +40,7 @@ fix 1 statted_grp_REACT nvt temp $T $T 100 fix 4 bond_react_MASTER_group temp/rescale 1 $T $T 1 1 -thermo_style custom step temp press density f_myrxns[1] +thermo_style custom step temp press density f_myrxns[*] thermo 100 diff --git a/examples/PACKAGES/reaction/nylon,6-6_melt/in.large_nylon_melt b/examples/PACKAGES/reaction/nylon,6-6_melt/in.large_nylon_melt index 9678a714d6..635b2c9750 100644 --- a/examples/PACKAGES/reaction/nylon,6-6_melt/in.large_nylon_melt +++ b/examples/PACKAGES/reaction/nylon,6-6_melt/in.large_nylon_melt @@ -26,7 +26,7 @@ read_data large_nylon_melt.data.gz & extra/angle/per/atom 15 & extra/dihedral/per/atom 15 & extra/improper/per/atom 25 & - extra/special/per/atom 25 + extra/special/per/atom 25 velocity all create 800.0 4928459 dist gaussian @@ -50,7 +50,7 @@ fix 1 statted_grp_REACT nvt temp 800 800 100 # you can use the internally created 'bond_react_MASTER_group', like so: # fix 2 bond_react_MASTER_group temp/rescale 1 800 800 10 1 -thermo_style custom step temp press density f_myrxns[1] f_myrxns[2] # cumulative reaction counts +thermo_style custom step temp press density f_myrxns[*] # cumulative reaction counts # restart 100 restart1 restart2 diff --git a/examples/PACKAGES/reaction/tiny_epoxy/in.tiny_epoxy.stabilized b/examples/PACKAGES/reaction/tiny_epoxy/in.tiny_epoxy.stabilized index 57b03b630f..7e0350cdb0 100644 --- a/examples/PACKAGES/reaction/tiny_epoxy/in.tiny_epoxy.stabilized +++ b/examples/PACKAGES/reaction/tiny_epoxy/in.tiny_epoxy.stabilized @@ -20,7 +20,8 @@ improper_style class2 special_bonds lj/coul 0 0 1 pair_modify tail yes mix sixthpower -read_data tiny_epoxy.data +read_data tiny_epoxy.data & + extra/special/per/atom 25 velocity all create 300.0 4928459 dist gaussian @@ -44,7 +45,7 @@ fix rxns all bond/react stabilization yes statted_grp .03 & fix 1 statted_grp_REACT nvt temp 300 300 100 -thermo_style custom step temp f_rxns[1] f_rxns[2] f_rxns[3] f_rxns[4] +thermo_style custom step temp f_rxns[*] run 2000 diff --git a/examples/PACKAGES/reaction/tiny_nylon/in.tiny_nylon.stabilized b/examples/PACKAGES/reaction/tiny_nylon/in.tiny_nylon.stabilized index 95b39033db..853bc45f1e 100644 --- a/examples/PACKAGES/reaction/tiny_nylon/in.tiny_nylon.stabilized +++ b/examples/PACKAGES/reaction/tiny_nylon/in.tiny_nylon.stabilized @@ -50,7 +50,7 @@ fix 1 statted_grp_REACT nvt temp 300 300 100 # by using the internally-created 'bond_react_MASTER_group', like so: fix 4 bond_react_MASTER_group temp/rescale 1 300 300 10 1 -thermo_style custom step temp press density f_myrxns[1] f_myrxns[2] +thermo_style custom step temp press density f_myrxns[*] # restart 100 restart1 restart2 diff --git a/examples/PACKAGES/reaction/tiny_nylon/in.tiny_nylon.stabilized_variable_probability b/examples/PACKAGES/reaction/tiny_nylon/in.tiny_nylon.stabilized_variable_probability index 88b5a95a41..f3c32f3cbd 100644 --- a/examples/PACKAGES/reaction/tiny_nylon/in.tiny_nylon.stabilized_variable_probability +++ b/examples/PACKAGES/reaction/tiny_nylon/in.tiny_nylon.stabilized_variable_probability @@ -54,7 +54,7 @@ fix 1 statted_grp_REACT nvt temp 300 300 100 # by using the internally-created 'bond_react_MASTER_group', like so: fix 4 bond_react_MASTER_group temp/rescale 1 300 300 10 1 -thermo_style custom step temp press density v_prob1 v_prob2 f_myrxns[1] f_myrxns[2] +thermo_style custom step temp press density v_prob1 v_prob2 f_myrxns[*] # restart 100 restart1 restart2 diff --git a/examples/PACKAGES/reaction/tiny_nylon/in.tiny_nylon.unstabilized b/examples/PACKAGES/reaction/tiny_nylon/in.tiny_nylon.unstabilized index a569e28d43..e5cbaaaf86 100644 --- a/examples/PACKAGES/reaction/tiny_nylon/in.tiny_nylon.unstabilized +++ b/examples/PACKAGES/reaction/tiny_nylon/in.tiny_nylon.unstabilized @@ -47,7 +47,7 @@ fix myrxns all bond/react stabilization no & fix 1 all nve/limit .03 -thermo_style custom step temp press density f_myrxns[1] f_myrxns[2] +thermo_style custom step temp press density f_myrxns[*] # restart 100 restart1 restart2 diff --git a/examples/PACKAGES/reaction/tiny_polystyrene/in.tiny_polystyrene.stabilized b/examples/PACKAGES/reaction/tiny_polystyrene/in.tiny_polystyrene.stabilized index 4ecc481719..230998fcd3 100644 --- a/examples/PACKAGES/reaction/tiny_polystyrene/in.tiny_polystyrene.stabilized +++ b/examples/PACKAGES/reaction/tiny_polystyrene/in.tiny_polystyrene.stabilized @@ -51,7 +51,7 @@ fix 1 statted_grp_REACT nvt temp $T $T 100 fix 4 bond_react_MASTER_group temp/rescale 1 $T $T 1 1 -thermo_style custom step temp press density f_rxn1[1] f_rxn1[2] f_rxn1[3] +thermo_style custom step temp press density f_rxn1[*] run 10000 diff --git a/examples/airebo/in.airebo-0-0 b/examples/airebo/in.airebo-0-0 index 077da68912..0e71644127 100644 --- a/examples/airebo/in.airebo-0-0 +++ b/examples/airebo/in.airebo-0-0 @@ -1,22 +1,22 @@ # AIREBO polyethelene benchmark -units metal -atom_style atomic +units metal +atom_style atomic -read_data data.airebo +read_data data.airebo -replicate 17 16 2 +replicate 17 16 2 -neighbor 0.5 bin -neigh_modify delay 5 every 1 +neighbor 0.5 bin +neigh_modify delay 5 every 1 -pair_style airebo 3.0 0 0 -pair_coeff * * CH.airebo C H +pair_style airebo 3.0 0 0 +pair_coeff * * CH.airebo C H -velocity all create 300.0 761341 +velocity all create 300.0 761341 -fix 1 all nve -timestep 0.0005 +fix 1 all nve +timestep 0.0005 -thermo 10 -run 100 +thermo 10 +run 100 diff --git a/examples/airebo/in.rebo2 b/examples/airebo/in.rebo2 index e06cf462ca..319a60bd50 100644 --- a/examples/airebo/in.rebo2 +++ b/examples/airebo/in.rebo2 @@ -1,22 +1,22 @@ # REBO polyethelene benchmark -units metal -atom_style atomic +units metal +atom_style atomic -read_data data.airebo +read_data data.airebo -replicate 17 16 2 +replicate 17 16 2 -neighbor 0.5 bin -neigh_modify delay 5 every 1 +neighbor 0.5 bin +neigh_modify delay 5 every 1 -pair_style rebo -pair_coeff * * CH.rebo C H +pair_style rebo +pair_coeff * * CH.rebo C H -velocity all create 300.0 761341 +velocity all create 300.0 761341 -fix 1 all nve -timestep 0.0005 +fix 1 all nve +timestep 0.0005 -thermo 10 -run 100 +thermo 10 +run 100 diff --git a/examples/granular/in.pour.heat b/examples/granular/in.pour.heat index 907e56dc39..cc6b03f7d0 100644 --- a/examples/granular/in.pour.heat +++ b/examples/granular/in.pour.heat @@ -73,7 +73,8 @@ thermo 100 timestep 0.001 -#dump 1 all custom 1000 ${name}.dump id type radius mass x y z temperature heatflow +compute 1 all property/atom temperature heatflow +#dump 1 all custom 1000 ${name}.dump id type radius mass x y z c_1[*] run 100000 diff --git a/examples/meam/msmeam/HGa.meam b/examples/meam/msmeam/HGa.meam deleted file mode 100644 index 9f01501c16..0000000000 --- a/examples/meam/msmeam/HGa.meam +++ /dev/null @@ -1,30 +0,0 @@ -bkgd_dyn = 1 -emb_lin_neg = 1 -augt1=0 -ialloy=1 -rc = 5.9 -#H -attrac(1,1)=0.460 -repuls(1,1)=0.460 -Cmin(1,1,1)=1.3 # PuMS -Cmax(1,1,1)= 2.80 -nn2(1,1)=1 -#Ga -rho0(2) = 0.6 -attrac(2,2)=0.097 -repuls(2,2)=0.097 -nn2(2,2)=1 -#HGa -attrac(1,2)=0.300 -repuls(1,2)=0.300 -lattce(1,2)=l12 -re(1,2)=3.19 -delta(1,2)=-0.48 -alpha(1,2)=6.6 -Cmin(1,1,2)=2.0 -Cmin(2,1,2)= 2.0 -Cmin(1,2,1)=2.0 -Cmin(2,2,1) = 1.4 -Cmin(1,2,2) = 1.4 -Cmin(1,1,2) = 1.4 -nn2(1,2)=1 diff --git a/examples/meam/msmeam/HGa.msmeam b/examples/meam/msmeam/HGa.msmeam new file mode 120000 index 0000000000..5629006d1d --- /dev/null +++ b/examples/meam/msmeam/HGa.msmeam @@ -0,0 +1 @@ +../../../potentials/HGa.msmeam \ No newline at end of file diff --git a/examples/meam/msmeam/data.msmeam.bu b/examples/meam/msmeam/data.msmeam.bu deleted file mode 100644 index 576a3c50de..0000000000 --- a/examples/meam/msmeam/data.msmeam.bu +++ /dev/null @@ -1,25 +0,0 @@ -LAMMPS data file via write_data, version 16 Feb 2016, timestep = 1 - -3 atoms -2 atom types - --4.0000000000000000e+00 4.0000000000000000e+00 xlo xhi --4.0000000000000000e+00 4.0000000000000000e+00 ylo yhi --4.0000000000000000e+00 4.0000000000000000e+00 zlo zhi - -Masses - -1 1.0079 -2 69.723 - -Atoms # atomic - -1 1 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 0 0 0 -2 2 2.2000000000000002e+00 0.0000000000000000e+00 0.0000000000000000e+00 0 0 0 -3 2 2.9999999999999999e-01 2.2999999999999998e+00 0.0000000000000000e+00 0 0 0 - -Velocities - -1 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 -2 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 -3 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 diff --git a/examples/meam/msmeam/in.msmeam b/examples/meam/msmeam/in.msmeam index 82ffb89a13..e8d13f8682 100644 --- a/examples/meam/msmeam/in.msmeam +++ b/examples/meam/msmeam/in.msmeam @@ -1,5 +1,3 @@ -echo both -log log.msmeam # Test of MEAM potential for HGa # ------------------------ INITIALIZATION ---------------------------- @@ -21,11 +19,11 @@ create_atoms 1 single 0 0 0 units box create_atoms 2 single 2.2 0 0 units box create_atoms 2 single 0.3 2.3 0 units box # ---------- Define Settings --------------------- -variable teng equal "c_eatoms" +variable teng equal "c_eatoms" compute pot_energy all pe/atom compute stress all stress/atom NULL dump 1 all custom 1 dump.msmeam id x y z fx fy fz c_pot_energy c_stress[1] c_stress[2] c_stress[3] c_stress[4] c_stress[5] c_stress[6] -run 1 -write_data data.msmeam +run 1 +#write_data data.msmeam print "All done!" diff --git a/examples/meam/msmeam/library.msmeam b/examples/meam/msmeam/library.msmeam deleted file mode 100644 index 9937eaee08..0000000000 --- a/examples/meam/msmeam/library.msmeam +++ /dev/null @@ -1,14 +0,0 @@ -# DATE: 2018-09-22 UNITS: metal CONTRIBUTOR: Steve Valone, smv@lanl.gov CITATION: Baskes, PRB 1992; smv, sr, mib, JNM 2010 -# ms-meam data format May 2010 -# elt lat z ielement atwt -# alpha b0 b1 b2 b3 b1m b2m b3m alat esub asub -# - t0 t1 t2 t3 t1m t2m t3m rozero ibar -# NOTE: leading character cannot be a space - -'H' 'dim' 1.0 1 1.0079 -2.960 2.960 3.0 1.0 1.0 1.0 3.0 1.0 0.741 2.235 2.50 -1.0 0.44721 0.0 0.00 0.0 0.31623 0 6.70 0 - -'Ga4' 'fcc' 12.0 31 69.723 -4.42 4.80 3.10 6.00 0.00 0.0 0.0 0.5 4.247 2.897 0.97 -1.0 1.649 1.435 0.00 0.0 0.0 2.0 0.70 0 diff --git a/examples/meam/msmeam/library.msmeam b/examples/meam/msmeam/library.msmeam new file mode 120000 index 0000000000..2226ef99da --- /dev/null +++ b/examples/meam/msmeam/library.msmeam @@ -0,0 +1 @@ +../../../potentials/library.msmeam \ No newline at end of file diff --git a/examples/meam/msmeam/log.1Mar2024.msmeam.g++.1 b/examples/meam/msmeam/log.1Mar2024.msmeam.g++.1 new file mode 100644 index 0000000000..70fbbdd89c --- /dev/null +++ b/examples/meam/msmeam/log.1Mar2024.msmeam.g++.1 @@ -0,0 +1,126 @@ +LAMMPS (7 Feb 2024 - Development - patch_7Feb2024_update1-182-g93942f2013-modified) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# Test of MEAM potential for HGa + +# ------------------------ INITIALIZATION ---------------------------- +units metal +dimension 3 +boundary p p p +atom_style atomic +variable latparam equal 4.646 +variable ncell equal 3 + +# ----------------------- ATOM DEFINITION ---------------------------- +region box block -4 4 -4 4 -4 4 +create_box 2 box +Created orthogonal box = (-4 -4 -4) to (4 4 4) + 1 by 1 by 1 MPI processor grid + +# + +include potential.mod +# NOTE: This script can be modified for different pair styles +# See in.elastic for more info. + +variable Pu string H +print "potential chosen ${Pu}" +potential chosen H +# Choose potential +pair_style meam/ms +print "we just executed" +we just executed + +pair_coeff * * library.msmeam ${Pu} Ga4 HGa.msmeam ${Pu} Ga4 +pair_coeff * * library.msmeam H Ga4 HGa.msmeam ${Pu} Ga4 +pair_coeff * * library.msmeam H Ga4 HGa.msmeam H Ga4 +Reading MEAM library file library.msmeam with DATE: 2018-09-22 +# Setup neighbor style +neighbor 1.0 bin +neigh_modify once no every 1 delay 0 check yes + +# Setup minimization style +variable dmax equal 1.0e-2 +min_style cg +min_modify dmax ${dmax} line quadratic +min_modify dmax 0.01 line quadratic +compute eng all pe/atom +compute eatoms all reduce sum c_eng + +# Setup output +thermo 100 +thermo_style custom step temp etotal press pxx pyy pzz pxy pxz pyz lx ly lz vol c_eatoms +thermo_modify norm yes +create_atoms 1 single 0 0 0 units box +Created 1 atoms + using box units in orthogonal box = (-4 -4 -4) to (4 4 4) + create_atoms CPU = 0.000 seconds +create_atoms 2 single 2.2 0 0 units box +Created 1 atoms + using box units in orthogonal box = (-4 -4 -4) to (4 4 4) + create_atoms CPU = 0.000 seconds +create_atoms 2 single 0.3 2.3 0 units box +Created 1 atoms + using box units in orthogonal box = (-4 -4 -4) to (4 4 4) + create_atoms CPU = 0.000 seconds +# ---------- Define Settings --------------------- +variable teng equal "c_eatoms" +compute pot_energy all pe/atom +compute stress all stress/atom NULL +# dump 1 all custom 1 dump.msmeam id x y z fx fy fz c_pot_energy c_stress[1] c_stress[2] c_stress[3] c_stress[4] c_stress[5] c_stress[6] +run 1 +WARNING: No fixes with time integration, atoms won't move (src/verlet.cpp:60) +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 6.9 + ghost atom cutoff = 6.9 + binsize = 3.45, bins = 3 3 3 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair meam/ms, perpetual + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard + (2) pair meam/ms, perpetual, half/full from (1) + attributes: half, newton on + pair build: halffull/newton + stencil: none + bin: none +Per MPI rank memory allocation (min/avg/max) = 8.587 | 8.587 | 8.587 Mbytes + Step Temp TotEng Press Pxx Pyy Pzz Pxy Pxz Pyz Lx Ly Lz Volume c_eatoms + 0 0 15.433079 491354.7 838670.96 635393.15 0 80195.797 0 0 8 8 8 512 15.433079 + 1 0 15.433079 491354.7 838670.96 635393.15 0 80195.797 0 0 8 8 8 512 15.433079 +Loop time of 4.4446e-05 on 1 procs for 1 steps with 3 atoms + +Performance: 1943.932 ns/day, 0.012 hours/ns, 22499.213 timesteps/s, 67.498 katom-step/s +31.5% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 2.9908e-05 | 2.9908e-05 | 2.9908e-05 | 0.0 | 67.29 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 1.033e-06 | 1.033e-06 | 1.033e-06 | 0.0 | 2.32 +Output | 9.347e-06 | 9.347e-06 | 9.347e-06 | 0.0 | 21.03 +Modify | 2.02e-07 | 2.02e-07 | 2.02e-07 | 0.0 | 0.45 +Other | | 3.956e-06 | | | 8.90 + +Nlocal: 3 ave 3 max 3 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 78 ave 78 max 78 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 7 ave 7 max 7 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +FullNghs: 14 ave 14 max 14 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 14 +Ave neighs/atom = 4.6666667 +Neighbor list builds = 0 +Dangerous builds = 0 +#write_data data.msmeam + +print "All done!" +All done! +Total wall time: 0:00:00 diff --git a/examples/meam/msmeam/log.1Mar2024.msmeam.g++.4 b/examples/meam/msmeam/log.1Mar2024.msmeam.g++.4 new file mode 100644 index 0000000000..6951a64945 --- /dev/null +++ b/examples/meam/msmeam/log.1Mar2024.msmeam.g++.4 @@ -0,0 +1,126 @@ +LAMMPS (7 Feb 2024 - Development - patch_7Feb2024_update1-182-g93942f2013-modified) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +# Test of MEAM potential for HGa + +# ------------------------ INITIALIZATION ---------------------------- +units metal +dimension 3 +boundary p p p +atom_style atomic +variable latparam equal 4.646 +variable ncell equal 3 + +# ----------------------- ATOM DEFINITION ---------------------------- +region box block -4 4 -4 4 -4 4 +create_box 2 box +Created orthogonal box = (-4 -4 -4) to (4 4 4) + 1 by 2 by 2 MPI processor grid + +# + +include potential.mod +# NOTE: This script can be modified for different pair styles +# See in.elastic for more info. + +variable Pu string H +print "potential chosen ${Pu}" +potential chosen H +# Choose potential +pair_style meam/ms +print "we just executed" +we just executed + +pair_coeff * * library.msmeam ${Pu} Ga4 HGa.msmeam ${Pu} Ga4 +pair_coeff * * library.msmeam H Ga4 HGa.msmeam ${Pu} Ga4 +pair_coeff * * library.msmeam H Ga4 HGa.msmeam H Ga4 +Reading MEAM library file library.msmeam with DATE: 2018-09-22 +# Setup neighbor style +neighbor 1.0 bin +neigh_modify once no every 1 delay 0 check yes + +# Setup minimization style +variable dmax equal 1.0e-2 +min_style cg +min_modify dmax ${dmax} line quadratic +min_modify dmax 0.01 line quadratic +compute eng all pe/atom +compute eatoms all reduce sum c_eng + +# Setup output +thermo 100 +thermo_style custom step temp etotal press pxx pyy pzz pxy pxz pyz lx ly lz vol c_eatoms +thermo_modify norm yes +create_atoms 1 single 0 0 0 units box +Created 1 atoms + using box units in orthogonal box = (-4 -4 -4) to (4 4 4) + create_atoms CPU = 0.000 seconds +create_atoms 2 single 2.2 0 0 units box +Created 1 atoms + using box units in orthogonal box = (-4 -4 -4) to (4 4 4) + create_atoms CPU = 0.000 seconds +create_atoms 2 single 0.3 2.3 0 units box +Created 1 atoms + using box units in orthogonal box = (-4 -4 -4) to (4 4 4) + create_atoms CPU = 0.000 seconds +# ---------- Define Settings --------------------- +variable teng equal "c_eatoms" +compute pot_energy all pe/atom +compute stress all stress/atom NULL +# dump 1 all custom 1 dump.msmeam id x y z fx fy fz c_pot_energy c_stress[1] c_stress[2] c_stress[3] c_stress[4] c_stress[5] c_stress[6] +run 1 +WARNING: No fixes with time integration, atoms won't move (src/verlet.cpp:60) +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 6.9 + ghost atom cutoff = 6.9 + binsize = 3.45, bins = 3 3 3 + 2 neighbor lists, perpetual/occasional/extra = 2 0 0 + (1) pair meam/ms, perpetual + attributes: full, newton on + pair build: full/bin/atomonly + stencil: full/bin/3d + bin: standard + (2) pair meam/ms, perpetual, half/full from (1) + attributes: half, newton on + pair build: halffull/newton + stencil: none + bin: none +Per MPI rank memory allocation (min/avg/max) = 7.965 | 8.123 | 8.594 Mbytes + Step Temp TotEng Press Pxx Pyy Pzz Pxy Pxz Pyz Lx Ly Lz Volume c_eatoms + 0 0 15.433079 491354.7 838670.96 635393.15 0 80195.797 0 0 8 8 8 512 15.433079 + 1 0 15.433079 491354.7 838670.96 635393.15 0 80195.797 0 0 8 8 8 512 15.433079 +Loop time of 8.70645e-05 on 4 procs for 1 steps with 3 atoms + +Performance: 992.368 ns/day, 0.024 hours/ns, 11485.738 timesteps/s, 34.457 katom-step/s +29.0% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 4.3957e-05 | 4.67e-05 | 5.1056e-05 | 0.0 | 53.64 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 1.105e-05 | 1.3822e-05 | 1.7033e-05 | 0.0 | 15.88 +Output | 1.5765e-05 | 1.9045e-05 | 2.5216e-05 | 0.0 | 21.87 +Modify | 2.58e-07 | 3.465e-07 | 3.81e-07 | 0.0 | 0.40 +Other | | 7.151e-06 | | | 8.21 + +Nlocal: 0.75 ave 3 max 0 min +Histogram: 3 0 0 0 0 0 0 0 0 1 +Nghost: 38.25 ave 42 max 36 min +Histogram: 2 0 0 0 0 1 0 0 0 1 +Neighs: 1.75 ave 7 max 0 min +Histogram: 3 0 0 0 0 0 0 0 0 1 +FullNghs: 3.5 ave 14 max 0 min +Histogram: 3 0 0 0 0 0 0 0 0 1 + +Total # of neighbors = 14 +Ave neighs/atom = 4.6666667 +Neighbor list builds = 0 +Dangerous builds = 0 +#write_data data.msmeam + +print "All done!" +All done! +Total wall time: 0:00:00 diff --git a/examples/meam/msmeam/log.msmeam.bu b/examples/meam/msmeam/log.msmeam.bu deleted file mode 100644 index 8eac453c1e..0000000000 --- a/examples/meam/msmeam/log.msmeam.bu +++ /dev/null @@ -1,107 +0,0 @@ -# Test of MEAM potential for HGa - -# ------------------------ INITIALIZATION ---------------------------- -units metal -dimension 3 -boundary p p p -atom_style atomic -variable latparam equal 4.646 -variable ncell equal 3 - -# ----------------------- ATOM DEFINITION ---------------------------- -region box block -4 4 -4 4 -4 4 -create_box 2 box -Created orthogonal box = (-4 -4 -4) to (4 4 4) - 1 by 1 by 1 MPI processor grid - -# - -include potential.mod -# NOTE: This script can be modified for different pair styles -# See in.elastic for more info. - -variable Pu string H -print "potential chosen ${Pu}" -potential chosen H -# Choose potential -pair_style MSmeam -print "we just executed" -we just executed - -pair_coeff * * library.MSmeam ${Pu} Ga4 HGaMS.meam ${Pu} Ga4 -pair_coeff * * library.MSmeam H Ga4 HGaMS.meam ${Pu} Ga4 -pair_coeff * * library.MSmeam H Ga4 HGaMS.meam H Ga4 -Reading potential file library.MSmeam with DATE: 2018-09-22 -# Setup neighbor style -neighbor 1.0 nsq -neigh_modify once no every 1 delay 0 check yes - -# Setup minimization style -variable dmax equal 1.0e-2 -min_style cg -min_modify dmax ${dmax} line quadratic -min_modify dmax 0.01 line quadratic -compute eng all pe/atom -compute eatoms all reduce sum c_eng - -# Setup output -thermo 100 -thermo_style custom step temp etotal press pxx pyy pzz pxy pxz pyz lx ly lz vol c_eatoms -thermo_modify norm yes -create_atoms 1 single 0 0 0 units box -Created 1 atoms -create_atoms 2 single 2.2 0 0 units box -Created 1 atoms -create_atoms 2 single 0.3 2.3 0 units box -Created 1 atoms -# ---------- Define Settings --------------------- -variable teng equal "c_eatoms" -compute pot_energy all pe/atom -compute stress all stress/atom NULL -dump 1 all custom 1 dump.msmeam id x y z fx fy fz c_pot_energy c_stress[1] c_stress[2] c_stress[3] c_stress[4] c_stress[5] c_stress[6] -run 1 -WARNING: No fixes defined, atoms won't move (../verlet.cpp:55) -Neighbor list info ... - 2 neighbor list requests - update every 1 steps, delay 0 steps, check yes - max neighbors/atom: 2000, page size: 100000 - master list distance cutoff = 6.9 - ghost atom cutoff = 6.9 -Memory usage per processor = 12.9295 Mbytes -Step Temp TotEng Press Pxx Pyy Pzz Pxy Pxz Pyz Lx Ly Lz Volume eatoms - 0 0 15.433079 491354.68 838670.91 635393.13 0 80195.793 0 0 8 8 8 512 15.433079 - 1 0 15.433079 491354.68 838670.91 635393.13 0 80195.793 0 0 8 8 8 512 15.433079 -Loop time of 0.000172138 on 1 procs for 1 steps with 3 atoms - -Performance: 501.922 ns/day, 0.048 hours/ns, 5809.285 timesteps/s -81.3% CPU use with 1 MPI tasks x no OpenMP threads - -MPI task timing breakdown: -Section | min time | avg time | max time |%varavg| %total ---------------------------------------------------------------- -Pair | 6.6996e-05 | 6.6996e-05 | 6.6996e-05 | 0.0 | 38.92 -Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 1.9073e-06 | 1.9073e-06 | 1.9073e-06 | 0.0 | 1.11 -Output | 9.7036e-05 | 9.7036e-05 | 9.7036e-05 | 0.0 | 56.37 -Modify | 0 | 0 | 0 | 0.0 | 0.00 -Other | | 6.199e-06 | | | 3.60 - -Nlocal: 3 ave 3 max 3 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Nghost: 78 ave 78 max 78 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 7 ave 7 max 7 min -Histogram: 1 0 0 0 0 0 0 0 0 0 -FullNghs: 14 ave 14 max 14 min -Histogram: 1 0 0 0 0 0 0 0 0 0 - -Total # of neighbors = 14 -Ave neighs/atom = 4.66667 -Neighbor list builds = 0 -Dangerous builds = 0 -write_data data.msmeam - -print "All done!" -All done! -Total wall time: 0:00:00 - diff --git a/examples/meam/msmeam/msmeam.dump.bu b/examples/meam/msmeam/msmeam.dump.bu deleted file mode 100644 index 039f630073..0000000000 --- a/examples/meam/msmeam/msmeam.dump.bu +++ /dev/null @@ -1,24 +0,0 @@ -ITEM: TIMESTEP -0 -ITEM: NUMBER OF ATOMS -3 -ITEM: BOX BOUNDS pp pp pp --4 4 --4 4 --4 4 -ITEM: ATOMS id x y z fx fy fz c_pot_energy c_stress[1] c_stress[2] c_stress[3] c_stress[4] c_stress[5] c_stress[6] -1 0 0 0 -131.925 -88.3005 0 22.9153 -2.147e+08 -1.62661e+08 -0 -2.05301e+07 -0 -0 -2 2.2 0 0 120.809 -0.482171 0 14.7692 -2.12028e+08 -0 -0 403352 -0 -0 -3 0.3 2.3 0 11.1159 88.7827 0 8.61478 -2.67145e+06 -1.62661e+08 -0 -2.09335e+07 -0 -0 -ITEM: TIMESTEP -1 -ITEM: NUMBER OF ATOMS -3 -ITEM: BOX BOUNDS pp pp pp --4 4 --4 4 --4 4 -ITEM: ATOMS id x y z fx fy fz c_pot_energy c_stress[1] c_stress[2] c_stress[3] c_stress[4] c_stress[5] c_stress[6] -1 0 0 0 -131.925 -88.3005 0 22.9153 -2.147e+08 -1.62661e+08 -0 -2.05301e+07 -0 -0 -2 2.2 0 0 120.809 -0.482171 0 14.7692 -2.12028e+08 -0 -0 403352 -0 -0 -3 0.3 2.3 0 11.1159 88.7827 0 8.61478 -2.67145e+06 -1.62661e+08 -0 -2.09335e+07 -0 -0 diff --git a/examples/meam/msmeam/potential.mod b/examples/meam/msmeam/potential.mod index 760cc93503..117736743b 100644 --- a/examples/meam/msmeam/potential.mod +++ b/examples/meam/msmeam/potential.mod @@ -7,7 +7,7 @@ print "potential chosen ${Pu}" pair_style meam/ms print "we just executed" -pair_coeff * * library.msmeam ${Pu} Ga4 HGa.meam ${Pu} Ga4 +pair_coeff * * library.msmeam ${Pu} Ga4 HGa.msmeam ${Pu} Ga4 # Setup neighbor style neighbor 1.0 bin neigh_modify once no every 1 delay 0 check yes diff --git a/examples/plugins/LAMMPSInterfaceCXX.cmake b/examples/plugins/LAMMPSInterfaceCXX.cmake index 7eef5bd6e4..d1f8faec22 100644 --- a/examples/plugins/LAMMPSInterfaceCXX.cmake +++ b/examples/plugins/LAMMPSInterfaceCXX.cmake @@ -23,12 +23,14 @@ function(validate_option name values) endfunction(validate_option) ################################################################################# -# LAMMPS C++ interface. We only need the header related parts. +# LAMMPS C++ interface. We only need the header related parts for shared linkage +# but the library .a file for real static or quasi-static linkage (of LAMMPS). add_library(lammps INTERFACE) target_include_directories(lammps INTERFACE ${LAMMPS_HEADER_DIR}) if((CMAKE_SYSTEM_NAME STREQUAL "Windows") AND CMAKE_CROSSCOMPILING) target_link_libraries(lammps INTERFACE ${CMAKE_BINARY_DIR}/../liblammps.dll.a) endif() + ################################################################################ # MPI configuration if(NOT CMAKE_CROSSCOMPILING) @@ -82,13 +84,9 @@ if(BUILD_MPI) # Download and configure custom MPICH files for Windows message(STATUS "Downloading and configuring MPICH-1.4.1 for Windows") set(MPICH2_WIN64_DEVEL_URL "${LAMMPS_THIRDPARTY_URL}/mpich2-win64-devel.tar.gz" CACHE STRING "URL for MPICH2 (win64) tarball") - set(MPICH2_WIN32_DEVEL_URL "${LAMMPS_THIRDPARTY_URL}/mpich2-win32-devel.tar.gz" CACHE STRING "URL for MPICH2 (win32) tarball") set(MPICH2_WIN64_DEVEL_MD5 "4939fdb59d13182fd5dd65211e469f14" CACHE STRING "MD5 checksum of MPICH2 (win64) tarball") - set(MPICH2_WIN32_DEVEL_MD5 "a61d153500dce44e21b755ee7257e031" CACHE STRING "MD5 checksum of MPICH2 (win32) tarball") mark_as_advanced(MPICH2_WIN64_DEVEL_URL) - mark_as_advanced(MPICH2_WIN32_DEVEL_URL) mark_as_advanced(MPICH2_WIN64_DEVEL_MD5) - mark_as_advanced(MPICH2_WIN32_DEVEL_MD5) include(ExternalProject) if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") @@ -131,6 +129,8 @@ else() target_include_directories(lammps INTERFACE "${LAMMPS_SOURCE_DIR}/STUBS") endif() +################ +# integer size selection set(LAMMPS_SIZES "smallbig" CACHE STRING "LAMMPS integer sizes (smallsmall: all 32-bit, smallbig: 64-bit #atoms #timesteps, bigbig: also 64-bit imageint, 64-bit atom ids)") set(LAMMPS_SIZES_VALUES smallbig bigbig smallsmall) set_property(CACHE LAMMPS_SIZES PROPERTY STRINGS ${LAMMPS_SIZES_VALUES}) diff --git a/examples/rdf-adf/in.spce b/examples/rdf-adf/in.spce index 9a9d99fd42..6627924adc 100644 --- a/examples/rdf-adf/in.spce +++ b/examples/rdf-adf/in.spce @@ -1,22 +1,22 @@ # Liquid water RDFs and ADFs (~12 O-O-O/atom, ~1 O-H...O/atom) -units real -atom_style full +units real +atom_style full -read_data data.spce +read_data data.spce pair_style lj/cut/coul/long 12.0 12.0 pair_coeff * * 0.0 1.0 pair_coeff 1 1 0.15535 3.166 -kspace_style pppm 1.0e-6 +kspace_style pppm 1.0e-6 -bond_style harmonic -angle_style harmonic -dihedral_style none -improper_style none +bond_style harmonic +angle_style harmonic +dihedral_style none +improper_style none -bond_coeff 1 1000.00 1.000 -angle_coeff 1 100.0 109.47 +bond_coeff 1 1000.00 1.000 +angle_coeff 1 100.0 109.47 # need to set bond/angle inclusion to > 0.0 # so that intramolecular pairs are included in neighbor lists (required for second ADF) @@ -26,8 +26,8 @@ neighbor 2.0 bin timestep 2.0 neigh_modify every 1 delay 2 check yes -fix 1 all shake 0.0001 20 0 b 1 a 1 -fix 2 all nvt temp 300.0 300.0 100.0 +fix 1 all shake 0.0001 20 0 b 1 a 1 +fix 2 all nvt temp 300.0 300.0 100.0 velocity all create 300.0 6244325 diff --git a/examples/threebody/MoS.rebomos b/examples/threebody/MoS.rebomos new file mode 120000 index 0000000000..6146c74c24 --- /dev/null +++ b/examples/threebody/MoS.rebomos @@ -0,0 +1 @@ +../../potentials/MoS.rebomos \ No newline at end of file diff --git a/examples/threebody/in.mos2-bulk b/examples/threebody/in.mos2-bulk new file mode 100644 index 0000000000..032e71fce8 --- /dev/null +++ b/examples/threebody/in.mos2-bulk @@ -0,0 +1,35 @@ +units metal + +lattice custom 1.0 a1 3.1903157234 0.0000000000 0.0000000000 & + a2 -1.5964590311 2.7651481541 0.0000000000 & + a3 0.0000000000 0.0000000000 13.9827680588 & + basis 0.0000000000 0.000000000 $(3.0/4.0) & + basis 0.0000000000 0.000000000 $(1.0/4.0) & + basis $(2.0/3.0) $(1.0/3.0) 0.862008989 & + basis $(1.0/3.0) $(2.0/3.0) 0.137990996 & + basis $(1.0/3.0) $(2.0/3.0) 0.362008989 & + basis $(2.0/3.0) $(1.0/3.0) 0.637991011 & + origin 0.1 0.1 0.1 + +region box prism 0 4 0 8 0 1 -2.0 0.0 0.0 +create_box 2 box +create_atoms 2 box & + basis 1 1 & + basis 2 1 & + basis 3 2 & + basis 4 2 & + basis 5 2 & + basis 6 2 + +mass 1 95.95 #Mo +mass 2 32.065 #S + +pair_style rebomos +pair_coeff * * MoS.rebomos Mo S + +thermo_style custom step temp press pe ke cellgamma vol +thermo 10 +#dump 1 all atom 10 MoS.lammpstrj +fix 1 all nve +run 20 + diff --git a/examples/threebody/in.mos2.rebomos b/examples/threebody/in.mos2.rebomos new file mode 100644 index 0000000000..ca91f67003 --- /dev/null +++ b/examples/threebody/in.mos2.rebomos @@ -0,0 +1,31 @@ +# monolayer MoS2 +units metal +boundary p p f +processors * * 1 +atom_modify map array + +atom_style atomic +read_data single_layer_MoS2.data + +mass * 32.065 # mass of sulphur atom , uint: a.u.=1.66X10^(-27)kg +mass 1 95.94 # mass of molebdenum atom , uint: a.u.=1.66X10^(-27)kg + +########################## Define potentials ################################ +pair_style rebomos +pair_coeff * * MoS.rebomos Mo S S +######################################################################### + +### Simulation settings #### +timestep 0.001 +velocity all create 300.0 12345 loop geom + +############################ + +# Output +thermo 500 +thermo_style custom step etotal pe ke temp +thermo_modify lost warn + +###### Run molecular dynamics ###### +fix thermostat all nve +run 5000 diff --git a/examples/threebody/log.22Feb24.mos2-bulk.g++.1 b/examples/threebody/log.22Feb24.mos2-bulk.g++.1 new file mode 100644 index 0000000000..8218026f3d --- /dev/null +++ b/examples/threebody/log.22Feb24.mos2-bulk.g++.1 @@ -0,0 +1,85 @@ +LAMMPS (7 Feb 2024 - Development - patch_7Feb2024_update1-73-g36fa601fe0) + using 1 OpenMP thread(s) per MPI task +units metal + +lattice custom 1.0 a1 3.1903157234 0.0000000000 0.0000000000 a2 -1.5964590311 2.7651481541 0.0000000000 a3 0.0000000000 0.0000000000 13.9827680588 basis 0.0000000000 0.000000000 $(3.0/4.0) basis 0.0000000000 0.000000000 $(1.0/4.0) basis $(2.0/3.0) $(1.0/3.0) 0.862008989 basis $(1.0/3.0) $(2.0/3.0) 0.137990996 basis $(1.0/3.0) $(2.0/3.0) 0.362008989 basis $(2.0/3.0) $(1.0/3.0) 0.637991011 origin 0.1 0.1 0.1 +lattice custom 1.0 a1 3.1903157234 0.0000000000 0.0000000000 a2 -1.5964590311 2.7651481541 0.0000000000 a3 0.0000000000 0.0000000000 13.9827680588 basis 0.0000000000 0.000000000 0.75 basis 0.0000000000 0.000000000 $(1.0/4.0) basis $(2.0/3.0) $(1.0/3.0) 0.862008989 basis $(1.0/3.0) $(2.0/3.0) 0.137990996 basis $(1.0/3.0) $(2.0/3.0) 0.362008989 basis $(2.0/3.0) $(1.0/3.0) 0.637991011 origin 0.1 0.1 0.1 +lattice custom 1.0 a1 3.1903157234 0.0000000000 0.0000000000 a2 -1.5964590311 2.7651481541 0.0000000000 a3 0.0000000000 0.0000000000 13.9827680588 basis 0.0000000000 0.000000000 0.75 basis 0.0000000000 0.000000000 0.25 basis $(2.0/3.0) $(1.0/3.0) 0.862008989 basis $(1.0/3.0) $(2.0/3.0) 0.137990996 basis $(1.0/3.0) $(2.0/3.0) 0.362008989 basis $(2.0/3.0) $(1.0/3.0) 0.637991011 origin 0.1 0.1 0.1 +lattice custom 1.0 a1 3.1903157234 0.0000000000 0.0000000000 a2 -1.5964590311 2.7651481541 0.0000000000 a3 0.0000000000 0.0000000000 13.9827680588 basis 0.0000000000 0.000000000 0.75 basis 0.0000000000 0.000000000 0.25 basis 0.66666666666666662966 $(1.0/3.0) 0.862008989 basis $(1.0/3.0) $(2.0/3.0) 0.137990996 basis $(1.0/3.0) $(2.0/3.0) 0.362008989 basis $(2.0/3.0) $(1.0/3.0) 0.637991011 origin 0.1 0.1 0.1 +lattice custom 1.0 a1 3.1903157234 0.0000000000 0.0000000000 a2 -1.5964590311 2.7651481541 0.0000000000 a3 0.0000000000 0.0000000000 13.9827680588 basis 0.0000000000 0.000000000 0.75 basis 0.0000000000 0.000000000 0.25 basis 0.66666666666666662966 0.33333333333333331483 0.862008989 basis $(1.0/3.0) $(2.0/3.0) 0.137990996 basis $(1.0/3.0) $(2.0/3.0) 0.362008989 basis $(2.0/3.0) $(1.0/3.0) 0.637991011 origin 0.1 0.1 0.1 +lattice custom 1.0 a1 3.1903157234 0.0000000000 0.0000000000 a2 -1.5964590311 2.7651481541 0.0000000000 a3 0.0000000000 0.0000000000 13.9827680588 basis 0.0000000000 0.000000000 0.75 basis 0.0000000000 0.000000000 0.25 basis 0.66666666666666662966 0.33333333333333331483 0.862008989 basis 0.33333333333333331483 $(2.0/3.0) 0.137990996 basis $(1.0/3.0) $(2.0/3.0) 0.362008989 basis $(2.0/3.0) $(1.0/3.0) 0.637991011 origin 0.1 0.1 0.1 +lattice custom 1.0 a1 3.1903157234 0.0000000000 0.0000000000 a2 -1.5964590311 2.7651481541 0.0000000000 a3 0.0000000000 0.0000000000 13.9827680588 basis 0.0000000000 0.000000000 0.75 basis 0.0000000000 0.000000000 0.25 basis 0.66666666666666662966 0.33333333333333331483 0.862008989 basis 0.33333333333333331483 0.66666666666666662966 0.137990996 basis $(1.0/3.0) $(2.0/3.0) 0.362008989 basis $(2.0/3.0) $(1.0/3.0) 0.637991011 origin 0.1 0.1 0.1 +lattice custom 1.0 a1 3.1903157234 0.0000000000 0.0000000000 a2 -1.5964590311 2.7651481541 0.0000000000 a3 0.0000000000 0.0000000000 13.9827680588 basis 0.0000000000 0.000000000 0.75 basis 0.0000000000 0.000000000 0.25 basis 0.66666666666666662966 0.33333333333333331483 0.862008989 basis 0.33333333333333331483 0.66666666666666662966 0.137990996 basis 0.33333333333333331483 $(2.0/3.0) 0.362008989 basis $(2.0/3.0) $(1.0/3.0) 0.637991011 origin 0.1 0.1 0.1 +lattice custom 1.0 a1 3.1903157234 0.0000000000 0.0000000000 a2 -1.5964590311 2.7651481541 0.0000000000 a3 0.0000000000 0.0000000000 13.9827680588 basis 0.0000000000 0.000000000 0.75 basis 0.0000000000 0.000000000 0.25 basis 0.66666666666666662966 0.33333333333333331483 0.862008989 basis 0.33333333333333331483 0.66666666666666662966 0.137990996 basis 0.33333333333333331483 0.66666666666666662966 0.362008989 basis $(2.0/3.0) $(1.0/3.0) 0.637991011 origin 0.1 0.1 0.1 +lattice custom 1.0 a1 3.1903157234 0.0000000000 0.0000000000 a2 -1.5964590311 2.7651481541 0.0000000000 a3 0.0000000000 0.0000000000 13.9827680588 basis 0.0000000000 0.000000000 0.75 basis 0.0000000000 0.000000000 0.25 basis 0.66666666666666662966 0.33333333333333331483 0.862008989 basis 0.33333333333333331483 0.66666666666666662966 0.137990996 basis 0.33333333333333331483 0.66666666666666662966 0.362008989 basis 0.66666666666666662966 $(1.0/3.0) 0.637991011 origin 0.1 0.1 0.1 +lattice custom 1.0 a1 3.1903157234 0.0000000000 0.0000000000 a2 -1.5964590311 2.7651481541 0.0000000000 a3 0.0000000000 0.0000000000 13.9827680588 basis 0.0000000000 0.000000000 0.75 basis 0.0000000000 0.000000000 0.25 basis 0.66666666666666662966 0.33333333333333331483 0.862008989 basis 0.33333333333333331483 0.66666666666666662966 0.137990996 basis 0.33333333333333331483 0.66666666666666662966 0.362008989 basis 0.66666666666666662966 0.33333333333333331483 0.637991011 origin 0.1 0.1 0.1 +Lattice spacing in x,y,z = 4.7867748 2.7651482 13.982768 + +region box prism 0 4 0 8 0 1 -2.0 0.0 0.0 +create_box 2 box +Created triclinic box = (0 0 0) to (19.147099 22.121185 13.982768) with tilt (-9.5735495 0 0) + 1 by 1 by 1 MPI processor grid +create_atoms 2 box basis 1 1 basis 2 1 basis 3 2 basis 4 2 basis 5 2 basis 6 2 +Created 288 atoms + using lattice units in triclinic box = (0 0 0) to (19.147099 22.121185 13.982768) with tilt (-9.5735495 0 0) + create_atoms CPU = 0.000 seconds + +mass 1 95.95 #Mo +mass 2 32.065 #S + +pair_style rebomos +pair_coeff * * MoS.rebomos Mo S +Reading rebomos potential file MoS.rebomos with DATE: 2013-11-04 + +thermo_style custom step temp press pe ke cellgamma vol +thermo 10 +#dump 1 all atom 10 MoS.lammpstrj +fix 1 all nve +run 20 +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 13.4 + ghost atom cutoff = 13.4 + binsize = 6.7, bins = 5 4 3 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair rebomos, perpetual + attributes: full, newton on, ghost + pair build: full/bin/ghost + stencil: full/ghost/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 4.996 | 4.996 | 4.996 Mbytes + Step Temp Press PotEng KinEng CellGamma Volume + 0 0 28799.53 -2061.6112 0 113.40187 5922.4926 + 10 80.776057 13540.088 -2064.6132 2.9966028 113.40187 5922.4926 + 20 146.17503 -20669.371 -2067.0428 5.4227518 113.40187 5922.4926 +Loop time of 0.058071 on 1 procs for 20 steps with 288 atoms + +Performance: 29.757 ns/day, 0.807 hours/ns, 344.406 timesteps/s, 99.189 katom-step/s +99.8% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.057666 | 0.057666 | 0.057666 | 0.0 | 99.30 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 0.00024654 | 0.00024654 | 0.00024654 | 0.0 | 0.42 +Output | 2.3975e-05 | 2.3975e-05 | 2.3975e-05 | 0.0 | 0.04 +Modify | 3.8394e-05 | 3.8394e-05 | 3.8394e-05 | 0.0 | 0.07 +Other | | 9.596e-05 | | | 0.17 + +Nlocal: 288 ave 288 max 288 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 4285 ave 4285 max 4285 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 0 ave 0 max 0 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +FullNghs: 142848 ave 142848 max 142848 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 142848 +Ave neighs/atom = 496 +Neighbor list builds = 0 +Dangerous builds = 0 + +Total wall time: 0:00:00 diff --git a/examples/threebody/log.22Feb24.mos2-bulk.g++.4 b/examples/threebody/log.22Feb24.mos2-bulk.g++.4 new file mode 100644 index 0000000000..0b9cd3ed8a --- /dev/null +++ b/examples/threebody/log.22Feb24.mos2-bulk.g++.4 @@ -0,0 +1,85 @@ +LAMMPS (7 Feb 2024 - Development - patch_7Feb2024_update1-73-g36fa601fe0) + using 1 OpenMP thread(s) per MPI task +units metal + +lattice custom 1.0 a1 3.1903157234 0.0000000000 0.0000000000 a2 -1.5964590311 2.7651481541 0.0000000000 a3 0.0000000000 0.0000000000 13.9827680588 basis 0.0000000000 0.000000000 $(3.0/4.0) basis 0.0000000000 0.000000000 $(1.0/4.0) basis $(2.0/3.0) $(1.0/3.0) 0.862008989 basis $(1.0/3.0) $(2.0/3.0) 0.137990996 basis $(1.0/3.0) $(2.0/3.0) 0.362008989 basis $(2.0/3.0) $(1.0/3.0) 0.637991011 origin 0.1 0.1 0.1 +lattice custom 1.0 a1 3.1903157234 0.0000000000 0.0000000000 a2 -1.5964590311 2.7651481541 0.0000000000 a3 0.0000000000 0.0000000000 13.9827680588 basis 0.0000000000 0.000000000 0.75 basis 0.0000000000 0.000000000 $(1.0/4.0) basis $(2.0/3.0) $(1.0/3.0) 0.862008989 basis $(1.0/3.0) $(2.0/3.0) 0.137990996 basis $(1.0/3.0) $(2.0/3.0) 0.362008989 basis $(2.0/3.0) $(1.0/3.0) 0.637991011 origin 0.1 0.1 0.1 +lattice custom 1.0 a1 3.1903157234 0.0000000000 0.0000000000 a2 -1.5964590311 2.7651481541 0.0000000000 a3 0.0000000000 0.0000000000 13.9827680588 basis 0.0000000000 0.000000000 0.75 basis 0.0000000000 0.000000000 0.25 basis $(2.0/3.0) $(1.0/3.0) 0.862008989 basis $(1.0/3.0) $(2.0/3.0) 0.137990996 basis $(1.0/3.0) $(2.0/3.0) 0.362008989 basis $(2.0/3.0) $(1.0/3.0) 0.637991011 origin 0.1 0.1 0.1 +lattice custom 1.0 a1 3.1903157234 0.0000000000 0.0000000000 a2 -1.5964590311 2.7651481541 0.0000000000 a3 0.0000000000 0.0000000000 13.9827680588 basis 0.0000000000 0.000000000 0.75 basis 0.0000000000 0.000000000 0.25 basis 0.66666666666666662966 $(1.0/3.0) 0.862008989 basis $(1.0/3.0) $(2.0/3.0) 0.137990996 basis $(1.0/3.0) $(2.0/3.0) 0.362008989 basis $(2.0/3.0) $(1.0/3.0) 0.637991011 origin 0.1 0.1 0.1 +lattice custom 1.0 a1 3.1903157234 0.0000000000 0.0000000000 a2 -1.5964590311 2.7651481541 0.0000000000 a3 0.0000000000 0.0000000000 13.9827680588 basis 0.0000000000 0.000000000 0.75 basis 0.0000000000 0.000000000 0.25 basis 0.66666666666666662966 0.33333333333333331483 0.862008989 basis $(1.0/3.0) $(2.0/3.0) 0.137990996 basis $(1.0/3.0) $(2.0/3.0) 0.362008989 basis $(2.0/3.0) $(1.0/3.0) 0.637991011 origin 0.1 0.1 0.1 +lattice custom 1.0 a1 3.1903157234 0.0000000000 0.0000000000 a2 -1.5964590311 2.7651481541 0.0000000000 a3 0.0000000000 0.0000000000 13.9827680588 basis 0.0000000000 0.000000000 0.75 basis 0.0000000000 0.000000000 0.25 basis 0.66666666666666662966 0.33333333333333331483 0.862008989 basis 0.33333333333333331483 $(2.0/3.0) 0.137990996 basis $(1.0/3.0) $(2.0/3.0) 0.362008989 basis $(2.0/3.0) $(1.0/3.0) 0.637991011 origin 0.1 0.1 0.1 +lattice custom 1.0 a1 3.1903157234 0.0000000000 0.0000000000 a2 -1.5964590311 2.7651481541 0.0000000000 a3 0.0000000000 0.0000000000 13.9827680588 basis 0.0000000000 0.000000000 0.75 basis 0.0000000000 0.000000000 0.25 basis 0.66666666666666662966 0.33333333333333331483 0.862008989 basis 0.33333333333333331483 0.66666666666666662966 0.137990996 basis $(1.0/3.0) $(2.0/3.0) 0.362008989 basis $(2.0/3.0) $(1.0/3.0) 0.637991011 origin 0.1 0.1 0.1 +lattice custom 1.0 a1 3.1903157234 0.0000000000 0.0000000000 a2 -1.5964590311 2.7651481541 0.0000000000 a3 0.0000000000 0.0000000000 13.9827680588 basis 0.0000000000 0.000000000 0.75 basis 0.0000000000 0.000000000 0.25 basis 0.66666666666666662966 0.33333333333333331483 0.862008989 basis 0.33333333333333331483 0.66666666666666662966 0.137990996 basis 0.33333333333333331483 $(2.0/3.0) 0.362008989 basis $(2.0/3.0) $(1.0/3.0) 0.637991011 origin 0.1 0.1 0.1 +lattice custom 1.0 a1 3.1903157234 0.0000000000 0.0000000000 a2 -1.5964590311 2.7651481541 0.0000000000 a3 0.0000000000 0.0000000000 13.9827680588 basis 0.0000000000 0.000000000 0.75 basis 0.0000000000 0.000000000 0.25 basis 0.66666666666666662966 0.33333333333333331483 0.862008989 basis 0.33333333333333331483 0.66666666666666662966 0.137990996 basis 0.33333333333333331483 0.66666666666666662966 0.362008989 basis $(2.0/3.0) $(1.0/3.0) 0.637991011 origin 0.1 0.1 0.1 +lattice custom 1.0 a1 3.1903157234 0.0000000000 0.0000000000 a2 -1.5964590311 2.7651481541 0.0000000000 a3 0.0000000000 0.0000000000 13.9827680588 basis 0.0000000000 0.000000000 0.75 basis 0.0000000000 0.000000000 0.25 basis 0.66666666666666662966 0.33333333333333331483 0.862008989 basis 0.33333333333333331483 0.66666666666666662966 0.137990996 basis 0.33333333333333331483 0.66666666666666662966 0.362008989 basis 0.66666666666666662966 $(1.0/3.0) 0.637991011 origin 0.1 0.1 0.1 +lattice custom 1.0 a1 3.1903157234 0.0000000000 0.0000000000 a2 -1.5964590311 2.7651481541 0.0000000000 a3 0.0000000000 0.0000000000 13.9827680588 basis 0.0000000000 0.000000000 0.75 basis 0.0000000000 0.000000000 0.25 basis 0.66666666666666662966 0.33333333333333331483 0.862008989 basis 0.33333333333333331483 0.66666666666666662966 0.137990996 basis 0.33333333333333331483 0.66666666666666662966 0.362008989 basis 0.66666666666666662966 0.33333333333333331483 0.637991011 origin 0.1 0.1 0.1 +Lattice spacing in x,y,z = 4.7867748 2.7651482 13.982768 + +region box prism 0 4 0 8 0 1 -2.0 0.0 0.0 +create_box 2 box +Created triclinic box = (0 0 0) to (19.147099 22.121185 13.982768) with tilt (-9.5735495 0 0) + 2 by 2 by 1 MPI processor grid +create_atoms 2 box basis 1 1 basis 2 1 basis 3 2 basis 4 2 basis 5 2 basis 6 2 +Created 288 atoms + using lattice units in triclinic box = (0 0 0) to (19.147099 22.121185 13.982768) with tilt (-9.5735495 0 0) + create_atoms CPU = 0.000 seconds + +mass 1 95.95 #Mo +mass 2 32.065 #S + +pair_style rebomos +pair_coeff * * MoS.rebomos Mo S +Reading rebomos potential file MoS.rebomos with DATE: 2013-11-04 + +thermo_style custom step temp press pe ke cellgamma vol +thermo 10 +#dump 1 all atom 10 MoS.lammpstrj +fix 1 all nve +run 20 +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 13.4 + ghost atom cutoff = 13.4 + binsize = 6.7, bins = 5 4 3 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair rebomos, perpetual + attributes: full, newton on, ghost + pair build: full/bin/ghost + stencil: full/ghost/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 4.15 | 4.151 | 4.151 Mbytes + Step Temp Press PotEng KinEng CellGamma Volume + 0 0 28799.53 -2061.6112 0 113.40187 5922.4926 + 10 80.776057 13540.088 -2064.6132 2.9966028 113.40187 5922.4926 + 20 146.17503 -20669.371 -2067.0428 5.4227518 113.40187 5922.4926 +Loop time of 0.0219485 on 4 procs for 20 steps with 288 atoms + +Performance: 78.730 ns/day, 0.305 hours/ns, 911.225 timesteps/s, 262.433 katom-step/s +96.3% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.018118 | 0.019372 | 0.020087 | 0.5 | 88.26 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 0.0015635 | 0.0023195 | 0.0035967 | 1.6 | 10.57 +Output | 2.5017e-05 | 4.6834e-05 | 0.00010543 | 0.0 | 0.21 +Modify | 1.3954e-05 | 1.423e-05 | 1.4594e-05 | 0.0 | 0.06 +Other | | 0.0001957 | | | 0.89 + +Nlocal: 72 ave 72 max 72 min +Histogram: 4 0 0 0 0 0 0 0 0 0 +Nghost: 2771.5 ave 2775 max 2768 min +Histogram: 2 0 0 0 0 0 0 0 0 2 +Neighs: 0 ave 0 max 0 min +Histogram: 4 0 0 0 0 0 0 0 0 0 +FullNghs: 35712 ave 35712 max 35712 min +Histogram: 4 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 142848 +Ave neighs/atom = 496 +Neighbor list builds = 0 +Dangerous builds = 0 + +Total wall time: 0:00:00 diff --git a/examples/threebody/log.22Feb24.mos2.rebomos.g++.1 b/examples/threebody/log.22Feb24.mos2.rebomos.g++.1 new file mode 100644 index 0000000000..f7c5b3c74d --- /dev/null +++ b/examples/threebody/log.22Feb24.mos2.rebomos.g++.1 @@ -0,0 +1,95 @@ +LAMMPS (7 Feb 2024 - Development - patch_7Feb2024_update1-73-g36fa601fe0) + using 1 OpenMP thread(s) per MPI task +# monolayer MoS2 +units metal +boundary p p f +processors * * 1 +atom_modify map array + +atom_style atomic +read_data single_layer_MoS2.data +Reading data file ... + triclinic box = (0 0 -100) to (51.15232 44.299209 100) with tilt (25.57616 0 0) +WARNING: Triclinic box skew is large. LAMMPS will run inefficiently. (src/domain.cpp:219) + 1 by 1 by 1 MPI processor grid + reading atoms ... + 768 atoms + read_data CPU = 0.002 seconds + +mass * 32.065 # mass of sulphur atom , uint: a.u.=1.66X10^(-27)kg +mass 1 95.94 # mass of molebdenum atom , uint: a.u.=1.66X10^(-27)kg + +########################## Define potentials ################################ +pair_style rebomos +pair_coeff * * MoS.rebomos Mo S S +Reading rebomos potential file MoS.rebomos with DATE: 2013-11-04 +######################################################################### + +### Simulation settings #### +timestep 0.001 +velocity all create 300.0 12345 loop geom + +############################ + +# Output +thermo 500 +thermo_style custom step etotal pe ke temp +thermo_modify lost warn + +###### Run molecular dynamics ###### +fix thermostat all nve +run 5000 +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 13.4 + ghost atom cutoff = 13.4 + binsize = 6.7, bins = 12 7 30 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair rebomos, perpetual + attributes: full, newton on, ghost + pair build: full/bin/ghost + stencil: full/ghost/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 4.473 | 4.473 | 4.473 Mbytes + Step TotEng PotEng KinEng Temp + 0 -5466.9785 -5496.7212 29.742759 300 + 500 -5466.964 -5482.6985 15.734505 158.7059 + 1000 -5466.9615 -5480.9492 13.98763 141.08607 + 1500 -5466.964 -5482.6912 15.727258 158.63281 + 2000 -5466.9657 -5483.3606 16.394878 165.36675 + 2500 -5466.9624 -5481.6253 14.662948 147.89765 + 3000 -5466.9642 -5482.7515 15.7873 159.23842 + 3500 -5466.9654 -5483.3789 16.413502 165.5546 + 4000 -5466.9628 -5481.848 14.885236 150.13977 + 4500 -5466.9648 -5483.5045 16.539775 166.82825 + 5000 -5466.9649 -5483.4932 16.528298 166.71249 +Loop time of 19.1009 on 1 procs for 5000 steps with 768 atoms + +Performance: 22.617 ns/day, 1.061 hours/ns, 261.768 timesteps/s, 201.038 katom-step/s +99.9% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 19.042 | 19.042 | 19.042 | 0.0 | 99.69 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 0.018451 | 0.018451 | 0.018451 | 0.0 | 0.10 +Output | 0.00015575 | 0.00015575 | 0.00015575 | 0.0 | 0.00 +Modify | 0.023931 | 0.023931 | 0.023931 | 0.0 | 0.13 +Other | | 0.01658 | | | 0.09 + +Nlocal: 768 ave 768 max 768 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 1158 ave 1158 max 1158 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 0 ave 0 max 0 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +FullNghs: 141824 ave 141824 max 141824 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 141824 +Ave neighs/atom = 184.66667 +Neighbor list builds = 0 +Dangerous builds = 0 +Total wall time: 0:00:19 diff --git a/examples/threebody/log.22Feb24.mos2.rebomos.g++.4 b/examples/threebody/log.22Feb24.mos2.rebomos.g++.4 new file mode 100644 index 0000000000..dc1cfa84d4 --- /dev/null +++ b/examples/threebody/log.22Feb24.mos2.rebomos.g++.4 @@ -0,0 +1,95 @@ +LAMMPS (7 Feb 2024 - Development - patch_7Feb2024_update1-73-g36fa601fe0) + using 1 OpenMP thread(s) per MPI task +# monolayer MoS2 +units metal +boundary p p f +processors * * 1 +atom_modify map array + +atom_style atomic +read_data single_layer_MoS2.data +Reading data file ... + triclinic box = (0 0 -100) to (51.15232 44.299209 100) with tilt (25.57616 0 0) +WARNING: Triclinic box skew is large. LAMMPS will run inefficiently. (src/domain.cpp:219) + 2 by 2 by 1 MPI processor grid + reading atoms ... + 768 atoms + read_data CPU = 0.002 seconds + +mass * 32.065 # mass of sulphur atom , uint: a.u.=1.66X10^(-27)kg +mass 1 95.94 # mass of molebdenum atom , uint: a.u.=1.66X10^(-27)kg + +########################## Define potentials ################################ +pair_style rebomos +pair_coeff * * MoS.rebomos Mo S S +Reading rebomos potential file MoS.rebomos with DATE: 2013-11-04 +######################################################################### + +### Simulation settings #### +timestep 0.001 +velocity all create 300.0 12345 loop geom + +############################ + +# Output +thermo 500 +thermo_style custom step etotal pe ke temp +thermo_modify lost warn + +###### Run molecular dynamics ###### +fix thermostat all nve +run 5000 +Neighbor list info ... + update: every = 1 steps, delay = 0 steps, check = yes + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 13.4 + ghost atom cutoff = 13.4 + binsize = 6.7, bins = 12 7 30 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair rebomos, perpetual + attributes: full, newton on, ghost + pair build: full/bin/ghost + stencil: full/ghost/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 4.045 | 4.045 | 4.045 Mbytes + Step TotEng PotEng KinEng Temp + 0 -5466.9785 -5496.7212 29.742759 300 + 500 -5466.964 -5482.6985 15.734505 158.7059 + 1000 -5466.9615 -5480.9492 13.98763 141.08607 + 1500 -5466.964 -5482.6912 15.727258 158.63281 + 2000 -5466.9657 -5483.3606 16.394878 165.36675 + 2500 -5466.9624 -5481.6253 14.662948 147.89765 + 3000 -5466.9642 -5482.7515 15.7873 159.23842 + 3500 -5466.9654 -5483.3789 16.413502 165.5546 + 4000 -5466.9628 -5481.848 14.885236 150.13977 + 4500 -5466.9648 -5483.5045 16.539775 166.82825 + 5000 -5466.9649 -5483.4932 16.528298 166.71249 +Loop time of 5.69326 on 4 procs for 5000 steps with 768 atoms + +Performance: 75.879 ns/day, 0.316 hours/ns, 878.231 timesteps/s, 674.482 katom-step/s +98.6% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 5.2611 | 5.3666 | 5.4358 | 3.0 | 94.26 +Neigh | 0 | 0 | 0 | 0.0 | 0.00 +Comm | 0.23476 | 0.30106 | 0.40642 | 12.8 | 5.29 +Output | 0.00014996 | 0.0004478 | 0.0013353 | 0.0 | 0.01 +Modify | 0.0068861 | 0.0069917 | 0.0072247 | 0.2 | 0.12 +Other | | 0.01814 | | | 0.32 + +Nlocal: 192 ave 194 max 190 min +Histogram: 1 0 0 0 0 2 0 0 0 1 +Nghost: 710 ave 712 max 708 min +Histogram: 1 0 0 0 0 2 0 0 0 1 +Neighs: 0 ave 0 max 0 min +Histogram: 4 0 0 0 0 0 0 0 0 0 +FullNghs: 35456 ave 35824 max 35088 min +Histogram: 1 0 0 0 0 2 0 0 0 1 + +Total # of neighbors = 141824 +Ave neighs/atom = 184.66667 +Neighbor list builds = 0 +Dangerous builds = 0 +Total wall time: 0:00:05 diff --git a/examples/wall/in.wall.flow b/examples/wall/in.wall.flow new file mode 100644 index 0000000000..9dfe001a55 --- /dev/null +++ b/examples/wall/in.wall.flow @@ -0,0 +1,79 @@ +variable nrun equal 1000 +variable dump_count equal 10 + +variable nwall equal 4 +variable w1 equal 67 +variable w2 equal 71 +variable w3 equal 75 +variable w4 equal 79 + +variable x_cylinder equal 20 +variable y_cylinder equal 17 +variable r_cylinder equal 4 + +variable MASS equal 1 +variable TEMP equal 0.4 +variable VFLOW equal 0.5 + +units lj +atom_style atomic + +lattice fcc 0.3 +region sim_box block 0 84 0 34 0 10 + +boundary p p p + +create_box 2 sim_box +region reg_cylinder cylinder z ${x_cylinder} ${y_cylinder} ${r_cylinder} EDGE EDGE + +create_atoms 1 box + +## setup obstacle ## +group g_obst region reg_cylinder +group g_flow subtract all g_obst +set group g_obst type 2 + +mass 1 ${MASS} +mass 2 ${MASS} + +velocity g_flow create ${TEMP} 4928459 rot yes dist gaussian +velocity g_obst set 0.0 0.0 0.0 + +pair_style lj/cut 1.122462 +pair_coeff 1 1 1.0 1.0 +pair_coeff 1 2 1.0 1.0 +pair_coeff 2 2 1.0 1.0 +pair_modify shift yes + +neighbor 0.3 bin +neigh_modify delay 0 every 20 check no + +fix 1 g_flow nve +fix 2 g_flow wall/flow x ${VFLOW} ${TEMP} 123 ${nwall} ${w1} ${w2} ${w3} ${w4} + +variable dump_every equal ${nrun}/${dump_count} +variable thermo_every equal ${dump_every} +variable restart_every equal ${nrun}/10 + +##### uncomment for grid aggregation ##### +#variable gr_Nx equal 42 +#variable gr_Ny equal 17 +#variable gr_Nz equal 1 +#variable gr_Nevery equal ${dump_every} +#variable gr_Nrepeat equal 1 +#variable gr_Nfreq equal ${dump_every} +#fix 3 g_flow ave/grid ${gr_Nevery} ${gr_Nrepeat} ${gr_Nfreq} ${gr_Nx} ${gr_Ny} ${gr_Nz} vx vy vz density/mass norm all ave one +#compute ct_gridId g_flow property/grid ${gr_Nx} ${gr_Ny} ${gr_Nz} id +#dump dmp_grid g_flow grid ${dump_every} grid.lammpstrj c_ct_gridId:grid:data f_3:grid:data[*] +########################################## + +#dump dmp_coord all atom ${dump_every} dump.lammpstrj + +#compute ct_Temp g_flow temp/com +#thermo_style custom step temp epair emol etotal press c_ct_Temp + +#restart ${restart_every} flow.restart + +timestep 0.005 +thermo ${thermo_every} +run ${nrun} diff --git a/examples/wall/log.7Feb24.wall.flow.g++.1 b/examples/wall/log.7Feb24.wall.flow.g++.1 new file mode 100644 index 0000000000..75e8b66fe1 --- /dev/null +++ b/examples/wall/log.7Feb24.wall.flow.g++.1 @@ -0,0 +1,182 @@ +LAMMPS (21 Nov 2023 - Development - patch_21Nov2023-758-ge33590b2fc-modified) + using 1 OpenMP thread(s) per MPI task +variable nrun equal 1000 +variable dump_count equal 10 + +variable nwall equal 4 +variable w1 equal 67 +variable w2 equal 71 +variable w3 equal 75 +variable w4 equal 79 + +variable x_cylinder equal 20 +variable y_cylinder equal 17 +variable r_cylinder equal 4 + +variable MASS equal 1 +variable TEMP equal 0.4 +variable VFLOW equal 0.5 + +units lj +atom_style atomic + +lattice fcc 0.3 +Lattice spacing in x,y,z = 2.3712622 2.3712622 2.3712622 +region sim_box block 0 84 0 34 0 10 + +boundary p p p + +create_box 2 sim_box +Created orthogonal box = (0 0 0) to (199.18603 80.622915 23.712622) + 1 by 1 by 1 MPI processor grid +region reg_cylinder cylinder z ${x_cylinder} ${y_cylinder} ${r_cylinder} EDGE EDGE +region reg_cylinder cylinder z 20 ${y_cylinder} ${r_cylinder} EDGE EDGE +region reg_cylinder cylinder z 20 17 ${r_cylinder} EDGE EDGE +region reg_cylinder cylinder z 20 17 4 EDGE EDGE + +create_atoms 1 box +Created 114240 atoms + using lattice units in orthogonal box = (0 0 0) to (199.18603 80.622915 23.712622) + create_atoms CPU = 0.010 seconds + +## setup obstacle ## +group g_obst region reg_cylinder +1950 atoms in group g_obst +group g_flow subtract all g_obst +112290 atoms in group g_flow +set group g_obst type 2 +Setting atom values ... + 1950 settings made for type + +mass 1 ${MASS} +mass 1 1 +mass 2 ${MASS} +mass 2 1 + +velocity g_flow create ${TEMP} 4928459 rot yes dist gaussian +velocity g_flow create 0.4 4928459 rot yes dist gaussian +velocity g_obst set 0.0 0.0 0.0 + +pair_style lj/cut 1.122462 +pair_coeff 1 1 1.0 1.0 +pair_coeff 1 2 1.0 1.0 +pair_coeff 2 2 1.0 1.0 +pair_modify shift yes + +neighbor 0.3 bin +neigh_modify delay 0 every 20 check no + +fix 1 g_flow nve +fix 2 g_flow wall/flow x ${VFLOW} ${TEMP} 123 ${nwall} ${w1} ${w2} ${w3} ${w4} +fix 2 g_flow wall/flow x 0.5 ${TEMP} 123 ${nwall} ${w1} ${w2} ${w3} ${w4} +fix 2 g_flow wall/flow x 0.5 0.4 123 ${nwall} ${w1} ${w2} ${w3} ${w4} +fix 2 g_flow wall/flow x 0.5 0.4 123 4 ${w1} ${w2} ${w3} ${w4} +fix 2 g_flow wall/flow x 0.5 0.4 123 4 67 ${w2} ${w3} ${w4} +fix 2 g_flow wall/flow x 0.5 0.4 123 4 67 71 ${w3} ${w4} +fix 2 g_flow wall/flow x 0.5 0.4 123 4 67 71 75 ${w4} +fix 2 g_flow wall/flow x 0.5 0.4 123 4 67 71 75 79 + +variable dump_every equal ${nrun}/${dump_count} +variable dump_every equal 1000/${dump_count} +variable dump_every equal 1000/10 +variable thermo_every equal ${dump_every} +variable thermo_every equal 100 +variable restart_every equal ${nrun}/10 +variable restart_every equal 1000/10 + +##### uncomment for grid aggregation ##### +#variable gr_Nx equal 42 +#variable gr_Ny equal 17 +#variable gr_Nz equal 1 +#variable gr_Nevery equal ${dump_every} +#variable gr_Nrepeat equal 1 +#variable gr_Nfreq equal ${dump_every} +#fix 3 g_flow ave/grid ${gr_Nevery} ${gr_Nrepeat} ${gr_Nfreq} ${gr_Nx} ${gr_Ny} ${gr_Nz} vx vy vz density/mass norm all ave one +#compute ct_gridId g_flow property/grid ${gr_Nx} ${gr_Ny} ${gr_Nz} id +#dump dmp_grid g_flow grid ${dump_every} grid.lammpstrj c_ct_gridId:grid:data f_3:grid:data[*] +########################################## + +#dump dmp_coord all atom ${dump_every} dump.lammpstrj + +#compute ct_Temp g_flow temp/com +#thermo_style custom step temp epair emol etotal press c_ct_Temp + +#restart ${restart_every} flow.restart + +timestep 0.005 +thermo ${thermo_every} +thermo 100 +run ${nrun} +run 1000 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- fix wall/flow command: doi:10.1177/10943420231213013 + +@Article{Pavlov-etal-IJHPCA-2024, + author = {Daniil Pavlov and Vladislav Galigerov and Daniil Kolotinskii and Vsevolod Nikolskiy and Vladimir Stegailov}, + title = {GPU-based molecular dynamics of fluid flows: Reaching for turbulence}, + journal = {The International Journal of High Performance Computing Applications}, + year = 2024, + volume = 38, + number = 1, + pages = 34-49 +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 20 steps, delay = 0 steps, check = no + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 1.422462 + ghost atom cutoff = 1.422462 + binsize = 0.711231, bins = 281 114 34 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 26.69 | 26.69 | 26.69 Mbytes + Step Temp E_pair E_mol TotEng Press + 0 0.39317221 0 0 0.58975315 0.11795063 + 100 0.3671684 0.045118445 0 0.59586622 0.27378331 + 200 0.3732041 0.036897471 0 0.59669873 0.24917809 + 300 0.37432305 0.036501844 0 0.5979815 0.24715194 + 400 0.37603886 0.035350565 0 0.59940392 0.24480762 + 500 0.37617142 0.036949771 0 0.60120196 0.24862985 + 600 0.37751983 0.036484268 0 0.60275905 0.24784635 + 700 0.37787831 0.037327783 0 0.60414029 0.25060427 + 800 0.37959242 0.036206184 0 0.60558983 0.2476903 + 900 0.38019033 0.036874395 0 0.6071549 0.24984211 + 1000 0.38070666 0.037068948 0 0.60812395 0.25041936 +Loop time of 5.61598 on 1 procs for 1000 steps with 114240 atoms + +Performance: 76923.319 tau/day, 178.063 timesteps/s, 20.342 Matom-step/s +99.7% CPU use with 1 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 2.6351 | 2.6351 | 2.6351 | 0.0 | 46.92 +Neigh | 1.2994 | 1.2994 | 1.2994 | 0.0 | 23.14 +Comm | 0.26576 | 0.26576 | 0.26576 | 0.0 | 4.73 +Output | 0.0030531 | 0.0030531 | 0.0030531 | 0.0 | 0.05 +Modify | 1.3019 | 1.3019 | 1.3019 | 0.0 | 23.18 +Other | | 0.1107 | | | 1.97 + +Nlocal: 114240 ave 114240 max 114240 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Nghost: 20119 ave 20119 max 20119 min +Histogram: 1 0 0 0 0 0 0 0 0 0 +Neighs: 164018 ave 164018 max 164018 min +Histogram: 1 0 0 0 0 0 0 0 0 0 + +Total # of neighbors = 164018 +Ave neighs/atom = 1.4357318 +Neighbor list builds = 50 +Dangerous builds not checked +Total wall time: 0:00:05 diff --git a/examples/wall/log.7Feb24.wall.flow.g++.4 b/examples/wall/log.7Feb24.wall.flow.g++.4 new file mode 100644 index 0000000000..1efe7bb28e --- /dev/null +++ b/examples/wall/log.7Feb24.wall.flow.g++.4 @@ -0,0 +1,182 @@ +LAMMPS (21 Nov 2023 - Development - patch_21Nov2023-758-ge33590b2fc-modified) + using 1 OpenMP thread(s) per MPI task +variable nrun equal 1000 +variable dump_count equal 10 + +variable nwall equal 4 +variable w1 equal 67 +variable w2 equal 71 +variable w3 equal 75 +variable w4 equal 79 + +variable x_cylinder equal 20 +variable y_cylinder equal 17 +variable r_cylinder equal 4 + +variable MASS equal 1 +variable TEMP equal 0.4 +variable VFLOW equal 0.5 + +units lj +atom_style atomic + +lattice fcc 0.3 +Lattice spacing in x,y,z = 2.3712622 2.3712622 2.3712622 +region sim_box block 0 84 0 34 0 10 + +boundary p p p + +create_box 2 sim_box +Created orthogonal box = (0 0 0) to (199.18603 80.622915 23.712622) + 4 by 1 by 1 MPI processor grid +region reg_cylinder cylinder z ${x_cylinder} ${y_cylinder} ${r_cylinder} EDGE EDGE +region reg_cylinder cylinder z 20 ${y_cylinder} ${r_cylinder} EDGE EDGE +region reg_cylinder cylinder z 20 17 ${r_cylinder} EDGE EDGE +region reg_cylinder cylinder z 20 17 4 EDGE EDGE + +create_atoms 1 box +Created 114240 atoms + using lattice units in orthogonal box = (0 0 0) to (199.18603 80.622915 23.712622) + create_atoms CPU = 0.003 seconds + +## setup obstacle ## +group g_obst region reg_cylinder +1950 atoms in group g_obst +group g_flow subtract all g_obst +112290 atoms in group g_flow +set group g_obst type 2 +Setting atom values ... + 1950 settings made for type + +mass 1 ${MASS} +mass 1 1 +mass 2 ${MASS} +mass 2 1 + +velocity g_flow create ${TEMP} 4928459 rot yes dist gaussian +velocity g_flow create 0.4 4928459 rot yes dist gaussian +velocity g_obst set 0.0 0.0 0.0 + +pair_style lj/cut 1.122462 +pair_coeff 1 1 1.0 1.0 +pair_coeff 1 2 1.0 1.0 +pair_coeff 2 2 1.0 1.0 +pair_modify shift yes + +neighbor 0.3 bin +neigh_modify delay 0 every 20 check no + +fix 1 g_flow nve +fix 2 g_flow wall/flow x ${VFLOW} ${TEMP} 123 ${nwall} ${w1} ${w2} ${w3} ${w4} +fix 2 g_flow wall/flow x 0.5 ${TEMP} 123 ${nwall} ${w1} ${w2} ${w3} ${w4} +fix 2 g_flow wall/flow x 0.5 0.4 123 ${nwall} ${w1} ${w2} ${w3} ${w4} +fix 2 g_flow wall/flow x 0.5 0.4 123 4 ${w1} ${w2} ${w3} ${w4} +fix 2 g_flow wall/flow x 0.5 0.4 123 4 67 ${w2} ${w3} ${w4} +fix 2 g_flow wall/flow x 0.5 0.4 123 4 67 71 ${w3} ${w4} +fix 2 g_flow wall/flow x 0.5 0.4 123 4 67 71 75 ${w4} +fix 2 g_flow wall/flow x 0.5 0.4 123 4 67 71 75 79 + +variable dump_every equal ${nrun}/${dump_count} +variable dump_every equal 1000/${dump_count} +variable dump_every equal 1000/10 +variable thermo_every equal ${dump_every} +variable thermo_every equal 100 +variable restart_every equal ${nrun}/10 +variable restart_every equal 1000/10 + +##### uncomment for grid aggregation ##### +#variable gr_Nx equal 42 +#variable gr_Ny equal 17 +#variable gr_Nz equal 1 +#variable gr_Nevery equal ${dump_every} +#variable gr_Nrepeat equal 1 +#variable gr_Nfreq equal ${dump_every} +#fix 3 g_flow ave/grid ${gr_Nevery} ${gr_Nrepeat} ${gr_Nfreq} ${gr_Nx} ${gr_Ny} ${gr_Nz} vx vy vz density/mass norm all ave one +#compute ct_gridId g_flow property/grid ${gr_Nx} ${gr_Ny} ${gr_Nz} id +#dump dmp_grid g_flow grid ${dump_every} grid.lammpstrj c_ct_gridId:grid:data f_3:grid:data[*] +########################################## + +#dump dmp_coord all atom ${dump_every} dump.lammpstrj + +#compute ct_Temp g_flow temp/com +#thermo_style custom step temp epair emol etotal press c_ct_Temp + +#restart ${restart_every} flow.restart + +timestep 0.005 +thermo ${thermo_every} +thermo 100 +run ${nrun} +run 1000 + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Your simulation uses code contributions which should be cited: + +- fix wall/flow command: doi:10.1177/10943420231213013 + +@Article{Pavlov-etal-IJHPCA-2024, + author = {Daniil Pavlov and Vladislav Galigerov and Daniil Kolotinskii and Vsevolod Nikolskiy and Vladimir Stegailov}, + title = {GPU-based molecular dynamics of fluid flows: Reaching for turbulence}, + journal = {The International Journal of High Performance Computing Applications}, + year = 2024, + volume = 38, + number = 1, + pages = 34-49 +} + +CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE-CITE + +Generated 0 of 1 mixed pair_coeff terms from geometric mixing rule +Neighbor list info ... + update: every = 20 steps, delay = 0 steps, check = no + max neighbors/atom: 2000, page size: 100000 + master list distance cutoff = 1.422462 + ghost atom cutoff = 1.422462 + binsize = 0.711231, bins = 281 114 34 + 1 neighbor lists, perpetual/occasional/extra = 1 0 0 + (1) pair lj/cut, perpetual + attributes: half, newton on + pair build: half/bin/atomonly/newton + stencil: half/bin/3d + bin: standard +Per MPI rank memory allocation (min/avg/max) = 8.496 | 8.496 | 8.496 Mbytes + Step Temp E_pair E_mol TotEng Press + 0 0.39317221 0 0 0.58975315 0.11795063 + 100 0.36726398 0.045386014 0 0.59627716 0.27402111 + 200 0.37384538 0.036574547 0 0.5973377 0.24836729 + 300 0.37487455 0.036519645 0 0.59882654 0.24691726 + 400 0.37591417 0.036405755 0 0.60027207 0.24700641 + 500 0.37654714 0.037008829 0 0.60182459 0.24883444 + 600 0.3778008 0.03663706 0 0.6033333 0.24874392 + 700 0.37851338 0.036714175 0 0.60447928 0.24881829 + 800 0.37984876 0.036237049 0 0.6060052 0.24843003 + 900 0.38022763 0.036847615 0 0.60718407 0.24987198 + 1000 0.38084717 0.037139994 0 0.60840575 0.25070072 +Loop time of 2.20347 on 4 procs for 1000 steps with 114240 atoms + +Performance: 196054.093 tau/day, 453.829 timesteps/s, 51.845 Matom-step/s +95.6% CPU use with 4 MPI tasks x 1 OpenMP threads + +MPI task timing breakdown: +Section | min time | avg time | max time |%varavg| %total +--------------------------------------------------------------- +Pair | 0.67927 | 0.70882 | 0.73473 | 2.4 | 32.17 +Neigh | 0.32928 | 0.34467 | 0.36084 | 2.0 | 15.64 +Comm | 0.3211 | 0.36609 | 0.40741 | 6.1 | 16.61 +Output | 0.0017748 | 0.0032465 | 0.0046508 | 2.1 | 0.15 +Modify | 0.71135 | 0.74424 | 0.76001 | 2.3 | 33.78 +Other | | 0.03641 | | | 1.65 + +Nlocal: 28560 ave 29169 max 27884 min +Histogram: 1 0 0 0 0 2 0 0 0 1 +Nghost: 6452.25 ave 6546 max 6368 min +Histogram: 1 0 0 0 2 0 0 0 0 1 +Neighs: 40893 ave 42032 max 39445 min +Histogram: 1 0 0 0 1 0 0 1 0 1 + +Total # of neighbors = 163572 +Ave neighs/atom = 1.4318277 +Neighbor list builds = 50 +Dangerous builds not checked +Total wall time: 0:00:02 diff --git a/fortran/lammps.f90 b/fortran/lammps.f90 index 28e40bca44..d0133f075c 100644 --- a/fortran/lammps.f90 +++ b/fortran/lammps.f90 @@ -118,6 +118,8 @@ MODULE LIBLAMMPS PROCEDURE :: extract_fix => lmp_extract_fix PROCEDURE :: extract_variable => lmp_extract_variable PROCEDURE :: set_variable => lmp_set_variable + PROCEDURE :: set_string_variable => lmp_set_string_variable + PROCEDURE :: set_internal_variable => lmp_set_internal_variable PROCEDURE, PRIVATE :: lmp_gather_atoms_int PROCEDURE, PRIVATE :: lmp_gather_atoms_double GENERIC :: gather_atoms => lmp_gather_atoms_int, & @@ -557,6 +559,21 @@ MODULE LIBLAMMPS INTEGER(c_int) :: lammps_set_variable END FUNCTION lammps_set_variable + FUNCTION lammps_set_string_variable(handle, name, str) BIND(C) + IMPORT :: c_int, c_ptr + IMPLICIT NONE + TYPE(c_ptr), VALUE :: handle, name, str + INTEGER(c_int) :: lammps_set_string_variable + END FUNCTION lammps_set_string_variable + + FUNCTION lammps_set_internal_variable(handle, name, val) BIND(C) + IMPORT :: c_int, c_ptr, c_double + IMPLICIT NONE + TYPE(c_ptr), VALUE :: handle, name + REAL(c_double), VALUE :: val + INTEGER(c_int) :: lammps_set_internal_variable + END FUNCTION lammps_set_internal_variable + SUBROUTINE lammps_gather_atoms(handle, name, type, count, data) BIND(C) IMPORT :: c_int, c_ptr IMPLICIT NONE @@ -1631,6 +1648,43 @@ CONTAINS END IF END SUBROUTINE lmp_set_variable + ! equivalent function to lammps_set_string_variable + SUBROUTINE lmp_set_string_variable(self, name, str) + CLASS(lammps), INTENT(IN) :: self + CHARACTER(LEN=*), INTENT(IN) :: name, str + INTEGER :: err + TYPE(c_ptr) :: Cstr, Cname + + Cstr = f2c_string(str) + Cname = f2c_string(name) + err = lammps_set_string_variable(self%handle, Cname, Cstr) + CALL lammps_free(Cname) + CALL lammps_free(Cstr) + IF (err /= 0) THEN + CALL lmp_error(self, LMP_ERROR_WARNING + LMP_ERROR_WORLD, & + 'WARNING: unable to set string variable "' // name & + // '" [Fortran/set_variable]') + END IF + END SUBROUTINE lmp_set_string_variable + + ! equivalent function to lammps_set_internal_variable + SUBROUTINE lmp_set_internal_variable(self, name, val) + CLASS(lammps), INTENT(IN) :: self + CHARACTER(LEN=*), INTENT(IN) :: name + REAL(KIND=c_double), INTENT(IN) :: val + INTEGER :: err + TYPE(c_ptr) :: Cname + + Cname = f2c_string(name) + err = lammps_set_internal_variable(self%handle, Cname, val) + CALL lammps_free(Cname) + IF (err /= 0) THEN + CALL lmp_error(self, LMP_ERROR_WARNING + LMP_ERROR_WORLD, & + 'WARNING: unable to set internal variable "' // name & + // '" [Fortran/set_variable]') + END IF + END SUBROUTINE lmp_set_internal_variable + ! equivalent function to lammps_gather_atoms (for integers) SUBROUTINE lmp_gather_atoms_int(self, name, count, data) CLASS(lammps), INTENT(IN) :: self diff --git a/lib/gpu/Makefile.cuda b/lib/gpu/Makefile.cuda index be8003e02e..75428c9513 100644 --- a/lib/gpu/Makefile.cuda +++ b/lib/gpu/Makefile.cuda @@ -134,11 +134,11 @@ $(OBJ_DIR)/scan_app.cu_o: cudpp_mini/scan_app.cu $(GPU_LIB): $(OBJS) $(CUDPP) $(AR) -crusv $(GPU_LIB) $(OBJS) $(CUDPP) @cp $(EXTRAMAKE) Makefile.lammps - + # test app for querying device info $(BIN_DIR)/nvc_get_devices: ./geryon/ucl_get_devices.cpp $(NVD_H) - $(CUDR) -o $@ ./geryon/ucl_get_devices.cpp -DUCL_CUDADR $(CUDA_LIB) -lcuda + $(CUDR) -o $@ ./geryon/ucl_get_devices.cpp -DUCL_CUDADR $(CUDA_LIB) -lcuda clean: -rm -f $(EXECS) $(GPU_LIB) $(OBJS) $(CUDPP) $(CUHS) *.linkinfo diff --git a/lib/gpu/Makefile.cuda_mps b/lib/gpu/Makefile.cuda_mps index 06d2ef0339..22a34c105c 100644 --- a/lib/gpu/Makefile.cuda_mps +++ b/lib/gpu/Makefile.cuda_mps @@ -133,11 +133,11 @@ $(OBJ_DIR)/scan_app.cu_o: cudpp_mini/scan_app.cu $(GPU_LIB): $(OBJS) $(CUDPP) $(AR) -crusv $(GPU_LIB) $(OBJS) $(CUDPP) @cp $(EXTRAMAKE) Makefile.lammps - + # test app for querying device info $(BIN_DIR)/nvc_get_devices: ./geryon/ucl_get_devices.cpp $(NVD_H) - $(CUDR) -o $@ ./geryon/ucl_get_devices.cpp -DUCL_CUDADR $(CUDA_LIB) -lcuda + $(CUDR) -o $@ ./geryon/ucl_get_devices.cpp -DUCL_CUDADR $(CUDA_LIB) -lcuda clean: -rm -f $(EXECS) $(GPU_LIB) $(OBJS) $(CUDPP) $(CUHS) *.linkinfo diff --git a/lib/gpu/Makefile.hip b/lib/gpu/Makefile.hip index f5a0d03608..0350c841c4 100644 --- a/lib/gpu/Makefile.hip +++ b/lib/gpu/Makefile.hip @@ -98,10 +98,10 @@ HIP_GPU_OPTS += $(HIP_OPTS) -I./ ifeq (spirv,$(HIP_PLATFORM)) HIP_HOST_OPTS += -fPIC HIP_GPU_CC = $(HIP_PATH)/bin/hipcc -c - HIP_GPU_OPTS_S = + HIP_GPU_OPTS_S = HIP_GPU_OPTS_E = HIP_KERNEL_SUFFIX = .cpp - HIP_LIBS_TARGET = + HIP_LIBS_TARGET = export HCC_AMDGPU_TARGET := $(HIP_ARCH) else ifeq (clang,$(HIP_COMPILER)) HIP_HOST_OPTS += -fPIC diff --git a/lib/gpu/Makefile.lammps.mac_ocl b/lib/gpu/Makefile.lammps.mac_ocl index 0073efa2ba..dbbd789464 100644 --- a/lib/gpu/Makefile.lammps.mac_ocl +++ b/lib/gpu/Makefile.lammps.mac_ocl @@ -2,4 +2,4 @@ gpu_SYSINC = -DFFT_SINGLE gpu_SYSLIB = -framework OpenCL -gpu_SYSPATH = +gpu_SYSPATH = diff --git a/lib/gpu/Makefile.lammps.mingw-cross b/lib/gpu/Makefile.lammps.mingw-cross deleted file mode 100644 index 12d833c744..0000000000 --- a/lib/gpu/Makefile.lammps.mingw-cross +++ /dev/null @@ -1,6 +0,0 @@ -# Settings that the LAMMPS build will import when this package library is used -# settings for OpenCL builds -gpu_SYSINC = -gpu_SYSLIB = -Wl,--enable-stdcall-fixup -L../../tools/mingw-cross$(LIBOBJDIR) -Wl,-Bdynamic,-lOpenCL,-Bstatic -gpu_SYSPATH = - diff --git a/lib/gpu/Makefile.lammps.opencl b/lib/gpu/Makefile.lammps.opencl index 413ae79210..50f5e63f77 100644 --- a/lib/gpu/Makefile.lammps.opencl +++ b/lib/gpu/Makefile.lammps.opencl @@ -2,4 +2,4 @@ gpu_SYSINC = gpu_SYSLIB = -lOpenCL -gpu_SYSPATH = +gpu_SYSPATH = diff --git a/lib/gpu/Makefile.linux b/lib/gpu/Makefile.linux index 3c37672e01..e02413f3ba 100644 --- a/lib/gpu/Makefile.linux +++ b/lib/gpu/Makefile.linux @@ -1,4 +1,4 @@ -# /* ---------------------------------------------------------------------- +# /* ---------------------------------------------------------------------- # Generic Linux Makefile for CUDA # - Change CUDA_ARCH for your GPU # ------------------------------------------------------------------------- */ diff --git a/lib/gpu/Makefile.linux_multi b/lib/gpu/Makefile.linux_multi index 005f659079..e3a76d9934 100644 --- a/lib/gpu/Makefile.linux_multi +++ b/lib/gpu/Makefile.linux_multi @@ -1,4 +1,4 @@ -# /* ---------------------------------------------------------------------- +# /* ---------------------------------------------------------------------- # Generic Linux Makefile for CUDA complied for multiple compute capabilities # - Add your GPU to CUDA_CODE # ------------------------------------------------------------------------- */ diff --git a/lib/gpu/Makefile.linux_opencl b/lib/gpu/Makefile.linux_opencl index 43d012dc4a..b4b25544ee 100644 --- a/lib/gpu/Makefile.linux_opencl +++ b/lib/gpu/Makefile.linux_opencl @@ -1,4 +1,4 @@ -# /* ---------------------------------------------------------------------- +# /* ---------------------------------------------------------------------- # Generic Linux Makefile for OpenCL - Mixed precision # ------------------------------------------------------------------------- */ @@ -11,7 +11,7 @@ EXTRAMAKE = Makefile.lammps.opencl LMP_INC = -DLAMMPS_SMALLBIG -OCL_INC = +OCL_INC = OCL_CPP = mpic++ -std=c++11 -O3 -DMPICH_IGNORE_CXX_SEEK $(LMP_INC) $(OCL_INC) OCL_LINK = -lOpenCL OCL_PREC = -D_SINGLE_DOUBLE diff --git a/lib/gpu/Makefile.mac_opencl b/lib/gpu/Makefile.mac_opencl index ae7e8ca6fd..3a9fd39f35 100644 --- a/lib/gpu/Makefile.mac_opencl +++ b/lib/gpu/Makefile.mac_opencl @@ -1,4 +1,4 @@ -# /* ---------------------------------------------------------------------- +# /* ---------------------------------------------------------------------- # Generic Mac Makefile for OpenCL - Single precision with FFT_SINGLE # ------------------------------------------------------------------------- */ diff --git a/lib/gpu/Makefile.mac_opencl_mpi b/lib/gpu/Makefile.mac_opencl_mpi index 9be9f07e93..b0c6e39aae 100644 --- a/lib/gpu/Makefile.mac_opencl_mpi +++ b/lib/gpu/Makefile.mac_opencl_mpi @@ -1,4 +1,4 @@ -# /* ---------------------------------------------------------------------- +# /* ---------------------------------------------------------------------- # Generic Mac Makefile for OpenCL - Single precision with FFT_SINGLE # ------------------------------------------------------------------------- */ diff --git a/lib/gpu/Makefile.oneapi b/lib/gpu/Makefile.oneapi index 32800676aa..e67f4bb082 100644 --- a/lib/gpu/Makefile.oneapi +++ b/lib/gpu/Makefile.oneapi @@ -1,4 +1,4 @@ -# /* ---------------------------------------------------------------------- +# /* ---------------------------------------------------------------------- # Linux Makefile for Intel oneAPI - Mixed precision # ------------------------------------------------------------------------- */ diff --git a/lib/gpu/Makefile.oneapi_prof b/lib/gpu/Makefile.oneapi_prof index 1e21597373..58a03392e2 100644 --- a/lib/gpu/Makefile.oneapi_prof +++ b/lib/gpu/Makefile.oneapi_prof @@ -1,4 +1,4 @@ -# /* ---------------------------------------------------------------------- +# /* ---------------------------------------------------------------------- # Linux Makefile for Intel oneAPI - Mixed precision (with timing enabled) # ------------------------------------------------------------------------- */ diff --git a/lib/gpu/Makefile.serial b/lib/gpu/Makefile.serial index 6c94911f32..67d2ce927d 100644 --- a/lib/gpu/Makefile.serial +++ b/lib/gpu/Makefile.serial @@ -1,4 +1,4 @@ -# /* ---------------------------------------------------------------------- +# /* ---------------------------------------------------------------------- # Generic Linux Makefile for CUDA without MPI libraries # - Change CUDA_ARCH for your GPU # ------------------------------------------------------------------------- */ diff --git a/lib/gpu/Nvidia.makefile b/lib/gpu/Nvidia.makefile index 298d404117..d351b87b37 100644 --- a/lib/gpu/Nvidia.makefile +++ b/lib/gpu/Nvidia.makefile @@ -11,7 +11,7 @@ HOST_H = lal_answer.h lal_atom.h lal_balance.h lal_base_atomic.h lal_base_amoeba lal_base_charge.h lal_base_dipole.h lal_base_dpd.h \ lal_base_ellipsoid.h lal_base_three.h lal_device.h lal_neighbor.h \ lal_neighbor_shared.h lal_pre_ocl_config.h $(NVD_H) - + # Source files SRCS := $(wildcard ./lal_*.cpp) OBJS := $(subst ./,$(OBJ_DIR)/,$(SRCS:%.cpp=%.o)) @@ -127,7 +127,7 @@ $(GPU_LIB): $(OBJS) $(CUDPP) # test app for querying device info $(BIN_DIR)/nvc_get_devices: ./geryon/ucl_get_devices.cpp $(NVD_H) - $(CUDR) -o $@ ./geryon/ucl_get_devices.cpp -DUCL_CUDADR $(CUDA_LIB) -lcuda + $(CUDR) -o $@ ./geryon/ucl_get_devices.cpp -DUCL_CUDADR $(CUDA_LIB) -lcuda clean: -rm -f $(EXECS) $(GPU_LIB) $(OBJS) $(CUDPP) $(CUHS) *.cubin *.linkinfo diff --git a/lib/gpu/Nvidia.makefile_multi b/lib/gpu/Nvidia.makefile_multi index ddbee4f2a1..c4b27ebbcb 100644 --- a/lib/gpu/Nvidia.makefile_multi +++ b/lib/gpu/Nvidia.makefile_multi @@ -89,7 +89,7 @@ $(GPU_LIB): $(OBJS) $(CUDPP) # test app for querying device info $(BIN_DIR)/nvc_get_devices: ./geryon/ucl_get_devices.cpp $(NVD_H) - $(CUDR) -o $@ ./geryon/ucl_get_devices.cpp -DUCL_CUDADR $(CUDA_LIB) -lcuda + $(CUDR) -o $@ ./geryon/ucl_get_devices.cpp -DUCL_CUDADR $(CUDA_LIB) -lcuda clean: -rm -f $(EXECS) $(GPU_LIB) $(OBJS) $(CUDPP) $(CUHS) *.linkinfo diff --git a/lib/gpu/geryon/nvd_device.h b/lib/gpu/geryon/nvd_device.h index e63a1f56b2..e627a7ca60 100644 --- a/lib/gpu/geryon/nvd_device.h +++ b/lib/gpu/geryon/nvd_device.h @@ -138,7 +138,7 @@ class UCL_Device { /** \note You cannot delete the default stream **/ inline void pop_command_queue() { if (_cq.size()<2) return; - CU_SAFE_CALL_NS(cuStreamDestroy(_cq.back())); + cuStreamDestroy(_cq.back()); _cq.pop_back(); } @@ -426,8 +426,8 @@ void UCL_Device::clear() { if (_device>-1) { for (int i=1; i struct _ucl_memcpy; // Both are images template<> struct _ucl_memcpy<2,2> { template - static inline void mc(p1 &dst, const p2 &src, const size_t n, - cl_command_queue &cq, const cl_bool block, - const size_t dst_offset, const size_t src_offset) { + static inline void mc(p1 &/*dst*/, const p2 &/*src*/, const size_t /*n*/, + cl_command_queue &/*cq*/, const cl_bool /*block*/, + const size_t /*dst_offset*/, const size_t /*src_offset*/) { assert(0==1); } template - static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, - const size_t spitch, const size_t cols, - const size_t rows, cl_command_queue &cq, - const cl_bool block, - const size_t dst_offset, const size_t src_offset) { + static inline void mc(p1 &/*dst*/, const size_t /*dpitch*/, const p2 &/*src*/, + const size_t /*spitch*/, const size_t /*cols*/, + const size_t /*rows*/, cl_command_queue &/*cq*/, + const cl_bool /*block*/, + const size_t /*dst_offset*/, const size_t /*src_offset*/) { assert(0==1); } }; @@ -509,17 +509,17 @@ template<> struct _ucl_memcpy<2,2> { // Destination is texture, source on device template<> struct _ucl_memcpy<2,0> { template - static inline void mc(p1 &dst, const p2 &src, const size_t n, - cl_command_queue &cq, const cl_bool block, - const size_t dst_offset, const size_t src_offset) { + static inline void mc(p1 &/*dst*/, const p2 &/*src*/, const size_t /*n*/, + cl_command_queue &/*cq*/, const cl_bool /*block*/, + const size_t /*dst_offset*/, const size_t /*src_offset*/) { assert(0==1); } template - static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, - const size_t spitch, const size_t cols, - const size_t rows, cl_command_queue &cq, - const cl_bool block, - const size_t dst_offset, const size_t src_offset) { + static inline void mc(p1 &/*dst*/, const size_t /*dpitch*/, const p2 &/*src*/, + const size_t /*spitch*/, const size_t /*cols*/, + const size_t /*rows*/, cl_command_queue &/*cq*/, + const cl_bool /*block*/, + const size_t /*dst_offset*/, const size_t /*src_offset*/) { assert(0==1); } }; @@ -527,17 +527,17 @@ template<> struct _ucl_memcpy<2,0> { // Destination is texture, source on host template<> struct _ucl_memcpy<2,1> { template - static inline void mc(p1 &dst, const p2 &src, const size_t n, - cl_command_queue &cq, const cl_bool block, - const size_t dst_offset, const size_t src_offset) { + static inline void mc(p1 &/*dst*/, const p2 &/*src*/, const size_t /*n*/, + cl_command_queue &/*cq*/, const cl_bool /*block*/, + const size_t /*dst_offset*/, const size_t /*src_offset*/) { assert(0==1); } template - static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, - const size_t spitch, const size_t cols, - const size_t rows, cl_command_queue &cq, - const cl_bool block, - const size_t dst_offset, const size_t src_offset) { + static inline void mc(p1 &/*dst*/, const size_t /*dpitch*/, const p2 &/*src*/, + const size_t /*spitch*/, const size_t /*cols*/, + const size_t /*rows*/, cl_command_queue &/*cq*/, + const cl_bool /*block*/, + const size_t /*dst_offset*/, const size_t /*src_offset*/) { assert(0==1); } }; @@ -545,17 +545,17 @@ template<> struct _ucl_memcpy<2,1> { // Source is texture, dest on device template<> struct _ucl_memcpy<0,2> { template - static inline void mc(p1 &dst, const p2 &src, const size_t n, - cl_command_queue &cq, const cl_bool block, - const size_t dst_offset, const size_t src_offset) { + static inline void mc(p1 &/*dst*/, const p2 &/*src*/, const size_t /*n*/, + cl_command_queue &/*cq*/, const cl_bool /*block*/, + const size_t /*dst_offset*/, const size_t /*src_offset*/) { assert(0==1); } template - static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, - const size_t spitch, const size_t cols, - const size_t rows, cl_command_queue &cq, - const cl_bool block, - const size_t dst_offset, const size_t src_offset) { + static inline void mc(p1 &/*dst*/, const size_t /*dpitch*/, const p2 &/*src*/, + const size_t /*spitch*/, const size_t /*cols*/, + const size_t /*rows*/, cl_command_queue &/*cq*/, + const cl_bool /*block*/, + const size_t /*dst_offset*/, const size_t /*src_offset*/) { assert(0==1); } }; @@ -563,17 +563,17 @@ template<> struct _ucl_memcpy<0,2> { // Source is texture, dest on host template<> struct _ucl_memcpy<1,2> { template - static inline void mc(p1 &dst, const p2 &src, const size_t n, - cl_command_queue &cq, const cl_bool block, - const size_t dst_offset, const size_t src_offset) { + static inline void mc(p1 &/*dst*/, const p2 &/*src*/, const size_t /*n*/, + cl_command_queue &/*cq*/, const cl_bool /*block*/, + const size_t /*dst_offset*/, const size_t /*src_offset*/) { assert(0==1); } template - static inline void mc(p1 &dst, const size_t dpitch, const p2 &src, - const size_t spitch, const size_t cols, - const size_t rows, cl_command_queue &cq, - const cl_bool block, - const size_t dst_offset, const size_t src_offset) { + static inline void mc(p1 &/*dst*/, const size_t /*dpitch*/, const p2 &/*src*/, + const size_t /*spitch*/, const size_t /*cols*/, + const size_t /*rows*/, cl_command_queue &/*cq*/, + const cl_bool /*block*/, + const size_t /*dst_offset*/, const size_t /*src_offset*/) { assert(0==1); } }; diff --git a/lib/gpu/geryon/ucl_copy.h b/lib/gpu/geryon/ucl_copy.h index 94b57f7a09..b7f4c4c986 100644 --- a/lib/gpu/geryon/ucl_copy.h +++ b/lib/gpu/geryon/ucl_copy.h @@ -507,7 +507,7 @@ template <> struct _ucl_cast_copy<0,0> { } template static inline void cc(mat1 & /*dst*/, const mat2 & /*src*/, const size_t /*rows*/, - const size_t cols, mat3 & /*cast_buffer*/, command_queue & /*cq*/) { + const size_t /*cols*/, mat3 & /*cast_buffer*/, command_queue & /*cq*/) { assert(0==1); } }; diff --git a/lib/gpu/geryon/ucl_d_vec.h b/lib/gpu/geryon/ucl_d_vec.h index 5e281fef07..fdb62d8fab 100644 --- a/lib/gpu/geryon/ucl_d_vec.h +++ b/lib/gpu/geryon/ucl_d_vec.h @@ -156,7 +156,7 @@ class UCL_D_Vec : public UCL_BaseMat { * \param stride Number of _elements_ between the start of each row **/ template inline void view(ucl_type &input, const size_t rows, const size_t cols, - const size_t stride) { view(input,rows,cols); } + const size_t /*stride*/) { view(input,rows,cols); } /// Do not allocate memory, instead use an existing allocation from Geryon /** This function must be passed a Geryon vector or matrix container. @@ -185,7 +185,7 @@ class UCL_D_Vec : public UCL_BaseMat { * - The view does not prevent the memory from being freed by the * allocating container when using CUDA APIs **/ template - inline void view(ptr_type input, const size_t rows, const size_t cols, + inline void view(ptr_type input, const size_t /*rows*/, const size_t cols, UCL_Device &dev) { #ifdef UCL_DEBUG assert(rows==1); @@ -213,7 +213,7 @@ class UCL_D_Vec : public UCL_BaseMat { * \param stride Number of _elements_ between the start of each row **/ template inline void view(ptr_type input, const size_t rows, const size_t cols, - const size_t stride, UCL_Device &dev) + const size_t stride, UCL_Device &/*dev*/) { view(input,rows,cols,stride); } /// Do not allocate memory, instead use an existing allocation @@ -262,7 +262,7 @@ class UCL_D_Vec : public UCL_BaseMat { * \param stride Number of _elements_ between the start of each row **/ template inline void view_offset(const size_t offset,ucl_type &input,const size_t rows, - const size_t cols, const size_t stride) + const size_t cols, const size_t /*stride*/) { view_offset(offset,input,rows,cols); } /// Do not allocate memory, instead use an existing allocation from Geryon @@ -292,7 +292,7 @@ class UCL_D_Vec : public UCL_BaseMat { * - The view does not prevent the memory from being freed by the * allocating container when using CUDA APIs **/ template - inline void view_offset(const size_t offset,ptr_type input,const size_t rows, + inline void view_offset(const size_t offset,ptr_type input,const size_t /*rows*/, const size_t cols, UCL_Device &dev) { #ifdef UCL_DEBUG assert(rows==1); @@ -328,7 +328,7 @@ class UCL_D_Vec : public UCL_BaseMat { * \param stride Number of _elements_ between the start of each row **/ template inline void view_offset(const size_t offset,ptr_type input,const size_t rows, - const size_t cols,const size_t stride,UCL_Device &dev) + const size_t cols,const size_t stride,UCL_Device &/*dev*/) { view_offset(offset,input,rows,cols,stride); } /// Do not allocate memory, instead use an existing allocation diff --git a/lib/gpu/geryon/ucl_h_vec.h b/lib/gpu/geryon/ucl_h_vec.h index 9f734ac40c..25e12a3ef5 100644 --- a/lib/gpu/geryon/ucl_h_vec.h +++ b/lib/gpu/geryon/ucl_h_vec.h @@ -156,7 +156,7 @@ class UCL_H_Vec : public UCL_BaseMat { * \param stride Number of _elements_ between the start of each row **/ template inline void view(ucl_type &input, const size_t rows, const size_t cols, - const size_t stride) { view(input,rows,cols); } + const size_t /*stride*/) { view(input,rows,cols); } /// Do not allocate memory, instead use an existing allocation from Geryon /** This function must be passed a Geryon vector or matrix container. @@ -214,7 +214,7 @@ class UCL_H_Vec : public UCL_BaseMat { * \param stride Number of _elements_ between the start of each row **/ template inline void view(ptr_type *input, const size_t rows, const size_t cols, - const size_t stride, UCL_Device &dev) + const size_t stride, UCL_Device &/*dev*/) { view(input,rows,cols,stride); } /// Do not allocate memory, instead use an existing allocation @@ -259,7 +259,7 @@ class UCL_H_Vec : public UCL_BaseMat { * \param stride Number of _elements_ between the start of each row **/ template inline void view_offset(const size_t offset,ucl_type &input,const size_t rows, - const size_t cols, const size_t stride) + const size_t cols, const size_t /*stride*/) { view_offset(offset,input,rows,cols); } /// Do not allocate memory, instead use an existing allocation from Geryon @@ -382,10 +382,10 @@ class UCL_H_Vec : public UCL_BaseMat { /// Get element at index i inline const numtyp & operator[](const int i) const { return _array[i]; } /// 2D access (row should always be 0) - inline numtyp & operator()(const int row, const int col) + inline numtyp & operator()(const int /*row*/, const int col) { return _array[col]; } /// 2D access (row should always be 0) - inline const numtyp & operator()(const int row, const int col) const + inline const numtyp & operator()(const int /*row*/, const int col) const { return _array[col]; } /// Returns pointer to memory pointer for allocation on host diff --git a/lib/gpu/geryon/ucl_print.h b/lib/gpu/geryon/ucl_print.h index 98ae8a8c06..6b1caf90e9 100644 --- a/lib/gpu/geryon/ucl_print.h +++ b/lib/gpu/geryon/ucl_print.h @@ -35,7 +35,7 @@ template <> struct _ucl_print<1> { } template static inline void p(const mat_type &mat, const size_t n, std::ostream &out, - const std::string delim, UCL_Device &dev) { + const std::string delim, UCL_Device &/*dev*/) { p(mat,n,out,delim); } template @@ -59,7 +59,7 @@ template <> struct _ucl_print<1> { template static inline void p(const mat_type &mat,const size_t rows,const size_t cols, std::ostream &out,const std::string delim, - const std::string row_delim, UCL_Device &dev) { + const std::string row_delim, UCL_Device &/*dev*/) { p(mat,rows,cols,out,delim,row_delim); } }; diff --git a/lib/gpu/geryon/ucl_s_obj_help.h b/lib/gpu/geryon/ucl_s_obj_help.h index 9bc2c40fe2..486caa4f2a 100644 --- a/lib/gpu/geryon/ucl_s_obj_help.h +++ b/lib/gpu/geryon/ucl_s_obj_help.h @@ -53,7 +53,7 @@ template <> struct _ucl_s_obj_help<1> { } template - static inline int alloc(t1 &host, t2 &device, t3 &_buffer, + static inline int alloc(t1 &host, t2 &device, t3 &/*_buffer*/, const int cols, mat_type &cq, const enum UCL_MEMOPT kind1, const enum UCL_MEMOPT kind2) { @@ -79,7 +79,7 @@ template <> struct _ucl_s_obj_help<1> { } template - static inline int alloc(t1 &host, t2 &device, t3 &_buffer, + static inline int alloc(t1 &host, t2 &device, t3 &/*_buffer*/, const int rows, const int cols, UCL_Device &acc, const enum UCL_MEMOPT kind1, const enum UCL_MEMOPT kind2) { @@ -105,7 +105,7 @@ template <> struct _ucl_s_obj_help<1> { } template - static inline int alloc(t1 &host, t2 &device, t3 &_buffer, + static inline int alloc(t1 &host, t2 &device, t3 &/*_buffer*/, const int rows, const int cols, mat_type &cq, const enum UCL_MEMOPT kind1, const enum UCL_MEMOPT kind2) { @@ -177,7 +177,7 @@ template <> struct _ucl_s_obj_help<1> { } template - static inline int dev_resize(t1 &device, t2 &host, t3 &buff, const int rows, + static inline int dev_resize(t1 &device, t2 &host, t3 &/*buff*/, const int rows, const int cols) { if (device.kind()==UCL_VIEW) { device.view(host); @@ -369,7 +369,7 @@ template struct _ucl_s_obj_help { } template - static inline int dev_resize(t1 &device, t2 &host, t3 &buff, const int rows, + static inline int dev_resize(t1 &device, t2 &/*host*/, t3 &buff, const int rows, const int cols) { int err=buff.resize(rows,cols); if (err!=UCL_SUCCESS) diff --git a/lib/gpu/geryon/ucl_vector.h b/lib/gpu/geryon/ucl_vector.h index 0939bae31e..10290f0585 100644 --- a/lib/gpu/geryon/ucl_vector.h +++ b/lib/gpu/geryon/ucl_vector.h @@ -147,10 +147,10 @@ class UCL_Vector { /// Get element at index i inline const hosttype & operator[](const int i) const { return host[i]; } /// 2D access (row should always be 0) - inline hosttype & operator()(const int row, const int col) + inline hosttype & operator()(const int /*row*/, const int col) { return host[col]; } /// 2D access (row should always be 0) - inline const hosttype & operator()(const int row, const int col) const + inline const hosttype & operator()(const int /*row*/, const int col) const { return host[col]; } /// Returns pointer to memory pointer for allocation on host diff --git a/lib/gpu/lal_amoeba.cu b/lib/gpu/lal_amoeba.cu index e7c313301e..a92509f06d 100644 --- a/lib/gpu/lal_amoeba.cu +++ b/lib/gpu/lal_amoeba.cu @@ -2033,13 +2033,13 @@ __kernel void k_amoeba_special15(__global int * dev_nbor, const __global tagint *restrict special15, const int inum, const int nall, const int nbor_pitch, const int t_per_atom) { - int tid, ii, offset, n_stride, i; + int tid, ii, offset, n_stride, j; atom_info(t_per_atom,ii,tid,offset); if (ii> SBBITS & 3; - int j = sj & NEIGHMASK; + j = sj & NEIGHMASK; tagint jtag = tag[j]; if (!which) { diff --git a/lib/gpu/lal_base_sph.cpp b/lib/gpu/lal_base_sph.cpp index f373c0ebb6..22ef5964ea 100644 --- a/lib/gpu/lal_base_sph.cpp +++ b/lib/gpu/lal_base_sph.cpp @@ -195,7 +195,7 @@ void BaseSPHT::compute(const int f_ago, const int inum_full, const int nall, int **firstneigh, const bool eflag_in, const bool vflag_in, const bool eatom, const bool vatom, int &host_start, const double cpu_time, bool &success, tagint *tag, - double **host_v, const int nlocal) { + double **host_v) { acc_timers(); int eflag, vflag; if (eatom) eflag=2; diff --git a/lib/gpu/lal_base_sph.h b/lib/gpu/lal_base_sph.h index d37e85f170..46d2879093 100644 --- a/lib/gpu/lal_base_sph.h +++ b/lib/gpu/lal_base_sph.h @@ -132,7 +132,7 @@ class BaseSPH { int **firstneigh, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, const double cpu_time, bool &success, tagint *tag, - double **v, const int nlocal); + double **v); /// Pair loop with device neighboring int** compute(const int ago, const int inum_full, const int nall, diff --git a/lib/gpu/lal_edpd.cu b/lib/gpu/lal_edpd.cu index 9662d15aea..0982d219eb 100644 --- a/lib/gpu/lal_edpd.cu +++ b/lib/gpu/lal_edpd.cu @@ -324,8 +324,8 @@ __kernel void k_edpd(const __global numtyp4 *restrict x_, f.z+=delz*force; // heat transfer - - if (r < coeff2w) { + + if (r < coeff2w) { numtyp wrT = (numtyp)1.0 - r/coeff2w; wrT = MAX((numtyp)0.0,MIN((numtyp)1.0,wrT)); wrT = ucl_pow(wrT, (numtyp)0.5*coeff2z); // powerT[itype][jtype] @@ -401,10 +401,8 @@ __kernel void k_edpd_fast(const __global numtyp4 *restrict x_, __local numtyp4 sc[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; __local numtyp4 kc[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; __local numtyp sp_lj[4]; - __local numtyp sp_sqrt[4]; if (tid<4) { sp_lj[tid]=sp_lj_in[tid]; - sp_sqrt[tid]=sp_sqrt_in[tid]; } if (tid> SBBITS & 3; - int j = sj & NEIGHMASK; + j = sj & NEIGHMASK; tagint jtag = tag[j]; if (!which) { diff --git a/lib/gpu/lal_mdpd.cu b/lib/gpu/lal_mdpd.cu index 6230cb2496..1e0ca8f052 100644 --- a/lib/gpu/lal_mdpd.cu +++ b/lib/gpu/lal_mdpd.cu @@ -210,13 +210,12 @@ __kernel void k_mdpd(const __global numtyp4 *restrict x_, const numtyp rhoi = extra[i].x; - numtyp factor_dpd, factor_sqrt; + numtyp factor_dpd; for ( ; nbor tag2) { tag1 = jtag; tag2 = itag; @@ -322,10 +320,8 @@ __kernel void k_mdpd_fast(const __global numtyp4 *restrict x_, __local numtyp4 coeff[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; __local numtyp4 coeff2[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; __local numtyp sp_lj[4]; - __local numtyp sp_sqrt[4]; if (tid<4) { sp_lj[tid]=sp_lj_in[tid]; - sp_sqrt[tid]=sp_sqrt_in[tid]; } if (tid tag2) { tag1 = jtag; tag2 = itag; diff --git a/lib/gpu/lal_sph_heatconduction.cu b/lib/gpu/lal_sph_heatconduction.cu index 21c936347a..e2ba40db0c 100644 --- a/lib/gpu/lal_sph_heatconduction.cu +++ b/lib/gpu/lal_sph_heatconduction.cu @@ -70,7 +70,9 @@ __kernel void k_sph_heatconduction(const __global numtyp4 *restrict x_, atom_info(t_per_atom,ii,tid,offset); int n_stride; +#if (SHUFFLE_AVAIL == 0) local_allocate_store_pair(); +#endif acctyp dEacc = (acctyp)0; @@ -171,7 +173,9 @@ __kernel void k_sph_heatconduction_fast(const __global numtyp4 *restrict x_, #endif int n_stride; +#if (SHUFFLE_AVAIL == 0) local_allocate_store_pair(); +#endif acctyp dEacc = (acctyp)0; @@ -234,7 +238,7 @@ __kernel void k_sph_heatconduction_fast(const __global numtyp4 *restrict x_, // Lucy Kernel, 2d wfd = (numtyp)-19.098593171027440292 * wfd * wfd * ihsq * ihsq * ihsq; } - + // total thermal energy increment numtyp D = coeffx; // alpha[itype][jtype] diffusion coefficient numtyp deltaE = (numtyp)2.0 * mass_itype * mass_jtype / (mass_itype + mass_jtype); diff --git a/lib/gpu/lal_sph_heatconduction_ext.cpp b/lib/gpu/lal_sph_heatconduction_ext.cpp index 92e0e342d2..645480154c 100644 --- a/lib/gpu/lal_sph_heatconduction_ext.cpp +++ b/lib/gpu/lal_sph_heatconduction_ext.cpp @@ -110,10 +110,10 @@ void sph_heatconduction_gpu_compute(const int ago, const int inum_full, const in int **firstneigh, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, const double cpu_time, bool &success, tagint *host_tag, - double **host_v, const int nlocal) { + double **host_v) { SPHHeatConductionMF.compute(ago, inum_full, nall, host_x, host_type, ilist, numj, firstneigh, eflag, vflag, eatom, vatom, host_start, cpu_time, success, - host_tag, host_v, nlocal); + host_tag, host_v); } void sph_heatconduction_gpu_get_extra_data(double *host_rho, double *host_esph) { diff --git a/lib/gpu/lal_sph_lj.cu b/lib/gpu/lal_sph_lj.cu index 23863b5e28..f376dfc533 100644 --- a/lib/gpu/lal_sph_lj.cu +++ b/lib/gpu/lal_sph_lj.cu @@ -362,7 +362,7 @@ __kernel void k_sph_lj_fast(const __global numtyp4 *restrict x_, // Lucy Kernel, 2d wfd = (numtyp)-19.098593171027440292 * wfd * wfd * ihsq * ihsq * ihsq; } - + // function call to LJ EOS numtyp fcj[2]; LJEOS2(rhoj, esphj, cvj, fcj); @@ -404,7 +404,7 @@ __kernel void k_sph_lj_fast(const __global numtyp4 *restrict x_, drhoEacc.y += deltaE; if (EVFLAG && eflag) { - numtyp e = (numtyp)0; + numtyp e = (numtyp)0; energy+=e; } if (EVFLAG && vflag) { diff --git a/lib/gpu/lal_sph_lj_ext.cpp b/lib/gpu/lal_sph_lj_ext.cpp index 55f85c030e..ba88dc4b19 100644 --- a/lib/gpu/lal_sph_lj_ext.cpp +++ b/lib/gpu/lal_sph_lj_ext.cpp @@ -110,10 +110,10 @@ void sph_lj_gpu_compute(const int ago, const int inum_full, const int nall, int **firstneigh, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, const double cpu_time, bool &success, tagint *host_tag, - double **host_v, const int nlocal) { + double **host_v) { SPHLJMF.compute(ago, inum_full, nall, host_x, host_type, ilist, numj, firstneigh, eflag, vflag, eatom, vatom, host_start, cpu_time, success, - host_tag, host_v, nlocal); + host_tag, host_v); } void sph_lj_gpu_get_extra_data(double *host_rho, double *host_esph, double *host_cv) { diff --git a/lib/gpu/lal_sph_taitwater.cu b/lib/gpu/lal_sph_taitwater.cu index 708d3ae43b..9424d58996 100644 --- a/lib/gpu/lal_sph_taitwater.cu +++ b/lib/gpu/lal_sph_taitwater.cu @@ -145,9 +145,9 @@ __kernel void k_sph_taitwater(const __global numtyp4 *restrict x_, // Lucy Kernel, 2d wfd = (numtyp)-19.098593171027440292 * wfd * wfd * ihsq * ihsq * ihsq; } - + // compute pressure of atom j with Tait EOS - + numtyp tmp = rhoj / rho0_jtype; numtyp fj = tmp * tmp * tmp; fj = B_jtype * (fj * fj * tmp - (numtyp)1.0); @@ -321,7 +321,7 @@ __kernel void k_sph_taitwater_fast(const __global numtyp4 *restrict x_, wfd = (numtyp)-19.098593171027440292 * wfd * wfd * ihsq * ihsq * ihsq; } - // compute pressure of atom j with Tait EOS + // compute pressure of atom j with Tait EOS numtyp tmp = rhoj / rho0_jtype; numtyp fj = tmp * tmp * tmp; fj = B_jtype * (fj * fj * tmp - (numtyp)1.0); @@ -356,7 +356,7 @@ __kernel void k_sph_taitwater_fast(const __global numtyp4 *restrict x_, drhoEacc.y += deltaE; if (EVFLAG && eflag) { - numtyp e = (numtyp)0; + numtyp e = (numtyp)0; energy+=e; } if (EVFLAG && vflag) { diff --git a/lib/gpu/lal_sph_taitwater_ext.cpp b/lib/gpu/lal_sph_taitwater_ext.cpp index 9d125a6395..8372132213 100644 --- a/lib/gpu/lal_sph_taitwater_ext.cpp +++ b/lib/gpu/lal_sph_taitwater_ext.cpp @@ -114,10 +114,10 @@ void sph_taitwater_gpu_compute(const int ago, const int inum_full, const int nal int **firstneigh, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, const double cpu_time, bool &success, tagint *host_tag, - double **host_v, const int nlocal) { + double **host_v) { SPHTaitwaterMF.compute(ago, inum_full, nall, host_x, host_type, ilist, numj, firstneigh, eflag, vflag, eatom, vatom, host_start, cpu_time, success, - host_tag, host_v, nlocal); + host_tag, host_v); } void sph_taitwater_gpu_get_extra_data(double *host_rho) { diff --git a/lib/kokkos/CHANGELOG.md b/lib/kokkos/CHANGELOG.md index c6115f4b3d..40e3c95f24 100644 --- a/lib/kokkos/CHANGELOG.md +++ b/lib/kokkos/CHANGELOG.md @@ -1,5 +1,26 @@ # CHANGELOG +## [4.2.01](https://github.com/kokkos/kokkos/tree/4.2.01) (2023-12-07) +[Full Changelog](https://github.com/kokkos/kokkos/compare/4.2.00...4.2.01) + +### Backend and Architecture Enhancements: + +#### CUDA: +- Add warp sync for `parallel_reduce` to avoid race condition [\#6630](https://github.com/kokkos/kokkos/pull/6630), [\#6746](https://github.com/kokkos/kokkos/pull/6746) + +#### HIP: +- Fix Graph "multiple definition of" linking error (missing `inline` specifier) [\#6624](https://github.com/kokkos/kokkos/pull/6624) +- Add support for gfx940 (AMD Instinct MI300 GPU) [\#6671](https://github.com/kokkos/kokkos/pull/6671) + +### Build System +- CMake: Don't let Kokkos set `CMAKE_CXX_FLAGS` for Trilinos builds [\#6742](https://github.com/kokkos/kokkos/pull/6742) + +### Bug Fixes +- Remove deprecation warning for `AllocationMechanism` for GCC <11.0 [\#6653](https://github.com/kokkos/kokkos/pull/6653) +- Fix bug early tools finalize with non-default host execution instances [\#6635](https://github.com/kokkos/kokkos/pull/6635) +- Fix various issues for MSVC CUDA builds [\#6659](https://github.com/kokkos/kokkos/pull/6659) +- Fix "extra `;`" warning with `-pedantic` flag in `` [\#6510](https://github.com/kokkos/kokkos/pull/6510) + ## [4.2.00](https://github.com/kokkos/kokkos/tree/4.2.00) (2023-11-06) [Full Changelog](https://github.com/kokkos/kokkos/compare/4.1.00...4.2.00) @@ -43,7 +64,7 @@ #### SYCL: - Enforce external `sycl::queues` to be in-order [\#6246](https://github.com/kokkos/kokkos/pull/6246) -- Improve reduction performance: [\#6272](https://github.com/kokkos/kokkos/pull/6272) [\#6271](https://github.com/kokkos/kokkos/pull/6271) [\#6270](https://github.com/kokkos/kokkos/pull/6270) [\#6264](https://github.com/kokkos/kokkos/pull/6264) +- Improve reduction performance: [\#6272](https://github.com/kokkos/kokkos/pull/6272) [\#6271](https://github.com/kokkos/kokkos/pull/6271) [\#6270](https://github.com/kokkos/kokkos/pull/6270) [\#6264](https://github.com/kokkos/kokkos/pull/6264) - Allow using the SYCL execution space on AMD GPUs [\#6321](https://github.com/kokkos/kokkos/pull/6321) - Allow sorting via native oneDPL to support Views with stride=1 [\#6322](https://github.com/kokkos/kokkos/pull/6322) - Make in-order queues the default via macro [\#6189](https://github.com/kokkos/kokkos/pull/6189) @@ -64,7 +85,7 @@ - Add converting assignment to `DualView`: [\#6474](https://github.com/kokkos/kokkos/pull/6474) -### Build System Changes +### Build System Changes - Export `Kokkos_CXX_COMPILER_VERSION` [\#6282](https://github.com/kokkos/kokkos/pull/6282) - Disable default oneDPL support in Trilinos [\#6342](https://github.com/kokkos/kokkos/pull/6342) diff --git a/lib/kokkos/CMakeLists.txt b/lib/kokkos/CMakeLists.txt index f6bd81058e..4a4e7a5501 100644 --- a/lib/kokkos/CMakeLists.txt +++ b/lib/kokkos/CMakeLists.txt @@ -151,7 +151,7 @@ ENDIF() set(Kokkos_VERSION_MAJOR 4) set(Kokkos_VERSION_MINOR 2) -set(Kokkos_VERSION_PATCH 0) +set(Kokkos_VERSION_PATCH 1) set(Kokkos_VERSION "${Kokkos_VERSION_MAJOR}.${Kokkos_VERSION_MINOR}.${Kokkos_VERSION_PATCH}") message(STATUS "Kokkos version: ${Kokkos_VERSION}") math(EXPR KOKKOS_VERSION "${Kokkos_VERSION_MAJOR} * 10000 + ${Kokkos_VERSION_MINOR} * 100 + ${Kokkos_VERSION_PATCH}") @@ -252,7 +252,6 @@ ENDIF() # subpackages ## This restores the old behavior of ProjectCompilerPostConfig.cmake -# It sets the CMAKE_CXX_FLAGS globally to those used by Kokkos # We must do this before KOKKOS_PACKAGE_DECL IF (KOKKOS_HAS_TRILINOS) # Overwrite the old flags at the top-level @@ -280,21 +279,13 @@ IF (KOKKOS_HAS_TRILINOS) SET(KOKKOSCORE_XCOMPILER_OPTIONS "${KOKKOSCORE_XCOMPILER_OPTIONS} -Xcompiler ${XCOMP_FLAG}") LIST(APPEND KOKKOS_ALL_COMPILE_OPTIONS -Xcompiler ${XCOMP_FLAG}) ENDFOREACH() - SET(KOKKOSCORE_CXX_FLAGS "${KOKKOSCORE_COMPILE_OPTIONS} ${KOKKOSCORE_XCOMPILER_OPTIONS}") IF (KOKKOS_ENABLE_CUDA) STRING(REPLACE ";" " " KOKKOSCORE_CUDA_OPTIONS "${KOKKOS_CUDA_OPTIONS}") FOREACH(CUDAFE_FLAG ${KOKKOS_CUDAFE_OPTIONS}) SET(KOKKOSCORE_CUDAFE_OPTIONS "${KOKKOSCORE_CUDAFE_OPTIONS} -Xcudafe ${CUDAFE_FLAG}") LIST(APPEND KOKKOS_ALL_COMPILE_OPTIONS -Xcudafe ${CUDAFE_FLAG}) ENDFOREACH() - SET(KOKKOSCORE_CXX_FLAGS "${KOKKOSCORE_CXX_FLAGS} ${KOKKOSCORE_CUDA_OPTIONS} ${KOKKOSCORE_CUDAFE_OPTIONS}") ENDIF() - # Both parent scope and this package - # In ProjectCompilerPostConfig.cmake, we capture the "global" flags Trilinos wants in - # TRILINOS_TOPLEVEL_CXX_FLAGS - SET(CMAKE_CXX_FLAGS "${TRILINOS_TOPLEVEL_CXX_FLAGS} ${KOKKOSCORE_CXX_FLAGS}" PARENT_SCOPE) - SET(CMAKE_CXX_FLAGS "${TRILINOS_TOPLEVEL_CXX_FLAGS} ${KOKKOSCORE_CXX_FLAGS}") - #CMAKE_CXX_FLAGS will get added to Kokkos and Kokkos dependencies automatically here #These flags get set up in KOKKOS_PACKAGE_DECL, which means they #must be configured before KOKKOS_PACKAGE_DECL SET(KOKKOS_ALL_COMPILE_OPTIONS diff --git a/lib/kokkos/Makefile.kokkos b/lib/kokkos/Makefile.kokkos index c970f72755..393422d73c 100644 --- a/lib/kokkos/Makefile.kokkos +++ b/lib/kokkos/Makefile.kokkos @@ -12,7 +12,7 @@ endif KOKKOS_VERSION_MAJOR = 4 KOKKOS_VERSION_MINOR = 2 -KOKKOS_VERSION_PATCH = 0 +KOKKOS_VERSION_PATCH = 1 KOKKOS_VERSION = $(shell echo $(KOKKOS_VERSION_MAJOR)*10000+$(KOKKOS_VERSION_MINOR)*100+$(KOKKOS_VERSION_PATCH) | bc) # Options: Cuda,HIP,SYCL,OpenMPTarget,OpenMP,Threads,Serial @@ -23,7 +23,7 @@ KOKKOS_DEVICES ?= "OpenMP" # NVIDIA: Kepler,Kepler30,Kepler32,Kepler35,Kepler37,Maxwell,Maxwell50,Maxwell52,Maxwell53,Pascal60,Pascal61,Volta70,Volta72,Turing75,Ampere80,Ampere86,Ada89,Hopper90 # ARM: ARMv80,ARMv81,ARMv8-ThunderX,ARMv8-TX2,A64FX # IBM: BGQ,Power7,Power8,Power9 -# AMD-GPUS: GFX906,GFX908,GFX90A,GFX942,GFX1030,GFX1100 +# AMD-GPUS: GFX906,GFX908,GFX90A,GFX940,GFX942,GFX1030,GFX1100 # AMD-CPUS: AMDAVX,Zen,Zen2,Zen3 # Intel-GPUs: Gen9,Gen11,Gen12LP,DG1,XeHP,PVC KOKKOS_ARCH ?= "" @@ -416,6 +416,8 @@ endif KOKKOS_INTERNAL_USE_ARCH_AMD_GFX906 := $(or $(call kokkos_has_string,$(KOKKOS_ARCH),VEGA906),$(call kokkos_has_string,$(KOKKOS_ARCH),AMD_GFX906)) KOKKOS_INTERNAL_USE_ARCH_AMD_GFX908 := $(or $(call kokkos_has_string,$(KOKKOS_ARCH),VEGA908),$(call kokkos_has_string,$(KOKKOS_ARCH),AMD_GFX908)) KOKKOS_INTERNAL_USE_ARCH_AMD_GFX90A := $(or $(call kokkos_has_string,$(KOKKOS_ARCH),VEGA90A),$(call kokkos_has_string,$(KOKKOS_ARCH),AMD_GFX90A)) +KOKKOS_INTERNAL_USE_ARCH_AMD_GFX940 := $(call kokkos_has_string,$(KOKKOS_ARCH),AMD_GFX940) +KOKKOS_INTERNAL_USE_ARCH_AMD_GFX942 := $(call kokkos_has_string,$(KOKKOS_ARCH),AMD_GFX942) KOKKOS_INTERNAL_USE_ARCH_AMD_GFX1030 := $(or $(call kokkos_has_string,$(KOKKOS_ARCH),NAVI1030),$(call kokkos_has_string,$(KOKKOS_ARCH),AMD_GFX1030)) KOKKOS_INTERNAL_USE_ARCH_AMD_GFX1100 := $(or $(call kokkos_has_string,$(KOKKOS_ARCH),NAVI1100),$(call kokkos_has_string,$(KOKKOS_ARCH),AMD_GFX1100)) @@ -1113,6 +1115,11 @@ ifeq ($(KOKKOS_INTERNAL_USE_ARCH_AMD_GFX90A), 1) tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_AMD_GPU") KOKKOS_INTERNAL_HIP_ARCH_FLAG := --offload-arch=gfx90a endif +ifeq ($(KOKKOS_INTERNAL_USE_ARCH_AMD_GFX940), 1) + tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_AMD_GFX940") + tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_AMD_GPU") + KOKKOS_INTERNAL_HIP_ARCH_FLAG := --offload-arch=gfx940 +endif ifeq ($(KOKKOS_INTERNAL_USE_ARCH_AMD_GFX942), 1) tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_AMD_GFX942") tmp := $(call kokkos_append_header,"$H""define KOKKOS_ARCH_AMD_GPU") diff --git a/lib/kokkos/algorithms/unit_tests/TestStdAlgorithmsCommon.hpp b/lib/kokkos/algorithms/unit_tests/TestStdAlgorithmsCommon.hpp index b962218b5f..3eb963faf2 100644 --- a/lib/kokkos/algorithms/unit_tests/TestStdAlgorithmsCommon.hpp +++ b/lib/kokkos/algorithms/unit_tests/TestStdAlgorithmsCommon.hpp @@ -198,8 +198,9 @@ auto create_deep_copyable_compatible_view_with_same_extent(ViewType view) { // this is needed for intel to avoid // error #1011: missing return statement at end of non-void function -#if defined KOKKOS_COMPILER_INTEL || \ - (defined(KOKKOS_COMPILER_NVCC) && KOKKOS_COMPILER_NVCC >= 1130) +#if defined KOKKOS_COMPILER_INTEL || \ + (defined(KOKKOS_COMPILER_NVCC) && KOKKOS_COMPILER_NVCC >= 1130 && \ + !defined(KOKKOS_COMPILER_MSVC)) __builtin_unreachable(); #endif } diff --git a/lib/kokkos/algorithms/unit_tests/TestStdAlgorithmsTeamCopyIf.cpp b/lib/kokkos/algorithms/unit_tests/TestStdAlgorithmsTeamCopyIf.cpp index b32a9be3a1..b5aa27c7c3 100644 --- a/lib/kokkos/algorithms/unit_tests/TestStdAlgorithmsTeamCopyIf.cpp +++ b/lib/kokkos/algorithms/unit_tests/TestStdAlgorithmsTeamCopyIf.cpp @@ -139,7 +139,7 @@ void test_A(std::size_t numTeams, std::size_t numCols, int apiId) { auto intraTeamSentinelView_h = create_host_space_copy(intraTeamSentinelView); Kokkos::View stdDestView("stdDestView", numTeams, numCols); - GreaterThanValueFunctor predicate(threshold); + GreaterThanValueFunctor predicate(threshold); for (std::size_t i = 0; i < sourceView.extent(0); ++i) { auto rowFrom = Kokkos::subview(sourceViewBeforeOp_h, i, Kokkos::ALL()); auto rowDest = Kokkos::subview(stdDestView, i, Kokkos::ALL()); diff --git a/lib/kokkos/algorithms/unit_tests/TestStdAlgorithmsTeamIsPartitioned.cpp b/lib/kokkos/algorithms/unit_tests/TestStdAlgorithmsTeamIsPartitioned.cpp index 1928f95588..21da333e75 100644 --- a/lib/kokkos/algorithms/unit_tests/TestStdAlgorithmsTeamIsPartitioned.cpp +++ b/lib/kokkos/algorithms/unit_tests/TestStdAlgorithmsTeamIsPartitioned.cpp @@ -191,7 +191,7 @@ void test_A(std::size_t numTeams, std::size_t numCols, int apiId, // ----------------------------------------------- auto returnView_h = create_host_space_copy(returnView); auto intraTeamSentinelView_h = create_host_space_copy(intraTeamSentinelView); - GreaterThanValueFunctor predicate(threshold); + GreaterThanValueFunctor predicate(threshold); for (std::size_t i = 0; i < dataView_dc_h.extent(0); ++i) { auto myRow = Kokkos::subview(dataView_dc_h, i, Kokkos::ALL()); diff --git a/lib/kokkos/algorithms/unit_tests/TestStdAlgorithmsTeamPartitionCopy.cpp b/lib/kokkos/algorithms/unit_tests/TestStdAlgorithmsTeamPartitionCopy.cpp index c0bbdfa390..78ab6bf1f8 100644 --- a/lib/kokkos/algorithms/unit_tests/TestStdAlgorithmsTeamPartitionCopy.cpp +++ b/lib/kokkos/algorithms/unit_tests/TestStdAlgorithmsTeamPartitionCopy.cpp @@ -240,7 +240,7 @@ void test_A(std::size_t numTeams, std::size_t numCols, int apiId, "stdDestTrueView", numTeams, numCols); Kokkos::View stdDestFalseView( "stdDestFalseView", numTeams, numCols); - GreaterThanValueFunctor predicate(threshold); + GreaterThanValueFunctor predicate(threshold); for (std::size_t i = 0; i < sourceView_dc_h.extent(0); ++i) { auto myRowSource = Kokkos::subview(sourceView_dc_h, i, Kokkos::ALL()); diff --git a/lib/kokkos/algorithms/unit_tests/TestStdAlgorithmsTeamPartitionPoint.cpp b/lib/kokkos/algorithms/unit_tests/TestStdAlgorithmsTeamPartitionPoint.cpp index 954d461246..370e91cc1f 100644 --- a/lib/kokkos/algorithms/unit_tests/TestStdAlgorithmsTeamPartitionPoint.cpp +++ b/lib/kokkos/algorithms/unit_tests/TestStdAlgorithmsTeamPartitionPoint.cpp @@ -197,7 +197,7 @@ void test_A(std::size_t numTeams, std::size_t numCols, int apiId, auto distancesView_h = create_host_space_copy(distancesView); auto dataViewAfterOp_h = create_host_space_copy(dataView); auto intraTeamSentinelView_h = create_host_space_copy(intraTeamSentinelView); - GreaterThanValueFunctor predicate(threshold); + GreaterThanValueFunctor predicate(threshold); for (std::size_t i = 0; i < dataView_dc_h.extent(0); ++i) { auto myRow = Kokkos::subview(dataView_dc_h, i, Kokkos::ALL()); diff --git a/lib/kokkos/algorithms/unit_tests/TestStdAlgorithmsTeamRemoveCopyIf.cpp b/lib/kokkos/algorithms/unit_tests/TestStdAlgorithmsTeamRemoveCopyIf.cpp index 2082fa9728..ce18eb4d31 100644 --- a/lib/kokkos/algorithms/unit_tests/TestStdAlgorithmsTeamRemoveCopyIf.cpp +++ b/lib/kokkos/algorithms/unit_tests/TestStdAlgorithmsTeamRemoveCopyIf.cpp @@ -138,7 +138,7 @@ void test_A(std::size_t numTeams, std::size_t numCols, int apiId) { auto intraTeamSentinelView_h = create_host_space_copy(intraTeamSentinelView); Kokkos::View stdDestView("stdDestView", numTeams, numCols); - GreaterThanValueFunctor predicate(threshold); + GreaterThanValueFunctor predicate(threshold); for (std::size_t i = 0; i < destViewAfterOp_h.extent(0); ++i) { auto rowFrom = Kokkos::subview(cloneOfSourceViewBeforeOp_h, i, Kokkos::ALL()); diff --git a/lib/kokkos/algorithms/unit_tests/TestStdAlgorithmsTeamRemoveIf.cpp b/lib/kokkos/algorithms/unit_tests/TestStdAlgorithmsTeamRemoveIf.cpp index 3315f281da..3dd7cb764c 100644 --- a/lib/kokkos/algorithms/unit_tests/TestStdAlgorithmsTeamRemoveIf.cpp +++ b/lib/kokkos/algorithms/unit_tests/TestStdAlgorithmsTeamRemoveIf.cpp @@ -127,7 +127,7 @@ void test_A(std::size_t numTeams, std::size_t numCols, int apiId) { // ----------------------------------------------- // check against std // ----------------------------------------------- - GreaterThanValueFunctor predicate(threshold); + GreaterThanValueFunctor predicate(threshold); auto dataViewAfterOp_h = create_host_space_copy(dataView); auto distancesView_h = create_host_space_copy(distancesView); auto intraTeamSentinelView_h = create_host_space_copy(intraTeamSentinelView); diff --git a/lib/kokkos/algorithms/unit_tests/TestStdAlgorithmsTeamReplaceCopyIf.cpp b/lib/kokkos/algorithms/unit_tests/TestStdAlgorithmsTeamReplaceCopyIf.cpp index ae43a2a426..d0217aed7a 100644 --- a/lib/kokkos/algorithms/unit_tests/TestStdAlgorithmsTeamReplaceCopyIf.cpp +++ b/lib/kokkos/algorithms/unit_tests/TestStdAlgorithmsTeamReplaceCopyIf.cpp @@ -145,7 +145,7 @@ void test_A(std::size_t numTeams, std::size_t numCols, int apiId) { auto intraTeamSentinelView_h = create_host_space_copy(intraTeamSentinelView); Kokkos::View stdDestView("stdDestView", numTeams, numCols); - GreaterThanValueFunctor predicate(threshold); + GreaterThanValueFunctor predicate(threshold); for (std::size_t i = 0; i < sourceView.extent(0); ++i) { auto rowFrom = Kokkos::subview(cloneOfSourceViewBeforeOp_h, i, Kokkos::ALL()); diff --git a/lib/kokkos/algorithms/unit_tests/TestStdAlgorithmsTeamReplaceIf.cpp b/lib/kokkos/algorithms/unit_tests/TestStdAlgorithmsTeamReplaceIf.cpp index 1d5d9578f9..d79b53d355 100644 --- a/lib/kokkos/algorithms/unit_tests/TestStdAlgorithmsTeamReplaceIf.cpp +++ b/lib/kokkos/algorithms/unit_tests/TestStdAlgorithmsTeamReplaceIf.cpp @@ -103,7 +103,7 @@ void test_A(std::size_t numTeams, std::size_t numCols, int apiId) { stdDataView(i, j) = cloneOfDataViewBeforeOp_h(i, j); } } - GreaterThanValueFunctor predicate(threshold); + GreaterThanValueFunctor predicate(threshold); for (std::size_t i = 0; i < dataView.extent(0); ++i) { auto thisRow = Kokkos::subview(stdDataView, i, Kokkos::ALL()); std::replace_if(KE::begin(thisRow), KE::end(thisRow), predicate, newVal); diff --git a/lib/kokkos/cmake/KokkosCore_config.h.in b/lib/kokkos/cmake/KokkosCore_config.h.in index bec59ebd03..9930d2abf0 100644 --- a/lib/kokkos/cmake/KokkosCore_config.h.in +++ b/lib/kokkos/cmake/KokkosCore_config.h.in @@ -114,6 +114,7 @@ #cmakedefine KOKKOS_ARCH_AMD_GFX906 #cmakedefine KOKKOS_ARCH_AMD_GFX908 #cmakedefine KOKKOS_ARCH_AMD_GFX90A +#cmakedefine KOKKOS_ARCH_AMD_GFX940 #cmakedefine KOKKOS_ARCH_AMD_GFX942 #cmakedefine KOKKOS_ARCH_AMD_GFX1030 #cmakedefine KOKKOS_ARCH_AMD_GFX1100 diff --git a/lib/kokkos/cmake/kokkos_arch.cmake b/lib/kokkos/cmake/kokkos_arch.cmake index bccf674d76..30764bde86 100644 --- a/lib/kokkos/cmake/kokkos_arch.cmake +++ b/lib/kokkos/cmake/kokkos_arch.cmake @@ -94,9 +94,9 @@ IF(Kokkos_ENABLE_HIP OR Kokkos_ENABLE_OPENMPTARGET OR Kokkos_ENABLE_OPENACC OR K ENDIF() # AMD archs ordered in decreasing priority of autodetection -LIST(APPEND SUPPORTED_AMD_GPUS MI300) -LIST(APPEND SUPPORTED_AMD_ARCHS AMD_GFX942) -LIST(APPEND CORRESPONDING_AMD_FLAGS gfx942) +LIST(APPEND SUPPORTED_AMD_GPUS MI300 MI300) +LIST(APPEND SUPPORTED_AMD_ARCHS AMD_GFX942 AMD_GFX940) +LIST(APPEND CORRESPONDING_AMD_FLAGS gfx942 gfx940) LIST(APPEND SUPPORTED_AMD_GPUS MI200 MI200 MI100 MI100) LIST(APPEND SUPPORTED_AMD_ARCHS VEGA90A AMD_GFX90A VEGA908 AMD_GFX908) LIST(APPEND CORRESPONDING_AMD_FLAGS gfx90a gfx90a gfx908 gfx908) diff --git a/lib/kokkos/core/src/Cuda/Kokkos_Cuda_Parallel_MDRange.hpp b/lib/kokkos/core/src/Cuda/Kokkos_Cuda_Parallel_MDRange.hpp index 8aae27d091..49d6c112e3 100644 --- a/lib/kokkos/core/src/Cuda/Kokkos_Cuda_Parallel_MDRange.hpp +++ b/lib/kokkos/core/src/Cuda/Kokkos_Cuda_Parallel_MDRange.hpp @@ -309,6 +309,11 @@ class ParallelReduce, if (CudaTraits::WarpSize < word_count.value) { __syncthreads(); + } else if (word_count.value > 1) { + // Inside cuda_single_inter_block_reduce_scan() above, shared[i] below + // might have been updated by a single thread within a warp without + // synchronization afterwards. Synchronize threads within warp to avoid + // potential racecondition. + __syncwarp(0xffffffff); } for (unsigned i = threadIdx.y; i < word_count.value; i += blockDim.y) { diff --git a/lib/kokkos/core/src/Cuda/Kokkos_Cuda_Parallel_Team.hpp b/lib/kokkos/core/src/Cuda/Kokkos_Cuda_Parallel_Team.hpp index 498e57f94a..b4679b4e0d 100644 --- a/lib/kokkos/core/src/Cuda/Kokkos_Cuda_Parallel_Team.hpp +++ b/lib/kokkos/core/src/Cuda/Kokkos_Cuda_Parallel_Team.hpp @@ -742,6 +742,11 @@ class ParallelReduce { hipGraphExec_t m_graph_exec = nullptr; }; -GraphImpl::~GraphImpl() { +inline GraphImpl::~GraphImpl() { m_execution_space.fence("Kokkos::GraphImpl::~GraphImpl: Graph Destruction"); KOKKOS_EXPECTS(m_graph); if (m_graph_exec) { @@ -92,12 +92,12 @@ GraphImpl::~GraphImpl() { KOKKOS_IMPL_HIP_SAFE_CALL(hipGraphDestroy(m_graph)); } -GraphImpl::GraphImpl(Kokkos::HIP instance) +inline GraphImpl::GraphImpl(Kokkos::HIP instance) : m_execution_space(std::move(instance)) { KOKKOS_IMPL_HIP_SAFE_CALL(hipGraphCreate(&m_graph, 0)); } -void GraphImpl::add_node( +inline void GraphImpl::add_node( std::shared_ptr const& arg_node_ptr) { // All of the predecessors are just added as normal, so all we need to // do here is add an empty node @@ -110,7 +110,7 @@ void GraphImpl::add_node( // Requires NodeImplPtr is a shared_ptr to specialization of GraphNodeImpl // Also requires that the kernel has the graph node tag in it's policy template -void GraphImpl::add_node( +inline void GraphImpl::add_node( std::shared_ptr const& arg_node_ptr) { static_assert(NodeImpl::kernel_type::Policy::is_graph_kernel::value); KOKKOS_EXPECTS(arg_node_ptr); @@ -129,8 +129,8 @@ void GraphImpl::add_node( // already been added to this graph and NodeImpl is a specialization of // GraphNodeImpl that has already been added to this graph. template -void GraphImpl::add_predecessor(NodeImplPtr arg_node_ptr, - PredecessorRef arg_pred_ref) { +inline void GraphImpl::add_predecessor( + NodeImplPtr arg_node_ptr, PredecessorRef arg_pred_ref) { KOKKOS_EXPECTS(arg_node_ptr); auto pred_ptr = GraphAccess::get_node_ptr(arg_pred_ref); KOKKOS_EXPECTS(pred_ptr); @@ -145,7 +145,7 @@ void GraphImpl::add_predecessor(NodeImplPtr arg_node_ptr, hipGraphAddDependencies(m_graph, &pred_node, &node, 1)); } -void GraphImpl::submit() { +inline void GraphImpl::submit() { if (!m_graph_exec) { instantiate_graph(); } @@ -153,12 +153,12 @@ void GraphImpl::submit() { hipGraphLaunch(m_graph_exec, m_execution_space.hip_stream())); } -Kokkos::HIP const& GraphImpl::get_execution_space() const +inline Kokkos::HIP const& GraphImpl::get_execution_space() const noexcept { return m_execution_space; } -auto GraphImpl::create_root_node_ptr() { +inline auto GraphImpl::create_root_node_ptr() { KOKKOS_EXPECTS(m_graph); KOKKOS_EXPECTS(!m_graph_exec); auto rv = std::make_shared(get_execution_space(), @@ -172,7 +172,7 @@ auto GraphImpl::create_root_node_ptr() { } template -auto GraphImpl::create_aggregate_ptr(PredecessorRefs&&...) { +inline auto GraphImpl::create_aggregate_ptr(PredecessorRefs&&...) { // The attachment to predecessors, which is all we really need, happens // in the generic layer, which calls through to add_predecessor for // each predecessor ref, so all we need to do here is create the (trivial) diff --git a/lib/kokkos/core/src/HIP/Kokkos_HIP_Instance.hpp b/lib/kokkos/core/src/HIP/Kokkos_HIP_Instance.hpp index ef140ec46c..63ad66686b 100644 --- a/lib/kokkos/core/src/HIP/Kokkos_HIP_Instance.hpp +++ b/lib/kokkos/core/src/HIP/Kokkos_HIP_Instance.hpp @@ -30,7 +30,8 @@ namespace Impl { struct HIPTraits { #if defined(KOKKOS_ARCH_AMD_GFX906) || defined(KOKKOS_ARCH_AMD_GFX908) || \ - defined(KOKKOS_ARCH_AMD_GFX90A) || defined(KOKKOS_ARCH_AMD_GFX942) + defined(KOKKOS_ARCH_AMD_GFX90A) || defined(KOKKOS_ARCH_AMD_GFX940) || \ + defined(KOKKOS_ARCH_AMD_GFX942) static constexpr int WarpSize = 64; static constexpr int WarpIndexMask = 0x003f; /* hexadecimal for 63 */ static constexpr int WarpIndexShift = 6; /* WarpSize == 1 << WarpShift*/ diff --git a/lib/kokkos/core/src/Kokkos_HostSpace.hpp b/lib/kokkos/core/src/Kokkos_HostSpace.hpp index 90d1404063..252aabd949 100644 --- a/lib/kokkos/core/src/Kokkos_HostSpace.hpp +++ b/lib/kokkos/core/src/Kokkos_HostSpace.hpp @@ -75,12 +75,19 @@ class HostSpace { /**\brief Non-default memory space instance to choose allocation mechansim, * if available */ - enum KOKKOS_DEPRECATED AllocationMechanism { - STD_MALLOC, - POSIX_MEMALIGN, - POSIX_MMAP, - INTEL_MM_ALLOC - }; +#if defined(KOKKOS_COMPILER_GNU) && KOKKOS_COMPILER_GNU < 1100 + // We see deprecation warnings even when not using the deprecated + // HostSpace constructor below when using gcc before release 11. + enum +#else + enum KOKKOS_DEPRECATED +#endif + AllocationMechanism { + STD_MALLOC, + POSIX_MEMALIGN, + POSIX_MMAP, + INTEL_MM_ALLOC + }; KOKKOS_DEPRECATED explicit HostSpace(const AllocationMechanism&); diff --git a/lib/kokkos/core/src/Kokkos_Printf.hpp b/lib/kokkos/core/src/Kokkos_Printf.hpp index af20221a5a..39f95825c3 100644 --- a/lib/kokkos/core/src/Kokkos_Printf.hpp +++ b/lib/kokkos/core/src/Kokkos_Printf.hpp @@ -31,7 +31,7 @@ namespace Kokkos { // backends. The GPU backends always return 1 and NVHPC only compiles if we // don't ask for the return value. template -KOKKOS_FORCEINLINE_FUNCTION void printf(const char* format, Args... args) { +KOKKOS_FUNCTION void printf(const char* format, Args... args) { #ifdef KOKKOS_ENABLE_SYCL // Some compilers warn if "args" is empty and format is not a string literal if constexpr (sizeof...(Args) == 0) diff --git a/lib/kokkos/core/src/OpenMP/Kokkos_OpenMP_Instance.cpp b/lib/kokkos/core/src/OpenMP/Kokkos_OpenMP_Instance.cpp index 44f0fbc180..12bf3b71f7 100644 --- a/lib/kokkos/core/src/OpenMP/Kokkos_OpenMP_Instance.cpp +++ b/lib/kokkos/core/src/OpenMP/Kokkos_OpenMP_Instance.cpp @@ -359,8 +359,6 @@ void OpenMPInternal::finalize() { } m_initialized = false; - - Kokkos::Profiling::finalize(); } void OpenMPInternal::print_configuration(std::ostream &s) const { diff --git a/lib/kokkos/core/src/OpenMP/Kokkos_OpenMP_Instance.hpp b/lib/kokkos/core/src/OpenMP/Kokkos_OpenMP_Instance.hpp index 4586406e16..03f5fff395 100644 --- a/lib/kokkos/core/src/OpenMP/Kokkos_OpenMP_Instance.hpp +++ b/lib/kokkos/core/src/OpenMP/Kokkos_OpenMP_Instance.hpp @@ -219,6 +219,8 @@ KOKKOS_DEPRECATED void OpenMP::partition_master(F const& f, int num_partitions, Exec::validate_partition_impl(prev_instance->m_pool_size, num_partitions, partition_size); + OpenMP::memory_space space; + #pragma omp parallel num_threads(num_partitions) { Exec thread_local_instance(partition_size); diff --git a/lib/kokkos/core/src/Serial/Kokkos_Serial.cpp b/lib/kokkos/core/src/Serial/Kokkos_Serial.cpp index e81e834939..071ecdbc4f 100644 --- a/lib/kokkos/core/src/Serial/Kokkos_Serial.cpp +++ b/lib/kokkos/core/src/Serial/Kokkos_Serial.cpp @@ -58,8 +58,6 @@ void SerialInternal::finalize() { m_thread_team_data.scratch_assign(nullptr, 0, 0, 0, 0, 0); } - Kokkos::Profiling::finalize(); - m_is_initialized = false; } diff --git a/lib/kokkos/core/src/Serial/Kokkos_Serial.hpp b/lib/kokkos/core/src/Serial/Kokkos_Serial.hpp index db1567610b..67119cac16 100644 --- a/lib/kokkos/core/src/Serial/Kokkos_Serial.hpp +++ b/lib/kokkos/core/src/Serial/Kokkos_Serial.hpp @@ -30,6 +30,7 @@ static_assert(false, #include #include +#include #include #include #include diff --git a/lib/kokkos/core/src/Threads/Kokkos_ThreadsExec.cpp b/lib/kokkos/core/src/Threads/Kokkos_ThreadsExec.cpp index c754091e87..801a1ac82e 100644 --- a/lib/kokkos/core/src/Threads/Kokkos_ThreadsExec.cpp +++ b/lib/kokkos/core/src/Threads/Kokkos_ThreadsExec.cpp @@ -815,8 +815,6 @@ void ThreadsExec::finalize() { s_threads_process.m_pool_size = 1; s_threads_process.m_pool_fan_size = 0; s_threads_process.m_pool_state = ThreadsExec::Inactive; - - Kokkos::Profiling::finalize(); } //---------------------------------------------------------------------------- diff --git a/lib/kokkos/core/unit_test/TestMathematicalFunctions.hpp b/lib/kokkos/core/unit_test/TestMathematicalFunctions.hpp index d32ef4ca23..424ba05a90 100644 --- a/lib/kokkos/core/unit_test/TestMathematicalFunctions.hpp +++ b/lib/kokkos/core/unit_test/TestMathematicalFunctions.hpp @@ -30,8 +30,9 @@ #define MATHEMATICAL_FUNCTIONS_HAVE_LONG_DOUBLE_OVERLOADS #endif -#if defined KOKKOS_COMPILER_INTEL || \ - (defined(KOKKOS_COMPILER_NVCC) && KOKKOS_COMPILER_NVCC >= 1130) +#if defined KOKKOS_COMPILER_INTEL || \ + (defined(KOKKOS_COMPILER_NVCC) && KOKKOS_COMPILER_NVCC >= 1130 && \ + !defined(KOKKOS_COMPILER_MSVC)) #define MATHEMATICAL_FUNCTIONS_TEST_UNREACHABLE __builtin_unreachable(); #else #define MATHEMATICAL_FUNCTIONS_TEST_UNREACHABLE @@ -394,10 +395,12 @@ DEFINE_UNARY_FUNCTION_EVAL(log2, 2); DEFINE_UNARY_FUNCTION_EVAL(log1p, 2); #endif -#ifndef KOKKOS_MATHEMATICAL_FUNCTIONS_SKIP_1 +#ifndef KOKKOS_MATHEMATICAL_FUNCTIONS_SKIP_2 DEFINE_UNARY_FUNCTION_EVAL(sqrt, 2); DEFINE_UNARY_FUNCTION_EVAL(cbrt, 2); +#endif +#ifndef KOKKOS_MATHEMATICAL_FUNCTIONS_SKIP_1 DEFINE_UNARY_FUNCTION_EVAL(sin, 2); DEFINE_UNARY_FUNCTION_EVAL(cos, 2); DEFINE_UNARY_FUNCTION_EVAL(tan, 2); @@ -483,11 +486,9 @@ DEFINE_UNARY_FUNCTION_EVAL(logb, 2); }; \ constexpr char math_function_name::name[] -#ifndef KOKKOS_MATHEMATICAL_FUNCTIONS_SKIP_1 +#ifndef KOKKOS_MATHEMATICAL_FUNCTIONS_SKIP_2 DEFINE_BINARY_FUNCTION_EVAL(pow, 2); DEFINE_BINARY_FUNCTION_EVAL(hypot, 2); -#endif -#ifndef KOKKOS_MATHEMATICAL_FUNCTIONS_SKIP_2 DEFINE_BINARY_FUNCTION_EVAL(nextafter, 1); DEFINE_BINARY_FUNCTION_EVAL(copysign, 1); #endif @@ -519,7 +520,7 @@ DEFINE_BINARY_FUNCTION_EVAL(copysign, 1); }; \ constexpr char math_function_name::name[] -#ifndef KOKKOS_MATHEMATICAL_FUNCTIONS_SKIP_1 +#ifndef KOKKOS_MATHEMATICAL_FUNCTIONS_SKIP_2 DEFINE_TERNARY_FUNCTION_EVAL(hypot, 2); DEFINE_TERNARY_FUNCTION_EVAL(fma, 2); #endif @@ -787,7 +788,9 @@ TEST(TEST_CATEGORY, mathematical_functions_trigonometric_functions) { // TODO atan2 } +#endif +#ifndef KOKKOS_MATHEMATICAL_FUNCTIONS_SKIP_2 TEST(TEST_CATEGORY, mathematical_functions_power_functions) { TEST_MATH_FUNCTION(sqrt)({0, 1, 2, 3, 5, 7, 11}); TEST_MATH_FUNCTION(sqrt)({0l, 1l, 2l, 3l, 5l, 7l, 11l}); @@ -1568,6 +1571,7 @@ TEST(TEST_CATEGORY, mathematical_functions_ieee_remainder_function) { // TODO: TestFpClassify, see https://github.com/kokkos/kokkos/issues/6279 +#ifndef KOKKOS_MATHEMATICAL_FUNCTIONS_SKIP_2 template struct TestIsFinite { TestIsFinite() { run(); } @@ -1591,6 +1595,7 @@ struct TestIsFinite { ++e; Kokkos::printf("failed isfinite(float)\n"); } +#if !(defined(KOKKOS_ENABLE_CUDA) && defined(KOKKOS_COMPILER_MSVC)) if (!isfinite(static_cast(2.f)) #ifndef KOKKOS_COMPILER_NVHPC // FIXME_NVHPC 23.7 || isfinite(quiet_NaN::value) || @@ -1611,6 +1616,7 @@ struct TestIsFinite { ++e; Kokkos::printf("failed isfinite(KE::bhalf_t)\n"); } +#endif if (!isfinite(3.) #ifndef KOKKOS_COMPILER_NVHPC // FIXME_NVHPC 23.7 || isfinite(quiet_NaN::value) || @@ -1670,6 +1676,7 @@ struct TestIsInf { ++e; Kokkos::printf("failed isinf(float)\n"); } +#if !(defined(KOKKOS_ENABLE_CUDA) && defined(KOKKOS_COMPILER_MSVC)) if (isinf(static_cast(2.f)) #ifndef KOKKOS_COMPILER_NVHPC // FIXME_NVHPC 23.7 || isinf(quiet_NaN::value) || @@ -1690,6 +1697,7 @@ struct TestIsInf { ++e; Kokkos::printf("failed isinf(KE::bhalf_t)\n"); } +#endif if (isinf(3.) #ifndef KOKKOS_COMPILER_NVHPC // FIXME_NVHPC 23.7 || isinf(quiet_NaN::value) || @@ -1748,6 +1756,7 @@ struct TestIsNaN { ++e; Kokkos::printf("failed isnan(float)\n"); } +#if !(defined(KOKKOS_ENABLE_CUDA) && defined(KOKKOS_COMPILER_MSVC)) if (isnan(static_cast(2.f)) #ifndef KOKKOS_COMPILER_NVHPC // FIXME_NVHPC 23.7 || !isnan(quiet_NaN::value) || @@ -1777,6 +1786,7 @@ struct TestIsNaN { ++e; Kokkos::printf("failed isnan(double)\n"); } +#endif #ifdef MATHEMATICAL_FUNCTIONS_HAVE_LONG_DOUBLE_OVERLOADS if (isnan(4.l) || !isnan(quiet_NaN::value) || !isnan(signaling_NaN::value) || @@ -1803,6 +1813,7 @@ struct TestIsNaN { TEST(TEST_CATEGORY, mathematical_functions_isnan) { TestIsNaN(); } +#endif // TODO: TestSignBit, see https://github.com/kokkos/kokkos/issues/6279 #endif diff --git a/lib/kokkos/core/unit_test/TestNumericTraits.hpp b/lib/kokkos/core/unit_test/TestNumericTraits.hpp index 2b5531f29a..ec1c1e0ca0 100644 --- a/lib/kokkos/core/unit_test/TestNumericTraits.hpp +++ b/lib/kokkos/core/unit_test/TestNumericTraits.hpp @@ -110,8 +110,8 @@ struct TestNumericTraits { KOKKOS_FUNCTION void operator()(Epsilon, int, int& e) const { using Kokkos::Experimental::epsilon; - auto const eps = epsilon::value; - auto const one = T(1); + T const eps = epsilon::value; + T const one = 1; // Avoid higher precision intermediate representation compare() = one + eps; e += (int)!(compare() != one); diff --git a/lib/kokkos/generate_makefile.bash b/lib/kokkos/generate_makefile.bash index 1b216d9fe3..301a1fceb5 100755 --- a/lib/kokkos/generate_makefile.bash +++ b/lib/kokkos/generate_makefile.bash @@ -160,6 +160,7 @@ display_help_text() { echo " AMD_GFX906 = AMD GPU MI50/MI60 GFX906" echo " AMD_GFX908 = AMD GPU MI100 GFX908" echo " AMD_GFX90A = AMD GPU MI200 GFX90A" + echo " AMD_GFX940 = AMD GPU MI300 GFX940" echo " AMD_GFX942 = AMD GPU MI300 GFX942" echo " AMD_GFX1030 = AMD GPU V620/W6800 GFX1030" echo " AMD_GFX1100 = AMD GPU RX 7900 XT(X) GFX1100" diff --git a/lib/kokkos/master_history.txt b/lib/kokkos/master_history.txt index fd0020b8d5..a43b5276a8 100644 --- a/lib/kokkos/master_history.txt +++ b/lib/kokkos/master_history.txt @@ -34,3 +34,4 @@ tag: 4.0.00 date: 02:23:2023 master: 5ad60966 release: 52ea2953 tag: 4.0.01 date: 04:26:2023 master: aa1f48f3 release: 5893754f tag: 4.1.00 date: 06:20:2023 master: 62d2b6c8 release: adde1e6a tag: 4.2.00 date: 11:09:2023 master: 1a3ea28f release: abe01c88 +tag: 4.2.01 date: 01:30:2024 master: 71a9bcae release: 221e5f7a diff --git a/lib/kokkos/simd/src/Kokkos_SIMD_Scalar.hpp b/lib/kokkos/simd/src/Kokkos_SIMD_Scalar.hpp index af7cb1e2c6..7443f5596b 100644 --- a/lib/kokkos/simd/src/Kokkos_SIMD_Scalar.hpp +++ b/lib/kokkos/simd/src/Kokkos_SIMD_Scalar.hpp @@ -224,7 +224,7 @@ template using data_type = std::conditional_t, T, double>; return Experimental::simd( Kokkos::floor(static_cast(a[0]))); -}; +} template [[nodiscard]] KOKKOS_FORCEINLINE_FUNCTION auto ceil( @@ -232,7 +232,7 @@ template using data_type = std::conditional_t, T, double>; return Experimental::simd( Kokkos::ceil(static_cast(a[0]))); -}; +} template [[nodiscard]] KOKKOS_FORCEINLINE_FUNCTION auto round( @@ -240,7 +240,7 @@ template using data_type = std::conditional_t, T, double>; return Experimental::simd( Experimental::round_half_to_nearest_even(static_cast(a[0]))); -}; +} template [[nodiscard]] KOKKOS_FORCEINLINE_FUNCTION auto trunc( @@ -248,7 +248,7 @@ template using data_type = std::conditional_t, T, double>; return Experimental::simd( Kokkos::trunc(static_cast(a[0]))); -}; +} template [[nodiscard]] KOKKOS_FORCEINLINE_FUNCTION diff --git a/lib/kokkos/simd/unit_tests/include/TestSIMD_GeneratorCtors.hpp b/lib/kokkos/simd/unit_tests/include/TestSIMD_GeneratorCtors.hpp index 4feff3a89d..4af08c266b 100644 --- a/lib/kokkos/simd/unit_tests/include/TestSIMD_GeneratorCtors.hpp +++ b/lib/kokkos/simd/unit_tests/include/TestSIMD_GeneratorCtors.hpp @@ -42,6 +42,7 @@ inline void host_check_gen_ctor() { simd_type blend; blend.copy_from(expected, Kokkos::Experimental::element_aligned_tag()); +#if !(defined(KOKKOS_ENABLE_CUDA) && defined(KOKKOS_COMPILER_MSVC)) if constexpr (std::is_same_v) { simd_type basic(KOKKOS_LAMBDA(std::size_t i) { return init[i]; }); host_check_equality(basic, rhs, lanes); @@ -63,6 +64,7 @@ inline void host_check_gen_ctor() { host_check_equality(blend, result, lanes); } +#endif } template diff --git a/lib/mdi/Install.py b/lib/mdi/Install.py index 316313ded8..c455f2d064 100644 --- a/lib/mdi/Install.py +++ b/lib/mdi/Install.py @@ -32,7 +32,7 @@ make lib-mdi args="-m mpi" # build MDI lib with same settings as in the mpi Make # settings -version = "1.4.16" +version = "1.4.26" url = "https://github.com/MolSSI-MDI/MDI_Library/archive/v%s.tar.gz" % version # known checksums for different MDI versions. used to validate the download. @@ -41,6 +41,7 @@ checksums = { \ '1.4.12' : '7a222353ae8e03961d5365e6cd48baee', \ '1.4.14' : '7a059bb12535360fdcb7de8402f9a0fc', \ '1.4.16' : '407db44e2d79447ab5c1233af1965f65', \ + '1.4.26' : '3124bb85259471e2a53a891f04bf697a', \ } # print error message or help diff --git a/lib/plumed/Install.py b/lib/plumed/Install.py index 9c42da4089..4a158cb31f 100644 --- a/lib/plumed/Install.py +++ b/lib/plumed/Install.py @@ -17,17 +17,17 @@ parser = ArgumentParser(prog='Install.py', # settings -version = "2.8.2" +version = "2.8.3" mode = "static" # help message HELP = """ Syntax from src dir: make lib-plumed args="-b" - or: make lib-plumed args="-b -v 2.8.2" + or: make lib-plumed args="-b -v 2.8.3" or: make lib-plumed args="-p /usr/local/plumed2 -m shared" -Syntax from lib dir: python Install.py -b -v 2.8.2 +Syntax from lib dir: python Install.py -b -v 2.8.3 or: python Install.py -b or: python Install.py -p /usr/local/plumed2 -m shared @@ -45,6 +45,8 @@ checksums = { \ '2.7.6' : 'fb8c0ec10f97a9353eb123a5c4c35aa6', \ '2.8.1' : '6bfe72ebdae63dc38a9ca27d9b0e08f8', \ '2.8.2' : '599092b6a0aa6fff992612537ad98994', \ + '2.8.3' : '76d23cd394eba9e6530316ed1184e219', \ + '2.9.0' : '661eabeebee05cf84bbf9dc23d7d5f46', \ } # parse and process arguments diff --git a/potentials/HGa.msmeam b/potentials/HGa.msmeam index 9f01501c16..1f84d0f8a5 100644 --- a/potentials/HGa.msmeam +++ b/potentials/HGa.msmeam @@ -1,29 +1,29 @@ bkgd_dyn = 1 emb_lin_neg = 1 -augt1=0 -ialloy=1 -rc = 5.9 +augt1=0 +ialloy=1 +rc = 5.9 #H -attrac(1,1)=0.460 -repuls(1,1)=0.460 +attrac(1,1)=0.460 +repuls(1,1)=0.460 Cmin(1,1,1)=1.3 # PuMS -Cmax(1,1,1)= 2.80 +Cmax(1,1,1)= 2.80 nn2(1,1)=1 #Ga rho0(2) = 0.6 -attrac(2,2)=0.097 -repuls(2,2)=0.097 +attrac(2,2)=0.097 +repuls(2,2)=0.097 nn2(2,2)=1 #HGa -attrac(1,2)=0.300 -repuls(1,2)=0.300 -lattce(1,2)=l12 -re(1,2)=3.19 -delta(1,2)=-0.48 -alpha(1,2)=6.6 -Cmin(1,1,2)=2.0 -Cmin(2,1,2)= 2.0 -Cmin(1,2,1)=2.0 +attrac(1,2)=0.300 +repuls(1,2)=0.300 +lattce(1,2)=l12 +re(1,2)=3.19 +delta(1,2)=-0.48 +alpha(1,2)=6.6 +Cmin(1,1,2)=2.0 +Cmin(2,1,2)= 2.0 +Cmin(1,2,1)=2.0 Cmin(2,2,1) = 1.4 Cmin(1,2,2) = 1.4 Cmin(1,1,2) = 1.4 diff --git a/potentials/MoS.rebomos b/potentials/MoS.rebomos new file mode 100644 index 0000000000..ea96981a1e --- /dev/null +++ b/potentials/MoS.rebomos @@ -0,0 +1,65 @@ +# DATE: 2013-11-04 UNITS: metal CONTRIBUTOR: J Stewart, K Dang, D Spearot (UArk) CITATION: Stewart J A and Spearot D E, Modelling Simul. Mater. Sci. Eng. 21. +# MoS-S REBO Brenner/Sinnot Potential as published in +# Liang T, Phillpot S R and Sinnott S B (2009) Phys. Rev. B79 245110, Erratum: Phys. Rev. B85 199903(E). + +3.50 rcmin_MM +2.75 rcmin_MS +2.30 rcmin_SS +3.80 rcmax_MM +3.05 rcmax_MS +3.00 rcmax_SS +3.419129390005910 Q_MM +1.505537839153790 Q_MS +0.254959104053671 Q_SS +1.07500712999340 alpha_MM +1.19267902218820 alpha_MS +1.10775022439715 alpha_SS +179.008013654688 A_MM +575.509677721866 A_MS +1228.43233679426 A_SS +706.247903589221 BIJc_MM1 +1344.46820036159 BIJc_MS1 +1498.64815404145 BIJc_SS1 +1.16100322369589 Beta_MM1 +1.26973752204290 Beta_MS1 +1.12673623610320 Beta_SS1 +0.1326842550663270 M_b0 +-0.007642788338017 M_b1 +0.0341395775059370 M_b2 +0.2523050971380870 M_b3 +0.1227287372225670 M_b4 +-0.361387798398897 M_b5 +-0.282577591351457 M_b6 +0.120194301035280 M_bg0 +0.045238287358190 M_bg1 +0.067922807244030 M_bg2 +-0.03672511378682 M_bg3 +0.107516477513860 M_bg4 +0.004964711984940 M_bg5 +-0.12997598358652 M_bg6 +0.006848761596750 S_b0 +-0.02389964401024 S_b1 +0.137457353311170 S_b2 +0.033016467497740 S_b3 +-0.31064291544850 S_b4 +-0.08550273135791 S_b5 +0.149252790306880 S_b6 +-0.2850852 S_bg0 +1.67102480 S_bg1 +-3.5678516 S_bg2 +3.45054990 S_bg3 +-1.2186289 S_bg4 +0.0 S_bg5 +0.0 S_bg6 +0.138040769883614 M_a0 +0.803625443023934 M_a1 +0.292412960851064 M_a2 +0.640588078946224 M_a3 +0.062978539843324 S_a0 +2.478617619878250 S_a1 +0.036666243238154 S_a2 +2.386431372486710 S_a3 +0.00058595 epsilon_MM +0.01386 epsilon_SS +4.200 sigma_MM +3.130 sigma_SS diff --git a/potentials/README b/potentials/README index c234f5f48b..2cb4a383c5 100644 --- a/potentials/README +++ b/potentials/README @@ -84,7 +84,7 @@ Au_u3 = Gold universal 3 The suffix of each file indicates the pair style it is used with: adp ADP angular dependent potential -airebo AI-REBO and REBO potentials +airebo AI-REBO potentials bop.table BOP potential, tabulated form cdeam concentration-dependent EAM comb COMB potential @@ -107,6 +107,8 @@ nb3b.harmonic nonbonded 3-body harmonic potential pod ML potential with proper orthogonal descriptors (POD) poly polymorphic 3-body potential reax ReaxFF potential (see README.reax for more info) +rebo REBO potentials +rebomos REBOMoS potential smtbq second moment tight binding QEq (SMTBQ) potential snap SNAP potential snapcoeff SNAP potential diff --git a/python/lammps/core.py b/python/lammps/core.py index 1ff123760b..28b384d6ba 100644 --- a/python/lammps/core.py +++ b/python/lammps/core.py @@ -282,6 +282,8 @@ class lammps(object): self.lib.lammps_config_accelerator.argtypes = [c_char_p, c_char_p, c_char_p] self.lib.lammps_set_variable.argtypes = [c_void_p, c_char_p, c_char_p] + self.lib.lammps_set_string_variable.argtypes = [c_void_p, c_char_p, c_char_p] + self.lib.lammps_set_internal_variable.argtypes = [c_void_p, c_char_p, c_double] self.lib.lammps_has_style.argtypes = [c_void_p, c_char_p, c_char_p] @@ -1252,6 +1254,8 @@ class lammps(object): def set_variable(self,name,value): """Set a new value for a LAMMPS string style variable + .. deprecated:: 7Feb2024 + This is a wrapper around the :cpp:func:`lammps_set_variable` function of the C-library interface. @@ -1271,6 +1275,52 @@ class lammps(object): # ------------------------------------------------------------------------- + def set_string_variable(self,name,value): + """Set a new value for a LAMMPS string style variable + + .. versionadded:: 7Feb2024 + + This is a wrapper around the :cpp:func:`lammps_set_string_variable` + function of the C-library interface. + + :param name: name of the variable + :type name: string + :param value: new variable value + :type value: any. will be converted to a string + :return: either 0 on success or -1 on failure + :rtype: int + """ + if name: name = name.encode() + else: return -1 + if value: value = str(value).encode() + else: return -1 + with ExceptionCheck(self): + return self.lib.lammps_set_string_variable(self.lmp,name,value) + + # ------------------------------------------------------------------------- + + def set_internal_variable(self,name,value): + """Set a new value for a LAMMPS internal style variable + + .. versionadded:: 7Feb2024 + + This is a wrapper around the :cpp:func:`lammps_set_internal_variable` + function of the C-library interface. + + :param name: name of the variable + :type name: string + :param value: new variable value + :type value: float or compatible. will be converted to float + :return: either 0 on success or -1 on failure + :rtype: int + """ + if name: name = name.encode() + else: return -1 + with ExceptionCheck(self): + return self.lib.lammps_set_internal_variable(self.lmp,name,value) + + # ------------------------------------------------------------------------- + # return vector of atom properties gathered across procs # 3 variants to match src/library.cpp # name = atom property recognized by LAMMPS in atom->extract() diff --git a/src/.gitignore b/src/.gitignore index 1e4c5b9ddb..88bb80fdc5 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -791,6 +791,8 @@ /fix_cmap.h /fix_damping_cundall.cpp /fix_damping_cundall.h +/fix_deform_pressure.cpp +/fix_deform_pressure.h /fix_dpd_energy.cpp /fix_dpd_energy.h /fix_efield_tip4p.cpp @@ -1023,6 +1025,8 @@ /fix_wall_colloid.h /fix_wall_ees.cpp /fix_wall_ees.h +/fix_wall_flow.cpp +/fix_wall_flow.h /fix_wall_region_ees.cpp /fix_wall_region_ees.h /fix_wall_reflect_stochastic.cpp @@ -1369,6 +1373,8 @@ /pair_reaxff.h /pair_rebo.cpp /pair_rebo.h +/pair_rebomos.cpp +/pair_rebomos.h /pair_resquared.cpp /pair_resquared.h /pair_saip_metal.cpp diff --git a/src/ADIOS/reader_adios.cpp b/src/ADIOS/reader_adios.cpp index ec87bc26cc..0fe82dd49f 100644 --- a/src/ADIOS/reader_adios.cpp +++ b/src/ADIOS/reader_adios.cpp @@ -30,7 +30,7 @@ using namespace LAMMPS_NS; -#define SMALL 1.0e-6 +static constexpr double SMALL = 1.0e-6; namespace LAMMPS_NS { class ReadADIOSInternal { diff --git a/src/AMOEBA/amoeba_convolution.cpp b/src/AMOEBA/amoeba_convolution.cpp index ae3dbf16c4..44b7248815 100644 --- a/src/AMOEBA/amoeba_convolution.cpp +++ b/src/AMOEBA/amoeba_convolution.cpp @@ -15,16 +15,13 @@ #include "amoeba_convolution.h" #include "comm.h" -#include "domain.h" #include "fft3d_wrap.h" #include "grid3d.h" -#include "math_extra.h" #include "memory.h" #include "neighbor.h" #include "remap_wrap.h" #include "timer.h" -#include #include using namespace LAMMPS_NS; @@ -47,13 +44,7 @@ enum{MPOLE_GRID,POLAR_GRID,POLAR_GRIDC,DISP_GRID,INDUCE_GRID,INDUCE_GRIDC}; //#define SCALE 1 #define SCALE 0 -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#define ONEF 1.0f -#else -#define ZEROF 0.0 -#define ONEF 1.0 -#endif +static constexpr FFT_SCALAR ZEROF = 0.0; /* ---------------------------------------------------------------------- partition an FFT grid across processors diff --git a/src/AMOEBA/amoeba_convolution.h b/src/AMOEBA/amoeba_convolution.h index bed65149ec..60825bb8b6 100644 --- a/src/AMOEBA/amoeba_convolution.h +++ b/src/AMOEBA/amoeba_convolution.h @@ -15,17 +15,7 @@ #define LMP_AMOEBA_CONVOLUTION_H #include "pointers.h" - -#ifdef FFT_SINGLE -typedef float FFT_SCALAR; -#define LMP_FFT_PREC "single" -#define MPI_FFT_SCALAR MPI_FLOAT -#else - -typedef double FFT_SCALAR; -#define LMP_FFT_PREC "double" -#define MPI_FFT_SCALAR MPI_DOUBLE -#endif +#include "lmpfftsettings.h" namespace LAMMPS_NS { diff --git a/src/AMOEBA/amoeba_file.cpp b/src/AMOEBA/amoeba_file.cpp index 6bf961cdab..a48af86ffe 100644 --- a/src/AMOEBA/amoeba_file.cpp +++ b/src/AMOEBA/amoeba_file.cpp @@ -25,23 +25,23 @@ using namespace LAMMPS_NS; -enum{UNKNOWN,FFIELD,LITERATURE,ATOMTYPE,VDWL,VDWLPAIR,BSTRETCH,SBEND,ABEND, - PAULI,DISPERSION,UB,OUTPLANE,TORSION,PITORSION,ATOMMULT, - QPENETRATION,DIPPOLAR,QTRANSFER,END_OF_FILE}; -enum{ALLINGER,BUFFERED_14_7}; -enum{ARITHMETIC,GEOMETRIC,CUBIC_MEAN,R_MIN,SIGMA,DIAMETER,HARMONIC,HHG,W_H}; -enum{MUTUAL,OPT,TCG,DIRECT}; -enum{NOFRAME,ZONLY,ZTHENX,BISECTOR,ZBISECT,THREEFOLD}; -enum{GEAR,ASPC,LSQR}; +enum { UNKNOWN, FFIELD, LITERATURE, ATOMTYPE, VDWL, VDWLPAIR, BSTRETCH, SBEND, ABEND, + PAULI, DISPERSION, UB, OUTPLANE, TORSION, PITORSION, ATOMMULT, QPENETRATION, DIPPOLAR, + QTRANSFER, END_OF_FILE }; +enum { ALLINGER, BUFFERED_14_7 }; +enum { ARITHMETIC, GEOMETRIC, CUBIC_MEAN, R_MIN, SIGMA, DIAMETER, HARMONIC, HHG, W_H }; +enum { MUTUAL, OPT, TCG, DIRECT }; +enum { NOFRAME, ZONLY, ZTHENX, BISECTOR, ZBISECT, THREEFOLD }; +enum { GEAR, ASPC, LSQR }; -#define MAXLINE 65536 // crazy big for TORSION-TORSION section -#define MAX_TYPE_PER_GROUP 6 // max types per AMOEBA group -#define MAX_FRAME_PER_TYPE 32 // max multipole frames for any AMOEBA type +static constexpr int MAXLINE = 65536; // crazy big for TORSION-TORSION section +static constexpr int MAX_TYPE_PER_GROUP = 6; // max types per AMOEBA group +static constexpr int MAX_FRAME_PER_TYPE = 32; // max multipole frames for any AMOEBA type -#define DELTA_TYPE_CLASS 32 -#define DELTA_VDWL_PAIR 16 +static constexpr int DELTA_TYPE_CLASS = 32; +static constexpr int DELTA_VDWL_PAIR = 16; -#define BOHR 0.52917721067 // Bohr in Angstroms +static constexpr double BOHR = 0.52917721067; // Bohr in Angstroms // methods to read, parse, and store info from force field file @@ -79,7 +79,7 @@ void PairAmoeba::read_prmfile(char *filename) int me = comm->me; FILE *fptr; - char line[MAXLINE]; + char line[MAXLINE] = {'\0'}; if (me == 0) { fptr = utils::open_potential(filename, lmp, nullptr); @@ -179,8 +179,7 @@ void PairAmoeba::read_prmfile(char *filename) for (int i = 1; i <= n_amtype; i++) nmultiframe[i] = 0; } - char next[MAXLINE]; - next[0] = '\0'; + char next[MAXLINE] = {'\0'}; bool has_next = false; int n; while (true) { @@ -381,7 +380,7 @@ void PairAmoeba::read_keyfile(char *filename) int me = comm->me; FILE *fptr; - char line[MAXLINE]; + char line[MAXLINE] = {'\0'}; if (me == 0) { fptr = utils::open_potential(filename, lmp, nullptr); if (fptr == nullptr) diff --git a/src/AMOEBA/amoeba_induce.cpp b/src/AMOEBA/amoeba_induce.cpp index 6017b775ca..278a00316d 100644 --- a/src/AMOEBA/amoeba_induce.cpp +++ b/src/AMOEBA/amoeba_induce.cpp @@ -41,7 +41,7 @@ enum{GEAR,ASPC,LSQR}; enum{BUILD,APPLY}; enum{GORDON1,GORDON2}; -#define DEBYE 4.80321 // conversion factor from q-Angs (real units) to Debye +static constexpr double DEBYE = 4.80321; // conversion factor from q-Angs (real units) to Debye /* ---------------------------------------------------------------------- induce = induced dipole moments via pre-conditioned CG solver diff --git a/src/AMOEBA/amoeba_multipole.cpp b/src/AMOEBA/amoeba_multipole.cpp index d0ae03401a..68235dfe26 100644 --- a/src/AMOEBA/amoeba_multipole.cpp +++ b/src/AMOEBA/amoeba_multipole.cpp @@ -31,16 +31,8 @@ using namespace MathConst; using MathSpecial::square; -enum{FIELD,ZRSD,TORQUE,UFLD}; // reverse comm -enum{VDWL,REPULSE,QFER,DISP,MPOLE,POLAR,USOLV,DISP_LONG,MPOLE_LONG,POLAR_LONG}; - -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#define ONEF 1.0f -#else -#define ZEROF 0.0 -#define ONEF 1.0 -#endif +enum { FIELD, ZRSD, TORQUE, UFLD }; // reverse comm +enum { VDWL, REPULSE, QFER, DISP, MPOLE, POLAR, USOLV, DISP_LONG, MPOLE_LONG, POLAR_LONG }; /* ---------------------------------------------------------------------- multipole = multipole interactions diff --git a/src/AMOEBA/angle_amoeba.cpp b/src/AMOEBA/angle_amoeba.cpp index e6ee7b579e..54fc3e9f9a 100644 --- a/src/AMOEBA/angle_amoeba.cpp +++ b/src/AMOEBA/angle_amoeba.cpp @@ -30,7 +30,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/AMOEBA/fix_amoeba_bitorsion.cpp b/src/AMOEBA/fix_amoeba_bitorsion.cpp index cb8c62819d..f814f4109a 100644 --- a/src/AMOEBA/fix_amoeba_bitorsion.cpp +++ b/src/AMOEBA/fix_amoeba_bitorsion.cpp @@ -32,10 +32,10 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace MathConst; -#define BITORSIONMAX 6 // max # of BiTorsion terms stored by one atom -#define LISTDELTA 10000 -#define LB_FACTOR 1.5 -#define MAXLINE 1024 +static constexpr int BITORSIONMAX = 6; // max # of BiTorsion terms stored by one atom +static constexpr int LISTDELTA = 10000; +static constexpr double LB_FACTOR = 1.5; +static constexpr int MAXLINE = 1024; // spline weighting factors @@ -724,7 +724,7 @@ double FixAmoebaBiTorsion::compute_scalar() void FixAmoebaBiTorsion::read_grid_data(char *bitorsion_file) { - char line[MAXLINE]; + char line[MAXLINE] = {'\0'}; char *eof; FILE *fp = nullptr; diff --git a/src/AMOEBA/fix_amoeba_pitorsion.cpp b/src/AMOEBA/fix_amoeba_pitorsion.cpp index 445845c075..33af4a3c31 100644 --- a/src/AMOEBA/fix_amoeba_pitorsion.cpp +++ b/src/AMOEBA/fix_amoeba_pitorsion.cpp @@ -32,9 +32,9 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace MathConst; -#define PITORSIONMAX 6 // max # of PiTorsion terms stored by one atom -#define LISTDELTA 8196 -#define LB_FACTOR 1.5 +static constexpr int PITORSIONMAX = 6; // max # of PiTorsion terms stored by one atom +static constexpr int LISTDELTA = 8196; +static constexpr double LB_FACTOR = 1.5; /* ---------------------------------------------------------------------- */ diff --git a/src/AMOEBA/improper_amoeba.cpp b/src/AMOEBA/improper_amoeba.cpp index 32c31b0af9..cbc7fbd8d2 100644 --- a/src/AMOEBA/improper_amoeba.cpp +++ b/src/AMOEBA/improper_amoeba.cpp @@ -28,9 +28,6 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define TOLERANCE 0.05 -#define SMALL 0.001 - /* ---------------------------------------------------------------------- */ ImproperAmoeba::ImproperAmoeba(LAMMPS *lmp) : Improper(lmp) diff --git a/src/AMOEBA/pair_amoeba.cpp b/src/AMOEBA/pair_amoeba.cpp index cad9e2b628..1bdd36dd94 100644 --- a/src/AMOEBA/pair_amoeba.cpp +++ b/src/AMOEBA/pair_amoeba.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/ Sandia National Laboratories @@ -39,17 +38,19 @@ using namespace LAMMPS_NS; using MathSpecial::powint; -enum{INDUCE,RSD,SETUP_AMOEBA,SETUP_HIPPO,KMPOLE,AMGROUP,PVAL}; // forward comm -enum{FIELD,ZRSD,TORQUE,UFLD}; // reverse comm -enum{ARITHMETIC,GEOMETRIC,CUBIC_MEAN,R_MIN,SIGMA,DIAMETER,HARMONIC,HHG,W_H}; -enum{HAL,REPULSE,QFER,DISP,MPOLE,POLAR,USOLV,DISP_LONG,MPOLE_LONG,POLAR_LONG}; -enum{MPOLE_GRID,POLAR_GRID,POLAR_GRIDC,DISP_GRID,INDUCE_GRID,INDUCE_GRIDC}; -enum{MUTUAL,OPT,TCG,DIRECT}; -enum{GEAR,ASPC,LSQR}; +enum { INDUCE, RSD, SETUP_AMOEBA, SETUP_HIPPO, KMPOLE, AMGROUP, PVAL }; // forward comm +enum { FIELD, ZRSD, TORQUE, UFLD }; // reverse comm +enum { ARITHMETIC, GEOMETRIC, CUBIC_MEAN, R_MIN, SIGMA, DIAMETER, HARMONIC, HHG, W_H }; +enum { HAL, REPULSE, QFER, DISP, MPOLE, POLAR, USOLV, DISP_LONG, MPOLE_LONG, POLAR_LONG }; +enum { MPOLE_GRID, POLAR_GRID, POLAR_GRIDC, DISP_GRID, INDUCE_GRID, INDUCE_GRIDC }; +enum { MUTUAL, OPT, TCG, DIRECT }; +enum { GEAR, ASPC, LSQR }; -#define DELTASTACK 16 +static constexpr int DELTASTACK = 16; #define DEBUG_AMOEBA 0 +// clang-format off + /* ---------------------------------------------------------------------- */ PairAmoeba::PairAmoeba(LAMMPS *lmp) : Pair(lmp) @@ -429,7 +430,7 @@ void PairAmoeba::compute(int eflag, int vflag) // output FF settings to screen and logfile // delay until here because RMS force accuracy is computed based on rpole - if (first_flag_compute && (comm->me == 0)) print_settings(); + if (first_flag_compute) print_settings(); first_flag_compute = 0; if (amoeba) pbc_xred(); @@ -827,28 +828,36 @@ void PairAmoeba::init_style() // check if all custom atom arrays were set via fix property/atom - int flag,cols; + // clang-format on + const char *names[6] = {"amtype", "amgroup", "redID", "xyzaxis", "polaxe", "pval"}; + const int flag_check[6] = {0, 0, 1, 1, 0, 1}; // correct type (0 int, 1 dbl) + const int cols_check[6] = {0, 0, 0, 3, 0, 0}; // xyzaxis 3 cols, all others 0 + const int ghost_check[6] = {1, 1, 1, 0, 0, 1}; // which types need ghost; TO-DO: check + int flag, cols, ghost, index[6]; - index_amtype = atom->find_custom("amtype",flag,cols); - if (index_amtype < 0 || flag || cols) - error->all(FLERR,"Pair {} amtype is not defined", mystyle); - index_amgroup = atom->find_custom("amgroup",flag,cols); - if (index_amgroup < 0 || flag || cols) - error->all(FLERR,"Pair {} amgroup is not defined", mystyle); + // clang-format off - index_redID = atom->find_custom("redID",flag,cols); - if (index_redID < 0 || !flag || cols) - error->all(FLERR,"Pair {} redID is not defined", mystyle); - index_xyzaxis = atom->find_custom("xyzaxis",flag,cols); - if (index_xyzaxis < 0 || !flag || cols == 0) - error->all(FLERR,"Pair {} xyzaxis is not defined", mystyle); + for (int i = 0; i < 6; i++) { + if (ghost_check[i]) { + index[i] = atom->find_custom_ghost(names[i], flag, cols, ghost); + } else { + index[i] = atom->find_custom(names[i], flag, cols); + } + std::string err; + if (index[i] < 0) err = "was not defined"; + else if (flag_check[i] != flag) err = "has the wrong type"; + else if (cols_check[i] != cols) err = "has the wrong number of columns"; + else if (ghost_check[i] && !ghost) err = "must be set by fix property/atom with ghost yes"; + if (err != "") + error->all(FLERR,"Pair {} per-atom variable {} {}", mystyle, names[i], err); + } - index_polaxe = atom->find_custom("polaxe",flag,cols); - if (index_polaxe < 0 || flag || cols) - error->all(FLERR,"Pair {} polaxe is not defined", mystyle); - index_pval = atom->find_custom("pval",flag,cols); - if (index_pval < 0 || !flag || cols) - error->all(FLERR,"Pair {} pval is not defined", mystyle); + index_amtype = index[0]; + index_amgroup = index[1]; + index_redID = index[2]; + index_xyzaxis = index[3]; + index_polaxe = index[4]; + index_pval = index[5]; // ------------------------------------------------------------------- // one-time initializations @@ -1069,79 +1078,86 @@ void PairAmoeba::init_style() void PairAmoeba::print_settings() { std::string mesg = utils::uppercase(mystyle) + " force field settings\n"; - - if (amoeba) { - choose(HAL); - mesg += fmt::format(" hal: cut {} taper {} vscale {} {} {} {}\n", sqrt(off2),sqrt(cut2), - special_hal[1],special_hal[2],special_hal[3],special_hal[4]); - } else { - choose(REPULSE); - mesg += fmt::format(" repulsion: cut {} taper {} rscale {} {} {} {}\n", sqrt(off2),sqrt(cut2), - special_repel[1],special_repel[2],special_repel[3],special_repel[4]); - - choose(QFER); - mesg += fmt::format(" qxfer: cut {} taper {} mscale {} {} {} {}\n", sqrt(off2),sqrt(cut2), - special_mpole[1],special_mpole[2],special_mpole[3],special_mpole[4]); - - if (use_dewald) { - choose(DISP_LONG); - mesg += fmt::format(" dispersion: cut {} aewald {} bsorder {} FFT {} {} {} " - "dspscale {} {} {} {}\n", sqrt(off2),aewald,bsdorder,ndfft1,ndfft2,ndfft3, - special_disp[1],special_disp[2],special_disp[3],special_disp[4]); - } else { - choose(DISP); - mesg += fmt::format(" dispersion: cut {} aewald {} dspscale {} {} {} {}\n", - sqrt(off2),aewald,special_disp[1], - special_disp[2],special_disp[3],special_disp[4]); - } - } + double estimated_mpole_accuracy = 0.0; if (use_ewald) { choose(MPOLE_LONG); - double estimated_accuracy = final_accuracy_mpole(); - mesg += fmt::format(" multipole: cut {} aewald {} bsorder {} FFT {} {} {}; " - "estimated absolute RMS force accuracy = {:.8g}; " - "estimated relative RMS force accuracy = {:.8g}; " - "mscale {} {} {} {}\n", - sqrt(off2),aewald,bseorder,nefft1,nefft2,nefft3, - estimated_accuracy,estimated_accuracy/two_charge_force, - special_mpole[1],special_mpole[2],special_mpole[3],special_mpole[4]); - } else { - choose(MPOLE); - mesg += fmt::format(" multipole: cut {} aewald {} mscale {} {} {} {}\n", sqrt(off2),aewald, - special_mpole[1],special_mpole[2],special_mpole[3],special_mpole[4]); + estimated_mpole_accuracy = final_accuracy_mpole(); } - if (use_ewald) { - choose(POLAR_LONG); - mesg += fmt::format(" polar: cut {} aewald {} bsorder {} FFT {} {} {}\n", - sqrt(off2),aewald,bsporder,nefft1,nefft2,nefft3); - mesg += fmt::format(" pscale {} {} {} {} piscale {} {} {} {} " - "wscale {} {} {} {} d/u scale {} {}\n", - special_polar_pscale[1],special_polar_pscale[2], - special_polar_pscale[3],special_polar_pscale[4], - special_polar_piscale[1],special_polar_piscale[2], - special_polar_piscale[3],special_polar_piscale[4], - special_polar_wscale[1],special_polar_wscale[2], - special_polar_wscale[3],special_polar_wscale[4], - polar_dscale,polar_uscale); - } else { - choose(POLAR); - mesg += fmt::format(" polar: cut {} aewald {}\n",sqrt(off2),aewald); - mesg += fmt::format(" pscale {} {} {} {} piscale {} {} {} {} " - "wscale {} {} {} {} d/u scale {} {}\n", - special_polar_pscale[1],special_polar_pscale[2], - special_polar_pscale[3],special_polar_pscale[4], - special_polar_piscale[1],special_polar_piscale[2], - special_polar_piscale[3],special_polar_piscale[4], - special_polar_wscale[1],special_polar_wscale[2], - special_polar_wscale[3],special_polar_wscale[4], - polar_dscale,polar_uscale); - } + if (comm->me == 0) { + if (amoeba) { + choose(HAL); + mesg += fmt::format(" hal: cut {} taper {} vscale {} {} {} {}\n", sqrt(off2),sqrt(cut2), + special_hal[1],special_hal[2],special_hal[3],special_hal[4]); + } else { + choose(REPULSE); + mesg += fmt::format(" repulsion: cut {} taper {} rscale {} {} {} {}\n", sqrt(off2),sqrt(cut2), + special_repel[1],special_repel[2],special_repel[3],special_repel[4]); - choose(USOLV); - mesg += fmt::format(" precondition: cut {}\n",sqrt(off2)); - utils::logmesg(lmp, mesg); + choose(QFER); + mesg += fmt::format(" qxfer: cut {} taper {} mscale {} {} {} {}\n", sqrt(off2),sqrt(cut2), + special_mpole[1],special_mpole[2],special_mpole[3],special_mpole[4]); + + if (use_dewald) { + choose(DISP_LONG); + mesg += fmt::format(" dispersion: cut {} aewald {} bsorder {} FFT {} {} {} " + "dspscale {} {} {} {}\n", sqrt(off2),aewald,bsdorder,ndfft1,ndfft2,ndfft3, + special_disp[1],special_disp[2],special_disp[3],special_disp[4]); + } else { + choose(DISP); + mesg += fmt::format(" dispersion: cut {} aewald {} dspscale {} {} {} {}\n", + sqrt(off2),aewald,special_disp[1], + special_disp[2],special_disp[3],special_disp[4]); + } + } + + if (use_ewald) { + choose(MPOLE_LONG); + mesg += fmt::format(" multipole: cut {} aewald {} bsorder {} FFT {} {} {}\n" + " estimated absolute RMS force accuracy = {:.8g}\n" + " estimated relative RMS force accuracy = {:.8g}\n" + " mscale {} {} {} {}\n", + sqrt(off2),aewald,bseorder,nefft1,nefft2,nefft3, + estimated_mpole_accuracy,estimated_mpole_accuracy/two_charge_force, + special_mpole[1],special_mpole[2],special_mpole[3],special_mpole[4]); + } else { + choose(MPOLE); + mesg += fmt::format(" multipole: cut {} aewald {} mscale {} {} {} {}\n", sqrt(off2),aewald, + special_mpole[1],special_mpole[2],special_mpole[3],special_mpole[4]); + } + + if (use_ewald) { + choose(POLAR_LONG); + mesg += fmt::format(" polar: cut {} aewald {} bsorder {} FFT {} {} {}\n", + sqrt(off2),aewald,bsporder,nefft1,nefft2,nefft3); + mesg += fmt::format(" pscale {} {} {} {} piscale {} {} {} {} " + "wscale {} {} {} {} d/u scale {} {}\n", + special_polar_pscale[1],special_polar_pscale[2], + special_polar_pscale[3],special_polar_pscale[4], + special_polar_piscale[1],special_polar_piscale[2], + special_polar_piscale[3],special_polar_piscale[4], + special_polar_wscale[1],special_polar_wscale[2], + special_polar_wscale[3],special_polar_wscale[4], + polar_dscale,polar_uscale); + } else { + choose(POLAR); + mesg += fmt::format(" polar: cut {} aewald {}\n",sqrt(off2),aewald); + mesg += fmt::format(" pscale {} {} {} {} piscale {} {} {} {} " + "wscale {} {} {} {} d/u scale {} {}\n", + special_polar_pscale[1],special_polar_pscale[2], + special_polar_pscale[3],special_polar_pscale[4], + special_polar_piscale[1],special_polar_piscale[2], + special_polar_piscale[3],special_polar_piscale[4], + special_polar_wscale[1],special_polar_wscale[2], + special_polar_wscale[3],special_polar_wscale[4], + polar_dscale,polar_uscale); + } + + choose(USOLV); + mesg += fmt::format(" precondition: cut {}\n",sqrt(off2)); + utils::logmesg(lmp, mesg); + } } /* ---------------------------------------------------------------------- diff --git a/src/AMOEBA/pair_amoeba.h b/src/AMOEBA/pair_amoeba.h index 648fc86126..fd694a8037 100644 --- a/src/AMOEBA/pair_amoeba.h +++ b/src/AMOEBA/pair_amoeba.h @@ -20,7 +20,7 @@ PairStyle(amoeba,PairAmoeba); #ifndef LMP_PAIR_AMOEBA_H #define LMP_PAIR_AMOEBA_H -#include "lmpfftsettings.h" +#include "lmpfftsettings.h" // IWYU pragma: export #include "pair.h" namespace LAMMPS_NS { @@ -330,10 +330,10 @@ class PairAmoeba : public Pair { double *qfac; // convoulution pre-factors double *gridfft1; // copy of p_kspace FFT grid - double **cmp,**fmp; // Cartesian and fractional multipoles - double **cphi,**fphi; + double **cmp, **fmp; // Cartesian and fractional multipoles + double **cphi, **fphi; - double *_moduli_array; // buffers for moduli + double *_moduli_array; // buffers for moduli double *_moduli_bsarray; int _nfft_max; @@ -345,11 +345,11 @@ class PairAmoeba : public Pair { double ctf[10][10]; // indices NOT flipped vs Fortran double ftc[10][10]; // indices NOT flipped vs Fortran - class AmoebaConvolution *m_kspace; // multipole KSpace - class AmoebaConvolution *p_kspace; // polar KSpace + class AmoebaConvolution *m_kspace; // multipole KSpace + class AmoebaConvolution *p_kspace; // polar KSpace class AmoebaConvolution *pc_kspace; - class AmoebaConvolution *d_kspace; // dispersion KSpace - class AmoebaConvolution *i_kspace; // induce KSpace + class AmoebaConvolution *d_kspace; // dispersion KSpace + class AmoebaConvolution *i_kspace; // induce KSpace class AmoebaConvolution *ic_kspace; // FFT grid size factors @@ -362,8 +362,8 @@ class PairAmoeba : public Pair { void hal(); virtual void repulsion(); - void damprep(double, double, double, double, double, double, double, double, - int, double, double, double *); + void damprep(double, double, double, double, double, double, double, double, int, double, double, + double *); void dispersion(); virtual void dispersion_real(); diff --git a/src/ASPHERE/compute_temp_asphere.cpp b/src/ASPHERE/compute_temp_asphere.cpp index 707938b2b9..d99d9f30c8 100644 --- a/src/ASPHERE/compute_temp_asphere.cpp +++ b/src/ASPHERE/compute_temp_asphere.cpp @@ -18,30 +18,29 @@ #include "compute_temp_asphere.h" -#include -#include "math_extra.h" #include "atom.h" #include "atom_vec_ellipsoid.h" -#include "update.h" -#include "force.h" #include "domain.h" -#include "modify.h" -#include "group.h" #include "error.h" +#include "force.h" +#include "group.h" +#include "math_extra.h" +#include "modify.h" +#include "update.h" + +#include using namespace LAMMPS_NS; -enum{ROTATE,ALL}; - -#define INERTIA 0.2 // moment of inertia prefactor for ellipsoid +enum { ROTATE, ALL }; +static constexpr double INERTIA = 0.2; // moment of inertia prefactor for ellipsoid /* ---------------------------------------------------------------------- */ ComputeTempAsphere::ComputeTempAsphere(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg), - id_bias(nullptr), tbias(nullptr), avec(nullptr) + Compute(lmp, narg, arg), id_bias(nullptr), tbias(nullptr), avec(nullptr) { - if (narg < 3) error->all(FLERR,"Illegal compute temp/asphere command"); + if (narg < 3) utils::missing_cmd_args(FLERR, "compute temp/asphere", error); scalar_flag = vector_flag = 1; size_vector = 6; @@ -56,19 +55,17 @@ ComputeTempAsphere::ComputeTempAsphere(LAMMPS *lmp, int narg, char **arg) : int iarg = 3; while (iarg < narg) { if (strcmp(arg[iarg],"bias") == 0) { - if (iarg+2 > narg) - error->all(FLERR,"Illegal compute temp/asphere command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "compute temp/asphere bias", error); tempbias = 1; id_bias = utils::strdup(arg[iarg+1]); iarg += 2; } else if (strcmp(arg[iarg],"dof") == 0) { - if (iarg+2 > narg) - error->all(FLERR,"Illegal compute temp/asphere command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "compute temp/asphere dof", error); if (strcmp(arg[iarg+1],"rotate") == 0) mode = ROTATE; else if (strcmp(arg[iarg+1],"all") == 0) mode = ALL; - else error->all(FLERR,"Illegal compute temp/asphere command"); + else error->all(FLERR,"Unknown compute temp/asphere dof keyword {}", arg[iarg+1]); iarg += 2; - } else error->all(FLERR,"Illegal compute temp/asphere command"); + } else error->all(FLERR,"Unknown compute temp/asphere keyword {}", arg[iarg]); } // when computing only the rotational temperature, @@ -84,8 +81,8 @@ ComputeTempAsphere::ComputeTempAsphere(LAMMPS *lmp, int narg, char **arg) : ComputeTempAsphere::~ComputeTempAsphere() { - delete [] id_bias; - delete [] vector; + delete[] id_bias; + delete[] vector; } /* ---------------------------------------------------------------------- */ @@ -107,17 +104,17 @@ void ComputeTempAsphere::init() for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) if (ellipsoid[i] < 0) - error->one(FLERR,"Compute temp/asphere requires extended particles"); + error->one(FLERR,"Compute temp/asphere requires all extended particles"); if (tempbias) { - int i = modify->find_compute(id_bias); - if (i < 0) - error->all(FLERR,"Could not find compute ID for temperature bias"); - tbias = modify->compute[i]; + tbias = modify->get_compute_by_id(id_bias); + if (!tbias) + error->all(FLERR,"Could not find compute ID {} for temperature bias", id_bias); + if (tbias->tempflag == 0) - error->all(FLERR,"Bias compute does not calculate temperature"); + error->all(FLERR,"Bias compute {} does not calculate temperature", id_bias); if (tbias->tempbias == 0) - error->all(FLERR,"Bias compute does not calculate a velocity bias"); + error->all(FLERR,"Bias compute {} does not calculate a velocity bias", id_bias); if (tbias->igroup != igroup) error->all(FLERR,"Bias compute group does not match compute group"); if (strcmp(tbias->style,"temp/region") == 0) tempbias = 2; diff --git a/src/ASPHERE/fix_nve_asphere.cpp b/src/ASPHERE/fix_nve_asphere.cpp index f4080493c8..a5655b875c 100644 --- a/src/ASPHERE/fix_nve_asphere.cpp +++ b/src/ASPHERE/fix_nve_asphere.cpp @@ -26,7 +26,7 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define INERTIA 0.2 // moment of inertia prefactor for ellipsoid +static constexpr double INERTIA = 0.2; // moment of inertia prefactor for ellipsoid /* ---------------------------------------------------------------------- */ diff --git a/src/ASPHERE/fix_nve_line.cpp b/src/ASPHERE/fix_nve_line.cpp index d7adf0a963..4d7a691bdd 100644 --- a/src/ASPHERE/fix_nve_line.cpp +++ b/src/ASPHERE/fix_nve_line.cpp @@ -23,7 +23,7 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace MathConst; -#define INERTIA (1.0/12.0) // moment of inertia prefactor for line segment +static constexpr double INERTIA = (1.0/12.0); // moment of inertia prefactor for line segment /* ---------------------------------------------------------------------- */ diff --git a/src/ASPHERE/pair_line_lj.cpp b/src/ASPHERE/pair_line_lj.cpp index 2d6dc557f3..3bfc10758c 100644 --- a/src/ASPHERE/pair_line_lj.cpp +++ b/src/ASPHERE/pair_line_lj.cpp @@ -25,7 +25,7 @@ using namespace LAMMPS_NS; -#define DELTA 10000 +static constexpr int DELTA = 10000; /* ---------------------------------------------------------------------- */ diff --git a/src/ASPHERE/pair_tri_lj.cpp b/src/ASPHERE/pair_tri_lj.cpp index 4fe999f039..b9cb2528ca 100644 --- a/src/ASPHERE/pair_tri_lj.cpp +++ b/src/ASPHERE/pair_tri_lj.cpp @@ -26,7 +26,7 @@ using namespace LAMMPS_NS; -#define DELTA 20 +static constexpr int DELTA = 20; /* ---------------------------------------------------------------------- */ diff --git a/src/ASPHERE/pair_ylz.cpp b/src/ASPHERE/pair_ylz.cpp index 0d0c8b9ee0..a678712619 100644 --- a/src/ASPHERE/pair_ylz.cpp +++ b/src/ASPHERE/pair_ylz.cpp @@ -12,7 +12,7 @@ ------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- - Contributing author: Hongyan Yuan (SUSTech) + Contributing authors: Hongyan Yuan (SUSTech), Zhaoyan Huang(SUSTech) ------------------------------------------------------------------------- */ #include "pair_ylz.h" diff --git a/src/ATC/fix_atc.cpp b/src/ATC/fix_atc.cpp index 436ffc9555..b1276d6788 100644 --- a/src/ATC/fix_atc.cpp +++ b/src/ATC/fix_atc.cpp @@ -20,15 +20,17 @@ #include "group.h" #include "neighbor.h" +#include "ATC_Error.h" #include "ATC_Method.h" -#include "ATC_TransferKernel.h" -#include "ATC_TransferPartitionOfUnity.h" #include "ATC_CouplingEnergy.h" #include "ATC_CouplingMomentum.h" #include "ATC_CouplingMass.h" #include "ATC_CouplingMomentumEnergy.h" +#include "ATC_TransferKernel.h" +#include "ATC_TransferPartitionOfUnity.h" +#include "ATC_TypeDefs.h" +#include "ExtrinsicModel.h" #include "LammpsInterface.h" - #include using namespace LAMMPS_NS; diff --git a/src/AWPMD/atom_vec_wavepacket.cpp b/src/AWPMD/atom_vec_wavepacket.cpp index ff0d660fb6..65b8214369 100644 --- a/src/AWPMD/atom_vec_wavepacket.cpp +++ b/src/AWPMD/atom_vec_wavepacket.cpp @@ -19,6 +19,8 @@ #include "atom.h" +#include + using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ diff --git a/src/BOCS/compute_pressure_bocs.cpp b/src/BOCS/compute_pressure_bocs.cpp index a8bc9596cc..16d6c91a1f 100644 --- a/src/BOCS/compute_pressure_bocs.cpp +++ b/src/BOCS/compute_pressure_bocs.cpp @@ -42,7 +42,7 @@ ComputePressureBocs::ComputePressureBocs(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg), vptr(nullptr), id_temp(nullptr) { - if (narg < 4) error->all(FLERR,"Illegal compute pressure/bocs command"); + if (narg < 4) utils::missing_cmd_args(FLERR,"compute pressure/bocs", error); if (igroup) error->all(FLERR,"Compute pressure/bocs must use group all"); scalar_flag = vector_flag = 1; @@ -62,12 +62,12 @@ ComputePressureBocs::ComputePressureBocs(LAMMPS *lmp, int narg, char **arg) : else { id_temp = utils::strdup(arg[3]); - int icompute = modify->find_compute(id_temp); - if (icompute < 0) - error->all(FLERR,"Could not find compute pressure/bocs temperature ID"); - if (modify->compute[icompute]->tempflag == 0) - error->all(FLERR,"Compute pressure/bocs temperature ID does not " - "compute temperature"); + temperature = modify->get_compute_by_id(id_temp); + if (!temperature) + error->all(FLERR,"Could not find compute pressure/bocs temperature compute {}", id_temp); + if (temperature->tempflag == 0) + error->all(FLERR,"Compute pressure/bocs temperature compute {} does not compute " + "temperature", id_temp); } // process optional args @@ -137,10 +137,9 @@ void ComputePressureBocs::init() // fixes could have changed or compute_modify could have changed it if (keflag) { - int icompute = modify->find_compute(id_temp); - if (icompute < 0) - error->all(FLERR,"Could not find compute pressure/bocs temperature ID"); - temperature = modify->compute[icompute]; + temperature = modify->get_compute_by_id(id_temp); + if (!temperature) + error->all(FLERR,"Could not find compute pressure/bocs temperature compute {}", id_temp); } // detect contributions to virial @@ -158,10 +157,8 @@ void ComputePressureBocs::init() if (improperflag && force->improper) nvirial++; } if (fixflag) { - Fix **fix = modify->fix; - int nfix = modify->nfix; - for (int i = 0; i < nfix; i++) - if (fix[i]->thermo_virial) nvirial++; + for (const auto &ifix : modify->get_fix_list()) + if (ifix->thermo_virial) nvirial++; } if (nvirial) { @@ -174,10 +171,11 @@ void ComputePressureBocs::init() vptr[nvirial++] = force->dihedral->virial; if (improperflag && force->improper) vptr[nvirial++] = force->improper->virial; - if (fixflag) - for (int i = 0; i < modify->nfix; i++) - if (modify->fix[i]->virial_global_flag && modify->fix[i]->thermo_virial) - vptr[nvirial++] = modify->fix[i]->virial; + if (fixflag) { + for (const auto &ifix : modify->get_fix_list()) + if (ifix->virial_global_flag && ifix->thermo_virial) + vptr[nvirial++] = ifix->virial; + } } // flag Kspace contribution separately, since not summed across procs diff --git a/src/BOCS/fix_bocs.cpp b/src/BOCS/fix_bocs.cpp index 4918f8d879..25471d04a4 100644 --- a/src/BOCS/fix_bocs.cpp +++ b/src/BOCS/fix_bocs.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -26,7 +25,6 @@ #include "error.h" #include "fix_deform.h" #include "force.h" -#include "group.h" #include "irregular.h" #include "kspace.h" #include "memory.h" @@ -42,40 +40,39 @@ using namespace LAMMPS_NS; using namespace FixConst; static const char cite_user_bocs_package[] = - "BOCS package: doi:10.1021/acs.jpcb.7b09993\n\n" - "@Article{Dunn2018,\n" - " author = {N. J. H. Dunn and K. M. Lebold and M. R. {DeLyser} and\n" - " J. F. Rudzinski and W. G. Noid},\n" - " title = {{BOCS}: Bottom-Up Open-Source Coarse-Graining Software},\n" - " journal = {J.~Phys.\\ Chem.~B},\n" - " year = 2018,\n" - " volume = 122,\n" - " number = 13,\n" - " pages = {3363--3377}\n" - "}\n\n"; + "BOCS package: doi:10.1021/acs.jpcb.7b09993\n\n" + "@Article{Dunn2018,\n" + " author = {N. J. H. Dunn and K. M. Lebold and M. R. {DeLyser} and\n" + " J. F. Rudzinski and W. G. Noid},\n" + " title = {{BOCS}: Bottom-Up Open-Source Coarse-Graining Software},\n" + " journal = {J.~Phys.\\ Chem.~B},\n" + " year = 2018,\n" + " volume = 122,\n" + " number = 13,\n" + " pages = {3363--3377}\n" + "}\n\n"; +static constexpr double DELTAFLIP = 0.1; +static constexpr double TILTMAX = 1.5; +static constexpr int NUM_INPUT_DATA_COLUMNS = 2; // columns in the pressure correction file -#define DELTAFLIP 0.1 -#define TILTMAX 1.5 - -enum{NOBIAS,BIAS}; -enum{NONE,XYZ,XY,YZ,XZ}; -enum{ISO,ANISO,TRICLINIC}; - -const int NUM_INPUT_DATA_COLUMNS = 2; // columns in the pressure correction file +enum { NOBIAS, BIAS }; +enum { NONE, XYZ, XY, YZ, XZ }; +enum { ISO, ANISO, TRICLINIC }; /* ---------------------------------------------------------------------- NVT,NPH,NPT integrators for improved Nose-Hoover equations of motion ---------------------------------------------------------------------- */ FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg), id_dilate(nullptr), irregular(nullptr), id_temp(nullptr), - id_press(nullptr), eta(nullptr), eta_dot(nullptr), eta_dotdot(nullptr), eta_mass(nullptr), - etap(nullptr), etap_dot(nullptr), etap_dotdot(nullptr), etap_mass(nullptr) + Fix(lmp, narg, arg), irregular(nullptr), id_temp(nullptr), id_press(nullptr), eta(nullptr), + eta_dot(nullptr), eta_dotdot(nullptr), eta_mass(nullptr), etap(nullptr), etap_dot(nullptr), + etap_dotdot(nullptr), etap_mass(nullptr) { if (lmp->citeme) lmp->citeme->add(cite_user_bocs_package); - if (narg < 4) error->all(FLERR,"Illegal fix bocs command"); + // clang-format off + if (narg < 4) utils::missing_cmd_args(FLERR,"fix bocs",error); restart_global = 1; dynamic_group_allow = 1; @@ -91,8 +88,6 @@ FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) : pcouple = NONE; drag = 0.0; - allremap = 1; - id_dilate = nullptr; mtchain = mpchain = 3; nc_tchain = nc_pchain = 1; mtk_flag = 1; @@ -102,8 +97,6 @@ FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) : omega_mass_flag = 0; etap_mass_flag = 0; flipflag = 1; - dipole_flag = 0; - dlm_flag = 0; tcomputeflag = 0; pcomputeflag = 0; @@ -151,15 +144,14 @@ FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) : while (iarg < narg) { if (strcmp(arg[iarg],"temp") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal fix bocs command"); + if (iarg+4 > narg) utils::missing_cmd_args(FLERR,"fix bocs temp", error); tstat_flag = 1; t_start = utils::numeric(FLERR,arg[iarg+1],false,lmp); t_target = t_start; t_stop = utils::numeric(FLERR,arg[iarg+2],false,lmp); t_period = utils::numeric(FLERR,arg[iarg+3],false,lmp); if (t_start <= 0.0 || t_stop <= 0.0) - error->all(FLERR, - "Target temperature for fix bocs cannot be 0.0"); + error->all(FLERR, "Target temperature for fix bocs cannot be 0.0"); iarg += 4; } else if (strcmp(arg[iarg],"iso") == 0) { error->all(FLERR,"Illegal fix bocs command. Pressure fix must be " @@ -170,12 +162,9 @@ FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) : "followed by: P_0 P_f P_coupl"); p_match_flag = 1; pcouple = XYZ; - p_start[0] = p_start[1] = p_start[2] = - utils::numeric(FLERR,arg[iarg+1],false,lmp); - p_stop[0] = p_stop[1] = p_stop[2] = - utils::numeric(FLERR,arg[iarg+2],false,lmp); - p_period[0] = p_period[1] = p_period[2] = - utils::numeric(FLERR,arg[iarg+3],false,lmp); + p_start[0] = p_start[1] = p_start[2] = utils::numeric(FLERR,arg[iarg+1],false,lmp); + p_stop[0] = p_stop[1] = p_stop[2] = utils::numeric(FLERR,arg[iarg+2],false,lmp); + p_period[0] = p_period[1] = p_period[2] = utils::numeric(FLERR,arg[iarg+3],false,lmp); p_flag[0] = p_flag[1] = p_flag[2] = 1; p_flag[3] = p_flag[4] = p_flag[5] = 0; // MRD @@ -266,13 +255,6 @@ FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) : if (p_flag[2] && domain->zperiodic == 0) error->all(FLERR,"Cannot use fix bocs on a non-periodic dimension"); - if (dipole_flag) { - if (!atom->sphere_flag) - error->all(FLERR,"Using update dipole flag requires atom style sphere"); - if (!atom->mu_flag) - error->all(FLERR,"Using update dipole flag requires atom attribute mu"); - } - if ((tstat_flag && t_period <= 0.0) || (p_flag[0] && p_period[0] <= 0.0) || (p_flag[1] && p_period[1] <= 0.0) || @@ -299,7 +281,6 @@ FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) : if (p_flag[4]) box_change |= BOX_CHANGE_XZ; if (p_flag[5]) box_change |= BOX_CHANGE_XY; no_change_box = 1; - if (allremap == 0) restart_pbc = 1; pstyle = ISO; // MRD this is the only one that can happen @@ -397,7 +378,7 @@ FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) : // and thus its KE/temperature contribution should use group all id_temp = utils::strdup(std::string(id)+"_temp"); - modify->add_compute(fmt::format("{} all temp",id_temp)); + temperature = modify->add_compute(fmt::format("{} all temp",id_temp)); tcomputeflag = 1; // create a new compute pressure style @@ -405,7 +386,7 @@ FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) : // pass id_temp as 4th arg to pressure constructor id_press = utils::strdup(std::string(id)+"_press"); - modify->add_compute(fmt::format("{} all PRESSURE/BOCS {}",id_press,id_temp)); + pressure = modify->add_compute(fmt::format("{} all PRESSURE/BOCS {}",id_press,id_temp)); pcomputeflag = 1; /*~ MRD End of stuff copied from fix_npt.cpp~*/ @@ -418,7 +399,6 @@ FixBocs::~FixBocs() { if (copymode) return; - delete[] id_dilate; delete irregular; // delete temperature and pressure if fix created them @@ -469,14 +449,6 @@ int FixBocs::setmask() void FixBocs::init() { - // recheck that dilate group has not been deleted - if (allremap == 0) { - int idilate = group->find(id_dilate); - if (idilate == -1) - error->all(FLERR,"Fix bocs dilate group ID does not exist"); - dilate_group_bit = group->bitmask[idilate]; - } - // ensure no conflict with fix deform if (pstat_flag) { @@ -616,8 +588,8 @@ int FixBocs::read_F_table( char *filename, int p_basis_type ) // Data file lines hold two floating point numbers. // Line length we allocate should be long enough without being too long. // 128 seems safe for a line we expect to be < 30 chars. - const int MAX_F_TABLE_LINE_LENGTH = 128; - char line[MAX_F_TABLE_LINE_LENGTH]; + constexpr int MAX_F_TABLE_LINE_LENGTH = 128; + char line[MAX_F_TABLE_LINE_LENGTH] = {'\0'}; std::vector inputLines; while (fgets(line, MAX_F_TABLE_LINE_LENGTH, fpi)) { inputLines.emplace_back(line); @@ -649,17 +621,13 @@ int FixBocs::read_F_table( char *filename, int p_basis_type ) for (int i = 0; i < (int)inputLines.size(); ++i) { lineNum++; // count each line processed now so lineNum messages can be 1-based test_sscanf = sscanf(inputLines.at(i).c_str()," %f , %f ",&f1, &f2); - if (test_sscanf == 2) - { + if (test_sscanf == 2) { data[VOLUME][i] = (double)f1; data[PRESSURE_CORRECTION][i] = (double)f2; - if (i == 1) - { + if (i == 1) { // second entry is used to compute the validation interval used below stdVolumeInterval = data[VOLUME][i] - data[VOLUME][i-1]; - } - else if (i > 1) - { + } else if (i > 1) { // after second entry, all intervals are validated currVolumeInterval = data[VOLUME][i] - data[VOLUME][i-1]; if (fabs(currVolumeInterval - stdVolumeInterval) > volumeIntervalTolerance) { @@ -673,17 +641,14 @@ int FixBocs::read_F_table( char *filename, int p_basis_type ) } // no concluding else is intentional: i = 0, first line, no interval to validate } - } - else - { + } else { if (comm->me == 0) error->warning(FLERR,"Bad input format: did not find 2 comma separated numeric" " values in line {} of file {}\nWARNING:\tline: {}", lineNum, filename, inputLines.at(i)); badInput = true; } - if (badInput) - { + if (badInput) { numBadVolumeIntervals++; } } @@ -700,18 +665,13 @@ int FixBocs::read_F_table( char *filename, int p_basis_type ) error->warning(FLERR,"Bad volume / pressure-correction data: {}\nSee details above", filename); } - if (p_basis_type == BASIS_LINEAR_SPLINE) - { + if (p_basis_type == BASIS_LINEAR_SPLINE) { spline_length = numEntries; numEntries = build_linear_splines(data); - } - else if (p_basis_type == BASIS_CUBIC_SPLINE) - { + } else if (p_basis_type == BASIS_CUBIC_SPLINE) { spline_length = numEntries; numEntries = build_cubic_splines(data); - } - else - { + } else { error->all(FLERR,"ERROR: invalid p_basis_type value of {} in read_F_table", p_basis_type); } @@ -724,8 +684,7 @@ int FixBocs::build_linear_splines(double **data) { splines[VOLUME] = (double *) calloc(spline_length,sizeof(double)); splines[PRESSURE_CORRECTION] = (double *) calloc(spline_length,sizeof(double)); - for (int i = 0; i < spline_length; ++i) - { + for (int i = 0; i < spline_length; ++i) { splines[VOLUME][i] = data[VOLUME][i]; splines[PRESSURE_CORRECTION][i] = data[PRESSURE_CORRECTION][i]; } @@ -758,18 +717,15 @@ int FixBocs::build_cubic_splines(double **data) memory->create(mu, n, "mu"); memory->create(z, n, "z"); - for (int i=0; i1 && i<(n-1)) - { + if (i>1 && i<(n-1)) { alpha_i = (3.0 / h[i]) * ( data[1][i+1] - data[1][i]) - (3.0 / h[i-1] ) * ( data[1][i] - data[1][i-1] ); alpha[i-1] = alpha_i; @@ -779,8 +735,7 @@ int FixBocs::build_cubic_splines(double **data) mu[0] = 0.0; z[0] = 0.0; - for (int i=1; i=0; j--) - { + for (int j=n-1; j>=0; j--) { c[j] = z[j] - mu[j]*c[j+1]; - b[j] = (a[j+1]-a[j])/h[j] - h[j]*(c[j+1] + 2.0 * c[j])/3.0; - d[j] = (c[j+1]-c[j])/(3.0 * h[j]); } int numSplines = n - 1; memory->create(splines, NUM_CUBIC_SPLINE_COLUMNS, numSplines, "splines"); - for (int idx = 0; idx < numSplines; ++idx) - { + for (int idx = 0; idx < numSplines; ++idx) { splines[0][idx] = data[0][idx]; splines[1][idx] = a[idx]; splines[2][idx] = b[idx]; @@ -1157,19 +1108,15 @@ void FixBocs::couple() } /* ---------------------------------------------------------------------- - change box size - remap all atoms or dilate group atoms depending on allremap flag + change box size, remap all atoms if rigid bodies exist, scale rigid body centers-of-mass ------------------------------------------------------------------------- */ void FixBocs::remap() { - int i; double oldlo,oldhi; double expfac; - double **x = atom->x; - int *mask = atom->mask; int nlocal = atom->nlocal; double *h = domain->h; @@ -1179,12 +1126,7 @@ void FixBocs::remap() // convert pertinent atoms and rigid bodies to lamda coords - if (allremap) domain->x2lamda(nlocal); - else { - for (i = 0; i < nlocal; i++) - if (mask[i] & dilate_group_bit) - domain->x2lamda(x[i],x[i]); - } + domain->x2lamda(nlocal); for (auto &ifix : rfix) ifix->deform(0); @@ -1324,12 +1266,7 @@ void FixBocs::remap() // convert pertinent atoms and rigid bodies back to box coords - if (allremap) domain->lamda2x(nlocal); - else { - for (i = 0; i < nlocal; i++) - if (mask[i] & dilate_group_bit) - domain->lamda2x(x[i],x[i]); - } + domain->lamda2x(nlocal); for (auto &ifix : rfix) ifix->deform(1); } @@ -1493,24 +1430,22 @@ int FixBocs::modify_param(int narg, char **arg) delete[] id_temp; id_temp = utils::strdup(arg[1]); - int icompute = modify->find_compute(arg[1]); - if (icompute < 0) - error->all(FLERR,"Could not find fix_modify temperature ID"); - temperature = modify->compute[icompute]; + temperature = modify->get_compute_by_id(id_temp); + if (!temperature) + error->all(FLERR,"Could not find fix_modify temperature compute {}", id_temp); if (temperature->tempflag == 0) - error->all(FLERR, - "Fix_modify temperature ID does not compute temperature"); + error->all(FLERR, "Fix_modify temperature compute {} does not compute temperature", id_temp); if (temperature->igroup != 0 && comm->me == 0) - error->warning(FLERR,"Temperature for fix modify is not for group all"); + error->warning(FLERR,"Temperature compute {} for fix modify is not for group all", id_temp); // reset id_temp of pressure to new temperature ID if (pstat_flag) { - icompute = modify->find_compute(id_press); - if (icompute < 0) - error->all(FLERR,"Pressure ID for fix modify does not exist"); - modify->compute[icompute]->reset_extra_compute_fix(id_temp); + pressure = modify->get_compute_by_id(id_press); + if (!pressure) + error->all(FLERR,"Pressure ID {} for fix modify does not exist", id_press); + pressure->reset_extra_compute_fix(id_temp); } return 2; diff --git a/src/BOCS/fix_bocs.h b/src/BOCS/fix_bocs.h index 71fbc273d8..7f752a03f3 100644 --- a/src/BOCS/fix_bocs.h +++ b/src/BOCS/fix_bocs.h @@ -65,7 +65,7 @@ class FixBocs : public Fix { int tstat_flag; // 1 if control T int pstat_flag; // 1 if control P - int pstyle, pcouple, allremap; + int pstyle, pcouple; int p_flag[6]; // 1 if control P on this dim, 0 if not double p_start[6], p_stop[6]; double p_freq[6], p_target[6]; @@ -75,9 +75,7 @@ class FixBocs : public Fix { double drag, tdrag_factor; // drag factor on particle thermostat double pdrag_factor; // drag factor on barostat int kspace_flag; // 1 if KSpace invoked, 0 if not - int dilate_group_bit; // mask for dilation group std::vector rfix; // list of rigid fixes - char *id_dilate; // group name to dilate class Irregular *irregular; // for migrating atoms after box flips // MRD NJD @@ -129,8 +127,6 @@ class FixBocs : public Fix { int eta_mass_flag; // 1 if eta_mass updated, 0 if not. int omega_mass_flag; // 1 if omega_mass updated, 0 if not. int etap_mass_flag; // 1 if etap_mass updated, 0 if not. - int dipole_flag; // 1 if dipole is updated, 0 if not. - int dlm_flag; // 1 if using the DLM rotational integrator, 0 if not int scaleyz; // 1 if yz scaled with lz int scalexz; // 1 if xz scaled with lz diff --git a/src/BODY/body_nparticle.cpp b/src/BODY/body_nparticle.cpp index 62e6ee802a..7a1dbaa0f0 100644 --- a/src/BODY/body_nparticle.cpp +++ b/src/BODY/body_nparticle.cpp @@ -26,7 +26,7 @@ using namespace LAMMPS_NS; -#define EPSILON 1.0e-7 +static constexpr double EPSILON = 1.0e-7; enum{SPHERE,LINE,TRI}; // also in DumpImage /* ---------------------------------------------------------------------- */ diff --git a/src/BODY/body_rounded_polygon.cpp b/src/BODY/body_rounded_polygon.cpp index 2fb2a991f1..6a94f68a8e 100644 --- a/src/BODY/body_rounded_polygon.cpp +++ b/src/BODY/body_rounded_polygon.cpp @@ -32,7 +32,7 @@ using namespace LAMMPS_NS; -#define EPSILON 1.0e-7 +static constexpr double EPSILON = 1.0e-7; enum{SPHERE,LINE}; // also in DumpImage /* ---------------------------------------------------------------------- */ diff --git a/src/BODY/body_rounded_polyhedron.cpp b/src/BODY/body_rounded_polyhedron.cpp index 1d11644618..991f52cac5 100644 --- a/src/BODY/body_rounded_polyhedron.cpp +++ b/src/BODY/body_rounded_polyhedron.cpp @@ -31,10 +31,10 @@ using namespace LAMMPS_NS; -#define EPSILON 1.0e-7 -#define MAX_FACE_SIZE 4 // maximum number of vertices per face (for now) +static constexpr double EPSILON = 1.0e-7; +static constexpr int MAX_FACE_SIZE = 4; // maximum number of vertices per face (for now) -enum{SPHERE,LINE}; // also in DumpImage +enum { SPHERE, LINE }; // also in DumpImage /* ---------------------------------------------------------------------- */ diff --git a/src/BODY/compute_body_local.cpp b/src/BODY/compute_body_local.cpp index 42afa13514..4a4a36bfae 100644 --- a/src/BODY/compute_body_local.cpp +++ b/src/BODY/compute_body_local.cpp @@ -25,7 +25,7 @@ using namespace LAMMPS_NS; -#define DELTA 10000 +static constexpr int DELTA = 10000; enum{ID,TYPE,INDEX}; diff --git a/src/BODY/compute_temp_body.cpp b/src/BODY/compute_temp_body.cpp index 319c2ff986..39b2518600 100644 --- a/src/BODY/compute_temp_body.cpp +++ b/src/BODY/compute_temp_body.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -19,27 +18,28 @@ #include "compute_temp_body.h" -#include -#include "math_extra.h" #include "atom.h" #include "atom_vec_body.h" -#include "update.h" -#include "force.h" #include "domain.h" -#include "modify.h" -#include "group.h" #include "error.h" +#include "force.h" +#include "group.h" +#include "math_extra.h" +#include "modify.h" +#include "update.h" + +#include using namespace LAMMPS_NS; -enum{ROTATE,ALL}; +enum { ROTATE, ALL }; /* ---------------------------------------------------------------------- */ ComputeTempBody::ComputeTempBody(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg), id_bias(nullptr), tbias(nullptr), avec(nullptr) + Compute(lmp, narg, arg), id_bias(nullptr), tbias(nullptr), avec(nullptr) { - if (narg < 3) error->all(FLERR,"Illegal compute temp/body command"); + if (narg < 3) utils::missing_cmd_args(FLERR, "compute temp/body", error); scalar_flag = vector_flag = 1; size_vector = 6; @@ -48,25 +48,24 @@ ComputeTempBody::ComputeTempBody(LAMMPS *lmp, int narg, char **arg) : tempflag = 1; tempbias = 0; - id_bias = nullptr; mode = ALL; + // clang-format off + int iarg = 3; while (iarg < narg) { if (strcmp(arg[iarg],"bias") == 0) { - if (iarg+2 > narg) - error->all(FLERR,"Illegal compute temp/body command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "compute temp/body bias", error); tempbias = 1; id_bias = utils::strdup(arg[iarg+1]); iarg += 2; } else if (strcmp(arg[iarg],"dof") == 0) { - if (iarg+2 > narg) - error->all(FLERR,"Illegal compute temp/body command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "compute temp/body dof", error); if (strcmp(arg[iarg+1],"rotate") == 0) mode = ROTATE; else if (strcmp(arg[iarg+1],"all") == 0) mode = ALL; - else error->all(FLERR,"Illegal compute temp/body command"); + else error->all(FLERR,"Unknown compute temp/body dof keyword {}", arg[iarg+1]); iarg += 2; - } else error->all(FLERR,"Illegal compute temp/body command"); + } else error->all(FLERR,"Unknown compute temp/body keyword {}", arg[iarg]); } vector = new double[size_vector]; @@ -77,8 +76,8 @@ ComputeTempBody::ComputeTempBody(LAMMPS *lmp, int narg, char **arg) : ComputeTempBody::~ComputeTempBody() { - delete [] id_bias; - delete [] vector; + delete[] id_bias; + delete[] vector; } /* ---------------------------------------------------------------------- */ @@ -88,8 +87,7 @@ void ComputeTempBody::init() // error check avec = dynamic_cast(atom->style_match("body")); - if (!avec) - error->all(FLERR,"Compute temp/body requires atom style body"); + if (!avec) error->all(FLERR,"Compute temp/body requires atom style body"); // check that all particles are finite-size, no point particles allowed @@ -99,18 +97,16 @@ void ComputeTempBody::init() for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) - if (body[i] < 0) - error->one(FLERR,"Compute temp/body requires bodies"); + if (body[i] < 0) error->one(FLERR,"Compute temp/body requires bodies"); if (tempbias) { - int i = modify->find_compute(id_bias); - if (i < 0) - error->all(FLERR,"Could not find compute ID for temperature bias"); - tbias = modify->compute[i]; + tbias = modify->get_compute_by_id(id_bias); + if (!tbias) + error->all(FLERR,"Could not find compute {} for temperature bias", id_bias); if (tbias->tempflag == 0) - error->all(FLERR,"Bias compute does not calculate temperature"); + error->all(FLERR,"Bias compute {} does not calculate temperature", id_bias); if (tbias->tempbias == 0) - error->all(FLERR,"Bias compute does not calculate a velocity bias"); + error->all(FLERR,"Bias compute {} does not calculate a velocity bias", id_bias); if (tbias->igroup != igroup) error->all(FLERR,"Bias compute group does not match compute group"); if (strcmp(tbias->style,"temp/region") == 0) tempbias = 2; diff --git a/src/BODY/fix_wall_body_polygon.cpp b/src/BODY/fix_wall_body_polygon.cpp index 6f0622cbf6..051d316a28 100644 --- a/src/BODY/fix_wall_body_polygon.cpp +++ b/src/BODY/fix_wall_body_polygon.cpp @@ -43,11 +43,11 @@ enum {INVALID=0,NONE=1,VERTEX=2}; enum {FAR=0,XLO,XHI,YLO,YHI}; //#define _POLYGON_DEBUG -#define DELTA 10000 -#define EPSILON 1e-2 // dimensionless threshold (dot products, end point checks, contact checks) -#define BIG 1.0e20 -#define MAX_CONTACTS 4 // maximum number of contacts for 2D models -#define EFF_CONTACTS 2 // effective contacts for 2D models +static constexpr int DELTA = 10000; +static constexpr double EPSILON = 1.0e-2; // dimensionless threshold (dot products, end point checks, contact checks) +static constexpr double BIG = 1.0e20; +static constexpr int MAX_CONTACTS = 4; // maximum number of contacts for 2D models +static constexpr int EFF_CONTACTS = 2; // effective contacts for 2D models /* ---------------------------------------------------------------------- */ diff --git a/src/BODY/fix_wall_body_polyhedron.cpp b/src/BODY/fix_wall_body_polyhedron.cpp index 4b28f6af72..b42cc6843f 100644 --- a/src/BODY/fix_wall_body_polyhedron.cpp +++ b/src/BODY/fix_wall_body_polyhedron.cpp @@ -43,11 +43,10 @@ enum {INVALID=0,NONE=1,VERTEX=2}; enum {FAR=0,XLO,XHI,YLO,YHI,ZLO,ZHI}; //#define _POLYHEDRON_DEBUG -#define DELTA 10000 -#define EPSILON 1e-3 // dimensionless threshold (dot products, end point checks) -#define BIG 1.0e20 -#define MAX_CONTACTS 4 // maximum number of contacts for 2D models -#define EFF_CONTACTS 2 // effective contacts for 2D models +static constexpr int DELTA = 10000; +static constexpr double EPSILON = 1.0e-3; // dimensionless threshold (dot products, end point checks) +static constexpr double BIG = 1.0e20; +static constexpr int MAX_CONTACTS = 4; // maximum number of contacts for 2D models /* ---------------------------------------------------------------------- */ diff --git a/src/BODY/pair_body_nparticle.cpp b/src/BODY/pair_body_nparticle.cpp index 9e1e640015..29ee06dbef 100644 --- a/src/BODY/pair_body_nparticle.cpp +++ b/src/BODY/pair_body_nparticle.cpp @@ -29,7 +29,7 @@ using namespace LAMMPS_NS; -#define DELTA 10000 +static constexpr int DELTA = 10000; /* ---------------------------------------------------------------------- */ diff --git a/src/BODY/pair_body_rounded_polygon.cpp b/src/BODY/pair_body_rounded_polygon.cpp index 24f38a6a0a..432f1d5c9c 100644 --- a/src/BODY/pair_body_rounded_polygon.cpp +++ b/src/BODY/pair_body_rounded_polygon.cpp @@ -39,15 +39,15 @@ using namespace LAMMPS_NS; -#define DELTA 10000 -#define EPSILON 1e-3 // dimensionless threshold (dot products, end point checks, contact checks) -#define MAX_CONTACTS 4 // maximum number of contacts for 2D models -#define EFF_CONTACTS 2 // effective contacts for 2D models +static constexpr int DELTA = 10000; +static constexpr double EPSILON = 1.0e-3; // dimensionless threshold (dot products, end point checks, contact checks) +static constexpr int MAX_CONTACTS = 4; // maximum number of contacts for 2D models +static constexpr int EFF_CONTACTS = 2; // effective contacts for 2D models //#define _CONVEX_POLYGON //#define _POLYGON_DEBUG -enum {INVALID=0,NONE=1,VERTEXI=2,VERTEXJ=3,EDGE=4}; +enum { INVALID=0, NONE=1, VERTEXI=2, VERTEXJ=3, EDGE=4 }; /* ---------------------------------------------------------------------- */ diff --git a/src/BODY/pair_body_rounded_polyhedron.cpp b/src/BODY/pair_body_rounded_polyhedron.cpp index e261ff14d3..82660df1e0 100644 --- a/src/BODY/pair_body_rounded_polyhedron.cpp +++ b/src/BODY/pair_body_rounded_polyhedron.cpp @@ -43,10 +43,10 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define DELTA 10000 -#define EPSILON 1e-3 // dimensionless threshold (dot products, end point checks, contact checks) -#define MAX_FACE_SIZE 4 // maximum number of vertices per face (same as BodyRoundedPolyhedron) -#define MAX_CONTACTS 32 // for 3D models (including duplicated counts) +static constexpr int DELTA = 10000; +static constexpr double EPSILON = 1.0e-3; // dimensionless threshold (dot products, end point checks, contact checks) +static constexpr int MAX_FACE_SIZE = 4; // maximum number of vertices per face (same as BodyRoundedPolyhedron) +static constexpr int MAX_CONTACTS = 32; // for 3D models (including duplicated counts) //#define _POLYHEDRON_DEBUG diff --git a/src/BPM/atom_vec_bpm_sphere.cpp b/src/BPM/atom_vec_bpm_sphere.cpp index 2820a74c8a..4332d517b4 100644 --- a/src/BPM/atom_vec_bpm_sphere.cpp +++ b/src/BPM/atom_vec_bpm_sphere.cpp @@ -14,14 +14,11 @@ #include "atom_vec_bpm_sphere.h" #include "atom.h" -#include "comm.h" #include "error.h" #include "fix.h" #include "math_const.h" #include "modify.h" -#include - using namespace LAMMPS_NS; using MathConst::MY_PI; @@ -35,7 +32,6 @@ AtomVecBPMSphere::AtomVecBPMSphere(LAMMPS *_lmp) : AtomVec(_lmp) radvary = 0; atom->molecule_flag = 1; - atom->sphere_flag = 1; atom->radius_flag = atom->rmass_flag = atom->omega_flag = atom->torque_flag = atom->quat_flag = 1; // strings with peratom variables to include in each AtomVec method diff --git a/src/BPM/bond_bpm.cpp b/src/BPM/bond_bpm.cpp index b484df7fab..f1482d4203 100644 --- a/src/BPM/bond_bpm.cpp +++ b/src/BPM/bond_bpm.cpp @@ -357,7 +357,6 @@ void BondBPM::process_broken(int i, int j) if (i < nlocal) { for (m = 0; m < num_bond[i]; m++) { if (bond_atom[i][m] == tag[j]) { - bond_type[i][m] = 0; n = num_bond[i]; bond_type[i][m] = bond_type[i][n - 1]; bond_atom[i][m] = bond_atom[i][n - 1]; @@ -372,7 +371,6 @@ void BondBPM::process_broken(int i, int j) if (j < nlocal) { for (m = 0; m < num_bond[j]; m++) { if (bond_atom[j][m] == tag[i]) { - bond_type[j][m] = 0; n = num_bond[j]; bond_type[j][m] = bond_type[j][n - 1]; bond_atom[j][m] = bond_atom[j][n - 1]; diff --git a/src/BPM/bond_bpm_rotational.cpp b/src/BPM/bond_bpm_rotational.cpp index ffb0d9521d..f2bfa3d770 100644 --- a/src/BPM/bond_bpm_rotational.cpp +++ b/src/BPM/bond_bpm_rotational.cpp @@ -28,7 +28,7 @@ #include #include -#define EPSILON 1e-10 +static constexpr double EPSILON = 1e-10; using namespace LAMMPS_NS; using MathConst::MY_SQRT2; @@ -645,7 +645,7 @@ void BondBPMRotational::init_style() { BondBPM::init_style(); - if (!atom->quat_flag || !atom->sphere_flag) + if (!atom->quat_flag || !atom->radius_flag || !atom->omega_flag) error->all(FLERR, "Bond bpm/rotational requires atom style bpm/sphere"); if (comm->ghost_velocity == 0) error->all(FLERR, "Bond bpm/rotational requires ghost atoms store velocity"); diff --git a/src/BPM/bond_bpm_spring.cpp b/src/BPM/bond_bpm_spring.cpp index 37b79f93fb..28d17b408a 100644 --- a/src/BPM/bond_bpm_spring.cpp +++ b/src/BPM/bond_bpm_spring.cpp @@ -26,7 +26,7 @@ #include #include -#define EPSILON 1e-10 +static constexpr double EPSILON = 1e-10; using namespace LAMMPS_NS; diff --git a/src/BPM/fix_nve_bpm_sphere.cpp b/src/BPM/fix_nve_bpm_sphere.cpp index ceab07822e..1766f49c5c 100644 --- a/src/BPM/fix_nve_bpm_sphere.cpp +++ b/src/BPM/fix_nve_bpm_sphere.cpp @@ -28,7 +28,7 @@ using namespace MathExtra; FixNVEBPMSphere::FixNVEBPMSphere(LAMMPS *_lmp, int narg, char **arg) : FixNVE(_lmp, narg, arg) { - if (narg < 3) error->all(FLERR, "Illegal fix nve/bpm/sphere command"); + if (narg < 3) utils::missing_cmd_args(FLERR, "fix nve/bpm/sphere", error); time_integrate = 1; @@ -45,14 +45,14 @@ FixNVEBPMSphere::FixNVEBPMSphere(LAMMPS *_lmp, int narg, char **arg) : FixNVE(_l error->all(FLERR, "Fix nve/bpm/sphere disc requires 2d simulation"); iarg++; } else - error->all(FLERR, "Illegal fix nve/bpm/sphere command"); + error->all(FLERR, "Illegal fix nve/bpm/sphere keyword {}", arg[iarg]); } inv_inertia = 1.0 / inertia; // error checks - if (!atom->quat_flag || !atom->sphere_flag) + if (!atom->quat_flag || !atom->radius_flag || !atom->omega_flag) error->all(FLERR, "Fix nve/bpm/sphere requires atom style bpm/sphere"); } diff --git a/src/BPM/fix_update_special_bonds.cpp b/src/BPM/fix_update_special_bonds.cpp index b6bf8b433f..cdc72ee987 100644 --- a/src/BPM/fix_update_special_bonds.cpp +++ b/src/BPM/fix_update_special_bonds.cpp @@ -21,15 +21,12 @@ #include "modify.h" #include "neigh_list.h" #include "neighbor.h" -#include "pair.h" #include using namespace LAMMPS_NS; using namespace FixConst; -#define DELTA 10000 - /* ---------------------------------------------------------------------- */ FixUpdateSpecialBonds::FixUpdateSpecialBonds(LAMMPS *lmp, int narg, char **arg) : diff --git a/src/BROWNIAN/fix_brownian_base.cpp b/src/BROWNIAN/fix_brownian_base.cpp index b2e89a096a..508ce4d1c6 100644 --- a/src/BROWNIAN/fix_brownian_base.cpp +++ b/src/BROWNIAN/fix_brownian_base.cpp @@ -204,7 +204,7 @@ FixBrownianBase::~FixBrownianBase() delete[] gamma_r_invsqrt; } - if (dipole_flag) { delete[] dipole_body; } + if (dipole_flag) delete[] dipole_body; delete rng; } diff --git a/src/BROWNIAN/fix_brownian_sphere.cpp b/src/BROWNIAN/fix_brownian_sphere.cpp index 220a3b9735..79e3858f00 100644 --- a/src/BROWNIAN/fix_brownian_sphere.cpp +++ b/src/BROWNIAN/fix_brownian_sphere.cpp @@ -36,12 +36,11 @@ FixBrownianSphere::FixBrownianSphere(LAMMPS *lmp, int narg, char **arg) : FixBrownianBase(lmp, narg, arg) { if (gamma_t_eigen_flag || gamma_r_eigen_flag) { - error->all(FLERR, "Illegal fix brownian command."); + error->all(FLERR, "Illegal fix brownian/sphere command."); } - if (!gamma_t_flag || !gamma_r_flag) { error->all(FLERR, "Illegal fix brownian command."); } + if (!gamma_t_flag || !gamma_r_flag) error->all(FLERR, "Illegal fix brownian/sphere command."); if (!atom->mu_flag) error->all(FLERR, "Fix brownian/sphere requires atom attribute mu"); - if (!atom->sphere_flag) error->all(FLERR, "Fix brownian/sphere requires atom style sphere"); } /* ---------------------------------------------------------------------- */ diff --git a/src/BROWNIAN/fix_propel_self.cpp b/src/BROWNIAN/fix_propel_self.cpp index 8d97b828a9..e98f461b80 100644 --- a/src/BROWNIAN/fix_propel_self.cpp +++ b/src/BROWNIAN/fix_propel_self.cpp @@ -35,7 +35,7 @@ using namespace FixConst; enum { DIPOLE, VELOCITY, QUAT }; -#define TOL 1e-14 +static constexpr double TOL = 1e-14; /* ---------------------------------------------------------------------- */ diff --git a/src/CG-DNA/fix_nve_dot.cpp b/src/CG-DNA/fix_nve_dot.cpp index a9d288eb16..4fbf9bb9be 100644 --- a/src/CG-DNA/fix_nve_dot.cpp +++ b/src/CG-DNA/fix_nve_dot.cpp @@ -26,7 +26,7 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace MathExtra; -#define INERTIA 0.2 // moment of inertia prefactor for ellipsoid +static constexpr double INERTIA = 0.2; // moment of inertia prefactor for ellipsoid /* ---------------------------------------------------------------------- */ diff --git a/src/CG-DNA/fix_nve_dotc_langevin.cpp b/src/CG-DNA/fix_nve_dotc_langevin.cpp index 56436a3a98..8151cbe4fe 100644 --- a/src/CG-DNA/fix_nve_dotc_langevin.cpp +++ b/src/CG-DNA/fix_nve_dotc_langevin.cpp @@ -33,7 +33,7 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace MathExtra; -#define INERTIA 0.2 // moment of inertia prefactor for ellipsoid +static constexpr double INERTIA = 0.2; // moment of inertia prefactor for ellipsoid /* ---------------------------------------------------------------------- */ diff --git a/src/CG-DNA/pair_oxdna_stk.cpp b/src/CG-DNA/pair_oxdna_stk.cpp index 99ddf9c96a..1ef779dbd9 100644 --- a/src/CG-DNA/pair_oxdna_stk.cpp +++ b/src/CG-DNA/pair_oxdna_stk.cpp @@ -25,6 +25,7 @@ #include "memory.h" #include "mf_oxdna.h" #include "neighbor.h" +#include "neigh_list.h" #include #include diff --git a/src/CG-DNA/pair_oxrna2_stk.cpp b/src/CG-DNA/pair_oxrna2_stk.cpp index f6e12fffe1..f56aa572e8 100644 --- a/src/CG-DNA/pair_oxrna2_stk.cpp +++ b/src/CG-DNA/pair_oxrna2_stk.cpp @@ -26,6 +26,7 @@ #include "memory.h" #include "mf_oxdna.h" #include "neighbor.h" +#include "neigh_list.h" #include #include diff --git a/src/CG-SPICA/angle_spica.cpp b/src/CG-SPICA/angle_spica.cpp index 3f8a506ed2..45b28d812a 100644 --- a/src/CG-SPICA/angle_spica.cpp +++ b/src/CG-SPICA/angle_spica.cpp @@ -39,7 +39,7 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace LJSPICAParms; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/CG-SPICA/pair_lj_spica_coul_long.cpp b/src/CG-SPICA/pair_lj_spica_coul_long.cpp index 8b655ea911..9e0d4dc276 100644 --- a/src/CG-SPICA/pair_lj_spica_coul_long.cpp +++ b/src/CG-SPICA/pair_lj_spica_coul_long.cpp @@ -21,6 +21,7 @@ #include "atom.h" #include "comm.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "kspace.h" #include "memory.h" @@ -35,14 +36,7 @@ using namespace LAMMPS_NS; using namespace LJSPICAParms; - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/CLASS2/angle_class2.cpp b/src/CLASS2/angle_class2.cpp index c731a4d5c9..1dbaaf0568 100644 --- a/src/CLASS2/angle_class2.cpp +++ b/src/CLASS2/angle_class2.cpp @@ -33,7 +33,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/CLASS2/dihedral_class2.cpp b/src/CLASS2/dihedral_class2.cpp index d49d50f0e6..288fac2e92 100644 --- a/src/CLASS2/dihedral_class2.cpp +++ b/src/CLASS2/dihedral_class2.cpp @@ -32,8 +32,8 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define TOLERANCE 0.05 -#define SMALL 0.0000001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.0000001; /* ---------------------------------------------------------------------- */ diff --git a/src/CLASS2/improper_class2.cpp b/src/CLASS2/improper_class2.cpp index 1e172757b0..73f21600bb 100644 --- a/src/CLASS2/improper_class2.cpp +++ b/src/CLASS2/improper_class2.cpp @@ -32,8 +32,6 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.001 - /* ---------------------------------------------------------------------- */ ImproperClass2::ImproperClass2(LAMMPS *lmp) : Improper(lmp) diff --git a/src/CLASS2/pair_lj_class2_coul_long.cpp b/src/CLASS2/pair_lj_class2_coul_long.cpp index 2a3d7a706e..965810c8f7 100644 --- a/src/CLASS2/pair_lj_class2_coul_long.cpp +++ b/src/CLASS2/pair_lj_class2_coul_long.cpp @@ -16,6 +16,7 @@ #include "atom.h" #include "comm.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "kspace.h" #include "math_const.h" @@ -29,16 +30,9 @@ #include using namespace LAMMPS_NS; +using namespace EwaldConst; using namespace MathConst; -static constexpr double EWALD_F = 1.12837917; -static constexpr double EWALD_P = 0.3275911; -static constexpr double A1 = 0.254829592; -static constexpr double A2 = -0.284496736; -static constexpr double A3 = 1.421413741; -static constexpr double A4 = -1.453152027; -static constexpr double A5 = 1.061405429; - /* ---------------------------------------------------------------------- */ PairLJClass2CoulLong::PairLJClass2CoulLong(LAMMPS *lmp) : Pair(lmp) diff --git a/src/COLLOID/fix_wall_colloid.cpp b/src/COLLOID/fix_wall_colloid.cpp index 0637057417..75dc5c797f 100644 --- a/src/COLLOID/fix_wall_colloid.cpp +++ b/src/COLLOID/fix_wall_colloid.cpp @@ -34,7 +34,7 @@ FixWallColloid::FixWallColloid(LAMMPS *lmp, int narg, char **arg) : FixWall(lmp, void FixWallColloid::init() { - if (!atom->sphere_flag) error->all(FLERR, "Fix wall/colloid requires atom style sphere"); + if (!atom->radius_flag) error->all(FLERR, "Fix wall/colloid requires atom attribute radius"); // ensure all particles in group are extended particles diff --git a/src/COLLOID/pair_brownian.cpp b/src/COLLOID/pair_brownian.cpp index 82be043df0..39432ca61b 100644 --- a/src/COLLOID/pair_brownian.cpp +++ b/src/COLLOID/pair_brownian.cpp @@ -42,10 +42,6 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -// same as fix_wall.cpp - -enum { EDGE, CONSTANT, VARIABLE }; - /* ---------------------------------------------------------------------- */ PairBrownian::PairBrownian(LAMMPS *lmp) : Pair(lmp) @@ -110,7 +106,7 @@ void PairBrownian::compute(int eflag, int vflag) for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -439,7 +435,7 @@ void PairBrownian::coeff(int narg, char **arg) void PairBrownian::init_style() { - if (!atom->sphere_flag) error->all(FLERR, "Pair brownian requires atom style sphere"); + if (!atom->radius_flag) error->all(FLERR, "Pair brownian requires atom attribute radius"); // if newton off, forces between atoms ij will be double computed // using different random numbers @@ -506,7 +502,7 @@ void PairBrownian::init_style() for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallfix->xindex[m] = input->variable->find(wallfix->xstr[m]); // Since fix->wall->init happens after pair->init_style wallcoord = input->variable->compute_equal(wallfix->xindex[m]); diff --git a/src/COLLOID/pair_brownian_poly.cpp b/src/COLLOID/pair_brownian_poly.cpp index 1e04b8dc2a..99cebe3792 100644 --- a/src/COLLOID/pair_brownian_poly.cpp +++ b/src/COLLOID/pair_brownian_poly.cpp @@ -42,10 +42,6 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -// same as fix_wall.cpp - -enum{EDGE,CONSTANT,VARIABLE}; - /* ---------------------------------------------------------------------- */ PairBrownianPoly::PairBrownianPoly(LAMMPS *lmp) : PairBrownian(lmp) @@ -95,7 +91,7 @@ void PairBrownianPoly::compute(int eflag, int vflag) for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -322,8 +318,8 @@ void PairBrownianPoly::init_style() { if (force->newton_pair == 1) error->all(FLERR,"Pair brownian/poly requires newton pair off"); - if (!atom->sphere_flag) - error->all(FLERR,"Pair brownian/poly requires atom style sphere"); + if (!atom->radius_flag) + error->all(FLERR,"Pair brownian/poly requires atom attribute radius"); // ensure all particles are finite-size // for pair hybrid, should limit test to types using the pair style @@ -376,7 +372,7 @@ void PairBrownianPoly::init_style() for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallfix->xindex[m] = input->variable->find(wallfix->xstr[m]); // Since fix->wall->init happens after pair->init_style wallcoord = input->variable->compute_equal(wallfix->xindex[m]); diff --git a/src/COLLOID/pair_lubricate.cpp b/src/COLLOID/pair_lubricate.cpp index 6f07d63bfb..99a544cd7f 100644 --- a/src/COLLOID/pair_lubricate.cpp +++ b/src/COLLOID/pair_lubricate.cpp @@ -41,10 +41,6 @@ using namespace LAMMPS_NS; using namespace MathConst; -// same as fix_wall.cpp - -enum{NONE=0,EDGE,CONSTANT,VARIABLE}; - /* ---------------------------------------------------------------------- */ PairLubricate::PairLubricate(LAMMPS *lmp) : Pair(lmp) @@ -169,7 +165,7 @@ void PairLubricate::compute(int eflag, int vflag) for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -531,8 +527,10 @@ void PairLubricate::coeff(int narg, char **arg) void PairLubricate::init_style() { - if (!atom->sphere_flag) - error->all(FLERR,"Pair lubricate requires atom style sphere"); + if (!atom->omega_flag) + error->all(FLERR,"Pair lubricate requires atom attribute omega"); + if (!atom->radius_flag) + error->all(FLERR,"Pair lubricate requires atom attribute radius"); if (comm->ghost_velocity == 0) error->all(FLERR,"Pair lubricate requires ghost atoms store velocity"); @@ -593,7 +591,7 @@ void PairLubricate::init_style() for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallfix->xindex[m] = input->variable->find(wallfix->xstr[m]); //Since fix->wall->init happens after pair->init_style wallcoord = input->variable->compute_equal(wallfix->xindex[m]); diff --git a/src/COLLOID/pair_lubricateU.cpp b/src/COLLOID/pair_lubricateU.cpp index ac1e62c2a2..f97a5b34c7 100644 --- a/src/COLLOID/pair_lubricateU.cpp +++ b/src/COLLOID/pair_lubricateU.cpp @@ -40,11 +40,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define TOL 1E-4 // tolerance for conjugate gradient - -// same as fix_wall.cpp - -enum{EDGE,CONSTANT,VARIABLE}; +static constexpr double TOL = 1e-4; // tolerance for conjugate gradient /* ---------------------------------------------------------------------- */ @@ -595,7 +591,7 @@ void PairLubricateU::compute_Fh(double **x) for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -827,7 +823,7 @@ void PairLubricateU::compute_RU() for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -1098,7 +1094,7 @@ void PairLubricateU::compute_RU(double **x) for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -1764,8 +1760,10 @@ void PairLubricateU::coeff(int narg, char **arg) void PairLubricateU::init_style() { - if (!atom->sphere_flag) - error->all(FLERR,"Pair lubricateU requires atom style sphere"); + if (!atom->omega_flag) + error->all(FLERR,"Pair lubricateU requires atom attribute omega"); + if (!atom->radius_flag) + error->all(FLERR,"Pair lubricateU requires atom attribute radius"); if (comm->ghost_velocity == 0) error->all(FLERR,"Pair lubricateU requires ghost atoms store velocity"); @@ -1819,7 +1817,7 @@ void PairLubricateU::init_style() for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallfix->xindex[m] = input->variable->find(wallfix->xstr[m]); //Since fix->wall->init happens after pair->init_style wallcoord = input->variable->compute_equal(wallfix->xindex[m]); diff --git a/src/COLLOID/pair_lubricateU_poly.cpp b/src/COLLOID/pair_lubricateU_poly.cpp index 297c4e1924..cc98656524 100644 --- a/src/COLLOID/pair_lubricateU_poly.cpp +++ b/src/COLLOID/pair_lubricateU_poly.cpp @@ -41,12 +41,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define TOL 1E-3 // tolerance for conjugate gradient - -// same as fix_wall.cpp - -enum{EDGE,CONSTANT,VARIABLE}; - +static constexpr double TOL = 1e-3; // tolerance for conjugate gradient /* ---------------------------------------------------------------------- */ @@ -365,7 +360,7 @@ void PairLubricateUPoly::compute_Fh(double **x) for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -640,7 +635,7 @@ void PairLubricateUPoly::compute_RU(double **x) for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -1126,12 +1121,13 @@ void PairLubricateUPoly::settings(int narg, char **arg) void PairLubricateUPoly::init_style() { if (force->newton_pair == 1) - error->all(FLERR,"Pair lubricateU/poly requires newton pair off"); + error->all(FLERR, "Pair lubricateU/poly requires newton pair off"); if (comm->ghost_velocity == 0) - error->all(FLERR, - "Pair lubricateU/poly requires ghost atoms store velocity"); - if (!atom->sphere_flag) - error->all(FLERR,"Pair lubricate/poly requires atom style sphere"); + error->all(FLERR, "Pair lubricateU/poly requires ghost atoms store velocity"); + if (!atom->omega_flag) + error->all(FLERR, "Pair lubricateU/poly requires atom attribute omega"); + if (!atom->radius_flag) + error->all(FLERR, "Pair lubricateU/poly requires atom attribute radius"); // ensure all particles are finite-size // for pair hybrid, should limit test to types using the pair style @@ -1141,7 +1137,7 @@ void PairLubricateUPoly::init_style() for (int i = 0; i < nlocal; i++) if (radius[i] == 0.0) - error->one(FLERR,"Pair lubricate/poly requires extended particles"); + error->one(FLERR,"Pair lubricateU/poly requires extended particles"); // Set the isotropic constants depending on the volume fraction @@ -1161,9 +1157,7 @@ void PairLubricateUPoly::init_style() flagdeform = 1; else if (strstr(modify->fix[i]->style,"wall") != nullptr) { if (flagwall) - error->all(FLERR, - "Cannot use multiple fix wall commands with " - "pair lubricateU"); + error->all(FLERR, "Cannot use multiple fix wall commands with pair lubricateU/poly"); flagwall = 1; // Walls exist wallfix = dynamic_cast(modify->fix[i]); if (wallfix->xflag) flagwall = 2; // Moving walls exist @@ -1184,7 +1178,7 @@ void PairLubricateUPoly::init_style() for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallfix->xindex[m] = input->variable->find(wallfix->xstr[m]); //Since fix->wall->init happens after pair->init_style wallcoord = input->variable->compute_equal(wallfix->xindex[m]); @@ -1214,14 +1208,8 @@ void PairLubricateUPoly::init_style() if (!flagVF) vol_f = 0; - if (!comm->me) { - if (logfile) - fprintf(logfile, "lubricateU: vol_f = %g, vol_p = %g, vol_T = %g\n", - vol_f,vol_P,vol_T); - if (screen) - fprintf(screen, "lubricateU: vol_f = %g, vol_p = %g, vol_T = %g\n", - vol_f,vol_P,vol_T); - } + if (comm->me == 0) + utils::logmesg(lmp, "lubricateU: vol_f = {}, vol_p = {}, vol_T = {}\n", vol_f, vol_P, vol_T); // Set the isotropic constant diff --git a/src/COLLOID/pair_lubricate_poly.cpp b/src/COLLOID/pair_lubricate_poly.cpp index e6a0606e87..33f32f3ad2 100644 --- a/src/COLLOID/pair_lubricate_poly.cpp +++ b/src/COLLOID/pair_lubricate_poly.cpp @@ -41,10 +41,6 @@ using namespace LAMMPS_NS; using namespace MathConst; -// same as fix_wall.cpp - -enum{EDGE,CONSTANT,VARIABLE}; - /* ---------------------------------------------------------------------- */ PairLubricatePoly::PairLubricatePoly(LAMMPS *lmp) : PairLubricate(lmp) @@ -151,7 +147,7 @@ void PairLubricatePoly::compute(int eflag, int vflag) for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -428,12 +424,13 @@ void PairLubricatePoly::compute(int eflag, int vflag) void PairLubricatePoly::init_style() { if (force->newton_pair == 1) - error->all(FLERR,"Pair lubricate/poly requires newton pair off"); + error->all(FLERR, "Pair lubricate/poly requires newton pair off"); if (comm->ghost_velocity == 0) - error->all(FLERR, - "Pair lubricate/poly requires ghost atoms store velocity"); - if (!atom->sphere_flag) - error->all(FLERR,"Pair lubricate/poly requires atom style sphere"); + error->all(FLERR, "Pair lubricate/poly requires ghost atoms store velocity"); + if (!atom->omega_flag) + error->all(FLERR, "Pair lubricate/poly requires atom attribute omega"); + if (!atom->radius_flag) + error->all(FLERR, "Pair lubricate/poly requires atom attribute radius"); // ensure all particles are finite-size // for pair hybrid, should limit test to types using the pair style @@ -443,7 +440,7 @@ void PairLubricatePoly::init_style() for (int i = 0; i < nlocal; i++) if (radius[i] == 0.0) - error->one(FLERR,"Pair lubricate/poly requires extended particles"); + error->one(FLERR,"Pair lubricate/poly requires only extended particles"); neighbor->add_request(this, NeighConst::REQ_FULL); @@ -498,7 +495,7 @@ void PairLubricatePoly::init_style() for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallfix->xindex[m] = input->variable->find(wallfix->xstr[m]); //Since fix->wall->init happens after pair->init_style wallcoord = input->variable->compute_equal(wallfix->xindex[m]); diff --git a/src/COLLOID/pair_yukawa_colloid.cpp b/src/COLLOID/pair_yukawa_colloid.cpp index ad63292e33..37bd4dfd99 100644 --- a/src/COLLOID/pair_yukawa_colloid.cpp +++ b/src/COLLOID/pair_yukawa_colloid.cpp @@ -121,8 +121,8 @@ void PairYukawaColloid::compute(int eflag, int vflag) void PairYukawaColloid::init_style() { - if (!atom->sphere_flag) - error->all(FLERR,"Pair yukawa/colloid requires atom style sphere"); + if (!atom->radius_flag) + error->all(FLERR,"Pair yukawa/colloid requires atom attribute radius"); neighbor->add_request(this); diff --git a/src/COLVARS/colvarproxy_lammps.cpp b/src/COLVARS/colvarproxy_lammps.cpp index 06a2a23ec0..1c5d84d62a 100644 --- a/src/COLVARS/colvarproxy_lammps.cpp +++ b/src/COLVARS/colvarproxy_lammps.cpp @@ -19,11 +19,7 @@ #include "colvarmodule.h" #include "colvarproxy.h" -#include -#include -#include -#include -#include +#include #define HASH_FAIL -1 diff --git a/src/COLVARS/fix_colvars.cpp b/src/COLVARS/fix_colvars.cpp index baf0209c61..0b496ee71b 100644 --- a/src/COLVARS/fix_colvars.cpp +++ b/src/COLVARS/fix_colvars.cpp @@ -40,8 +40,6 @@ #include #include -#include -#include #include "colvarproxy_lammps.h" #include "colvarmodule.h" diff --git a/src/COLVARS/ndx_group.cpp b/src/COLVARS/ndx_group.cpp index 1d24db3900..4170a9ea70 100644 --- a/src/COLVARS/ndx_group.cpp +++ b/src/COLVARS/ndx_group.cpp @@ -26,8 +26,7 @@ #include "tokenizer.h" using namespace LAMMPS_NS; -#define BUFLEN 4096 -#define DELTA 16384 +static constexpr int BUFLEN = 4096; // read file until next section "name" or any next section if name == "" diff --git a/src/COMPRESS/dump_cfg_gz.cpp b/src/COMPRESS/dump_cfg_gz.cpp index 259056c013..e4d5ae76cc 100644 --- a/src/COMPRESS/dump_cfg_gz.cpp +++ b/src/COMPRESS/dump_cfg_gz.cpp @@ -22,7 +22,7 @@ #include using namespace LAMMPS_NS; -#define UNWRAPEXPAND 10.0 +static constexpr double UNWRAPEXPAND = 10.0; DumpCFGGZ::DumpCFGGZ(LAMMPS *lmp, int narg, char **arg) : DumpCFG(lmp, narg, arg) { diff --git a/src/COMPRESS/dump_cfg_zstd.cpp b/src/COMPRESS/dump_cfg_zstd.cpp index e3f9a7c1f9..c52f9e0942 100644 --- a/src/COMPRESS/dump_cfg_zstd.cpp +++ b/src/COMPRESS/dump_cfg_zstd.cpp @@ -28,7 +28,7 @@ #include using namespace LAMMPS_NS; -#define UNWRAPEXPAND 10.0 +static constexpr double UNWRAPEXPAND = 10.0; DumpCFGZstd::DumpCFGZstd(LAMMPS *lmp, int narg, char **arg) : DumpCFG(lmp, narg, arg) { diff --git a/src/CORESHELL/pair_born_coul_dsf_cs.cpp b/src/CORESHELL/pair_born_coul_dsf_cs.cpp index 9e0ac11c78..9edcf2755d 100644 --- a/src/CORESHELL/pair_born_coul_dsf_cs.cpp +++ b/src/CORESHELL/pair_born_coul_dsf_cs.cpp @@ -30,7 +30,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define EPSILON 1.0e-20 +static constexpr double EPSILON = 1.0e-20; /* ---------------------------------------------------------------------- */ diff --git a/src/CORESHELL/pair_born_coul_long_cs.cpp b/src/CORESHELL/pair_born_coul_long_cs.cpp index 3a3dc39d69..3e13577879 100644 --- a/src/CORESHELL/pair_born_coul_long_cs.cpp +++ b/src/CORESHELL/pair_born_coul_long_cs.cpp @@ -17,25 +17,27 @@ ------------------------------------------------------------------------- */ #include "pair_born_coul_long_cs.h" -#include + #include "atom.h" #include "force.h" #include "neigh_list.h" +#include + using namespace LAMMPS_NS; -#define EWALD_F 1.12837917 -#define EWALD_P 9.95473818e-1 -#define B0 -0.1335096380159268 -#define B1 -2.57839507e-1 -#define B2 -1.37203639e-1 -#define B3 -8.88822059e-3 -#define B4 -5.80844129e-3 -#define B5 1.14652755e-1 +static constexpr double EWALD_F = 1.12837917; +static constexpr double EWALD_P = 9.95473818e-1; +static constexpr double B0 = -0.1335096380159268; +static constexpr double B1 = -2.57839507e-1; +static constexpr double B2 = -1.37203639e-1; +static constexpr double B3 = -8.88822059e-3; +static constexpr double B4 = -5.80844129e-3; +static constexpr double B5 = 1.14652755e-1; -#define EPSILON 1.0e-20 -#define EPS_EWALD 1.0e-6 -#define EPS_EWALD_SQR 1.0e-12 +static constexpr double EPSILON = 1.0e-20; +static constexpr double EPS_EWALD = 1.0e-6; +static constexpr double EPS_EWALD_SQR = 1.0e-12; /* ---------------------------------------------------------------------- */ diff --git a/src/CORESHELL/pair_born_coul_wolf_cs.cpp b/src/CORESHELL/pair_born_coul_wolf_cs.cpp index 4765e1575c..47241c0beb 100644 --- a/src/CORESHELL/pair_born_coul_wolf_cs.cpp +++ b/src/CORESHELL/pair_born_coul_wolf_cs.cpp @@ -25,7 +25,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define EPSILON 1.0e-20 +static constexpr double EPSILON = 1.0e-20; /* ---------------------------------------------------------------------- */ diff --git a/src/CORESHELL/pair_buck_coul_long_cs.cpp b/src/CORESHELL/pair_buck_coul_long_cs.cpp index 6b15e8dfe5..f885b412d8 100644 --- a/src/CORESHELL/pair_buck_coul_long_cs.cpp +++ b/src/CORESHELL/pair_buck_coul_long_cs.cpp @@ -24,18 +24,18 @@ using namespace LAMMPS_NS; -#define EWALD_F 1.12837917 -#define EWALD_P 9.95473818e-1 -#define B0 -0.1335096380159268 -#define B1 -2.57839507e-1 -#define B2 -1.37203639e-1 -#define B3 -8.88822059e-3 -#define B4 -5.80844129e-3 -#define B5 1.14652755e-1 +static constexpr double EWALD_F = 1.12837917; +static constexpr double EWALD_P = 9.95473818e-1; +static constexpr double B0 = -0.1335096380159268; +static constexpr double B1 = -2.57839507e-1; +static constexpr double B2 = -1.37203639e-1; +static constexpr double B3 = -8.88822059e-3; +static constexpr double B4 = -5.80844129e-3; +static constexpr double B5 = 1.14652755e-1; -#define EPSILON 1.0e-20 -#define EPS_EWALD 1.0e-6 -#define EPS_EWALD_SQR 1.0e-12 +static constexpr double EPSILON = 1.0e-20; +static constexpr double EPS_EWALD = 1.0e-6; +static constexpr double EPS_EWALD_SQR = 1.0e-12; /* ---------------------------------------------------------------------- */ diff --git a/src/CORESHELL/pair_coul_long_cs.cpp b/src/CORESHELL/pair_coul_long_cs.cpp index 5148ffda2d..156fef7e03 100644 --- a/src/CORESHELL/pair_coul_long_cs.cpp +++ b/src/CORESHELL/pair_coul_long_cs.cpp @@ -24,18 +24,18 @@ using namespace LAMMPS_NS; -#define EWALD_F 1.12837917 -#define EWALD_P 9.95473818e-1 -#define B0 -0.1335096380159268 -#define B1 -2.57839507e-1 -#define B2 -1.37203639e-1 -#define B3 -8.88822059e-3 -#define B4 -5.80844129e-3 -#define B5 1.14652755e-1 +static constexpr double EWALD_F = 1.12837917; +static constexpr double EWALD_P = 9.95473818e-1; +static constexpr double B0 = -0.1335096380159268; +static constexpr double B1 = -2.57839507e-1; +static constexpr double B2 = -1.37203639e-1; +static constexpr double B3 = -8.88822059e-3; +static constexpr double B4 = -5.80844129e-3; +static constexpr double B5 = 1.14652755e-1; -#define EPSILON 1.0e-20 -#define EPS_EWALD 1.0e-6 -#define EPS_EWALD_SQR 1.0e-12 +static constexpr double EPSILON = 1.0e-20; +static constexpr double EPS_EWALD = 1.0e-6; +static constexpr double EPS_EWALD_SQR = 1.0e-12; /* ---------------------------------------------------------------------- */ diff --git a/src/CORESHELL/pair_coul_wolf_cs.cpp b/src/CORESHELL/pair_coul_wolf_cs.cpp index 5e15493aad..6deb66735b 100644 --- a/src/CORESHELL/pair_coul_wolf_cs.cpp +++ b/src/CORESHELL/pair_coul_wolf_cs.cpp @@ -24,7 +24,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define EPSILON 1.0e-20 +static constexpr double EPSILON = 1.0e-20; /* ---------------------------------------------------------------------- */ diff --git a/src/CORESHELL/pair_lj_class2_coul_long_cs.cpp b/src/CORESHELL/pair_lj_class2_coul_long_cs.cpp index 1cbddf0614..48141b40a1 100644 --- a/src/CORESHELL/pair_lj_class2_coul_long_cs.cpp +++ b/src/CORESHELL/pair_lj_class2_coul_long_cs.cpp @@ -20,18 +20,18 @@ using namespace LAMMPS_NS; -#define EWALD_F 1.12837917 -#define EWALD_P 9.95473818e-1 -#define B0 -0.1335096380159268 -#define B1 -2.57839507e-1 -#define B2 -1.37203639e-1 -#define B3 -8.88822059e-3 -#define B4 -5.80844129e-3 -#define B5 1.14652755e-1 +static constexpr double EWALD_F = 1.12837917; +static constexpr double EWALD_P = 9.95473818e-1; +static constexpr double B0 = -0.1335096380159268; +static constexpr double B1 = -2.57839507e-1; +static constexpr double B2 = -1.37203639e-1; +static constexpr double B3 = -8.88822059e-3; +static constexpr double B4 = -5.80844129e-3; +static constexpr double B5 = 1.14652755e-1; -#define EPSILON 1.0e-20 -#define EPS_EWALD 1.0e-6 -#define EPS_EWALD_SQR 1.0e-12 +static constexpr double EPSILON = 1.0e-20; +static constexpr double EPS_EWALD = 1.0e-6; +static constexpr double EPS_EWALD_SQR = 1.0e-12; /* ---------------------------------------------------------------------- */ diff --git a/src/CORESHELL/pair_lj_cut_coul_long_cs.cpp b/src/CORESHELL/pair_lj_cut_coul_long_cs.cpp index 253ae440b0..ddb6d57837 100644 --- a/src/CORESHELL/pair_lj_cut_coul_long_cs.cpp +++ b/src/CORESHELL/pair_lj_cut_coul_long_cs.cpp @@ -24,18 +24,18 @@ using namespace LAMMPS_NS; -#define EWALD_F 1.12837917 -#define EWALD_P 9.95473818e-1 -#define B0 -0.1335096380159268 -#define B1 -2.57839507e-1 -#define B2 -1.37203639e-1 -#define B3 -8.88822059e-3 -#define B4 -5.80844129e-3 -#define B5 1.14652755e-1 +static constexpr double EWALD_F = 1.12837917; +static constexpr double EWALD_P = 9.95473818e-1; +static constexpr double B0 = -0.1335096380159268; +static constexpr double B1 = -2.57839507e-1; +static constexpr double B2 = -1.37203639e-1; +static constexpr double B3 = -8.88822059e-3; +static constexpr double B4 = -5.80844129e-3; +static constexpr double B5 = 1.14652755e-1; -#define EPSILON 1.0e-20 -#define EPS_EWALD 1.0e-6 -#define EPS_EWALD_SQR 1.0e-12 +static constexpr double EPSILON = 1.0e-20; +static constexpr double EPS_EWALD = 1.0e-6; +static constexpr double EPS_EWALD_SQR = 1.0e-12; /* ---------------------------------------------------------------------- */ diff --git a/src/DIELECTRIC/fix_polarize_bem_gmres.cpp b/src/DIELECTRIC/fix_polarize_bem_gmres.cpp index 40f7d0c853..67d79d57f0 100644 --- a/src/DIELECTRIC/fix_polarize_bem_gmres.cpp +++ b/src/DIELECTRIC/fix_polarize_bem_gmres.cpp @@ -41,7 +41,6 @@ #include "comm.h" #include "error.h" #include "force.h" -#include "group.h" #include "kspace.h" #include "math_const.h" #include "memory.h" diff --git a/src/DIELECTRIC/pppm_dielectric.cpp b/src/DIELECTRIC/pppm_dielectric.cpp index e308cb0826..e02cc33162 100644 --- a/src/DIELECTRIC/pppm_dielectric.cpp +++ b/src/DIELECTRIC/pppm_dielectric.cpp @@ -23,7 +23,6 @@ #include "comm.h" #include "domain.h" #include "error.h" -#include "fft3d_wrap.h" #include "force.h" #include "grid3d.h" #include "math_const.h" @@ -36,18 +35,12 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define SMALL 0.00001 +static constexpr double SMALL = 0.00001; -enum {REVERSE_RHO}; -enum {FORWARD_IK,FORWARD_AD,FORWARD_IK_PERATOM,FORWARD_AD_PERATOM}; +enum { REVERSE_RHO }; +enum { FORWARD_IK, FORWARD_AD, FORWARD_IK_PERATOM, FORWARD_AD_PERATOM }; -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#define ONEF 1.0f -#else -#define ZEROF 0.0 -#define ONEF 1.0 -#endif +static constexpr FFT_SCALAR ZEROF = 0.0; /* ---------------------------------------------------------------------- */ diff --git a/src/DIELECTRIC/pppm_disp_dielectric.cpp b/src/DIELECTRIC/pppm_disp_dielectric.cpp index 2c4de6ada1..e5149ae427 100644 --- a/src/DIELECTRIC/pppm_disp_dielectric.cpp +++ b/src/DIELECTRIC/pppm_disp_dielectric.cpp @@ -25,19 +25,18 @@ #include "error.h" #include "force.h" #include "grid3d.h" +#include "lmpfftsettings.h" #include "math_const.h" #include "memory.h" #include +#include using namespace LAMMPS_NS; using namespace MathConst; -#define MAXORDER 7 -#define OFFSET 16384 -#define SMALL 0.00001 -#define LARGE 10000.0 -#define EPS_HOC 1.0e-7 +static constexpr double SMALL = 0.00001; +static constexpr FFT_SCALAR ZEROF = 0.0; enum{REVERSE_RHO,REVERSE_RHO_GEOM,REVERSE_RHO_ARITH,REVERSE_RHO_NONE}; enum{FORWARD_IK,FORWARD_AD,FORWARD_IK_PERATOM,FORWARD_AD_PERATOM, @@ -48,14 +47,6 @@ enum{FORWARD_IK,FORWARD_AD,FORWARD_IK_PERATOM,FORWARD_AD_PERATOM, FORWARD_IK_NONE,FORWARD_AD_NONE,FORWARD_IK_PERATOM_NONE, FORWARD_AD_PERATOM_NONE}; -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#define ONEF 1.0f -#else -#define ZEROF 0.0 -#define ONEF 1.0 -#endif - /* ---------------------------------------------------------------------- */ PPPMDispDielectric::PPPMDispDielectric(LAMMPS *_lmp) : PPPMDisp(_lmp) diff --git a/src/DIFFRACTION/compute_xrd.cpp b/src/DIFFRACTION/compute_xrd.cpp index 426248b31e..11e0bb9a9f 100644 --- a/src/DIFFRACTION/compute_xrd.cpp +++ b/src/DIFFRACTION/compute_xrd.cpp @@ -35,7 +35,7 @@ #include "omp_compat.h" using namespace LAMMPS_NS; -using namespace MathConst; +using MathConst::MY_PI; static const char cite_compute_xrd_c[] = "compute xrd command: doi:10.1088/0965-0393/21/5/055020\n\n" @@ -261,7 +261,7 @@ void ComputeXRD::init() double ang = 0.0; double convf = 360 / MY_PI; - if (radflag ==1) convf = 1; + if (radflag == 1) convf = 2; int n = 0; for (int m = 0; m < mmax; m++) { diff --git a/src/DIPOLE/pair_lj_cut_dipole_long.cpp b/src/DIPOLE/pair_lj_cut_dipole_long.cpp index 0522a7a34d..5d71842d54 100644 --- a/src/DIPOLE/pair_lj_cut_dipole_long.cpp +++ b/src/DIPOLE/pair_lj_cut_dipole_long.cpp @@ -17,6 +17,7 @@ #include "atom.h" #include "comm.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "kspace.h" #include "math_const.h" @@ -30,14 +31,7 @@ using namespace LAMMPS_NS; using namespace MathConst; - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/DIPOLE/pair_lj_long_dipole_long.cpp b/src/DIPOLE/pair_lj_long_dipole_long.cpp index 1ed4a8c8d7..2e1a9c4db0 100644 --- a/src/DIPOLE/pair_lj_long_dipole_long.cpp +++ b/src/DIPOLE/pair_lj_long_dipole_long.cpp @@ -21,6 +21,7 @@ #include "atom.h" #include "comm.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "kspace.h" #include "math_const.h" @@ -36,14 +37,7 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathExtra; - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; // ---------------------------------------------------------------------- @@ -407,7 +401,7 @@ void PairLJLongDipoleLong::compute(int eflag, int vflag) ev_init(eflag,vflag); double **x = atom->x, *x0 = x[0]; - double **mu = atom->mu, *mu0 = mu[0], *imu, *jmu; + double **mu = atom->mu, *mu0 = mu[0]; double **tq = atom->torque, *tq0 = tq[0], *tqi; double **f = atom->f, *f0 = f[0], *fi = f0, fx, fy, fz; double *q = atom->q, qi = 0, qj; @@ -441,7 +435,7 @@ void PairLJLongDipoleLong::compute(int eflag, int vflag) lj1i = lj1[typei]; lj2i = lj2[typei]; lj3i = lj3[typei]; lj4i = lj4[typei]; cutsqi = cutsq[typei]; cut_ljsqi = cut_ljsq[typei]; memcpy(xi, x0+(i+(i<<1)), 3*sizeof(double)); - memcpy(mui, imu = mu0+(i<<2), 3*sizeof(double)); + memcpy(mui, mu0+(i<<2), 3*sizeof(double)); jneighn = (jneigh = list->firstneigh[i])+list->numneigh[i]; @@ -459,7 +453,7 @@ void PairLJLongDipoleLong::compute(int eflag, int vflag) r2inv = 1.0/rsq; if (order3 && (rsq < cut_coulsq)) { // dipole - memcpy(muj, jmu = mu0+(j<<2), 3*sizeof(double)); + memcpy(muj, mu0+(j<<2), 3*sizeof(double)); { // series real space double r = sqrt(rsq); double x = g_ewald*r; diff --git a/src/DPD-BASIC/pair_dpd.cpp b/src/DPD-BASIC/pair_dpd.cpp index 5771831e02..1f60074280 100644 --- a/src/DPD-BASIC/pair_dpd.cpp +++ b/src/DPD-BASIC/pair_dpd.cpp @@ -32,7 +32,7 @@ using namespace LAMMPS_NS; -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; /* ---------------------------------------------------------------------- */ diff --git a/src/DPD-BASIC/pair_dpd_ext.cpp b/src/DPD-BASIC/pair_dpd_ext.cpp index 623b16774c..da08e53a4a 100644 --- a/src/DPD-BASIC/pair_dpd_ext.cpp +++ b/src/DPD-BASIC/pair_dpd_ext.cpp @@ -33,7 +33,7 @@ using namespace LAMMPS_NS; -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; /* ---------------------------------------------------------------------- */ diff --git a/src/DPD-BASIC/pair_dpd_ext_tstat.cpp b/src/DPD-BASIC/pair_dpd_ext_tstat.cpp index 433bc54063..fe881d7bc5 100644 --- a/src/DPD-BASIC/pair_dpd_ext_tstat.cpp +++ b/src/DPD-BASIC/pair_dpd_ext_tstat.cpp @@ -30,7 +30,7 @@ using namespace LAMMPS_NS; -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; /* ---------------------------------------------------------------------- */ diff --git a/src/DPD-BASIC/pair_dpd_tstat.cpp b/src/DPD-BASIC/pair_dpd_tstat.cpp index ed659e7cc3..108177ed69 100644 --- a/src/DPD-BASIC/pair_dpd_tstat.cpp +++ b/src/DPD-BASIC/pair_dpd_tstat.cpp @@ -26,7 +26,7 @@ using namespace LAMMPS_NS; -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; /* ---------------------------------------------------------------------- */ diff --git a/src/DPD-MESO/pair_edpd.cpp b/src/DPD-MESO/pair_edpd.cpp index ed99a5eac1..b575956f71 100644 --- a/src/DPD-MESO/pair_edpd.cpp +++ b/src/DPD-MESO/pair_edpd.cpp @@ -38,7 +38,7 @@ using namespace LAMMPS_NS; #define MIN(A,B) ((A) < (B) ? (A) : (B)) #define MAX(A,B) ((A) > (B) ? (A) : (B)) -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; static const char cite_pair_edpd[] = "pair edpd command: doi:10.1016/j.jcp.2014.02.003\n\n" diff --git a/src/DPD-MESO/pair_mdpd.cpp b/src/DPD-MESO/pair_mdpd.cpp index 767fddd7ac..de148189e0 100644 --- a/src/DPD-MESO/pair_mdpd.cpp +++ b/src/DPD-MESO/pair_mdpd.cpp @@ -34,7 +34,7 @@ using namespace LAMMPS_NS; -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; static const char cite_pair_mdpd[] = "pair mdpd command: doi:10.1063/1.4812366\n\n" diff --git a/src/DPD-MESO/pair_tdpd.cpp b/src/DPD-MESO/pair_tdpd.cpp index eac5bd1318..038b3c3cdc 100644 --- a/src/DPD-MESO/pair_tdpd.cpp +++ b/src/DPD-MESO/pair_tdpd.cpp @@ -37,7 +37,7 @@ using namespace LAMMPS_NS; #define MIN(A,B) ((A) < (B) ? (A) : (B)) #define MAX(A,B) ((A) > (B) ? (A) : (B)) -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; static const char cite_pair_tdpd[] = "pair tdpd command: doi:10.1063/1.4923254\n\n" diff --git a/src/DPD-REACT/fix_eos_table.cpp b/src/DPD-REACT/fix_eos_table.cpp index 36bbe4d478..42567119df 100644 --- a/src/DPD-REACT/fix_eos_table.cpp +++ b/src/DPD-REACT/fix_eos_table.cpp @@ -24,7 +24,7 @@ #include -#define MAXLINE 1024 +static constexpr int MAXLINE = 1024; using namespace LAMMPS_NS; using namespace FixConst; @@ -194,7 +194,7 @@ void FixEOStable::free_table(Table *tb) void FixEOStable::read_table(Table *tb, Table *tb2, char *file, char *keyword) { - char line[MAXLINE]; + char line[MAXLINE] = {'\0'}; // open file diff --git a/src/DPD-REACT/fix_eos_table_rx.cpp b/src/DPD-REACT/fix_eos_table_rx.cpp index f7afddc64f..bf71b502f0 100644 --- a/src/DPD-REACT/fix_eos_table_rx.cpp +++ b/src/DPD-REACT/fix_eos_table_rx.cpp @@ -28,12 +28,12 @@ #include #include -#define MAXLINE 1024 +static constexpr int MAXLINE = 1024; #ifdef DBL_EPSILON - #define MY_EPSILON (10.0*DBL_EPSILON) +static constexpr double MY_EPSILON = 10.0*DBL_EPSILON; #else - #define MY_EPSILON (10.0*2.220446049250313e-16) +static constexpr double MY_EPSILON = 10.0*2.220446049250313e-16; #endif using namespace LAMMPS_NS; @@ -318,7 +318,8 @@ void FixEOStableRX::read_file(char *file) // one set of params can span multiple lines int n,nwords,ispecies; - char line[MAXLINE],*ptr; + char line[MAXLINE] = {'\0'}; + char *ptr; int eof = 0; while (true) { @@ -414,7 +415,7 @@ void FixEOStableRX::free_table(Table *tb) void FixEOStableRX::read_table(Table *tb, Table *tb2, char *file, char *keyword) { - char line[MAXLINE]; + char line[MAXLINE] = {'\0'}; // open file diff --git a/src/DPD-REACT/fix_rx.cpp b/src/DPD-REACT/fix_rx.cpp index cce88cf465..a7e9e4ea77 100644 --- a/src/DPD-REACT/fix_rx.cpp +++ b/src/DPD-REACT/fix_rx.cpp @@ -38,16 +38,15 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace MathSpecial; -enum{NONE,HARMONIC}; -enum{LUCY}; +enum { NONE, HARMONIC }; +enum { LUCY }; -#define MAXLINE 1024 -#define DELTA 4 +static constexpr int MAXLINE = 1024; #ifdef DBL_EPSILON - #define MY_EPSILON (10.0*DBL_EPSILON) +static constexpr double MY_EPSILON = 10.0*DBL_EPSILON; #else - #define MY_EPSILON (10.0*2.220446049250313e-16) +static constexpr double MY_EPSILON = 10.0*2.220446049250313e-16; #endif #define SparseKinetics_enableIntegralReactions (true) @@ -250,7 +249,8 @@ void FixRX::post_constructor() // Assign species names to tmpspecies array and determine the number of unique species int n; - char line[MAXLINE],*ptr; + char line[MAXLINE] = {'\0'}; + char *ptr; int eof = 0; char * word; @@ -784,7 +784,8 @@ void FixRX::read_file(char *file) // Count the number of reactions from kinetics file int n,ispecies; - char line[MAXLINE],*ptr; + char line[MAXLINE] = {'\0'}; + char *ptr; int eof = 0; while (true) { diff --git a/src/DPD-REACT/fix_shardlow.cpp b/src/DPD-REACT/fix_shardlow.cpp index 19f2c08a5f..7d4d9ce674 100644 --- a/src/DPD-REACT/fix_shardlow.cpp +++ b/src/DPD-REACT/fix_shardlow.cpp @@ -50,6 +50,7 @@ #include "npair_half_bin_newton_ssa.h" #include "pair_dpd_fdt.h" #include "pair_dpd_fdt_energy.h" +#include "random_external_state.h" #include "update.h" #include @@ -59,8 +60,7 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace random_external_state; -#define EPSILON 1.0e-10 -#define EPSILON_SQUARED ((EPSILON) * (EPSILON)) +static constexpr double EPSILON_SQUARED = 1.0e-20; static const char cite_fix_shardlow[] = "fix shardlow command: doi:10.1016/j.cpc.2014.03.029, doi:10.1063/1.3660209\n\n" @@ -85,8 +85,8 @@ static const char cite_fix_shardlow[] = /* ---------------------------------------------------------------------- */ FixShardlow::FixShardlow(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg), pairDPD(nullptr), pairDPDE(nullptr), v_t0(nullptr) - ,rand_state(nullptr) + Fix(lmp, narg, arg), pairDPD(nullptr), pairDPDE(nullptr), v_t0(nullptr), + rand_state(nullptr) { if (lmp->citeme) lmp->citeme->add(cite_fix_shardlow); diff --git a/src/DPD-REACT/fix_shardlow.h b/src/DPD-REACT/fix_shardlow.h index 0086874e31..552ac3b21d 100644 --- a/src/DPD-REACT/fix_shardlow.h +++ b/src/DPD-REACT/fix_shardlow.h @@ -21,7 +21,10 @@ FixStyle(shardlow,FixShardlow); #define LMP_FIX_SHARDLOW_H #include "fix.h" -#include "random_external_state.h" + +namespace random_external_state { +using es_RNG_t = uint64_t; +} namespace LAMMPS_NS { diff --git a/src/DPD-REACT/npair_half_bin_newton_ssa.cpp b/src/DPD-REACT/npair_half_bin_newton_ssa.cpp index ce405da3ac..7393e54f78 100644 --- a/src/DPD-REACT/npair_half_bin_newton_ssa.cpp +++ b/src/DPD-REACT/npair_half_bin_newton_ssa.cpp @@ -18,6 +18,7 @@ ------------------------------------------------------------------------- */ #include "npair_half_bin_newton_ssa.h" + #include "nstencil_ssa.h" #include "nbin_ssa.h" #include "neigh_list.h" diff --git a/src/DPD-REACT/pair_dpd_fdt.cpp b/src/DPD-REACT/pair_dpd_fdt.cpp index e6cab0e996..44920a6bda 100644 --- a/src/DPD-REACT/pair_dpd_fdt.cpp +++ b/src/DPD-REACT/pair_dpd_fdt.cpp @@ -34,7 +34,7 @@ using namespace LAMMPS_NS; -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; /* ---------------------------------------------------------------------- */ diff --git a/src/DPD-REACT/pair_dpd_fdt_energy.cpp b/src/DPD-REACT/pair_dpd_fdt_energy.cpp index d3371f465a..12d6dc5fb7 100644 --- a/src/DPD-REACT/pair_dpd_fdt_energy.cpp +++ b/src/DPD-REACT/pair_dpd_fdt_energy.cpp @@ -34,7 +34,7 @@ using namespace LAMMPS_NS; -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; /* ---------------------------------------------------------------------- */ diff --git a/src/DPD-REACT/pair_exp6_rx.cpp b/src/DPD-REACT/pair_exp6_rx.cpp index c6b831f84b..e0ac9c0b27 100644 --- a/src/DPD-REACT/pair_exp6_rx.cpp +++ b/src/DPD-REACT/pair_exp6_rx.cpp @@ -31,13 +31,13 @@ using namespace LAMMPS_NS; using namespace MathSpecial; -#define MAXLINE 1024 -#define DELTA 4 +static constexpr int MAXLINE = 1024; +static constexpr int DELTA = 4; #ifdef DBL_EPSILON - #define MY_EPSILON (10.0*DBL_EPSILON) +static constexpr double MY_EPSILON = 10.0*DBL_EPSILON; #else - #define MY_EPSILON (10.0*2.220446049250313e-16) +static constexpr double MY_EPSILON = 10.0*2.220446049250313e-16; #endif #define oneFluidApproxParameter (-1) @@ -728,7 +728,8 @@ void PairExp6rx::read_file(char *file) // one set of params can span multiple lines int n,nwords,ispecies; - char line[MAXLINE],*ptr; + char line[MAXLINE] = {'\0'}; + char *ptr; int eof = 0; while (true) { @@ -835,7 +836,8 @@ void PairExp6rx::read_file2(char *file) // one set of params can span multiple lines int n,nwords; - char line[MAXLINE],*ptr; + char line[MAXLINE] = {'\0'}; + char *ptr; int eof = 0; while (true) { diff --git a/src/DPD-REACT/pair_multi_lucy.cpp b/src/DPD-REACT/pair_multi_lucy.cpp index 89263dd445..918246dcde 100644 --- a/src/DPD-REACT/pair_multi_lucy.cpp +++ b/src/DPD-REACT/pair_multi_lucy.cpp @@ -39,9 +39,8 @@ using namespace LAMMPS_NS; using MathConst::MY_PI; -enum{NONE,RLINEAR,RSQ}; - -#define MAXLINE 1024 +enum { NONE, RLINEAR, RSQ }; +static constexpr int MAXLINE = 1024; static const char cite_pair_multi_lucy[] = "pair_style multi/lucy command: doi:10.1063/1.4942520\n\n" @@ -344,7 +343,7 @@ double PairMultiLucy::init_one(int i, int j) void PairMultiLucy::read_table(Table *tb, char *file, char *keyword) { - char line[MAXLINE]; + char line[MAXLINE] = {'\0'}; // open file diff --git a/src/DPD-REACT/pair_multi_lucy_rx.cpp b/src/DPD-REACT/pair_multi_lucy_rx.cpp index 9620908531..c248d92694 100644 --- a/src/DPD-REACT/pair_multi_lucy_rx.cpp +++ b/src/DPD-REACT/pair_multi_lucy_rx.cpp @@ -41,15 +41,9 @@ using namespace LAMMPS_NS; using MathConst::MY_PI; -enum{NONE,RLINEAR,RSQ}; +enum{ NONE, RLINEAR, RSQ }; -#define MAXLINE 1024 - -#ifdef DBL_EPSILON - #define MY_EPSILON (10.0*DBL_EPSILON) -#else - #define MY_EPSILON (10.0*2.220446049250313e-16) -#endif +static constexpr int MAXLINE = 1024; #define oneFluidParameter (-1) #define isOneFluid(_site) ( (_site) == oneFluidParameter ) @@ -483,16 +477,13 @@ double PairMultiLucyRX::init_one(int i, int j) void PairMultiLucyRX::read_table(Table *tb, char *file, char *keyword) { - char line[MAXLINE]; + char line[MAXLINE] = {'\0'}; // open file FILE *fp = utils::open_potential(file,lmp,nullptr); - if (fp == nullptr) { - char str[128]; - snprintf(str,128,"Cannot open file %s",file); - error->one(FLERR,str); - } + if (fp == nullptr) + error->one(FLERR, "Cannot open file {}: {}",file,utils::getsyserror()); // loop until section found with matching keyword diff --git a/src/DPD-REACT/random_external_state.h b/src/DPD-REACT/random_external_state.h index 9c5958e243..5ce1cf100c 100644 --- a/src/DPD-REACT/random_external_state.h +++ b/src/DPD-REACT/random_external_state.h @@ -76,7 +76,7 @@ // A replacement for the Kokkos Random_XorShift64 class that uses // an external state variable, instead of a class member variable. namespace random_external_state { -typedef uint64_t es_RNG_t; +using es_RNG_t = uint64_t; constexpr uint32_t MAX_URAND = 0xffffffffU; constexpr uint64_t MAX_URAND64 = 0xffffffffffffffffULL - 1; diff --git a/src/DRUDE/compute_temp_drude.cpp b/src/DRUDE/compute_temp_drude.cpp index b309346934..0bf276924a 100644 --- a/src/DRUDE/compute_temp_drude.cpp +++ b/src/DRUDE/compute_temp_drude.cpp @@ -54,20 +54,19 @@ ComputeTempDrude::ComputeTempDrude(LAMMPS *lmp, int narg, char **arg) : ComputeTempDrude::~ComputeTempDrude() { - delete [] vector; - delete [] extlist; - delete [] id_temp; + delete[] vector; + delete[] extlist; + delete[] id_temp; } /* ---------------------------------------------------------------------- */ void ComputeTempDrude::init() { - int ifix; - for (ifix = 0; ifix < modify->nfix; ifix++) - if (strcmp(modify->fix[ifix]->style,"drude") == 0) break; - if (ifix == modify->nfix) error->all(FLERR, "compute temp/drude requires fix drude"); - fix_drude = dynamic_cast(modify->fix[ifix]); + // Fix drude already checks that there is only one fix drude instance + auto &fixes = modify->get_fix_by_style("^drude$"); + if (fixes.size() == 0) error->all(FLERR, "compute temp/drude requires fix drude"); + fix_drude = dynamic_cast(fixes[0]); if (!comm->ghost_velocity) error->all(FLERR,"compute temp/drude requires ghost velocities. Use comm_modify vel yes"); @@ -118,14 +117,12 @@ int ComputeTempDrude::modify_param(int narg, char **arg) delete [] id_temp; id_temp = utils::strdup(arg[1]); - int icompute = modify->find_compute(id_temp); - if (icompute < 0) - error->all(FLERR,"Could not find fix_modify temperature ID"); - temperature = modify->compute[icompute]; + temperature = modify->get_compute_by_id(id_temp); + if (!temperature) + error->all(FLERR,"Could not find fix_modify temperature compute {}", id_temp); if (temperature->tempflag == 0) - error->all(FLERR, - "Fix_modify temperature ID does not compute temperature"); + error->all(FLERR, "Fix_modify temperature compute {} does not compute temperature", id_temp); if (temperature->igroup != igroup && comm->me == 0) error->warning(FLERR,"Group for fix_modify temp != fix group"); return 2; diff --git a/src/DRUDE/fix_drude.cpp b/src/DRUDE/fix_drude.cpp index 56a5cd42f6..6c0c84861a 100644 --- a/src/DRUDE/fix_drude.cpp +++ b/src/DRUDE/fix_drude.cpp @@ -22,7 +22,6 @@ #include "modify.h" #include "molecule.h" -#include #include #include @@ -83,10 +82,7 @@ FixDrude::~FixDrude() void FixDrude::init() { - int count = 0; - for (int i = 0; i < modify->nfix; i++) - if (strcmp(modify->fix[i]->style,"drude") == 0) count++; - if (count > 1) error->all(FLERR,"More than one fix drude"); + if (modify->get_fix_by_style("^drude$").size() > 1) error->all(FLERR,"More than one fix drude"); if (!rebuildflag) rebuild_special(); } diff --git a/src/DRUDE/fix_drude_transform.cpp b/src/DRUDE/fix_drude_transform.cpp index 4a85b8ae4c..ad92740116 100644 --- a/src/DRUDE/fix_drude_transform.cpp +++ b/src/DRUDE/fix_drude_transform.cpp @@ -24,7 +24,6 @@ #include "modify.h" #include -#include using namespace LAMMPS_NS; using namespace FixConst; @@ -54,7 +53,7 @@ void FixDrudeTransform::init() std::string substyle = "direct"; if (inverse) substyle = "inverse"; - auto fixes = modify->get_fix_by_style("^drude"); + auto fixes = modify->get_fix_by_style("^drude$"); if (fixes.size() > 0) fix_drude = dynamic_cast(fixes[0]); if (!fix_drude) error->all(FLERR, "fix drude/transform/{} requires fix drude", substyle); diff --git a/src/DRUDE/fix_tgnh_drude.cpp b/src/DRUDE/fix_tgnh_drude.cpp index b23acd349b..e15e865ce8 100644 --- a/src/DRUDE/fix_tgnh_drude.cpp +++ b/src/DRUDE/fix_tgnh_drude.cpp @@ -40,8 +40,8 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define DELTAFLIP 0.1 -#define TILTMAX 1.5 +static constexpr double DELTAFLIP = 0.1; +static constexpr double TILTMAX = 1.5; enum{NOBIAS,BIAS}; enum{NONE,XYZ,XY,YZ,XZ}; @@ -516,7 +516,7 @@ FixTGNHDrude::FixTGNHDrude(LAMMPS *lmp, int narg, char **arg) : // find fix drude - auto fdrude = modify->get_fix_by_style("^drude"); + auto fdrude = modify->get_fix_by_style("^drude$"); if (fdrude.size() < 1) error->all(FLERR, "Fix {} requires fix drude", style); fix_drude = dynamic_cast(fdrude[0]); if (!fix_drude) error->all(FLERR, "Fix {} requires fix drude", style); diff --git a/src/DRUDE/pair_lj_cut_thole_long.cpp b/src/DRUDE/pair_lj_cut_thole_long.cpp index cfdf631eb9..b7f1ce9be9 100644 --- a/src/DRUDE/pair_lj_cut_thole_long.cpp +++ b/src/DRUDE/pair_lj_cut_thole_long.cpp @@ -37,18 +37,18 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define EWALD_F 1.12837917 -#define EWALD_P 9.95473818e-1 -#define B0 -0.1335096380159268 -#define B1 -2.57839507e-1 -#define B2 -1.37203639e-1 -#define B3 -8.88822059e-3 -#define B4 -5.80844129e-3 -#define B5 1.14652755e-1 +static constexpr double EWALD_F = 1.12837917; +static constexpr double EWALD_P = 9.95473818e-1; +static constexpr double B0 = -0.1335096380159268; +static constexpr double B1 = -2.57839507e-1; +static constexpr double B2 = -1.37203639e-1; +static constexpr double B3 = -8.88822059e-3; +static constexpr double B4 = -5.80844129e-3; +static constexpr double B5 = 1.14652755e-1; -#define EPSILON 1.0e-20 -#define EPS_EWALD 1.0e-6 -#define EPS_EWALD_SQR 1.0e-12 +static constexpr double EPSILON = 1.0e-20; +static constexpr double EPS_EWALD = 1.0e-6; +static constexpr double EPS_EWALD_SQR = 1.0e-12; /* ---------------------------------------------------------------------- */ diff --git a/src/EFF/fix_langevin_eff.cpp b/src/EFF/fix_langevin_eff.cpp index a25b6ac837..65a3f5b115 100644 --- a/src/EFF/fix_langevin_eff.cpp +++ b/src/EFF/fix_langevin_eff.cpp @@ -34,11 +34,8 @@ using namespace LAMMPS_NS; using namespace FixConst; -enum{NOBIAS,BIAS}; -enum{CONSTANT,EQUAL,ATOM}; - -#define SINERTIA 0.4 // moment of inertia prefactor for sphere -#define EINERTIA 0.2 // moment of inertia prefactor for ellipsoid +enum { NOBIAS, BIAS }; +enum { CONSTANT, EQUAL, ATOM }; /* ---------------------------------------------------------------------- */ diff --git a/src/ELECTRODE/README b/src/ELECTRODE/README new file mode 100644 index 0000000000..72a95b7fe9 --- /dev/null +++ b/src/ELECTRODE/README @@ -0,0 +1,17 @@ +This package provides the "fix electrode/*" commands which can be used in a +LAMMPS input script. These fixes implement the constant potential method, which +minimizes the energy of electrodes as a function of atom charges at given +electric potentials or electrode charges. + +See the doc page for the fix electrode/conp command to get started. There are +example scripts for using this package in examples/PACKAGES/electrode. + +This package uses an external library in lib/electrode which must be compiled +before making LAMMPS. For a CMake build, the location of the LAPACK library +should be linked automatically. Alternatively, the "USE_INTERNAL_LINALG" option +can be used to enable the bundled library. See the doc page on "Packages with +extra build options" for more information. + +The primary people who created this package are Ludwig Ahrens-Iwers, Shern Tee +(s.tee@griffith.edu.au) and Robert Meißner (robert.meissner@tuhh.de). Contact +them directly if you have questions. diff --git a/src/ELECTRODE/electrode_math.h b/src/ELECTRODE/electrode_math.h index 5992df2289..4a3cb7bac4 100644 --- a/src/ELECTRODE/electrode_math.h +++ b/src/ELECTRODE/electrode_math.h @@ -18,22 +18,20 @@ #ifndef LMP_ELECTRODE_MATH_H #define LMP_ELECTRODE_MATH_H +#include "ewald_const.h" #include "math_const.h" +#include + namespace LAMMPS_NS { +using namespace EwaldConst; namespace ElectrodeMath { - static constexpr double EWALD_P = 0.3275911; - static constexpr double A1 = 0.254829592; - static constexpr double A2 = -0.284496736; - static constexpr double A3 = 1.421413741; - static constexpr double A4 = -1.453152027; - static constexpr double A5 = 1.061405429; static constexpr double ERFCMAX = 5.8; // erfc(ERFCMAX) < machine epsilon(double) static double safe_erfc(double x) { - if (x > ERFCMAX) return 0.; + if (x > ERFCMAX) return 0.0; double expm2 = exp(-x * x); double t = 1.0 / (1.0 + EWALD_P * x); return t * (A1 + t * (A2 + t * (A3 + t * (A4 + t * A5)))) * expm2; @@ -42,14 +40,14 @@ namespace ElectrodeMath { static double safe_derfcr(double x, double &erfc) { if (x > ERFCMAX) { - erfc = 0.; - return 0.; + erfc = 0.0; + return 0.0; } double x2 = x * x; double expm2 = exp(-x2); double t = 1.0 / (1.0 + EWALD_P * x); erfc = t * (A1 + t * (A2 + t * (A3 + t * (A4 + t * A5)))) * expm2; - return -erfc - 2 * expm2 * x / MathConst::MY_PIS; + return -erfc - 2.0 * expm2 * x / MathConst::MY_PIS; } } // namespace ElectrodeMath diff --git a/src/ELECTRODE/electrode_matrix.cpp b/src/ELECTRODE/electrode_matrix.cpp index 86761742d4..9c2da1d13b 100644 --- a/src/ELECTRODE/electrode_matrix.cpp +++ b/src/ELECTRODE/electrode_matrix.cpp @@ -43,6 +43,7 @@ ElectrodeMatrix::ElectrodeMatrix(LAMMPS *lmp, int electrode_group, double eta) : groupbit = group->bitmask[igroup]; ngroup = group->count(igroup); this->eta = eta; + etaflag = false; tfflag = false; } @@ -72,6 +73,14 @@ void ElectrodeMatrix::setup_tf(const std::map &tf_types) /* ---------------------------------------------------------------------- */ +void ElectrodeMatrix::setup_eta(int index) +{ + etaflag = true; + eta_index = index; +} + +/* ---------------------------------------------------------------------- */ + void ElectrodeMatrix::compute_array(double **array, bool timer_flag) { // setting all entries of coulomb matrix to zero @@ -115,8 +124,6 @@ void ElectrodeMatrix::pair_contribution(double **array) int nlocal = atom->nlocal; int newton_pair = force->newton_pair; - double const etaij = eta * eta / sqrt(2.0 * eta * eta); // see mw ewald theory eq. (29)-(30) - // neighbor list will be ready because called from post_neighbor inum = list->inum; ilist = list->ilist; @@ -135,6 +142,7 @@ void ElectrodeMatrix::pair_contribution(double **array) xtmp = x[i][0]; ytmp = x[i][1]; ztmp = x[i][2]; + double const eta_i = etaflag ? atom->dvector[eta_index][i] : eta; itype = type[i]; jlist = firstneigh[i]; jnum = numneigh[i]; @@ -152,6 +160,9 @@ void ElectrodeMatrix::pair_contribution(double **array) jtype = type[j]; if (rsq < cutsq[itype][jtype]) { + double const eta_j = etaflag ? atom->dvector[eta_index][j] : eta; + double const etaij = eta_i * eta_j / sqrt(eta_i * eta_i + eta_j * eta_j); + r = sqrt(rsq); rinv = 1.0 / r; aij = rinv; @@ -178,7 +189,10 @@ void ElectrodeMatrix::self_contribution(double **array) const double preta = MY_SQRT2 / MY_PIS; for (int i = 0; i < nlocal; i++) - if (mask[i] & groupbit) { array[mpos[i]][mpos[i]] += preta * eta - selfint; } + if (mask[i] & groupbit) { + double const eta_i = etaflag ? atom->dvector[eta_index][i] : eta; + array[mpos[i]][mpos[i]] += preta * eta_i - selfint; + } } /* ---------------------------------------------------------------------- */ diff --git a/src/ELECTRODE/electrode_matrix.h b/src/ELECTRODE/electrode_matrix.h index 8499cfdb34..1c64d8a4c4 100644 --- a/src/ELECTRODE/electrode_matrix.h +++ b/src/ELECTRODE/electrode_matrix.h @@ -30,6 +30,7 @@ class ElectrodeMatrix : protected Pointers { ElectrodeMatrix(class LAMMPS *, int, double); void setup(const std::unordered_map &, class Pair *, class NeighList *); void setup_tf(const std::map &); + void setup_eta(int); void compute_array(double **, bool); int igroup; @@ -39,6 +40,8 @@ class ElectrodeMatrix : protected Pointers { double **cutsq; double g_ewald, eta; bool tfflag; + bool etaflag; + int eta_index; std::map tf_types; std::unordered_map tag_to_iele; bool assigned; diff --git a/src/ELECTRODE/electrode_vector.cpp b/src/ELECTRODE/electrode_vector.cpp index 8511ddc17c..fc2cca5e46 100644 --- a/src/ELECTRODE/electrode_vector.cpp +++ b/src/ELECTRODE/electrode_vector.cpp @@ -29,6 +29,7 @@ #include "neigh_list.h" #include "pair.h" +#include #include #include @@ -47,6 +48,7 @@ ElectrodeVector::ElectrodeVector(LAMMPS *lmp, int sensor_group, int source_group source_grpbit = group->bitmask[source_group]; this->eta = eta; tfflag = false; + etaflag = false; kspace_time_total = 0; pair_time_total = 0; @@ -93,6 +95,14 @@ void ElectrodeVector::setup_tf(const std::map &tf_types) /* ---------------------------------------------------------------------- */ +void ElectrodeVector::setup_eta(int index) +{ + etaflag = true; + eta_index = index; +} + +/* ---------------------------------------------------------------------- */ + void ElectrodeVector::compute_vector(double *vector) { MPI_Barrier(world); @@ -121,7 +131,6 @@ void ElectrodeVector::compute_vector(double *vector) void ElectrodeVector::pair_contribution(double *vector) { - double const etaij = eta * MY_ISQRT2; double **x = atom->x; double *q = atom->q; int *type = atom->type; @@ -142,6 +151,7 @@ void ElectrodeVector::pair_contribution(double *vector) double const xtmp = x[i][0]; double const ytmp = x[i][1]; double const ztmp = x[i][2]; + double const eta_i = etaflag ? atom->dvector[eta_index][i] : eta; int itype = type[i]; int *jlist = firstneigh[i]; int jnum = numneigh[i]; @@ -158,18 +168,22 @@ void ElectrodeVector::pair_contribution(double *vector) double const rsq = delx * delx + dely * dely + delz * delz; int jtype = type[j]; if (rsq >= cutsq[itype][jtype]) continue; + double const eta_j = etaflag ? atom->dvector[eta_index][j] : eta; + double etaij; + if (i_in_sensor && j_in_sensor) { + etaij = eta_i * eta_j / sqrt(eta_i * eta_i + eta_j * eta_j); + } else if (i_in_sensor) { + etaij = eta_i; + } else { + assert(j_in_sensor); + etaij = eta_j; + } double const r = sqrt(rsq); double const rinv = 1.0 / r; double aij = rinv; aij *= ElectrodeMath::safe_erfc(g_ewald * r); - if (invert_source) - aij -= ElectrodeMath::safe_erfc(eta * r) * rinv; - else - aij -= ElectrodeMath::safe_erfc(etaij * r) * rinv; - if (i_in_sensor) { - vector[i] += aij * q[j]; - //} else if (j_in_sensor) { - } + aij -= ElectrodeMath::safe_erfc(etaij * r) * rinv; + if (i_in_sensor) { vector[i] += aij * q[j]; } if (j_in_sensor && (!invert_source || !i_in_sensor)) { vector[j] += aij * q[i]; } } } @@ -189,9 +203,10 @@ void ElectrodeVector::self_contribution(double *vector) for (int ii = 0; ii < inum; ii++) { int const i = ilist[ii]; + double const eta_i = etaflag ? atom->dvector[eta_index][i] : eta; bool const i_in_sensor = (mask[i] & groupbit); bool const i_in_source = !!(mask[i] & source_grpbit) != invert_source; - if (i_in_sensor && i_in_source) vector[i] += (preta * eta - selfint) * q[i]; + if (i_in_sensor && i_in_source) vector[i] += (preta * eta_i - selfint) * q[i]; } } diff --git a/src/ELECTRODE/electrode_vector.h b/src/ELECTRODE/electrode_vector.h index e7f637dd2d..a4f274a049 100644 --- a/src/ELECTRODE/electrode_vector.h +++ b/src/ELECTRODE/electrode_vector.h @@ -29,6 +29,7 @@ class ElectrodeVector : protected Pointers { ~ElectrodeVector() override; void setup(class Pair *, class NeighList *, bool); void setup_tf(const std::map &); + void setup_eta(int); void compute_vector(double *); int igroup, source_group; @@ -39,6 +40,8 @@ class ElectrodeVector : protected Pointers { double **cutsq; double g_ewald, eta; bool tfflag; + bool etaflag; + int eta_index; std::map tf_types; class Pair *pair; class NeighList *list; diff --git a/src/ELECTRODE/ewald_electrode.cpp b/src/ELECTRODE/ewald_electrode.cpp index 99266ed450..80c9c94a06 100644 --- a/src/ELECTRODE/ewald_electrode.cpp +++ b/src/ELECTRODE/ewald_electrode.cpp @@ -37,8 +37,6 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.00001 - /* ---------------------------------------------------------------------- */ EwaldElectrode::EwaldElectrode(LAMMPS *lmp) : Ewald(lmp), boundcorr(nullptr) diff --git a/src/ELECTRODE/fix_electrode_conp.cpp b/src/ELECTRODE/fix_electrode_conp.cpp index 1b6c0a37d4..94c085de5c 100644 --- a/src/ELECTRODE/fix_electrode_conp.cpp +++ b/src/ELECTRODE/fix_electrode_conp.cpp @@ -43,12 +43,13 @@ #include #include #include +#include #include using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 1e-16 +static constexpr double SMALL = 1e-16; extern "C" { void dgetrf_(const int *M, const int *N, double *A, const int *lda, int *ipiv, int *info); @@ -97,26 +98,30 @@ FixElectrodeConp::FixElectrodeConp(LAMMPS *lmp, int narg, char **arg) : top_group = 0; intelflag = false; tfflag = false; + etaflag = false; timer_flag = false; update_time = 0; mult_time = 0; n_call = n_cg_step = 0; + qtotal = 0.; + qtotal_var_style = VarStyle::UNSET; + // read fix command fixname = std::string(arg[0]); groups = std::vector(1, igroup); group_bits = std::vector(1, groupbit); group_psi_var_names = std::vector(1); group_psi_var_styles = std::vector(1, VarStyle::CONST); - group_psi = std::vector(1); + group_psi_const = std::vector(1); etypes_neighlists = false; if (strstr(arg[3], "v_") == arg[3]) { std::string vname = arg[3]; group_psi_var_names[0] = vname.substr(2); group_psi_var_styles[0] = VarStyle::EQUAL; } else - group_psi[0] = utils::numeric(FLERR, arg[3], false, lmp); + group_psi_const[0] = utils::numeric(FLERR, arg[3], false, lmp); char *eta_str = arg[4]; eta = utils::numeric(FLERR, eta_str, false, lmp); int iarg = 5; @@ -132,12 +137,12 @@ FixElectrodeConp::FixElectrodeConp(LAMMPS *lmp, int narg, char **arg) : std::string vname = arg[iarg]; group_psi_var_names.push_back(vname.substr(2)); group_psi_var_styles.push_back(VarStyle::EQUAL); - group_psi.push_back(0.); + group_psi_const.push_back(0.); } else { std::string null; group_psi_var_names.push_back(null); group_psi_var_styles.push_back(VarStyle::CONST); - group_psi.push_back(utils::numeric(FLERR, arg[iarg], false, lmp)); + group_psi_const.push_back(utils::numeric(FLERR, arg[iarg], false, lmp)); } } else if ((strcmp(arg[iarg], "algo") == 0)) { if (!default_algo) error->one(FLERR, "Algorithm can be set only once"); @@ -195,8 +200,32 @@ FixElectrodeConp::FixElectrodeConp(LAMMPS *lmp, int narg, char **arg) : thermo_temp = force->boltz / force->qe2f * utils::numeric(FLERR, arg[++iarg], false, lmp); thermo_time = utils::numeric(FLERR, arg[++iarg], false, lmp); thermo_init = utils::inumeric(FLERR, arg[++iarg], false, lmp); - // toggle parameters - } else if ((strcmp(arg[iarg], "etypes") == 0)) { + } else if ((strcmp(arg[iarg], "qtotal") == 0)) { + if (iarg + 2 > narg) error->all(FLERR, "Need one argument after qtotal keyword"); + if (strcmp(this->style, "electrode/conq") == 0) + error->all(FLERR, "qtotal keyword not available for electrode/conq"); + ++iarg; + if (strstr(arg[iarg], "v_") == arg[iarg]) { + std::string vname = arg[iarg]; + qtotal_var_name = vname.substr(2); + qtotal_var_style = VarStyle::EQUAL; + } else { + qtotal = utils::numeric(FLERR, arg[iarg], false, lmp); + qtotal_var_style = VarStyle::CONST; + } + } else if ((strcmp(arg[iarg], "eta") == 0)) { + if (iarg + 2 > narg) error->all(FLERR, "Need two arguments after eta command"); + etaflag = true; + int is_double, cols, ghost; + eta_index = atom->find_custom_ghost(arg[++iarg] + 2, is_double, cols, ghost); + if (eta_index == -1) + error->all(FLERR, "eta keyword requires name of previously defined property"); + if (!is_double) error->all(FLERR, "eta keyword requires double-valued property/atom vector"); + if (cols != 0) error->all(FLERR, "eta keyword requires property/atom vector not an array"); + if (!ghost) error->all(FLERR, "eta keyword requires property/atom fix with ghost on"); + } + // toggle parameters + else if ((strcmp(arg[iarg], "etypes") == 0)) { etypes_neighlists = utils::logical(FLERR, arg[++iarg], false, lmp); } else if ((strncmp(arg[iarg], "symm", 4) == 0)) { symm = utils::logical(FLERR, arg[++iarg], false, lmp); @@ -208,6 +237,12 @@ FixElectrodeConp::FixElectrodeConp(LAMMPS *lmp, int narg, char **arg) : iarg++; } + if (qtotal_var_style != VarStyle::UNSET) { + if (symm) error->all(FLERR, "{} cannot use qtotal keyword with symm on", this->style); + } + + // computatonal potential + group_psi = std::vector(groups.size()); // union of all coupled groups std::string union_group = "conp_group"; std::string group_cmd = union_group + " union"; @@ -225,6 +260,7 @@ FixElectrodeConp::FixElectrodeConp(LAMMPS *lmp, int narg, char **arg) : if (need_elec_vector) elec_vector = new ElectrodeVector(lmp, igroup, igroup, eta, false); assert(groups.size() == group_bits.size()); assert(groups.size() == group_psi.size()); + assert(groups.size() == group_psi_const.size()); assert(groups.size() == group_psi_var_styles.size()); assert(groups.size() == group_psi_var_names.size()); assert(igroup == elyt_vector->igroup); @@ -374,6 +410,31 @@ void FixElectrodeConp::init() if (strncmp(modify->fix[i]->style, "electrode", 9) == 0) count++; if (count > 1) error->all(FLERR, "More than one fix electrode"); + // make sure electrode atoms are not integrated if a matrix is used for electrode-electrode interaction + int const nlocal = atom->nlocal; + int *mask = atom->mask; + Fix **fix = modify->fix; + if (matrix_algo) { + std::vector integrate_ids = std::vector(); + for (int i = 0; i < modify->nfix; i++) { + if (fix[i]->time_integrate == 0) continue; + int electrode_mover = 0; + int fix_groupbit = fix[i]->groupbit; + for (int j = 0; j < nlocal; j++) + if ((mask[j] & fix_groupbit) && (mask[j] & groupbit)) electrode_mover = 1; + MPI_Allreduce(MPI_IN_PLACE, &electrode_mover, 1, MPI_INT, MPI_SUM, world); + if (electrode_mover && comm->me == 0) integrate_ids.push_back(fix[i]->id); + } + if (comm->me == 0) + for (char *fix_id : integrate_ids) + error->warning( + FLERR, + "Electrode atoms are integrated by fix {}, but fix electrode is using a matrix method. " + "For " + "mobile electrodes use the conjugate gradient algorithm without matrix ('algo cg').", + fix_id); + } + // check for package intel if (etypes_neighlists) request_etypes_neighlists(); @@ -448,6 +509,7 @@ void FixElectrodeConp::setup_post_neighbor() // get equal-style variable ids: group_psi_var_ids = std::vector(num_of_groups, -1); for (int g = 0; g < num_of_groups; g++) { + assert(group_psi_var_styles[g] != VarStyle::UNSET); if (group_psi_var_styles[g] == VarStyle::CONST) continue; const char *var_name = group_psi_var_names[g].c_str(); int var_id = input->variable->find(var_name); @@ -456,13 +518,23 @@ void FixElectrodeConp::setup_post_neighbor() error->all(FLERR, "Variable '{}' for fix {} is not equal-style", var_name, style); group_psi_var_ids[g] = var_id; } + if (qtotal_var_style == VarStyle::EQUAL) { + const char *var_name = qtotal_var_name.c_str(); + int var_id = input->variable->find(var_name); + if (var_id < 0) error->all(FLERR, "Variable '{}' for fix electrode does not exist", var_name); + if (!input->variable->equalstyle(var_id)) + error->all(FLERR, "Variable '{}' for fix electrode is not equal-style", var_name); + qtotal_var_id = var_id; + } // pair and list setups: evscale = force->qe2f / force->qqrd2e; elyt_vector->setup(pair, vec_neighlist, timer_flag); + if (etaflag) elyt_vector->setup_eta(eta_index); if (need_elec_vector) { elec_vector->setup(pair, mat_neighlist, timer_flag); + if (etaflag) elec_vector->setup_eta(eta_index); if (tfflag) elec_vector->setup_tf(tf_types); } @@ -497,7 +569,8 @@ void FixElectrodeConp::setup_post_neighbor() if (etypes_neighlists) neighbor->build_one(mat_neighlist, 0); auto array_compute = std::unique_ptr(new ElectrodeMatrix(lmp, igroup, eta)); array_compute->setup(tag_to_iele, pair, mat_neighlist); - if (tfflag) { array_compute->setup_tf(tf_types); } + if (etaflag) array_compute->setup_eta(eta_index); + if (tfflag) array_compute->setup_tf(tf_types); array_compute->compute_array(elastance, timer_flag); } // write_mat before proceeding if (comm->me == 0 && write_mat) { @@ -804,6 +877,8 @@ void FixElectrodeConp::update_charges() } MPI_Allreduce(MPI_IN_PLACE, &sb_charges.front(), num_of_groups, MPI_DOUBLE, MPI_SUM, world); update_psi(); // use for equal-style and conq + if (qtotal_var_style != VarStyle::UNSET) + update_psi_qtotal(); // use for qtotal; same for thermo for (int g = 0; g < num_of_groups; g++) for (int j = 0; j < nlocalele; j++) q_local[j] += sd_vectors[g][list_iele[j]] * group_psi[g]; MPI_Barrier(world); @@ -906,12 +981,22 @@ std::vector FixElectrodeConp::gather_ngroup(std::vector x_local) } /* ---------------------------------------------------------------------- - ensure total electrode charge is 0 if symm + ensure total electrode charge is 0 if symm and qtotal if qtotal is used ------------------------------------------------------------------------- */ std::vector FixElectrodeConp::constraint_correction(std::vector x) { - return constraint_projection(std::move(x)); + if (symm || qtotal_var_style != VarStyle::UNSET) { + if (qtotal_var_style == VarStyle::EQUAL) qtotal = input->variable->compute_equal(qtotal_var_id); + double sum = 0.; + for (double xi : x) sum += xi; + MPI_Allreduce(MPI_IN_PLACE, &sum, 1, MPI_DOUBLE, MPI_SUM, world); + if (qtotal_var_style != VarStyle::UNSET) sum -= qtotal; + sum /= ngroup; + for (double &xi : x) xi -= sum; + return x; + } + return x; } /* ---------------------------------------------------------------------- @@ -920,7 +1005,7 @@ std::vector FixElectrodeConp::constraint_correction(std::vector std::vector FixElectrodeConp::constraint_projection(std::vector x) { - if (symm) { + if (symm || qtotal_var_style != VarStyle::UNSET) { double sum = 0.; for (double xi : x) sum += xi; MPI_Allreduce(MPI_IN_PLACE, &sum, 1, MPI_DOUBLE, MPI_SUM, world); @@ -978,13 +1063,28 @@ std::vector FixElectrodeConp::times_elastance(std::vector x) void FixElectrodeConp::update_psi() { for (int g = 0; g < num_of_groups; g++) { - if (group_psi_var_styles[g] == VarStyle::CONST) continue; - group_psi[g] = input->variable->compute_equal(group_psi_var_ids[g]); + if (group_psi_var_styles[g] == VarStyle::CONST) + group_psi[g] = group_psi_const[g]; + else + group_psi[g] = input->variable->compute_equal(group_psi_var_ids[g]); } } /* ---------------------------------------------------------------------- */ +void FixElectrodeConp::update_psi_qtotal() +{ + if (qtotal_var_style == VarStyle::EQUAL) qtotal = input->variable->compute_equal(qtotal_var_id); + double q_current = 0.; + for (int i = 0; i < num_of_groups; i++) { + q_current += sb_charges[i]; + for (int j = 0; j < num_of_groups; j++) q_current += macro_capacitance[i][j] * group_psi[j]; + } + double add_psi = (qtotal - q_current) / macro_capacitance_sum; + for (int i = 0; i < num_of_groups; i++) group_psi[i] += add_psi; +} +/* ---------------------------------------------------------------------- */ + void FixElectrodeConp::compute_macro_matrices() { assert(algo == Algo::MATRIX_INV); @@ -1040,6 +1140,10 @@ void FixElectrodeConp::compute_macro_matrices() } } } + + macro_capacitance_sum = 0.; + for (int i = 0; i < num_of_groups; i++) + for (int j = 0; j < num_of_groups; j++) macro_capacitance_sum += macro_capacitance[i][j]; } /* ---------------------------------------------------------------------- */ @@ -1096,7 +1200,7 @@ double FixElectrodeConp::self_energy(int eflag) // corrections to energy due to self interaction double const qqrd2e = force->qqrd2e; int const nlocal = atom->nlocal; - double const pre = eta / sqrt(MY_2PI) * qqrd2e; + double const pre = 1. / sqrt(MY_2PI) * qqrd2e; int *mask = atom->mask; int *type = atom->type; double *q = atom->q; @@ -1104,7 +1208,8 @@ double FixElectrodeConp::self_energy(int eflag) for (int i = 0; i < nlocal; i++) { if (groupbit & mask[i]) { double const q2 = q[i] * q[i]; - double e = pre * q2; + double ieta = etaflag ? atom->dvector[eta_index][i] : eta; + double e = ieta * pre * q2; if (tfflag && (groupbit & mask[i])) e += 0.5 * qqrd2e * q2 * tf_types[type[i]]; energy += e; if (eflag) { @@ -1144,6 +1249,7 @@ double FixElectrodeConp::gausscorr(int eflag, bool fflag) double xtmp = x[i][0]; double ytmp = x[i][1]; double ztmp = x[i][2]; + double const eta_i = etaflag ? atom->dvector[eta_index][i] : eta; int itype = type[i]; int *jlist = firstneigh[i]; int jnum = numneigh[i]; @@ -1152,7 +1258,6 @@ double FixElectrodeConp::gausscorr(int eflag, bool fflag) int const j = jlist[jj] & NEIGHMASK; bool j_in_ele = groupbit & mask[j]; if (!(i_in_ele || j_in_ele)) continue; - double eta_ij = (i_in_ele && j_in_ele) ? eta / MY_SQRT2 : eta; double delx = xtmp - x[j][0]; double dely = ytmp - x[j][1]; @@ -1161,6 +1266,16 @@ double FixElectrodeConp::gausscorr(int eflag, bool fflag) int jtype = type[j]; if (rsq < force->pair->cutsq[itype][jtype]) { + double const eta_j = etaflag ? atom->dvector[eta_index][j] : eta; + double eta_ij; + if (i_in_ele && j_in_ele) + eta_ij = eta_i * eta_j / sqrt(eta_i * eta_i + eta_j * eta_j); + else if (i_in_ele) + eta_ij = eta_i; + else { + assert(j_in_ele); + eta_ij = eta_j; + } double r2inv = 1.0 / rsq; double r = sqrt(rsq); double erfc_etar = 0.; diff --git a/src/ELECTRODE/fix_electrode_conp.h b/src/ELECTRODE/fix_electrode_conp.h index 1289d96281..a1d7530bd1 100644 --- a/src/ELECTRODE/fix_electrode_conp.h +++ b/src/ELECTRODE/fix_electrode_conp.h @@ -29,7 +29,6 @@ FixStyle(electrode/conp, FixElectrodeConp); #include "fix.h" #include -#include #include namespace LAMMPS_NS { @@ -71,7 +70,7 @@ class FixElectrodeConp : public Fix { protected: enum class Algo { MATRIX_INV, MATRIX_CG, CG }; - enum class VarStyle { CONST, EQUAL }; + enum class VarStyle { CONST, EQUAL, UNSET }; virtual void update_psi(); virtual void pre_update(){}; virtual void recompute_potential(std::vector, std::vector){}; @@ -80,6 +79,7 @@ class FixElectrodeConp : public Fix { virtual void compute_macro_matrices(); std::vector ele_ele_interaction(const std::vector &); std::vector group_psi; + std::vector group_psi_const; // needed to undo qtotal psi updates std::vector group_bits; std::vector groups; int num_of_groups; @@ -101,6 +101,10 @@ class FixElectrodeConp : public Fix { std::string fixname; // used by electrode/ffield to set up internal efield bool intelflag; inline virtual void intel_pack_buffers() {} + double qtotal; + std::string qtotal_var_name; + int qtotal_var_id; + VarStyle qtotal_var_style; private: std::string output_file_inv, output_file_mat, output_file_vec; @@ -133,6 +137,8 @@ class FixElectrodeConp : public Fix { int get_top_group(); // used by ffield int top_group; // used by ffield bool tfflag; + int eta_index; // index of atom property for eta + bool etaflag; // eta specified as atom property bool timer_flag; std::map tf_types; // cg @@ -143,6 +149,9 @@ class FixElectrodeConp : public Fix { std::vector gather_ngroup(std::vector); std::vector gather_elevec_local(ElectrodeVector *); void set_charges(std::vector); + // qtotal + double macro_capacitance_sum; + void update_psi_qtotal(); // fix-specific electrode ID storage system: diff --git a/src/ELECTRODE/fix_electrode_conq.cpp b/src/ELECTRODE/fix_electrode_conq.cpp index 0d3d1d2aaf..a6baa1e122 100644 --- a/src/ELECTRODE/fix_electrode_conq.cpp +++ b/src/ELECTRODE/fix_electrode_conq.cpp @@ -30,7 +30,7 @@ FixElectrodeConq::FixElectrodeConq(LAMMPS *lmp, int narg, char **arg) : FixElectrodeConp(lmp, narg, arg) { // copy const-style values across because update_psi will change group_psi - group_q = group_psi; + group_q = group_psi_const; if (symm) { if (num_of_groups == 1) diff --git a/src/ELECTRODE/fix_electrode_thermo.cpp b/src/ELECTRODE/fix_electrode_thermo.cpp index 52c0a3ce4c..92db4b3ee0 100644 --- a/src/ELECTRODE/fix_electrode_thermo.cpp +++ b/src/ELECTRODE/fix_electrode_thermo.cpp @@ -29,8 +29,8 @@ using namespace LAMMPS_NS; -#define NUM_GROUPS 2 -#define SMALL 0.00001 +static constexpr int NUM_GROUPS = 2; +static constexpr double SMALL = 0.00001; /* ----------------------------------------------------------------------- */ @@ -47,7 +47,8 @@ FixElectrodeThermo::FixElectrodeThermo(LAMMPS *lmp, int narg, char **arg) : if (thermo_time < SMALL) error->all(FLERR, "Keyword temp not set or zero in electrode/thermo"); thermo_random = new RanMars(lmp, thermo_init); - if (group_psi_var_styles[0] == VarStyle::CONST) delta_psi_0 = group_psi[1] - group_psi[0]; + if (group_psi_var_styles[0] == VarStyle::CONST) + delta_psi_0 = group_psi_const[1] - group_psi_const[0]; } /* ----------------------------------------------------------------------- */ @@ -102,7 +103,7 @@ void FixElectrodeThermo::update_psi() double const delta_psi = group_psi_old[1] - group_psi_old[0]; // target potential difference from input parameters - if (group_psi_var_styles[0] != VarStyle::CONST) { + if (group_psi_var_styles[0] == VarStyle::EQUAL) { delta_psi_0 = input->variable->compute_equal(group_psi_var_ids[1]) - input->variable->compute_equal(group_psi_var_ids[0]); } diff --git a/src/ELECTRODE/pppm_electrode.cpp b/src/ELECTRODE/pppm_electrode.cpp index 0ae3da6863..ee34def74d 100644 --- a/src/ELECTRODE/pppm_electrode.cpp +++ b/src/ELECTRODE/pppm_electrode.cpp @@ -20,6 +20,7 @@ #include "angle.h" #include "atom.h" #include "bond.h" +#include "boundary_correction.h" #include "citeme.h" #include "comm.h" #include "domain.h" @@ -45,22 +46,14 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define MAXORDER 7 -#define OFFSET 16384 -#define LARGE 10000.0 -#define SMALL 0.00001 -#define EPS_HOC 1.0e-7 +static constexpr int MAXORDER = 7; +static constexpr int OFFSET = 16384; +static constexpr double EPS_HOC = 1.0e-7; enum { REVERSE_RHO }; enum { FORWARD_IK, FORWARD_AD, FORWARD_IK_PERATOM, FORWARD_AD_PERATOM }; -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#define ONEF 1.0f -#else -#define ZEROF 0.0 -#define ONEF 1.0 -#endif +static constexpr FFT_SCALAR ZEROF = 0.0; static const char cite_pppm_electrode[] = "kspace_style pppm/electrode command:\n\n" @@ -445,6 +438,7 @@ void PPPMElectrode::compute(int eflag, int vflag) start_compute(); + /* if (compute_vector_called && last_invert_source) { // electrolyte_density_brick is filled, so we can grab only electrode atoms. // Does not work for direct cg algorithm because electrode charges change after compute_vector. @@ -460,15 +454,17 @@ void PPPMElectrode::compute(int eflag, int vflag) density_brick[nz][ny][nx] += electrolyte_density_brick[nz][ny][nx]; } } else { - make_rho(); + */ + particle_map(); + make_rho(); - // all procs communicate density values from their ghost cells - // to fully sum contribution in their 3d bricks - // remap from 3d decomposition to FFT decomposition + // all procs communicate density values from their ghost cells + // to fully sum contribution in their 3d bricks + // remap from 3d decomposition to FFT decomposition - gc->reverse_comm(Grid3d::KSPACE, this, REVERSE_RHO, 1, sizeof(FFT_SCALAR), gc_buf1, gc_buf2, - MPI_FFT_SCALAR); - } + gc->reverse_comm(Grid3d::KSPACE, this, REVERSE_RHO, 1, sizeof(FFT_SCALAR), gc_buf1, gc_buf2, + MPI_FFT_SCALAR); + //} brick2fft(); @@ -591,6 +587,7 @@ void PPPMElectrode::compute_vector(double *vec, int sensor_grpbit, int source_gr // electrolyte density (without writing an additional function) FFT_SCALAR ***density_brick_real = density_brick; FFT_SCALAR *density_fft_real = density_fft; + particle_map(); make_rho_in_brick(source_grpbit, electrolyte_density_brick, invert_source); density_brick = electrolyte_density_brick; density_fft = electrolyte_density_fft; @@ -676,7 +673,8 @@ void PPPMElectrode::compute_matrix(bigint *imat, double **matrix, bool timer_fla // fft green's function k -> r (double) double *greens_real; memory->create(greens_real, nz_pppm * ny_pppm * nx_pppm, "pppm/electrode:greens_real"); - memset(greens_real, 0, (std::size_t)nz_pppm * (std::size_t)ny_pppm * (std::size_t)nx_pppm * sizeof(double)); + memset(greens_real, 0, + (std::size_t) nz_pppm * (std::size_t) ny_pppm * (std::size_t) nx_pppm * sizeof(double)); for (int i = 0, n = 0; i < nfft; i++) { work2[n++] = greensfn[i]; work2[n++] = ZEROF; @@ -869,7 +867,7 @@ void PPPMElectrode::two_step_multiplication(bigint *imat, double *greens_real, d double **gw; memory->create(gw, nmat, nxyz, "pppm/electrode:gw"); - memset(&(gw[0][0]), 0, (std::size_t)nmat * (std::size_t)nxyz * sizeof(double)); + memset(&(gw[0][0]), 0, (std::size_t) nmat * (std::size_t) nxyz * sizeof(double)); auto fmod = [](int x, int n) { // fast unsigned mod int r = abs(x); @@ -988,17 +986,18 @@ void PPPMElectrode::allocate() // returns local owned and ghost grid bounds // setup communication patterns and buffers - gc = new Grid3d(lmp,world,nx_pppm,ny_pppm,nz_pppm, - nxlo_in,nxhi_in,nylo_in,nyhi_in,nzlo_in,nzhi_in, - nxlo_out,nxhi_out,nylo_out,nyhi_out,nzlo_out,nzhi_out); + gc = new Grid3d(lmp, world, nx_pppm, ny_pppm, nz_pppm, nxlo_in, nxhi_in, nylo_in, nyhi_in, + nzlo_in, nzhi_in, nxlo_out, nxhi_out, nylo_out, nyhi_out, nzlo_out, nzhi_out); - gc->setup_comm(ngc_buf1,ngc_buf2); + gc->setup_comm(ngc_buf1, ngc_buf2); - if (differentiation_flag) npergrid = 1; - else npergrid = 3; + if (differentiation_flag) + npergrid = 1; + else + npergrid = 3; - memory->create(gc_buf1,npergrid*ngc_buf1,"pppm:gc_buf1"); - memory->create(gc_buf2,npergrid*ngc_buf2,"pppm:gc_buf2"); + memory->create(gc_buf1, npergrid * ngc_buf1, "pppm:gc_buf1"); + memory->create(gc_buf2, npergrid * ngc_buf2, "pppm:gc_buf2"); // tally local grid sizes // ngrid = count of owned+ghost grid cells on this proc @@ -1007,67 +1006,63 @@ void PPPMElectrode::allocate() // nfft = FFT points in x-pencil FFT decomposition on this proc // nfft_both = greater of nfft and nfft_brick - ngrid = (nxhi_out-nxlo_out+1) * (nyhi_out-nylo_out+1) * - (nzhi_out-nzlo_out+1); + ngrid = (nxhi_out - nxlo_out + 1) * (nyhi_out - nylo_out + 1) * (nzhi_out - nzlo_out + 1); - nfft_brick = (nxhi_in-nxlo_in+1) * (nyhi_in-nylo_in+1) * - (nzhi_in-nzlo_in+1); + nfft_brick = (nxhi_in - nxlo_in + 1) * (nyhi_in - nylo_in + 1) * (nzhi_in - nzlo_in + 1); - nfft = (nxhi_fft-nxlo_fft+1) * (nyhi_fft-nylo_fft+1) * - (nzhi_fft-nzlo_fft+1); + nfft = (nxhi_fft - nxlo_fft + 1) * (nyhi_fft - nylo_fft + 1) * (nzhi_fft - nzlo_fft + 1); - nfft_both = MAX(nfft,nfft_brick); + nfft_both = MAX(nfft, nfft_brick); // allocate distributed grid data - memory->create3d_offset(density_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out, - nxlo_out,nxhi_out,"pppm:density_brick"); + memory->create3d_offset(density_brick, nzlo_out, nzhi_out, nylo_out, nyhi_out, nxlo_out, nxhi_out, + "pppm:density_brick"); - memory->create(density_fft,nfft_both,"pppm:density_fft"); - memory->create(greensfn,nfft_both,"pppm:greensfn"); - memory->create(work1,2*nfft_both,"pppm:work1"); - memory->create(work2,2*nfft_both,"pppm:work2"); - memory->create(vg,nfft_both,6,"pppm:vg"); + memory->create(density_fft, nfft_both, "pppm:density_fft"); + memory->create(greensfn, nfft_both, "pppm:greensfn"); + memory->create(work1, 2 * nfft_both, "pppm:work1"); + memory->create(work2, 2 * nfft_both, "pppm:work2"); + memory->create(vg, nfft_both, 6, "pppm:vg"); if (triclinic == 0) { - memory->create1d_offset(fkx,nxlo_fft,nxhi_fft,"pppm:fkx"); - memory->create1d_offset(fky,nylo_fft,nyhi_fft,"pppm:fky"); - memory->create1d_offset(fkz,nzlo_fft,nzhi_fft,"pppm:fkz"); + memory->create1d_offset(fkx, nxlo_fft, nxhi_fft, "pppm:fkx"); + memory->create1d_offset(fky, nylo_fft, nyhi_fft, "pppm:fky"); + memory->create1d_offset(fkz, nzlo_fft, nzhi_fft, "pppm:fkz"); } else { - memory->create(fkx,nfft_both,"pppm:fkx"); - memory->create(fky,nfft_both,"pppm:fky"); - memory->create(fkz,nfft_both,"pppm:fkz"); + memory->create(fkx, nfft_both, "pppm:fkx"); + memory->create(fky, nfft_both, "pppm:fky"); + memory->create(fkz, nfft_both, "pppm:fkz"); } if (differentiation_flag == 1) { - memory->create3d_offset(u_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out, - nxlo_out,nxhi_out,"pppm:u_brick"); + memory->create3d_offset(u_brick, nzlo_out, nzhi_out, nylo_out, nyhi_out, nxlo_out, nxhi_out, + "pppm:u_brick"); - memory->create(sf_precoeff1,nfft_both,"pppm:sf_precoeff1"); - memory->create(sf_precoeff2,nfft_both,"pppm:sf_precoeff2"); - memory->create(sf_precoeff3,nfft_both,"pppm:sf_precoeff3"); - memory->create(sf_precoeff4,nfft_both,"pppm:sf_precoeff4"); - memory->create(sf_precoeff5,nfft_both,"pppm:sf_precoeff5"); - memory->create(sf_precoeff6,nfft_both,"pppm:sf_precoeff6"); + memory->create(sf_precoeff1, nfft_both, "pppm:sf_precoeff1"); + memory->create(sf_precoeff2, nfft_both, "pppm:sf_precoeff2"); + memory->create(sf_precoeff3, nfft_both, "pppm:sf_precoeff3"); + memory->create(sf_precoeff4, nfft_both, "pppm:sf_precoeff4"); + memory->create(sf_precoeff5, nfft_both, "pppm:sf_precoeff5"); + memory->create(sf_precoeff6, nfft_both, "pppm:sf_precoeff6"); } else { - memory->create3d_offset(vdx_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out, - nxlo_out,nxhi_out,"pppm:vdx_brick"); - memory->create3d_offset(vdy_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out, - nxlo_out,nxhi_out,"pppm:vdy_brick"); - memory->create3d_offset(vdz_brick,nzlo_out,nzhi_out,nylo_out,nyhi_out, - nxlo_out,nxhi_out,"pppm:vdz_brick"); + memory->create3d_offset(vdx_brick, nzlo_out, nzhi_out, nylo_out, nyhi_out, nxlo_out, nxhi_out, + "pppm:vdx_brick"); + memory->create3d_offset(vdy_brick, nzlo_out, nzhi_out, nylo_out, nyhi_out, nxlo_out, nxhi_out, + "pppm:vdy_brick"); + memory->create3d_offset(vdz_brick, nzlo_out, nzhi_out, nylo_out, nyhi_out, nxlo_out, nxhi_out, + "pppm:vdz_brick"); } // summation coeffs order_allocated = order; - if (!stagger_flag) memory->create(gf_b,order,"pppm:gf_b"); - memory->create2d_offset(rho1d,3,-order/2,order/2,"pppm:rho1d"); - memory->create2d_offset(drho1d,3,-order/2,order/2,"pppm:drho1d"); - memory->create2d_offset(rho_coeff,order,(1-order)/2,order/2,"pppm:rho_coeff"); - memory->create2d_offset(drho_coeff,order,(1-order)/2,order/2, - "pppm:drho_coeff"); + if (!stagger_flag) memory->create(gf_b, order, "pppm:gf_b"); + memory->create2d_offset(rho1d, 3, -order / 2, order / 2, "pppm:rho1d"); + memory->create2d_offset(drho1d, 3, -order / 2, order / 2, "pppm:drho1d"); + memory->create2d_offset(rho_coeff, order, (1 - order) / 2, order / 2, "pppm:rho_coeff"); + memory->create2d_offset(drho_coeff, order, (1 - order) / 2, order / 2, "pppm:drho_coeff"); // create 2 FFTs and a Remap // 1st FFT keeps data in FFT decomposition @@ -1076,20 +1071,17 @@ void PPPMElectrode::allocate() int tmp; - fft1 = new FFT3d(lmp,world,nx_pppm,ny_pppm,nz_pppm, - nxlo_fft,nxhi_fft,nylo_fft,nyhi_fft,nzlo_fft,nzhi_fft, - nxlo_fft,nxhi_fft,nylo_fft,nyhi_fft,nzlo_fft,nzhi_fft, - 0,0,&tmp,collective_flag); + fft1 = new FFT3d(lmp, world, nx_pppm, ny_pppm, nz_pppm, nxlo_fft, nxhi_fft, nylo_fft, nyhi_fft, + nzlo_fft, nzhi_fft, nxlo_fft, nxhi_fft, nylo_fft, nyhi_fft, nzlo_fft, nzhi_fft, + 0, 0, &tmp, collective_flag); - fft2 = new FFT3d(lmp,world,nx_pppm,ny_pppm,nz_pppm, - nxlo_fft,nxhi_fft,nylo_fft,nyhi_fft,nzlo_fft,nzhi_fft, - nxlo_in,nxhi_in,nylo_in,nyhi_in,nzlo_in,nzhi_in, - 0,0,&tmp,collective_flag); + fft2 = new FFT3d(lmp, world, nx_pppm, ny_pppm, nz_pppm, nxlo_fft, nxhi_fft, nylo_fft, nyhi_fft, + nzlo_fft, nzhi_fft, nxlo_in, nxhi_in, nylo_in, nyhi_in, nzlo_in, nzhi_in, 0, 0, + &tmp, collective_flag); - remap = new Remap(lmp,world, - nxlo_in,nxhi_in,nylo_in,nyhi_in,nzlo_in,nzhi_in, - nxlo_fft,nxhi_fft,nylo_fft,nyhi_fft,nzlo_fft,nzhi_fft, - 1,0,0,FFT_PRECISION,collective_flag); + remap = new Remap(lmp, world, nxlo_in, nxhi_in, nylo_in, nyhi_in, nzlo_in, nzhi_in, nxlo_fft, + nxhi_fft, nylo_fft, nyhi_fft, nzlo_fft, nzhi_fft, 1, 0, 0, FFT_PRECISION, + collective_flag); // ELECTRODE specific allocations diff --git a/src/ELECTRODE/slab_dipole.cpp b/src/ELECTRODE/slab_dipole.cpp index d5f3eae7aa..27ec42a8b5 100644 --- a/src/ELECTRODE/slab_dipole.cpp +++ b/src/ELECTRODE/slab_dipole.cpp @@ -28,7 +28,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.00001 +static constexpr double SMALL = 0.00001; /* ---------------------------------------------------------------------- Slab-geometry correction term to dampen inter-slab interactions between diff --git a/src/EXTRA-COMPUTE/compute_adf.cpp b/src/EXTRA-COMPUTE/compute_adf.cpp index 35ff8bfd33..20b1749fa9 100644 --- a/src/EXTRA-COMPUTE/compute_adf.cpp +++ b/src/EXTRA-COMPUTE/compute_adf.cpp @@ -34,32 +34,27 @@ #include using namespace LAMMPS_NS; -using namespace MathConst; +using MathConst::MY_PI; +using MathConst::RAD2DEG; -enum{DEGREE, RADIAN, COSINE}; +enum { DEGREE, RADIAN, COSINE }; /* ---------------------------------------------------------------------- compute angular distribution functions for I, J, K atoms ---------------------------------------------------------------------- */ ComputeADF::ComputeADF(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg), - ilo(nullptr), ihi(nullptr), jlo(nullptr), jhi(nullptr), klo(nullptr), khi(nullptr), - hist(nullptr), histall(nullptr), - rcutinnerj(nullptr), rcutinnerk(nullptr), - rcutouterj(nullptr), rcutouterk(nullptr), - list(nullptr), - iatomcount(nullptr), iatomcountall(nullptr), iatomflag(nullptr), - maxjatom(nullptr), maxkatom(nullptr), - numjatom(nullptr), numkatom(nullptr), - neighjatom(nullptr),neighkatom(nullptr), - jatomflag(nullptr), katomflag(nullptr), - maxjkatom(nullptr), numjkatom(nullptr), - neighjkatom(nullptr), bothjkatom(nullptr), delrjkatom(nullptr) + Compute(lmp, narg, arg), ilo(nullptr), ihi(nullptr), jlo(nullptr), jhi(nullptr), klo(nullptr), + khi(nullptr), hist(nullptr), histall(nullptr), rcutinnerj(nullptr), rcutinnerk(nullptr), + rcutouterj(nullptr), rcutouterk(nullptr), list(nullptr), iatomcount(nullptr), + iatomcountall(nullptr), iatomflag(nullptr), maxjatom(nullptr), maxkatom(nullptr), + numjatom(nullptr), numkatom(nullptr), neighjatom(nullptr), neighkatom(nullptr), + jatomflag(nullptr), katomflag(nullptr), maxjkatom(nullptr), numjkatom(nullptr), + neighjkatom(nullptr), bothjkatom(nullptr), delrjkatom(nullptr) { int nargsperadf = 7; - if (narg < 4 ) error->all(FLERR,"Illegal compute adf command"); + if (narg < 4) utils::missing_cmd_args(FLERR, "compute adf", error); array_flag = 1; extarray = 0; @@ -89,17 +84,16 @@ ComputeADF::ComputeADF(LAMMPS *lmp, int narg, char **arg) : if (strcmp(arg[iarg+1],"degree") == 0) ordinate_style = DEGREE; else if (strcmp(arg[iarg+1],"radian") == 0) ordinate_style = RADIAN; else if (strcmp(arg[iarg+1],"cosine") == 0) ordinate_style = COSINE; - else error->all(FLERR,"Illegal compute adf command"); + else error->all(FLERR,"Unknown compute adf ordinate flag {}",arg[iarg+1]); iarg += 2; - } else error->all(FLERR,"Illegal compute adf command"); + } else error->all(FLERR,"Unknown compute adf keyword {}", arg[iarg]); } // triplewise args if (!nargtriple) ntriples = 1; else { - if (nargtriple % nargsperadf) - error->all(FLERR,"Illegal compute adf command"); + if (nargtriple % nargsperadf) error->all(FLERR,"Illegal compute adf command"); ntriples = nargtriple/nargsperadf; } @@ -107,12 +101,9 @@ ComputeADF::ComputeADF(LAMMPS *lmp, int narg, char **arg) : size_array_cols = 1 + 2*ntriples; int ntypes = atom->ntypes; - memory->create(iatomflag,ntriples,ntypes+1, - "adf:iatomflag"); - memory->create(jatomflag,ntriples,ntypes+1, - "adf:jatomflag"); - memory->create(katomflag,ntriples,ntypes+1, - "adf:katomflag"); + memory->create(iatomflag,ntriples,ntypes+1,"adf:iatomflag"); + memory->create(jatomflag,ntriples,ntypes+1,"adf:jatomflag"); + memory->create(katomflag,ntriples,ntypes+1,"adf:katomflag"); ilo = new int[ntriples]; ihi = new int[ntriples]; @@ -134,14 +125,14 @@ ComputeADF::ComputeADF(LAMMPS *lmp, int narg, char **arg) : klo[0] = 1; khi[0] = ntypes; } else { cutflag = 1; + if ((neighbor->style == Neighbor::MULTI) || (neighbor->style == Neighbor::MULTI_OLD)) + error->all(FLERR, "Compute adf with custom cutoffs requires neighbor style 'bin' or 'nsq'"); iarg = 4; for (int m = 0; m < ntriples; m++) { utils::bounds(FLERR,arg[iarg],1,atom->ntypes,ilo[m],ihi[m],error); utils::bounds(FLERR,arg[iarg+1],1,atom->ntypes,jlo[m],jhi[m],error); utils::bounds(FLERR,arg[iarg+2],1,atom->ntypes,klo[m],khi[m],error); - if (ilo[m] > ihi[m] || - jlo[m] > jhi[m] || - klo[m] > khi[m]) + if ((ilo[m] > ihi[m]) || (jlo[m] > jhi[m]) || (klo[m] > khi[m])) error->all(FLERR,"Illegal compute adf command"); rcutinnerj[m] = utils::numeric(FLERR,arg[iarg+3],false,lmp); rcutouterj[m] = utils::numeric(FLERR,arg[iarg+4],false,lmp); @@ -221,8 +212,6 @@ ComputeADF::ComputeADF(LAMMPS *lmp, int narg, char **arg) : memory->create(bothjkatom[m],maxjkatom[m],"adf:bothjkatom"); memory->create(delrjkatom[m],maxjkatom[m],4,"adf:delrjkatom"); } - - rad2deg = 180.0 / MY_PI; } /* ---------------------------------------------------------------------- */ @@ -230,47 +219,47 @@ ComputeADF::ComputeADF(LAMMPS *lmp, int narg, char **arg) : ComputeADF::~ComputeADF() { memory->destroy(iatomflag); - delete [] ilo; - delete [] ihi; - delete [] jlo; - delete [] jhi; - delete [] klo; - delete [] khi; - delete [] iatomcount; - delete [] iatomcountall; + delete[] ilo; + delete[] ihi; + delete[] jlo; + delete[] jhi; + delete[] klo; + delete[] khi; + delete[] iatomcount; + delete[] iatomcountall; memory->destroy(hist); memory->destroy(histall); memory->destroy(array); memory->destroy(jatomflag); - delete [] rcutinnerj; - delete [] rcutouterj; - delete [] maxjatom; - delete [] numjatom; + delete[] rcutinnerj; + delete[] rcutouterj; + delete[] maxjatom; + delete[] numjatom; for (int m = 0; m < ntriples; m++) memory->destroy(neighjatom[m]); - delete [] neighjatom; + delete[] neighjatom; memory->destroy(katomflag); - delete [] rcutinnerk; - delete [] rcutouterk; - delete [] maxkatom; - delete [] numkatom; + delete[] rcutinnerk; + delete[] rcutouterk; + delete[] maxkatom; + delete[] numkatom; for (int m = 0; m < ntriples; m++) memory->destroy(neighkatom[m]); - delete [] neighkatom; + delete[] neighkatom; - delete [] maxjkatom; - delete [] numjkatom; + delete[] maxjkatom; + delete[] numjkatom; for (int m = 0; m < ntriples; m++) memory->destroy(neighjkatom[m]); - delete [] neighjkatom; + delete[] neighjkatom; for (int m = 0; m < ntriples; m++) memory->destroy(bothjkatom[m]); - delete [] bothjkatom; + delete[] bothjkatom; for (int m = 0; m < ntriples; m++) memory->destroy(delrjkatom[m]); - delete [] delrjkatom; + delete[] delrjkatom; } /* ---------------------------------------------------------------------- */ @@ -282,8 +271,7 @@ void ComputeADF::init() if (!cutflag) { if (!force->pair) - error->all(FLERR,"Compute adf requires a pair style be defined " - "or an outer cutoff specified"); + error->all(FLERR,"Compute adf requires a pair style be defined or an outer cutoff specified"); rcutinnerj[0] = 0.0; rcutinnerk[0] = 0.0; rcutouterj[0] = force->pair->cutforce; @@ -298,7 +286,7 @@ void ComputeADF::init() // specify mycutneigh if force cutoff too small or non-existent - if (!(force->pair) || maxouter > force->pair->cutforce) { + if (!(force->pair) || (maxouter > force->pair->cutforce)) { double skin = neighbor->skin; mycutneigh = maxouter + skin; if (mycutneigh > comm->cutghostuser) @@ -310,7 +298,7 @@ void ComputeADF::init() int x0; if (ordinate_style == DEGREE) { - deltax = MY_PI / nbin * rad2deg; + deltax = MY_PI / nbin * RAD2DEG; deltaxinv = nbin / MY_PI; x0 = 0.0; @@ -337,7 +325,11 @@ void ComputeADF::init() // than maxouter apart, just like a normal neighbor list does auto req = neighbor->add_request(this, NeighConst::REQ_FULL | NeighConst::REQ_OCCASIONAL); - if (mycutneigh > 0.0) req->set_cutoff(mycutneigh); + if (mycutneigh > 0.0) { + if ((neighbor->style == Neighbor::MULTI) || (neighbor->style == Neighbor::MULTI_OLD)) + error->all(FLERR, "Compute adf with custom cutoffs requires neighbor style 'bin' or 'nsq'"); + req->set_cutoff(mycutneigh); + } } /* ---------------------------------------------------------------------- */ diff --git a/src/EXTRA-COMPUTE/compute_adf.h b/src/EXTRA-COMPUTE/compute_adf.h index 5f30995aa2..f1f95d325e 100644 --- a/src/EXTRA-COMPUTE/compute_adf.h +++ b/src/EXTRA-COMPUTE/compute_adf.h @@ -59,7 +59,6 @@ class ComputeADF : public Compute { int **bothjkatom; // 1 if atom is in both jatom and katom lists double ***delrjkatom; // list of 4-vectors: delx, dely, delx, and 1/r - double rad2deg; // conversion factor from radians to degrees int ordinate_style; // DEGREE, RADIAN, or COSINE int cutflag; // 1 if at least one outer cutoff specified }; diff --git a/src/EXTRA-COMPUTE/compute_ave_sphere_atom.cpp b/src/EXTRA-COMPUTE/compute_ave_sphere_atom.cpp index 89011e7177..b3b920fef3 100644 --- a/src/EXTRA-COMPUTE/compute_ave_sphere_atom.cpp +++ b/src/EXTRA-COMPUTE/compute_ave_sphere_atom.cpp @@ -33,7 +33,7 @@ #include using namespace LAMMPS_NS; -using namespace MathConst; +using MathConst::MY_PI; /* ---------------------------------------------------------------------- */ @@ -108,6 +108,9 @@ void ComputeAveSphereAtom::init() else volume = MY_PI * cutsq; + if ((neighbor->style == Neighbor::MULTI) || (neighbor->style == Neighbor::MULTI_OLD)) + error->all(FLERR, "Compute ave/sphere/atom requires neighbor style 'bin' or 'nsq'"); + // need an occasional full neighbor list auto req = neighbor->add_request(this, NeighConst::REQ_FULL | NeighConst::REQ_OCCASIONAL); diff --git a/src/EXTRA-COMPUTE/compute_born_matrix.cpp b/src/EXTRA-COMPUTE/compute_born_matrix.cpp index 4eecbbfa14..2e674409d1 100644 --- a/src/EXTRA-COMPUTE/compute_born_matrix.cpp +++ b/src/EXTRA-COMPUTE/compute_born_matrix.cpp @@ -42,8 +42,7 @@ using namespace LAMMPS_NS; -#define BIG 1000000000 -#define SMALL 1e-16 +static constexpr double SMALL = 1e-16; // this table is used to pick the 3d rij vector indices used to // compute the 6 indices long Voigt stress vector diff --git a/src/EXTRA-COMPUTE/compute_cnp_atom.cpp b/src/EXTRA-COMPUTE/compute_cnp_atom.cpp index 526874d7a4..f42d896f6b 100644 --- a/src/EXTRA-COMPUTE/compute_cnp_atom.cpp +++ b/src/EXTRA-COMPUTE/compute_cnp_atom.cpp @@ -41,8 +41,8 @@ using namespace LAMMPS_NS; //define maximum values -#define MAXNEAR 24 -#define MAXCOMMON 12 +static constexpr int MAXNEAR = 24; +static constexpr int MAXCOMMON = 12; enum{NCOMMON}; diff --git a/src/EXTRA-COMPUTE/compute_composition_atom.cpp b/src/EXTRA-COMPUTE/compute_composition_atom.cpp index 48aaa68dea..d36cb96028 100644 --- a/src/EXTRA-COMPUTE/compute_composition_atom.cpp +++ b/src/EXTRA-COMPUTE/compute_composition_atom.cpp @@ -19,7 +19,6 @@ #include "atom.h" #include "comm.h" -#include "domain.h" #include "error.h" #include "force.h" #include "math_const.h" @@ -103,6 +102,9 @@ void ComputeCompositionAtom::init() cutsq = cutoff * cutoff; + if ((neighbor->style == Neighbor::MULTI) || (neighbor->style == Neighbor::MULTI_OLD)) + error->all(FLERR, "Compute composition/atom requires neighbor style 'bin' or 'nsq'"); + // need an occasional full neighbor list auto req = neighbor->add_request(this, NeighConst::REQ_FULL | NeighConst::REQ_OCCASIONAL); diff --git a/src/EXTRA-COMPUTE/compute_dipole_tip4p_chunk.cpp b/src/EXTRA-COMPUTE/compute_dipole_tip4p_chunk.cpp index 571f1d562d..466bc0e882 100644 --- a/src/EXTRA-COMPUTE/compute_dipole_tip4p_chunk.cpp +++ b/src/EXTRA-COMPUTE/compute_dipole_tip4p_chunk.cpp @@ -16,7 +16,6 @@ #include "angle.h" #include "atom.h" #include "bond.h" -#include "comm.h" #include "compute_chunk_atom.h" #include "domain.h" #include "error.h" diff --git a/src/EXTRA-COMPUTE/compute_dipole_tip4p_chunk.h b/src/EXTRA-COMPUTE/compute_dipole_tip4p_chunk.h index b3354c9ab9..126f9962aa 100644 --- a/src/EXTRA-COMPUTE/compute_dipole_tip4p_chunk.h +++ b/src/EXTRA-COMPUTE/compute_dipole_tip4p_chunk.h @@ -23,7 +23,6 @@ ComputeStyle(dipole/tip4p/chunk,ComputeDipoleTIP4PChunk); #include "compute_chunk.h" namespace LAMMPS_NS { -class Fix; class ComputeDipoleTIP4PChunk : public ComputeChunk { public: diff --git a/src/EXTRA-COMPUTE/compute_efield_wolf_atom.cpp b/src/EXTRA-COMPUTE/compute_efield_wolf_atom.cpp index ba5a16d52b..ceb16de2ec 100644 --- a/src/EXTRA-COMPUTE/compute_efield_wolf_atom.cpp +++ b/src/EXTRA-COMPUTE/compute_efield_wolf_atom.cpp @@ -92,7 +92,11 @@ void ComputeEfieldWolfAtom::init() if (atom->mu_flag && (comm->me == 0)) error->warning(FLERR, "Compute efield/wolf/atom does not support per-atom dipoles"); - // need an occasional full neighbor list + if ((neighbor->style == Neighbor::MULTI) || (neighbor->style == Neighbor::MULTI_OLD)) + error->all(FLERR, "Compute efield/wolf/atom requires neighbor style 'bin' or 'nsq'"); + + // request an occasional full neighbor list + auto req = neighbor->add_request(this, NeighConst::REQ_FULL | NeighConst::REQ_OCCASIONAL); if (cutoff_flag) req->set_cutoff(cutoff); diff --git a/src/EXTRA-COMPUTE/compute_rattlers_atom.cpp b/src/EXTRA-COMPUTE/compute_rattlers_atom.cpp index 9dacf14171..5f707d8433 100644 --- a/src/EXTRA-COMPUTE/compute_rattlers_atom.cpp +++ b/src/EXTRA-COMPUTE/compute_rattlers_atom.cpp @@ -29,7 +29,6 @@ #include "pair.h" #include "update.h" -#include #include using namespace LAMMPS_NS; diff --git a/src/EXTRA-COMPUTE/compute_slcsa_atom.cpp b/src/EXTRA-COMPUTE/compute_slcsa_atom.cpp index 6c272938b6..e0b34b8ff1 100644 --- a/src/EXTRA-COMPUTE/compute_slcsa_atom.cpp +++ b/src/EXTRA-COMPUTE/compute_slcsa_atom.cpp @@ -22,12 +22,9 @@ #include "citeme.h" #include "comm.h" #include "error.h" -#include "force.h" #include "memory.h" #include "modify.h" #include "neigh_list.h" -#include "neighbor.h" -#include "pair.h" #include "potential_file_reader.h" #include "update.h" diff --git a/src/EXTRA-COMPUTE/compute_stress_cartesian.cpp b/src/EXTRA-COMPUTE/compute_stress_cartesian.cpp index e1bc6bcd91..622ea839be 100644 --- a/src/EXTRA-COMPUTE/compute_stress_cartesian.cpp +++ b/src/EXTRA-COMPUTE/compute_stress_cartesian.cpp @@ -32,7 +32,7 @@ using namespace LAMMPS_NS; -#define SMALL 1.0e-10 +static constexpr double SMALL = 1.0e-10; /*----------------------------------------------------------------------------------- Contributing author: Olav Galteland (Norwegian University of Science and Technology) olav.galteland@ntnu.no diff --git a/src/EXTRA-COMPUTE/compute_stress_mop.cpp b/src/EXTRA-COMPUTE/compute_stress_mop.cpp index 6c35b4ba07..ee8f5e554a 100644 --- a/src/EXTRA-COMPUTE/compute_stress_mop.cpp +++ b/src/EXTRA-COMPUTE/compute_stress_mop.cpp @@ -39,7 +39,7 @@ using namespace LAMMPS_NS; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; enum { X, Y, Z }; enum { TOTAL, CONF, KIN, PAIR, BOND, ANGLE, DIHEDRAL }; @@ -773,7 +773,7 @@ void ComputeStressMop::compute_angles() // only left bond crossing the plane - if (!right_cross && left_cross) { + else if (!right_cross && left_cross) { double sgn = copysign(1.0, x_angle_left[dir] - pos); dcos_theta[0] = -sgn * (dx_left[0] * cos_theta / r1 + dx_right[0] / r2) / r1; dcos_theta[1] = -sgn * (dx_left[1] * cos_theta / r1 + dx_right[1] / r2) / r1; @@ -782,7 +782,7 @@ void ComputeStressMop::compute_angles() // both bonds crossing the plane - if (right_cross && left_cross) { + else if (right_cross && left_cross) { // due to right bond @@ -1042,9 +1042,12 @@ void ComputeStressMop::compute_dihedrals() f3[1] = sy2 - f4[1]; f3[2] = sz2 - f4[2]; - // only right bond crossing the plane - if (right_cross && !middle_cross && !left_cross) - { + // no bonds crossing the plane + + if (!right_cross && !middle_cross && !left_cross) continue; + + // onPly right bond crossing the plane + if (right_cross && !middle_cross && !left_cross) { double sgn = copysign(1.0, x_atom_1[dir] - pos); df[0] = sgn * f1[0]; df[1] = sgn * f1[1]; @@ -1052,8 +1055,7 @@ void ComputeStressMop::compute_dihedrals() } // only middle bond crossing the plane - if (!right_cross && middle_cross && !left_cross) - { + else if (!right_cross && middle_cross && !left_cross) { double sgn = copysign(1.0, x_atom_2[dir] - pos); df[0] = sgn * (f2[0] + f1[0]); df[1] = sgn * (f2[1] + f1[1]); @@ -1061,8 +1063,7 @@ void ComputeStressMop::compute_dihedrals() } // only left bond crossing the plane - if (!right_cross && !middle_cross && left_cross) - { + else if (!right_cross && !middle_cross && left_cross) { double sgn = copysign(1.0, x_atom_4[dir] - pos); df[0] = sgn * f4[0]; df[1] = sgn * f4[1]; @@ -1070,8 +1071,7 @@ void ComputeStressMop::compute_dihedrals() } // only right & middle bonds crossing the plane - if (right_cross && middle_cross && !left_cross) - { + else if (right_cross && middle_cross && !left_cross) { double sgn = copysign(1.0, x_atom_2[dir] - pos); df[0] = sgn * f2[0]; df[1] = sgn * f2[1]; @@ -1079,8 +1079,7 @@ void ComputeStressMop::compute_dihedrals() } // only right & left bonds crossing the plane - if (right_cross && !middle_cross && left_cross) - { + else if (right_cross && !middle_cross && left_cross) { double sgn = copysign(1.0, x_atom_1[dir] - pos); df[0] = sgn * (f1[0] + f4[0]); df[1] = sgn * (f1[1] + f4[1]); @@ -1088,8 +1087,7 @@ void ComputeStressMop::compute_dihedrals() } // only middle & left bonds crossing the plane - if (!right_cross && middle_cross && left_cross) - { + else if (!right_cross && middle_cross && left_cross) { double sgn = copysign(1.0, x_atom_3[dir] - pos); df[0] = sgn * f3[0]; df[1] = sgn * f3[1]; @@ -1097,14 +1095,12 @@ void ComputeStressMop::compute_dihedrals() } // all three bonds crossing the plane - if (right_cross && middle_cross && left_cross) - { + else if (right_cross && middle_cross && left_cross) { double sgn = copysign(1.0, x_atom_1[dir] - pos); df[0] = sgn * (f1[0] + f3[0]); df[1] = sgn * (f1[1] + f3[1]); df[2] = sgn * (f1[2] + f3[2]); } - local_contribution[0] += df[0]/area*nktv2p; local_contribution[1] += df[1]/area*nktv2p; local_contribution[2] += df[2]/area*nktv2p; diff --git a/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp b/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp index 41b5f64a67..676b0f5796 100644 --- a/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp +++ b/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp @@ -39,7 +39,7 @@ using namespace LAMMPS_NS; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; enum { X, Y, Z }; enum { TOTAL, CONF, KIN, PAIR, BOND, ANGLE, DIHEDRAL }; diff --git a/src/EXTRA-COMPUTE/compute_stress_spherical.cpp b/src/EXTRA-COMPUTE/compute_stress_spherical.cpp index db20ab6706..983d31559d 100644 --- a/src/EXTRA-COMPUTE/compute_stress_spherical.cpp +++ b/src/EXTRA-COMPUTE/compute_stress_spherical.cpp @@ -34,7 +34,7 @@ using namespace MathConst; using MathSpecial::cube; using MathSpecial::square; -#define SMALL 1.0e-10 +static constexpr double SMALL = 1.0e-10; /*----------------------------------------------------------------------------------- Contributing author: Olav Galteland (Norwegian University of Science and Technology) diff --git a/src/EXTRA-FIX/fix_deform_pressure.cpp b/src/EXTRA-FIX/fix_deform_pressure.cpp new file mode 100644 index 0000000000..ffa3f11d92 --- /dev/null +++ b/src/EXTRA-FIX/fix_deform_pressure.cpp @@ -0,0 +1,940 @@ +// clang-format off +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + LAMMPS development team: developers@lammps.org + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing author: Joel Clemmer (SNL) +------------------------------------------------------------------------- */ + +#include "fix_deform_pressure.h" + +#include "comm.h" +#include "compute.h" +#include "domain.h" +#include "error.h" +#include "group.h" +#include "input.h" +#include "irregular.h" +#include "math_const.h" +#include "modify.h" +#include "update.h" +#include "variable.h" + +#include +#include + +using namespace LAMMPS_NS; +using namespace FixConst; +using namespace MathConst; + +enum { NOCOUPLE = 0, XYZ, XY, YZ, XZ }; + +/* ---------------------------------------------------------------------- */ + +FixDeformPressure::FixDeformPressure(LAMMPS *lmp, int narg, char **arg) : + FixDeform(lmp, narg, arg), id_temp(nullptr), id_press(nullptr), temperature(nullptr), + pressure(nullptr) +{ + // set defaults + + set_extra = new SetExtra[7]; + memset(set_extra, 0, 7 * sizeof(SetExtra)); + memset(&set_box, 0, sizeof(Set)); + + // parse only parameter/style arguments specific to this child class + + int index, iarg; + std::size_t i = 0; + while (i < leftover_iarg.size()) { + iarg = leftover_iarg[i]; + if (strcmp(arg[iarg], "x") == 0 || + strcmp(arg[iarg], "y") == 0 || + strcmp(arg[iarg], "z") == 0) { + + if (strcmp(arg[iarg], "x") == 0) index = 0; + else if (strcmp(arg[iarg], "y") == 0) index = 1; + else if (strcmp(arg[iarg], "z") == 0) index = 2; + + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "fix deform/pressure", error); + if (strcmp(arg[iarg + 1], "pressure") == 0) { + if (iarg + 4 > narg) utils::missing_cmd_args(FLERR, "fix deform/pressure pressure", error); + set[index].style = PRESSURE; + if (strstr(arg[iarg + 2], "v_") != arg[iarg + 2]) { + set_extra[index].ptarget = utils::numeric(FLERR, arg[iarg + 2], false, lmp); + } else { + set_extra[index].pstr = utils::strdup(&arg[iarg + 2][2]); + set_extra[index].pvar_flag = 1; + } + set_extra[index].pgain = utils::numeric(FLERR, arg[iarg + 3], false, lmp); + i += 4; + } else if (strcmp(arg[iarg + 1], "pressure/mean") == 0) { + if (iarg + 4 > narg) utils::missing_cmd_args(FLERR, "fix deform/pressure pressure/mean", error); + set[index].style = PMEAN; + if (strstr(arg[iarg + 2], "v_") != arg[iarg + 2]) { + set_extra[index].ptarget = utils::numeric(FLERR, arg[iarg + 2], false, lmp); + } else { + set_extra[index].pstr = utils::strdup(&arg[iarg + 2][2]); + set_extra[index].pvar_flag = 1; + } + set_extra[index].pgain = utils::numeric(FLERR, arg[iarg + 3], false, lmp); + i += 4; + } else error->all(FLERR, "Illegal fix deform/pressure command argument: {}", arg[iarg + 1]); + + } else if (strcmp(arg[iarg], "xy") == 0 || + strcmp(arg[iarg], "xz") == 0 || + strcmp(arg[iarg], "yz") == 0) { + + if (strcmp(arg[iarg], "xy") == 0) index = 5; + else if (strcmp(arg[iarg], "xz") == 0) index = 4; + else if (strcmp(arg[iarg], "yz") == 0) index = 3; + + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "fix deform/pressure", error); + if (strcmp(arg[iarg + 1], "pressure") == 0) { + if (iarg + 4 > narg) utils::missing_cmd_args(FLERR, "fix deform/pressure pressure", error); + set[index].style = PRESSURE; + if (strstr(arg[iarg + 2], "v_") != arg[iarg + 2]) { + set_extra[index].ptarget = utils::numeric(FLERR, arg[iarg + 2], false, lmp); + } else { + set_extra[index].pstr = utils::strdup(&arg[iarg + 2][2]); + set_extra[index].pvar_flag = 1; + } + set_extra[index].pgain = utils::numeric(FLERR, arg[iarg + 3], false, lmp); + i += 4; + } else error->all(FLERR, "Illegal fix deform/pressure command: {}", arg[iarg + 1]); + + } else if (strcmp(arg[iarg], "box") == 0) { + if (strcmp(arg[iarg + 1], "volume") == 0) { + set_box.style = VOLUME; + i += 2; + } else if (strcmp(arg[iarg + 1], "pressure") == 0) { + if (iarg + 4 > narg) utils::missing_cmd_args(FLERR, "fix deform/pressure pressure", error); + set_box.style = PRESSURE; + if (strstr(arg[iarg + 2], "v_") != arg[iarg + 2]) { + set_extra[6].ptarget = utils::numeric(FLERR, arg[iarg + 2], false, lmp); + } else { + set_extra[6].pstr = utils::strdup(&arg[iarg + 2][2]); + set_extra[6].pvar_flag = 1; + } + set_extra[6].pgain = utils::numeric(FLERR, arg[iarg + 3], false, lmp); + i += 4; + } else error->all(FLERR, "Illegal fix deform/pressure command argument: {}", arg[iarg + 1]); + } else break; + } + + // read options from end of input line + // shift arguments before reading + + iarg = iarg_options_start; + options(i, narg - iarg, &arg[iarg]); + + // repeat: setup dimflags used by other classes to check for volume-change conflicts + + for (int i = 0; i < 6; i++) + if (set[i].style == NONE) dimflag[i] = 0; + else dimflag[i] = 1; + + if (set_box.style != NONE) { + dimflag[0] = 1; + dimflag[1] = 1; + dimflag[2] = 1; + } + + if (dimflag[0]) box_change |= BOX_CHANGE_X; + if (dimflag[1]) box_change |= BOX_CHANGE_Y; + if (dimflag[2]) box_change |= BOX_CHANGE_Z; + if (dimflag[3]) box_change |= BOX_CHANGE_YZ; + if (dimflag[4]) box_change |= BOX_CHANGE_XZ; + if (dimflag[5]) box_change |= BOX_CHANGE_XY; + + // repeat: no tensile deformation on shrink-wrapped dims + // b/c shrink wrap will change box-length + + for (int i = 0; i < 3; i++) + if (set_box.style && (domain->boundary[i][0] >= 2 || domain->boundary[i][1] >= 2)) + error->all(FLERR, "Cannot use fix deform/pressure on a shrink-wrapped boundary"); + + // repeat: no tilt deformation on shrink-wrapped 2nd dim + // b/c shrink wrap will change tilt factor in domain::reset_box() + + if (set[3].style && (domain->boundary[2][0] >= 2 || domain->boundary[2][1] >= 2)) + error->all(FLERR, "Cannot use fix deform/pressure tilt on a shrink-wrapped 2nd dim"); + if (set[4].style && (domain->boundary[2][0] >= 2 || domain->boundary[2][1] >= 2)) + error->all(FLERR, "Cannot use fix deform/pressure tilt on a shrink-wrapped 2nd dim"); + if (set[5].style && (domain->boundary[1][0] >= 2 || domain->boundary[1][1] >= 2)) + error->all(FLERR, "Cannot use fix deform/pressure tilt on a shrink-wrapped 2nd dim"); + + // for VOLUME, setup links to other dims + // fixed, dynamic1, dynamic2 + + for (int i = 0; i < 3; i++) { + if (set[i].style != VOLUME) continue; + int other1 = (i + 1) % 3; + int other2 = (i + 2) % 3; + + // Cannot use VOLUME option without at least one deformed dimension + if (set[other1].style == NONE || set[other1].style == VOLUME) + if (set[other2].style == NONE || set[other2].style == VOLUME) + error->all(FLERR, "Fix {} volume setting is invalid", style); + + if (set[other1].style == NONE) { + set[i].substyle = ONE_FROM_ONE; + set[i].fixed = other1; + set[i].dynamic1 = other2; + } else if (set[other2].style == NONE) { + set[i].substyle = ONE_FROM_ONE; + set[i].fixed = other2; + set[i].dynamic1 = other1; + } else if (set[other1].style == VOLUME) { + set[i].substyle = TWO_FROM_ONE; + set[i].fixed = other1; + set[i].dynamic1 = other2; + } else if (set[other2].style == VOLUME) { + set[i].substyle = TWO_FROM_ONE; + set[i].fixed = other2; + set[i].dynamic1 = other1; + } else { + set[i].substyle = ONE_FROM_TWO; + set[i].dynamic1 = other1; + set[i].dynamic2 = other2; + } + } + + // repeat: set varflag + + for (int i = 0; i < 7; i++) + if (set_extra[i].pvar_flag) varflag = 1; + + // repeat: reneighboring only forced if flips can occur due to shape changes + + if ((!force_reneighbor) && flipflag && (set[3].style || set[4].style || set[5].style)) { + force_reneighbor = 1; + irregular = new Irregular(lmp); + } + + // set initial values at time fix deform/pressure is issued + + set_box.vol_initial = domain->xprd * domain->yprd * domain->zprd; + + // populate coupled pressure controls + + if (pcouple != NOCOUPLE) { + + if (domain->dimension == 2) + if (pcouple == XYZ || pcouple == XZ || pcouple == YZ) + error->all(FLERR, "Cannot couple Z dimension in fix deform/pressure in 2D"); + + int coupled_indices[3] = {0}; + int j = -1; + + if (pcouple == XYZ || pcouple == XY || pcouple == XZ) + coupled_indices[0] = 1; + if (pcouple == XYZ || pcouple == XY || pcouple == YZ) + coupled_indices[1] = 1; + if (pcouple == XYZ || pcouple == XZ || pcouple == YZ) + coupled_indices[2] = 1; + + // Check coupled styles and find reference + for (int i = 0; i < 3; i++) { + if (coupled_indices[i]) { + set_extra[i].coupled_flag = 1; + if (set[i].style != PRESSURE && set[i].style != NONE) + error->all(FLERR, "Cannot couple non-pressure-controlled dimensions"); + if (set[i].style == PRESSURE) + j = i; + } + } + + if (j == -1) + error->all(FLERR, "Must specify deformation style for at least one coupled dimension"); + + // Copy or compare data for each coupled dimension + + for (int i = 0; i < 3; i++) { + if (coupled_indices[i]) { + // Copy coupling information if dimension style is undefined + if (set[i].style == NONE) { + set[i].style = PRESSURE; + dimflag[i] = 1; + set_extra[i].pgain = set_extra[j].pgain; + if (set_extra[j].pvar_flag) { + set_extra[i].pstr = set_extra[j].pstr; + set_extra[i].pvar_flag = 1; + } else { + set_extra[i].ptarget = set_extra[j].ptarget; + } + } else { + // Check for incompatibilities in style + if (set[j].style != set[i].style && set[i].style != NONE) + error->all(FLERR, "Cannot couple dimensions with different control options"); + if (set[j].style != PRESSURE) continue; + + // If pressure controlled, check for incompatibilities in parameters + if (set_extra[i].pgain != set_extra[j].pgain || set_extra[i].pvar_flag != set_extra[j].pvar_flag || + set_extra[i].ptarget != set_extra[j].ptarget) + error->all(FLERR, "Coupled dimensions must have identical gain parameters"); + + if (set_extra[j].pvar_flag) + if (strcmp(set_extra[i].pstr, set_extra[j].pstr) != 0) + error->all(FLERR, "Coupled dimensions must have the same target pressure"); + } + } + } + } + + // if vol/balance/p used, must have 2 free dimensions + + if (vol_balance_flag) { + for (int i = 0; i < 3; i++) { + if (set[i].style != VOLUME) continue; + if (set[i].substyle != TWO_FROM_ONE) + error->all(FLERR, "Two dimensions must maintain constant volume to use the vol/balance/p option"); + } + } + + // set strain_flag + + strain_flag = 0; + for (int i = 0; i < 6; i++) + if (set[i].style != NONE && set[i].style != VOLUME && + set[i].style != PRESSURE && set[i].style != PMEAN) + strain_flag = 1; + + // set pressure_flag + + pressure_flag = 0; + for (int i = 0; i < 6; i++) { + if (set[i].style == PRESSURE || set[i].style == PMEAN) { + pressure_flag = 1; + if (set_extra[i].pgain <= 0.0) + error->all(FLERR, "Illegal fix deform/pressure gain constant, must be positive"); + } + if (set_extra[i].coupled_flag) pressure_flag = 1; + } + if (set_box.style == PRESSURE) pressure_flag = 1; + if (vol_balance_flag) pressure_flag = 1; + + // check conflict between constant volume/pressure + + volume_flag = 0; + for (int i = 0; i < 3; i++) + if (set[i].style == VOLUME) + volume_flag = 1; + + if (volume_flag) + for (int i = 0; i < 6; i++) + if (set[i].style == PMEAN) + error->all(FLERR, "Cannot use fix deform/pressure to assign constant volume and pressure"); + + // check conflicts between x,y,z styles and box + + if (set_box.style) + for (int i = 0; i < 3; i++) + if (set[i].style == FINAL || set[i].style == DELTA || set[i].style == SCALE || set[i].style == PMEAN || set[i].style == VARIABLE) + error->all(FLERR, "Cannot use fix deform/pressure box parameter with x, y, or z styles other than vel, erate, trate, pressure, and wiggle"); + + // check pressure used for max rate and normalize error flag + + if (!pressure_flag && max_h_rate != 0) + error->all(FLERR, "Can only assign a maximum strain rate using pressure-controlled dimensions"); + + if (!pressure_flag && normalize_pressure_flag) + error->all(FLERR, "Can only normalize error using pressure-controlled dimensions"); + + // Create pressure compute, if needed + + pflag = 0; + tflag = 0; + if (pressure_flag) { + // create a new compute temp style + // id = fix-ID + temp + // compute group = all since pressure is always global (group all) + // and thus its KE/temperature contribution should use group all + + id_temp = utils::strdup(std::string(id) + "_temp"); + temperature = modify->add_compute(fmt::format("{} all temp", id_temp)); + tflag = 1; + + // create a new compute pressure style + // id = fix-ID + press, compute group = all + // pass id_temp as 4th arg to pressure constructor + + id_press = utils::strdup(std::string(id) + "_press"); + pressure = modify->add_compute(fmt::format("{} all pressure {}", id_press, id_temp)); + pflag = 1; + } +} + +/* ---------------------------------------------------------------------- */ + +FixDeformPressure::~FixDeformPressure() +{ + if (set_extra) + for (int i = 0; i < 7; i++) + delete[] set_extra[i].pstr; + delete[] set_extra; + + delete[] set_box.hstr; + delete[] set_box.hratestr; + + // delete temperature and pressure if fix created them + + if (tflag) modify->delete_compute(id_temp); + if (pflag) modify->delete_compute(id_press); + delete [] id_temp; + delete [] id_press; +} + +/* ---------------------------------------------------------------------- */ + +void FixDeformPressure::init() +{ + FixDeform::init(); + + set_box.vol_start = domain->xprd * domain->yprd * domain->zprd; + + // check optional variables for PRESSURE or PMEAN style + + for (int i = 0; i < 7; i++) { + if (!set_extra[i].pvar_flag) continue; + set_extra[i].pvar = input->variable->find(set_extra[i].pstr); + if (set_extra[i].pvar < 0) + error->all(FLERR, "Variable name {} for fix deform/pressure does not exist", set_extra[i].pstr); + if (!input->variable->equalstyle(set_extra[i].pvar)) + error->all(FLERR, "Variable {} for fix deform/pressure is invalid style", set_extra[i].pstr); + } + + // Find pressure/temp computes if needed + + if (pressure_flag) { + temperature = modify->get_compute_by_id(id_temp); + if (!temperature) + error->all(FLERR, "Temperature ID {} for fix deform/pressure does not exist", id_temp); + + pressure = modify->get_compute_by_id(id_press); + if (!pressure) + error->all(FLERR, "Pressure ID {} for fix deform/pressure does not exist", id_press); + } +} + +/* ---------------------------------------------------------------------- + compute T,P if needed before integrator starts +------------------------------------------------------------------------- */ + +void FixDeformPressure::setup(int /*vflag*/) +{ + // trigger virial computation on next timestep + if (pressure_flag) pressure->addstep(update->ntimestep+1); +} + +/* ---------------------------------------------------------------------- */ + +void FixDeformPressure::end_of_step() +{ + // wrap variable evaluations with clear/add + + if (varflag) modify->clearstep_compute(); + + // set new box size for strain-based dims + + if (strain_flag) FixDeform::apply_strain(); + + // set new box size for pressure-based dims + + if (pressure_flag) { + temperature->compute_vector(); + pressure->compute_vector(); + pressure->compute_scalar(); + for (int i = 0; i < 3; i++) { + if (!set_extra[i].saved) { + set_extra[i].saved = 1; + set_extra[i].prior_rate = 0.0; + set_extra[i].prior_pressure = pressure->vector[i]; + } + } + apply_pressure(); + } + + // set new box size for VOLUME dims that are linked to other dims + // NOTE: still need to set h_rate for these dims + + if (volume_flag) apply_volume(); + + // apply any final box scalings + + if (set_box.style) apply_box(); + + // Save pressure/strain rate if required + + if (pressure_flag) { + for (int i = 0; i < 3; i++) { + set_extra[i].prior_pressure = pressure->vector[i]; + set_extra[i].prior_rate = ((set[i].hi_target - set[i].lo_target) / + (domain->boxhi[i] - domain->boxlo[i]) - 1.0) / update->dt; + } + } + + if (varflag) modify->addstep_compute(update->ntimestep + nevery); + + + FixDeform::update_domain(); + + // trigger virial computation, if needed, on next timestep + + if (pressure_flag) + pressure->addstep(update->ntimestep+1); +} + +/* ---------------------------------------------------------------------- + apply pressure controls +------------------------------------------------------------------------- */ + +void FixDeformPressure::apply_pressure() +{ + // If variable pressure, calculate current target + for (int i = 0; i < 6; i++) + if (set[i].style == PRESSURE) + if (set_extra[i].pvar_flag) + set_extra[i].ptarget = input->variable->compute_equal(set_extra[i].pvar); + + // Find current (possibly coupled/hydrostatic) pressure for X, Y, Z + double *tensor = pressure->vector; + double scalar = pressure->scalar; + double p_current[3] = {0.0, 0.0, 0.0}; + + if (pcouple == XYZ) { + double ave = THIRD * (tensor[0] + tensor[1] + tensor[2]); + p_current[0] = p_current[1] = p_current[2] = ave; + } else if (pcouple == XY) { + double ave = 0.5 * (tensor[0] + tensor[1]); + p_current[0] = p_current[1] = ave; + p_current[2] = tensor[2]; + } else if (pcouple == YZ) { + double ave = 0.5 * (tensor[1] + tensor[2]); + p_current[1] = p_current[2] = ave; + p_current[0] = tensor[0]; + } else if (pcouple == XZ) { + double ave = 0.5 * (tensor[0] + tensor[2]); + p_current[0] = p_current[2] = ave; + p_current[1] = tensor[1]; + } else { + if (set[0].style == PRESSURE) p_current[0] = tensor[0]; + else if (set[0].style == PMEAN) p_current[0] = scalar; + + if (set[1].style == PRESSURE) p_current[1] = tensor[1]; + else if (set[1].style == PMEAN) p_current[1] = scalar; + + if (set[2].style == PRESSURE) p_current[2] = tensor[2]; + else if (set[2].style == PMEAN) p_current[2] = scalar; + } + + for (int i = 0; i < 3; i++) { + if (set[i].style != PRESSURE && set[i].style != PMEAN) continue; + + h_rate[i] = set_extra[i].pgain * (p_current[i] - set_extra[i].ptarget); + + if (normalize_pressure_flag) { + if (set_extra[i].ptarget == 0) { + if (max_h_rate == 0) { + error->all(FLERR, "Cannot normalize error for zero pressure without defining a max rate"); + } else h_rate[i] = max_h_rate * h_rate[i] / fabs(h_rate[i]); + } else h_rate[i] /= fabs(set_extra[i].ptarget); + } + + if (max_h_rate != 0) + if (fabs(h_rate[i]) > max_h_rate) + h_rate[i] = max_h_rate * h_rate[i] / fabs(h_rate[i]); + + h_ratelo[i] = -0.5 * h_rate[i]; + + double offset = 0.5 * (domain->boxhi[i] - domain->boxlo[i]) * (1.0 + update->dt * h_rate[i]); + set[i].lo_target = 0.5 * (set[i].lo_start + set[i].hi_start) - offset; + set[i].hi_target = 0.5 * (set[i].lo_start + set[i].hi_start) + offset; + } + + for (int i = 3; i < 6; i++) { + if (set[i].style != PRESSURE) continue; + + double L, tilt, pcurrent; + if (i == 3) { + L = domain->zprd; + tilt = domain->yz; + pcurrent = tensor[5]; + } else if (i == 4) { + L = domain->zprd; + tilt = domain->xz + update->dt; + pcurrent = tensor[4]; + } else { + L = domain->yprd; + tilt = domain->xy; + pcurrent = tensor[3]; + } + + h_rate[i] = L * set_extra[i].pgain * (pcurrent - set_extra[i].ptarget); + if (normalize_pressure_flag) { + if (set_extra[i].ptarget == 0) { + if (max_h_rate == 0) { + error->all(FLERR, "Cannot normalize error for zero pressure without defining a max rate"); + } else h_rate[i] = max_h_rate * h_rate[i] / fabs(h_rate[i]); + } else h_rate[i] /= fabs(set_extra[i].ptarget); + } + + if (max_h_rate != 0) + if (fabs(h_rate[i]) > max_h_rate) + h_rate[i] = max_h_rate * h_rate[i] / fabs(h_rate[i]); + + set[i].tilt_target = tilt + update->dt * h_rate[i]; + } +} + +/* ---------------------------------------------------------------------- + apply volume controls +------------------------------------------------------------------------- */ + +void FixDeformPressure::apply_volume() +{ + double e1, e2; + int linked_pressure = 0; + + for (int i = 0; i < 3; i++) { + if (set[i].style != VOLUME) continue; + + int dynamic1 = set[i].dynamic1; + int dynamic2 = set[i].dynamic2; + int fixed = set[i].fixed; + double v0 = set[i].vol_start; + double shift = 0.0; + + if (set[i].substyle == ONE_FROM_ONE) { + shift = 0.5 * (v0 / (set[dynamic1].hi_target - set[dynamic1].lo_target) / + (set[fixed].hi_start-set[fixed].lo_start)); + } else if (set[i].substyle == ONE_FROM_TWO) { + shift = 0.5 * (v0 / (set[dynamic1].hi_target - set[dynamic1].lo_target) / + (set[dynamic2].hi_target - set[dynamic2].lo_target)); + } else if (set[i].substyle == TWO_FROM_ONE) { + if (!vol_balance_flag) { + shift = 0.5 * sqrt(v0 * (set[i].hi_start - set[i].lo_start) / + (set[dynamic1].hi_target - set[dynamic1].lo_target) / + (set[fixed].hi_start - set[fixed].lo_start)); + } else { + double dt = update->dt; + double e1i = set_extra[i].prior_rate; + double e2i = set_extra[fixed].prior_rate; + double L1i = domain->boxhi[i] - domain->boxlo[i]; + double L2i = domain->boxhi[fixed] - domain->boxlo[fixed]; + double L3i = domain->boxhi[dynamic1] - domain->boxlo[dynamic1]; + double L3 = (set[dynamic1].hi_target - set[dynamic1].lo_target); + double Vi = L1i * L2i * L3i; + double V = L3 * L1i * L2i; + double e3 = (L3 / L3i - 1.0) / dt; + double p1 = pressure->vector[i]; + double p2 = pressure->vector[fixed]; + double p1i = set_extra[i].prior_pressure; + double p2i = set_extra[fixed].prior_pressure; + double denominator; + + if (e3 == 0) { + e1 = 0.0; + e2 = 0.0; + shift = 0.5 * L1i; + } else if (e1i == 0 || e2i == 0 || (p2 == p2i && p1 == p1i)) { + // If no prior strain or no change in pressure (initial step) just scale shift by relative box lengths + shift = 0.5 * sqrt(v0 * L1i / L3 / L2i); + } else { + if (!linked_pressure) { + // Calculate first strain rate by expanding stress to linear order, p1(t+dt) = p2(t+dt) + // Calculate second strain rate to preserve volume + denominator = p2 - p2i + e2i * ((p1 - p1i) / e1i); + if (denominator != 0.0 && e1i != 0.0) { + e1 = (((p2 - p2i) * (Vi - V) / (V * dt)) - e2i * (p1 - p2)) / denominator; + } else { + e1 = e2i; + } + e2 = (Vi - V * (1 + e1 * dt)) / (V * (1 + e1 * dt) * dt); + + // If strain rate exceeds limit in either dimension, cap it at the maximum compatible rate + if (max_h_rate != 0) { + if ((fabs(e1) > max_h_rate) || (fabs(e2) > max_h_rate)) { + if (fabs(e1) > fabs(e2)) + adjust_linked_rates(e1, e2, e3, Vi, V); + else + adjust_linked_rates(e2, e1, e3, Vi, V); + } + } + shift = 0.5 * L1i * (1.0 + e1 * dt); + linked_pressure = 1; + } else { + // Already calculated value of e2 + shift = 0.5 * L1i * (1.0 + e2 * dt); + } + } + } + } + + h_rate[i] = (2.0 * shift / (domain->boxhi[i] - domain->boxlo[i]) - 1.0) / update->dt; + h_ratelo[i] = -0.5 * h_rate[i]; + + set[i].lo_target = 0.5 * (set[i].lo_start + set[i].hi_start) - shift; + set[i].hi_target = 0.5 * (set[i].lo_start + set[i].hi_start) + shift; + } +} + + +/* ---------------------------------------------------------------------- + Rescale volume preserving strain rates to enforce max rate +------------------------------------------------------------------------- */ + +void FixDeformPressure::adjust_linked_rates(double &e_larger, double &e_smaller, double e3, double Vi, double V) +{ + double dt = update->dt; + double e_lim_positive = (Vi - V * (1 + max_h_rate * dt)) / (V * (1 + max_h_rate * dt) * dt); + double e_lim_negative = (Vi - V * (1 - max_h_rate * dt)) / (V * (1 - max_h_rate * dt) * dt); + if ((e_larger * e3) >= 0) { + if (e_larger > 0.0) { + // Same sign as primary strain rate, cap third dimension + e_smaller = -max_h_rate; + e_larger = e_lim_negative; + } else { + e_smaller = max_h_rate; + e_larger = e_lim_positive; + } + } else { + // Opposite sign, set to maxrate. + if (e_larger > 0.0) { + e_larger = max_h_rate; + e_smaller = e_lim_positive; + } else { + e_larger = -max_h_rate; + e_smaller = e_lim_negative; + } + } +} + +/* ---------------------------------------------------------------------- + apply box controls +------------------------------------------------------------------------- */ + +void FixDeformPressure::apply_box() +{ + int i; + double scale, shift = 0.0; + double v_rate; + + if (set_box.style == VOLUME) { + double v0 = set_box.vol_start; + double v = 1.0; + for (i = 0; i < 3; i++) + v *= (set[i].hi_target - set[i].lo_target); + + scale = std::pow(v0 / v, THIRD); + for (i = 0; i < 3; i++) { + shift = 0.5 * (set[i].hi_target - set[i].lo_target) * scale; + set[i].lo_target = 0.5 * (set[i].lo_start + set[i].hi_start) - shift; + set[i].hi_target = 0.5 * (set[i].lo_start + set[i].hi_start) + shift; + + // Recalculate h_rate + h_rate[i] = (set[i].hi_target - set[i].lo_target) / (domain->boxhi[i] - domain->boxlo[i]) - 1.0; + h_rate[i] /= update->dt; + h_ratelo[i] = -0.5 * h_rate[i]; + } + + } else if (set_box.style == PRESSURE) { + + // If variable pressure, calculate current target + if (set_extra[6].pvar_flag) + set_extra[6].ptarget = input->variable->compute_equal(set_extra[6].pvar); + + v_rate = set_extra[6].pgain * (pressure->scalar - set_extra[6].ptarget); + + if (normalize_pressure_flag) { + if (set_extra[6].ptarget == 0) { + if (max_h_rate == 0) { + error->all(FLERR, "Cannot normalize error for zero pressure without defining a max rate"); + } else v_rate = max_h_rate * v_rate / fabs(v_rate); + } else v_rate /= fabs(set_extra[6].ptarget); + } + + if (max_h_rate != 0) + if (fabs(v_rate) > max_h_rate) + v_rate = max_h_rate * v_rate / fabs(v_rate); + + set_extra[6].cumulative_strain += update->dt * v_rate; + scale = (1.0 + set_extra[6].cumulative_strain); + for (i = 0; i < 3; i++) { + shift = 0.5 * (set[i].hi_target - set[i].lo_target) * scale; + set[i].lo_target = 0.5 * (set[i].lo_start + set[i].hi_start) - shift; + set[i].hi_target = 0.5 * (set[i].lo_start + set[i].hi_start) + shift; + + // Recalculate h_rate + h_rate[i] = (set[i].hi_target - set[i].lo_target) / (domain->boxhi[i] - domain->boxlo[i]) - 1.0; + h_rate[i] /= update->dt; + h_ratelo[i] = -0.5 * h_rate[i]; + } + } +} + +/* ---------------------------------------------------------------------- + write Set data to restart file +------------------------------------------------------------------------- */ + +void FixDeformPressure::write_restart(FILE *fp) +{ + if (comm->me == 0) { + int size = 9 * sizeof(double) + 7 * sizeof(Set) + 7 * sizeof(SetExtra); + fwrite(&size, sizeof(int), 1, fp); + fwrite(set, sizeof(Set), 6, fp); + fwrite(&set_box, sizeof(Set), 1, fp); + fwrite(set_extra, sizeof(SetExtra), 7, fp); + } +} + +/* ---------------------------------------------------------------------- + use selected state info from restart file to restart the Fix +------------------------------------------------------------------------- */ + +void FixDeformPressure::restart(char *buf) +{ + int n = 0; + auto list = (double *) buf; + for (int i = 0; i < 6; i++) + h_rate[i] = list[n++]; + for (int i = 0; i < 3; i++) + h_ratelo[i] = list[n++]; + + n = n * sizeof(double); + int samestyle = 1; + Set *set_restart = (Set *) &buf[n]; + for (int i = 0; i < 6; ++i) { + // restore data from initial state + set[i].lo_initial = set_restart[i].lo_initial; + set[i].hi_initial = set_restart[i].hi_initial; + set[i].vol_initial = set_restart[i].vol_initial; + set[i].tilt_initial = set_restart[i].tilt_initial; + // check if style settings are consistent (should do the whole set?) + if (set[i].style != set_restart[i].style) + samestyle = 0; + if (set[i].substyle != set_restart[i].substyle) + samestyle = 0; + } + n += 6 * sizeof(Set); + + // Only restore relevant box variables & check consistency + Set set_box_restart; + memcpy(&set_box_restart, (Set *) &buf[n], sizeof(Set)); + set_box.vol_initial = set_box_restart.vol_initial; + if (set_box.style != set_box_restart.style) + samestyle = 0; + + if (!samestyle) + error->all(FLERR, "Fix deform/pressure settings not consistent with restart"); + + n += sizeof(Set); + SetExtra *set_extra_restart = (SetExtra *) &buf[n]; + for (int i = 0; i < 7; ++i) { + set_extra[i].saved = set_extra_restart[i].saved; + set_extra[i].prior_rate = set_extra_restart[i].prior_rate; + set_extra[i].prior_pressure = set_extra_restart[i].prior_pressure; + set_extra[i].cumulative_strain = set_extra_restart[i].cumulative_strain; + } +} + +/* ---------------------------------------------------------------------- */ + +void FixDeformPressure::options(int i, int narg, char **arg) +{ + pcouple = NOCOUPLE; + max_h_rate = 0.0; + vol_balance_flag = 0; + normalize_pressure_flag = 0; + + // parse only options not handled by parent class + + int iarg; + while (i < (int) leftover_iarg.size()) { + iarg = leftover_iarg[i]; + if (strcmp(arg[iarg], "couple") == 0) { + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "fix deform/pressure couple", error); + if (strcmp(arg[iarg + 1], "xyz") == 0) pcouple = XYZ; + else if (strcmp(arg[iarg + 1], "xy") == 0) pcouple = XY; + else if (strcmp(arg[iarg + 1], "yz") == 0) pcouple = YZ; + else if (strcmp(arg[iarg + 1], "xz") == 0) pcouple = XZ; + else if (strcmp(arg[iarg + 1], "none") == 0) pcouple = NOCOUPLE; + else error->all(FLERR, "Illegal fix deform/pressure couple command: {}", arg[iarg + 1]); + i += 2; + } else if (strcmp(arg[iarg], "max/rate") == 0) { + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "fix deform/pressure max/rate", error); + max_h_rate = utils::numeric(FLERR, arg[iarg + 1], false, lmp); + if (max_h_rate <= 0.0) + error->all(FLERR, "Maximum strain rate must be a positive, non-zero value"); + i += 2; + } else if (strcmp(arg[iarg], "normalize/pressure") == 0) { + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "fix deform/pressure normalize/pressure", error); + normalize_pressure_flag = utils::logical(FLERR, arg[iarg + 1], false, lmp); + i += 2; + } else if (strcmp(arg[iarg], "vol/balance/p") == 0) { + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "fix deform/pressure vol/balance/p", error); + vol_balance_flag = utils::logical(FLERR, arg[iarg + 1], false, lmp); + i += 2; + } else error->all(FLERR, "Illegal fix deform/pressure command: {}", arg[iarg]); + } +} + +/* ---------------------------------------------------------------------- */ + +int FixDeformPressure::modify_param(int narg, char **arg) +{ + if (strcmp(arg[0], "temp") == 0) { + if (narg < 2) error->all(FLERR, "Illegal fix_modify command"); + if (tflag) { + modify->delete_compute(id_temp); + tflag = 0; + } + delete[] id_temp; + id_temp = utils::strdup(arg[1]); + + temperature = modify->get_compute_by_id(arg[1]); + if (!temperature) + error->all(FLERR, "Could not find fix_modify temperature compute ID: ", arg[1]); + + if (temperature->tempflag == 0) + error->all(FLERR, "Fix_modify temperature compute {} does not compute temperature", arg[1]); + if (temperature->igroup != 0 && comm->me == 0) + error->warning(FLERR, "Temperature compute {} for fix {} is not for group all: {}", + arg[1], style, group->names[temperature->igroup]); + + // reset id_temp of pressure to new temperature ID + + auto icompute = modify->get_compute_by_id(id_press); + if (!icompute) + error->all(FLERR, "Pressure compute ID {} for fix {} does not exist", id_press, style); + icompute->reset_extra_compute_fix(id_temp); + + return 2; + + } else if (strcmp(arg[0], "press") == 0) { + if (narg < 2) error->all(FLERR, "Illegal fix_modify command"); + if (pflag) { + modify->delete_compute(id_press); + pflag = 0; + } + delete[] id_press; + id_press = utils::strdup(arg[1]); + + pressure = modify->get_compute_by_id(arg[1]); + if (!pressure) error->all(FLERR, "Could not find fix_modify pressure compute ID: {}", arg[1]); + if (pressure->pressflag == 0) + error->all(FLERR, "Fix_modify pressure compute {} does not compute pressure", arg[1]); + return 2; + } + + return 0; +} diff --git a/src/EXTRA-FIX/fix_deform_pressure.h b/src/EXTRA-FIX/fix_deform_pressure.h new file mode 100644 index 0000000000..5a0d844bad --- /dev/null +++ b/src/EXTRA-FIX/fix_deform_pressure.h @@ -0,0 +1,74 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + LAMMPS development team: developers@lammps.org + + 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. +------------------------------------------------------------------------- */ + +#ifdef FIX_CLASS +// clang-format off +FixStyle(deform/pressure,FixDeformPressure); +// clang-format on +#else + +#ifndef LMP_FIX_DEFORM_PRESSURE_H +#define LMP_FIX_DEFORM_PRESSURE_H + +#include "fix_deform.h" + +namespace LAMMPS_NS { + +class FixDeformPressure : public FixDeform { + public: + FixDeformPressure(class LAMMPS *, int, char **); + ~FixDeformPressure() override; + void init() override; + void setup(int) override; + void end_of_step() override; + void write_restart(FILE *) override; + void restart(char *buf) override; + int modify_param(int, char **) override; + + protected: + int pcouple; + double max_h_rate; + int strain_flag; // 1 if strain-based option is used, 0 if not + int pressure_flag; // 1 if pressure tensor used, 0 if not + int volume_flag; // 1 if VOLUME option is used, 0 if not + int normalize_pressure_flag; // 1 if normalize pressure deviation by target + int vol_balance_flag; // 1 if pressures balanced when maintaining const vol + + char *id_temp, *id_press; + class Compute *temperature, *pressure; + int tflag, pflag; + + struct SetExtra { + double ptarget, pgain; + double prior_pressure, prior_rate; + double cumulative_strain; + int saved; + char *pstr; + int pvar, pvar_flag; + int coupled_flag; + }; + SetExtra *set_extra; + Set set_box; + + void options(int, int, char **); + void apply_volume() override; + void apply_pressure(); + void apply_box(); + void couple(); + void adjust_linked_rates(double&, double&, double, double, double); +}; + +} // namespace LAMMPS_NS + +#endif +#endif diff --git a/src/EXTRA-FIX/fix_efield_tip4p.cpp b/src/EXTRA-FIX/fix_efield_tip4p.cpp index 47b1d9e27a..a83939a620 100644 --- a/src/EXTRA-FIX/fix_efield_tip4p.cpp +++ b/src/EXTRA-FIX/fix_efield_tip4p.cpp @@ -16,7 +16,6 @@ #include "angle.h" #include "atom.h" #include "bond.h" -#include "comm.h" #include "domain.h" #include "error.h" #include "force.h" @@ -25,11 +24,10 @@ #include "modify.h" #include "pair.h" #include "region.h" -#include "respa.h" #include "update.h" #include "variable.h" -#include +#include using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/EXTRA-FIX/fix_ffl.cpp b/src/EXTRA-FIX/fix_ffl.cpp index 0a06707fbd..e113a5fd37 100644 --- a/src/EXTRA-FIX/fix_ffl.cpp +++ b/src/EXTRA-FIX/fix_ffl.cpp @@ -43,8 +43,6 @@ enum {CONSTANT,EQUAL,ATOM}; enum {NO_FLIP, FLIP_RESCALE, FLIP_HARD, FLIP_SOFT}; //#define FFL_DEBUG 1 -#define MAXLINE 1024 - /* syntax for fix_ffl: * fix nfix id-group ffl tau Tstart Tstop seed [flip_type] * */ diff --git a/src/EXTRA-FIX/fix_filter_corotate.cpp b/src/EXTRA-FIX/fix_filter_corotate.cpp index c88969344a..872ebd1772 100644 --- a/src/EXTRA-FIX/fix_filter_corotate.cpp +++ b/src/EXTRA-FIX/fix_filter_corotate.cpp @@ -42,8 +42,7 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace FixConst; -#define BIG 1.0e20 -#define MASSDELTA 0.1 +static constexpr double MASSDELTA = 0.1; static const char cite_filter_corotate[] = "Mollified Impulse Method with Corotational Filter: doi:10.1016/j.jcp.2016.12.024\n\n" diff --git a/src/EXTRA-FIX/fix_gle.cpp b/src/EXTRA-FIX/fix_gle.cpp index c5a6c974f6..1ecc06ddf4 100644 --- a/src/EXTRA-FIX/fix_gle.cpp +++ b/src/EXTRA-FIX/fix_gle.cpp @@ -41,8 +41,6 @@ enum{CONSTANT,EQUAL,ATOM}; //#define GLE_DEBUG 1 -#define MAXLINE 1024 - /* syntax for fix_gle: * fix nfix id-group gle ns Tstart Tstop seed amatrix [noneq cmatrix] [every nmts] * diff --git a/src/EXTRA-FIX/fix_nonaffine_displacement.cpp b/src/EXTRA-FIX/fix_nonaffine_displacement.cpp index a426a8fb55..ee14822e98 100644 --- a/src/EXTRA-FIX/fix_nonaffine_displacement.cpp +++ b/src/EXTRA-FIX/fix_nonaffine_displacement.cpp @@ -35,6 +35,7 @@ #include "pair.h" #include "update.h" +#include #include using namespace LAMMPS_NS; @@ -64,9 +65,9 @@ static const char cite_nonaffine_d2min[] = /* ---------------------------------------------------------------------- */ FixNonaffineDisplacement::FixNonaffineDisplacement(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg), id_fix(nullptr), X(nullptr), Y(nullptr), F(nullptr), norm(nullptr) + Fix(lmp, narg, arg), id_fix(nullptr), X(nullptr), Y(nullptr), F(nullptr), norm(nullptr), D2min(nullptr) { - if (narg < 4) error->all(FLERR,"Illegal fix nonaffine/displacement command"); + if (narg < 4) utils::missing_cmd_args(FLERR,"fix nonaffine/displacement", error); nevery = utils::inumeric(FLERR, arg[3], false, lmp); if (nevery <= 0) error->all(FLERR,"Illegal nevery value {} in fix nonaffine/displacement", nevery); @@ -75,17 +76,18 @@ FixNonaffineDisplacement::FixNonaffineDisplacement(LAMMPS *lmp, int narg, char * int iarg = 4; if (strcmp(arg[iarg], "integrated") == 0) { nad_style = INTEGRATED; - nevery = 1; iarg += 1; } else if (strcmp(arg[iarg], "d2min") == 0) { - if (iarg + 1 > narg) error->all(FLERR,"Illegal fix nonaffine/displacement command"); + if (iarg + 1 > narg) utils::missing_cmd_args(FLERR,"fix nonaffine/displacement d2min", error); nad_style = D2MIN; if (strcmp(arg[iarg + 1], "type") == 0) { cut_style = TYPE; } else if (strcmp(arg[iarg + 1], "radius") == 0) { cut_style = RADIUS; } else if (strcmp(arg[iarg + 1], "custom") == 0) { - if (iarg + 2 > narg) error->all(FLERR,"Illegal fix nonaffine/displacement command"); + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR,"fix nonaffine/displacement custom", error); + if ((neighbor->style == Neighbor::MULTI) || (neighbor->style == Neighbor::MULTI_OLD)) + error->all(FLERR, "Fix nonaffine/displacement with custom cutoff requires neighbor style 'bin' or 'nsq'"); cut_style = CUSTOM; cutoff_custom = utils::numeric(FLERR, arg[iarg + 2], false, lmp); cutsq_custom = cutoff_custom * cutoff_custom; @@ -96,7 +98,7 @@ FixNonaffineDisplacement::FixNonaffineDisplacement(LAMMPS *lmp, int narg, char * iarg += 2; } else error->all(FLERR,"Illegal nonaffine displacement style {} in fix nonaffine/displacement", arg[iarg]); - if (iarg + 2 > narg) error->all(FLERR,"Illegal fix nonaffine/displacement command"); + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR,"fix nonaffine/displacement", error); if (strcmp(arg[iarg], "fixed") == 0) { reference_style = FIXED; reference_timestep = utils::inumeric(FLERR, arg[iarg + 1], false, lmp); @@ -105,7 +107,7 @@ FixNonaffineDisplacement::FixNonaffineDisplacement(LAMMPS *lmp, int narg, char * } else if (strcmp(arg[iarg], "update") == 0) { reference_style = UPDATE; update_timestep = utils::inumeric(FLERR, arg[iarg + 1], false, lmp); - if (update_timestep < 0) + if (update_timestep <= 0) error->all(FLERR, "Illegal update timestep {} in fix nonaffine/displacement", arg[iarg + 1]); } else if (strcmp(arg[iarg], "offset") == 0) { reference_style = OFFSET; @@ -118,9 +120,6 @@ FixNonaffineDisplacement::FixNonaffineDisplacement(LAMMPS *lmp, int narg, char * if (cut_style == RADIUS && (!atom->radius_flag)) error->all(FLERR, "Fix nonaffine/displacement radius style requires atom attribute radius"); - if (nad_style == INTEGRATED && reference_style == OFFSET) - error->all(FLERR, "Fix nonaffine/displacement cannot use the integrated style with an offset reference state"); - peratom_flag = 1; peratom_freq = nevery; nmax = -1; @@ -150,8 +149,10 @@ FixNonaffineDisplacement::~FixNonaffineDisplacement() memory->destroy(Y); memory->destroy(F); memory->destroy(norm); - memory->destroy(array_atom); + memory->destroy(D2min); } + + memory->destroy(array_atom); } /* ---------------------------------------------------------------------- */ @@ -175,12 +176,7 @@ void FixNonaffineDisplacement::post_constructor() id_fix = utils::strdup(id + std::string("_FIX_PA")); fix = dynamic_cast(modify->add_fix(fmt::format("{} {} STORE/ATOM 3 0 {} 1", id_fix, group->names[igroup], ghost_status))); - if (nad_style == INTEGRATED) - array_atom = fix->astore; - - if (nad_style == D2MIN) - grow_arrays(atom->nmax); - + grow_arrays(atom->nmax); for (int i = 0; i < atom->nlocal; i++) for (int j = 0; j < 3; j++) array_atom[i][j] = 0.0; } @@ -206,6 +202,9 @@ void FixNonaffineDisplacement::init() } else { auto req = neighbor->add_request(this, NeighConst::REQ_OCCASIONAL); if (cut_style == CUSTOM) { + if ((neighbor->style == Neighbor::MULTI) || (neighbor->style == Neighbor::MULTI_OLD)) + error->all(FLERR, "Fix nonaffine/displacement with custom cutoff requires neighbor style 'bin' or 'nsq'"); + double skin = neighbor->skin; mycutneigh = cutoff_custom + skin; @@ -245,6 +244,15 @@ void FixNonaffineDisplacement::post_force(int /*vflag*/) if (reference_saved && (!update->setupflag)) { if (nad_style == INTEGRATED) { integrate_velocity(); + if ((update->ntimestep % nevery) == 0) { + if (atom->nmax > nmax) + grow_arrays(atom->nmax); + + double **x_nonaffine = fix->astore; + for (int i = 0; i < atom->nlocal; i++) + for (int m = 0; m < 3; m++) + array_atom[i][m] = x_nonaffine[i][m]; + } } else { if ((update->ntimestep % nevery) == 0) calculate_D2Min(); } @@ -291,11 +299,12 @@ void FixNonaffineDisplacement::integrate_velocity() int *mask = atom->mask; int nlocal = atom->nlocal; + double **x_nonaffine = fix->astore; for (int m = 0; m < 3; m++) { for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - array_atom[i][m] += dtv * v[i][m]; + x_nonaffine[i][m] += dtv * v[i][m]; } } } @@ -306,6 +315,7 @@ void FixNonaffineDisplacement::integrate_velocity() void FixNonaffineDisplacement::save_reference_state() { double **x = atom->x; + double **x0 = fix->astore; int *mask = atom->mask; int nlocal = atom->nlocal; @@ -314,13 +324,13 @@ void FixNonaffineDisplacement::save_reference_state() if (nad_style == D2MIN) { for (int m = 0; m < 3; m++) { for (int i = 0; i < nall; i++) { - if (mask[i] & groupbit) array_atom[i][m] = x[i][m]; + if (mask[i] & groupbit) x0[i][m] = x[i][m]; } } } else { for (int m = 0; m < 3; m++) { for (int i = 0; i < nall; i++) { - if (mask[i] & groupbit) array_atom[i][m] = 0.0; + if (mask[i] & groupbit) x0[i][m] = 0.0; } } } @@ -358,7 +368,7 @@ void FixNonaffineDisplacement::calculate_D2Min() int *ilist, *jlist, *numneigh, **firstneigh; double **x = atom->x; - double **x0 = array_atom; + double **x0 = fix->astore; double *radius = atom->radius; int *type = atom->type; int *mask = atom->mask; @@ -383,7 +393,7 @@ void FixNonaffineDisplacement::calculate_D2Min() } } norm[i] = 0; - array_atom[i][0] = 0; + D2min[i] = 0; } // First loop through neighbors @@ -524,7 +534,7 @@ void FixNonaffineDisplacement::calculate_D2Min() } sub3(r, temp, temp); - array_atom[i][0] += lensq3(temp); + D2min[i] += lensq3(temp); norm[i] += 1; if (newton_pair || j < nlocal) { @@ -535,7 +545,7 @@ void FixNonaffineDisplacement::calculate_D2Min() } sub3(r, temp, temp); - array_atom[j][0] += lensq3(temp); + D2min[j] += lensq3(temp); norm[j] += 1; } } @@ -548,10 +558,9 @@ void FixNonaffineDisplacement::calculate_D2Min() if (!(mask[i] & groupbit)) continue; if (norm[i] != 0) - array_atom[i][0] /= norm[i]; + D2min[i] /= norm[i]; else - array_atom[i][0] = 0.0; - array_atom[i][0] = sqrt(array_atom[i][0]); + D2min[i] = 0.0; for (j = 0; j < 3; j++) for (k = 0; k < 3; k++) @@ -571,6 +580,7 @@ void FixNonaffineDisplacement::calculate_D2Min() edev = sqrt(0.5 * j2); + array_atom[i][0] = sqrt(D2min[i]); array_atom[i][1] = evol; array_atom[i][2] = edev; } @@ -593,7 +603,7 @@ int FixNonaffineDisplacement::pack_reverse_comm(int n, int first, double *buf) } } } else { - buf[m++] = array_atom[i][0]; + buf[m++] = D2min[i]; buf[m++] = ubuf(norm[i]).d; } } @@ -617,7 +627,7 @@ void FixNonaffineDisplacement::unpack_reverse_comm(int n, int *list, double *buf } } } else { - array_atom[j][0] += buf[m++]; + D2min[j] += buf[m++]; norm[j] += (int) ubuf(buf[m++]).i; } } @@ -723,12 +733,18 @@ void FixNonaffineDisplacement::minimum_image0(double *delta) void FixNonaffineDisplacement::grow_arrays(int nmax_new) { nmax = nmax_new; - memory->destroy(X); - memory->destroy(Y); - memory->destroy(F); - memory->destroy(norm); - memory->create(X, nmax, 3, 3, "fix_nonaffine_displacement:X"); - memory->create(Y, nmax, 3, 3, "fix_nonaffine_displacement:Y"); - memory->create(F, nmax, 3, 3, "fix_nonaffine_displacement:F"); - memory->create(norm, nmax, "fix_nonaffine_displacement:norm"); + memory->destroy(array_atom); + memory->create(array_atom, nmax, 3, "fix_nonaffine_displacement:array_atom"); + if (nad_style == D2MIN) { + memory->destroy(X); + memory->destroy(Y); + memory->destroy(F); + memory->destroy(D2min); + memory->destroy(norm); + memory->create(X, nmax, 3, 3, "fix_nonaffine_displacement:X"); + memory->create(Y, nmax, 3, 3, "fix_nonaffine_displacement:Y"); + memory->create(F, nmax, 3, 3, "fix_nonaffine_displacement:F"); + memory->create(D2min, nmax, "fix_nonaffine_displacement:D2min"); + memory->create(norm, nmax, "fix_nonaffine_displacement:norm"); + } } diff --git a/src/EXTRA-FIX/fix_nonaffine_displacement.h b/src/EXTRA-FIX/fix_nonaffine_displacement.h index 3341ab1834..79dbdabf49 100644 --- a/src/EXTRA-FIX/fix_nonaffine_displacement.h +++ b/src/EXTRA-FIX/fix_nonaffine_displacement.h @@ -52,7 +52,7 @@ class FixNonaffineDisplacement : public Fix { double cutoff_custom, cutsq_custom, mycutneigh; double xprd0, yprd0, zprd0, xprd0_half, yprd0_half, zprd0_half, xy0, xz0, yz0; - double ***X, ***Y, ***F; + double *D2min, ***X, ***Y, ***F; int *norm; class NeighList *list; // half neighbor list diff --git a/src/EXTRA-FIX/fix_npt_cauchy.cpp b/src/EXTRA-FIX/fix_npt_cauchy.cpp index f3dfd1af36..8eb6a80b6d 100644 --- a/src/EXTRA-FIX/fix_npt_cauchy.cpp +++ b/src/EXTRA-FIX/fix_npt_cauchy.cpp @@ -42,8 +42,8 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define DELTAFLIP 0.1 -#define TILTMAX 1.5 +static constexpr double DELTAFLIP = 0.1; +static constexpr double TILTMAX = 1.5; enum{NOBIAS,BIAS}; enum{NONE,XYZ,XY,YZ,XZ}; @@ -91,8 +91,6 @@ FixNPTCauchy::FixNPTCauchy(LAMMPS *lmp, int narg, char **arg) : omega_mass_flag = 0; etap_mass_flag = 0; flipflag = 1; - dipole_flag = 0; - dlm_flag = 0; tcomputeflag = 0; pcomputeflag = 0; @@ -327,14 +325,6 @@ FixNPTCauchy::FixNPTCauchy(LAMMPS *lmp, int narg, char **arg) : if (iarg+2 > narg) 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"); - if (strcmp(arg[iarg+1],"dipole") == 0) dipole_flag = 1; - else if (strcmp(arg[iarg+1],"dipole/dlm") == 0) { - dipole_flag = 1; - dlm_flag = 1; - } else error->all(FLERR,"Illegal fix npt/cauchy command"); - iarg += 2; } else if (strcmp(arg[iarg],"alpha") == 0) { alpha = utils::numeric(FLERR,arg[iarg+1],false,lmp); iarg += 2; @@ -349,20 +339,6 @@ FixNPTCauchy::FixNPTCauchy(LAMMPS *lmp, int narg, char **arg) : fixedpoint[2] = utils::numeric(FLERR,arg[iarg+3],false,lmp); iarg += 4; - // disc keyword is also parsed in fix/nh/sphere - - } else if (strcmp(arg[iarg],"disc") == 0) { - iarg++; - - // keywords erate, strain, and ext are also parsed in fix/nh/uef - - } else if (strcmp(arg[iarg],"erate") == 0) { - iarg += 3; - } else if (strcmp(arg[iarg],"strain") == 0) { - iarg += 3; - } else if (strcmp(arg[iarg],"ext") == 0) { - iarg += 2; - } else error->all(FLERR,"Illegal fix npt/cauchy command"); } @@ -453,13 +429,6 @@ FixNPTCauchy::FixNPTCauchy(LAMMPS *lmp, int narg, char **arg) : p_period[0] != p_period[2])) error->all(FLERR,"Invalid fix npt/cauchy pressure settings"); - if (dipole_flag) { - if (!atom->sphere_flag) - error->all(FLERR,"Using update dipole flag requires atom style sphere"); - if (!atom->mu_flag) - error->all(FLERR,"Using update dipole flag requires atom attribute mu"); - } - if ((tstat_flag && t_period <= 0.0) || (p_flag[0] && p_period[0] <= 0.0) || (p_flag[1] && p_period[1] <= 0.0) || diff --git a/src/EXTRA-FIX/fix_npt_cauchy.h b/src/EXTRA-FIX/fix_npt_cauchy.h index 43a944acb4..4a738e48ab 100644 --- a/src/EXTRA-FIX/fix_npt_cauchy.h +++ b/src/EXTRA-FIX/fix_npt_cauchy.h @@ -117,8 +117,6 @@ class FixNPTCauchy : public Fix { int eta_mass_flag; // 1 if eta_mass updated, 0 if not. int omega_mass_flag; // 1 if omega_mass updated, 0 if not. int etap_mass_flag; // 1 if etap_mass updated, 0 if not. - int dipole_flag; // 1 if dipole is updated, 0 if not. - int dlm_flag; // 1 if using the DLM rotational integrator, 0 if not int scaleyz; // 1 if yz scaled with lz int scalexz; // 1 if xz scaled with lz diff --git a/src/EXTRA-FIX/fix_smd.cpp b/src/EXTRA-FIX/fix_smd.cpp index e19a605e71..bc5dca0b58 100644 --- a/src/EXTRA-FIX/fix_smd.cpp +++ b/src/EXTRA-FIX/fix_smd.cpp @@ -38,7 +38,7 @@ enum { SMD_NONE=0, SMD_CVEL=1<<2, SMD_CFOR=1<<3, SMD_AUTOX=1<<4, SMD_AUTOY=1<<5, SMD_AUTOZ=1<<6}; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ @@ -430,7 +430,7 @@ void FixSMD::smd_couple() void FixSMD::write_restart(FILE *fp) { -#define RESTART_ITEMS 5 + static constexpr int RESTART_ITEMS = 5; double buf[RESTART_ITEMS], fsign; if (comm->me == 0) { diff --git a/src/EXTRA-FIX/fix_tmd.cpp b/src/EXTRA-FIX/fix_tmd.cpp index e88007a29d..242efcf41c 100644 --- a/src/EXTRA-FIX/fix_tmd.cpp +++ b/src/EXTRA-FIX/fix_tmd.cpp @@ -32,12 +32,13 @@ #include #include +#include using namespace LAMMPS_NS; using namespace FixConst; -#define CHUNK 1000 -#define MAXLINE 256 +static constexpr int CHUNK = 1000; +static constexpr int MAXLINE = 256; /* ---------------------------------------------------------------------- */ diff --git a/src/EXTRA-FIX/fix_ttm_mod.cpp b/src/EXTRA-FIX/fix_ttm_mod.cpp index 79af414f0a..335acdd853 100644 --- a/src/EXTRA-FIX/fix_ttm_mod.cpp +++ b/src/EXTRA-FIX/fix_ttm_mod.cpp @@ -486,12 +486,12 @@ void FixTTMMod::read_parameters(const std::string &filename) reader.next_line(); intensity = reader.next_values(1).next_double(); - // coordinate of 1st surface in x-direction (in box units) - constant + // coordinate of 1st surface in x-direction (electron grid units) - constant reader.next_line(); surface_l = reader.next_values(1).next_int(); - // coordinate of 2nd surface in x-direction (in box units) - constant + // coordinate of 2nd surface in x-direction (electron grid units) - constant reader.next_line(); surface_r = reader.next_values(1).next_int(); diff --git a/src/EXTRA-FIX/fix_viscosity.cpp b/src/EXTRA-FIX/fix_viscosity.cpp index a44050636d..715c30afdd 100644 --- a/src/EXTRA-FIX/fix_viscosity.cpp +++ b/src/EXTRA-FIX/fix_viscosity.cpp @@ -32,7 +32,7 @@ using namespace FixConst; // needs to be big, but not so big that lose precision when subtract velocity -#define BIG 1.0e10 +static constexpr double BIG = 1.0e10; /* ---------------------------------------------------------------------- */ @@ -120,14 +120,14 @@ int FixViscosity::setmask() void FixViscosity::init() { - // warn if any fix ave/spatial comes after this fix + // warn if any fix ave/chunk comes after this fix // can cause glitch in averaging since ave will happen after swap int foundme = 0; - for (int i = 0; i < modify->nfix; i++) { - if (modify->fix[i] == this) foundme = 1; - if (foundme && strcmp(modify->fix[i]->style,"ave/spatial") == 0 && me == 0) - error->warning(FLERR,"Fix viscosity comes before fix ave/spatial"); + for (const auto &ifix : modify->get_fix_list()) { + if (ifix == this) foundme = 1; + if (foundme && utils::strmatch(ifix->style,"^ave/chunk") && (me == 0)) + error->warning(FLERR,"Fix viscosity comes before fix ave/chunk"); } // set bounds of 2 slabs in pdim diff --git a/src/EXTRA-FIX/fix_viscous_sphere.cpp b/src/EXTRA-FIX/fix_viscous_sphere.cpp index 5b4dd72231..0eda323c15 100644 --- a/src/EXTRA-FIX/fix_viscous_sphere.cpp +++ b/src/EXTRA-FIX/fix_viscous_sphere.cpp @@ -38,7 +38,7 @@ FixViscousSphere::FixViscousSphere(LAMMPS *_lmp, int narg, char **arg) : { dynamic_group_allow = 1; - if (!atom->sphere_flag) error->all(FLERR, "Fix viscous/sphere requires atom style sphere"); + if (!atom->omega_flag) error->all(FLERR, "Fix viscous/sphere requires atom attribute omega"); if (narg < 4) error->all(FLERR, "Illegal fix viscous/sphere command"); diff --git a/src/EXTRA-FIX/fix_wall_flow.cpp b/src/EXTRA-FIX/fix_wall_flow.cpp new file mode 100644 index 0000000000..35997b5b63 --- /dev/null +++ b/src/EXTRA-FIX/fix_wall_flow.cpp @@ -0,0 +1,323 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + LAMMPS development team: developers@lammps.org + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing authors: Vladislav Galigerov (HSE), + Daniil Pavlov (MIPT) +------------------------------------------------------------------------- */ + +#include "fix_wall_flow.h" + +#include "atom.h" +#include "citeme.h" +#include "comm.h" +#include "domain.h" +#include "error.h" +#include "force.h" +#include "lattice.h" +#include "math_const.h" +#include "memory.h" +#include "modify.h" +#include "random_mars.h" + +#include +#include +#include +#include + +using namespace LAMMPS_NS; +using namespace FixConst; + +/* ---------------------------------------------------------------------- */ + +static const char cite_fix_wall_flow_c[] = + "fix wall/flow command: doi:10.1177/10943420231213013\n\n" + "@Article{Pavlov-etal-IJHPCA-2024,\n" + " author = {Daniil Pavlov and Vladislav Galigerov and Daniil Kolotinskii and Vsevolod " + "Nikolskiy and Vladimir Stegailov},\n" + " title = {GPU-based molecular dynamics of fluid flows: Reaching for turbulence},\n" + " journal = {The International Journal of High Performance Computing Applications},\n" + " year = 2024,\n" + " volume = 38,\n" + " number = 1,\n" + " pages = 34-49\n" + "}\n\n"; + +FixWallFlow::FixWallFlow(LAMMPS *lmp, int narg, char **arg) : + Fix(lmp, narg, arg), flowax(FlowAxis::AX_X), flowvel(0.0), flowdir(0), rndseed(0), + current_segment(nullptr) +{ + if (lmp->citeme) lmp->citeme->add(cite_fix_wall_flow_c); + if (narg < 9) utils::missing_cmd_args(FLERR, "fix wall/flow", error); + + if (domain->triclinic != 0) + error->all(FLERR, "Fix wall/flow cannot be used with triclinic simulation box"); + + dynamic_group_allow = 1; + bool do_abort = false; + + int iarg = 3; + // parsing axis + if (strcmp(arg[iarg], "x") == 0) + flowax = FlowAxis::AX_X; + else if (strcmp(arg[iarg], "y") == 0) + flowax = FlowAxis::AX_Y; + else if (strcmp(arg[iarg], "z") == 0) + flowax = FlowAxis::AX_Z; + else + error->all(FLERR, "Illegal fix wall/flow argument: axis must by x or y or z, but {} specified", + arg[iarg]); + + if (domain->periodicity[flowax] != 1) + error->all(FLERR, + "Fix wall/flow cannot be used with a non-periodic boundary along the flow axis"); + + ++iarg; + // parsing velocity + flowvel = utils::numeric(FLERR, arg[iarg], do_abort, lmp); + if (flowvel == 0.0) error->all(FLERR, "Illegal fix wall/flow argument: velocity cannot be 0"); + if (flowvel > 0.0) + flowdir = 1; + else + flowdir = -1; + if (flowdir < 0) + error->all(FLERR, "Illegal fix wall/flow argument: negative direction is not supported yet"); + + ++iarg; + // parsing temperature + double flowtemp = utils::numeric(FLERR, arg[iarg], do_abort, lmp); + kT = lmp->force->boltz * flowtemp / force->mvv2e; + + ++iarg; + // parsing seed + rndseed = utils::inumeric(FLERR, arg[iarg], do_abort, lmp); + if (rndseed <= 0) + error->all(FLERR, "Illegal fix wall/flow argument: random seed must be positive integer"); + + ++iarg; + // parsing wall count + int wallcount = utils::inumeric(FLERR, arg[iarg], do_abort, lmp); + if (wallcount <= 0) + error->all(FLERR, "Illegal fix wall/flow argument: wall count must be positive integer"); + + ++iarg; + // parsing walls + if (narg - iarg != wallcount && narg - iarg != wallcount + 2) + error->all(FLERR, "Wrong fix wall/flow wall count"); + + double scale = 0.0; + if (flowax == FlowAxis::AX_X) + scale = domain->lattice->xlattice; + else if (flowax == FlowAxis::AX_Y) + scale = domain->lattice->ylattice; + else if (flowax == FlowAxis::AX_Z) + scale = domain->lattice->zlattice; + + if (narg - iarg == wallcount + 2) { + if (strcmp(arg[narg - 2], "units") != 0) error->all(FLERR, "Wrong fix wall/flow units command"); + if (strcmp(arg[narg - 1], "box") == 0) + scale = 1.0; + else if (strcmp(arg[narg - 1], "lattice") != 0) + error->all(FLERR, "Wrong fix wall/flow units command"); + } + + walls.resize(wallcount + 2); + walls.front() = domain->boxlo[flowax]; + for (int w = 1; w <= wallcount; ++w, ++iarg) { + walls[w] = utils::numeric(FLERR, arg[iarg], do_abort, lmp) * scale; + } + walls.back() = domain->boxhi[flowax]; + if (!std::is_sorted(walls.begin(), walls.end(), std::less_equal())) { + error->all(FLERR, + "Wrong fix wall/flow wall ordering or some walls are outside simulation domain"); + } + + if (std::adjacent_find(walls.begin(), walls.end()) != walls.end()) { + error->all(FLERR, + "Wrong fix wall/flow wall coordinates: some walls have the same coordinates or lie " + "on the boundary"); + } + + memory->grow(current_segment, atom->nmax, "WallFlow::current_segment"); + atom->add_callback(Atom::GROW); + if (restart_peratom) atom->add_callback(Atom::RESTART); + + maxexchange = 1; + + random = new RanMars(lmp, rndseed + comm->me); +} + +/* ---------------------------------------------------------------------- */ + +FixWallFlow::~FixWallFlow() +{ + if (copymode) return; + atom->delete_callback(id, Atom::GROW); + if (restart_peratom) atom->delete_callback(id, Atom::RESTART); + memory->destroy(current_segment); + + delete random; +} + +/* ---------------------------------------------------------------------- */ + +int FixWallFlow::setmask() +{ + int mask = 0; + + mask |= END_OF_STEP; + + return mask; +} + +/* ---------------------------------------------------------------------- */ + +void FixWallFlow::init() +{ + if (domain->triclinic != 0) + error->all(FLERR, "Fix wall/flow cannot be used with triclinic simulation box"); + + int nrigid = 0; + int box_change_flowax = 0; + for (const auto &ifix : modify->get_fix_list()) { + if (ifix->rigid_flag) nrigid++; + switch (flowax) { + case FlowAxis::AX_X: + if (ifix->box_change & Fix::BOX_CHANGE_X) box_change_flowax++; + break; + case FlowAxis::AX_Y: + if (ifix->box_change & Fix::BOX_CHANGE_Y) box_change_flowax++; + break; + case FlowAxis::AX_Z: + if (ifix->box_change & Fix::BOX_CHANGE_Z) box_change_flowax++; + break; + } + } + + if (nrigid) error->all(FLERR, "Fix wall/flow is not compatible with rigid bodies"); + if (box_change_flowax) + error->all( + FLERR, + "Fix wall/flow is not compatible with simulation box size changing along flow direction"); + + for (int i = 0; i < atom->nlocal; ++i) { + double pos = atom->x[i][flowax]; + current_segment[i] = compute_current_segment(pos); + } +} + +/* ---------------------------------------------------------------------- */ + +void FixWallFlow::end_of_step() +{ + double **x = atom->x; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; ++i) { + if (mask[i] & groupbit) { + double pos = x[i][flowax]; + int prev_segment = current_segment[i]; + current_segment[i] = compute_current_segment(pos); + + if (prev_segment != current_segment[i]) generate_velocity(i); + } + } +} + +/* ---------------------------------------------------------------------- */ + +void FixWallFlow::generate_velocity(int atom_i) +{ + const int newton_iteration_count = 10; + double *vel = atom->v[atom_i]; + + double *prmass = atom->rmass; + double *pmass = atom->mass; + double mass = 0.0; + if (prmass) + mass = prmass[atom_i]; + else + mass = pmass[atom->type[atom_i]]; + + const double gamma = 1.0 / std::sqrt(2.0 * kT / mass); + double delta = gamma * flowvel; + + const double edd = std::exp(-delta * delta) / MathConst::MY_PIS + delta * std::erf(delta); + const double probability_threshold = 0.5f * (1.f + delta / edd); + + double direction = 1.0; + + if (random->uniform() > probability_threshold) { + delta = -delta; + direction = -direction; + } + + const double xi_0 = random->uniform(); + const double F_inf = edd + delta; + const double xi = xi_0 * F_inf; + const double x_0 = (std::sqrt(delta * delta + 2) - delta) * 0.5; + double x = x_0; + for (int i = 0; i < newton_iteration_count; ++i) { + x -= (std::exp(x * x) * MathConst::MY_PIS * (xi - delta * std::erfc(x)) - 1.0) / (x + delta) * + 0.5; + } + + const double nu = x + delta; + const double v = nu / gamma; + + vel[flowax] = v * direction; + vel[(flowax + 1) % 3] = random->gaussian() / (gamma * MathConst::MY_SQRT2); + vel[(flowax + 2) % 3] = random->gaussian() / (gamma * MathConst::MY_SQRT2); +} + +/* ---------------------------------------------------------------------- */ + +int FixWallFlow::compute_current_segment(double pos) const +{ + int result = 0; + for (; result < (int)walls.size() - 1; ++result) { + if (pos >= walls[result] && pos < walls[result + 1]) { return result; } + } + return -1; // -1 is "out of box" region +} + +/* ---------------------------------------------------------------------- */ + +void FixWallFlow::grow_arrays(int nmax) +{ + memory->grow(current_segment, nmax, "WallFlow::current_segment"); +} + +/* ---------------------------------------------------------------------- */ + +void FixWallFlow::copy_arrays(int i, int j, int) +{ + current_segment[j] = current_segment[i]; +} + +/* ---------------------------------------------------------------------- */ + +int FixWallFlow::pack_exchange(int i, double *buf) +{ + buf[0] = static_cast(current_segment[i]); + return 1; +} + +/* ---------------------------------------------------------------------- */ + +int FixWallFlow::unpack_exchange(int i, double *buf) +{ + current_segment[i] = static_cast(buf[0]); + return 1; +} diff --git a/src/EXTRA-FIX/fix_wall_flow.h b/src/EXTRA-FIX/fix_wall_flow.h new file mode 100644 index 0000000000..6a662f3d94 --- /dev/null +++ b/src/EXTRA-FIX/fix_wall_flow.h @@ -0,0 +1,61 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + LAMMPS development team: developers@lammps.org + + 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. +------------------------------------------------------------------------- */ + +#ifdef FIX_CLASS +// clang-format off +FixStyle(wall/flow,FixWallFlow); +// clang-format on +#else + +#ifndef LMP_FIX_WALL_FLOW_H +#define LMP_FIX_WALL_FLOW_H + +#include "fix.h" + +namespace LAMMPS_NS { + +class FixWallFlow : public Fix { + public: + enum FlowAxis { AX_X = 0, AX_Y = 1, AX_Z = 2 }; + + FixWallFlow(class LAMMPS *, int, char **); + ~FixWallFlow() override; + int setmask() override; + void init() override; + void end_of_step() override; + + void grow_arrays(int) override; + void copy_arrays(int, int, int) override; + + int pack_exchange(int, double *) override; + int unpack_exchange(int, double *) override; + + protected: + FlowAxis flowax; + double flowvel; + double kT; + std::vector walls; + + int flowdir; + int rndseed; + class RanMars *random; + int *current_segment; + + int compute_current_segment(double pos) const; + void generate_velocity(int i); +}; + +} // namespace LAMMPS_NS + +#endif +#endif diff --git a/src/EXTRA-FIX/fix_wall_reflect_stochastic.cpp b/src/EXTRA-FIX/fix_wall_reflect_stochastic.cpp index c435cc14ae..42bb198049 100644 --- a/src/EXTRA-FIX/fix_wall_reflect_stochastic.cpp +++ b/src/EXTRA-FIX/fix_wall_reflect_stochastic.cpp @@ -43,8 +43,7 @@ FixWallReflectStochastic(LAMMPS *lmp, int narg, char **arg) : if (narg < 8) error->all(FLERR,"Illegal fix wall/reflect/stochastic command"); if (domain->triclinic != 0) - error->all(FLERR, "Fix wall/reflect/stochastic cannot be used with " - "triclinic simulation box"); + error->all(FLERR, "Fix wall/reflect/stochastic cannot be used with triclinic simulation box"); dynamic_group_allow = 1; @@ -168,8 +167,7 @@ FixWallReflectStochastic(LAMMPS *lmp, int narg, char **arg) : xscale = domain->lattice->xlattice; yscale = domain->lattice->ylattice; zscale = domain->lattice->zlattice; - } - else xscale = yscale = zscale = 1.0; + } else xscale = yscale = zscale = 1.0; for (int m = 0; m < nwall; m++) { if (wallstyle[m] != CONSTANT) continue; diff --git a/src/EXTRA-MOLECULE/angle_cosine_delta.cpp b/src/EXTRA-MOLECULE/angle_cosine_delta.cpp index 71acca6001..51a53e1a96 100644 --- a/src/EXTRA-MOLECULE/angle_cosine_delta.cpp +++ b/src/EXTRA-MOLECULE/angle_cosine_delta.cpp @@ -25,7 +25,7 @@ using namespace LAMMPS_NS; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/EXTRA-MOLECULE/angle_cosine_periodic.cpp b/src/EXTRA-MOLECULE/angle_cosine_periodic.cpp index 245a7b8d58..0b2a6d336d 100644 --- a/src/EXTRA-MOLECULE/angle_cosine_periodic.cpp +++ b/src/EXTRA-MOLECULE/angle_cosine_periodic.cpp @@ -34,7 +34,7 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/EXTRA-MOLECULE/angle_cosine_shift.cpp b/src/EXTRA-MOLECULE/angle_cosine_shift.cpp index ce9b4c4133..53ecb35eaf 100644 --- a/src/EXTRA-MOLECULE/angle_cosine_shift.cpp +++ b/src/EXTRA-MOLECULE/angle_cosine_shift.cpp @@ -32,7 +32,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/EXTRA-MOLECULE/angle_cosine_shift_exp.cpp b/src/EXTRA-MOLECULE/angle_cosine_shift_exp.cpp index a411ea3199..acca92c48e 100644 --- a/src/EXTRA-MOLECULE/angle_cosine_shift_exp.cpp +++ b/src/EXTRA-MOLECULE/angle_cosine_shift_exp.cpp @@ -32,7 +32,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/EXTRA-MOLECULE/angle_fourier.cpp b/src/EXTRA-MOLECULE/angle_fourier.cpp index c7eb3d4fe4..da1667c06f 100644 --- a/src/EXTRA-MOLECULE/angle_fourier.cpp +++ b/src/EXTRA-MOLECULE/angle_fourier.cpp @@ -29,12 +29,9 @@ #include "memory.h" #include "error.h" - using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.001 - /* ---------------------------------------------------------------------- */ AngleFourier::AngleFourier(LAMMPS *lmp) : Angle(lmp) diff --git a/src/EXTRA-MOLECULE/angle_fourier_simple.cpp b/src/EXTRA-MOLECULE/angle_fourier_simple.cpp index 0ba890b273..6de7956ffa 100644 --- a/src/EXTRA-MOLECULE/angle_fourier_simple.cpp +++ b/src/EXTRA-MOLECULE/angle_fourier_simple.cpp @@ -32,7 +32,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.0001 +static constexpr double SMALL = 0.0001; /* ---------------------------------------------------------------------- */ diff --git a/src/EXTRA-MOLECULE/angle_quartic.cpp b/src/EXTRA-MOLECULE/angle_quartic.cpp index eaccdbe608..aade6b4534 100644 --- a/src/EXTRA-MOLECULE/angle_quartic.cpp +++ b/src/EXTRA-MOLECULE/angle_quartic.cpp @@ -33,7 +33,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/EXTRA-MOLECULE/dihedral_cosine_shift_exp.cpp b/src/EXTRA-MOLECULE/dihedral_cosine_shift_exp.cpp index 7165cde1fd..28015b0c36 100644 --- a/src/EXTRA-MOLECULE/dihedral_cosine_shift_exp.cpp +++ b/src/EXTRA-MOLECULE/dihedral_cosine_shift_exp.cpp @@ -30,8 +30,7 @@ using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; /* ---------------------------------------------------------------------- */ diff --git a/src/EXTRA-MOLECULE/dihedral_fourier.cpp b/src/EXTRA-MOLECULE/dihedral_fourier.cpp index f9b4a0d13e..37e1ae8328 100644 --- a/src/EXTRA-MOLECULE/dihedral_fourier.cpp +++ b/src/EXTRA-MOLECULE/dihedral_fourier.cpp @@ -32,7 +32,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define TOLERANCE 0.05 +static constexpr double TOLERANCE = 0.05; /* ---------------------------------------------------------------------- */ diff --git a/src/EXTRA-MOLECULE/dihedral_helix.cpp b/src/EXTRA-MOLECULE/dihedral_helix.cpp index 1d99de6ba9..0111da9f99 100644 --- a/src/EXTRA-MOLECULE/dihedral_helix.cpp +++ b/src/EXTRA-MOLECULE/dihedral_helix.cpp @@ -32,9 +32,9 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define TOLERANCE 0.05 -#define SMALL 0.001 -#define SMALLER 0.00001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; +static constexpr double SMALLER = 0.00001; /* ---------------------------------------------------------------------- */ diff --git a/src/EXTRA-MOLECULE/dihedral_nharmonic.cpp b/src/EXTRA-MOLECULE/dihedral_nharmonic.cpp index 206ad4f3ad..4c3cd3be2c 100644 --- a/src/EXTRA-MOLECULE/dihedral_nharmonic.cpp +++ b/src/EXTRA-MOLECULE/dihedral_nharmonic.cpp @@ -30,8 +30,8 @@ using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/EXTRA-MOLECULE/dihedral_quadratic.cpp b/src/EXTRA-MOLECULE/dihedral_quadratic.cpp index a7c0dc3eb1..1bef5956fa 100644 --- a/src/EXTRA-MOLECULE/dihedral_quadratic.cpp +++ b/src/EXTRA-MOLECULE/dihedral_quadratic.cpp @@ -32,9 +32,9 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define TOLERANCE 0.05 -#define SMALL 0.001 -#define SMALLER 0.00001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; +static constexpr double SMALLER = 0.00001; /* ---------------------------------------------------------------------- */ diff --git a/src/EXTRA-MOLECULE/dihedral_table_cut.cpp b/src/EXTRA-MOLECULE/dihedral_table_cut.cpp index ce0d431e7c..a06df279f3 100644 --- a/src/EXTRA-MOLECULE/dihedral_table_cut.cpp +++ b/src/EXTRA-MOLECULE/dihedral_table_cut.cpp @@ -47,8 +47,8 @@ static const char cite_dihedral_tablecut[] = /* ---------------------------------------------------------------------- */ -#define TOLERANCE 0.05 -#define SMALL 0.0000001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.0000001; // ------------------------------------------------------------------------ // The following auxiliary functions were left out of the diff --git a/src/EXTRA-MOLECULE/improper_cossq.cpp b/src/EXTRA-MOLECULE/improper_cossq.cpp index bd21fa12e7..864ec28927 100644 --- a/src/EXTRA-MOLECULE/improper_cossq.cpp +++ b/src/EXTRA-MOLECULE/improper_cossq.cpp @@ -32,8 +32,8 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/EXTRA-MOLECULE/improper_distance.cpp b/src/EXTRA-MOLECULE/improper_distance.cpp index 18f6dd9a3f..934eeb285d 100644 --- a/src/EXTRA-MOLECULE/improper_distance.cpp +++ b/src/EXTRA-MOLECULE/improper_distance.cpp @@ -27,12 +27,8 @@ #include "memory.h" #include "error.h" - using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 - /* ---------------------------------------------------------------------- */ ImproperDistance::ImproperDistance(LAMMPS *lmp) : Improper(lmp) diff --git a/src/EXTRA-MOLECULE/improper_fourier.cpp b/src/EXTRA-MOLECULE/improper_fourier.cpp index 295657b1b6..1db8b3697c 100644 --- a/src/EXTRA-MOLECULE/improper_fourier.cpp +++ b/src/EXTRA-MOLECULE/improper_fourier.cpp @@ -30,8 +30,8 @@ using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/EXTRA-MOLECULE/improper_ring.cpp b/src/EXTRA-MOLECULE/improper_ring.cpp index 36d6277e46..3d8b672e1e 100644 --- a/src/EXTRA-MOLECULE/improper_ring.cpp +++ b/src/EXTRA-MOLECULE/improper_ring.cpp @@ -54,8 +54,7 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/EXTRA-PAIR/pair_born_gauss.cpp b/src/EXTRA-PAIR/pair_born_gauss.cpp index f60cc4dc6f..4b1390889d 100644 --- a/src/EXTRA-PAIR/pair_born_gauss.cpp +++ b/src/EXTRA-PAIR/pair_born_gauss.cpp @@ -18,10 +18,8 @@ #include "atom.h" #include "comm.h" #include "error.h" -#include "fix.h" #include "force.h" #include "memory.h" -#include "modify.h" #include "neigh_list.h" #include diff --git a/src/EXTRA-PAIR/pair_coul_slater_long.cpp b/src/EXTRA-PAIR/pair_coul_slater_long.cpp index 3f5803af8e..65906f73b5 100644 --- a/src/EXTRA-PAIR/pair_coul_slater_long.cpp +++ b/src/EXTRA-PAIR/pair_coul_slater_long.cpp @@ -21,6 +21,7 @@ #include "atom.h" #include "comm.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "kspace.h" #include "memory.h" @@ -31,14 +32,7 @@ #include using namespace LAMMPS_NS; - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/EXTRA-PAIR/pair_lj_cut_coul_dsf.cpp b/src/EXTRA-PAIR/pair_lj_cut_coul_dsf.cpp index 49e1468af1..6ac0c1cdae 100644 --- a/src/EXTRA-PAIR/pair_lj_cut_coul_dsf.cpp +++ b/src/EXTRA-PAIR/pair_lj_cut_coul_dsf.cpp @@ -22,6 +22,7 @@ #include "atom.h" #include "comm.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "math_const.h" #include "memory.h" @@ -32,16 +33,9 @@ #include using namespace LAMMPS_NS; +using namespace EwaldConst; using namespace MathConst; -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 - /* ---------------------------------------------------------------------- */ PairLJCutCoulDSF::PairLJCutCoulDSF(LAMMPS *lmp) : Pair(lmp) diff --git a/src/EXTRA-PAIR/pair_lj_cut_sphere.cpp b/src/EXTRA-PAIR/pair_lj_cut_sphere.cpp index 3f16a96666..852b2eea1d 100644 --- a/src/EXTRA-PAIR/pair_lj_cut_sphere.cpp +++ b/src/EXTRA-PAIR/pair_lj_cut_sphere.cpp @@ -20,10 +20,7 @@ #include "math_special.h" #include "memory.h" #include "neigh_list.h" -#include "neighbor.h" -#include "update.h" -#include #include using namespace LAMMPS_NS; diff --git a/src/EXTRA-PAIR/pair_lj_expand_coul_long.cpp b/src/EXTRA-PAIR/pair_lj_expand_coul_long.cpp index 119ad6edbf..428b105621 100644 --- a/src/EXTRA-PAIR/pair_lj_expand_coul_long.cpp +++ b/src/EXTRA-PAIR/pair_lj_expand_coul_long.cpp @@ -21,6 +21,7 @@ #include "atom.h" #include "comm.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "kspace.h" #include "math_const.h" @@ -35,14 +36,7 @@ using namespace LAMMPS_NS; using namespace MathConst; - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/EXTRA-PAIR/pair_lj_expand_sphere.cpp b/src/EXTRA-PAIR/pair_lj_expand_sphere.cpp index 089a9deea7..c275a9f9ee 100644 --- a/src/EXTRA-PAIR/pair_lj_expand_sphere.cpp +++ b/src/EXTRA-PAIR/pair_lj_expand_sphere.cpp @@ -20,8 +20,6 @@ #include "math_special.h" #include "memory.h" #include "neigh_list.h" -#include "neighbor.h" -#include "update.h" #include #include diff --git a/src/EXTRA-PAIR/pair_nm_cut_coul_long.cpp b/src/EXTRA-PAIR/pair_nm_cut_coul_long.cpp index d68e12c37f..2d4d048e26 100644 --- a/src/EXTRA-PAIR/pair_nm_cut_coul_long.cpp +++ b/src/EXTRA-PAIR/pair_nm_cut_coul_long.cpp @@ -21,6 +21,7 @@ #include "atom.h" #include "comm.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "kspace.h" #include "math_const.h" @@ -33,14 +34,7 @@ using namespace LAMMPS_NS; using namespace MathConst; - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/FEP/pair_coul_long_soft.cpp b/src/FEP/pair_coul_long_soft.cpp index d243e7662f..bc3774fd1c 100644 --- a/src/FEP/pair_coul_long_soft.cpp +++ b/src/FEP/pair_coul_long_soft.cpp @@ -22,6 +22,7 @@ #include "atom.h" #include "comm.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "kspace.h" #include "memory.h" @@ -32,14 +33,7 @@ #include using namespace LAMMPS_NS; - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/FEP/pair_lj_charmm_coul_long_soft.cpp b/src/FEP/pair_lj_charmm_coul_long_soft.cpp index e1c3894790..1fa2ff6ea6 100644 --- a/src/FEP/pair_lj_charmm_coul_long_soft.cpp +++ b/src/FEP/pair_lj_charmm_coul_long_soft.cpp @@ -22,6 +22,7 @@ #include "atom.h" #include "comm.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "kspace.h" #include "memory.h" @@ -34,14 +35,7 @@ #include using namespace LAMMPS_NS; - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/FEP/pair_lj_class2_coul_long_soft.cpp b/src/FEP/pair_lj_class2_coul_long_soft.cpp index e7f928f540..43801ef5c6 100644 --- a/src/FEP/pair_lj_class2_coul_long_soft.cpp +++ b/src/FEP/pair_lj_class2_coul_long_soft.cpp @@ -17,6 +17,7 @@ #include "atom.h" #include "comm.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "kspace.h" #include "math_const.h" @@ -29,14 +30,7 @@ using namespace LAMMPS_NS; using namespace MathConst; - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/FEP/pair_lj_cut_coul_long_soft.cpp b/src/FEP/pair_lj_cut_coul_long_soft.cpp index 20fd052035..a5f9f03d12 100644 --- a/src/FEP/pair_lj_cut_coul_long_soft.cpp +++ b/src/FEP/pair_lj_cut_coul_long_soft.cpp @@ -22,6 +22,7 @@ #include "atom.h" #include "comm.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "kspace.h" #include "math_const.h" @@ -36,14 +37,7 @@ using namespace LAMMPS_NS; using namespace MathConst; - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/FEP/pair_lj_cut_tip4p_long_soft.cpp b/src/FEP/pair_lj_cut_tip4p_long_soft.cpp index bced5c17cc..d0a0d846a9 100644 --- a/src/FEP/pair_lj_cut_tip4p_long_soft.cpp +++ b/src/FEP/pair_lj_cut_tip4p_long_soft.cpp @@ -25,24 +25,18 @@ #include "bond.h" #include "comm.h" #include "domain.h" -#include "force.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "memory.h" #include "error.h" +#include "ewald_const.h" +#include "force.h" +#include "memory.h" +#include "neigh_list.h" +#include "neighbor.h" #include #include using namespace LAMMPS_NS; - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/FEP/pair_tip4p_long_soft.cpp b/src/FEP/pair_tip4p_long_soft.cpp index 4c357b32e0..09351f9e05 100644 --- a/src/FEP/pair_tip4p_long_soft.cpp +++ b/src/FEP/pair_tip4p_long_soft.cpp @@ -25,24 +25,18 @@ #include "bond.h" #include "comm.h" #include "domain.h" -#include "force.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "memory.h" #include "error.h" +#include "ewald_const.h" +#include "force.h" +#include "memory.h" +#include "neigh_list.h" +#include "neighbor.h" #include #include using namespace LAMMPS_NS; - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/GPU/fix_nh_gpu.cpp b/src/GPU/fix_nh_gpu.cpp index 00df278ea8..d15f6c6a7e 100644 --- a/src/GPU/fix_nh_gpu.cpp +++ b/src/GPU/fix_nh_gpu.cpp @@ -33,7 +33,7 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define TILTMAX 1.5 +static constexpr double TILTMAX = 1.5; enum{NOBIAS,BIAS}; enum{ISO,ANISO,TRICLINIC}; diff --git a/src/GPU/fix_nve_asphere_gpu.cpp b/src/GPU/fix_nve_asphere_gpu.cpp index 481f44bb63..9b75964c79 100644 --- a/src/GPU/fix_nve_asphere_gpu.cpp +++ b/src/GPU/fix_nve_asphere_gpu.cpp @@ -35,7 +35,7 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define INERTIA 0.2 // moment of inertia prefactor for ellipsoid +static constexpr double INERTIA = 0.2; // moment of inertia prefactor for ellipsoid #define ME_qnormalize(q) \ { \ diff --git a/src/GPU/pair_amoeba_gpu.cpp b/src/GPU/pair_amoeba_gpu.cpp index 1621e1f5b6..569dc125f0 100644 --- a/src/GPU/pair_amoeba_gpu.cpp +++ b/src/GPU/pair_amoeba_gpu.cpp @@ -51,7 +51,7 @@ enum{GORDON1,GORDON2}; // same as in pair_amoeba.cpp enum{MPOLE_GRID,POLAR_GRID,POLAR_GRIDC,DISP_GRID,INDUCE_GRID,INDUCE_GRIDC}; -#define DEBYE 4.80321 // conversion factor from q-Angs (real units) to Debye +static constexpr double DEBYE = 4.80321; // conversion factor from q-Angs (real units) to Debye // External functions from cuda library for atom decomposition diff --git a/src/GPU/pair_born_coul_long_cs_gpu.cpp b/src/GPU/pair_born_coul_long_cs_gpu.cpp index 798caeb97a..1ab61c0582 100644 --- a/src/GPU/pair_born_coul_long_cs_gpu.cpp +++ b/src/GPU/pair_born_coul_long_cs_gpu.cpp @@ -33,18 +33,18 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define EWALD_F 1.12837917 -#define EWALD_P 9.95473818e-1 -#define B0 -0.1335096380159268 -#define B1 -2.57839507e-1 -#define B2 -1.37203639e-1 -#define B3 -8.88822059e-3 -#define B4 -5.80844129e-3 -#define B5 1.14652755e-1 +static constexpr double EWALD_F = 1.12837917; +static constexpr double EWALD_P = 9.95473818e-1; +static constexpr double B0 = -0.1335096380159268; +static constexpr double B1 = -2.57839507e-1; +static constexpr double B2 = -1.37203639e-1; +static constexpr double B3 = -8.88822059e-3; +static constexpr double B4 = -5.80844129e-3; +static constexpr double B5 = 1.14652755e-1; -#define EPSILON 1.0e-20 -#define EPS_EWALD 1.0e-6 -#define EPS_EWALD_SQR 1.0e-12 +static constexpr double EPSILON = 1.0e-20; +static constexpr double EPS_EWALD = 1.0e-6; +static constexpr double EPS_EWALD_SQR = 1.0e-12; // External functions from cuda library for atom decomposition diff --git a/src/GPU/pair_born_coul_long_gpu.cpp b/src/GPU/pair_born_coul_long_gpu.cpp index ca12f03070..19b545003e 100644 --- a/src/GPU/pair_born_coul_long_gpu.cpp +++ b/src/GPU/pair_born_coul_long_gpu.cpp @@ -20,6 +20,7 @@ #include "atom.h" #include "domain.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "gpu_extra.h" #include "kspace.h" @@ -30,16 +31,9 @@ #include -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 - using namespace LAMMPS_NS; using namespace MathConst; +using namespace EwaldConst; // External functions from cuda library for atom decomposition diff --git a/src/GPU/pair_born_coul_wolf_cs_gpu.cpp b/src/GPU/pair_born_coul_wolf_cs_gpu.cpp index 9858015622..128863527c 100644 --- a/src/GPU/pair_born_coul_wolf_cs_gpu.cpp +++ b/src/GPU/pair_born_coul_wolf_cs_gpu.cpp @@ -32,7 +32,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define EPSILON 1.0e-20 +static constexpr double EPSILON = 1.0e-20; // External functions from cuda library for atom decomposition diff --git a/src/GPU/pair_buck_coul_long_gpu.cpp b/src/GPU/pair_buck_coul_long_gpu.cpp index adae92d1ac..bb29096007 100644 --- a/src/GPU/pair_buck_coul_long_gpu.cpp +++ b/src/GPU/pair_buck_coul_long_gpu.cpp @@ -20,6 +20,7 @@ #include "atom.h" #include "domain.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "gpu_extra.h" #include "kspace.h" @@ -29,15 +30,8 @@ #include -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 - using namespace LAMMPS_NS; +using namespace EwaldConst; // External functions from cuda library for atom decomposition diff --git a/src/GPU/pair_coul_dsf_gpu.cpp b/src/GPU/pair_coul_dsf_gpu.cpp index bf207caf60..86f104d2e8 100644 --- a/src/GPU/pair_coul_dsf_gpu.cpp +++ b/src/GPU/pair_coul_dsf_gpu.cpp @@ -20,24 +20,19 @@ #include "atom.h" #include "domain.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "gpu_extra.h" +#include "math_const.h" #include "neigh_list.h" #include "neighbor.h" #include "suffix.h" #include -#define MY_PIS 1.77245385090551602729 -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 - using namespace LAMMPS_NS; +using namespace EwaldConst; +using MathConst::MY_PIS; // External functions from cuda library for atom decomposition diff --git a/src/GPU/pair_coul_long_cs_gpu.cpp b/src/GPU/pair_coul_long_cs_gpu.cpp index 79c4c4ab7c..5eba34c85f 100644 --- a/src/GPU/pair_coul_long_cs_gpu.cpp +++ b/src/GPU/pair_coul_long_cs_gpu.cpp @@ -31,18 +31,18 @@ using namespace LAMMPS_NS; -#define EWALD_F 1.12837917 -#define EWALD_P 9.95473818e-1 -#define B0 -0.1335096380159268 -#define B1 -2.57839507e-1 -#define B2 -1.37203639e-1 -#define B3 -8.88822059e-3 -#define B4 -5.80844129e-3 -#define B5 1.14652755e-1 +static constexpr double EWALD_F = 1.12837917; +static constexpr double EWALD_P = 9.95473818e-1; +static constexpr double B0 = -0.1335096380159268; +static constexpr double B1 = -2.57839507e-1; +static constexpr double B2 = -1.37203639e-1; +static constexpr double B3 = -8.88822059e-3; +static constexpr double B4 = -5.80844129e-3; +static constexpr double B5 = 1.14652755e-1; -#define EPSILON 1.0e-20 -#define EPS_EWALD 1.0e-6 -#define EPS_EWALD_SQR 1.0e-12 +static constexpr double EPSILON = 1.0e-20; +static constexpr double EPS_EWALD = 1.0e-6; +static constexpr double EPS_EWALD_SQR = 1.0e-12; // External functions from cuda library for atom decomposition diff --git a/src/GPU/pair_coul_long_gpu.cpp b/src/GPU/pair_coul_long_gpu.cpp index 7ecb052f69..eb176673dd 100644 --- a/src/GPU/pair_coul_long_gpu.cpp +++ b/src/GPU/pair_coul_long_gpu.cpp @@ -20,6 +20,7 @@ #include "atom.h" #include "domain.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "gpu_extra.h" #include "kspace.h" @@ -29,15 +30,8 @@ #include -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 - using namespace LAMMPS_NS; +using namespace EwaldConst; // External functions from cuda library for atom decomposition diff --git a/src/GPU/pair_coul_slater_long_gpu.cpp b/src/GPU/pair_coul_slater_long_gpu.cpp index 4ace8bd761..c5489fa9fb 100644 --- a/src/GPU/pair_coul_slater_long_gpu.cpp +++ b/src/GPU/pair_coul_slater_long_gpu.cpp @@ -20,6 +20,7 @@ #include "atom.h" #include "domain.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "gpu_extra.h" #include "kspace.h" @@ -29,15 +30,8 @@ #include -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 - using namespace LAMMPS_NS; +using namespace EwaldConst; // External functions from cuda library for atom decomposition diff --git a/src/GPU/pair_dpd_gpu.cpp b/src/GPU/pair_dpd_gpu.cpp index e4657cf2eb..afbdedcd11 100644 --- a/src/GPU/pair_dpd_gpu.cpp +++ b/src/GPU/pair_dpd_gpu.cpp @@ -53,7 +53,7 @@ void dpd_gpu_compute(const int ago, const int inum_full, const int nall, double double *boxlo, double *prd); double dpd_gpu_bytes(); -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; //#define _USE_UNIFORM_SARU_LCG //#define _USE_UNIFORM_SARU_TEA8 diff --git a/src/GPU/pair_dpd_tstat_gpu.cpp b/src/GPU/pair_dpd_tstat_gpu.cpp index 4a7b05fd2c..6889a0e0b8 100644 --- a/src/GPU/pair_dpd_tstat_gpu.cpp +++ b/src/GPU/pair_dpd_tstat_gpu.cpp @@ -55,7 +55,7 @@ void dpd_tstat_gpu_update_coeff(int ntypes, double **host_a0, double **host_gamm double **host_sigma, double **host_cut); double dpd_tstat_gpu_bytes(); -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; //#define _USE_UNIFORM_SARU_LCG //#define _USE_UNIFORM_SARU_TEA8 diff --git a/src/GPU/pair_eam_gpu.cpp b/src/GPU/pair_eam_gpu.cpp index 155da43768..40f143ebde 100644 --- a/src/GPU/pair_eam_gpu.cpp +++ b/src/GPU/pair_eam_gpu.cpp @@ -29,8 +29,6 @@ #include -#define MAXLINE 1024 - using namespace LAMMPS_NS; // External functions from cuda library for atom decomposition diff --git a/src/GPU/pair_edpd_gpu.cpp b/src/GPU/pair_edpd_gpu.cpp index 5bee0cadb8..4b865b6a7e 100644 --- a/src/GPU/pair_edpd_gpu.cpp +++ b/src/GPU/pair_edpd_gpu.cpp @@ -58,8 +58,6 @@ void edpd_gpu_get_extra_data(double *host_T, double *host_cv); void edpd_gpu_update_flux(void **flux_ptr); double edpd_gpu_bytes(); -#define EPSILON 1.0e-10 - /* ---------------------------------------------------------------------- */ PairEDPDGPU::PairEDPDGPU(LAMMPS *lmp) : PairEDPD(lmp), gpu_mode(GPU_FORCE) diff --git a/src/GPU/pair_hippo_gpu.cpp b/src/GPU/pair_hippo_gpu.cpp index 59a95619d7..7346ffda8c 100644 --- a/src/GPU/pair_hippo_gpu.cpp +++ b/src/GPU/pair_hippo_gpu.cpp @@ -50,7 +50,7 @@ enum{GORDON1,GORDON2}; // same as in pair_amoeba.cpp enum{MPOLE_GRID,POLAR_GRID,POLAR_GRIDC,DISP_GRID,INDUCE_GRID,INDUCE_GRIDC}; -#define DEBYE 4.80321 // conversion factor from q-Angs (real units) to Debye +static constexpr double DEBYE = 4.80321; // conversion factor from q-Angs (real units) to Debye // External functions from cuda library for atom decomposition diff --git a/src/GPU/pair_lj_charmm_coul_long_gpu.cpp b/src/GPU/pair_lj_charmm_coul_long_gpu.cpp index 87d4896bde..a84ec67c6b 100644 --- a/src/GPU/pair_lj_charmm_coul_long_gpu.cpp +++ b/src/GPU/pair_lj_charmm_coul_long_gpu.cpp @@ -20,6 +20,7 @@ #include "atom.h" #include "domain.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "gpu_extra.h" #include "kspace.h" @@ -29,15 +30,8 @@ #include -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 - using namespace LAMMPS_NS; +using namespace EwaldConst; // External functions from cuda library for atom decomposition diff --git a/src/GPU/pair_lj_class2_coul_long_gpu.cpp b/src/GPU/pair_lj_class2_coul_long_gpu.cpp index 90a4682e8f..0f87099e3b 100644 --- a/src/GPU/pair_lj_class2_coul_long_gpu.cpp +++ b/src/GPU/pair_lj_class2_coul_long_gpu.cpp @@ -20,6 +20,7 @@ #include "atom.h" #include "domain.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "gpu_extra.h" #include "kspace.h" @@ -29,15 +30,8 @@ #include -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 - using namespace LAMMPS_NS; +using namespace EwaldConst; // External functions from cuda library for atom decomposition diff --git a/src/GPU/pair_lj_cut_coul_dsf_gpu.cpp b/src/GPU/pair_lj_cut_coul_dsf_gpu.cpp index 08d90b8b57..32a4008def 100644 --- a/src/GPU/pair_lj_cut_coul_dsf_gpu.cpp +++ b/src/GPU/pair_lj_cut_coul_dsf_gpu.cpp @@ -20,24 +20,19 @@ #include "atom.h" #include "domain.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "gpu_extra.h" +#include "math_const.h" #include "neigh_list.h" #include "neighbor.h" #include "suffix.h" #include -#define MY_PIS 1.77245385090551602729 -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 - using namespace LAMMPS_NS; +using namespace EwaldConst; +using MathConst::MY_PIS; // External functions from cuda library for atom decomposition diff --git a/src/GPU/pair_lj_cut_coul_long_gpu.cpp b/src/GPU/pair_lj_cut_coul_long_gpu.cpp index c70fe555d0..45e71440eb 100644 --- a/src/GPU/pair_lj_cut_coul_long_gpu.cpp +++ b/src/GPU/pair_lj_cut_coul_long_gpu.cpp @@ -20,6 +20,7 @@ #include "atom.h" #include "domain.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "gpu_extra.h" #include "kspace.h" @@ -29,15 +30,8 @@ #include -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 - using namespace LAMMPS_NS; +using namespace EwaldConst; // External functions from cuda library for atom decomposition diff --git a/src/GPU/pair_lj_cut_coul_long_soft_gpu.cpp b/src/GPU/pair_lj_cut_coul_long_soft_gpu.cpp index e8342b6530..e6e40ce08e 100644 --- a/src/GPU/pair_lj_cut_coul_long_soft_gpu.cpp +++ b/src/GPU/pair_lj_cut_coul_long_soft_gpu.cpp @@ -20,6 +20,7 @@ #include "atom.h" #include "domain.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "gpu_extra.h" #include "kspace.h" @@ -29,15 +30,8 @@ #include -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 - using namespace LAMMPS_NS; +using namespace EwaldConst; // External functions from cuda library for atom decomposition diff --git a/src/GPU/pair_lj_cut_dipole_cut_gpu.cpp b/src/GPU/pair_lj_cut_dipole_cut_gpu.cpp index b71e526bf2..1052e16c11 100644 --- a/src/GPU/pair_lj_cut_dipole_cut_gpu.cpp +++ b/src/GPU/pair_lj_cut_dipole_cut_gpu.cpp @@ -179,7 +179,7 @@ void PairLJCutDipoleCutGPU::cpu_compute(int start, int inum, int eflag, int vfla double qtmp, xtmp, ytmp, ztmp, delx, dely, delz, evdwl, ecoul, fx, fy, fz; double rsq, rinv, r2inv, r6inv, r3inv, r5inv, r7inv; double forcecoulx, forcecouly, forcecoulz, crossx, crossy, crossz; - double tixcoul, tiycoul, tizcoul, tjxcoul, tjycoul, tjzcoul; + double tixcoul, tiycoul, tizcoul; double fq, pdotp, pidotr, pjdotr, pre1, pre2, pre3, pre4; double forcelj, factor_coul, factor_lj; int *jlist; @@ -230,7 +230,6 @@ void PairLJCutDipoleCutGPU::cpu_compute(int start, int inum, int eflag, int vfla forcecoulx = forcecouly = forcecoulz = 0.0; tixcoul = tiycoul = tizcoul = 0.0; - tjxcoul = tjycoul = tjzcoul = 0.0; if (rsq < cut_coulsq[itype][jtype]) { @@ -268,9 +267,6 @@ void PairLJCutDipoleCutGPU::cpu_compute(int start, int inum, int eflag, int vfla tixcoul += crossx + pre2 * (mu[i][1] * delz - mu[i][2] * dely); tiycoul += crossy + pre2 * (mu[i][2] * delx - mu[i][0] * delz); tizcoul += crossz + pre2 * (mu[i][0] * dely - mu[i][1] * delx); - tjxcoul += -crossx + pre3 * (mu[j][1] * delz - mu[j][2] * dely); - tjycoul += -crossy + pre3 * (mu[j][2] * delx - mu[j][0] * delz); - tjzcoul += -crossz + pre3 * (mu[j][0] * dely - mu[j][1] * delx); } if (mu[i][3] > 0.0 && q[j] != 0.0) { @@ -298,9 +294,6 @@ void PairLJCutDipoleCutGPU::cpu_compute(int start, int inum, int eflag, int vfla forcecoulx += pre1 * delx - pre2 * mu[j][0]; forcecouly += pre1 * dely - pre2 * mu[j][1]; forcecoulz += pre1 * delz - pre2 * mu[j][2]; - tjxcoul += -pre2 * (mu[j][1] * delz - mu[j][2] * dely); - tjycoul += -pre2 * (mu[j][2] * delx - mu[j][0] * delz); - tjzcoul += -pre2 * (mu[j][0] * dely - mu[j][1] * delx); } } diff --git a/src/GPU/pair_lj_cut_dipole_long_gpu.cpp b/src/GPU/pair_lj_cut_dipole_long_gpu.cpp index df1a2d78ba..6c04b92b47 100644 --- a/src/GPU/pair_lj_cut_dipole_long_gpu.cpp +++ b/src/GPU/pair_lj_cut_dipole_long_gpu.cpp @@ -20,6 +20,7 @@ #include "atom.h" #include "domain.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "gpu_extra.h" #include "kspace.h" @@ -32,16 +33,9 @@ #include #include -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 - using namespace LAMMPS_NS; using namespace MathConst; +using namespace EwaldConst; // External functions from cuda library for atom decomposition @@ -207,7 +201,7 @@ void PairLJCutDipoleLongGPU::cpu_compute(int start, int inum, int eflag, int vfl double pdotp, pidotr, pjdotr, pre1, pre2, pre3; double grij, expm2, t, erfc; double g0, g1, g2, b0, b1, b2, b3, d0, d1, d2, d3; - double zdix, zdiy, zdiz, zdjx, zdjy, zdjz, zaix, zaiy, zaiz, zajx, zajy, zajz; + double zdix, zdiy, zdiz, zaix, zaiy, zaiz; double g0b1_g1b2_g2b3, g0d1_g1d2_g2d3; double forcelj, factor_coul, factor_lj, facm1; double evdwl, ecoul; @@ -290,9 +284,6 @@ void PairLJCutDipoleLongGPU::cpu_compute(int start, int inum, int eflag, int vfl zdix = delx * (q[j] * b1 + b2 * pjdotr) - b1 * mu[j][0]; zdiy = dely * (q[j] * b1 + b2 * pjdotr) - b1 * mu[j][1]; zdiz = delz * (q[j] * b1 + b2 * pjdotr) - b1 * mu[j][2]; - zdjx = delx * (-qtmp * b1 + b2 * pidotr) - b1 * mu[i][0]; - zdjy = dely * (-qtmp * b1 + b2 * pidotr) - b1 * mu[i][1]; - zdjz = delz * (-qtmp * b1 + b2 * pidotr) - b1 * mu[i][2]; if (factor_coul < 1.0) { fdx *= factor_coul; @@ -301,14 +292,10 @@ void PairLJCutDipoleLongGPU::cpu_compute(int start, int inum, int eflag, int vfl zdix *= factor_coul; zdiy *= factor_coul; zdiz *= factor_coul; - zdjx *= factor_coul; - zdjy *= factor_coul; - zdjz *= factor_coul; } } else { fdx = fdy = fdz = 0.0; zdix = zdiy = zdiz = 0.0; - zdjx = zdjy = zdjz = 0.0; } if (factor_coul < 1.0) { @@ -328,9 +315,6 @@ void PairLJCutDipoleLongGPU::cpu_compute(int start, int inum, int eflag, int vfl zaix = delx * (q[j] * d1 + d2 * pjdotr) - d1 * mu[j][0]; zaiy = dely * (q[j] * d1 + d2 * pjdotr) - d1 * mu[j][1]; zaiz = delz * (q[j] * d1 + d2 * pjdotr) - d1 * mu[j][2]; - zajx = delx * (-qtmp * d1 + d2 * pidotr) - d1 * mu[i][0]; - zajy = dely * (-qtmp * d1 + d2 * pidotr) - d1 * mu[i][1]; - zajz = delz * (-qtmp * d1 + d2 * pidotr) - d1 * mu[i][2]; if (factor_coul > 0.0) { facm1 = 1.0 - factor_coul; @@ -340,14 +324,10 @@ void PairLJCutDipoleLongGPU::cpu_compute(int start, int inum, int eflag, int vfl zaix *= facm1; zaiy *= facm1; zaiz *= facm1; - zajx *= facm1; - zajy *= facm1; - zajz *= facm1; } } else { fax = fay = faz = 0.0; zaix = zaiy = zaiz = 0.0; - zajx = zajy = zajz = 0.0; } forcecoulx = fdx + fax; diff --git a/src/GPU/pair_lj_cut_tip4p_long_gpu.cpp b/src/GPU/pair_lj_cut_tip4p_long_gpu.cpp index d7eaf4b006..b89272c457 100644 --- a/src/GPU/pair_lj_cut_tip4p_long_gpu.cpp +++ b/src/GPU/pair_lj_cut_tip4p_long_gpu.cpp @@ -23,6 +23,7 @@ #include "comm.h" #include "domain.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "gpu_extra.h" #include "kspace.h" @@ -33,15 +34,8 @@ #include -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 - using namespace LAMMPS_NS; +using namespace EwaldConst; // External functions from cuda library for atom decomposition diff --git a/src/GPU/pair_lj_expand_coul_long_gpu.cpp b/src/GPU/pair_lj_expand_coul_long_gpu.cpp index 35cb18122a..99f61316e2 100644 --- a/src/GPU/pair_lj_expand_coul_long_gpu.cpp +++ b/src/GPU/pair_lj_expand_coul_long_gpu.cpp @@ -20,6 +20,7 @@ #include "atom.h" #include "domain.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "gpu_extra.h" #include "kspace.h" @@ -29,15 +30,8 @@ #include -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 - using namespace LAMMPS_NS; +using namespace EwaldConst; // External functions from cuda library for atom decomposition diff --git a/src/GPU/pair_lj_sf_dipole_sf_gpu.cpp b/src/GPU/pair_lj_sf_dipole_sf_gpu.cpp index 4d8fbb5139..57ba3ec353 100644 --- a/src/GPU/pair_lj_sf_dipole_sf_gpu.cpp +++ b/src/GPU/pair_lj_sf_dipole_sf_gpu.cpp @@ -178,8 +178,8 @@ void PairLJSFDipoleSFGPU::cpu_compute(int start, int inum, int eflag, int vflag, double qtmp, xtmp, ytmp, ztmp, delx, dely, delz, evdwl, ecoul, fx, fy, fz; double rsq, rinv, r2inv, r6inv, r3inv, r5inv; double forcecoulx, forcecouly, forcecoulz, crossx, crossy, crossz; - double tixcoul, tiycoul, tizcoul, tjxcoul, tjycoul, tjzcoul; - double fq, pdotp, pidotr, pjdotr, pre1, pre2, pre3, pre4; + double tixcoul, tiycoul, tizcoul; + double fq, pdotp, pidotr, pjdotr, pre1, pre2, pre4; double forcelj, factor_coul, factor_lj; double presf, afac, bfac, pqfac, qpfac, forceljcut, forceljsf; double aforcecoulx, aforcecouly, aforcecoulz; @@ -233,7 +233,6 @@ void PairLJSFDipoleSFGPU::cpu_compute(int start, int inum, int eflag, int vflag, forcecoulx = forcecouly = forcecoulz = 0.0; tixcoul = tiycoul = tizcoul = 0.0; - tjxcoul = tjycoul = tjzcoul = 0.0; if (rsq < cut_coulsq[itype][jtype]) { @@ -272,7 +271,6 @@ void PairLJSFDipoleSFGPU::cpu_compute(int start, int inum, int eflag, int vflag, forcecoulz += 3.0 * r5inv * (aforcecoulz + bforcecoulz); pre2 = 3.0 * bfac * r5inv * pjdotr; - pre3 = 3.0 * bfac * r5inv * pidotr; pre4 = -bfac * r3inv; crossx = pre4 * (mu[i][1] * mu[j][2] - mu[i][2] * mu[j][1]); @@ -282,9 +280,6 @@ void PairLJSFDipoleSFGPU::cpu_compute(int start, int inum, int eflag, int vflag, tixcoul += crossx + pre2 * (mu[i][1] * delz - mu[i][2] * dely); tiycoul += crossy + pre2 * (mu[i][2] * delx - mu[i][0] * delz); tizcoul += crossz + pre2 * (mu[i][0] * dely - mu[i][1] * delx); - tjxcoul += -crossx + pre3 * (mu[j][1] * delz - mu[j][2] * dely); - tjycoul += -crossy + pre3 * (mu[j][2] * delx - mu[j][0] * delz); - tjzcoul += -crossz + pre3 * (mu[j][0] * dely - mu[j][1] * delx); } if (mu[i][3] > 0.0 && q[j] != 0.0) { @@ -318,9 +313,6 @@ void PairLJSFDipoleSFGPU::cpu_compute(int start, int inum, int eflag, int vflag, forcecoulx += pre1 * delx - pre2 * mu[j][0]; forcecouly += pre1 * dely - pre2 * mu[j][1]; forcecoulz += pre1 * delz - pre2 * mu[j][2]; - tjxcoul += -pre2 * (mu[j][1] * delz - mu[j][2] * dely); - tjycoul += -pre2 * (mu[j][2] * delx - mu[j][0] * delz); - tjzcoul += -pre2 * (mu[j][0] * dely - mu[j][1] * delx); } } diff --git a/src/GPU/pair_lj_spica_coul_long_gpu.cpp b/src/GPU/pair_lj_spica_coul_long_gpu.cpp index 4317c04220..896f692d02 100644 --- a/src/GPU/pair_lj_spica_coul_long_gpu.cpp +++ b/src/GPU/pair_lj_spica_coul_long_gpu.cpp @@ -20,6 +20,7 @@ #include "atom.h" #include "domain.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "gpu_extra.h" #include "kspace.h" @@ -29,15 +30,8 @@ #include -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 - using namespace LAMMPS_NS; +using namespace EwaldConst; // External functions from cuda library for atom decomposition diff --git a/src/GPU/pair_mdpd_gpu.cpp b/src/GPU/pair_mdpd_gpu.cpp index bebe1e9736..8647dbd0fd 100644 --- a/src/GPU/pair_mdpd_gpu.cpp +++ b/src/GPU/pair_mdpd_gpu.cpp @@ -55,8 +55,6 @@ void mdpd_gpu_compute(const int ago, const int inum_full, const int nall, double void mdpd_gpu_get_extra_data(double *host_rho); double mdpd_gpu_bytes(); -#define EPSILON 1.0e-10 - /* ---------------------------------------------------------------------- */ PairMDPDGPU::PairMDPDGPU(LAMMPS *lmp) : PairMDPD(lmp), gpu_mode(GPU_FORCE) diff --git a/src/GPU/pair_sph_heatconduction_gpu.cpp b/src/GPU/pair_sph_heatconduction_gpu.cpp index 0f0aa079c8..a81de53c91 100644 --- a/src/GPU/pair_sph_heatconduction_gpu.cpp +++ b/src/GPU/pair_sph_heatconduction_gpu.cpp @@ -53,7 +53,7 @@ void sph_heatconduction_gpu_compute(const int ago, const int inum_full, const in int **firstneigh, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, const double cpu_time, bool &success, tagint *host_tag, - double **host_v, const int nlocal); + double **host_v); void sph_heatconduction_gpu_get_extra_data(double *host_rho, double *host_esph); void sph_heatconduction_gpu_update_dE(void **dE_ptr); double sph_heatconduction_gpu_bytes(); @@ -122,7 +122,7 @@ void PairSPHHeatConductionGPU::compute(int eflag, int vflag) sph_heatconduction_gpu_compute(neighbor->ago, inum, nall, atom->x, atom->type, ilist, numneigh, firstneigh, eflag, vflag, eflag_atom, vflag_atom, host_start, cpu_time, success, - atom->tag, atom->v, atom->nlocal); + atom->tag, atom->v); } if (!success) error->one(FLERR, "Insufficient memory on accelerator"); diff --git a/src/GPU/pair_sph_lj_gpu.cpp b/src/GPU/pair_sph_lj_gpu.cpp index 942a3c33bd..46d7b38073 100644 --- a/src/GPU/pair_sph_lj_gpu.cpp +++ b/src/GPU/pair_sph_lj_gpu.cpp @@ -53,7 +53,7 @@ void sph_lj_gpu_compute(const int ago, const int inum_full, const int nall, int **firstneigh, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, const double cpu_time, bool &success, tagint *host_tag, - double **host_v, const int nlocal); + double **host_v); void sph_lj_gpu_get_extra_data(double *host_rho, double *host_esph, double *host_cv); void sph_lj_gpu_update_drhoE(void **drhoE_ptr); @@ -123,7 +123,7 @@ void PairSPHLJGPU::compute(int eflag, int vflag) sph_lj_gpu_compute(neighbor->ago, inum, nall, atom->x, atom->type, ilist, numneigh, firstneigh, eflag, vflag, eflag_atom, vflag_atom, host_start, cpu_time, success, - atom->tag, atom->v, atom->nlocal); + atom->tag, atom->v); } if (!success) error->one(FLERR, "Insufficient memory on accelerator"); diff --git a/src/GPU/pair_sph_taitwater_gpu.cpp b/src/GPU/pair_sph_taitwater_gpu.cpp index 37a1b0feb5..6f2762c144 100644 --- a/src/GPU/pair_sph_taitwater_gpu.cpp +++ b/src/GPU/pair_sph_taitwater_gpu.cpp @@ -53,7 +53,7 @@ void sph_taitwater_gpu_compute(const int ago, const int inum_full, const int nal int **firstneigh, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, const double cpu_time, bool &success, tagint *tag, - double **host_v, const int nlocal); + double **host_v); void sph_taitwater_gpu_get_extra_data(double *host_rho); void sph_taitwater_gpu_update_drhoE(void **drhoE_ptr); double sph_taitwater_gpu_bytes(); @@ -118,7 +118,7 @@ void PairSPHTaitwaterGPU::compute(int eflag, int vflag) firstneigh = list->firstneigh; sph_taitwater_gpu_compute(neighbor->ago, inum, nall, atom->x, atom->type, ilist, numneigh, firstneigh, eflag, vflag, eflag_atom, vflag_atom, host_start, cpu_time, success, - atom->tag, atom->v, atom->nlocal); + atom->tag, atom->v); } if (!success) error->one(FLERR, "Insufficient memory on accelerator"); diff --git a/src/GPU/pair_sw_gpu.cpp b/src/GPU/pair_sw_gpu.cpp index 7645218a85..3e916a6571 100644 --- a/src/GPU/pair_sw_gpu.cpp +++ b/src/GPU/pair_sw_gpu.cpp @@ -49,9 +49,6 @@ void sw_gpu_compute(const int ago, const int nloc, const int nall, const int ln, const double cpu_time, bool &success); double sw_gpu_bytes(); -#define MAXLINE 1024 -#define DELTA 4 - /* ---------------------------------------------------------------------- */ PairSWGPU::PairSWGPU(LAMMPS *lmp) : PairSW(lmp), gpu_mode(GPU_FORCE) diff --git a/src/GPU/pair_tersoff_gpu.cpp b/src/GPU/pair_tersoff_gpu.cpp index 8610a3880c..9ba94548c1 100644 --- a/src/GPU/pair_tersoff_gpu.cpp +++ b/src/GPU/pair_tersoff_gpu.cpp @@ -54,9 +54,6 @@ void tersoff_gpu_compute(const int ago, const int nlocal, const int nall, const int &host_start, const double cpu_time, bool &success); double tersoff_gpu_bytes(); -#define MAXLINE 1024 -#define DELTA 4 - /* ---------------------------------------------------------------------- */ PairTersoffGPU::PairTersoffGPU(LAMMPS *lmp) : PairTersoff(lmp), gpu_mode(GPU_FORCE) diff --git a/src/GPU/pair_yukawa_colloid_gpu.cpp b/src/GPU/pair_yukawa_colloid_gpu.cpp index c1e785380d..db199a4701 100644 --- a/src/GPU/pair_yukawa_colloid_gpu.cpp +++ b/src/GPU/pair_yukawa_colloid_gpu.cpp @@ -123,7 +123,7 @@ void PairYukawaColloidGPU::compute(int eflag, int vflag) void PairYukawaColloidGPU::init_style() { - if (!atom->sphere_flag) error->all(FLERR, "Pair yukawa/colloid/gpu requires atom style sphere"); + if (!atom->radius_flag) error->all(FLERR, "Pair style yukawa/colloid/gpu requires atom attribute radius"); // Repeat cutsq calculation because done after call to init_style double maxcut = -1.0; diff --git a/src/GPU/pppm_gpu.cpp b/src/GPU/pppm_gpu.cpp index 1959f00865..517d843c93 100644 --- a/src/GPU/pppm_gpu.cpp +++ b/src/GPU/pppm_gpu.cpp @@ -1,4 +1,3 @@ - // clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator @@ -40,22 +39,10 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define MAXORDER 7 -#define OFFSET 16384 -#define SMALL 0.00001 -#define LARGE 10000.0 -#define EPS_HOC 1.0e-7 +enum { REVERSE_RHO_GPU, REVERSE_RHO }; +enum { FORWARD_IK, FORWARD_AD, FORWARD_IK_PERATOM, FORWARD_AD_PERATOM }; -enum{REVERSE_RHO_GPU,REVERSE_RHO}; -enum{FORWARD_IK,FORWARD_AD,FORWARD_IK_PERATOM,FORWARD_AD_PERATOM}; - -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#define ONEF 1.0f -#else -#define ZEROF 0.0 -#define ONEF 1.0 -#endif +static constexpr FFT_SCALAR ZEROF = 0.0; // external functions from cuda library for atom decomposition diff --git a/src/GRANULAR/compute_contact_atom.cpp b/src/GRANULAR/compute_contact_atom.cpp index 310fdb5a41..a3e71af0fe 100644 --- a/src/GRANULAR/compute_contact_atom.cpp +++ b/src/GRANULAR/compute_contact_atom.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -51,7 +50,7 @@ ComputeContactAtom::ComputeContactAtom(LAMMPS *lmp, int narg, char **arg) : // error checks - if (!atom->sphere_flag) error->all(FLERR, "Compute contact/atom requires atom style sphere"); + if (!atom->radius_flag) error->all(FLERR, "Compute contact/atom requires atom attribute radius"); } /* ---------------------------------------------------------------------- */ @@ -67,10 +66,10 @@ ComputeContactAtom::~ComputeContactAtom() void ComputeContactAtom::init() { if (force->pair == nullptr) - error->all(FLERR,"Compute contact/atom requires a pair style be defined"); + error->all(FLERR, "Compute contact/atom requires a pair style be defined"); if (modify->get_compute_by_style("contact/atom").size() > 1 && comm->me == 0) - error->warning(FLERR,"More than one compute contact/atom"); + error->warning(FLERR, "More than one compute contact/atom"); // need an occasional neighbor list @@ -88,10 +87,10 @@ void ComputeContactAtom::init_list(int /*id*/, NeighList *ptr) void ComputeContactAtom::compute_peratom() { - int i,j,ii,jj,inum,jnum; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - double radi,radsum,radsumsq; - int *ilist,*jlist,*numneigh,**firstneigh; + int i, j, ii, jj, inum, jnum; + double xtmp, ytmp, ztmp, delx, dely, delz, rsq; + double radi, radsum, radsumsq; + int *ilist, *jlist, *numneigh, **firstneigh; invoked_peratom = update->ntimestep; @@ -100,7 +99,7 @@ void ComputeContactAtom::compute_peratom() if (atom->nmax > nmax) { memory->destroy(contact); nmax = atom->nmax; - memory->create(contact,nmax,"contact/atom:contact"); + memory->create(contact, nmax, "contact/atom:contact"); vector_atom = contact; } @@ -130,7 +129,7 @@ void ComputeContactAtom::compute_peratom() i = ilist[ii]; // Only proceed if i is either part of the compute group or will contribute to contacts - if (! (mask[i] & groupbit) && ! (mask[i] & jgroupbit)) continue; + if (!(mask[i] & groupbit) && !(mask[i] & jgroupbit)) continue; xtmp = x[i][0]; ytmp = x[i][1]; @@ -146,7 +145,7 @@ void ComputeContactAtom::compute_peratom() // Only tally for atoms in compute group (groupbit) if neighbor is in group2 (jgroupbit) update_i_flag = (mask[i] & groupbit) && (mask[j] & jgroupbit); update_j_flag = (mask[j] & groupbit) && (mask[i] & jgroupbit); - if (! update_i_flag && ! update_j_flag) continue; + if (!update_i_flag && !update_j_flag) continue; delx = xtmp - x[j][0]; dely = ytmp - x[j][1]; @@ -170,12 +169,11 @@ void ComputeContactAtom::compute_peratom() int ComputeContactAtom::pack_reverse_comm(int n, int first, double *buf) { - int i,m,last; + int i, m, last; m = 0; last = first + n; - for (i = first; i < last; i++) - buf[m++] = contact[i]; + for (i = first; i < last; i++) buf[m++] = contact[i]; return m; } @@ -183,7 +181,7 @@ int ComputeContactAtom::pack_reverse_comm(int n, int first, double *buf) void ComputeContactAtom::unpack_reverse_comm(int n, int *list, double *buf) { - int i,j,m; + int i, j, m; m = 0; for (i = 0; i < n; i++) { @@ -198,6 +196,6 @@ void ComputeContactAtom::unpack_reverse_comm(int n, int *list, double *buf) double ComputeContactAtom::memory_usage() { - double bytes = (double)nmax * sizeof(double); + double bytes = (double) nmax * sizeof(double); return bytes; } diff --git a/src/GRANULAR/compute_fabric.cpp b/src/GRANULAR/compute_fabric.cpp index adaf242c92..04afc95280 100644 --- a/src/GRANULAR/compute_fabric.cpp +++ b/src/GRANULAR/compute_fabric.cpp @@ -184,7 +184,7 @@ void ComputeFabric::compute_vector() double nx, ny, nz; double ncinv, denom, fn, ft, prefactor; double br_tensor[6], ft_tensor[6], fn_tensor[6]; - double trace_phi, trace_D, trace_Xfn, trace_Xft; + double trace_third_phi, trace_third_D, trace_third_Xfn, trace_third_Xft; double phi_ij[6] = {0.0}; double Ac_ij[6] = {0.0}; double D_ij[6] = {0.0}; @@ -295,11 +295,11 @@ void ComputeFabric::compute_vector() MPI_Allreduce(phi_ij, temp_dbl, 6, MPI_DOUBLE, MPI_SUM, world); for (i = 0; i < 6; i++) phi_ij[i] = temp_dbl[i] * ncinv; - trace_phi = (1.0 / 3.0) * (phi_ij[0] + phi_ij[1] + phi_ij[2]); + trace_third_phi = (1.0 / 3.0) * (phi_ij[0] + phi_ij[1] + phi_ij[2]); - Ac_ij[0] = (15.0 / 2.0) * (phi_ij[0] - trace_phi); - Ac_ij[1] = (15.0 / 2.0) * (phi_ij[1] - trace_phi); - Ac_ij[2] = (15.0 / 2.0) * (phi_ij[2] - trace_phi); + Ac_ij[0] = (15.0 / 2.0) * (phi_ij[0] - trace_third_phi); + Ac_ij[1] = (15.0 / 2.0) * (phi_ij[1] - trace_third_phi); + Ac_ij[2] = (15.0 / 2.0) * (phi_ij[2] - trace_third_phi); Ac_ij[3] = (15.0 / 2.0) * (phi_ij[3]); Ac_ij[4] = (15.0 / 2.0) * (phi_ij[4]); Ac_ij[5] = (15.0 / 2.0) * (phi_ij[5]); @@ -419,14 +419,14 @@ void ComputeFabric::compute_vector() MPI_Allreduce(D_ij, temp_dbl, 6, MPI_DOUBLE, MPI_SUM, world); for (i = 0; i < 6; i++) D_ij[i] = temp_dbl[i]; - trace_D = (1.0 / 3.0) * (D_ij[0] + D_ij[1] + D_ij[2]); + trace_third_D = (1.0 / 3.0) * (D_ij[0] + D_ij[1] + D_ij[2]); - br_tensor[0] = (15.0 / (6.0 * trace_D)) * (D_ij[0] - trace_D); - br_tensor[1] = (15.0 / (6.0 * trace_D)) * (D_ij[1] - trace_D); - br_tensor[2] = (15.0 / (6.0 * trace_D)) * (D_ij[2] - trace_D); - br_tensor[3] = (15.0 / (6.0 * trace_D)) * (D_ij[3]); - br_tensor[4] = (15.0 / (6.0 * trace_D)) * (D_ij[4]); - br_tensor[5] = (15.0 / (6.0 * trace_D)) * (D_ij[5]); + br_tensor[0] = (15.0 / (6.0 * trace_third_D)) * (D_ij[0] - trace_third_D); + br_tensor[1] = (15.0 / (6.0 * trace_third_D)) * (D_ij[1] - trace_third_D); + br_tensor[2] = (15.0 / (6.0 * trace_third_D)) * (D_ij[2] - trace_third_D); + br_tensor[3] = (15.0 / (6.0 * trace_third_D)) * (D_ij[3]); + br_tensor[4] = (15.0 / (6.0 * trace_third_D)) * (D_ij[4]); + br_tensor[5] = (15.0 / (6.0 * trace_third_D)) * (D_ij[5]); for (i = 0; i < ntensors; i++) { if (tensor_style[i] == BR) { @@ -439,17 +439,17 @@ void ComputeFabric::compute_vector() MPI_Allreduce(Xfn_ij, temp_dbl, 6, MPI_DOUBLE, MPI_SUM, world); for (i = 0; i < 6; i++) Xfn_ij[i] = temp_dbl[i]; - trace_Xfn = (1.0 / 3.0) * (Xfn_ij[0] + Xfn_ij[1] + Xfn_ij[2]); + trace_third_Xfn = (1.0 / 3.0) * (Xfn_ij[0] + Xfn_ij[1] + Xfn_ij[2]); } if (fn_flag) { - fn_tensor[0] = (15.0 / (6.0 * trace_Xfn)) * (Xfn_ij[0] - trace_Xfn); - fn_tensor[1] = (15.0 / (6.0 * trace_Xfn)) * (Xfn_ij[1] - trace_Xfn); - fn_tensor[2] = (15.0 / (6.0 * trace_Xfn)) * (Xfn_ij[2] - trace_Xfn); - fn_tensor[3] = (15.0 / (6.0 * trace_Xfn)) * (Xfn_ij[3]); - fn_tensor[4] = (15.0 / (6.0 * trace_Xfn)) * (Xfn_ij[4]); - fn_tensor[5] = (15.0 / (6.0 * trace_Xfn)) * (Xfn_ij[5]); + fn_tensor[0] = (15.0 / (6.0 * trace_third_Xfn)) * (Xfn_ij[0] - trace_third_Xfn); + fn_tensor[1] = (15.0 / (6.0 * trace_third_Xfn)) * (Xfn_ij[1] - trace_third_Xfn); + fn_tensor[2] = (15.0 / (6.0 * trace_third_Xfn)) * (Xfn_ij[2] - trace_third_Xfn); + fn_tensor[3] = (15.0 / (6.0 * trace_third_Xfn)) * (Xfn_ij[3]); + fn_tensor[4] = (15.0 / (6.0 * trace_third_Xfn)) * (Xfn_ij[4]); + fn_tensor[5] = (15.0 / (6.0 * trace_third_Xfn)) * (Xfn_ij[5]); for (i = 0; i < ntensors; i++) { if (tensor_style[i] == FN) { @@ -462,14 +462,14 @@ void ComputeFabric::compute_vector() MPI_Allreduce(Xft_ij, temp_dbl, 6, MPI_DOUBLE, MPI_SUM, world); for (i = 0; i < 6; i++) Xft_ij[i] = temp_dbl[i]; - trace_Xft = (1.0 / 3.0) * (Xft_ij[0] + Xft_ij[1] + Xft_ij[2]); + trace_third_Xft = (1.0 / 3.0) * (Xft_ij[0] + Xft_ij[1] + Xft_ij[2]); - ft_tensor[0] = (15.0 / (9.0 * trace_Xfn)) * (Xft_ij[0] - trace_Xft); - ft_tensor[1] = (15.0 / (9.0 * trace_Xfn)) * (Xft_ij[1] - trace_Xft); - ft_tensor[2] = (15.0 / (9.0 * trace_Xfn)) * (Xft_ij[2] - trace_Xft); - ft_tensor[3] = (15.0 / (9.0 * trace_Xfn)) * (Xft_ij[3]); - ft_tensor[4] = (15.0 / (9.0 * trace_Xfn)) * (Xft_ij[4]); - ft_tensor[5] = (15.0 / (9.0 * trace_Xfn)) * (Xft_ij[5]); + ft_tensor[0] = (15.0 / (9.0 * trace_third_Xfn)) * (Xft_ij[0] - trace_third_Xft); + ft_tensor[1] = (15.0 / (9.0 * trace_third_Xfn)) * (Xft_ij[1] - trace_third_Xft); + ft_tensor[2] = (15.0 / (9.0 * trace_third_Xfn)) * (Xft_ij[2] - trace_third_Xft); + ft_tensor[3] = (15.0 / (9.0 * trace_third_Xfn)) * (Xft_ij[3]); + ft_tensor[4] = (15.0 / (9.0 * trace_third_Xfn)) * (Xft_ij[4]); + ft_tensor[5] = (15.0 / (9.0 * trace_third_Xfn)) * (Xft_ij[5]); for (i = 0; i < ntensors; i++) { if (tensor_style[i] == FT) { diff --git a/src/GRANULAR/fix_damping_cundall.cpp b/src/GRANULAR/fix_damping_cundall.cpp index cf17e91050..cf3dd46b96 100644 --- a/src/GRANULAR/fix_damping_cundall.cpp +++ b/src/GRANULAR/fix_damping_cundall.cpp @@ -40,9 +40,9 @@ FixDampingCundall::FixDampingCundall(LAMMPS *_lmp, int narg, char **arg) : { dynamic_group_allow = 1; - if (!atom->sphere_flag) error->all(FLERR, "Fix damping/cundall requires atom style sphere"); + if (!atom->omega_flag) error->all(FLERR, "Fix damping/cundall requires atom attribute omega"); - if (narg < 5) error->all(FLERR, "Illegal fix damping/cundall command"); + if (narg < 5) utils::missing_cmd_args(FLERR, "fix damping/cundall", error); gamma_lin = utils::numeric(FLERR, arg[3], false, lmp); gamma_ang = utils::numeric(FLERR, arg[4], false, lmp); diff --git a/src/GRANULAR/fix_heat_flow.cpp b/src/GRANULAR/fix_heat_flow.cpp index d0d7a73ce6..b7643c2c24 100644 --- a/src/GRANULAR/fix_heat_flow.cpp +++ b/src/GRANULAR/fix_heat_flow.cpp @@ -16,12 +16,12 @@ #include "atom.h" #include "comm.h" #include "error.h" -#include "force.h" #include "memory.h" #include "modify.h" -#include "respa.h" #include "update.h" +#include + using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/GRANULAR/fix_wall_gran.cpp b/src/GRANULAR/fix_wall_gran.cpp index 550d2e17db..b8b06add2e 100644 --- a/src/GRANULAR/fix_wall_gran.cpp +++ b/src/GRANULAR/fix_wall_gran.cpp @@ -34,6 +34,7 @@ #include "update.h" #include "variable.h" +#include #include using namespace LAMMPS_NS; @@ -42,7 +43,7 @@ using namespace FixConst; using namespace MathConst; using namespace MathExtra; -#define BIG 1.0e20 +static constexpr double BIG = 1.0e20; // XYZ PLANE need to be 0,1,2 @@ -55,10 +56,10 @@ FixWallGran::FixWallGran(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), idregion(nullptr), tstr(nullptr), history_one(nullptr), fix_rigid(nullptr), mass_rigid(nullptr) { - if (narg < 4) error->all(FLERR,"Illegal fix wall/gran command"); + if (narg < 4) utils::missing_cmd_args(FLERR,"fix wall/gran", error); - if (!atom->sphere_flag) - error->all(FLERR,"Fix wall/gran requires atom style sphere"); + if (!atom->omega_flag) error->all(FLERR,"Fix wall/gran requires atom attribute omega"); + if (!atom->radius_flag) error->all(FLERR,"Fix wall/gran requires atom attribute radius"); create_attribute = 1; @@ -110,7 +111,7 @@ FixWallGran::FixWallGran(LAMMPS *lmp, int narg, char **arg) : model->limit_damping = 1; iarg += 1; } else { - error->all(FLERR, "Illegal fix wall/gran command"); + error->all(FLERR, "Unknown fix wall/gran keyword {}", arg[iarg]); } } } @@ -281,8 +282,8 @@ FixWallGran::~FixWallGran() // delete local storage delete model; - delete [] tstr; - delete [] idregion; + delete[] tstr; + delete[] idregion; memory->destroy(history_one); memory->destroy(mass_rigid); } diff --git a/src/GRANULAR/fix_wall_gran.h b/src/GRANULAR/fix_wall_gran.h index 45e4e43844..cd1e8778c3 100644 --- a/src/GRANULAR/fix_wall_gran.h +++ b/src/GRANULAR/fix_wall_gran.h @@ -20,7 +20,6 @@ FixStyle(wall/gran,FixWallGran); #ifndef LMP_FIX_WALL_GRAN_H #define LMP_FIX_WALL_GRAN_H -#include "granular_model.h" #include "fix.h" namespace LAMMPS_NS { diff --git a/src/GRANULAR/fix_wall_gran_region.cpp b/src/GRANULAR/fix_wall_gran_region.cpp index 1c2fd4bcc0..b90620f3aa 100644 --- a/src/GRANULAR/fix_wall_gran_region.cpp +++ b/src/GRANULAR/fix_wall_gran_region.cpp @@ -30,8 +30,6 @@ #include "update.h" #include "variable.h" -#include - using namespace LAMMPS_NS; using namespace Granular_NS; using namespace MathExtra; diff --git a/src/GRANULAR/gran_sub_mod.cpp b/src/GRANULAR/gran_sub_mod.cpp index bf945523dd..bac9c9edfe 100644 --- a/src/GRANULAR/gran_sub_mod.cpp +++ b/src/GRANULAR/gran_sub_mod.cpp @@ -21,7 +21,8 @@ ----------------------------------------------------------------------- */ #include "gran_sub_mod.h" -#include "error.h" + +#include using namespace LAMMPS_NS; using namespace Granular_NS; diff --git a/src/GRANULAR/gran_sub_mod.h b/src/GRANULAR/gran_sub_mod.h index 2524565332..88e77eb77b 100644 --- a/src/GRANULAR/gran_sub_mod.h +++ b/src/GRANULAR/gran_sub_mod.h @@ -14,50 +14,50 @@ #ifndef LMP_GRAN_SUB_MOD_H #define LMP_GRAN_SUB_MOD_H -#include "granular_model.h" #include "pointers.h" // IWYU pragma: export namespace LAMMPS_NS { namespace Granular_NS { + class GranularModel; -class GranSubMod : protected Pointers { - public: - GranSubMod(class GranularModel *, class LAMMPS *); - ~GranSubMod() override; + class GranSubMod : protected Pointers { + public: + GranSubMod(class GranularModel *, class LAMMPS *); + ~GranSubMod() override; - int num_coeffs; - double *coeffs; - void read_restart(); - virtual void mix_coeffs(double*, double*); - virtual void coeffs_to_local() {}; - virtual void init() {}; // called after all sub models + coeffs defined + int num_coeffs; + double *coeffs; + void read_restart(); + virtual void mix_coeffs(double *, double *); + virtual void coeffs_to_local(){}; + virtual void init(){}; // called after all sub models + coeffs defined - void allocate_coeffs(); - std::string name; + void allocate_coeffs(); + std::string name; - int size_history; - int nondefault_history_transfer; - double *transfer_history_factor; + int size_history; + int nondefault_history_transfer; + double *transfer_history_factor; - int history_index; - int beyond_contact; // If the sub model contact extends beyond overlap - int allow_cohesion; // If the sub model works with a cohesive normal force - int contact_radius_flag; // If the sub model requires contact radius + int history_index; + int beyond_contact; // If the sub model contact extends beyond overlap + int allow_cohesion; // If the sub model works with a cohesive normal force + int contact_radius_flag; // If the sub model requires contact radius - GranularModel *gm; + GranularModel *gm; - protected: - int allocated; + protected: + int allocated; - double mix_stiffnessE(double, double, double, double); - double mix_stiffnessG(double, double, double, double); - double mix_stiffnessE_wall(double, double); - double mix_stiffnessG_wall(double, double); - double mix_geom(double, double); - double mix_mean(double, double); -}; + double mix_stiffnessE(double, double, double, double); + double mix_stiffnessG(double, double, double, double); + double mix_stiffnessE_wall(double, double); + double mix_stiffnessG_wall(double, double); + double mix_geom(double, double); + double mix_mean(double, double); + }; -} // namespace GranularModel +} // namespace Granular_NS } // namespace LAMMPS_NS #endif /* GRAN_SUB_MOD_H */ diff --git a/src/GRANULAR/gran_sub_mod_damping.cpp b/src/GRANULAR/gran_sub_mod_damping.cpp index 7d6a02b8f0..4386ed71fc 100644 --- a/src/GRANULAR/gran_sub_mod_damping.cpp +++ b/src/GRANULAR/gran_sub_mod_damping.cpp @@ -17,6 +17,8 @@ #include "granular_model.h" #include "math_special.h" +#include + using namespace LAMMPS_NS; using namespace Granular_NS; @@ -130,6 +132,12 @@ void GranSubModDampingTsuji::init() double GranSubModDampingTsuji::calculate_forces() { - damp_prefactor = damp * sqrt(gm->meff * gm->Fnormal / gm->delta); + // in case argument <= 0 due to precision issues + double sqrt1; + if (gm->delta > 0.0) + sqrt1 = MAX(0.0, gm->meff * gm->Fnormal / gm->delta); + else + sqrt1 = 0.0; + damp_prefactor = damp * sqrt(sqrt1); return -damp_prefactor * gm->vnnr; } diff --git a/src/GRANULAR/gran_sub_mod_normal.cpp b/src/GRANULAR/gran_sub_mod_normal.cpp index ffc18b8c32..f4294bbc35 100644 --- a/src/GRANULAR/gran_sub_mod_normal.cpp +++ b/src/GRANULAR/gran_sub_mod_normal.cpp @@ -16,6 +16,8 @@ #include "granular_model.h" #include "math_const.h" +#include + using namespace LAMMPS_NS; using namespace Granular_NS; diff --git a/src/GRANULAR/gran_sub_mod_rolling.cpp b/src/GRANULAR/gran_sub_mod_rolling.cpp index 554aa7ab63..4b10bd2358 100644 --- a/src/GRANULAR/gran_sub_mod_rolling.cpp +++ b/src/GRANULAR/gran_sub_mod_rolling.cpp @@ -18,6 +18,8 @@ #include "granular_model.h" #include "math_extra.h" +#include + using namespace LAMMPS_NS; using namespace Granular_NS; using namespace MathExtra; diff --git a/src/GRANULAR/gran_sub_mod_tangential.cpp b/src/GRANULAR/gran_sub_mod_tangential.cpp index c74233701b..f8f39a38f9 100644 --- a/src/GRANULAR/gran_sub_mod_tangential.cpp +++ b/src/GRANULAR/gran_sub_mod_tangential.cpp @@ -19,6 +19,8 @@ #include "granular_model.h" #include "math_extra.h" +#include + using namespace LAMMPS_NS; using namespace Granular_NS; using namespace MathExtra; diff --git a/src/GRANULAR/gran_sub_mod_twisting.cpp b/src/GRANULAR/gran_sub_mod_twisting.cpp index 48af89c9e7..95c62ad342 100644 --- a/src/GRANULAR/gran_sub_mod_twisting.cpp +++ b/src/GRANULAR/gran_sub_mod_twisting.cpp @@ -19,6 +19,8 @@ #include "granular_model.h" #include "math_const.h" +#include + using namespace LAMMPS_NS; using namespace Granular_NS; diff --git a/src/GRANULAR/granular_model.cpp b/src/GRANULAR/granular_model.cpp index c1ad692fb3..6de147b34a 100644 --- a/src/GRANULAR/granular_model.cpp +++ b/src/GRANULAR/granular_model.cpp @@ -31,6 +31,7 @@ #include "style_gran_sub_mod.h" // IWYU pragma: keep #include +#include using namespace LAMMPS_NS; using namespace Granular_NS; diff --git a/src/GRANULAR/pair_gran_hooke_history.cpp b/src/GRANULAR/pair_gran_hooke_history.cpp index 98191e0564..79bf2b87aa 100644 --- a/src/GRANULAR/pair_gran_hooke_history.cpp +++ b/src/GRANULAR/pair_gran_hooke_history.cpp @@ -435,10 +435,10 @@ void PairGranHookeHistory::init_style() // error and warning checks - if (!atom->radius_flag || !atom->rmass_flag) - error->all(FLERR, "Pair granular requires atom attributes radius, rmass"); + if (!atom->radius_flag || !atom->rmass_flag || !atom->omega_flag) + error->all(FLERR, "Pair gran/h* requires atom attributes radius, rmass, omega"); if (comm->ghost_velocity == 0) - error->all(FLERR, "Pair granular requires ghost atoms store velocity"); + error->all(FLERR, "Pair gran/h* requires ghost atoms store velocity"); // need a granular neighbor list diff --git a/src/GRANULAR/pair_granular.cpp b/src/GRANULAR/pair_granular.cpp index 30f272791e..d5179a19b7 100644 --- a/src/GRANULAR/pair_granular.cpp +++ b/src/GRANULAR/pair_granular.cpp @@ -37,7 +37,6 @@ #include "update.h" #include -#include using namespace LAMMPS_NS; using namespace Granular_NS; @@ -401,8 +400,8 @@ void PairGranular::init_style() { // error and warning checks - if (!atom->radius_flag || !atom->rmass_flag) - error->all(FLERR,"Pair granular requires atom attributes radius, rmass"); + if (!atom->radius_flag || !atom->rmass_flag || !atom->omega_flag) + error->all(FLERR,"Pair granular requires atom attributes radius, rmass, omega"); if (comm->ghost_velocity == 0) error->all(FLERR,"Pair granular requires ghost atoms store velocity"); diff --git a/src/GRANULAR/pair_granular.h b/src/GRANULAR/pair_granular.h index 956717d598..46c5570543 100644 --- a/src/GRANULAR/pair_granular.h +++ b/src/GRANULAR/pair_granular.h @@ -21,7 +21,6 @@ PairStyle(granular,PairGranular); #define LMP_PAIR_GRANULAR_H #include "pair.h" -#include namespace LAMMPS_NS { diff --git a/src/INTEL/fix_nh_intel.cpp b/src/INTEL/fix_nh_intel.cpp index 688101ab13..5455576a1c 100644 --- a/src/INTEL/fix_nh_intel.cpp +++ b/src/INTEL/fix_nh_intel.cpp @@ -33,7 +33,7 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define TILTMAX 1.5 +static constexpr double TILTMAX = 1.5; enum{NOBIAS,BIAS}; enum{ISO,ANISO,TRICLINIC}; diff --git a/src/INTEL/fix_nve_asphere_intel.cpp b/src/INTEL/fix_nve_asphere_intel.cpp index 7e429901a4..848afa20cc 100644 --- a/src/INTEL/fix_nve_asphere_intel.cpp +++ b/src/INTEL/fix_nve_asphere_intel.cpp @@ -30,7 +30,7 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define INERTIA 0.2 // moment of inertia prefactor for ellipsoid +static constexpr double INERTIA = 0.2; // moment of inertia prefactor for ellipsoid /* ---------------------------------------------------------------------- */ diff --git a/src/INTEL/npair_skip_intel.cpp b/src/INTEL/npair_skip_intel.cpp index 8840f7ee43..3596237746 100644 --- a/src/INTEL/npair_skip_intel.cpp +++ b/src/INTEL/npair_skip_intel.cpp @@ -164,8 +164,6 @@ void NPairSkipIntel::build_t(NeighList *list, int *numhalf, int *cnumneigh, if (ipage.status()) error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); } - - int last_inum = 0, loop_end; _inum_counts[tid] = my_inum; } int inum = _inum_counts[0]; @@ -406,7 +404,6 @@ void NPairSkipTrimIntel::build_t(NeighList *list, int *numhalf, int *cnumneigh, error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); } - int last_inum = 0, loop_end; _inum_counts[tid] = my_inum; } int inum = _inum_counts[0]; diff --git a/src/INTEL/pair_airebo_intel.cpp b/src/INTEL/pair_airebo_intel.cpp index 7bc2b3edb8..cc3168cb99 100644 --- a/src/INTEL/pair_airebo_intel.cpp +++ b/src/INTEL/pair_airebo_intel.cpp @@ -633,9 +633,8 @@ namespace overloaded { compared to original code. ---------------------------------------------------------------------- */ -#define CARBON 0 -#define HYDROGEN 1 -#define TOL 1.0e-9 +enum { CARBON, HYDROGEN }; +static constexpr double TOL = 1.0e-9; template inline T fmin_nonan(T a, T b) { @@ -1603,9 +1602,6 @@ void ref_torsion_single_interaction(KernelArgsAIREBOT * ka, int i, flt_t thmin = ka->params.thmin; flt_t thmax = ka->params.thmax; int itype = map[x[i].w]; - flt_t xtmp = x[i].x; - flt_t ytmp = x[i].y; - flt_t ztmp = x[i].z; int * REBO_neighs_i = &ka->neigh_rebo.entries[ka->neigh_rebo.offset[i]]; int jnum = ka->neigh_rebo.num[i]; int jtype = map[x[j].w]; diff --git a/src/INTEL/pair_eam_intel.cpp b/src/INTEL/pair_eam_intel.cpp index 9c5d6da5e5..bd78c3239d 100644 --- a/src/INTEL/pair_eam_intel.cpp +++ b/src/INTEL/pair_eam_intel.cpp @@ -34,8 +34,6 @@ using namespace LAMMPS_NS; -#define MAXLINE 1024 - #define FC_PACKED1_T typename ForceConst::fc_packed1 #define FC_PACKED2_T typename ForceConst::fc_packed2 diff --git a/src/INTEL/pair_lj_charmm_coul_charmm_intel.cpp b/src/INTEL/pair_lj_charmm_coul_charmm_intel.cpp index faae6e5cbc..8cd02c934e 100644 --- a/src/INTEL/pair_lj_charmm_coul_charmm_intel.cpp +++ b/src/INTEL/pair_lj_charmm_coul_charmm_intel.cpp @@ -131,8 +131,7 @@ void PairLJCharmmCoulCharmmIntel::eval(const int offload, const int vflag, int nlocal, nall, minlocal; fix->get_buffern(offload, nlocal, nall, minlocal); - const int ago = neighbor->ago; - IP_PRE_pack_separate_buffers(fix, buffers, ago, offload, nlocal, nall); + IP_PRE_pack_separate_buffers(fix, buffers, neighbor->ago, offload, nlocal, nall); ATOM_T * _noalias const x = buffers->get_x(offload); flt_t * _noalias const q = buffers->get_q(offload); @@ -231,7 +230,6 @@ void PairLJCharmmCoulCharmmIntel::eval(const int offload, const int vflag, else foff = -minlocal; FORCE_T * _noalias const f = f_start + foff; if (NEWTON_PAIR) memset(f + minlocal, 0, f_stride * sizeof(FORCE_T)); - flt_t cutboth = cut_coulsq; const int toffs = tid * ccache_stride; flt_t * _noalias const tdelx = ccachex + toffs; @@ -246,7 +244,6 @@ void PairLJCharmmCoulCharmmIntel::eval(const int offload, const int vflag, const int itype = x[i].w; const int ptr_off = itype * ntypes; - const flt_t * _noalias const cutsqi = cutsq + ptr_off; const LJ_T * _noalias const lji = lj + ptr_off; const int * _noalias const jlist = firstneigh[i]; diff --git a/src/INTEL/pair_snap_intel.cpp b/src/INTEL/pair_snap_intel.cpp index d91f0adc36..c9a4ed3d5a 100644 --- a/src/INTEL/pair_snap_intel.cpp +++ b/src/INTEL/pair_snap_intel.cpp @@ -34,8 +34,8 @@ using namespace LAMMPS_NS; using namespace ip_simd; -#define MAXLINE 1024 -#define MAXWORD 3 +static constexpr int MAXLINE = 1024; +static constexpr int MAXWORD = 3; /* ---------------------------------------------------------------------- */ @@ -445,7 +445,8 @@ void PairSNAPIntel::read_files(char *coefffilename, char *paramfilename) coefffilename, utils::getsyserror()); } - char line[MAXLINE],*ptr; + char line[MAXLINE] = {'\0'}; + char *ptr; int eof = 0; int nwords = 0; while (nwords == 0) { diff --git a/src/INTEL/pair_sw_intel.cpp b/src/INTEL/pair_sw_intel.cpp index fa62f499de..35a091aef2 100644 --- a/src/INTEL/pair_sw_intel.cpp +++ b/src/INTEL/pair_sw_intel.cpp @@ -52,9 +52,6 @@ using namespace LAMMPS_NS; #define FC_PACKED2_T typename ForceConst::fc_packed2 #define FC_PACKED3_T typename ForceConst::fc_packed3 -#define MAXLINE 1024 -#define DELTA 4 - /* ---------------------------------------------------------------------- */ PairSWIntel::PairSWIntel(LAMMPS *lmp) : PairSW(lmp) @@ -478,7 +475,6 @@ void PairSWIntel::eval(const int offload, const int vflag, const flt_t r2 = (flt_t)1.0 / std::sqrt(rinvsq2); const flt_t rainv2 = (flt_t)1.0 / (r2 - cut); const flt_t gsrainv2 = sigma_gamma * rainv2; - const flt_t gsrainvsq2 = gsrainv2 * rainv2 / r2; const flt_t expgsrainv2 = std::exp(gsrainv2); const flt_t rinv12 = (flt_t)1.0 / (r1 * r2); @@ -494,7 +490,6 @@ void PairSWIntel::eval(const int offload, const int vflag, const flt_t facexp = expgsrainv1*expgsrainv2*kfactor; const flt_t facrad = lambda_epsilon * facexp * delcssq; const flt_t frad1 = facrad*gsrainvsq1; - const flt_t frad2 = facrad*gsrainvsq2; const flt_t facang = lambda_epsilon2 * facexp * delcs; const flt_t facang12 = rinv12*facang; const flt_t csfacang = cs*facang; @@ -1273,13 +1268,13 @@ void PairSWIntel::ForceConst::set_ntypes(const int ntypes, if (memory != nullptr) _memory = memory; if (ntypes != _ntypes) { if (_ntypes > 0) { + + #ifdef _LMP_INTEL_OFFLOAD fc_packed0 *op2 = p2[0]; fc_packed1 *op2f = p2f[0]; fc_packed1p2 *op2f2 = p2f2[0]; fc_packed2 *op2e = p2e[0]; fc_packed3 *op3 = p3[0][0]; - - #ifdef _LMP_INTEL_OFFLOAD if (op2 != nullptr && op2f != nullptr && op2f2 != nullptr && op2e != nullptr && op3 != nullptr && _cop >= 0) { #pragma offload_transfer target(mic:_cop) \ diff --git a/src/INTEL/pppm_disp_intel.cpp b/src/INTEL/pppm_disp_intel.cpp index 6dac9fad99..50e9c6e469 100644 --- a/src/INTEL/pppm_disp_intel.cpp +++ b/src/INTEL/pppm_disp_intel.cpp @@ -39,11 +39,8 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define MAXORDER 7 -#define OFFSET 16384 -#define SMALL 0.00001 -#define LARGE 10000.0 -#define EPS_HOC 1.0e-7 +static constexpr int OFFSET = 16384; +static constexpr FFT_SCALAR ZEROF = 0.0; enum{GEOMETRIC,ARITHMETIC,SIXTHPOWER}; enum{REVERSE_RHO, REVERSE_RHO_G, REVERSE_RHO_A, REVERSE_RHO_NONE}; @@ -53,14 +50,6 @@ enum{FORWARD_IK, FORWARD_AD, FORWARD_IK_PERATOM, FORWARD_AD_PERATOM, FORWARD_IK_NONE, FORWARD_AD_NONE, FORWARD_IK_PERATOM_NONE, FORWARD_AD_PERATOM_NONE}; -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#define ONEF 1.0f -#else -#define ZEROF 0.0 -#define ONEF 1.0 -#endif - /* ---------------------------------------------------------------------- */ PPPMDispIntel::PPPMDispIntel(LAMMPS *lmp) : PPPMDisp(lmp) @@ -268,23 +257,23 @@ void PPPMDispIntel::compute(int eflag, int vflag) //perform calculations for coulomb interactions only if (fix->precision() == FixIntel::PREC_MODE_MIXED) { - particle_map(delxinv, delyinv, delzinv, shift, part2grid, - nupper, nlower, nxlo_out, nylo_out, nzlo_out, - nxhi_out, nyhi_out, nzhi_out, - fix->get_mixed_buffers()); - make_rho_c(fix->get_mixed_buffers()); + particle_map_intel(delxinv, delyinv, delzinv, shift, part2grid, + nupper, nlower, nxlo_out, nylo_out, nzlo_out, + nxhi_out, nyhi_out, nzhi_out, + fix->get_mixed_buffers()); + make_rho_c_intel(fix->get_mixed_buffers()); } else if (fix->precision() == FixIntel::PREC_MODE_DOUBLE) { - particle_map(delxinv, delyinv, delzinv, shift, part2grid, - nupper, nlower, nxlo_out, nylo_out, - nzlo_out, nxhi_out, nyhi_out, nzhi_out, - fix->get_double_buffers()); - make_rho_c(fix->get_double_buffers()); + particle_map_intel(delxinv, delyinv, delzinv, shift, part2grid, + nupper, nlower, nxlo_out, nylo_out, + nzlo_out, nxhi_out, nyhi_out, nzhi_out, + fix->get_double_buffers()); + make_rho_c_intel(fix->get_double_buffers()); } else { - particle_map(delxinv, delyinv, delzinv, shift, part2grid, - nupper, nlower, nxlo_out, nylo_out, nzlo_out, - nxhi_out, nyhi_out, nzhi_out, - fix->get_single_buffers()); - make_rho_c(fix->get_single_buffers()); + particle_map_intel(delxinv, delyinv, delzinv, shift, part2grid, + nupper, nlower, nxlo_out, nylo_out, nzlo_out, + nxhi_out, nyhi_out, nzhi_out, + fix->get_single_buffers()); + make_rho_c_intel(fix->get_single_buffers()); } gc->reverse_comm(Grid3d::KSPACE,this,REVERSE_RHO,1,sizeof(FFT_SCALAR), @@ -305,11 +294,11 @@ void PPPMDispIntel::compute(int eflag, int vflag) gc_buf1,gc_buf2,MPI_FFT_SCALAR); if (fix->precision() == FixIntel::PREC_MODE_MIXED) { - fieldforce_c_ad(fix->get_mixed_buffers()); + fieldforce_c_ad_intel(fix->get_mixed_buffers()); } else if (fix->precision() == FixIntel::PREC_MODE_DOUBLE) { - fieldforce_c_ad(fix->get_double_buffers()); + fieldforce_c_ad_intel(fix->get_double_buffers()); } else { - fieldforce_c_ad(fix->get_single_buffers()); + fieldforce_c_ad_intel(fix->get_single_buffers()); } if (vflag_atom) @@ -330,11 +319,11 @@ void PPPMDispIntel::compute(int eflag, int vflag) gc_buf1,gc_buf2,MPI_FFT_SCALAR); if (fix->precision() == FixIntel::PREC_MODE_MIXED) { - fieldforce_c_ik(fix->get_mixed_buffers()); + fieldforce_c_ik_intel(fix->get_mixed_buffers()); } else if (fix->precision() == FixIntel::PREC_MODE_DOUBLE) { - fieldforce_c_ik(fix->get_double_buffers()); + fieldforce_c_ik_intel(fix->get_double_buffers()); } else { - fieldforce_c_ik(fix->get_single_buffers()); + fieldforce_c_ik_intel(fix->get_single_buffers()); } if (evflag_atom) @@ -349,26 +338,26 @@ void PPPMDispIntel::compute(int eflag, int vflag) //perform calculations for geometric mixing if (fix->precision() == FixIntel::PREC_MODE_MIXED) { - particle_map(delxinv_6, delyinv_6, delzinv_6, shift_6, - part2grid_6, nupper_6, nlower_6, nxlo_out_6, - nylo_out_6, nzlo_out_6, nxhi_out_6, - nyhi_out_6, nzhi_out_6, - fix->get_mixed_buffers()); - make_rho_g(fix->get_mixed_buffers()); + particle_map_intel(delxinv_6, delyinv_6, delzinv_6, shift_6, + part2grid_6, nupper_6, nlower_6, nxlo_out_6, + nylo_out_6, nzlo_out_6, nxhi_out_6, + nyhi_out_6, nzhi_out_6, + fix->get_mixed_buffers()); + make_rho_g_intel(fix->get_mixed_buffers()); } else if (fix->precision() == FixIntel::PREC_MODE_DOUBLE) { - particle_map(delxinv_6, delyinv_6, delzinv_6, shift_6, - part2grid_6, nupper_6, nlower_6, nxlo_out_6, - nylo_out_6, nzlo_out_6, nxhi_out_6, - nyhi_out_6, nzhi_out_6, - fix->get_double_buffers()); - make_rho_g(fix->get_double_buffers()); + particle_map_intel(delxinv_6, delyinv_6, delzinv_6, shift_6, + part2grid_6, nupper_6, nlower_6, nxlo_out_6, + nylo_out_6, nzlo_out_6, nxhi_out_6, + nyhi_out_6, nzhi_out_6, + fix->get_double_buffers()); + make_rho_g_intel(fix->get_double_buffers()); } else { - particle_map(delxinv_6, delyinv_6, delzinv_6, shift_6, - part2grid_6, nupper_6, nlower_6, nxlo_out_6, - nylo_out_6, nzlo_out_6, nxhi_out_6, - nyhi_out_6, nzhi_out_6, - fix->get_single_buffers()); - make_rho_g(fix->get_single_buffers()); + particle_map_intel(delxinv_6, delyinv_6, delzinv_6, shift_6, + part2grid_6, nupper_6, nlower_6, nxlo_out_6, + nylo_out_6, nzlo_out_6, nxhi_out_6, + nyhi_out_6, nzhi_out_6, + fix->get_single_buffers()); + make_rho_g_intel(fix->get_single_buffers()); } gc6->reverse_comm(Grid3d::KSPACE,this,REVERSE_RHO_G,1,sizeof(FFT_SCALAR), @@ -390,11 +379,11 @@ void PPPMDispIntel::compute(int eflag, int vflag) gc6_buf1,gc6_buf2,MPI_FFT_SCALAR); if (fix->precision() == FixIntel::PREC_MODE_MIXED) { - fieldforce_g_ad(fix->get_mixed_buffers()); + fieldforce_g_ad_intel(fix->get_mixed_buffers()); } else if (fix->precision() == FixIntel::PREC_MODE_DOUBLE) { - fieldforce_g_ad(fix->get_double_buffers()); + fieldforce_g_ad_intel(fix->get_double_buffers()); } else { - fieldforce_g_ad(fix->get_single_buffers()); + fieldforce_g_ad_intel(fix->get_single_buffers()); } if (vflag_atom) @@ -415,11 +404,11 @@ void PPPMDispIntel::compute(int eflag, int vflag) gc6_buf1,gc6_buf2,MPI_FFT_SCALAR); if (fix->precision() == FixIntel::PREC_MODE_MIXED) { - fieldforce_g_ik(fix->get_mixed_buffers()); + fieldforce_g_ik_intel(fix->get_mixed_buffers()); } else if (fix->precision() == FixIntel::PREC_MODE_DOUBLE) { - fieldforce_g_ik(fix->get_double_buffers()); + fieldforce_g_ik_intel(fix->get_double_buffers()); } else { - fieldforce_g_ik(fix->get_single_buffers()); + fieldforce_g_ik_intel(fix->get_single_buffers()); } if (evflag_atom) @@ -434,26 +423,26 @@ void PPPMDispIntel::compute(int eflag, int vflag) //perform calculations for arithmetic mixing if (fix->precision() == FixIntel::PREC_MODE_MIXED) { - particle_map(delxinv_6, delyinv_6, delzinv_6, shift_6, - part2grid_6, nupper_6, nlower_6, - nxlo_out_6, nylo_out_6, nzlo_out_6, - nxhi_out_6, nyhi_out_6, nzhi_out_6, - fix->get_mixed_buffers()); - make_rho_a(fix->get_mixed_buffers()); + particle_map_intel(delxinv_6, delyinv_6, delzinv_6, shift_6, + part2grid_6, nupper_6, nlower_6, + nxlo_out_6, nylo_out_6, nzlo_out_6, + nxhi_out_6, nyhi_out_6, nzhi_out_6, + fix->get_mixed_buffers()); + make_rho_a_intel(fix->get_mixed_buffers()); } else if (fix->precision() == FixIntel::PREC_MODE_DOUBLE) { - particle_map(delxinv_6, delyinv_6, delzinv_6, shift_6, - part2grid_6, nupper_6, nlower_6, nxlo_out_6, - nylo_out_6, nzlo_out_6, nxhi_out_6, - nyhi_out_6, nzhi_out_6, - fix->get_double_buffers()); - make_rho_a(fix->get_double_buffers()); + particle_map_intel(delxinv_6, delyinv_6, delzinv_6, shift_6, + part2grid_6, nupper_6, nlower_6, nxlo_out_6, + nylo_out_6, nzlo_out_6, nxhi_out_6, + nyhi_out_6, nzhi_out_6, + fix->get_double_buffers()); + make_rho_a_intel(fix->get_double_buffers()); } else { - particle_map(delxinv_6, delyinv_6, delzinv_6, shift_6, - part2grid_6, nupper_6, nlower_6, nxlo_out_6, - nylo_out_6, nzlo_out_6, nxhi_out_6, - nyhi_out_6, nzhi_out_6, - fix->get_single_buffers()); - make_rho_a(fix->get_single_buffers()); + particle_map_intel(delxinv_6, delyinv_6, delzinv_6, shift_6, + part2grid_6, nupper_6, nlower_6, nxlo_out_6, + nylo_out_6, nzlo_out_6, nxhi_out_6, + nyhi_out_6, nzhi_out_6, + fix->get_single_buffers()); + make_rho_a_intel(fix->get_single_buffers()); } gc->reverse_comm(Grid3d::KSPACE,this,REVERSE_RHO_A,7,sizeof(FFT_SCALAR), @@ -486,11 +475,11 @@ void PPPMDispIntel::compute(int eflag, int vflag) gc6_buf1,gc6_buf2,MPI_FFT_SCALAR); if (fix->precision() == FixIntel::PREC_MODE_MIXED) { - fieldforce_a_ad(fix->get_mixed_buffers()); + fieldforce_a_ad_intel(fix->get_mixed_buffers()); } else if (fix->precision() == FixIntel::PREC_MODE_DOUBLE) { - fieldforce_a_ad(fix->get_double_buffers()); + fieldforce_a_ad_intel(fix->get_double_buffers()); } else { - fieldforce_a_ad(fix->get_single_buffers()); + fieldforce_a_ad_intel(fix->get_single_buffers()); } if (evflag_atom) @@ -529,11 +518,11 @@ void PPPMDispIntel::compute(int eflag, int vflag) gc6_buf1,gc6_buf2,MPI_FFT_SCALAR); if (fix->precision() == FixIntel::PREC_MODE_MIXED) { - fieldforce_a_ik(fix->get_mixed_buffers()); + fieldforce_a_ik_intel(fix->get_mixed_buffers()); } else if (fix->precision() == FixIntel::PREC_MODE_DOUBLE) { - fieldforce_a_ik(fix->get_double_buffers()); + fieldforce_a_ik_intel(fix->get_double_buffers()); } else { - fieldforce_a_ik(fix->get_single_buffers()); + fieldforce_a_ik_intel(fix->get_single_buffers()); } if (evflag_atom) @@ -549,26 +538,26 @@ void PPPMDispIntel::compute(int eflag, int vflag) // perform calculations if no mixing rule applies if (fix->precision() == FixIntel::PREC_MODE_MIXED) { - particle_map(delxinv_6, delyinv_6, delzinv_6, shift_6, - part2grid_6, nupper_6, nlower_6, nxlo_out_6, - nylo_out_6, nzlo_out_6, nxhi_out_6, - nyhi_out_6, nzhi_out_6, - fix->get_mixed_buffers()); - make_rho_none(fix->get_mixed_buffers()); + particle_map_intel(delxinv_6, delyinv_6, delzinv_6, shift_6, + part2grid_6, nupper_6, nlower_6, nxlo_out_6, + nylo_out_6, nzlo_out_6, nxhi_out_6, + nyhi_out_6, nzhi_out_6, + fix->get_mixed_buffers()); + make_rho_none_intel(fix->get_mixed_buffers()); } else if (fix->precision() == FixIntel::PREC_MODE_DOUBLE) { - particle_map(delxinv_6, delyinv_6, delzinv_6, shift_6, - part2grid_6, nupper_6, nlower_6, nxlo_out_6, - nylo_out_6, nzlo_out_6, nxhi_out_6, - nyhi_out_6, nzhi_out_6, - fix->get_double_buffers()); - make_rho_none(fix->get_double_buffers()); + particle_map_intel(delxinv_6, delyinv_6, delzinv_6, shift_6, + part2grid_6, nupper_6, nlower_6, nxlo_out_6, + nylo_out_6, nzlo_out_6, nxhi_out_6, + nyhi_out_6, nzhi_out_6, + fix->get_double_buffers()); + make_rho_none_intel(fix->get_double_buffers()); } else { - particle_map(delxinv_6, delyinv_6, delzinv_6, shift_6, - part2grid_6, nupper_6, nlower_6, nxlo_out_6, - nylo_out_6, nzlo_out_6, nxhi_out_6, - nyhi_out_6, nzhi_out_6, - fix->get_single_buffers()); - make_rho_none(fix->get_single_buffers()); + particle_map_intel(delxinv_6, delyinv_6, delzinv_6, shift_6, + part2grid_6, nupper_6, nlower_6, nxlo_out_6, + nylo_out_6, nzlo_out_6, nxhi_out_6, + nyhi_out_6, nzhi_out_6, + fix->get_single_buffers()); + make_rho_none_intel(fix->get_single_buffers()); } gc->reverse_comm(Grid3d::KSPACE,this,REVERSE_RHO_NONE,1,sizeof(FFT_SCALAR), @@ -591,11 +580,11 @@ void PPPMDispIntel::compute(int eflag, int vflag) gc6_buf1,gc6_buf2,MPI_FFT_SCALAR); if (fix->precision() == FixIntel::PREC_MODE_MIXED) { - fieldforce_none_ad(fix->get_mixed_buffers()); + fieldforce_none_ad_intel(fix->get_mixed_buffers()); } else if (fix->precision() == FixIntel::PREC_MODE_DOUBLE) { - fieldforce_none_ad(fix->get_double_buffers()); + fieldforce_none_ad_intel(fix->get_double_buffers()); } else { - fieldforce_none_ad(fix->get_single_buffers()); + fieldforce_none_ad_intel(fix->get_single_buffers()); } if (vflag_atom) @@ -620,11 +609,11 @@ void PPPMDispIntel::compute(int eflag, int vflag) gc6_buf1,gc6_buf2,MPI_FFT_SCALAR); if (fix->precision() == FixIntel::PREC_MODE_MIXED) { - fieldforce_none_ik(fix->get_mixed_buffers()); + fieldforce_none_ik_intel(fix->get_mixed_buffers()); } else if (fix->precision() == FixIntel::PREC_MODE_DOUBLE) { - fieldforce_none_ik(fix->get_double_buffers()); + fieldforce_none_ik_intel(fix->get_double_buffers()); } else { - fieldforce_none_ik(fix->get_single_buffers()); + fieldforce_none_ik_intel(fix->get_single_buffers()); } if (evflag_atom) @@ -730,11 +719,11 @@ void PPPMDispIntel::compute(int eflag, int vflag) ------------------------------------------------------------------------- */ template -void PPPMDispIntel::particle_map(double delx, double dely, double delz, - double sft, int** p2g, int nup, int nlow, - int nxlo, int nylo, int nzlo, - int nxhi, int nyhi, int nzhi, - IntelBuffers * /*buffers*/) +void PPPMDispIntel::particle_map_intel(double delx, double dely, double delz, + double sft, int** p2g, int nup, int nlow, + int nxlo, int nylo, int nzlo, + int nxhi, int nyhi, int nzhi, + IntelBuffers * /*buffers*/) { int nlocal = atom->nlocal; int nthr = comm->nthreads; @@ -805,7 +794,7 @@ void PPPMDispIntel::particle_map(double delx, double dely, double delz, ------------------------------------------------------------------------- */ template -void PPPMDispIntel::make_rho_c(IntelBuffers * /*buffers*/) +void PPPMDispIntel::make_rho_c_intel(IntelBuffers * /*buffers*/) { // clear 3d density array @@ -968,7 +957,7 @@ void PPPMDispIntel::make_rho_c(IntelBuffers * /*buffers*/) ------------------------------------------------------------------------- */ template -void PPPMDispIntel::make_rho_g(IntelBuffers * /*buffers*/) +void PPPMDispIntel::make_rho_g_intel(IntelBuffers * /*buffers*/) { // clear 3d density array @@ -1134,7 +1123,7 @@ void PPPMDispIntel::make_rho_g(IntelBuffers * /*buffers*/) ------------------------------------------------------------------------- */ template -void PPPMDispIntel::make_rho_a(IntelBuffers * /*buffers*/) +void PPPMDispIntel::make_rho_a_intel(IntelBuffers * /*buffers*/) { // clear 3d density array @@ -1268,7 +1257,7 @@ void PPPMDispIntel::make_rho_a(IntelBuffers * /*buffers*/) ------------------------------------------------------------------------- */ template -void PPPMDispIntel::make_rho_none(IntelBuffers * /*buffers*/) +void PPPMDispIntel::make_rho_none_intel(IntelBuffers * /*buffers*/) { FFT_SCALAR * _noalias global_density = &(density_brick_none[0][nzlo_out_6][nylo_out_6][nxlo_out_6]); @@ -1428,7 +1417,7 @@ void PPPMDispIntel::make_rho_none(IntelBuffers * /*buffers*/) ------------------------------------------------------------------------- */ template -void PPPMDispIntel::fieldforce_c_ik(IntelBuffers * /*buffers*/) +void PPPMDispIntel::fieldforce_c_ik_intel(IntelBuffers * /*buffers*/) { // loop over my charges, interpolate electric field from nearby grid points @@ -1587,7 +1576,7 @@ void PPPMDispIntel::fieldforce_c_ik(IntelBuffers * /*buffers*/) ------------------------------------------------------------------------- */ template -void PPPMDispIntel::fieldforce_c_ad(IntelBuffers * /*buffers*/) +void PPPMDispIntel::fieldforce_c_ad_intel(IntelBuffers * /*buffers*/) { // loop over my charges, interpolate electric field from nearby grid points @@ -1808,7 +1797,7 @@ void PPPMDispIntel::fieldforce_c_ad(IntelBuffers * /*buffers*/) ------------------------------------------------------------------------- */ template -void PPPMDispIntel::fieldforce_g_ik(IntelBuffers * /*buffers*/) +void PPPMDispIntel::fieldforce_g_ik_intel(IntelBuffers * /*buffers*/) { // loop over my charges, interpolate electric field from nearby grid points @@ -1964,7 +1953,7 @@ void PPPMDispIntel::fieldforce_g_ik(IntelBuffers * /*buffers*/) ------------------------------------------------------------------------- */ template -void PPPMDispIntel::fieldforce_g_ad(IntelBuffers * /*buffers*/) +void PPPMDispIntel::fieldforce_g_ad_intel(IntelBuffers * /*buffers*/) { // loop over my charges, interpolate electric field from nearby grid points @@ -2180,7 +2169,7 @@ void PPPMDispIntel::fieldforce_g_ad(IntelBuffers * /*buffers*/) ------------------------------------------------------------------------- */ template -void PPPMDispIntel::fieldforce_a_ik(IntelBuffers * /*buffers*/) +void PPPMDispIntel::fieldforce_a_ik_intel(IntelBuffers * /*buffers*/) { // loop over my charges, interpolate electric field from nearby grid points @@ -2405,7 +2394,7 @@ void PPPMDispIntel::fieldforce_a_ik(IntelBuffers * /*buffers*/) ------------------------------------------------------------------------- */ template -void PPPMDispIntel::fieldforce_a_ad(IntelBuffers * /*buffers*/) +void PPPMDispIntel::fieldforce_a_ad_intel(IntelBuffers * /*buffers*/) { // loop over my charges, interpolate electric field from nearby grid points @@ -2733,7 +2722,7 @@ void PPPMDispIntel::fieldforce_a_ad(IntelBuffers * /*buffers*/) ------------------------------------------------------------------------- */ template -void PPPMDispIntel::fieldforce_none_ik(IntelBuffers * /*buffers*/) +void PPPMDispIntel::fieldforce_none_ik_intel(IntelBuffers * /*buffers*/) { // loop over my charges, interpolate electric field from nearby grid points @@ -2906,7 +2895,7 @@ void PPPMDispIntel::fieldforce_none_ik(IntelBuffers * /*buffers*/) ------------------------------------------------------------------------- */ template -void PPPMDispIntel::fieldforce_none_ad(IntelBuffers * /*buffers*/) +void PPPMDispIntel::fieldforce_none_ad_intel(IntelBuffers * /*buffers*/) { // loop over my charges, interpolate electric field from nearby grid points // (nx,ny,nz) = global coords of grid pt to "lower left" of charge diff --git a/src/INTEL/pppm_disp_intel.h b/src/INTEL/pppm_disp_intel.h index 20c59c00e8..11fdd05638 100644 --- a/src/INTEL/pppm_disp_intel.h +++ b/src/INTEL/pppm_disp_intel.h @@ -86,137 +86,137 @@ class PPPMDispIntel : public PPPMDisp { #endif template - void particle_map(double, double, double, double, int **, int, int, int, int, int, int, int, int, - IntelBuffers *buffers); + void particle_map_intel(double, double, double, double, int **, int, int, int, int, int, int, int, int, + IntelBuffers *buffers); template - void make_rho_c(IntelBuffers *buffers); - template void make_rho_c(IntelBuffers *buffers) + void make_rho_c_intel(IntelBuffers *buffers); + template void make_rho_c_intel(IntelBuffers *buffers) { if (_use_table == 1) { - make_rho_c(buffers); + make_rho_c_intel(buffers); } else { - make_rho_c(buffers); + make_rho_c_intel(buffers); } } template - void make_rho_g(IntelBuffers *buffers); - template void make_rho_g(IntelBuffers *buffers) + void make_rho_g_intel(IntelBuffers *buffers); + template void make_rho_g_intel(IntelBuffers *buffers) { if (_use_table == 1) { - make_rho_g(buffers); + make_rho_g_intel(buffers); } else { - make_rho_g(buffers); + make_rho_g_intel(buffers); } } template - void make_rho_a(IntelBuffers *buffers); - template void make_rho_a(IntelBuffers *buffers) + void make_rho_a_intel(IntelBuffers *buffers); + template void make_rho_a_intel(IntelBuffers *buffers) { if (_use_table == 1) { - make_rho_a(buffers); + make_rho_a_intel(buffers); } else { - make_rho_a(buffers); + make_rho_a_intel(buffers); } } template - void make_rho_none(IntelBuffers *buffers); - template void make_rho_none(IntelBuffers *buffers) + void make_rho_none_intel(IntelBuffers *buffers); + template void make_rho_none_intel(IntelBuffers *buffers) { if (_use_table == 1) { - make_rho_none(buffers); + make_rho_none_intel(buffers); } else { - make_rho_none(buffers); + make_rho_none_intel(buffers); } } template - void fieldforce_c_ik(IntelBuffers *buffers); - template void fieldforce_c_ik(IntelBuffers *buffers) + void fieldforce_c_ik_intel(IntelBuffers *buffers); + template void fieldforce_c_ik_intel(IntelBuffers *buffers) { if (_use_table == 1) { - fieldforce_c_ik(buffers); + fieldforce_c_ik_intel(buffers); } else { - fieldforce_c_ik(buffers); + fieldforce_c_ik_intel(buffers); } } template - void fieldforce_c_ad(IntelBuffers *buffers); - template void fieldforce_c_ad(IntelBuffers *buffers) + void fieldforce_c_ad_intel(IntelBuffers *buffers); + template void fieldforce_c_ad_intel(IntelBuffers *buffers) { if (_use_table == 1) { - fieldforce_c_ad(buffers); + fieldforce_c_ad_intel(buffers); } else { - fieldforce_c_ad(buffers); + fieldforce_c_ad_intel(buffers); } } template - void fieldforce_g_ik(IntelBuffers *buffers); - template void fieldforce_g_ik(IntelBuffers *buffers) + void fieldforce_g_ik_intel(IntelBuffers *buffers); + template void fieldforce_g_ik_intel(IntelBuffers *buffers) { if (_use_table == 1) { - fieldforce_g_ik(buffers); + fieldforce_g_ik_intel(buffers); } else { - fieldforce_g_ik(buffers); + fieldforce_g_ik_intel(buffers); } } template - void fieldforce_g_ad(IntelBuffers *buffers); - template void fieldforce_g_ad(IntelBuffers *buffers) + void fieldforce_g_ad_intel(IntelBuffers *buffers); + template void fieldforce_g_ad_intel(IntelBuffers *buffers) { if (_use_table == 1) { - fieldforce_g_ad(buffers); + fieldforce_g_ad_intel(buffers); } else { - fieldforce_g_ad(buffers); + fieldforce_g_ad_intel(buffers); } } template - void fieldforce_a_ik(IntelBuffers *buffers); - template void fieldforce_a_ik(IntelBuffers *buffers) + void fieldforce_a_ik_intel(IntelBuffers *buffers); + template void fieldforce_a_ik_intel(IntelBuffers *buffers) { if (_use_table == 1) { - fieldforce_a_ik(buffers); + fieldforce_a_ik_intel(buffers); } else { - fieldforce_a_ik(buffers); + fieldforce_a_ik_intel(buffers); } } template - void fieldforce_a_ad(IntelBuffers *buffers); - template void fieldforce_a_ad(IntelBuffers *buffers) + void fieldforce_a_ad_intel(IntelBuffers *buffers); + template void fieldforce_a_ad_intel(IntelBuffers *buffers) { if (_use_table == 1) { - fieldforce_a_ad(buffers); + fieldforce_a_ad_intel(buffers); } else { - fieldforce_a_ad(buffers); + fieldforce_a_ad_intel(buffers); } } template - void fieldforce_none_ik(IntelBuffers *buffers); - template void fieldforce_none_ik(IntelBuffers *buffers) + void fieldforce_none_ik_intel(IntelBuffers *buffers); + template void fieldforce_none_ik_intel(IntelBuffers *buffers) { if (_use_table == 1) { - fieldforce_none_ik(buffers); + fieldforce_none_ik_intel(buffers); } else { - fieldforce_none_ik(buffers); + fieldforce_none_ik_intel(buffers); } } template - void fieldforce_none_ad(IntelBuffers *buffers); - template void fieldforce_none_ad(IntelBuffers *buffers) + void fieldforce_none_ad_intel(IntelBuffers *buffers); + template void fieldforce_none_ad_intel(IntelBuffers *buffers) { if (_use_table == 1) { - fieldforce_none_ad(buffers); + fieldforce_none_ad_intel(buffers); } else { - fieldforce_none_ad(buffers); + fieldforce_none_ad_intel(buffers); } } diff --git a/src/INTEL/pppm_electrode_intel.cpp b/src/INTEL/pppm_electrode_intel.cpp index 4d8a0331b8..076ea5dd5d 100644 --- a/src/INTEL/pppm_electrode_intel.cpp +++ b/src/INTEL/pppm_electrode_intel.cpp @@ -42,29 +42,20 @@ #include "update.h" #include "wire_dipole.h" +#include #include #include using namespace LAMMPS_NS; using namespace std; -#define MAXORDER 7 -#define OFFSET 16384 -#define LARGE 10000.0 -#define SMALL 0.00001 -#define EPS_HOC 1.0e-7 +static constexpr int OFFSET = 16384; enum { REVERSE_RHO }; enum { FORWARD_IK, FORWARD_AD, FORWARD_IK_PERATOM, FORWARD_AD_PERATOM }; enum : bool { ELECTRODE = true, ELECTROLYTE = false }; -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#define ONEF 1.0f -#else -#define ZEROF 0.0 -#define ONEF 1.0 -#endif +static constexpr FFT_SCALAR ZEROF = 0.0; static const char cite_pppm_electrode[] = "kspace_style pppm/electrode command:\n\n" @@ -169,7 +160,6 @@ void PPPMElectrodeIntel::setup() PPPMIntel::setup(); prd[0] /= wire_volfactor; prd[1] /= wire_volfactor; - } void PPPMElectrodeIntel::compute(int eflag, int vflag) @@ -285,7 +275,7 @@ void PPPMElectrodeIntel::compute(int eflag, int vflag) slabflag = 0; // bypass compute_second's slabcorr() PPPMIntel::compute_second(eflag, vflag); slabflag = tempslabflag; - boundcorr->compute_corr(qsum, eflag_atom, eflag_global, energy, eatom); + boundcorr->compute_corr(qsum, eflag_atom, eflag_global, energy, eatom); compute_vector_called = false; } @@ -338,7 +328,7 @@ void PPPMElectrodeIntel::compute_vector(double *vec, int sensor_grpbit, int sour // electrolyte density (without writing an additional function) FFT_SCALAR ***density_brick_real = density_brick; FFT_SCALAR *density_fft_real = density_fft; - if (neighbor->ago != 0) pack_buffers(); // since midstep positions may be outdated + if (neighbor->ago != 0) pack_buffers(); // since midstep positions may be outdated switch (fix->precision()) { case FixIntel::PREC_MODE_MIXED: make_rho_in_brick(fix->get_mixed_buffers(), source_grpbit, @@ -1207,22 +1197,23 @@ void PPPMElectrodeIntel::pack_buffers_q() { fix->start_watch(TIME_PACK); int packthreads; - if (comm->nthreads > INTEL_HTHREADS) packthreads = comm->nthreads; - else packthreads = 1; - #if defined(_OPENMP) - #pragma omp parallel if (packthreads > 1) - #endif + if (comm->nthreads > INTEL_HTHREADS) + packthreads = comm->nthreads; + else + packthreads = 1; +#if defined(_OPENMP) +#pragma omp parallel if (packthreads > 1) +#endif { int ifrom, ito, tid; - IP_PRE_omp_range_id_align(ifrom, ito, tid, atom->nlocal+atom->nghost, - packthreads, - sizeof(IntelBuffers::atom_t)); + IP_PRE_omp_range_id_align(ifrom, ito, tid, atom->nlocal + atom->nghost, packthreads, + sizeof(IntelBuffers::atom_t)); if (fix->precision() == FixIntel::PREC_MODE_MIXED) - fix->get_mixed_buffers()->thr_pack_q(ifrom,ito); + fix->get_mixed_buffers()->thr_pack_q(ifrom, ito); else if (fix->precision() == FixIntel::PREC_MODE_DOUBLE) - fix->get_double_buffers()->thr_pack_q(ifrom,ito); + fix->get_double_buffers()->thr_pack_q(ifrom, ito); else - fix->get_single_buffers()->thr_pack_q(ifrom,ito); + fix->get_single_buffers()->thr_pack_q(ifrom, ito); } fix->stop_watch(TIME_PACK); } diff --git a/src/INTEL/pppm_electrode_intel.h b/src/INTEL/pppm_electrode_intel.h index bfe325d9a1..e61641ea19 100644 --- a/src/INTEL/pppm_electrode_intel.h +++ b/src/INTEL/pppm_electrode_intel.h @@ -29,12 +29,9 @@ KSpaceStyle(pppm/electrode/intel,PPPMElectrodeIntel) #ifndef LMP_PPPM_ELECTRODE_INTEL_H #define LMP_PPPM_ELECTRODE_INTEL_H -#include "boundary_correction.h" #include "electrode_kspace.h" #include "fix_intel.h" -#include "pppm.h" #include "pppm_intel.h" -#include namespace LAMMPS_NS { diff --git a/src/INTEL/pppm_intel.cpp b/src/INTEL/pppm_intel.cpp index f67b3a89b3..369c824142 100644 --- a/src/INTEL/pppm_intel.cpp +++ b/src/INTEL/pppm_intel.cpp @@ -41,22 +41,11 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define MAXORDER 7 -#define OFFSET 16384 -#define LARGE 10000.0 -#define SMALL 0.00001 -#define EPS_HOC 1.0e-7 +static constexpr int OFFSET = 16384; +static constexpr FFT_SCALAR ZEROF = 0.0; -enum{REVERSE_RHO}; -enum{FORWARD_IK,FORWARD_AD,FORWARD_IK_PERATOM,FORWARD_AD_PERATOM}; - -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#define ONEF 1.0f -#else -#define ZEROF 0.0 -#define ONEF 1.0 -#endif +enum { REVERSE_RHO }; +enum { FORWARD_IK, FORWARD_AD, FORWARD_IK_PERATOM, FORWARD_AD_PERATOM }; /* ---------------------------------------------------------------------- */ @@ -156,8 +145,6 @@ void PPPMIntel::compute(int eflag, int vflag) void PPPMIntel::compute_first(int eflag, int vflag) { - int i,j; - // set energy/virial flags // invoke allocate_peratom() if needed for first time @@ -465,7 +452,6 @@ void PPPMIntel::make_rho(IntelBuffers *buffers) const flt_t xi = delxinv; const flt_t yi = delyinv; const flt_t zi = delzinv; - const flt_t fshift = shift; const flt_t fshiftone = shiftone; const flt_t fdelvolinv = delvolinv; @@ -698,8 +684,6 @@ void PPPMIntel::fieldforce_ik(IntelBuffers *buffers) _alignvar(FFT_SCALAR ekx_arr[INTEL_P3M_ALIGNED_MAXORDER], 64) = {0}; _alignvar(FFT_SCALAR eky_arr[INTEL_P3M_ALIGNED_MAXORDER], 64) = {0}; _alignvar(FFT_SCALAR ekz_arr[INTEL_P3M_ALIGNED_MAXORDER], 64) = {0}; - _alignvar(FFT_SCALAR ekxy_arr[2 * INTEL_P3M_ALIGNED_MAXORDER], 64) = {0}; - _alignvar(FFT_SCALAR ekz0_arr[2 * INTEL_P3M_ALIGNED_MAXORDER], 64) = {0}; #if defined(LMP_SIMD_COMPILER) #pragma loop_count min(2), max(INTEL_P3M_ALIGNED_MAXORDER), avg(7) diff --git a/src/INTERLAYER/pair_aip_water_2dm.cpp b/src/INTERLAYER/pair_aip_water_2dm.cpp index 6e2bf7228d..2c6b222d45 100644 --- a/src/INTERLAYER/pair_aip_water_2dm.cpp +++ b/src/INTERLAYER/pair_aip_water_2dm.cpp @@ -24,15 +24,8 @@ #include "error.h" #include "force.h" -#include -#include - using namespace LAMMPS_NS; -#define MAXLINE 1024 -#define DELTA 4 -#define PGDELTA 1 - static const char cite_aip_water[] = "aip/water/2dm potential doi/10.1021/acs.jpcc.2c08464\n" "@Article{Feng2023\n" diff --git a/src/INTERLAYER/pair_drip.cpp b/src/INTERLAYER/pair_drip.cpp index 90773b4034..2800bd604d 100644 --- a/src/INTERLAYER/pair_drip.cpp +++ b/src/INTERLAYER/pair_drip.cpp @@ -36,9 +36,8 @@ using namespace LAMMPS_NS; -#define MAXLINE 1024 -#define DELTA 4 -#define HALF 0.5 +static constexpr int DELTA = 4; +static constexpr double HALF = 0.5; // inline functions static inline double dot(double const *x, double const *y) diff --git a/src/INTERLAYER/pair_ilp_graphene_hbn.cpp b/src/INTERLAYER/pair_ilp_graphene_hbn.cpp index 69896d7c0b..a3e3a833c3 100644 --- a/src/INTERLAYER/pair_ilp_graphene_hbn.cpp +++ b/src/INTERLAYER/pair_ilp_graphene_hbn.cpp @@ -39,8 +39,8 @@ using namespace LAMMPS_NS; using namespace InterLayer; -#define DELTA 4 -#define PGDELTA 1 +static constexpr int DELTA = 4; +static constexpr int PGDELTA = 1; static const char cite_ilp[] = "ilp/graphene/hbn potential doi:10.1021/acs.nanolett.8b02848\n" diff --git a/src/INTERLAYER/pair_ilp_tmd.h b/src/INTERLAYER/pair_ilp_tmd.h index 8381c2e830..7e7edbb01b 100644 --- a/src/INTERLAYER/pair_ilp_tmd.h +++ b/src/INTERLAYER/pair_ilp_tmd.h @@ -20,7 +20,7 @@ PairStyle(ilp/tmd,PairILPTMD); #ifndef LMP_PAIR_ILP_TMD_H #define LMP_PAIR_ILP_TMD_H -#include "pair_ilp_graphene_hbn.h" +#include "pair_ilp_graphene_hbn.h" // IWYU pragma: export namespace LAMMPS_NS { diff --git a/src/INTERLAYER/pair_kolmogorov_crespi_full.cpp b/src/INTERLAYER/pair_kolmogorov_crespi_full.cpp index ad42ba1922..6bc3a6dde7 100644 --- a/src/INTERLAYER/pair_kolmogorov_crespi_full.cpp +++ b/src/INTERLAYER/pair_kolmogorov_crespi_full.cpp @@ -40,9 +40,8 @@ using namespace LAMMPS_NS; using namespace InterLayer; -#define MAXLINE 1024 -#define DELTA 4 -#define PGDELTA 1 +static constexpr int DELTA = 4; +static constexpr int PGDELTA = 1; static const char cite_kc[] = "kolmogorov/crespi/full potential doi:10.1021/acs.nanolett.8b02848\n" diff --git a/src/INTERLAYER/pair_kolmogorov_crespi_z.cpp b/src/INTERLAYER/pair_kolmogorov_crespi_z.cpp index d8f0d798e4..dc1b82647a 100644 --- a/src/INTERLAYER/pair_kolmogorov_crespi_z.cpp +++ b/src/INTERLAYER/pair_kolmogorov_crespi_z.cpp @@ -37,8 +37,7 @@ using namespace LAMMPS_NS; -#define MAXLINE 1024 -#define DELTA 4 +static constexpr int DELTA = 4; /* ---------------------------------------------------------------------- */ diff --git a/src/INTERLAYER/pair_lebedeva_z.cpp b/src/INTERLAYER/pair_lebedeva_z.cpp index b38900ad14..b68db0184f 100644 --- a/src/INTERLAYER/pair_lebedeva_z.cpp +++ b/src/INTERLAYER/pair_lebedeva_z.cpp @@ -39,8 +39,7 @@ using namespace LAMMPS_NS; -#define MAXLINE 1024 -#define DELTA 4 +static constexpr int DELTA = 4; /* ---------------------------------------------------------------------- */ diff --git a/src/INTERLAYER/pair_saip_metal.cpp b/src/INTERLAYER/pair_saip_metal.cpp index bd327391a4..3053113894 100644 --- a/src/INTERLAYER/pair_saip_metal.cpp +++ b/src/INTERLAYER/pair_saip_metal.cpp @@ -33,10 +33,6 @@ using namespace LAMMPS_NS; using namespace InterLayer; -#define MAXLINE 1024 -#define DELTA 4 -#define PGDELTA 1 - static const char cite_saip[] = "saip/metal potential: doi:10.1021/acs.jctc.1c00622\n\n" "@Article{Ouyang2021\n" diff --git a/src/KIM/kim_interactions.cpp b/src/KIM/kim_interactions.cpp index 1f4f84e648..c0ec0ee28e 100644 --- a/src/KIM/kim_interactions.cpp +++ b/src/KIM/kim_interactions.cpp @@ -70,6 +70,8 @@ #include "modify.h" #include "update.h" +#include "fmt/ranges.h" + #include #include @@ -79,7 +81,7 @@ extern "C" { using namespace LAMMPS_NS; -#define MAXLINE 1024 +static constexpr int MAXLINE = 1024; /* ---------------------------------------------------------------------- */ @@ -279,7 +281,8 @@ void KimInteractions::KIM_SET_TYPE_PARAMETERS(const std::string &input_line) con if (fp == nullptr) error->one(FLERR, "Parameter file {} not found", filename); } - char line[MAXLINE], *ptr; + char line[MAXLINE] = {'\0'}; + char *ptr; int n, eof = 0; while (true) { diff --git a/src/KIM/kim_param.cpp b/src/KIM/kim_param.cpp index f72df81989..c50474fe67 100644 --- a/src/KIM/kim_param.cpp +++ b/src/KIM/kim_param.cpp @@ -68,6 +68,8 @@ #include "pair_kim.h" #include "variable.h" +#include "fmt/ranges.h" + #include #include #include diff --git a/src/KOKKOS/Install.sh b/src/KOKKOS/Install.sh index af80420d7a..75949c35d8 100755 --- a/src/KOKKOS/Install.sh +++ b/src/KOKKOS/Install.sh @@ -106,6 +106,8 @@ action compute_temp_kokkos.cpp action compute_temp_kokkos.h action dihedral_charmm_kokkos.cpp dihedral_charmm.cpp action dihedral_charmm_kokkos.h dihedral_charmm.h +action dihedral_charmmfsw_kokkos.cpp dihedral_charmmfsw.cpp +action dihedral_charmmfsw_kokkos.h dihedral_charmmfsw.h action dihedral_class2_kokkos.cpp dihedral_class2.cpp action dihedral_class2_kokkos.h dihedral_class2.h action dihedral_harmonic_kokkos.cpp dihedral_harmonic.cpp @@ -185,6 +187,8 @@ action fix_temp_rescale_kokkos.cpp action fix_temp_rescale_kokkos.h action fix_viscous_kokkos.cpp action fix_viscous_kokkos.h +action fix_wall_flow_kokkos.cpp fix_wall_flow.cpp +action fix_wall_flow_kokkos.h fix_wall_flow.h action fix_wall_gran_kokkos.cpp fix_wall_gran.cpp action fix_wall_gran_kokkos.h fix_wall_gran.h action fix_wall_gran_old.cpp fix_wall_gran.cpp @@ -310,6 +314,8 @@ action pair_lj_charmm_coul_charmm_kokkos.cpp pair_lj_charmm_coul_charmm.cpp action pair_lj_charmm_coul_charmm_kokkos.h pair_lj_charmm_coul_charmm.h action pair_lj_charmm_coul_long_kokkos.cpp pair_lj_charmm_coul_long.cpp action pair_lj_charmm_coul_long_kokkos.h pair_lj_charmm_coul_long.h +action pair_lj_charmmfsw_coul_long_kokkos.cpp pair_lj_charmmfsw_coul_long.cpp +action pair_lj_charmmfsw_coul_long_kokkos.h pair_lj_charmmfsw_coul_long.h action pair_lj_class2_coul_cut_kokkos.cpp pair_lj_class2_coul_cut.cpp action pair_lj_class2_coul_cut_kokkos.h pair_lj_class2_coul_cut.h action pair_lj_class2_coul_long_kokkos.cpp pair_lj_class2_coul_long.cpp diff --git a/src/KOKKOS/angle_charmm_kokkos.cpp b/src/KOKKOS/angle_charmm_kokkos.cpp index 8b41a93451..666002686c 100644 --- a/src/KOKKOS/angle_charmm_kokkos.cpp +++ b/src/KOKKOS/angle_charmm_kokkos.cpp @@ -31,7 +31,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/angle_class2_kokkos.cpp b/src/KOKKOS/angle_class2_kokkos.cpp index 8f77ab4c94..e831ae2283 100644 --- a/src/KOKKOS/angle_class2_kokkos.cpp +++ b/src/KOKKOS/angle_class2_kokkos.cpp @@ -31,7 +31,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/angle_cosine_kokkos.cpp b/src/KOKKOS/angle_cosine_kokkos.cpp index 189a156866..768dfd43ca 100644 --- a/src/KOKKOS/angle_cosine_kokkos.cpp +++ b/src/KOKKOS/angle_cosine_kokkos.cpp @@ -31,8 +31,6 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.001 - /* ---------------------------------------------------------------------- */ template diff --git a/src/KOKKOS/angle_harmonic_kokkos.cpp b/src/KOKKOS/angle_harmonic_kokkos.cpp index 1d8ada4bd9..d7be418326 100644 --- a/src/KOKKOS/angle_harmonic_kokkos.cpp +++ b/src/KOKKOS/angle_harmonic_kokkos.cpp @@ -31,7 +31,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/atom_kokkos.cpp b/src/KOKKOS/atom_kokkos.cpp index 501b719ad4..b1a066f165 100644 --- a/src/KOKKOS/atom_kokkos.cpp +++ b/src/KOKKOS/atom_kokkos.cpp @@ -16,7 +16,7 @@ #include "atom_masks.h" #include "atom_vec.h" #include "atom_vec_kokkos.h" -#include "comm_kokkos.h" +#include "comm.h" #include "domain.h" #include "error.h" #include "kokkos.h" @@ -300,7 +300,7 @@ void AtomKokkos::grow(unsigned int mask) return index in ivector or dvector of its location ------------------------------------------------------------------------- */ -int AtomKokkos::add_custom(const char *name, int flag, int cols) +int AtomKokkos::add_custom(const char *name, int flag, int cols, int ghost) { int index = -1; @@ -309,6 +309,8 @@ int AtomKokkos::add_custom(const char *name, int flag, int cols) nivector++; ivname = (char **) memory->srealloc(ivname, nivector * sizeof(char *), "atom:ivname"); ivname[index] = utils::strdup(name); + ivghost = (int *) memory->srealloc(ivghost,nivector * sizeof(int),"atom:ivghost"); + ivghost[index] = ghost; ivector = (int **) memory->srealloc(ivector, nivector * sizeof(int *), "atom:ivector"); memory->create(ivector[index], nmax, "atom:ivector"); @@ -317,6 +319,8 @@ int AtomKokkos::add_custom(const char *name, int flag, int cols) ndvector++; dvname = (char **) memory->srealloc(dvname, ndvector * sizeof(char *), "atom:dvname"); dvname[index] = utils::strdup(name); + dvghost = (int *) memory->srealloc(dvghost, ndvector * sizeof(int), "atom:dvghost"); + dvghost[index] = ghost; dvector = (double **) memory->srealloc(dvector, ndvector * sizeof(double *), "atom:dvector"); this->sync(Device, DVECTOR_MASK); memoryKK->grow_kokkos(k_dvector, dvector, ndvector, nmax, "atom:dvector"); @@ -327,6 +331,8 @@ int AtomKokkos::add_custom(const char *name, int flag, int cols) niarray++; ianame = (char **) memory->srealloc(ianame, niarray * sizeof(char *), "atom:ianame"); ianame[index] = utils::strdup(name); + iaghost = (int *) memory->srealloc(iaghost, niarray * sizeof(int), "atom:iaghost"); + iaghost[index] = ghost; iarray = (int ***) memory->srealloc(iarray, niarray * sizeof(int **), "atom:iarray"); memory->create(iarray[index], nmax, cols, "atom:iarray"); @@ -338,6 +344,8 @@ int AtomKokkos::add_custom(const char *name, int flag, int cols) ndarray++; daname = (char **) memory->srealloc(daname, ndarray * sizeof(char *), "atom:daname"); daname[index] = utils::strdup(name); + daghost = (int *) memory->srealloc(daghost, ndarray * sizeof(int), "atom:daghost"); + daghost[index] = ghost; darray = (double ***) memory->srealloc(darray, ndarray * sizeof(double **), "atom:darray"); memory->create(darray[index], nmax, cols, "atom:darray"); @@ -345,6 +353,9 @@ int AtomKokkos::add_custom(const char *name, int flag, int cols) dcols[index] = cols; } + if (index < 0) + error->all(FLERR,"Invalid call to AtomKokkos::add_custom()"); + return index; } diff --git a/src/KOKKOS/atom_kokkos.h b/src/KOKKOS/atom_kokkos.h index e6269b5527..652e6c2191 100644 --- a/src/KOKKOS/atom_kokkos.h +++ b/src/KOKKOS/atom_kokkos.h @@ -154,9 +154,13 @@ class AtomKokkos : public Atom { void sync_overlapping_device(const ExecutionSpace space, unsigned int mask); void sort() override; virtual void grow(unsigned int mask); - int add_custom(const char *, int, int) override; + int add_custom(const char *, int, int, int border = 0) override; void remove_custom(int, int, int) override; virtual void deallocate_topology(); + + void map_set_device(); + void map_set_host(); + private: void sort_device(); class AtomVec *new_avec(const std::string &, int, int &) override; diff --git a/src/KOKKOS/atom_map_kokkos.cpp b/src/KOKKOS/atom_map_kokkos.cpp index a266c44a91..8203e1e6a2 100644 --- a/src/KOKKOS/atom_map_kokkos.cpp +++ b/src/KOKKOS/atom_map_kokkos.cpp @@ -16,16 +16,12 @@ #include "atom_masks.h" #include "comm.h" #include "error.h" -#include "fix.h" +#include "kokkos.h" #include "memory_kokkos.h" -#include "modify.h" -#include "neighbor_kokkos.h" - -#include using namespace LAMMPS_NS; -#define EXTRA 1000 +static constexpr int EXTRA = 1000; /* ---------------------------------------------------------------------- allocate and initialize array or hash table for global -> local map @@ -34,6 +30,8 @@ using namespace LAMMPS_NS; set entire array to -1 as initial values for hash option: map_nhash = length of hash table + map_nbucket = # of hash buckets, prime larger than map_nhash * 2 + so buckets will only be filled with 0 or 1 atoms on average ------------------------------------------------------------------------- */ void AtomKokkos::map_init(int check) @@ -46,19 +44,29 @@ void AtomKokkos::map_init(int check) int recreate = 0; if (check) recreate = map_style_set(); - if (map_style == MAP_ARRAY && map_tag_max > map_maxarray) - recreate = 1; - else if (map_style == MAP_HASH && nlocal + nghost > map_nhash) - recreate = 1; + if (map_style == MAP_ARRAY && map_tag_max > map_maxarray) recreate = 1; + else if (map_style == MAP_HASH && nlocal+nghost > map_nhash) recreate = 1; // if not recreating: // for array, initialize current map_tag_max values // for hash, set all buckets to empty, put all entries in free list if (!recreate) { - map_clear(); + if (lmp->kokkos->atom_map_classic) { + if (map_style == MAP_ARRAY) { + for (int i = 0; i <= map_tag_max; i++) map_array[i] = -1; + } else { + for (int i = 0; i < map_nbucket; i++) map_bucket[i] = -1; + map_nused = 0; + map_free = 0; + for (int i = 0; i < map_nhash; i++) map_hash[i].next = i+1; + if (map_nhash > 0) map_hash[map_nhash-1].next = -1; + } + } else { + map_clear(); + } - // recreating: delete old map and create new one for array or hash + // recreating: delete old map and create new one for array or hash } else { map_delete(); @@ -66,8 +74,7 @@ void AtomKokkos::map_init(int check) if (map_style == MAP_ARRAY) { map_maxarray = map_tag_max; memoryKK->create_kokkos(k_map_array, map_array, map_maxarray + 1, "atom:map_array"); - Kokkos::deep_copy(k_map_array.d_view,-1); - k_map_array.modify_device(); + map_clear(); } else { @@ -76,14 +83,38 @@ void AtomKokkos::map_init(int check) // multiply by 2, require at least 1000 // doubling means hash table will need to be re-init only rarely - int nper = static_cast(natoms / comm->nprocs); - map_nhash = MAX(nper, nmax); + int nper = static_cast (natoms/comm->nprocs); + map_nhash = MAX(nper,nmax); map_nhash *= 2; - map_nhash = MAX(map_nhash, 1000); + map_nhash = MAX(map_nhash,1000); + + if (lmp->kokkos->atom_map_classic) { + // map_nbucket = prime just larger than map_nhash + // next_prime() should be fast enough, + // about 10% of odd integers are prime above 1M + + map_nbucket = next_prime(map_nhash); + + // set all buckets to empty + // set hash to map_nhash in length + // put all hash entries in free list and point them to each other + + map_bucket = new int[map_nbucket]; + for (int i = 0; i < map_nbucket; i++) map_bucket[i] = -1; + + map_hash = new HashElem[map_nhash]; + map_nused = 0; + map_free = 0; + for (int i = 0; i < map_nhash; i++) map_hash[i].next = i + 1; + map_hash[map_nhash - 1].next = -1; + } k_map_hash = dual_hash_type(map_nhash); } } + + if (lmp->kokkos->atom_map_classic) + if (map_style == MAP_ARRAY) k_map_array.modify_host(); } /* ---------------------------------------------------------------------- @@ -94,12 +125,23 @@ void AtomKokkos::map_init(int check) void AtomKokkos::map_clear() { - if (map_style == Atom::MAP_ARRAY) { - Kokkos::deep_copy(k_map_array.d_view,-1); - k_map_array.modify_device(); + if (map_style == MAP_ARRAY) { + if (lmp->kokkos->atom_map_classic) { + Kokkos::deep_copy(k_map_array.h_view,-1); + k_map_array.modify_host(); + } else { + Kokkos::deep_copy(k_map_array.d_view,-1); + k_map_array.modify_device(); + } } else { - k_map_hash.d_view.clear(); - k_map_hash.modify_device(); + if (lmp->kokkos->atom_map_classic) { + Atom::map_clear(); + k_map_hash.h_view.clear(); + k_map_hash.modify_host(); + } else { + k_map_hash.d_view.clear(); + k_map_hash.modify_device(); + } } } @@ -114,6 +156,16 @@ void AtomKokkos::map_clear() ------------------------------------------------------------------------- */ void AtomKokkos::map_set() +{ + if (lmp->kokkos->atom_map_classic) + map_set_host(); + else + map_set_device(); +} + +/* ---------------------------------------------------------------------- */ + +void AtomKokkos::map_set_device() { int nall = nlocal + nghost; @@ -273,6 +325,7 @@ void AtomKokkos::map_set() error->one(FLERR,"Failed to insert into Kokkos hash atom map"); k_sametag.modify_device(); + k_sametag.sync_host(); if (map_style == MAP_ARRAY) k_map_array.modify_device(); @@ -280,6 +333,122 @@ void AtomKokkos::map_set() k_map_hash.modify_device(); } +/* ---------------------------------------------------------------------- */ + +void AtomKokkos::map_set_host() +{ + int nall = nlocal + nghost; + + atomKK->sync(Host, TAG_MASK); + k_sametag.sync_host(); + + if (map_style == MAP_ARRAY) { + k_map_array.sync_host(); + + // possible reallocation of sametag must come before loop over atoms + // since loop sets sametag + + if (nall > max_same) { + max_same = nall + EXTRA; + memoryKK->destroy_kokkos(k_sametag, sametag); + memoryKK->create_kokkos(k_sametag, sametag, max_same, "atom:sametag"); + } + + for (int i = nall - 1; i >= 0; i--) { + sametag[i] = map_array[tag[i]]; + map_array[tag[i]] = i; + } + + } else { + + // if this proc has more atoms than hash table size, call map_init() + // call with 0 since max atomID in system has not changed + // possible reallocation of sametag must come after map_init(), + // b/c map_init() may invoke map_delete(), whacking sametag + + if (nall > map_nhash) map_init(0); + if (nall > max_same) { + max_same = nall + EXTRA; + memoryKK->destroy_kokkos(k_sametag, sametag); + memoryKK->create_kokkos(k_sametag, sametag, max_same, "atom:sametag"); + } + + int previous, ibucket, index; + tagint global; + + for (int i = nall - 1; i >= 0; i--) { + sametag[i] = Atom::map_find_hash(tag[i]); + + // search for key + // if found it, just overwrite local value with index + + previous = -1; + global = tag[i]; + ibucket = global % map_nbucket; + index = map_bucket[ibucket]; + while (index > -1) { + if (map_hash[index].global == global) break; + previous = index; + index = map_hash[index].next; + } + if (index > -1) { + map_hash[index].local = i; + continue; + } + + // take one entry from free list + // add the new global/local pair as entry at end of bucket list + // special logic if this entry is 1st in bucket + + index = map_free; + map_free = map_hash[map_free].next; + if (previous == -1) + map_bucket[ibucket] = index; + else + map_hash[previous].next = index; + map_hash[index].global = global; + map_hash[index].local = i; + map_hash[index].next = -1; + map_nused++; + } + + // Copy to Kokkos hash + + // use "view" template method to avoid unnecessary deep_copy + + auto h_map_hash = k_map_hash.view(); + h_map_hash.clear(); + + for (int i = nall - 1; i >= 0; i--) { + + // search for key + // if don't find it, done + + previous = -1; + global = tag[i]; + ibucket = global % map_nbucket; + index = map_bucket[ibucket]; + while (index > -1) { + if (map_hash[index].global == global) break; + previous = index; + index = map_hash[index].next; + } + if (index == -1) continue; + + int local = map_hash[index].local; + + auto insert_result = h_map_hash.insert(global, local); + if (insert_result.failed()) error->one(FLERR, "Kokkos::UnorderedMap insertion failed"); + } + } + + k_sametag.modify_host(); + if (map_style == MAP_ARRAY) + k_map_array.modify_host(); + else if (map_style == MAP_HASH) + k_map_hash.modify_host(); +} + /* ---------------------------------------------------------------------- set global to local map for one atom for hash table option: @@ -335,4 +504,7 @@ void AtomKokkos::map_delete() map_array = nullptr; } else k_map_hash = dual_hash_type(); + + if (lmp->kokkos->atom_map_classic) + Atom::map_delete(); } diff --git a/src/KOKKOS/atom_vec_angle_kokkos.cpp b/src/KOKKOS/atom_vec_angle_kokkos.cpp index 418c2d629d..dc8641a6b6 100644 --- a/src/KOKKOS/atom_vec_angle_kokkos.cpp +++ b/src/KOKKOS/atom_vec_angle_kokkos.cpp @@ -186,302 +186,13 @@ void AtomVecAngleKokkos::sort_kokkos(Kokkos::BinSort &Sorter /* ---------------------------------------------------------------------- */ -template -struct AtomVecAngleKokkos_PackComm { - typedef DeviceType device_type; - - typename ArrayTypes::t_x_array_randomread _x; - typename ArrayTypes::t_xfloat_2d_um _buf; - typename ArrayTypes::t_int_2d_const _list; - const int _iswap; - X_FLOAT _xprd,_yprd,_zprd,_xy,_xz,_yz; - X_FLOAT _pbc[6]; - - AtomVecAngleKokkos_PackComm( - const typename DAT::tdual_x_array &x, - const typename DAT::tdual_xfloat_2d &buf, - const typename DAT::tdual_int_2d &list, - const int & iswap, - const X_FLOAT &xprd, const X_FLOAT &yprd, const X_FLOAT &zprd, - const X_FLOAT &xy, const X_FLOAT &xz, const X_FLOAT &yz, const int* const pbc): - _x(x.view()),_list(list.view()),_iswap(iswap), - _xprd(xprd),_yprd(yprd),_zprd(zprd), - _xy(xy),_xz(xz),_yz(yz) { - const size_t maxsend = (buf.view().extent(0) - *buf.view().extent(1))/3; - const size_t elements = 3; - buffer_view(_buf,buf,maxsend,elements); - _pbc[0] = pbc[0]; _pbc[1] = pbc[1]; _pbc[2] = pbc[2]; - _pbc[3] = pbc[3]; _pbc[4] = pbc[4]; _pbc[5] = pbc[5]; - }; - - KOKKOS_INLINE_FUNCTION - void operator() (const int& i) const { - const int j = _list(_iswap,i); - if (PBC_FLAG == 0) { - _buf(i,0) = _x(j,0); - _buf(i,1) = _x(j,1); - _buf(i,2) = _x(j,2); - } else { - if (TRICLINIC == 0) { - _buf(i,0) = _x(j,0) + _pbc[0]*_xprd; - _buf(i,1) = _x(j,1) + _pbc[1]*_yprd; - _buf(i,2) = _x(j,2) + _pbc[2]*_zprd; - } else { - _buf(i,0) = _x(j,0) + _pbc[0]*_xprd + _pbc[5]*_xy + _pbc[4]*_xz; - _buf(i,1) = _x(j,1) + _pbc[1]*_yprd + _pbc[3]*_yz; - _buf(i,2) = _x(j,2) + _pbc[2]*_zprd; - } - } - } -}; - -/* ---------------------------------------------------------------------- */ - -int AtomVecAngleKokkos::pack_comm_kokkos(const int &n, - const DAT::tdual_int_2d &list, - const int & iswap, - const DAT::tdual_xfloat_2d &buf, - const int &pbc_flag, - const int* const pbc) -{ - // Check whether to always run forward communication on the host - // Choose correct forward PackComm kernel - - if (commKK->forward_comm_on_host) { - atomKK->sync(Host,X_MASK); - if (pbc_flag) { - if (domain->triclinic) { - struct AtomVecAngleKokkos_PackComm f(atomKK->k_x,buf,list,iswap, - domain->xprd,domain->yprd,domain->zprd, - domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); - } else { - struct AtomVecAngleKokkos_PackComm f(atomKK->k_x,buf,list,iswap, - domain->xprd,domain->yprd,domain->zprd, - domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); - } - } else { - if (domain->triclinic) { - struct AtomVecAngleKokkos_PackComm f(atomKK->k_x,buf,list,iswap, - domain->xprd,domain->yprd,domain->zprd, - domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); - } else { - struct AtomVecAngleKokkos_PackComm f(atomKK->k_x,buf,list,iswap, - domain->xprd,domain->yprd,domain->zprd, - domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); - } - } - } else { - atomKK->sync(Device,X_MASK); - if (pbc_flag) { - if (domain->triclinic) { - struct AtomVecAngleKokkos_PackComm f(atomKK->k_x,buf,list,iswap, - domain->xprd,domain->yprd,domain->zprd, - domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); - } else { - struct AtomVecAngleKokkos_PackComm f(atomKK->k_x,buf,list,iswap, - domain->xprd,domain->yprd,domain->zprd, - domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); - } - } else { - if (domain->triclinic) { - struct AtomVecAngleKokkos_PackComm f(atomKK->k_x,buf,list,iswap, - domain->xprd,domain->yprd,domain->zprd, - domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); - } else { - struct AtomVecAngleKokkos_PackComm f(atomKK->k_x,buf,list,iswap, - domain->xprd,domain->yprd,domain->zprd, - domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); - } - } - } - - return n*size_forward; -} - -/* ---------------------------------------------------------------------- */ - -template -struct AtomVecAngleKokkos_PackCommSelf { - typedef DeviceType device_type; - - typename ArrayTypes::t_x_array_randomread _x; - typename ArrayTypes::t_x_array _xw; - int _nfirst; - typename ArrayTypes::t_int_2d_const _list; - const int _iswap; - X_FLOAT _xprd,_yprd,_zprd,_xy,_xz,_yz; - X_FLOAT _pbc[6]; - - AtomVecAngleKokkos_PackCommSelf( - const typename DAT::tdual_x_array &x, - const int &nfirst, - const typename DAT::tdual_int_2d &list, - const int & iswap, - const X_FLOAT &xprd, const X_FLOAT &yprd, const X_FLOAT &zprd, - const X_FLOAT &xy, const X_FLOAT &xz, const X_FLOAT &yz, const int* const pbc): - _x(x.view()),_xw(x.view()),_nfirst(nfirst),_list(list.view()),_iswap(iswap), - _xprd(xprd),_yprd(yprd),_zprd(zprd), - _xy(xy),_xz(xz),_yz(yz) { - _pbc[0] = pbc[0]; _pbc[1] = pbc[1]; _pbc[2] = pbc[2]; - _pbc[3] = pbc[3]; _pbc[4] = pbc[4]; _pbc[5] = pbc[5]; - }; - - KOKKOS_INLINE_FUNCTION - void operator() (const int& i) const { - const int j = _list(_iswap,i); - if (PBC_FLAG == 0) { - _xw(i+_nfirst,0) = _x(j,0); - _xw(i+_nfirst,1) = _x(j,1); - _xw(i+_nfirst,2) = _x(j,2); - } else { - if (TRICLINIC == 0) { - _xw(i+_nfirst,0) = _x(j,0) + _pbc[0]*_xprd; - _xw(i+_nfirst,1) = _x(j,1) + _pbc[1]*_yprd; - _xw(i+_nfirst,2) = _x(j,2) + _pbc[2]*_zprd; - } else { - _xw(i+_nfirst,0) = _x(j,0) + _pbc[0]*_xprd + _pbc[5]*_xy + _pbc[4]*_xz; - _xw(i+_nfirst,1) = _x(j,1) + _pbc[1]*_yprd + _pbc[3]*_yz; - _xw(i+_nfirst,2) = _x(j,2) + _pbc[2]*_zprd; - } - } - - } -}; - -/* ---------------------------------------------------------------------- */ - -int AtomVecAngleKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d &list, - const int & iswap, - const int nfirst, const int &pbc_flag, - const int* const pbc) { - if (commKK->forward_comm_on_host) { - atomKK->sync(Host,X_MASK); - atomKK->modified(Host,X_MASK); - if (pbc_flag) { - if (domain->triclinic) { - struct AtomVecAngleKokkos_PackCommSelf - f(atomKK->k_x,nfirst,list,iswap, - domain->xprd,domain->yprd,domain->zprd, - domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); - } else { - struct AtomVecAngleKokkos_PackCommSelf - f(atomKK->k_x,nfirst,list,iswap, - domain->xprd,domain->yprd,domain->zprd, - domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); - } - } else { - if (domain->triclinic) { - struct AtomVecAngleKokkos_PackCommSelf - f(atomKK->k_x,nfirst,list,iswap, - domain->xprd,domain->yprd,domain->zprd, - domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); - } else { - struct AtomVecAngleKokkos_PackCommSelf - f(atomKK->k_x,nfirst,list,iswap, - domain->xprd,domain->yprd,domain->zprd, - domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); - } - } - } else { - atomKK->sync(Device,X_MASK); - atomKK->modified(Device,X_MASK); - if (pbc_flag) { - if (domain->triclinic) { - struct AtomVecAngleKokkos_PackCommSelf - f(atomKK->k_x,nfirst,list,iswap, - domain->xprd,domain->yprd,domain->zprd, - domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); - } else { - struct AtomVecAngleKokkos_PackCommSelf - f(atomKK->k_x,nfirst,list,iswap, - domain->xprd,domain->yprd,domain->zprd, - domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); - } - } else { - if (domain->triclinic) { - struct AtomVecAngleKokkos_PackCommSelf - f(atomKK->k_x,nfirst,list,iswap, - domain->xprd,domain->yprd,domain->zprd, - domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); - } else { - struct AtomVecAngleKokkos_PackCommSelf - f(atomKK->k_x,nfirst,list,iswap, - domain->xprd,domain->yprd,domain->zprd, - domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); - } - } - } - return n*3; -} - -/* ---------------------------------------------------------------------- */ - -template -struct AtomVecAngleKokkos_UnpackComm { - typedef DeviceType device_type; - - typename ArrayTypes::t_x_array _x; - typename ArrayTypes::t_xfloat_2d_const _buf; - int _first; - - AtomVecAngleKokkos_UnpackComm( - const typename DAT::tdual_x_array &x, - const typename DAT::tdual_xfloat_2d &buf, - const int& first):_x(x.view()),_buf(buf.view()), - _first(first) {}; - - KOKKOS_INLINE_FUNCTION - void operator() (const int& i) const { - _x(i+_first,0) = _buf(i,0); - _x(i+_first,1) = _buf(i,1); - _x(i+_first,2) = _buf(i,2); - } -}; - -/* ---------------------------------------------------------------------- */ - -void AtomVecAngleKokkos::unpack_comm_kokkos(const int &n, const int &first, - const DAT::tdual_xfloat_2d &buf) { - if (commKK->forward_comm_on_host) { - atomKK->sync(Host,X_MASK); - atomKK->modified(Host,X_MASK); - struct AtomVecAngleKokkos_UnpackComm f(atomKK->k_x,buf,first); - Kokkos::parallel_for(n,f); - } else { - atomKK->sync(Device,X_MASK); - atomKK->modified(Device,X_MASK); - struct AtomVecAngleKokkos_UnpackComm f(atomKK->k_x,buf,first); - Kokkos::parallel_for(n,f); - } -} - -/* ---------------------------------------------------------------------- */ - template struct AtomVecAngleKokkos_PackBorder { typedef DeviceType device_type; typedef ArrayTypes AT; typename AT::t_xfloat_2d _buf; - const typename AT::t_int_2d_const _list; - const int _iswap; + const typename AT::t_int_1d_const _list; const typename AT::t_x_array_randomread _x; const typename AT::t_tagint_1d _tag; const typename AT::t_int_1d _type; @@ -491,21 +202,20 @@ struct AtomVecAngleKokkos_PackBorder { AtomVecAngleKokkos_PackBorder( const typename AT::t_xfloat_2d &buf, - const typename AT::t_int_2d_const &list, - const int & iswap, + const typename AT::t_int_1d_const &list, const typename AT::t_x_array &x, const typename AT::t_tagint_1d &tag, const typename AT::t_int_1d &type, const typename AT::t_int_1d &mask, const typename AT::t_tagint_1d &molecule, const X_FLOAT &dx, const X_FLOAT &dy, const X_FLOAT &dz): - _buf(buf),_list(list),_iswap(iswap), + _buf(buf),_list(list), _x(x),_tag(tag),_type(type),_mask(mask),_molecule(molecule), _dx(dx),_dy(dy),_dz(dz) {} KOKKOS_INLINE_FUNCTION void operator() (const int& i) const { - const int j = _list(_iswap,i); + const int j = _list(i); if (PBC_FLAG == 0) { _buf(i,0) = _x(j,0); _buf(i,1) = _x(j,1); @@ -528,8 +238,8 @@ struct AtomVecAngleKokkos_PackBorder { /* ---------------------------------------------------------------------- */ -int AtomVecAngleKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, - DAT::tdual_xfloat_2d buf,int iswap, +int AtomVecAngleKokkos::pack_border_kokkos(int n, DAT::tdual_int_1d k_sendlist, + DAT::tdual_xfloat_2d buf, int pbc_flag, int *pbc, ExecutionSpace space) { X_FLOAT dx,dy,dz; @@ -547,12 +257,12 @@ int AtomVecAngleKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, if (space==Host) { AtomVecAngleKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,h_x,h_tag,h_type,h_mask,h_molecule,dx,dy,dz); + h_x,h_tag,h_type,h_mask,h_molecule,dx,dy,dz); Kokkos::parallel_for(n,f); } else { AtomVecAngleKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,d_x,d_tag,d_type,d_mask,d_molecule,dx,dy,dz); + d_x,d_tag,d_type,d_mask,d_molecule,dx,dy,dz); Kokkos::parallel_for(n,f); } @@ -561,12 +271,12 @@ int AtomVecAngleKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, if (space==Host) { AtomVecAngleKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,h_x,h_tag,h_type,h_mask,h_molecule,dx,dy,dz); + h_x,h_tag,h_type,h_mask,h_molecule,dx,dy,dz); Kokkos::parallel_for(n,f); } else { AtomVecAngleKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,d_x,d_tag,d_type,d_mask,d_molecule,dx,dy,dz); + d_x,d_tag,d_type,d_mask,d_molecule,dx,dy,dz); Kokkos::parallel_for(n,f); } } diff --git a/src/KOKKOS/atom_vec_angle_kokkos.h b/src/KOKKOS/atom_vec_angle_kokkos.h index 44f1d824b2..157e8b45cc 100644 --- a/src/KOKKOS/atom_vec_angle_kokkos.h +++ b/src/KOKKOS/atom_vec_angle_kokkos.h @@ -35,17 +35,8 @@ class AtomVecAngleKokkos : public AtomVecKokkos, public AtomVecAngle { void grow(int) override; void grow_pointers() override; void sort_kokkos(Kokkos::BinSort &Sorter) override; - int pack_comm_kokkos(const int &n, const DAT::tdual_int_2d &k_sendlist, - const int & iswap, - const DAT::tdual_xfloat_2d &buf, - const int &pbc_flag, const int pbc[]) override; - void unpack_comm_kokkos(const int &n, const int &nfirst, - const DAT::tdual_xfloat_2d &buf) override; - int pack_comm_self(const int &n, const DAT::tdual_int_2d &list, - const int & iswap, const int nfirst, - const int &pbc_flag, const int pbc[]) override; - int pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, - DAT::tdual_xfloat_2d buf,int iswap, + int pack_border_kokkos(int n, DAT::tdual_int_1d k_sendlist, + DAT::tdual_xfloat_2d buf, int pbc_flag, int *pbc, ExecutionSpace space) override; void unpack_border_kokkos(const int &n, const int &nfirst, const DAT::tdual_xfloat_2d &buf, diff --git a/src/KOKKOS/atom_vec_atomic_kokkos.cpp b/src/KOKKOS/atom_vec_atomic_kokkos.cpp index 973ad2f7f2..81f4f55962 100644 --- a/src/KOKKOS/atom_vec_atomic_kokkos.cpp +++ b/src/KOKKOS/atom_vec_atomic_kokkos.cpp @@ -16,7 +16,6 @@ #include "atom_kokkos.h" #include "atom_masks.h" -#include "comm_kokkos.h" #include "domain.h" #include "error.h" #include "fix.h" @@ -125,8 +124,7 @@ struct AtomVecAtomicKokkos_PackBorder { typedef DeviceType device_type; typename ArrayTypes::t_xfloat_2d _buf; - const typename ArrayTypes::t_int_2d_const _list; - const int _iswap; + const typename ArrayTypes::t_int_1d_const _list; const typename ArrayTypes::t_x_array_randomread _x; const typename ArrayTypes::t_tagint_1d _tag; const typename ArrayTypes::t_int_1d _type; @@ -135,20 +133,19 @@ struct AtomVecAtomicKokkos_PackBorder { AtomVecAtomicKokkos_PackBorder( const typename ArrayTypes::t_xfloat_2d &buf, - const typename ArrayTypes::t_int_2d_const &list, - const int &iswap, + const typename ArrayTypes::t_int_1d_const &list, const typename ArrayTypes::t_x_array &x, const typename ArrayTypes::t_tagint_1d &tag, const typename ArrayTypes::t_int_1d &type, const typename ArrayTypes::t_int_1d &mask, const X_FLOAT &dx, const X_FLOAT &dy, const X_FLOAT &dz): - _buf(buf),_list(list),_iswap(iswap), + _buf(buf),_list(list), _x(x),_tag(tag),_type(type),_mask(mask), _dx(dx),_dy(dy),_dz(dz) {} KOKKOS_INLINE_FUNCTION void operator() (const int& i) const { - const int j = _list(_iswap,i); + const int j = _list(i); if (PBC_FLAG == 0) { _buf(i,0) = _x(j,0); _buf(i,1) = _x(j,1); @@ -169,7 +166,7 @@ struct AtomVecAtomicKokkos_PackBorder { /* ---------------------------------------------------------------------- */ -int AtomVecAtomicKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, DAT::tdual_xfloat_2d buf,int iswap, +int AtomVecAtomicKokkos::pack_border_kokkos(int n, DAT::tdual_int_1d k_sendlist, DAT::tdual_xfloat_2d buf, int pbc_flag, int *pbc, ExecutionSpace space) { X_FLOAT dx,dy,dz; @@ -187,12 +184,12 @@ int AtomVecAtomicKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, if (space==Host) { AtomVecAtomicKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,h_x,h_tag,h_type,h_mask,dx,dy,dz); + h_x,h_tag,h_type,h_mask,dx,dy,dz); Kokkos::parallel_for(n,f); } else { AtomVecAtomicKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,d_x,d_tag,d_type,d_mask,dx,dy,dz); + d_x,d_tag,d_type,d_mask,dx,dy,dz); Kokkos::parallel_for(n,f); } @@ -201,12 +198,12 @@ int AtomVecAtomicKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, if (space==Host) { AtomVecAtomicKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,h_x,h_tag,h_type,h_mask,dx,dy,dz); + h_x,h_tag,h_type,h_mask,dx,dy,dz); Kokkos::parallel_for(n,f); } else { AtomVecAtomicKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,d_x,d_tag,d_type,d_mask,dx,dy,dz); + d_x,d_tag,d_type,d_mask,dx,dy,dz); Kokkos::parallel_for(n,f); } } diff --git a/src/KOKKOS/atom_vec_atomic_kokkos.h b/src/KOKKOS/atom_vec_atomic_kokkos.h index 07631dda98..457b5b61a9 100644 --- a/src/KOKKOS/atom_vec_atomic_kokkos.h +++ b/src/KOKKOS/atom_vec_atomic_kokkos.h @@ -36,8 +36,8 @@ class AtomVecAtomicKokkos : public AtomVecKokkos, public AtomVecAtomic { void grow(int) override; void grow_pointers() override; void sort_kokkos(Kokkos::BinSort &Sorter) override; - int pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, - DAT::tdual_xfloat_2d buf,int iswap, + int pack_border_kokkos(int n, DAT::tdual_int_1d k_sendlist, + DAT::tdual_xfloat_2d buf, int pbc_flag, int *pbc, ExecutionSpace space) override; void unpack_border_kokkos(const int &n, const int &nfirst, const DAT::tdual_xfloat_2d &buf, diff --git a/src/KOKKOS/atom_vec_bond_kokkos.cpp b/src/KOKKOS/atom_vec_bond_kokkos.cpp index a4fd9ca1b5..6b32574c2a 100644 --- a/src/KOKKOS/atom_vec_bond_kokkos.cpp +++ b/src/KOKKOS/atom_vec_bond_kokkos.cpp @@ -16,7 +16,6 @@ #include "atom_kokkos.h" #include "atom_masks.h" -#include "comm_kokkos.h" #include "domain.h" #include "error.h" #include "fix.h" @@ -158,8 +157,7 @@ struct AtomVecBondKokkos_PackBorder { typedef ArrayTypes AT; typename AT::t_xfloat_2d _buf; - const typename AT::t_int_2d_const _list; - const int _iswap; + const typename AT::t_int_1d_const _list; const typename AT::t_x_array_randomread _x; const typename AT::t_tagint_1d _tag; const typename AT::t_int_1d _type; @@ -169,21 +167,20 @@ struct AtomVecBondKokkos_PackBorder { AtomVecBondKokkos_PackBorder( const typename AT::t_xfloat_2d &buf, - const typename AT::t_int_2d_const &list, - const int & iswap, + const typename AT::t_int_1d_const &list, const typename AT::t_x_array &x, const typename AT::t_tagint_1d &tag, const typename AT::t_int_1d &type, const typename AT::t_int_1d &mask, const typename AT::t_tagint_1d &molecule, const X_FLOAT &dx, const X_FLOAT &dy, const X_FLOAT &dz): - _buf(buf),_list(list),_iswap(iswap), + _buf(buf),_list(list), _x(x),_tag(tag),_type(type),_mask(mask),_molecule(molecule), _dx(dx),_dy(dy),_dz(dz) {} KOKKOS_INLINE_FUNCTION void operator() (const int& i) const { - const int j = _list(_iswap,i); + const int j = _list(i); if (PBC_FLAG == 0) { _buf(i,0) = _x(j,0); _buf(i,1) = _x(j,1); @@ -206,8 +203,8 @@ struct AtomVecBondKokkos_PackBorder { /* ---------------------------------------------------------------------- */ -int AtomVecBondKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, - DAT::tdual_xfloat_2d buf,int iswap, +int AtomVecBondKokkos::pack_border_kokkos(int n, DAT::tdual_int_1d k_sendlist, + DAT::tdual_xfloat_2d buf, int pbc_flag, int *pbc, ExecutionSpace space) { X_FLOAT dx,dy,dz; @@ -225,12 +222,12 @@ int AtomVecBondKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, if (space==Host) { AtomVecBondKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,h_x,h_tag,h_type,h_mask,h_molecule,dx,dy,dz); + h_x,h_tag,h_type,h_mask,h_molecule,dx,dy,dz); Kokkos::parallel_for(n,f); } else { AtomVecBondKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,d_x,d_tag,d_type,d_mask,d_molecule,dx,dy,dz); + d_x,d_tag,d_type,d_mask,d_molecule,dx,dy,dz); Kokkos::parallel_for(n,f); } @@ -239,12 +236,12 @@ int AtomVecBondKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, if (space==Host) { AtomVecBondKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,h_x,h_tag,h_type,h_mask,h_molecule,dx,dy,dz); + h_x,h_tag,h_type,h_mask,h_molecule,dx,dy,dz); Kokkos::parallel_for(n,f); } else { AtomVecBondKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,d_x,d_tag,d_type,d_mask,d_molecule,dx,dy,dz); + d_x,d_tag,d_type,d_mask,d_molecule,dx,dy,dz); Kokkos::parallel_for(n,f); } } diff --git a/src/KOKKOS/atom_vec_bond_kokkos.h b/src/KOKKOS/atom_vec_bond_kokkos.h index 5ed59432de..cad1ea86d7 100644 --- a/src/KOKKOS/atom_vec_bond_kokkos.h +++ b/src/KOKKOS/atom_vec_bond_kokkos.h @@ -35,8 +35,8 @@ class AtomVecBondKokkos : public AtomVecKokkos, public AtomVecBond { void grow(int) override; void grow_pointers() override; void sort_kokkos(Kokkos::BinSort &Sorter) override; - int pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, - DAT::tdual_xfloat_2d buf,int iswap, + int pack_border_kokkos(int n, DAT::tdual_int_1d k_sendlist, + DAT::tdual_xfloat_2d buf, int pbc_flag, int *pbc, ExecutionSpace space) override; void unpack_border_kokkos(const int &n, const int &nfirst, const DAT::tdual_xfloat_2d &buf, diff --git a/src/KOKKOS/atom_vec_charge_kokkos.cpp b/src/KOKKOS/atom_vec_charge_kokkos.cpp index 4fa814f1ac..637a219433 100644 --- a/src/KOKKOS/atom_vec_charge_kokkos.cpp +++ b/src/KOKKOS/atom_vec_charge_kokkos.cpp @@ -16,7 +16,6 @@ #include "atom_kokkos.h" #include "atom_masks.h" -#include "comm_kokkos.h" #include "domain.h" #include "error.h" #include "fix.h" @@ -134,19 +133,17 @@ struct AtomVecChargeKokkos_PackComm { typename AT::t_x_array_randomread _x; typename AT::t_xfloat_2d_um _buf; - typename AT::t_int_2d_const _list; - const int _iswap; + typename AT::t_int_1d_const _list; X_FLOAT _xprd,_yprd,_zprd,_xy,_xz,_yz; X_FLOAT _pbc[6]; AtomVecChargeKokkos_PackComm( const typename DAT::tdual_x_array &x, const typename DAT::tdual_xfloat_2d &buf, - const typename DAT::tdual_int_2d &list, - const int & iswap, + const typename DAT::tdual_int_1d &list, const X_FLOAT &xprd, const X_FLOAT &yprd, const X_FLOAT &zprd, const X_FLOAT &xy, const X_FLOAT &xz, const X_FLOAT &yz, const int* const pbc): - _x(x.view()),_list(list.view()),_iswap(iswap), + _x(x.view()),_list(list.view()), _xprd(xprd),_yprd(yprd),_zprd(zprd), _xy(xy),_xz(xz),_yz(yz) { const size_t maxsend = (buf.view().extent(0)*buf.view().extent(1))/3; @@ -158,7 +155,7 @@ struct AtomVecChargeKokkos_PackComm { KOKKOS_INLINE_FUNCTION void operator() (const int& i) const { - const int j = _list(_iswap,i); + const int j = _list(i); if (PBC_FLAG == 0) { _buf(i,0) = _x(j,0); _buf(i,1) = _x(j,1); @@ -185,8 +182,7 @@ struct AtomVecChargeKokkos_PackBorder { typedef ArrayTypes AT; typename AT::t_xfloat_2d _buf; - const typename AT::t_int_2d_const _list; - const int _iswap; + const typename AT::t_int_1d_const _list; const typename AT::t_x_array_randomread _x; const typename AT::t_tagint_1d _tag; const typename AT::t_int_1d _type; @@ -196,21 +192,20 @@ struct AtomVecChargeKokkos_PackBorder { AtomVecChargeKokkos_PackBorder( const typename AT::t_xfloat_2d &buf, - const typename AT::t_int_2d_const &list, - const int & iswap, + const typename AT::t_int_1d_const &list, const typename AT::t_x_array &x, const typename AT::t_tagint_1d &tag, const typename AT::t_int_1d &type, const typename AT::t_int_1d &mask, const typename AT::t_float_1d &q, const X_FLOAT &dx, const X_FLOAT &dy, const X_FLOAT &dz): - _buf(buf),_list(list),_iswap(iswap), + _buf(buf),_list(list), _x(x),_tag(tag),_type(type),_mask(mask),_q(q), _dx(dx),_dy(dy),_dz(dz) {} KOKKOS_INLINE_FUNCTION void operator() (const int& i) const { - const int j = _list(_iswap,i); + const int j = _list(i); if (PBC_FLAG == 0) { _buf(i,0) = _x(j,0); _buf(i,1) = _x(j,1); @@ -233,7 +228,7 @@ struct AtomVecChargeKokkos_PackBorder { /* ---------------------------------------------------------------------- */ -int AtomVecChargeKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, DAT::tdual_xfloat_2d buf,int iswap, +int AtomVecChargeKokkos::pack_border_kokkos(int n, DAT::tdual_int_1d k_sendlist, DAT::tdual_xfloat_2d buf, int pbc_flag, int *pbc, ExecutionSpace space) { X_FLOAT dx,dy,dz; @@ -251,12 +246,12 @@ int AtomVecChargeKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, if (space==Host) { AtomVecChargeKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,h_x,h_tag,h_type,h_mask,h_q,dx,dy,dz); + h_x,h_tag,h_type,h_mask,h_q,dx,dy,dz); Kokkos::parallel_for(n,f); } else { AtomVecChargeKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,d_x,d_tag,d_type,d_mask,d_q,dx,dy,dz); + d_x,d_tag,d_type,d_mask,d_q,dx,dy,dz); Kokkos::parallel_for(n,f); } @@ -265,12 +260,12 @@ int AtomVecChargeKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, if (space==Host) { AtomVecChargeKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,h_x,h_tag,h_type,h_mask,h_q,dx,dy,dz); + h_x,h_tag,h_type,h_mask,h_q,dx,dy,dz); Kokkos::parallel_for(n,f); } else { AtomVecChargeKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,d_x,d_tag,d_type,d_mask,d_q,dx,dy,dz); + d_x,d_tag,d_type,d_mask,d_q,dx,dy,dz); Kokkos::parallel_for(n,f); } } diff --git a/src/KOKKOS/atom_vec_charge_kokkos.h b/src/KOKKOS/atom_vec_charge_kokkos.h index 397a5ee4c0..1d1c68735e 100644 --- a/src/KOKKOS/atom_vec_charge_kokkos.h +++ b/src/KOKKOS/atom_vec_charge_kokkos.h @@ -36,8 +36,8 @@ class AtomVecChargeKokkos : public AtomVecKokkos, public AtomVecCharge { void grow(int) override; void grow_pointers() override; void sort_kokkos(Kokkos::BinSort &Sorter) override; - int pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, - DAT::tdual_xfloat_2d buf,int iswap, + int pack_border_kokkos(int n, DAT::tdual_int_1d k_sendlist, + DAT::tdual_xfloat_2d buf, int pbc_flag, int *pbc, ExecutionSpace space) override; void unpack_border_kokkos(const int &n, const int &nfirst, const DAT::tdual_xfloat_2d &buf, diff --git a/src/KOKKOS/atom_vec_dipole_kokkos.cpp b/src/KOKKOS/atom_vec_dipole_kokkos.cpp index ecc0f3b497..7728fedd4b 100644 --- a/src/KOKKOS/atom_vec_dipole_kokkos.cpp +++ b/src/KOKKOS/atom_vec_dipole_kokkos.cpp @@ -16,7 +16,6 @@ #include "atom_kokkos.h" #include "atom_masks.h" -#include "comm_kokkos.h" #include "domain.h" #include "error.h" #include "fix.h" @@ -136,8 +135,7 @@ struct AtomVecDipoleKokkos_PackComm { typename ArrayTypes::t_x_array_randomread _x; typename ArrayTypes::t_mu_array_randomread _mu; typename ArrayTypes::t_xfloat_2d_um _buf; - typename ArrayTypes::t_int_2d_const _list; - const int _iswap; + typename ArrayTypes::t_int_1d_const _list; X_FLOAT _xprd,_yprd,_zprd,_xy,_xz,_yz; X_FLOAT _pbc[6]; @@ -145,13 +143,12 @@ struct AtomVecDipoleKokkos_PackComm { const typename DAT::tdual_x_array &x, const typename DAT::tdual_float_1d_4 &mu, const typename DAT::tdual_xfloat_2d &buf, - const typename DAT::tdual_int_2d &list, - const int & iswap, + const typename DAT::tdual_int_1d &list, const X_FLOAT &xprd, const X_FLOAT &yprd, const X_FLOAT &zprd, const X_FLOAT &xy, const X_FLOAT &xz, const X_FLOAT &yz, const int* const pbc): _x(x.view()), _mu(mu.view()), - _list(list.view()),_iswap(iswap), + _list(list.view()), _xprd(xprd),_yprd(yprd),_zprd(zprd), _xy(xy),_xz(xz),_yz(yz) { const size_t elements = 7; // size_forward @@ -163,7 +160,7 @@ struct AtomVecDipoleKokkos_PackComm { KOKKOS_INLINE_FUNCTION void operator() (const int& i) const { - const int j = _list(_iswap,i); + const int j = _list(i); if (PBC_FLAG == 0) { _buf(i,0) = _x(j,0); _buf(i,1) = _x(j,1); @@ -201,8 +198,7 @@ struct AtomVecDipoleKokkos_PackBorder { typedef DeviceType device_type; typename ArrayTypes::t_xfloat_2d _buf; - const typename ArrayTypes::t_int_2d_const _list; - const int _iswap; + const typename ArrayTypes::t_int_1d_const _list; const typename ArrayTypes::t_x_array_randomread _x; const typename ArrayTypes::t_tagint_1d _tag; const typename ArrayTypes::t_int_1d _type; @@ -213,8 +209,7 @@ struct AtomVecDipoleKokkos_PackBorder { AtomVecDipoleKokkos_PackBorder( const typename ArrayTypes::t_xfloat_2d &buf, - const typename ArrayTypes::t_int_2d_const &list, - const int & iswap, + const typename ArrayTypes::t_int_1d_const &list, const typename ArrayTypes::t_x_array &x, const typename ArrayTypes::t_tagint_1d &tag, const typename ArrayTypes::t_int_1d &type, @@ -222,13 +217,13 @@ struct AtomVecDipoleKokkos_PackBorder { const typename ArrayTypes::t_float_1d &q, const typename ArrayTypes::t_mu_array_randomread &mu, const X_FLOAT &dx, const X_FLOAT &dy, const X_FLOAT &dz): - _buf(buf),_list(list),_iswap(iswap), + _buf(buf),_list(list), _x(x),_tag(tag),_type(type),_mask(mask),_q(q),_mu(mu), _dx(dx),_dy(dy),_dz(dz) {} KOKKOS_INLINE_FUNCTION void operator() (const int& i) const { - const int j = _list(_iswap,i); + const int j = _list(i); if (PBC_FLAG == 0) { _buf(i,0) = _x(j,0); _buf(i,1) = _x(j,1); @@ -259,7 +254,7 @@ struct AtomVecDipoleKokkos_PackBorder { /* ---------------------------------------------------------------------- */ -int AtomVecDipoleKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, DAT::tdual_xfloat_2d buf,int iswap, +int AtomVecDipoleKokkos::pack_border_kokkos(int n, DAT::tdual_int_1d k_sendlist, DAT::tdual_xfloat_2d buf, int pbc_flag, int *pbc, ExecutionSpace space) { X_FLOAT dx,dy,dz; @@ -277,12 +272,12 @@ int AtomVecDipoleKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, if (space==Host) { AtomVecDipoleKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,h_x,h_tag,h_type,h_mask,h_q,h_mu,dx,dy,dz); + h_x,h_tag,h_type,h_mask,h_q,h_mu,dx,dy,dz); Kokkos::parallel_for(n,f); } else { AtomVecDipoleKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,d_x,d_tag,d_type,d_mask,d_q,d_mu,dx,dy,dz); + d_x,d_tag,d_type,d_mask,d_q,d_mu,dx,dy,dz); Kokkos::parallel_for(n,f); } @@ -291,12 +286,12 @@ int AtomVecDipoleKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, if (space==Host) { AtomVecDipoleKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,h_x,h_tag,h_type,h_mask,h_q,h_mu,dx,dy,dz); + h_x,h_tag,h_type,h_mask,h_q,h_mu,dx,dy,dz); Kokkos::parallel_for(n,f); } else { AtomVecDipoleKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,d_x,d_tag,d_type,d_mask,d_q,d_mu,dx,dy,dz); + d_x,d_tag,d_type,d_mask,d_q,d_mu,dx,dy,dz); Kokkos::parallel_for(n,f); } } diff --git a/src/KOKKOS/atom_vec_dipole_kokkos.h b/src/KOKKOS/atom_vec_dipole_kokkos.h index 97ec92c6c6..46e102936a 100644 --- a/src/KOKKOS/atom_vec_dipole_kokkos.h +++ b/src/KOKKOS/atom_vec_dipole_kokkos.h @@ -36,8 +36,8 @@ class AtomVecDipoleKokkos : public AtomVecKokkos, public AtomVecDipole { void grow(int) override; void grow_pointers() override; void sort_kokkos(Kokkos::BinSort &Sorter) override; - int pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, - DAT::tdual_xfloat_2d buf,int iswap, + int pack_border_kokkos(int n, DAT::tdual_int_1d k_sendlist, + DAT::tdual_xfloat_2d buf, int pbc_flag, int *pbc, ExecutionSpace space) override; void unpack_border_kokkos(const int &n, const int &nfirst, const DAT::tdual_xfloat_2d &buf, diff --git a/src/KOKKOS/atom_vec_dpd_kokkos.cpp b/src/KOKKOS/atom_vec_dpd_kokkos.cpp index 70aedcc931..6152fa60fb 100644 --- a/src/KOKKOS/atom_vec_dpd_kokkos.cpp +++ b/src/KOKKOS/atom_vec_dpd_kokkos.cpp @@ -20,6 +20,7 @@ #include "domain.h" #include "error.h" #include "fix.h" +#include "kokkos.h" #include "memory_kokkos.h" #include "modify.h" @@ -168,8 +169,7 @@ struct AtomVecDPDKokkos_PackComm { typename ArrayTypes::t_x_array_randomread _x; typename ArrayTypes::t_efloat_1d _dpdTheta,_uCond,_uMech,_uChem; typename ArrayTypes::t_xfloat_2d_um _buf; - typename ArrayTypes::t_int_2d_const _list; - const int _iswap; + typename ArrayTypes::t_int_1d_const _list; X_FLOAT _xprd,_yprd,_zprd,_xy,_xz,_yz; X_FLOAT _pbc[6]; @@ -180,8 +180,7 @@ struct AtomVecDPDKokkos_PackComm { const typename DAT::tdual_efloat_1d &uMech, const typename DAT::tdual_efloat_1d &uChem, const typename DAT::tdual_xfloat_2d &buf, - const typename DAT::tdual_int_2d &list, - const int & iswap, + const typename DAT::tdual_int_1d &list, const X_FLOAT &xprd, const X_FLOAT &yprd, const X_FLOAT &zprd, const X_FLOAT &xy, const X_FLOAT &xz, const X_FLOAT &yz, const int* const pbc): _x(x.view()), @@ -189,7 +188,7 @@ struct AtomVecDPDKokkos_PackComm { _uCond(uCond.view()), _uMech(uMech.view()), _uChem(uChem.view()), - _list(list.view()),_iswap(iswap), + _list(list.view()), _xprd(xprd),_yprd(yprd),_zprd(zprd), _xy(xy),_xz(xz),_yz(yz) { const size_t maxsend = (buf.view().extent(0)*buf.view().extent(1))/3; @@ -201,7 +200,7 @@ struct AtomVecDPDKokkos_PackComm { KOKKOS_INLINE_FUNCTION void operator() (const int& i) const { - const int j = _list(_iswap,i); + const int j = _list(i); if (PBC_FLAG == 0) { _buf(i,0) = _x(j,0); _buf(i,1) = _x(j,1); @@ -227,8 +226,7 @@ struct AtomVecDPDKokkos_PackComm { /* ---------------------------------------------------------------------- */ int AtomVecDPDKokkos::pack_comm_kokkos(const int &n, - const DAT::tdual_int_2d &list, - const int & iswap, + const DAT::tdual_int_1d &list, const DAT::tdual_xfloat_2d &buf, const int &pbc_flag, const int* const pbc) @@ -236,20 +234,20 @@ int AtomVecDPDKokkos::pack_comm_kokkos(const int &n, // Check whether to always run forward communication on the host // Choose correct forward PackComm kernel - if (commKK->forward_comm_on_host) { + if (lmp->kokkos->forward_comm_on_host) { atomKK->sync(Host,X_MASK|DPDTHETA_MASK|UCOND_MASK|UMECH_MASK|UCHEM_MASK); if (pbc_flag) { if (domain->triclinic) { struct AtomVecDPDKokkos_PackComm f(atomKK->k_x, atomKK->k_dpdTheta,atomKK->k_uCond,atomKK->k_uMech,atomKK->k_uChem, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); } else { struct AtomVecDPDKokkos_PackComm f(atomKK->k_x, atomKK->k_dpdTheta,atomKK->k_uCond,atomKK->k_uMech,atomKK->k_uChem, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); @@ -258,14 +256,14 @@ int AtomVecDPDKokkos::pack_comm_kokkos(const int &n, if (domain->triclinic) { struct AtomVecDPDKokkos_PackComm f(atomKK->k_x, atomKK->k_dpdTheta,atomKK->k_uCond,atomKK->k_uMech,atomKK->k_uChem, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); } else { struct AtomVecDPDKokkos_PackComm f(atomKK->k_x, atomKK->k_dpdTheta,atomKK->k_uCond,atomKK->k_uMech,atomKK->k_uChem, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); @@ -277,14 +275,14 @@ int AtomVecDPDKokkos::pack_comm_kokkos(const int &n, if (domain->triclinic) { struct AtomVecDPDKokkos_PackComm f(atomKK->k_x, atomKK->k_dpdTheta,atomKK->k_uCond,atomKK->k_uMech,atomKK->k_uChem, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); } else { struct AtomVecDPDKokkos_PackComm f(atomKK->k_x, atomKK->k_dpdTheta,atomKK->k_uCond,atomKK->k_uMech,atomKK->k_uChem, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); @@ -293,14 +291,14 @@ int AtomVecDPDKokkos::pack_comm_kokkos(const int &n, if (domain->triclinic) { struct AtomVecDPDKokkos_PackComm f(atomKK->k_x, atomKK->k_dpdTheta,atomKK->k_uCond,atomKK->k_uMech,atomKK->k_uChem, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); } else { struct AtomVecDPDKokkos_PackComm f(atomKK->k_x, atomKK->k_dpdTheta,atomKK->k_uCond,atomKK->k_uMech,atomKK->k_uChem, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); @@ -321,8 +319,7 @@ struct AtomVecDPDKokkos_PackCommSelf { typename ArrayTypes::t_x_array _xw; typename ArrayTypes::t_efloat_1d _dpdTheta,_uCond,_uMech,_uChem; int _nfirst; - typename ArrayTypes::t_int_2d_const _list; - const int _iswap; + typename ArrayTypes::t_int_1d_const _list; X_FLOAT _xprd,_yprd,_zprd,_xy,_xz,_yz; X_FLOAT _pbc[6]; @@ -333,8 +330,7 @@ struct AtomVecDPDKokkos_PackCommSelf { const typename DAT::tdual_efloat_1d &uMech, const typename DAT::tdual_efloat_1d &uChem, const int &nfirst, - const typename DAT::tdual_int_2d &list, - const int & iswap, + const typename DAT::tdual_int_1d &list, const X_FLOAT &xprd, const X_FLOAT &yprd, const X_FLOAT &zprd, const X_FLOAT &xy, const X_FLOAT &xz, const X_FLOAT &yz, const int* const pbc): _x(x.view()),_xw(x.view()), @@ -342,7 +338,7 @@ struct AtomVecDPDKokkos_PackCommSelf { _uCond(uCond.view()), _uMech(uMech.view()), _uChem(uChem.view()), - _nfirst(nfirst),_list(list.view()),_iswap(iswap), + _nfirst(nfirst),_list(list.view()), _xprd(xprd),_yprd(yprd),_zprd(zprd), _xy(xy),_xz(xz),_yz(yz) { _pbc[0] = pbc[0]; _pbc[1] = pbc[1]; _pbc[2] = pbc[2]; @@ -351,7 +347,7 @@ struct AtomVecDPDKokkos_PackCommSelf { KOKKOS_INLINE_FUNCTION void operator() (const int& i) const { - const int j = _list(_iswap,i); + const int j = _list(i); if (PBC_FLAG == 0) { _xw(i+_nfirst,0) = _x(j,0); _xw(i+_nfirst,1) = _x(j,1); @@ -376,23 +372,23 @@ struct AtomVecDPDKokkos_PackCommSelf { /* ---------------------------------------------------------------------- */ -int AtomVecDPDKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d &list, const int & iswap, +int AtomVecDPDKokkos::pack_comm_self(const int &n, const DAT::tdual_int_1d &list, const int nfirst, const int &pbc_flag, const int* const pbc) { - if (commKK->forward_comm_on_host) { + if (lmp->kokkos->forward_comm_on_host) { atomKK->sync(Host,X_MASK|DPDTHETA_MASK|UCOND_MASK|UMECH_MASK|UCHEM_MASK); atomKK->modified(Host,X_MASK|DPDTHETA_MASK|UCOND_MASK|UMECH_MASK|UCHEM_MASK); if (pbc_flag) { if (domain->triclinic) { struct AtomVecDPDKokkos_PackCommSelf f(atomKK->k_x, atomKK->k_dpdTheta,atomKK->k_uCond,atomKK->k_uMech,atomKK->k_uChem, - nfirst,list,iswap, + nfirst,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); } else { struct AtomVecDPDKokkos_PackCommSelf f(atomKK->k_x, atomKK->k_dpdTheta,atomKK->k_uCond,atomKK->k_uMech,atomKK->k_uChem, - nfirst,list,iswap, + nfirst,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); @@ -401,14 +397,14 @@ int AtomVecDPDKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d &list if (domain->triclinic) { struct AtomVecDPDKokkos_PackCommSelf f(atomKK->k_x, atomKK->k_dpdTheta,atomKK->k_uCond,atomKK->k_uMech,atomKK->k_uChem, - nfirst,list,iswap, + nfirst,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); } else { struct AtomVecDPDKokkos_PackCommSelf f(atomKK->k_x, atomKK->k_dpdTheta,atomKK->k_uCond,atomKK->k_uMech,atomKK->k_uChem, - nfirst,list,iswap, + nfirst,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); @@ -421,14 +417,14 @@ int AtomVecDPDKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d &list if (domain->triclinic) { struct AtomVecDPDKokkos_PackCommSelf f(atomKK->k_x, atomKK->k_dpdTheta,atomKK->k_uCond,atomKK->k_uMech,atomKK->k_uChem, - nfirst,list,iswap, + nfirst,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); } else { struct AtomVecDPDKokkos_PackCommSelf f(atomKK->k_x, atomKK->k_dpdTheta,atomKK->k_uCond,atomKK->k_uMech,atomKK->k_uChem, - nfirst,list,iswap, + nfirst,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); @@ -437,14 +433,14 @@ int AtomVecDPDKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d &list if (domain->triclinic) { struct AtomVecDPDKokkos_PackCommSelf f(atomKK->k_x, atomKK->k_dpdTheta,atomKK->k_uCond,atomKK->k_uMech,atomKK->k_uChem, - nfirst,list,iswap, + nfirst,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); } else { struct AtomVecDPDKokkos_PackCommSelf f(atomKK->k_x, atomKK->k_dpdTheta,atomKK->k_uCond,atomKK->k_uMech,atomKK->k_uChem, - nfirst,list,iswap, + nfirst,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); @@ -496,7 +492,7 @@ struct AtomVecDPDKokkos_UnpackComm { void AtomVecDPDKokkos::unpack_comm_kokkos(const int &n, const int &first, const DAT::tdual_xfloat_2d &buf) { - if (commKK->forward_comm_on_host) { + if (lmp->kokkos->forward_comm_on_host) { atomKK->sync(Host,X_MASK|DPDTHETA_MASK|UCOND_MASK|UMECH_MASK|UCHEM_MASK); atomKK->modified(Host,X_MASK|DPDTHETA_MASK|UCOND_MASK|UMECH_MASK|UCHEM_MASK); struct AtomVecDPDKokkos_UnpackComm f(atomKK->k_x, @@ -520,8 +516,7 @@ struct AtomVecDPDKokkos_PackBorder { typedef DeviceType device_type; typename ArrayTypes::t_xfloat_2d _buf; - const typename ArrayTypes::t_int_2d_const _list; - const int _iswap; + const typename ArrayTypes::t_int_1d_const _list; const typename ArrayTypes::t_x_array_randomread _x; const typename ArrayTypes::t_tagint_1d _tag; const typename ArrayTypes::t_int_1d _type; @@ -531,8 +526,7 @@ struct AtomVecDPDKokkos_PackBorder { AtomVecDPDKokkos_PackBorder( const typename ArrayTypes::t_xfloat_2d &buf, - const typename ArrayTypes::t_int_2d_const &list, - const int & iswap, + const typename ArrayTypes::t_int_1d_const &list, const typename ArrayTypes::t_x_array &x, const typename ArrayTypes::t_tagint_1d &tag, const typename ArrayTypes::t_int_1d &type, @@ -544,7 +538,7 @@ struct AtomVecDPDKokkos_PackBorder { const typename ArrayTypes::t_efloat_1d &uCG, const typename ArrayTypes::t_efloat_1d &uCGnew, const X_FLOAT &dx, const X_FLOAT &dy, const X_FLOAT &dz): - _buf(buf),_list(list),_iswap(iswap), + _buf(buf),_list(list), _x(x),_tag(tag),_type(type),_mask(mask), _dpdTheta(dpdTheta), _uCond(uCond), @@ -556,7 +550,7 @@ struct AtomVecDPDKokkos_PackBorder { KOKKOS_INLINE_FUNCTION void operator() (const int& i) const { - const int j = _list(_iswap,i); + const int j = _list(i); if (PBC_FLAG == 0) { _buf(i,0) = _x(j,0); _buf(i,1) = _x(j,1); @@ -580,7 +574,7 @@ struct AtomVecDPDKokkos_PackBorder { /* ---------------------------------------------------------------------- */ -int AtomVecDPDKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, DAT::tdual_xfloat_2d buf,int iswap, +int AtomVecDPDKokkos::pack_border_kokkos(int n, DAT::tdual_int_1d k_sendlist, DAT::tdual_xfloat_2d buf, int pbc_flag, int *pbc, ExecutionSpace space) { X_FLOAT dx,dy,dz; @@ -600,14 +594,14 @@ int AtomVecDPDKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, DA if (space==Host) { AtomVecDPDKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,h_x,h_tag,h_type,h_mask, + h_x,h_tag,h_type,h_mask, h_dpdTheta,h_uCond,h_uMech,h_uChem,h_uCG,h_uCGnew, dx,dy,dz); Kokkos::parallel_for(n,f); } else { AtomVecDPDKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,d_x,d_tag,d_type,d_mask, + d_x,d_tag,d_type,d_mask, d_dpdTheta,d_uCond,d_uMech,d_uChem,d_uCG,d_uCGnew, dx,dy,dz); Kokkos::parallel_for(n,f); @@ -618,14 +612,14 @@ int AtomVecDPDKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, DA if (space==Host) { AtomVecDPDKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,h_x,h_tag,h_type,h_mask, + h_x,h_tag,h_type,h_mask, h_dpdTheta,h_uCond,h_uMech,h_uChem,h_uCG,h_uCGnew, dx,dy,dz); Kokkos::parallel_for(n,f); } else { AtomVecDPDKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,d_x,d_tag,d_type,d_mask, + d_x,d_tag,d_type,d_mask, d_dpdTheta,d_uCond,d_uMech,d_uChem,d_uCG,d_uCGnew, dx,dy,dz); Kokkos::parallel_for(n,f); diff --git a/src/KOKKOS/atom_vec_dpd_kokkos.h b/src/KOKKOS/atom_vec_dpd_kokkos.h index a76d7f908a..185422cfcf 100644 --- a/src/KOKKOS/atom_vec_dpd_kokkos.h +++ b/src/KOKKOS/atom_vec_dpd_kokkos.h @@ -36,17 +36,16 @@ class AtomVecDPDKokkos : public AtomVecKokkos, public AtomVecDPD { void grow(int) override; void grow_pointers() override; void sort_kokkos(Kokkos::BinSort &Sorter) override; - int pack_comm_kokkos(const int &n, const DAT::tdual_int_2d &k_sendlist, - const int & iswap, + int pack_comm_kokkos(const int &n, const DAT::tdual_int_1d &k_sendlist, const DAT::tdual_xfloat_2d &buf, const int &pbc_flag, const int pbc[]) override; void unpack_comm_kokkos(const int &n, const int &nfirst, const DAT::tdual_xfloat_2d &buf) override; - int pack_comm_self(const int &n, const DAT::tdual_int_2d &list, - const int & iswap, const int nfirst, + int pack_comm_self(const int &n, const DAT::tdual_int_1d &list, + const int nfirst, const int &pbc_flag, const int pbc[]) override; - int pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, - DAT::tdual_xfloat_2d buf,int iswap, + int pack_border_kokkos(int n, DAT::tdual_int_1d k_sendlist, + DAT::tdual_xfloat_2d buf, int pbc_flag, int *pbc, ExecutionSpace space) override; void unpack_border_kokkos(const int &n, const int &nfirst, const DAT::tdual_xfloat_2d &buf, diff --git a/src/KOKKOS/atom_vec_full_kokkos.cpp b/src/KOKKOS/atom_vec_full_kokkos.cpp index 732078a627..1ae93a3df6 100644 --- a/src/KOKKOS/atom_vec_full_kokkos.cpp +++ b/src/KOKKOS/atom_vec_full_kokkos.cpp @@ -16,7 +16,6 @@ #include "atom_kokkos.h" #include "atom_masks.h" -#include "comm_kokkos.h" #include "domain.h" #include "error.h" #include "fix.h" @@ -275,8 +274,7 @@ struct AtomVecFullKokkos_PackBorder { typedef ArrayTypes AT; typename AT::t_xfloat_2d _buf; - const typename AT::t_int_2d_const _list; - const int _iswap; + const typename AT::t_int_1d_const _list; const typename AT::t_x_array_randomread _x; const typename AT::t_tagint_1d _tag; const typename AT::t_int_1d _type; @@ -287,8 +285,7 @@ struct AtomVecFullKokkos_PackBorder { AtomVecFullKokkos_PackBorder( const typename AT::t_xfloat_2d &buf, - const typename AT::t_int_2d_const &list, - const int & iswap, + const typename AT::t_int_1d_const &list, const typename AT::t_x_array &x, const typename AT::t_tagint_1d &tag, const typename AT::t_int_1d &type, @@ -296,13 +293,13 @@ struct AtomVecFullKokkos_PackBorder { const typename AT::t_float_1d &q, const typename AT::t_tagint_1d &molecule, const X_FLOAT &dx, const X_FLOAT &dy, const X_FLOAT &dz): - _buf(buf),_list(list),_iswap(iswap), + _buf(buf),_list(list), _x(x),_tag(tag),_type(type),_mask(mask),_q(q),_molecule(molecule), _dx(dx),_dy(dy),_dz(dz) {} KOKKOS_INLINE_FUNCTION void operator() (const int& i) const { - const int j = _list(_iswap,i); + const int j = _list(i); if (PBC_FLAG == 0) { _buf(i,0) = _x(j,0); _buf(i,1) = _x(j,1); @@ -327,8 +324,8 @@ struct AtomVecFullKokkos_PackBorder { /* ---------------------------------------------------------------------- */ -int AtomVecFullKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, - DAT::tdual_xfloat_2d buf,int iswap, +int AtomVecFullKokkos::pack_border_kokkos(int n, DAT::tdual_int_1d k_sendlist, + DAT::tdual_xfloat_2d buf, int pbc_flag, int *pbc, ExecutionSpace space) { X_FLOAT dx,dy,dz; @@ -346,12 +343,12 @@ int AtomVecFullKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, if (space==Host) { AtomVecFullKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,h_x,h_tag,h_type,h_mask,h_q,h_molecule,dx,dy,dz); + h_x,h_tag,h_type,h_mask,h_q,h_molecule,dx,dy,dz); Kokkos::parallel_for(n,f); } else { AtomVecFullKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,d_x,d_tag,d_type,d_mask,d_q,d_molecule,dx,dy,dz); + d_x,d_tag,d_type,d_mask,d_q,d_molecule,dx,dy,dz); Kokkos::parallel_for(n,f); } @@ -360,12 +357,12 @@ int AtomVecFullKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, if (space==Host) { AtomVecFullKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,h_x,h_tag,h_type,h_mask,h_q,h_molecule,dx,dy,dz); + h_x,h_tag,h_type,h_mask,h_q,h_molecule,dx,dy,dz); Kokkos::parallel_for(n,f); } else { AtomVecFullKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,d_x,d_tag,d_type,d_mask,d_q,d_molecule,dx,dy,dz); + d_x,d_tag,d_type,d_mask,d_q,d_molecule,dx,dy,dz); Kokkos::parallel_for(n,f); } } diff --git a/src/KOKKOS/atom_vec_full_kokkos.h b/src/KOKKOS/atom_vec_full_kokkos.h index 4937ef4152..9eea48ef95 100644 --- a/src/KOKKOS/atom_vec_full_kokkos.h +++ b/src/KOKKOS/atom_vec_full_kokkos.h @@ -35,8 +35,8 @@ class AtomVecFullKokkos : public AtomVecKokkos, public AtomVecFull { void grow(int) override; void grow_pointers() override; void sort_kokkos(Kokkos::BinSort &Sorter) override; - int pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, - DAT::tdual_xfloat_2d buf,int iswap, + int pack_border_kokkos(int n, DAT::tdual_int_1d k_sendlist, + DAT::tdual_xfloat_2d buf, int pbc_flag, int *pbc, ExecutionSpace space) override; void unpack_border_kokkos(const int &n, const int &nfirst, const DAT::tdual_xfloat_2d &buf, diff --git a/src/KOKKOS/atom_vec_hybrid_kokkos.cpp b/src/KOKKOS/atom_vec_hybrid_kokkos.cpp index 08bcaaef74..77af2cff05 100644 --- a/src/KOKKOS/atom_vec_hybrid_kokkos.cpp +++ b/src/KOKKOS/atom_vec_hybrid_kokkos.cpp @@ -15,14 +15,7 @@ #include "atom_vec_hybrid_kokkos.h" #include "atom_kokkos.h" -#include "atom_masks.h" -#include "domain.h" #include "error.h" -#include "fix.h" -#include "memory_kokkos.h" -#include "modify.h" - -#include using namespace LAMMPS_NS; @@ -63,8 +56,7 @@ void AtomVecHybridKokkos::sort_kokkos(Kokkos::BinSort &Sorte /* ---------------------------------------------------------------------- */ -int AtomVecHybridKokkos::pack_comm_kokkos(const int &/*n*/, const DAT::tdual_int_2d &/*k_sendlist*/, - const int & /*iswap*/, +int AtomVecHybridKokkos::pack_comm_kokkos(const int &/*n*/, const DAT::tdual_int_1d &/*k_sendlist*/, const DAT::tdual_xfloat_2d &/*buf*/, const int &/*pbc_flag*/, const int /*pbc*/[]) { @@ -78,16 +70,16 @@ void AtomVecHybridKokkos::unpack_comm_kokkos(const int &/*n*/, const int &/*nfir error->all(FLERR,"AtomVecHybridKokkos doesn't yet support threaded comm"); } -int AtomVecHybridKokkos::pack_comm_self(const int &/*n*/, const DAT::tdual_int_2d &/*list*/, - const int & /*iswap*/, const int /*nfirst*/, - const int &/*pbc_flag*/, const int /*pbc*/[]) +int AtomVecHybridKokkos::pack_comm_self(const int &/*n*/, const DAT::tdual_int_1d &/*list*/, + const int /*nfirst*/, + const int &/*pbc_flag*/, const int pbc[]) { error->all(FLERR,"AtomVecHybridKokkos doesn't yet support threaded comm"); return 0; } -int AtomVecHybridKokkos::pack_border_kokkos(int /*n*/, DAT::tdual_int_2d /*k_sendlist*/, - DAT::tdual_xfloat_2d /*buf*/,int /*iswap*/, +int AtomVecHybridKokkos::pack_border_kokkos(int /*n*/, DAT::tdual_int_1d /*k_sendlist*/, + DAT::tdual_xfloat_2d /*buf*/, int /*pbc_flag*/, int * /*pbc*/, ExecutionSpace /*space*/) { error->all(FLERR,"AtomVecHybridKokkos doesn't yet support threaded comm"); diff --git a/src/KOKKOS/atom_vec_hybrid_kokkos.h b/src/KOKKOS/atom_vec_hybrid_kokkos.h index 6f81c93673..19210549f5 100644 --- a/src/KOKKOS/atom_vec_hybrid_kokkos.h +++ b/src/KOKKOS/atom_vec_hybrid_kokkos.h @@ -36,17 +36,16 @@ class AtomVecHybridKokkos : public AtomVecKokkos, public AtomVecHybrid { void grow(int) override; void sort_kokkos(Kokkos::BinSort &Sorter) override; - int pack_comm_kokkos(const int &n, const DAT::tdual_int_2d &k_sendlist, - const int & iswap, + int pack_comm_kokkos(const int &n, const DAT::tdual_int_1d &k_sendlist, const DAT::tdual_xfloat_2d &buf, const int &pbc_flag, const int pbc[]) override; void unpack_comm_kokkos(const int &n, const int &nfirst, const DAT::tdual_xfloat_2d &buf) override; - int pack_comm_self(const int &n, const DAT::tdual_int_2d &list, - const int & iswap, const int nfirst, + int pack_comm_self(const int &n, const DAT::tdual_int_1d &list, + const int nfirst, const int &pbc_flag, const int pbc[]) override; - int pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, - DAT::tdual_xfloat_2d buf,int iswap, + int pack_border_kokkos(int n, DAT::tdual_int_1d k_sendlist, + DAT::tdual_xfloat_2d buf, int pbc_flag, int *pbc, ExecutionSpace space) override; void unpack_border_kokkos(const int &n, const int &nfirst, const DAT::tdual_xfloat_2d &buf, diff --git a/src/KOKKOS/atom_vec_kokkos.cpp b/src/KOKKOS/atom_vec_kokkos.cpp index 93393e9e09..d54cc2c3af 100644 --- a/src/KOKKOS/atom_vec_kokkos.cpp +++ b/src/KOKKOS/atom_vec_kokkos.cpp @@ -17,8 +17,8 @@ #include "atom_kokkos.h" #include "atom_masks.h" #include "comm_kokkos.h" -#include "error.h" #include "domain.h" +#include "kokkos.h" using namespace LAMMPS_NS; @@ -37,7 +37,6 @@ AtomVecKokkos::AtomVecKokkos(LAMMPS *lmp) : AtomVec(lmp) k_count = DAT::tdual_int_1d("atom:k_count",1); atomKK = (AtomKokkos *) atom; - commKK = (CommKokkos *) comm; } /* ---------------------------------------------------------------------- */ @@ -57,19 +56,17 @@ struct AtomVecKokkos_PackComm { typename ArrayTypes::t_x_array_randomread _x; typename ArrayTypes::t_xfloat_2d_um _buf; - typename ArrayTypes::t_int_2d_const _list; - const int _iswap; + typename ArrayTypes::t_int_1d_const _list; X_FLOAT _xprd,_yprd,_zprd,_xy,_xz,_yz; X_FLOAT _pbc[6]; AtomVecKokkos_PackComm( const typename DAT::tdual_x_array &x, const typename DAT::tdual_xfloat_2d &buf, - const typename DAT::tdual_int_2d &list, - const int & iswap, + const typename DAT::tdual_int_1d &list, const X_FLOAT &xprd, const X_FLOAT &yprd, const X_FLOAT &zprd, const X_FLOAT &xy, const X_FLOAT &xz, const X_FLOAT &yz, const int* const pbc): - _x(x.view()),_list(list.view()),_iswap(iswap), + _x(x.view()),_list(list.view()), _xprd(xprd),_yprd(yprd),_zprd(zprd), _xy(xy),_xz(xz),_yz(yz) { const size_t maxsend = (buf.view().extent(0)*buf.view().extent(1))/3; @@ -81,7 +78,7 @@ struct AtomVecKokkos_PackComm { KOKKOS_INLINE_FUNCTION void operator() (const int& i) const { - const int j = _list(_iswap,i); + const int j = _list(i); if (PBC_FLAG == 0) { _buf(i,0) = _x(j,0); _buf(i,1) = _x(j,1); @@ -103,8 +100,7 @@ struct AtomVecKokkos_PackComm { /* ---------------------------------------------------------------------- */ int AtomVecKokkos::pack_comm_kokkos(const int &n, - const DAT::tdual_int_2d &list, - const int & iswap, + const DAT::tdual_int_1d &list, const DAT::tdual_xfloat_2d &buf, const int &pbc_flag, const int* const pbc) @@ -112,28 +108,28 @@ int AtomVecKokkos::pack_comm_kokkos(const int &n, // Check whether to always run forward communication on the host // Choose correct forward PackComm kernel - if (commKK->forward_comm_on_host) { + if (lmp->kokkos->forward_comm_on_host) { atomKK->sync(Host,X_MASK); if (pbc_flag) { if (domain->triclinic) { - struct AtomVecKokkos_PackComm f(atomKK->k_x,buf,list,iswap, + struct AtomVecKokkos_PackComm f(atomKK->k_x,buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); } else { - struct AtomVecKokkos_PackComm f(atomKK->k_x,buf,list,iswap, + struct AtomVecKokkos_PackComm f(atomKK->k_x,buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); } } else { if (domain->triclinic) { - struct AtomVecKokkos_PackComm f(atomKK->k_x,buf,list,iswap, + struct AtomVecKokkos_PackComm f(atomKK->k_x,buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); } else { - struct AtomVecKokkos_PackComm f(atomKK->k_x,buf,list,iswap, + struct AtomVecKokkos_PackComm f(atomKK->k_x,buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); @@ -143,24 +139,24 @@ int AtomVecKokkos::pack_comm_kokkos(const int &n, atomKK->sync(Device,X_MASK); if (pbc_flag) { if (domain->triclinic) { - struct AtomVecKokkos_PackComm f(atomKK->k_x,buf,list,iswap, + struct AtomVecKokkos_PackComm f(atomKK->k_x,buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); } else { - struct AtomVecKokkos_PackComm f(atomKK->k_x,buf,list,iswap, + struct AtomVecKokkos_PackComm f(atomKK->k_x,buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); } } else { if (domain->triclinic) { - struct AtomVecKokkos_PackComm f(atomKK->k_x,buf,list,iswap, + struct AtomVecKokkos_PackComm f(atomKK->k_x,buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); } else { - struct AtomVecKokkos_PackComm f(atomKK->k_x,buf,list,iswap, + struct AtomVecKokkos_PackComm f(atomKK->k_x,buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); @@ -168,7 +164,7 @@ int AtomVecKokkos::pack_comm_kokkos(const int &n, } } - return n*size_forward; + return n*size_forward; } /* ---------------------------------------------------------------------- */ @@ -180,19 +176,17 @@ struct AtomVecKokkos_PackCommSelf { typename ArrayTypes::t_x_array_randomread _x; typename ArrayTypes::t_x_array _xw; int _nfirst; - typename ArrayTypes::t_int_2d_const _list; - const int _iswap; + typename ArrayTypes::t_int_1d_const _list; X_FLOAT _xprd,_yprd,_zprd,_xy,_xz,_yz; X_FLOAT _pbc[6]; AtomVecKokkos_PackCommSelf( const typename DAT::tdual_x_array &x, const int &nfirst, - const typename DAT::tdual_int_2d &list, - const int & iswap, + const typename DAT::tdual_int_1d &list, const X_FLOAT &xprd, const X_FLOAT &yprd, const X_FLOAT &zprd, const X_FLOAT &xy, const X_FLOAT &xz, const X_FLOAT &yz, const int* const pbc): - _x(x.view()),_xw(x.view()),_nfirst(nfirst),_list(list.view()),_iswap(iswap), + _x(x.view()),_xw(x.view()),_nfirst(nfirst),_list(list.view()), _xprd(xprd),_yprd(yprd),_zprd(zprd), _xy(xy),_xz(xz),_yz(yz) { _pbc[0] = pbc[0]; _pbc[1] = pbc[1]; _pbc[2] = pbc[2]; @@ -201,7 +195,7 @@ struct AtomVecKokkos_PackCommSelf { KOKKOS_INLINE_FUNCTION void operator() (const int& i) const { - const int j = _list(_iswap,i); + const int j = _list(i); if (PBC_FLAG == 0) { _xw(i+_nfirst,0) = _x(j,0); _xw(i+_nfirst,1) = _x(j,1); @@ -223,66 +217,67 @@ struct AtomVecKokkos_PackCommSelf { /* ---------------------------------------------------------------------- */ -int AtomVecKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d &list, const int & iswap, +int AtomVecKokkos::pack_comm_self(const int &n, const DAT::tdual_int_1d &list, const int nfirst, const int &pbc_flag, const int* const pbc) { - if (commKK->forward_comm_on_host) { + if (lmp->kokkos->forward_comm_on_host) { atomKK->sync(Host,X_MASK); - atomKK->modified(Host,X_MASK); if (pbc_flag) { if (domain->triclinic) { - struct AtomVecKokkos_PackCommSelf f(atomKK->k_x,nfirst,list,iswap, + struct AtomVecKokkos_PackCommSelf f(atomKK->k_x,nfirst,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); + Kokkos::parallel_for(n,f); } else { - struct AtomVecKokkos_PackCommSelf f(atomKK->k_x,nfirst,list,iswap, + struct AtomVecKokkos_PackCommSelf f(atomKK->k_x,nfirst,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); + Kokkos::parallel_for(n,f); } } else { if (domain->triclinic) { - struct AtomVecKokkos_PackCommSelf f(atomKK->k_x,nfirst,list,iswap, + struct AtomVecKokkos_PackCommSelf f(atomKK->k_x,nfirst,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); + Kokkos::parallel_for(n,f); } else { - struct AtomVecKokkos_PackCommSelf f(atomKK->k_x,nfirst,list,iswap, + struct AtomVecKokkos_PackCommSelf f(atomKK->k_x,nfirst,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); + Kokkos::parallel_for(n,f); } } + atomKK->modified(Host,X_MASK); } else { atomKK->sync(Device,X_MASK); - atomKK->modified(Device,X_MASK); if (pbc_flag) { if (domain->triclinic) { - struct AtomVecKokkos_PackCommSelf f(atomKK->k_x,nfirst,list,iswap, + struct AtomVecKokkos_PackCommSelf f(atomKK->k_x,nfirst,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); + Kokkos::parallel_for(n,f); } else { - struct AtomVecKokkos_PackCommSelf f(atomKK->k_x,nfirst,list,iswap, + struct AtomVecKokkos_PackCommSelf f(atomKK->k_x,nfirst,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); + Kokkos::parallel_for(n,f); } } else { if (domain->triclinic) { - struct AtomVecKokkos_PackCommSelf f(atomKK->k_x,nfirst,list,iswap, + struct AtomVecKokkos_PackCommSelf f(atomKK->k_x,nfirst,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); + Kokkos::parallel_for(n,f); } else { - struct AtomVecKokkos_PackCommSelf f(atomKK->k_x,nfirst,list,iswap, + struct AtomVecKokkos_PackCommSelf f(atomKK->k_x,nfirst,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); + Kokkos::parallel_for(n,f); } } + atomKK->modified(Device,X_MASK); } - return n*3; + + return n*3; } @@ -361,35 +356,36 @@ struct AtomVecKokkos_PackCommSelfFused { int AtomVecKokkos::pack_comm_self_fused(const int &n, const DAT::tdual_int_2d &list, const DAT::tdual_int_1d &sendnum_scan, const DAT::tdual_int_1d &firstrecv, const DAT::tdual_int_1d &pbc_flag, const DAT::tdual_int_2d &pbc, const DAT::tdual_int_1d &g2l) { - if (commKK->forward_comm_on_host) { + if (lmp->kokkos->forward_comm_on_host) { atomKK->sync(Host,X_MASK); - atomKK->modified(Host,X_MASK); if (domain->triclinic) { - struct AtomVecKokkos_PackCommSelfFused f(atomKK->k_x,list,pbc,pbc_flag,firstrecv,sendnum_scan,g2l, + struct AtomVecKokkos_PackCommSelfFused f(atomKK->k_x,list,pbc,pbc_flag,firstrecv,sendnum_scan,g2l, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz); - Kokkos::parallel_for(n,f); + Kokkos::parallel_for(n,f); } else { - struct AtomVecKokkos_PackCommSelfFused f(atomKK->k_x,list,pbc,pbc_flag,firstrecv,sendnum_scan,g2l, + struct AtomVecKokkos_PackCommSelfFused f(atomKK->k_x,list,pbc,pbc_flag,firstrecv,sendnum_scan,g2l, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz); - Kokkos::parallel_for(n,f); + Kokkos::parallel_for(n,f); } + atomKK->modified(Host,X_MASK); } else { atomKK->sync(Device,X_MASK); - atomKK->modified(Device,X_MASK); if (domain->triclinic) { - struct AtomVecKokkos_PackCommSelfFused f(atomKK->k_x,list,pbc,pbc_flag,firstrecv,sendnum_scan,g2l, + struct AtomVecKokkos_PackCommSelfFused f(atomKK->k_x,list,pbc,pbc_flag,firstrecv,sendnum_scan,g2l, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz); - Kokkos::parallel_for(n,f); + Kokkos::parallel_for(n,f); } else { - struct AtomVecKokkos_PackCommSelfFused f(atomKK->k_x,list,pbc,pbc_flag,firstrecv,sendnum_scan,g2l, + struct AtomVecKokkos_PackCommSelfFused f(atomKK->k_x,list,pbc,pbc_flag,firstrecv,sendnum_scan,g2l, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz); - Kokkos::parallel_for(n,f); + Kokkos::parallel_for(n,f); } + atomKK->modified(Device,X_MASK); } + return n*3; } @@ -421,20 +417,19 @@ struct AtomVecKokkos_UnpackComm { void AtomVecKokkos::unpack_comm_kokkos(const int &n, const int &first, const DAT::tdual_xfloat_2d &buf) { - if (commKK->forward_comm_on_host) { + if (lmp->kokkos->forward_comm_on_host) { atomKK->sync(Host,X_MASK); - atomKK->modified(Host,X_MASK); struct AtomVecKokkos_UnpackComm f(atomKK->k_x,buf,first); Kokkos::parallel_for(n,f); + atomKK->modified(Host,X_MASK); } else { atomKK->sync(Device,X_MASK); - atomKK->modified(Device,X_MASK); struct AtomVecKokkos_UnpackComm f(atomKK->k_x,buf,first); Kokkos::parallel_for(n,f); + atomKK->modified(Device,X_MASK); } } - /* ---------------------------------------------------------------------- */ template @@ -445,8 +440,7 @@ struct AtomVecKokkos_PackCommVel { typename ArrayTypes::t_int_1d _mask; typename ArrayTypes::t_v_array _v; typename ArrayTypes::t_xfloat_2d_um _buf; - typename ArrayTypes::t_int_2d_const _list; - const int _iswap; + typename ArrayTypes::t_int_1d_const _list; X_FLOAT _xprd,_yprd,_zprd,_xy,_xz,_yz; X_FLOAT _pbc[6]; X_FLOAT _h_rate[6]; @@ -457,8 +451,7 @@ struct AtomVecKokkos_PackCommVel { const typename DAT::tdual_int_1d &mask, const typename DAT::tdual_v_array &v, const typename DAT::tdual_xfloat_2d &buf, - const typename DAT::tdual_int_2d &list, - const int &iswap, + const typename DAT::tdual_int_1d &list, const X_FLOAT &xprd, const X_FLOAT &yprd, const X_FLOAT &zprd, const X_FLOAT &xy, const X_FLOAT &xz, const X_FLOAT &yz, const int* const pbc, const double * const h_rate, @@ -466,7 +459,7 @@ struct AtomVecKokkos_PackCommVel { _x(x.view()), _mask(mask.view()), _v(v.view()), - _list(list.view()),_iswap(iswap), + _list(list.view()), _xprd(xprd),_yprd(yprd),_zprd(zprd), _xy(xy),_xz(xz),_yz(yz), _deform_vremap(deform_vremap) @@ -482,7 +475,7 @@ struct AtomVecKokkos_PackCommVel { KOKKOS_INLINE_FUNCTION void operator() (const int& i) const { - const int j = _list(_iswap,i); + const int j = _list(i); if (PBC_FLAG == 0) { _buf(i,0) = _x(j,0); _buf(i,1) = _x(j,1); @@ -524,13 +517,12 @@ struct AtomVecKokkos_PackCommVel { int AtomVecKokkos::pack_comm_vel_kokkos( const int &n, - const DAT::tdual_int_2d &list, - const int & iswap, + const DAT::tdual_int_1d &list, const DAT::tdual_xfloat_2d &buf, const int &pbc_flag, const int* const pbc) { - if (commKK->forward_comm_on_host) { + if (lmp->kokkos->forward_comm_on_host) { atomKK->sync(Host,X_MASK|V_MASK); if (pbc_flag) { if (deform_vremap) { @@ -538,7 +530,7 @@ int AtomVecKokkos::pack_comm_vel_kokkos( struct AtomVecKokkos_PackCommVel f( atomKK->k_x,atomKK->k_mask, atomKK->k_v, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc,h_rate,deform_vremap); Kokkos::parallel_for(n,f); @@ -546,7 +538,7 @@ int AtomVecKokkos::pack_comm_vel_kokkos( struct AtomVecKokkos_PackCommVel f( atomKK->k_x,atomKK->k_mask, atomKK->k_v, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc,h_rate,deform_vremap); Kokkos::parallel_for(n,f); @@ -556,7 +548,7 @@ int AtomVecKokkos::pack_comm_vel_kokkos( struct AtomVecKokkos_PackCommVel f( atomKK->k_x,atomKK->k_mask, atomKK->k_v, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc,h_rate,deform_vremap); Kokkos::parallel_for(n,f); @@ -564,7 +556,7 @@ int AtomVecKokkos::pack_comm_vel_kokkos( struct AtomVecKokkos_PackCommVel f( atomKK->k_x,atomKK->k_mask, atomKK->k_v, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc,h_rate,deform_vremap); Kokkos::parallel_for(n,f); @@ -575,7 +567,7 @@ int AtomVecKokkos::pack_comm_vel_kokkos( struct AtomVecKokkos_PackCommVel f( atomKK->k_x,atomKK->k_mask, atomKK->k_v, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc,h_rate,deform_vremap); Kokkos::parallel_for(n,f); @@ -583,7 +575,7 @@ int AtomVecKokkos::pack_comm_vel_kokkos( struct AtomVecKokkos_PackCommVel f( atomKK->k_x,atomKK->k_mask, atomKK->k_v, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc,h_rate,deform_vremap); Kokkos::parallel_for(n,f); @@ -597,7 +589,7 @@ int AtomVecKokkos::pack_comm_vel_kokkos( struct AtomVecKokkos_PackCommVel f( atomKK->k_x,atomKK->k_mask, atomKK->k_v, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc,h_rate,deform_vremap); Kokkos::parallel_for(n,f); @@ -605,7 +597,7 @@ int AtomVecKokkos::pack_comm_vel_kokkos( struct AtomVecKokkos_PackCommVel f( atomKK->k_x,atomKK->k_mask, atomKK->k_v, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc,h_rate,deform_vremap); Kokkos::parallel_for(n,f); @@ -615,7 +607,7 @@ int AtomVecKokkos::pack_comm_vel_kokkos( struct AtomVecKokkos_PackCommVel f( atomKK->k_x,atomKK->k_mask, atomKK->k_v, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc,h_rate,deform_vremap); Kokkos::parallel_for(n,f); @@ -623,7 +615,7 @@ int AtomVecKokkos::pack_comm_vel_kokkos( struct AtomVecKokkos_PackCommVel f( atomKK->k_x,atomKK->k_mask, atomKK->k_v, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc,h_rate,deform_vremap); Kokkos::parallel_for(n,f); @@ -634,7 +626,7 @@ int AtomVecKokkos::pack_comm_vel_kokkos( struct AtomVecKokkos_PackCommVel f( atomKK->k_x,atomKK->k_mask, atomKK->k_v, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc,h_rate,deform_vremap); Kokkos::parallel_for(n,f); @@ -642,13 +634,14 @@ int AtomVecKokkos::pack_comm_vel_kokkos( struct AtomVecKokkos_PackCommVel f( atomKK->k_x,atomKK->k_mask, atomKK->k_v, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc,h_rate,deform_vremap); Kokkos::parallel_for(n,f); } } } + return n*6; } @@ -692,16 +685,16 @@ struct AtomVecKokkos_UnpackCommVel { void AtomVecKokkos::unpack_comm_vel_kokkos(const int &n, const int &first, const DAT::tdual_xfloat_2d &buf) { - if (commKK->forward_comm_on_host) { + if (lmp->kokkos->forward_comm_on_host) { atomKK->sync(Host,X_MASK|V_MASK); - atomKK->modified(Host,X_MASK|V_MASK); struct AtomVecKokkos_UnpackCommVel f(atomKK->k_x,atomKK->k_v,buf,first); Kokkos::parallel_for(n,f); + atomKK->modified(Host,X_MASK|V_MASK); } else { atomKK->sync(Device,X_MASK|V_MASK); - atomKK->modified(Device,X_MASK|V_MASK); struct AtomVecKokkos_UnpackCommVel f(atomKK->k_x,atomKK->k_v,buf,first); Kokkos::parallel_for(n,f); + atomKK->modified(Device,X_MASK|V_MASK); } } @@ -733,7 +726,7 @@ struct AtomVecKokkos_PackReverse { int AtomVecKokkos::pack_reverse_kokkos(const int &n, const int &first, const DAT::tdual_ffloat_2d &buf) { - if (commKK->reverse_comm_on_host) { + if (lmp->kokkos->reverse_comm_on_host) { atomKK->sync(Host,F_MASK); struct AtomVecKokkos_PackReverse f(atomKK->k_f,buf,first); Kokkos::parallel_for(n,f); @@ -755,20 +748,18 @@ struct AtomVecKokkos_UnPackReverseSelf { typename ArrayTypes::t_f_array_randomread _f; typename ArrayTypes::t_f_array _fw; int _nfirst; - typename ArrayTypes::t_int_2d_const _list; - const int _iswap; + typename ArrayTypes::t_int_1d_const _list; AtomVecKokkos_UnPackReverseSelf( const typename DAT::tdual_f_array &f, const int &nfirst, - const typename DAT::tdual_int_2d &list, - const int & iswap): - _f(f.view()),_fw(f.view()),_nfirst(nfirst),_list(list.view()),_iswap(iswap) { + const typename DAT::tdual_int_1d &list): + _f(f.view()),_fw(f.view()),_nfirst(nfirst),_list(list.view()) { }; KOKKOS_INLINE_FUNCTION void operator() (const int& i) const { - const int j = _list(_iswap,i); + const int j = _list(i); _fw(j,0) += _f(i+_nfirst,0); _fw(j,1) += _f(i+_nfirst,1); _fw(j,2) += _f(i+_nfirst,2); @@ -777,19 +768,20 @@ struct AtomVecKokkos_UnPackReverseSelf { /* ---------------------------------------------------------------------- */ -int AtomVecKokkos::unpack_reverse_self(const int &n, const DAT::tdual_int_2d &list, const int & iswap, - const int nfirst) { - if (commKK->reverse_comm_on_host) { +int AtomVecKokkos::pack_reverse_self(const int &n, const DAT::tdual_int_1d &list, + const int nfirst) { + if (lmp->kokkos->reverse_comm_on_host) { atomKK->sync(Host,F_MASK); - struct AtomVecKokkos_UnPackReverseSelf f(atomKK->k_f,nfirst,list,iswap); + struct AtomVecKokkos_UnPackReverseSelf f(atomKK->k_f,nfirst,list); Kokkos::parallel_for(n,f); atomKK->modified(Host,F_MASK); } else { atomKK->sync(Device,F_MASK); - struct AtomVecKokkos_UnPackReverseSelf f(atomKK->k_f,nfirst,list,iswap); + struct AtomVecKokkos_UnPackReverseSelf f(atomKK->k_f,nfirst,list); Kokkos::parallel_for(n,f); atomKK->modified(Device,F_MASK); } + return n*3; } @@ -801,15 +793,13 @@ struct AtomVecKokkos_UnPackReverse { typename ArrayTypes::t_f_array _f; typename ArrayTypes::t_ffloat_2d_const _buf; - typename ArrayTypes::t_int_2d_const _list; - const int _iswap; + typename ArrayTypes::t_int_1d_const _list; AtomVecKokkos_UnPackReverse( const typename DAT::tdual_f_array &f, const typename DAT::tdual_ffloat_2d &buf, - const typename DAT::tdual_int_2d &list, - const int & iswap): - _f(f.view()),_list(list.view()),_iswap(iswap) { + const typename DAT::tdual_int_1d &list): + _f(f.view()),_list(list.view()) { const size_t maxsend = (buf.view().extent(0)*buf.view().extent(1))/3; const size_t elements = 3; buffer_view(_buf,buf,maxsend,elements); @@ -817,7 +807,7 @@ struct AtomVecKokkos_UnPackReverse { KOKKOS_INLINE_FUNCTION void operator() (const int& i) const { - const int j = _list(_iswap,i); + const int j = _list(i); _f(j,0) += _buf(i,0); _f(j,1) += _buf(i,1); _f(j,2) += _buf(i,2); @@ -827,19 +817,18 @@ struct AtomVecKokkos_UnPackReverse { /* ---------------------------------------------------------------------- */ void AtomVecKokkos::unpack_reverse_kokkos(const int &n, - const DAT::tdual_int_2d &list, - const int & iswap, + const DAT::tdual_int_1d &list, const DAT::tdual_ffloat_2d &buf) { // Check whether to always run reverse communication on the host // Choose correct reverse UnPackReverse kernel - if (commKK->reverse_comm_on_host) { - struct AtomVecKokkos_UnPackReverse f(atomKK->k_f,buf,list,iswap); + if (lmp->kokkos->reverse_comm_on_host) { + struct AtomVecKokkos_UnPackReverse f(atomKK->k_f,buf,list); Kokkos::parallel_for(n,f); atomKK->modified(Host,F_MASK); } else { - struct AtomVecKokkos_UnPackReverse f(atomKK->k_f,buf,list,iswap); + struct AtomVecKokkos_UnPackReverse f(atomKK->k_f,buf,list); Kokkos::parallel_for(n,f); atomKK->modified(Device,F_MASK); } diff --git a/src/KOKKOS/atom_vec_kokkos.h b/src/KOKKOS/atom_vec_kokkos.h index c10ff5b40a..646d9a4840 100644 --- a/src/KOKKOS/atom_vec_kokkos.h +++ b/src/KOKKOS/atom_vec_kokkos.h @@ -50,8 +50,8 @@ class AtomVecKokkos : virtual public AtomVec { virtual void sync_overlapping_device(ExecutionSpace space, unsigned int mask) = 0; virtual int - pack_comm_self(const int &n, const DAT::tdual_int_2d &list, - const int & iswap, const int nfirst, + pack_comm_self(const int &n, const DAT::tdual_int_1d &list, + const int nfirst, const int &pbc_flag, const int pbc[]); virtual int @@ -63,8 +63,8 @@ class AtomVecKokkos : virtual public AtomVec { const DAT::tdual_int_1d &g2l); virtual int - pack_comm_kokkos(const int &n, const DAT::tdual_int_2d &list, - const int & iswap, const DAT::tdual_xfloat_2d &buf, + pack_comm_kokkos(const int &n, const DAT::tdual_int_1d &list, + const DAT::tdual_xfloat_2d &buf, const int &pbc_flag, const int pbc[]); virtual void @@ -72,8 +72,8 @@ class AtomVecKokkos : virtual public AtomVec { const DAT::tdual_xfloat_2d &buf); virtual int - pack_comm_vel_kokkos(const int &n, const DAT::tdual_int_2d &list, - const int & iswap, const DAT::tdual_xfloat_2d &buf, + pack_comm_vel_kokkos(const int &n, const DAT::tdual_int_1d &list, + const DAT::tdual_xfloat_2d &buf, const int &pbc_flag, const int pbc[]); virtual void @@ -81,20 +81,20 @@ class AtomVecKokkos : virtual public AtomVec { const DAT::tdual_xfloat_2d &buf); virtual int - unpack_reverse_self(const int &n, const DAT::tdual_int_2d &list, - const int & iswap, const int nfirst); + pack_reverse_self(const int &n, const DAT::tdual_int_1d &list, + const int nfirst); virtual int pack_reverse_kokkos(const int &n, const int &nfirst, const DAT::tdual_ffloat_2d &buf); virtual void - unpack_reverse_kokkos(const int &n, const DAT::tdual_int_2d &list, - const int & iswap, const DAT::tdual_ffloat_2d &buf); + unpack_reverse_kokkos(const int &n, const DAT::tdual_int_1d &list, + const DAT::tdual_ffloat_2d &buf); virtual int - pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, - DAT::tdual_xfloat_2d buf,int iswap, + pack_border_kokkos(int n, DAT::tdual_int_1d k_sendlist, + DAT::tdual_xfloat_2d buf, int pbc_flag, int *pbc, ExecutionSpace space) = 0; virtual void @@ -103,8 +103,8 @@ class AtomVecKokkos : virtual public AtomVec { ExecutionSpace space) = 0; virtual int - pack_border_vel_kokkos(int /*n*/, DAT::tdual_int_2d /*k_sendlist*/, - DAT::tdual_xfloat_2d /*buf*/,int /*iswap*/, + pack_border_vel_kokkos(int /*n*/, DAT::tdual_int_1d /*k_sendlist*/, + DAT::tdual_xfloat_2d /*buf*/, int /*pbc_flag*/, int * /*pbc*/, ExecutionSpace /*space*/) { return 0; } virtual void @@ -133,7 +133,6 @@ class AtomVecKokkos : virtual public AtomVec { HAT::t_v_array h_v; HAT::t_f_array h_f; - class CommKokkos *commKK; size_t buffer_size; void* buffer; diff --git a/src/KOKKOS/atom_vec_molecular_kokkos.cpp b/src/KOKKOS/atom_vec_molecular_kokkos.cpp index ec98ff9239..68369e2fad 100644 --- a/src/KOKKOS/atom_vec_molecular_kokkos.cpp +++ b/src/KOKKOS/atom_vec_molecular_kokkos.cpp @@ -260,295 +260,13 @@ void AtomVecMolecularKokkos::sort_kokkos(Kokkos::BinSort &So /* ---------------------------------------------------------------------- */ -template -struct AtomVecMolecularKokkos_PackComm { - typedef DeviceType device_type; - - typename ArrayTypes::t_x_array_randomread _x; - typename ArrayTypes::t_xfloat_2d_um _buf; - typename ArrayTypes::t_int_2d_const _list; - const int _iswap; - X_FLOAT _xprd,_yprd,_zprd,_xy,_xz,_yz; - X_FLOAT _pbc[6]; - - AtomVecMolecularKokkos_PackComm( - const typename DAT::tdual_x_array &x, - const typename DAT::tdual_xfloat_2d &buf, - const typename DAT::tdual_int_2d &list, - const int & iswap, - const X_FLOAT &xprd, const X_FLOAT &yprd, const X_FLOAT &zprd, - const X_FLOAT &xy, const X_FLOAT &xz, const X_FLOAT &yz, const int* const pbc): - _x(x.view()),_list(list.view()),_iswap(iswap), - _xprd(xprd),_yprd(yprd),_zprd(zprd), - _xy(xy),_xz(xz),_yz(yz) { - const size_t maxsend = (buf.view().extent(0) - *buf.view().extent(1))/3; - const size_t elements = 3; - buffer_view(_buf,buf,maxsend,elements); - _pbc[0] = pbc[0]; _pbc[1] = pbc[1]; _pbc[2] = pbc[2]; - _pbc[3] = pbc[3]; _pbc[4] = pbc[4]; _pbc[5] = pbc[5]; - }; - - KOKKOS_INLINE_FUNCTION - void operator() (const int& i) const { - const int j = _list(_iswap,i); - if (PBC_FLAG == 0) { - _buf(i,0) = _x(j,0); - _buf(i,1) = _x(j,1); - _buf(i,2) = _x(j,2); - } else { - if (TRICLINIC == 0) { - _buf(i,0) = _x(j,0) + _pbc[0]*_xprd; - _buf(i,1) = _x(j,1) + _pbc[1]*_yprd; - _buf(i,2) = _x(j,2) + _pbc[2]*_zprd; - } else { - _buf(i,0) = _x(j,0) + _pbc[0]*_xprd + _pbc[5]*_xy + _pbc[4]*_xz; - _buf(i,1) = _x(j,1) + _pbc[1]*_yprd + _pbc[3]*_yz; - _buf(i,2) = _x(j,2) + _pbc[2]*_zprd; - } - } - } -}; - -/* ---------------------------------------------------------------------- */ - -int AtomVecMolecularKokkos::pack_comm_kokkos(const int &n, - const DAT::tdual_int_2d &list, - const int & iswap, - const DAT::tdual_xfloat_2d &buf, - const int &pbc_flag, - const int* const pbc) -{ - // Check whether to always run forward communication on the host - // Choose correct forward PackComm kernel - - if (commKK->forward_comm_on_host) { - atomKK->sync(Host,X_MASK); - if (pbc_flag) { - if (domain->triclinic) { - struct AtomVecMolecularKokkos_PackComm - f(atomKK->k_x,buf,list,iswap,domain->xprd,domain->yprd,domain->zprd, - domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); - } else { - struct AtomVecMolecularKokkos_PackComm - f(atomKK->k_x,buf,list,iswap,domain->xprd,domain->yprd,domain->zprd, - domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); - } - } else { - if (domain->triclinic) { - struct AtomVecMolecularKokkos_PackComm - f(atomKK->k_x,buf,list,iswap,domain->xprd,domain->yprd,domain->zprd, - domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); - } else { - struct AtomVecMolecularKokkos_PackComm - f(atomKK->k_x,buf,list,iswap,domain->xprd,domain->yprd,domain->zprd, - domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); - } - } - } else { - atomKK->sync(Device,X_MASK); - if (pbc_flag) { - if (domain->triclinic) { - struct AtomVecMolecularKokkos_PackComm - f(atomKK->k_x,buf,list,iswap,domain->xprd,domain->yprd,domain->zprd, - domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); - } else { - struct AtomVecMolecularKokkos_PackComm - f(atomKK->k_x,buf,list,iswap,domain->xprd,domain->yprd,domain->zprd, - domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); - } - } else { - if (domain->triclinic) { - struct AtomVecMolecularKokkos_PackComm - f(atomKK->k_x,buf,list,iswap,domain->xprd,domain->yprd,domain->zprd, - domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); - } else { - struct AtomVecMolecularKokkos_PackComm - f(atomKK->k_x,buf,list,iswap,domain->xprd,domain->yprd,domain->zprd, - domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); - } - } - } - - return n*size_forward; -} - -/* ---------------------------------------------------------------------- */ - -template -struct AtomVecMolecularKokkos_PackCommSelf { - typedef DeviceType device_type; - - typename ArrayTypes::t_x_array_randomread _x; - typename ArrayTypes::t_x_array _xw; - int _nfirst; - typename ArrayTypes::t_int_2d_const _list; - const int _iswap; - X_FLOAT _xprd,_yprd,_zprd,_xy,_xz,_yz; - X_FLOAT _pbc[6]; - - AtomVecMolecularKokkos_PackCommSelf( - const typename DAT::tdual_x_array &x, - const int &nfirst, - const typename DAT::tdual_int_2d &list, - const int & iswap, - const X_FLOAT &xprd, const X_FLOAT &yprd, const X_FLOAT &zprd, - const X_FLOAT &xy, const X_FLOAT &xz, const X_FLOAT &yz, const int* const pbc): - _x(x.view()),_xw(x.view()),_nfirst(nfirst), - _list(list.view()),_iswap(iswap), - _xprd(xprd),_yprd(yprd),_zprd(zprd), - _xy(xy),_xz(xz),_yz(yz) { - _pbc[0] = pbc[0]; _pbc[1] = pbc[1]; _pbc[2] = pbc[2]; - _pbc[3] = pbc[3]; _pbc[4] = pbc[4]; _pbc[5] = pbc[5]; - }; - - KOKKOS_INLINE_FUNCTION - void operator() (const int& i) const { - const int j = _list(_iswap,i); - if (PBC_FLAG == 0) { - _xw(i+_nfirst,0) = _x(j,0); - _xw(i+_nfirst,1) = _x(j,1); - _xw(i+_nfirst,2) = _x(j,2); - } else { - if (TRICLINIC == 0) { - _xw(i+_nfirst,0) = _x(j,0) + _pbc[0]*_xprd; - _xw(i+_nfirst,1) = _x(j,1) + _pbc[1]*_yprd; - _xw(i+_nfirst,2) = _x(j,2) + _pbc[2]*_zprd; - } else { - _xw(i+_nfirst,0) = _x(j,0) + _pbc[0]*_xprd + _pbc[5]*_xy + _pbc[4]*_xz; - _xw(i+_nfirst,1) = _x(j,1) + _pbc[1]*_yprd + _pbc[3]*_yz; - _xw(i+_nfirst,2) = _x(j,2) + _pbc[2]*_zprd; - } - } - - } -}; - -/* ---------------------------------------------------------------------- */ - -int AtomVecMolecularKokkos::pack_comm_self(const int &n, const DAT::tdual_int_2d &list, - const int & iswap, - const int nfirst, const int &pbc_flag, - const int* const pbc) { - if (commKK->forward_comm_on_host) { - atomKK->sync(Host,X_MASK); - atomKK->modified(Host,X_MASK); - if (pbc_flag) { - if (domain->triclinic) { - struct AtomVecMolecularKokkos_PackCommSelf - f(atomKK->k_x,nfirst,list,iswap,domain->xprd,domain->yprd,domain->zprd, - domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); - } else { - struct AtomVecMolecularKokkos_PackCommSelf - f(atomKK->k_x,nfirst,list,iswap,domain->xprd,domain->yprd,domain->zprd, - domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); - } - } else { - if (domain->triclinic) { - struct AtomVecMolecularKokkos_PackCommSelf - f(atomKK->k_x,nfirst,list,iswap,domain->xprd,domain->yprd,domain->zprd, - domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); - } else { - struct AtomVecMolecularKokkos_PackCommSelf - f(atomKK->k_x,nfirst,list,iswap,domain->xprd,domain->yprd,domain->zprd, - domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); - } - } - } else { - atomKK->sync(Device,X_MASK); - atomKK->modified(Device,X_MASK); - if (pbc_flag) { - if (domain->triclinic) { - struct AtomVecMolecularKokkos_PackCommSelf - f(atomKK->k_x,nfirst,list,iswap,domain->xprd,domain->yprd,domain->zprd, - domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); - } else { - struct AtomVecMolecularKokkos_PackCommSelf - f(atomKK->k_x,nfirst,list,iswap,domain->xprd,domain->yprd,domain->zprd, - domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); - } - } else { - if (domain->triclinic) { - struct AtomVecMolecularKokkos_PackCommSelf - f(atomKK->k_x,nfirst,list,iswap,domain->xprd,domain->yprd,domain->zprd, - domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); - } else { - struct AtomVecMolecularKokkos_PackCommSelf - f(atomKK->k_x,nfirst,list,iswap,domain->xprd,domain->yprd,domain->zprd, - domain->xy,domain->xz,domain->yz,pbc); - Kokkos::parallel_for(n,f); - } - } - } - return n*3; -} - -/* ---------------------------------------------------------------------- */ - -template -struct AtomVecMolecularKokkos_UnpackComm { - typedef DeviceType device_type; - - typename ArrayTypes::t_x_array _x; - typename ArrayTypes::t_xfloat_2d_const _buf; - int _first; - - AtomVecMolecularKokkos_UnpackComm( - const typename DAT::tdual_x_array &x, - const typename DAT::tdual_xfloat_2d &buf, - const int& first):_x(x.view()),_buf(buf.view()), - _first(first) {}; - - KOKKOS_INLINE_FUNCTION - void operator() (const int& i) const { - _x(i+_first,0) = _buf(i,0); - _x(i+_first,1) = _buf(i,1); - _x(i+_first,2) = _buf(i,2); - } -}; - -/* ---------------------------------------------------------------------- */ - -void AtomVecMolecularKokkos::unpack_comm_kokkos(const int &n, const int &first, - const DAT::tdual_xfloat_2d &buf) { - if (commKK->forward_comm_on_host) { - atomKK->sync(Host,X_MASK); - atomKK->modified(Host,X_MASK); - struct AtomVecMolecularKokkos_UnpackComm f(atomKK->k_x,buf,first); - Kokkos::parallel_for(n,f); - } else { - atomKK->sync(Device,X_MASK); - atomKK->modified(Device,X_MASK); - struct AtomVecMolecularKokkos_UnpackComm f(atomKK->k_x,buf,first); - Kokkos::parallel_for(n,f); - } -} - -/* ---------------------------------------------------------------------- */ - template struct AtomVecMolecularKokkos_PackBorder { typedef DeviceType device_type; typedef ArrayTypes AT; typename AT::t_xfloat_2d _buf; - const typename AT::t_int_2d_const _list; - const int _iswap; + const typename AT::t_int_1d_const _list; const typename AT::t_x_array_randomread _x; const typename AT::t_tagint_1d _tag; const typename AT::t_int_1d _type; @@ -558,21 +276,20 @@ struct AtomVecMolecularKokkos_PackBorder { AtomVecMolecularKokkos_PackBorder( const typename AT::t_xfloat_2d &buf, - const typename AT::t_int_2d_const &list, - const int & iswap, + const typename AT::t_int_1d_const &list, const typename AT::t_x_array &x, const typename AT::t_tagint_1d &tag, const typename AT::t_int_1d &type, const typename AT::t_int_1d &mask, const typename AT::t_tagint_1d &molecule, const X_FLOAT &dx, const X_FLOAT &dy, const X_FLOAT &dz): - _buf(buf),_list(list),_iswap(iswap), + _buf(buf),_list(list), _x(x),_tag(tag),_type(type),_mask(mask),_molecule(molecule), _dx(dx),_dy(dy),_dz(dz) {} KOKKOS_INLINE_FUNCTION void operator() (const int& i) const { - const int j = _list(_iswap,i); + const int j = _list(i); if (PBC_FLAG == 0) { _buf(i,0) = _x(j,0); _buf(i,1) = _x(j,1); @@ -595,8 +312,8 @@ struct AtomVecMolecularKokkos_PackBorder { /* ---------------------------------------------------------------------- */ -int AtomVecMolecularKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, - DAT::tdual_xfloat_2d buf,int iswap, +int AtomVecMolecularKokkos::pack_border_kokkos(int n, DAT::tdual_int_1d k_sendlist, + DAT::tdual_xfloat_2d buf, int pbc_flag, int *pbc, ExecutionSpace space) { X_FLOAT dx,dy,dz; @@ -614,12 +331,12 @@ int AtomVecMolecularKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendli if (space==Host) { AtomVecMolecularKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,h_x,h_tag,h_type,h_mask,h_molecule,dx,dy,dz); + h_x,h_tag,h_type,h_mask,h_molecule,dx,dy,dz); Kokkos::parallel_for(n,f); } else { AtomVecMolecularKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,d_x,d_tag,d_type,d_mask,d_molecule,dx,dy,dz); + d_x,d_tag,d_type,d_mask,d_molecule,dx,dy,dz); Kokkos::parallel_for(n,f); } @@ -628,12 +345,12 @@ int AtomVecMolecularKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendli if (space==Host) { AtomVecMolecularKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,h_x,h_tag,h_type,h_mask,h_molecule,dx,dy,dz); + h_x,h_tag,h_type,h_mask,h_molecule,dx,dy,dz); Kokkos::parallel_for(n,f); } else { AtomVecMolecularKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,d_x,d_tag,d_type,d_mask,d_molecule,dx,dy,dz); + d_x,d_tag,d_type,d_mask,d_molecule,dx,dy,dz); Kokkos::parallel_for(n,f); } } diff --git a/src/KOKKOS/atom_vec_molecular_kokkos.h b/src/KOKKOS/atom_vec_molecular_kokkos.h index eb976e9073..a92784fbd9 100644 --- a/src/KOKKOS/atom_vec_molecular_kokkos.h +++ b/src/KOKKOS/atom_vec_molecular_kokkos.h @@ -35,17 +35,8 @@ class AtomVecMolecularKokkos : public AtomVecKokkos, public AtomVecMolecular { void grow(int) override; void grow_pointers() override; void sort_kokkos(Kokkos::BinSort &Sorter) override; - int pack_comm_kokkos(const int &n, const DAT::tdual_int_2d &k_sendlist, - const int & iswap, - const DAT::tdual_xfloat_2d &buf, - const int &pbc_flag, const int pbc[]) override; - void unpack_comm_kokkos(const int &n, const int &nfirst, - const DAT::tdual_xfloat_2d &buf) override; - int pack_comm_self(const int &n, const DAT::tdual_int_2d &list, - const int & iswap, const int nfirst, - const int &pbc_flag, const int pbc[]) override; - int pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, - DAT::tdual_xfloat_2d buf,int iswap, + int pack_border_kokkos(int n, DAT::tdual_int_1d k_sendlist, + DAT::tdual_xfloat_2d buf, int pbc_flag, int *pbc, ExecutionSpace space) override; void unpack_border_kokkos(const int &n, const int &nfirst, const DAT::tdual_xfloat_2d &buf, diff --git a/src/KOKKOS/atom_vec_sphere_kokkos.cpp b/src/KOKKOS/atom_vec_sphere_kokkos.cpp index 3dfb5143cd..8802275e31 100644 --- a/src/KOKKOS/atom_vec_sphere_kokkos.cpp +++ b/src/KOKKOS/atom_vec_sphere_kokkos.cpp @@ -20,13 +20,11 @@ #include "domain.h" #include "error.h" #include "fix.h" +#include "kokkos.h" #include "math_const.h" -#include "memory.h" #include "memory_kokkos.h" #include "modify.h" -#include - using namespace LAMMPS_NS; using namespace MathConst; @@ -152,8 +150,7 @@ struct AtomVecSphereKokkos_PackComm { typename ArrayTypes::t_x_array_randomread _x; typename ArrayTypes::t_float_1d _radius,_rmass; typename ArrayTypes::t_xfloat_2d_um _buf; - typename ArrayTypes::t_int_2d_const _list; - const int _iswap; + typename ArrayTypes::t_int_1d_const _list; X_FLOAT _xprd,_yprd,_zprd,_xy,_xz,_yz; X_FLOAT _pbc[6]; @@ -162,14 +159,13 @@ struct AtomVecSphereKokkos_PackComm { const typename DAT::tdual_float_1d &radius, const typename DAT::tdual_float_1d &rmass, const typename DAT::tdual_xfloat_2d &buf, - const typename DAT::tdual_int_2d &list, - const int & iswap, + const typename DAT::tdual_int_1d &list, const X_FLOAT &xprd, const X_FLOAT &yprd, const X_FLOAT &zprd, const X_FLOAT &xy, const X_FLOAT &xz, const X_FLOAT &yz, const int* const pbc): _x(x.view()), _radius(radius.view()), _rmass(rmass.view()), - _list(list.view()),_iswap(iswap), + _list(list.view()), _xprd(xprd),_yprd(yprd),_zprd(zprd), _xy(xy),_xz(xz),_yz(yz) { const size_t elements = 5; @@ -181,7 +177,7 @@ struct AtomVecSphereKokkos_PackComm { KOKKOS_INLINE_FUNCTION void operator() (const int& i) const { - const int j = _list(_iswap,i); + const int j = _list(i); if (PBC_FLAG == 0) { _buf(i,0) = _x(j,0); _buf(i,1) = _x(j,1); @@ -206,25 +202,24 @@ struct AtomVecSphereKokkos_PackComm { int AtomVecSphereKokkos::pack_comm_kokkos( const int &n, - const DAT::tdual_int_2d &list, - const int & iswap, + const DAT::tdual_int_1d &list, const DAT::tdual_xfloat_2d &buf, const int &pbc_flag, const int* const pbc) { // Fallback to AtomVecKokkos if radvary == 0 if (radvary == 0) - return AtomVecKokkos::pack_comm_kokkos(n,list,iswap,buf,pbc_flag,pbc); + return AtomVecKokkos::pack_comm_kokkos(n,list,buf,pbc_flag,pbc); // Check whether to always run forward communication on the host // Choose correct forward PackComm kernel - if (commKK->forward_comm_on_host) { + if (lmp->kokkos->forward_comm_on_host) { atomKK->sync(Host,X_MASK|RADIUS_MASK|RMASS_MASK); if (pbc_flag) { if (domain->triclinic) { struct AtomVecSphereKokkos_PackComm f( atomKK->k_x, atomKK->k_radius,atomKK->k_rmass, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); @@ -232,7 +227,7 @@ int AtomVecSphereKokkos::pack_comm_kokkos( struct AtomVecSphereKokkos_PackComm f( atomKK->k_x, atomKK->k_radius,atomKK->k_rmass, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); @@ -242,7 +237,7 @@ int AtomVecSphereKokkos::pack_comm_kokkos( struct AtomVecSphereKokkos_PackComm f( atomKK->k_x, atomKK->k_radius,atomKK->k_rmass, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); @@ -250,7 +245,7 @@ int AtomVecSphereKokkos::pack_comm_kokkos( struct AtomVecSphereKokkos_PackComm f( atomKK->k_x, atomKK->k_radius,atomKK->k_rmass, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); @@ -263,7 +258,7 @@ int AtomVecSphereKokkos::pack_comm_kokkos( struct AtomVecSphereKokkos_PackComm f( atomKK->k_x, atomKK->k_radius,atomKK->k_rmass, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); @@ -271,7 +266,7 @@ int AtomVecSphereKokkos::pack_comm_kokkos( struct AtomVecSphereKokkos_PackComm f( atomKK->k_x, atomKK->k_radius,atomKK->k_rmass, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); @@ -281,7 +276,7 @@ int AtomVecSphereKokkos::pack_comm_kokkos( struct AtomVecSphereKokkos_PackComm f( atomKK->k_x, atomKK->k_radius,atomKK->k_rmass, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); @@ -289,7 +284,7 @@ int AtomVecSphereKokkos::pack_comm_kokkos( struct AtomVecSphereKokkos_PackComm f( atomKK->k_x, atomKK->k_radius,atomKK->k_rmass, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); @@ -310,8 +305,7 @@ struct AtomVecSphereKokkos_PackCommVel { typename ArrayTypes::t_float_1d _radius,_rmass; typename ArrayTypes::t_v_array _v, _omega; typename ArrayTypes::t_xfloat_2d_um _buf; - typename ArrayTypes::t_int_2d_const _list; - const int _iswap; + typename ArrayTypes::t_int_1d_const _list; X_FLOAT _xprd,_yprd,_zprd,_xy,_xz,_yz; X_FLOAT _pbc[6]; X_FLOAT _h_rate[6]; @@ -325,8 +319,7 @@ struct AtomVecSphereKokkos_PackCommVel { const typename DAT::tdual_v_array &v, const typename DAT::tdual_v_array &omega, const typename DAT::tdual_xfloat_2d &buf, - const typename DAT::tdual_int_2d &list, - const int &iswap, + const typename DAT::tdual_int_1d &list, const X_FLOAT &xprd, const X_FLOAT &yprd, const X_FLOAT &zprd, const X_FLOAT &xy, const X_FLOAT &xz, const X_FLOAT &yz, const int* const pbc, const double * const h_rate, @@ -337,7 +330,7 @@ struct AtomVecSphereKokkos_PackCommVel { _rmass(rmass.view()), _v(v.view()), _omega(omega.view()), - _list(list.view()),_iswap(iswap), + _list(list.view()), _xprd(xprd),_yprd(yprd),_zprd(zprd), _xy(xy),_xz(xz),_yz(yz), _deform_vremap(deform_vremap) @@ -353,7 +346,7 @@ struct AtomVecSphereKokkos_PackCommVel { KOKKOS_INLINE_FUNCTION void operator() (const int& i) const { - const int j = _list(_iswap,i); + const int j = _list(i); if (PBC_FLAG == 0) { _buf(i,0) = _x(j,0); _buf(i,1) = _x(j,1); @@ -398,13 +391,12 @@ struct AtomVecSphereKokkos_PackCommVel { int AtomVecSphereKokkos::pack_comm_vel_kokkos( const int &n, - const DAT::tdual_int_2d &list, - const int & iswap, + const DAT::tdual_int_1d &list, const DAT::tdual_xfloat_2d &buf, const int &pbc_flag, const int* const pbc) { - if (commKK->forward_comm_on_host) { + if (lmp->kokkos->forward_comm_on_host) { atomKK->sync(Host,X_MASK|RADIUS_MASK|RMASS_MASK|V_MASK|OMEGA_MASK); if (pbc_flag) { if (deform_vremap) { @@ -414,7 +406,7 @@ int AtomVecSphereKokkos::pack_comm_vel_kokkos( atomKK->k_x,atomKK->k_mask, atomKK->k_radius,atomKK->k_rmass, atomKK->k_v,atomKK->k_omega, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc,h_rate,deform_vremap); Kokkos::parallel_for(n,f); @@ -423,7 +415,7 @@ int AtomVecSphereKokkos::pack_comm_vel_kokkos( atomKK->k_x,atomKK->k_mask, atomKK->k_radius,atomKK->k_rmass, atomKK->k_v,atomKK->k_omega, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc,h_rate,deform_vremap); Kokkos::parallel_for(n,f); @@ -434,7 +426,7 @@ int AtomVecSphereKokkos::pack_comm_vel_kokkos( atomKK->k_x,atomKK->k_mask, atomKK->k_radius,atomKK->k_rmass, atomKK->k_v,atomKK->k_omega, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc,h_rate,deform_vremap); Kokkos::parallel_for(n,f); @@ -443,7 +435,7 @@ int AtomVecSphereKokkos::pack_comm_vel_kokkos( atomKK->k_x,atomKK->k_mask, atomKK->k_radius,atomKK->k_rmass, atomKK->k_v,atomKK->k_omega, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc,h_rate,deform_vremap); Kokkos::parallel_for(n,f); @@ -456,7 +448,7 @@ int AtomVecSphereKokkos::pack_comm_vel_kokkos( atomKK->k_x,atomKK->k_mask, atomKK->k_radius,atomKK->k_rmass, atomKK->k_v,atomKK->k_omega, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc,h_rate,deform_vremap); Kokkos::parallel_for(n,f); @@ -465,7 +457,7 @@ int AtomVecSphereKokkos::pack_comm_vel_kokkos( atomKK->k_x,atomKK->k_mask, atomKK->k_radius,atomKK->k_rmass, atomKK->k_v,atomKK->k_omega, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc,h_rate,deform_vremap); Kokkos::parallel_for(n,f); @@ -476,7 +468,7 @@ int AtomVecSphereKokkos::pack_comm_vel_kokkos( atomKK->k_x,atomKK->k_mask, atomKK->k_radius,atomKK->k_rmass, atomKK->k_v,atomKK->k_omega, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc,h_rate,deform_vremap); Kokkos::parallel_for(n,f); @@ -485,7 +477,7 @@ int AtomVecSphereKokkos::pack_comm_vel_kokkos( atomKK->k_x,atomKK->k_mask, atomKK->k_radius,atomKK->k_rmass, atomKK->k_v,atomKK->k_omega, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc,h_rate,deform_vremap); Kokkos::parallel_for(n,f); @@ -499,7 +491,7 @@ int AtomVecSphereKokkos::pack_comm_vel_kokkos( atomKK->k_x,atomKK->k_mask, atomKK->k_radius,atomKK->k_rmass, atomKK->k_v,atomKK->k_omega, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc,h_rate,deform_vremap); Kokkos::parallel_for(n,f); @@ -508,7 +500,7 @@ int AtomVecSphereKokkos::pack_comm_vel_kokkos( atomKK->k_x,atomKK->k_mask, atomKK->k_radius,atomKK->k_rmass, atomKK->k_v,atomKK->k_omega, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc,h_rate,deform_vremap); Kokkos::parallel_for(n,f); @@ -519,7 +511,7 @@ int AtomVecSphereKokkos::pack_comm_vel_kokkos( atomKK->k_x,atomKK->k_mask, atomKK->k_radius,atomKK->k_rmass, atomKK->k_v,atomKK->k_omega, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc,h_rate,deform_vremap); Kokkos::parallel_for(n,f); @@ -528,7 +520,7 @@ int AtomVecSphereKokkos::pack_comm_vel_kokkos( atomKK->k_x,atomKK->k_mask, atomKK->k_radius,atomKK->k_rmass, atomKK->k_v,atomKK->k_omega, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc,h_rate,deform_vremap); Kokkos::parallel_for(n,f); @@ -545,7 +537,7 @@ int AtomVecSphereKokkos::pack_comm_vel_kokkos( atomKK->k_x,atomKK->k_mask, atomKK->k_radius,atomKK->k_rmass, atomKK->k_v,atomKK->k_omega, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc,h_rate,deform_vremap); Kokkos::parallel_for(n,f); @@ -554,7 +546,7 @@ int AtomVecSphereKokkos::pack_comm_vel_kokkos( atomKK->k_x,atomKK->k_mask, atomKK->k_radius,atomKK->k_rmass, atomKK->k_v,atomKK->k_omega, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc,h_rate,deform_vremap); Kokkos::parallel_for(n,f); @@ -565,7 +557,7 @@ int AtomVecSphereKokkos::pack_comm_vel_kokkos( atomKK->k_x,atomKK->k_mask, atomKK->k_radius,atomKK->k_rmass, atomKK->k_v,atomKK->k_omega, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc,h_rate,deform_vremap); Kokkos::parallel_for(n,f); @@ -574,7 +566,7 @@ int AtomVecSphereKokkos::pack_comm_vel_kokkos( atomKK->k_x,atomKK->k_mask, atomKK->k_radius,atomKK->k_rmass, atomKK->k_v,atomKK->k_omega, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc,h_rate,deform_vremap); Kokkos::parallel_for(n,f); @@ -587,7 +579,7 @@ int AtomVecSphereKokkos::pack_comm_vel_kokkos( atomKK->k_x,atomKK->k_mask, atomKK->k_radius,atomKK->k_rmass, atomKK->k_v,atomKK->k_omega, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc,h_rate,deform_vremap); Kokkos::parallel_for(n,f); @@ -596,7 +588,7 @@ int AtomVecSphereKokkos::pack_comm_vel_kokkos( atomKK->k_x,atomKK->k_mask, atomKK->k_radius,atomKK->k_rmass, atomKK->k_v,atomKK->k_omega, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc,h_rate,deform_vremap); Kokkos::parallel_for(n,f); @@ -607,7 +599,7 @@ int AtomVecSphereKokkos::pack_comm_vel_kokkos( atomKK->k_x,atomKK->k_mask, atomKK->k_radius,atomKK->k_rmass, atomKK->k_v,atomKK->k_omega, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc,h_rate,deform_vremap); Kokkos::parallel_for(n,f); @@ -616,7 +608,7 @@ int AtomVecSphereKokkos::pack_comm_vel_kokkos( atomKK->k_x,atomKK->k_mask, atomKK->k_radius,atomKK->k_rmass, atomKK->k_v,atomKK->k_omega, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc,h_rate,deform_vremap); Kokkos::parallel_for(n,f); @@ -630,7 +622,7 @@ int AtomVecSphereKokkos::pack_comm_vel_kokkos( atomKK->k_x,atomKK->k_mask, atomKK->k_radius,atomKK->k_rmass, atomKK->k_v,atomKK->k_omega, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc,h_rate,deform_vremap); Kokkos::parallel_for(n,f); @@ -639,7 +631,7 @@ int AtomVecSphereKokkos::pack_comm_vel_kokkos( atomKK->k_x,atomKK->k_mask, atomKK->k_radius,atomKK->k_rmass, atomKK->k_v,atomKK->k_omega, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc,h_rate,deform_vremap); Kokkos::parallel_for(n,f); @@ -650,7 +642,7 @@ int AtomVecSphereKokkos::pack_comm_vel_kokkos( atomKK->k_x,atomKK->k_mask, atomKK->k_radius,atomKK->k_rmass, atomKK->k_v,atomKK->k_omega, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc,h_rate,deform_vremap); Kokkos::parallel_for(n,f); @@ -659,7 +651,7 @@ int AtomVecSphereKokkos::pack_comm_vel_kokkos( atomKK->k_x,atomKK->k_mask, atomKK->k_radius,atomKK->k_rmass, atomKK->k_v,atomKK->k_omega, - buf,list,iswap, + buf,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc,h_rate,deform_vremap); Kokkos::parallel_for(n,f); @@ -680,8 +672,7 @@ struct AtomVecSphereKokkos_PackCommSelf { typename ArrayTypes::t_x_array _xw; typename ArrayTypes::t_float_1d _radius,_rmass; int _nfirst; - typename ArrayTypes::t_int_2d_const _list; - const int _iswap; + typename ArrayTypes::t_int_1d_const _list; X_FLOAT _xprd,_yprd,_zprd,_xy,_xz,_yz; X_FLOAT _pbc[6]; @@ -690,14 +681,13 @@ struct AtomVecSphereKokkos_PackCommSelf { const typename DAT::tdual_float_1d &radius, const typename DAT::tdual_float_1d &rmass, const int &nfirst, - const typename DAT::tdual_int_2d &list, - const int & iswap, + const typename DAT::tdual_int_1d &list, const X_FLOAT &xprd, const X_FLOAT &yprd, const X_FLOAT &zprd, const X_FLOAT &xy, const X_FLOAT &xz, const X_FLOAT &yz, const int* const pbc): _x(x.view()),_xw(x.view()), _radius(radius.view()), _rmass(rmass.view()), - _nfirst(nfirst),_list(list.view()),_iswap(iswap), + _nfirst(nfirst),_list(list.view()), _xprd(xprd),_yprd(yprd),_zprd(zprd), _xy(xy),_xz(xz),_yz(yz) { _pbc[0] = pbc[0]; _pbc[1] = pbc[1]; _pbc[2] = pbc[2]; @@ -706,7 +696,7 @@ struct AtomVecSphereKokkos_PackCommSelf { KOKKOS_INLINE_FUNCTION void operator() (const int& i) const { - const int j = _list(_iswap,i); + const int j = _list(i); if (PBC_FLAG == 0) { _xw(i+_nfirst,0) = _x(j,0); _xw(i+_nfirst,1) = _x(j,1); @@ -730,12 +720,12 @@ struct AtomVecSphereKokkos_PackCommSelf { /* ---------------------------------------------------------------------- */ int AtomVecSphereKokkos::pack_comm_self( - const int &n, const DAT::tdual_int_2d &list, const int &iswap, + const int &n, const DAT::tdual_int_1d &list, const int nfirst, const int &pbc_flag, const int* const pbc) { // Fallback to AtomVecKokkos if radvary == 0 if (radvary == 0) - return AtomVecKokkos::pack_comm_self(n,list,iswap,nfirst,pbc_flag,pbc); - if (commKK->forward_comm_on_host) { + return AtomVecKokkos::pack_comm_self(n,list,nfirst,pbc_flag,pbc); + if (lmp->kokkos->forward_comm_on_host) { atomKK->sync(Host,X_MASK|RADIUS_MASK|RMASS_MASK); atomKK->modified(Host,X_MASK|RADIUS_MASK|RMASS_MASK); if (pbc_flag) { @@ -743,7 +733,7 @@ int AtomVecSphereKokkos::pack_comm_self( struct AtomVecSphereKokkos_PackCommSelf f( atomKK->k_x, atomKK->k_radius,atomKK->k_rmass, - nfirst,list,iswap, + nfirst,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); @@ -751,7 +741,7 @@ int AtomVecSphereKokkos::pack_comm_self( struct AtomVecSphereKokkos_PackCommSelf f( atomKK->k_x, atomKK->k_radius,atomKK->k_rmass, - nfirst,list,iswap, + nfirst,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); @@ -761,7 +751,7 @@ int AtomVecSphereKokkos::pack_comm_self( struct AtomVecSphereKokkos_PackCommSelf f( atomKK->k_x, atomKK->k_radius,atomKK->k_rmass, - nfirst,list,iswap, + nfirst,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); @@ -769,7 +759,7 @@ int AtomVecSphereKokkos::pack_comm_self( struct AtomVecSphereKokkos_PackCommSelf f( atomKK->k_x, atomKK->k_radius,atomKK->k_rmass, - nfirst,list,iswap, + nfirst,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); @@ -783,7 +773,7 @@ int AtomVecSphereKokkos::pack_comm_self( struct AtomVecSphereKokkos_PackCommSelf f( atomKK->k_x, atomKK->k_radius,atomKK->k_rmass, - nfirst,list,iswap, + nfirst,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); @@ -791,7 +781,7 @@ int AtomVecSphereKokkos::pack_comm_self( struct AtomVecSphereKokkos_PackCommSelf f( atomKK->k_x, atomKK->k_radius,atomKK->k_rmass, - nfirst,list,iswap, + nfirst,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); @@ -801,7 +791,7 @@ int AtomVecSphereKokkos::pack_comm_self( struct AtomVecSphereKokkos_PackCommSelf f( atomKK->k_x, atomKK->k_radius,atomKK->k_rmass, - nfirst,list,iswap, + nfirst,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); @@ -809,7 +799,7 @@ int AtomVecSphereKokkos::pack_comm_self( struct AtomVecSphereKokkos_PackCommSelf f( atomKK->k_x, atomKK->k_radius,atomKK->k_rmass, - nfirst,list,iswap, + nfirst,list, domain->xprd,domain->yprd,domain->zprd, domain->xy,domain->xz,domain->yz,pbc); Kokkos::parallel_for(n,f); @@ -866,7 +856,7 @@ void AtomVecSphereKokkos::unpack_comm_kokkos( AtomVecKokkos::unpack_comm_kokkos(n,first,buf); return; } - if (commKK->forward_comm_on_host) { + if (lmp->kokkos->forward_comm_on_host) { atomKK->modified(Host,X_MASK|RADIUS_MASK|RMASS_MASK); struct AtomVecSphereKokkos_UnpackComm f( atomKK->k_x, @@ -938,7 +928,7 @@ struct AtomVecSphereKokkos_UnpackCommVel { void AtomVecSphereKokkos::unpack_comm_vel_kokkos( const int &n, const int &first, const DAT::tdual_xfloat_2d &buf) { - if (commKK->forward_comm_on_host) { + if (lmp->kokkos->forward_comm_on_host) { atomKK->modified(Host,X_MASK|RADIUS_MASK|RMASS_MASK|V_MASK|OMEGA_MASK); if (radvary == 0) { struct AtomVecSphereKokkos_UnpackCommVel f( @@ -982,8 +972,7 @@ struct AtomVecSphereKokkos_PackBorder { typedef DeviceType device_type; typename ArrayTypes::t_xfloat_2d_um _buf; - const typename ArrayTypes::t_int_2d_const _list; - const int _iswap; + const typename ArrayTypes::t_int_1d_const _list; const typename ArrayTypes::t_x_array_randomread _x; const typename ArrayTypes::t_tagint_1d _tag; const typename ArrayTypes::t_int_1d _type; @@ -993,8 +982,7 @@ struct AtomVecSphereKokkos_PackBorder { AtomVecSphereKokkos_PackBorder( const typename ArrayTypes::t_xfloat_2d &buf, - const typename ArrayTypes::t_int_2d_const &list, - const int &iswap, + const typename ArrayTypes::t_int_1d_const &list, const typename ArrayTypes::t_x_array &x, const typename ArrayTypes::t_tagint_1d &tag, const typename ArrayTypes::t_int_1d &type, @@ -1002,7 +990,7 @@ struct AtomVecSphereKokkos_PackBorder { const typename ArrayTypes::t_float_1d &radius, const typename ArrayTypes::t_float_1d &rmass, const X_FLOAT &dx, const X_FLOAT &dy, const X_FLOAT &dz): - _list(list),_iswap(iswap), + _buf(buf),_list(list), _x(x),_tag(tag),_type(type),_mask(mask), _radius(radius), _rmass(rmass), @@ -1015,7 +1003,7 @@ struct AtomVecSphereKokkos_PackBorder { KOKKOS_INLINE_FUNCTION void operator() (const int& i) const { - const int j = _list(_iswap,i); + const int j = _list(i); if (PBC_FLAG == 0) { _buf(i,0) = _x(j,0); _buf(i,1) = _x(j,1); @@ -1036,7 +1024,7 @@ struct AtomVecSphereKokkos_PackBorder { /* ---------------------------------------------------------------------- */ int AtomVecSphereKokkos::pack_border_kokkos( - int n, DAT::tdual_int_2d k_sendlist, DAT::tdual_xfloat_2d buf,int iswap, + int n, DAT::tdual_int_1d k_sendlist, DAT::tdual_xfloat_2d buf, int pbc_flag, int *pbc, ExecutionSpace space) { X_FLOAT dx,dy,dz; @@ -1057,14 +1045,14 @@ int AtomVecSphereKokkos::pack_border_kokkos( if (space==Host) { AtomVecSphereKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,h_x,h_tag,h_type,h_mask, + h_x,h_tag,h_type,h_mask, h_radius,h_rmass, dx,dy,dz); Kokkos::parallel_for(n,f); } else { AtomVecSphereKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,d_x,d_tag,d_type,d_mask, + d_x,d_tag,d_type,d_mask, d_radius,d_rmass, dx,dy,dz); Kokkos::parallel_for(n,f); @@ -1074,14 +1062,14 @@ int AtomVecSphereKokkos::pack_border_kokkos( if (space==Host) { AtomVecSphereKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,h_x,h_tag,h_type,h_mask, + h_x,h_tag,h_type,h_mask, h_radius,h_rmass, dx,dy,dz); Kokkos::parallel_for(n,f); } else { AtomVecSphereKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,d_x,d_tag,d_type,d_mask, + d_x,d_tag,d_type,d_mask, d_radius,d_rmass, dx,dy,dz); Kokkos::parallel_for(n,f); @@ -1097,8 +1085,7 @@ struct AtomVecSphereKokkos_PackBorderVel { typedef DeviceType device_type; typename ArrayTypes::t_xfloat_2d_um _buf; - const typename ArrayTypes::t_int_2d_const _list; - const int _iswap; + const typename ArrayTypes::t_int_1d_const _list; const typename ArrayTypes::t_x_array_randomread _x; const typename ArrayTypes::t_tagint_1d _tag; const typename ArrayTypes::t_int_1d _type; @@ -1110,8 +1097,7 @@ struct AtomVecSphereKokkos_PackBorderVel { AtomVecSphereKokkos_PackBorderVel( const typename ArrayTypes::t_xfloat_2d &buf, - const typename ArrayTypes::t_int_2d_const &list, - const int &iswap, + const typename ArrayTypes::t_int_1d_const &list, const typename ArrayTypes::t_x_array &x, const typename ArrayTypes::t_tagint_1d &tag, const typename ArrayTypes::t_int_1d &type, @@ -1123,7 +1109,7 @@ struct AtomVecSphereKokkos_PackBorderVel { const X_FLOAT &dx, const X_FLOAT &dy, const X_FLOAT &dz, const X_FLOAT &dvx, const X_FLOAT &dvy, const X_FLOAT &dvz, const int &deform_groupbit): - _buf(buf),_list(list),_iswap(iswap), + _buf(buf),_list(list), _x(x),_tag(tag),_type(type),_mask(mask), _radius(radius), _rmass(rmass), @@ -1139,7 +1125,7 @@ struct AtomVecSphereKokkos_PackBorderVel { KOKKOS_INLINE_FUNCTION void operator() (const int& i) const { - const int j = _list(_iswap,i); + const int j = _list(i); if (PBC_FLAG == 0) { _buf(i,0) = _x(j,0); _buf(i,1) = _x(j,1); @@ -1175,7 +1161,7 @@ struct AtomVecSphereKokkos_PackBorderVel { /* ---------------------------------------------------------------------- */ int AtomVecSphereKokkos::pack_border_vel_kokkos( - int n, DAT::tdual_int_2d k_sendlist, DAT::tdual_xfloat_2d buf,int iswap, + int n, DAT::tdual_int_1d k_sendlist, DAT::tdual_xfloat_2d buf, int pbc_flag, int *pbc, ExecutionSpace space) { X_FLOAT dx=0,dy=0,dz=0; @@ -1198,7 +1184,7 @@ int AtomVecSphereKokkos::pack_border_vel_kokkos( if (space==Host) { AtomVecSphereKokkos_PackBorderVel f( buf.view(), k_sendlist.view(), - iswap,h_x,h_tag,h_type,h_mask, + h_x,h_tag,h_type,h_mask, h_radius,h_rmass, h_v, h_omega, dx,dy,dz,dvx,dvy,dvz, @@ -1207,7 +1193,7 @@ int AtomVecSphereKokkos::pack_border_vel_kokkos( } else { AtomVecSphereKokkos_PackBorderVel f( buf.view(), k_sendlist.view(), - iswap,d_x,d_tag,d_type,d_mask, + d_x,d_tag,d_type,d_mask, d_radius,d_rmass, d_v, d_omega, dx,dy,dz,dvx,dvy,dvz, @@ -1222,7 +1208,7 @@ int AtomVecSphereKokkos::pack_border_vel_kokkos( if (space==Host) { AtomVecSphereKokkos_PackBorderVel f( buf.view(), k_sendlist.view(), - iswap,h_x,h_tag,h_type,h_mask, + h_x,h_tag,h_type,h_mask, h_radius,h_rmass, h_v, h_omega, dx,dy,dz,dvx,dvy,dvz, @@ -1231,7 +1217,7 @@ int AtomVecSphereKokkos::pack_border_vel_kokkos( } else { AtomVecSphereKokkos_PackBorderVel f( buf.view(), k_sendlist.view(), - iswap,d_x,d_tag,d_type,d_mask, + d_x,d_tag,d_type,d_mask, d_radius,d_rmass, d_v, d_omega, dx,dy,dz,dvx,dvy,dvz, @@ -1243,7 +1229,7 @@ int AtomVecSphereKokkos::pack_border_vel_kokkos( if (space==Host) { AtomVecSphereKokkos_PackBorderVel f( buf.view(), k_sendlist.view(), - iswap,h_x,h_tag,h_type,h_mask, + h_x,h_tag,h_type,h_mask, h_radius,h_rmass, h_v, h_omega, dx,dy,dz,dvx,dvy,dvz, @@ -1252,7 +1238,7 @@ int AtomVecSphereKokkos::pack_border_vel_kokkos( } else { AtomVecSphereKokkos_PackBorderVel f( buf.view(), k_sendlist.view(), - iswap,d_x,d_tag,d_type,d_mask, + d_x,d_tag,d_type,d_mask, d_radius,d_rmass, d_v, d_omega, dx,dy,dz,dvx,dvy,dvz, diff --git a/src/KOKKOS/atom_vec_sphere_kokkos.h b/src/KOKKOS/atom_vec_sphere_kokkos.h index 34529320d9..b28da45c6a 100644 --- a/src/KOKKOS/atom_vec_sphere_kokkos.h +++ b/src/KOKKOS/atom_vec_sphere_kokkos.h @@ -37,29 +37,27 @@ class AtomVecSphereKokkos : public AtomVecKokkos, public AtomVecSphere { void grow_pointers() override; void sort_kokkos(Kokkos::BinSort &Sorter) override; - int pack_comm_kokkos(const int &n, const DAT::tdual_int_2d &k_sendlist, - const int & iswap, + int pack_comm_kokkos(const int &n, const DAT::tdual_int_1d &k_sendlist, const DAT::tdual_xfloat_2d &buf, const int &pbc_flag, const int pbc[]) override; void unpack_comm_kokkos(const int &n, const int &nfirst, const DAT::tdual_xfloat_2d &buf) override; - int pack_comm_vel_kokkos(const int &n, const DAT::tdual_int_2d &k_sendlist, - const int & iswap, + int pack_comm_vel_kokkos(const int &n, const DAT::tdual_int_1d &k_sendlist, const DAT::tdual_xfloat_2d &buf, const int &pbc_flag, const int pbc[]) override; void unpack_comm_vel_kokkos(const int &n, const int &nfirst, const DAT::tdual_xfloat_2d &buf) override; - int pack_comm_self(const int &n, const DAT::tdual_int_2d &list, - const int & iswap, const int nfirst, + int pack_comm_self(const int &n, const DAT::tdual_int_1d &list, + const int nfirst, const int &pbc_flag, const int pbc[]) override; - int pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, - DAT::tdual_xfloat_2d buf,int iswap, + int pack_border_kokkos(int n, DAT::tdual_int_1d k_sendlist, + DAT::tdual_xfloat_2d buf, int pbc_flag, int *pbc, ExecutionSpace space) override; void unpack_border_kokkos(const int &n, const int &nfirst, const DAT::tdual_xfloat_2d &buf, ExecutionSpace space) override; - int pack_border_vel_kokkos(int n, DAT::tdual_int_2d k_sendlist, - DAT::tdual_xfloat_2d buf,int iswap, + int pack_border_vel_kokkos(int n, DAT::tdual_int_1d k_sendlist, + DAT::tdual_xfloat_2d buf, int pbc_flag, int *pbc, ExecutionSpace space) override; void unpack_border_vel_kokkos(const int &n, const int &nfirst, const DAT::tdual_xfloat_2d &buf, diff --git a/src/KOKKOS/atom_vec_spin_kokkos.cpp b/src/KOKKOS/atom_vec_spin_kokkos.cpp index 72d38a731e..7cd0b8934c 100644 --- a/src/KOKKOS/atom_vec_spin_kokkos.cpp +++ b/src/KOKKOS/atom_vec_spin_kokkos.cpp @@ -26,7 +26,6 @@ #include "atom_kokkos.h" #include "atom_masks.h" -#include "comm_kokkos.h" #include "domain.h" #include "error.h" #include "fix.h" @@ -35,7 +34,7 @@ using namespace LAMMPS_NS; -#define DELTA 10 +static constexpr int DELTA = 10; /* ---------------------------------------------------------------------- */ @@ -157,8 +156,7 @@ struct AtomVecSpinKokkos_PackComm { typename ArrayTypes::t_x_array_randomread _x; typename ArrayTypes::t_sp_array_randomread _sp; typename ArrayTypes::t_xfloat_2d_um _buf; - typename ArrayTypes::t_int_2d_const _list; - const int _iswap; + typename ArrayTypes::t_int_1d_const _list; X_FLOAT _xprd,_yprd,_zprd,_xy,_xz,_yz; X_FLOAT _pbc[6]; @@ -166,12 +164,11 @@ struct AtomVecSpinKokkos_PackComm { const typename DAT::tdual_x_array &x, const typename DAT::tdual_float_1d_4 &sp, const typename DAT::tdual_xfloat_2d &buf, - const typename DAT::tdual_int_2d &list, - const int & iswap, + const typename DAT::tdual_int_1d &list, const X_FLOAT &xprd, const X_FLOAT &yprd, const X_FLOAT &zprd, const X_FLOAT &xy, const X_FLOAT &xz, const X_FLOAT &yz, const int* const pbc): _x(x.view()),_sp(sp.view()), - _list(list.view()),_iswap(iswap), + _list(list.view()), _xprd(xprd),_yprd(yprd),_zprd(zprd), _xy(xy),_xz(xz),_yz(yz) { const size_t maxsend = (buf.view().extent(0)*buf.view().extent(1))/3; @@ -183,7 +180,7 @@ struct AtomVecSpinKokkos_PackComm { KOKKOS_INLINE_FUNCTION void operator() (const int& i) const { - const int j = _list(_iswap,i); + const int j = _list(i); if (PBC_FLAG == 0) { _buf(i,0) = _x(j,0); _buf(i,1) = _x(j,1); @@ -221,8 +218,7 @@ struct AtomVecSpinKokkos_PackBorder { typedef DeviceType device_type; typename ArrayTypes::t_xfloat_2d _buf; - const typename ArrayTypes::t_int_2d_const _list; - const int _iswap; + const typename ArrayTypes::t_int_1d_const _list; const typename ArrayTypes::t_x_array_randomread _x; const typename ArrayTypes::t_tagint_1d _tag; const typename ArrayTypes::t_int_1d _type; @@ -232,21 +228,20 @@ struct AtomVecSpinKokkos_PackBorder { AtomVecSpinKokkos_PackBorder( const typename ArrayTypes::t_xfloat_2d &buf, - const typename ArrayTypes::t_int_2d_const &list, - const int & iswap, + const typename ArrayTypes::t_int_1d_const &list, const typename ArrayTypes::t_x_array &x, const typename ArrayTypes::t_tagint_1d &tag, const typename ArrayTypes::t_int_1d &type, const typename ArrayTypes::t_int_1d &mask, const typename ArrayTypes::t_sp_array &sp, const X_FLOAT &dx, const X_FLOAT &dy, const X_FLOAT &dz): - _buf(buf),_list(list),_iswap(iswap), + _buf(buf),_list(list), _x(x),_tag(tag),_type(type),_mask(mask),_sp(sp), _dx(dx),_dy(dy),_dz(dz) {} KOKKOS_INLINE_FUNCTION void operator() (const int& i) const { - const int j = _list(_iswap,i); + const int j = _list(i); if (PBC_FLAG == 0) { _buf(i,0) = _x(j,0); _buf(i,1) = _x(j,1); @@ -275,7 +270,7 @@ struct AtomVecSpinKokkos_PackBorder { /* ---------------------------------------------------------------------- */ -int AtomVecSpinKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, DAT::tdual_xfloat_2d buf,int iswap, +int AtomVecSpinKokkos::pack_border_kokkos(int n, DAT::tdual_int_1d k_sendlist, DAT::tdual_xfloat_2d buf, int pbc_flag, int *pbc, ExecutionSpace space) { X_FLOAT dx,dy,dz; @@ -293,12 +288,12 @@ int AtomVecSpinKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, D if(space==Host) { AtomVecSpinKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,h_x,h_tag,h_type,h_mask,h_sp,dx,dy,dz); + h_x,h_tag,h_type,h_mask,h_sp,dx,dy,dz); Kokkos::parallel_for(n,f); } else { AtomVecSpinKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,d_x,d_tag,d_type,d_mask,d_sp,dx,dy,dz); + d_x,d_tag,d_type,d_mask,d_sp,dx,dy,dz); Kokkos::parallel_for(n,f); } @@ -307,12 +302,12 @@ int AtomVecSpinKokkos::pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, D if(space==Host) { AtomVecSpinKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,h_x,h_tag,h_type,h_mask,h_sp,dx,dy,dz); + h_x,h_tag,h_type,h_mask,h_sp,dx,dy,dz); Kokkos::parallel_for(n,f); } else { AtomVecSpinKokkos_PackBorder f( buf.view(), k_sendlist.view(), - iswap,d_x,d_tag,d_type,d_mask,d_sp,dx,dy,dz); + d_x,d_tag,d_type,d_mask,d_sp,dx,dy,dz); Kokkos::parallel_for(n,f); } } diff --git a/src/KOKKOS/atom_vec_spin_kokkos.h b/src/KOKKOS/atom_vec_spin_kokkos.h index f0145e4db7..6f968dcd25 100644 --- a/src/KOKKOS/atom_vec_spin_kokkos.h +++ b/src/KOKKOS/atom_vec_spin_kokkos.h @@ -36,8 +36,8 @@ class AtomVecSpinKokkos : public AtomVecKokkos, public AtomVecSpin { void grow_pointers() override; void force_clear(int, size_t) override; void sort_kokkos(Kokkos::BinSort &Sorter) override; - int pack_border_kokkos(int n, DAT::tdual_int_2d k_sendlist, - DAT::tdual_xfloat_2d buf,int iswap, + int pack_border_kokkos(int n, DAT::tdual_int_1d k_sendlist, + DAT::tdual_xfloat_2d buf, int pbc_flag, int *pbc, ExecutionSpace space) override; void unpack_border_kokkos(const int &n, const int &nfirst, const DAT::tdual_xfloat_2d &buf, diff --git a/src/KOKKOS/comm_kokkos.cpp b/src/KOKKOS/comm_kokkos.cpp index 5d2a7795fe..2425857d61 100644 --- a/src/KOKKOS/comm_kokkos.cpp +++ b/src/KOKKOS/comm_kokkos.cpp @@ -36,9 +36,9 @@ using namespace LAMMPS_NS; -#define BUFFACTOR 1.5 -#define BUFMIN 10000 -#define BUFEXTRA 1000 +static constexpr double BUFFACTOR = 1.5; +static constexpr int BUFMIN = 10000; +static constexpr int BUFEXTRA = 1000; /* ---------------------------------------------------------------------- setup MPI and allocate buffer space @@ -142,11 +142,15 @@ void CommKokkos::init() if (force->newton == 0) check_reverse = 0; if (force->pair) check_reverse += force->pair->comm_reverse_off; - if (!comm_f_only) // not all Kokkos atom_vec styles have reverse pack/unpack routines yet + if (!comm_f_only) {// not all Kokkos atom_vec styles have reverse pack/unpack routines yet reverse_comm_classic = true; + lmp->kokkos->reverse_comm_classic = 1; + } - if (ghost_velocity && atomKK->avecKK->no_comm_vel_flag) // not all Kokkos atom_vec styles have comm vel pack/unpack routines yet + if (ghost_velocity && atomKK->avecKK->no_comm_vel_flag) { // not all Kokkos atom_vec styles have comm vel pack/unpack routines yet forward_comm_classic = true; + lmp->kokkos->forward_comm_classic = 1; + } } /* ---------------------------------------------------------------------- @@ -157,8 +161,8 @@ void CommKokkos::init() void CommKokkos::forward_comm(int dummy) { if (!forward_comm_classic) { - if (forward_comm_on_host) forward_comm_device(dummy); - else forward_comm_device(dummy); + if (forward_comm_on_host) forward_comm_device(); + else forward_comm_device(); return; } @@ -181,7 +185,7 @@ void CommKokkos::forward_comm(int dummy) /* ---------------------------------------------------------------------- */ template -void CommKokkos::forward_comm_device(int) +void CommKokkos::forward_comm_device() { int n; MPI_Request request; @@ -192,7 +196,6 @@ void CommKokkos::forward_comm_device(int) // if comm_x_only set, exchange or copy directly to x, don't unpack k_sendlist.sync(); - atomKK->sync(ExecutionSpaceFromDevice::space,X_MASK); if (comm->nprocs == 1 && !ghost_velocity) { k_swap.sync(); @@ -211,26 +214,26 @@ void CommKokkos::forward_comm_device(int) MPI_Irecv(buf,size_forward_recv[iswap],MPI_DOUBLE, recvproc[iswap],0,world,&request); } - n = atomKK->avecKK->pack_comm_kokkos(sendnum[iswap],k_sendlist, - iswap,k_buf_send,pbc_flag[iswap],pbc[iswap]); + auto k_sendlist_iswap = Kokkos::subview(k_sendlist,iswap,Kokkos::ALL); + n = atomKK->avecKK->pack_comm_kokkos(sendnum[iswap],k_sendlist_iswap, + k_buf_send,pbc_flag[iswap],pbc[iswap]); DeviceType().fence(); if (n) { MPI_Send(k_buf_send.view().data(), n,MPI_DOUBLE,sendproc[iswap],0,world); } - if (size_forward_recv[iswap]) { + if (size_forward_recv[iswap]) MPI_Wait(&request,MPI_STATUS_IGNORE); - atomKK->modified(ExecutionSpaceFromDevice:: - space,X_MASK); - } + } else if (ghost_velocity) { if (size_forward_recv[iswap]) { MPI_Irecv(k_buf_recv.view().data(), size_forward_recv[iswap],MPI_DOUBLE, recvproc[iswap],0,world,&request); } - n = atomKK->avecKK->pack_comm_vel_kokkos(sendnum[iswap],k_sendlist,iswap, + auto k_sendlist_iswap = Kokkos::subview(k_sendlist,iswap,Kokkos::ALL); + n = atomKK->avecKK->pack_comm_vel_kokkos(sendnum[iswap],k_sendlist_iswap, k_buf_send,pbc_flag[iswap],pbc[iswap]); DeviceType().fence(); if (n) { @@ -245,7 +248,8 @@ void CommKokkos::forward_comm_device(int) MPI_Irecv(k_buf_recv.view().data(), size_forward_recv[iswap],MPI_DOUBLE, recvproc[iswap],0,world,&request); - n = atomKK->avecKK->pack_comm_kokkos(sendnum[iswap],k_sendlist,iswap, + auto k_sendlist_iswap = Kokkos::subview(k_sendlist,iswap,Kokkos::ALL); + n = atomKK->avecKK->pack_comm_kokkos(sendnum[iswap],k_sendlist_iswap, k_buf_send,pbc_flag[iswap],pbc[iswap]); DeviceType().fence(); if (n) @@ -257,12 +261,15 @@ void CommKokkos::forward_comm_device(int) } } else { if (!ghost_velocity) { - if (sendnum[iswap]) - n = atomKK->avecKK->pack_comm_self(sendnum[iswap],k_sendlist,iswap, + if (sendnum[iswap]) { + auto k_sendlist_iswap = Kokkos::subview(k_sendlist,iswap,Kokkos::ALL); + n = atomKK->avecKK->pack_comm_self(sendnum[iswap],k_sendlist_iswap, firstrecv[iswap],pbc_flag[iswap],pbc[iswap]); - DeviceType().fence(); + DeviceType().fence(); + } } else { - n = atomKK->avecKK->pack_comm_vel_kokkos(sendnum[iswap],k_sendlist,iswap, + auto k_sendlist_iswap = Kokkos::subview(k_sendlist,iswap,Kokkos::ALL); + n = atomKK->avecKK->pack_comm_vel_kokkos(sendnum[iswap],k_sendlist_iswap, k_buf_send,pbc_flag[iswap],pbc[iswap]); DeviceType().fence(); atomKK->avecKK->unpack_comm_vel_kokkos(recvnum[iswap],firstrecv[iswap],k_buf_send); @@ -299,10 +306,10 @@ void CommKokkos::reverse_comm() atomKK->modified(Host,F_MASK); else atomKK->modified(Host,ALL_MASK); - - //atomKK->sync(Device,ALL_MASK); // is this needed? } +/* ---------------------------------------------------------------------- */ + template void CommKokkos::reverse_comm_device() { @@ -315,7 +322,6 @@ void CommKokkos::reverse_comm_device() // if comm_f_only set, exchange or copy directly from f, don't pack k_sendlist.sync(); - atomKK->sync(ExecutionSpaceFromDevice::space,F_MASK); for (int iswap = nswap-1; iswap >= 0; iswap--) { if (sendproc[iswap] != me) { @@ -330,11 +336,9 @@ void CommKokkos::reverse_comm_device() MPI_Send(buf,size_reverse_send[iswap],MPI_DOUBLE, recvproc[iswap],0,world); } - if (size_reverse_recv[iswap]) { + if (size_reverse_recv[iswap]) MPI_Wait(&request,MPI_STATUS_IGNORE); - atomKK->modified(ExecutionSpaceFromDevice:: - space,F_MASK); - } + } else { if (size_reverse_recv[iswap]) MPI_Irecv(k_buf_recv.view().data(), @@ -347,18 +351,28 @@ void CommKokkos::reverse_comm_device() MPI_DOUBLE,recvproc[iswap],0,world); if (size_reverse_recv[iswap]) MPI_Wait(&request,MPI_STATUS_IGNORE); } - atomKK->avecKK->unpack_reverse_kokkos(sendnum[iswap],k_sendlist,iswap, + auto k_sendlist_iswap = Kokkos::subview(k_sendlist,iswap,Kokkos::ALL); + atomKK->avecKK->unpack_reverse_kokkos(sendnum[iswap],k_sendlist_iswap, k_buf_recv); DeviceType().fence(); } else { - if (sendnum[iswap]) - n = atomKK->avecKK->unpack_reverse_self(sendnum[iswap],k_sendlist,iswap, + if (sendnum[iswap]) { + auto k_sendlist_iswap = Kokkos::subview(k_sendlist,iswap,Kokkos::ALL); + n = atomKK->avecKK->pack_reverse_self(sendnum[iswap],k_sendlist_iswap, firstrecv[iswap]); + } } } } -/* ---------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + forward communication invoked by a Fix + size/nsize used only to set recv buffer limit + size = 0 (default) -> use comm_forward from Fix + size > 0 -> Fix passes max size per atom + the latter is only useful if Fix does several comm modes, + some are smaller than max stored in its comm_forward +------------------------------------------------------------------------- */ void CommKokkos::forward_comm(Fix *fix, int size) { @@ -371,6 +385,8 @@ void CommKokkos::forward_comm(Fix *fix, int size) } } +/* ---------------------------------------------------------------------- */ + template void CommKokkos::forward_comm_device(Fix *fix, int size) { @@ -393,8 +409,9 @@ void CommKokkos::forward_comm_device(Fix *fix, int size) // pack buffer - n = fixKKBase->pack_forward_comm_kokkos(sendnum[iswap],k_sendlist, - iswap,k_buf_send_fix,pbc_flag[iswap],pbc[iswap]); + auto k_sendlist_iswap = Kokkos::subview(k_sendlist,iswap,Kokkos::ALL); + n = fixKKBase->pack_forward_comm_kokkos(sendnum[iswap],k_sendlist_iswap, + k_buf_send_fix,pbc_flag[iswap],pbc[iswap]); DeviceType().fence(); // exchange with another proc @@ -435,7 +452,14 @@ void CommKokkos::forward_comm_device(Fix *fix, int size) } } -/* ---------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- + reverse communication invoked by a Fix + size/nsize used only to set recv buffer limit + size = 0 (default) -> use comm_forward from Fix + size > 0 -> Fix passes max size per atom + the latter is only useful if Fix does several comm modes, + some are smaller than max stored in its comm_forward +------------------------------------------------------------------------- */ void CommKokkos::reverse_comm(Fix *fix, int size) { @@ -443,18 +467,66 @@ void CommKokkos::reverse_comm(Fix *fix, int size) CommBrick::reverse_comm(fix, size); } + +/* ---------------------------------------------------------------------- + reverse communication invoked by a Fix with variable size data + query fix for pack size to ensure buf_send is big enough + handshake sizes before each Irecv/Send to ensure buf_recv is big enough +------------------------------------------------------------------------- */ + +void CommKokkos::reverse_comm_variable(Fix *fix) +{ + k_sendlist.sync(); + CommBrick::reverse_comm_variable(fix); +} + +/* ---------------------------------------------------------------------- + forward communication invoked by a Compute + nsize used only to set recv buffer limit +------------------------------------------------------------------------- */ + void CommKokkos::forward_comm(Compute *compute) { k_sendlist.sync(); CommBrick::forward_comm(compute); } +/* ---------------------------------------------------------------------- + forward communication invoked by a Bond + nsize used only to set recv buffer limit +------------------------------------------------------------------------- */ + +void CommKokkos::forward_comm(Bond *bond) +{ + CommBrick::forward_comm(bond); +} + +/* ---------------------------------------------------------------------- + reverse communication invoked by a Bond + nsize used only to set recv buffer limit +------------------------------------------------------------------------- */ + +void CommKokkos::reverse_comm(Bond *bond) +{ + CommBrick::reverse_comm(bond); +} + +/* ---------------------------------------------------------------------- + reverse communication invoked by a Compute + nsize used only to set recv buffer limit +------------------------------------------------------------------------- */ + void CommKokkos::reverse_comm(Compute *compute) { k_sendlist.sync(); CommBrick::reverse_comm(compute); } +/* ---------------------------------------------------------------------- + forward communication invoked by a Dump + nsize used only to set recv buffer limit +------------------------------------------------------------------------- */ + void CommKokkos::forward_comm(Pair *pair) { if (pair->execution_space == Host || forward_pair_comm_classic) { @@ -466,6 +538,8 @@ void CommKokkos::forward_comm(Pair *pair) } } +/* ---------------------------------------------------------------------- */ + template void CommKokkos::forward_comm_device(Pair *pair) { @@ -488,8 +562,9 @@ void CommKokkos::forward_comm_device(Pair *pair) // pack buffer - n = pairKKBase->pack_forward_comm_kokkos(sendnum[iswap],k_sendlist, - iswap,k_buf_send_pair,pbc_flag[iswap],pbc[iswap]); + auto k_sendlist_iswap = Kokkos::subview(k_sendlist,iswap,Kokkos::ALL); + n = pairKKBase->pack_forward_comm_kokkos(sendnum[iswap],k_sendlist_iswap, + k_buf_send_pair,pbc_flag[iswap],pbc[iswap]); DeviceType().fence(); // exchange with another proc @@ -530,18 +605,24 @@ void CommKokkos::forward_comm_device(Pair *pair) } } +/* ---------------------------------------------------------------------- */ + void CommKokkos::grow_buf_pair(int n) { max_buf_pair = n * BUFFACTOR; k_buf_send_pair.resize(max_buf_pair); k_buf_recv_pair.resize(max_buf_pair); } +/* ---------------------------------------------------------------------- */ + void CommKokkos::grow_buf_fix(int n) { max_buf_fix = n * BUFFACTOR; k_buf_send_fix.resize(max_buf_fix); k_buf_recv_fix.resize(max_buf_fix); } +/* ---------------------------------------------------------------------- */ + void CommKokkos::reverse_comm(Pair *pair) { if (pair->execution_space == Host || !pair->reverse_comm_device || reverse_pair_comm_classic) { @@ -553,6 +634,8 @@ void CommKokkos::reverse_comm(Pair *pair) } } +/* ---------------------------------------------------------------------- */ + template void CommKokkos::reverse_comm_device(Pair *pair) { @@ -610,18 +693,23 @@ void CommKokkos::reverse_comm_device(Pair *pair) // unpack buffer - pairKKBase->unpack_reverse_comm_kokkos(sendnum[iswap],k_sendlist, - iswap,k_buf_tmp); + auto k_sendlist_iswap = Kokkos::subview(k_sendlist,iswap,Kokkos::ALL); + pairKKBase->unpack_reverse_comm_kokkos(sendnum[iswap],k_sendlist_iswap, + k_buf_tmp); DeviceType().fence(); } } +/* ---------------------------------------------------------------------- */ + void CommKokkos::forward_comm(Dump *dump) { k_sendlist.sync(); CommBrick::forward_comm(dump); } +/* ---------------------------------------------------------------------- */ + void CommKokkos::reverse_comm(Dump *dump) { k_sendlist.sync(); @@ -668,6 +756,7 @@ void CommKokkos::exchange() } } exchange_comm_classic = true; + lmp->kokkos->exchange_comm_classic = 1; } } } @@ -729,6 +818,14 @@ void CommKokkos::exchange_device() double lo,hi; MPI_Request request; + // clear global->local map for owned and ghost atoms + // b/c atoms migrate to new procs in exchange() and + // new ghosts are created in borders() + // map_set() is done at end of borders() + + if (lmp->kokkos->atom_map_classic) + if (map_style != Atom::MAP_NONE) atom->map_clear(); + // clear ghost count and any ghost bonus data internal to AtomVec atom->nghost = 0; @@ -931,6 +1028,7 @@ void CommKokkos::exchange_device() if (nextrarecv) { kkbase->unpack_exchange_kokkos( k_buf_recv,k_indices,nrecv/data_size, + nrecv1/data_size,nextrarecv1, ExecutionSpaceFromDevice::space); DeviceType().fence(); } @@ -971,6 +1069,7 @@ void CommKokkos::borders() "switching to classic exchange/border communication"); } exchange_comm_classic = true; + lmp->kokkos->exchange_comm_classic = 1; } } @@ -1193,14 +1292,15 @@ void CommKokkos::borders_device() { if (nsend*size_border > maxsend) grow_send_kokkos(nsend*size_border,0); if (ghost_velocity) { + auto k_sendlist_iswap = Kokkos::subview(k_sendlist,iswap,Kokkos::ALL); n = atomKK->avecKK-> - pack_border_vel_kokkos(nsend,k_sendlist,k_buf_send,iswap, + pack_border_vel_kokkos(nsend,k_sendlist_iswap,k_buf_send, pbc_flag[iswap],pbc[iswap],exec_space); DeviceType().fence(); - } - else { + } else { + auto k_sendlist_iswap = Kokkos::subview(k_sendlist,iswap,Kokkos::ALL); n = atomKK->avecKK-> - pack_border_kokkos(nsend,k_sendlist,k_buf_send,iswap, + pack_border_kokkos(nsend,k_sendlist_iswap,k_buf_send, pbc_flag[iswap],pbc[iswap],exec_space); DeviceType().fence(); } diff --git a/src/KOKKOS/comm_kokkos.h b/src/KOKKOS/comm_kokkos.h index e06810b939..4fb4dfbe29 100644 --- a/src/KOKKOS/comm_kokkos.h +++ b/src/KOKKOS/comm_kokkos.h @@ -45,18 +45,21 @@ class CommKokkos : public CommBrick { void exchange() override; // move atoms to new procs void borders() override; // setup list of atoms to comm - void forward_comm(class Pair *) override; // forward comm from a Pair - void reverse_comm(class Pair *) override; // reverse comm from a Pair - void forward_comm(class Fix *, int size=0) override; // forward comm from a Fix - void reverse_comm(class Fix *, int size=0) override; // reverse comm from a Fix - void forward_comm(class Compute *) override; // forward from a Compute - void reverse_comm(class Compute *) override; // reverse from a Compute - void forward_comm(class Dump *) override; // forward comm from a Dump - void reverse_comm(class Dump *) override; // reverse comm from a Dump + void forward_comm(class Pair *) override; // forward comm from a Pair + void reverse_comm(class Pair *) override; // reverse comm from a Pair + void forward_comm(class Bond *) override; // forward comm from a Bond + void reverse_comm(class Bond *) override; // reverse comm from a Bond + void forward_comm(class Fix *, int size = 0) override; // forward comm from a Fix + void reverse_comm(class Fix *, int size = 0) override; // reverse comm from a Fix + void reverse_comm_variable(class Fix *) override; // variable size reverse comm from a Fix + void forward_comm(class Compute *) override; // forward from a Compute + void reverse_comm(class Compute *) override; // reverse from a Compute + void forward_comm(class Dump *) override; // forward comm from a Dump + void reverse_comm(class Dump *) override; // reverse comm from a Dump void forward_comm_array(int, double **) override; // forward comm of array - template void forward_comm_device(int dummy); + template void forward_comm_device(); template void reverse_comm_device(); template void forward_comm_device(Pair *pair); template void reverse_comm_device(Pair *pair); @@ -95,7 +98,6 @@ class CommKokkos : public CommBrick { void copy_swap_info(); }; -} +} // namespace LAMMPS_NS #endif - diff --git a/src/KOKKOS/comm_tiled_kokkos.cpp b/src/KOKKOS/comm_tiled_kokkos.cpp index e3286a73f5..2e4ca30bed 100644 --- a/src/KOKKOS/comm_tiled_kokkos.cpp +++ b/src/KOKKOS/comm_tiled_kokkos.cpp @@ -16,21 +16,28 @@ #include "atom_kokkos.h" #include "atom_masks.h" -#include "atom_vec.h" +#include "atom_vec_kokkos.h" +#include "compute.h" +#include "dump.h" +#include "fix.h" +#include "force.h" +#include "kokkos.h" +#include "memory_kokkos.h" +#include "modify.h" +#include "output.h" using namespace LAMMPS_NS; -#define BUFFACTOR 1.5 -#define BUFFACTOR 1.5 -#define BUFMIN 1000 -#define BUFEXTRA 1000 -#define EPSILON 1.0e-6 - -#define DELTA_PROCS 16 +static constexpr double BUFFACTOR = 1.5; +static constexpr int BUFMIN = 1024; +static constexpr int BUFEXTRA = 1000; /* ---------------------------------------------------------------------- */ -CommTiledKokkos::CommTiledKokkos(LAMMPS *_lmp) : CommTiled(_lmp) {} +CommTiledKokkos::CommTiledKokkos(LAMMPS *_lmp) : CommTiled(_lmp) +{ + sendlist = nullptr; +} /* ---------------------------------------------------------------------- */ //IMPORTANT: we *MUST* pass "*oldcomm" to the Comm initializer here, as @@ -39,10 +46,69 @@ CommTiledKokkos::CommTiledKokkos(LAMMPS *_lmp) : CommTiled(_lmp) {} // The call to Comm::copy_arrays() then converts the shallow copy // into a deep copy of the class with the new layout. -CommTiledKokkos::CommTiledKokkos(LAMMPS *_lmp, Comm *oldcomm) : CommTiled(_lmp,oldcomm) {} +CommTiledKokkos::CommTiledKokkos(LAMMPS *_lmp, Comm *oldcomm) : CommTiled(_lmp,oldcomm) +{ + sendlist = nullptr; +} /* ---------------------------------------------------------------------- */ +CommTiledKokkos::~CommTiledKokkos() +{ + memoryKK->destroy_kokkos(k_sendlist,sendlist); + sendlist = nullptr; + buf_send = nullptr; + buf_recv = nullptr; +} + +/* ---------------------------------------------------------------------- */ + +void CommTiledKokkos::init() +{ + atomKK = (AtomKokkos *) atom; + exchange_comm_classic = lmp->kokkos->exchange_comm_classic; + forward_comm_classic = lmp->kokkos->forward_comm_classic; + forward_pair_comm_classic = lmp->kokkos->forward_pair_comm_classic; + reverse_pair_comm_classic = lmp->kokkos->reverse_pair_comm_classic; + forward_fix_comm_classic = lmp->kokkos->forward_fix_comm_classic; + reverse_comm_classic = lmp->kokkos->reverse_comm_classic; + exchange_comm_on_host = lmp->kokkos->exchange_comm_on_host; + forward_comm_on_host = lmp->kokkos->forward_comm_on_host; + reverse_comm_on_host = lmp->kokkos->reverse_comm_on_host; + + CommTiled::init(); + + int check_forward = 0; + int check_reverse = 0; + if (force->pair && (force->pair->execution_space == Host)) + check_forward += force->pair->comm_forward; + if (force->pair && (force->pair->execution_space == Host)) + check_reverse += force->pair->comm_reverse; + + for (const auto &fix : modify->get_fix_list()) { + check_forward += fix->comm_forward; + check_reverse += fix->comm_reverse; + } + + for (const auto &compute : modify->get_compute_list()) { + check_forward += compute->comm_forward; + check_reverse += compute->comm_reverse; + } + + for (const auto &dump : output->get_dump_list()) { + check_forward += dump->comm_forward; + check_reverse += dump->comm_reverse; + } + + if (force->newton == 0) check_reverse = 0; + if (force->pair) check_reverse += force->pair->comm_reverse_off; + + if (!comm_f_only) { // not all Kokkos atom_vec styles have reverse pack/unpack routines yet + reverse_comm_classic = true; + lmp->kokkos->reverse_comm_classic = 1; + } +} + /* ---------------------------------------------------------------------- forward communication of atom coords every timestep other per-atom attributes may also be sent via pack/unpack routines @@ -50,6 +116,14 @@ CommTiledKokkos::CommTiledKokkos(LAMMPS *_lmp, Comm *oldcomm) : CommTiled(_lmp,o void CommTiledKokkos::forward_comm(int dummy) { + if (!forward_comm_classic) { + if (forward_comm_on_host) forward_comm_device(); + else forward_comm_device(); + return; + } + + k_sendlist.sync(); + if (comm_x_only) { atomKK->sync(Host,X_MASK); atomKK->modified(Host,X_MASK); @@ -64,6 +138,127 @@ void CommTiledKokkos::forward_comm(int dummy) CommTiled::forward_comm(dummy); } +/* ---------------------------------------------------------------------- */ + +template +void CommTiledKokkos::forward_comm_device() +{ + int i,irecv,n,nsend,nrecv; + double *buf; + + // exchange data with another set of procs in each swap + // post recvs from all procs except self + // send data to all procs except self + // copy data to self if sendself is set + // wait on all procs except self and unpack received data + // if comm_x_only set, exchange or copy directly to x, don't unpack + + k_sendlist.sync(); + + for (int iswap = 0; iswap < nswap; iswap++) { + nsend = nsendproc[iswap] - sendself[iswap]; + nrecv = nrecvproc[iswap] - sendself[iswap]; + + if (comm_x_only) { + if (recvother[iswap]) { + for (i = 0; i < nrecv; i++) { + buf = atomKK->k_x.view().data() + + firstrecv[iswap][i]*atomKK->k_x.view().extent(1); + MPI_Irecv(buf,size_forward_recv[iswap][i], + MPI_DOUBLE,recvproc[iswap][i],0,world,&requests[i]); + } + } + if (sendother[iswap]) { + for (i = 0; i < nsend; i++) { + auto k_sendlist_small = Kokkos::subview(k_sendlist,iswap,i,Kokkos::ALL); + n = atomKK->avecKK->pack_comm_kokkos(sendnum[iswap][i],k_sendlist_small, + k_buf_send,pbc_flag[iswap][i],pbc[iswap][i]); + DeviceType().fence(); + MPI_Send(k_buf_send.view().data(),n,MPI_DOUBLE,sendproc[iswap][i],0,world); + } + } + if (sendself[iswap]) { + auto k_sendlist_small = Kokkos::subview(k_sendlist,iswap,nsend,Kokkos::ALL); + atomKK->avecKK->pack_comm_self(sendnum[iswap][nsend],k_sendlist_small, + firstrecv[iswap][nrecv],pbc_flag[iswap][nsend],pbc[iswap][nsend]); + DeviceType().fence(); + } + if (recvother[iswap]) MPI_Waitall(nrecv,requests,MPI_STATUS_IGNORE); + + } else if (ghost_velocity) { + if (recvother[iswap]) { + for (i = 0; i < nrecv; i++) { + buf = k_buf_recv.view().data() + + forward_recv_offset[iswap][i]*k_buf_recv.view().extent(1); + MPI_Irecv(buf, + size_forward_recv[iswap][i],MPI_DOUBLE,recvproc[iswap][i],0,world,&requests[i]); + } + } + if (sendother[iswap]) { + for (i = 0; i < nsend; i++) { + auto k_sendlist_small = Kokkos::subview(k_sendlist,iswap,i,Kokkos::ALL); + n = atomKK->avecKK->pack_comm_vel_kokkos(sendnum[iswap][i],k_sendlist_small, + k_buf_send,pbc_flag[iswap][i],pbc[iswap][i]); + DeviceType().fence(); + MPI_Send(k_buf_send.view().data(),n, + MPI_DOUBLE,sendproc[iswap][i],0,world); + } + } + if (sendself[iswap]) { + auto k_sendlist_small = Kokkos::subview(k_sendlist,iswap,nsend,Kokkos::ALL); + atomKK->avecKK->pack_comm_vel_kokkos(sendnum[iswap][nsend],k_sendlist_small, + k_buf_send,pbc_flag[iswap][nsend],pbc[iswap][nsend]); + DeviceType().fence(); + atomKK->avecKK->unpack_comm_vel_kokkos(recvnum[iswap][nrecv],firstrecv[iswap][nrecv],k_buf_send); + DeviceType().fence(); + } + if (recvother[iswap]) { + for (i = 0; i < nrecv; i++) { + MPI_Waitany(nrecv,requests,&irecv,MPI_STATUS_IGNORE); + auto k_buf_recv_offset = Kokkos::subview(k_buf_recv,std::pair(forward_recv_offset[iswap][irecv],(int)k_buf_recv.extent(0)),Kokkos::ALL); + atomKK->avecKK->unpack_comm_vel_kokkos(recvnum[iswap][irecv],firstrecv[iswap][irecv], + k_buf_recv_offset); + DeviceType().fence(); + } + } + + } else { + if (recvother[iswap]) { + for (i = 0; i < nrecv; i++) { + buf = k_buf_recv.view().data() + + forward_recv_offset[iswap][i]*k_buf_recv.view().extent(1); + MPI_Irecv(buf, + size_forward_recv[iswap][i],MPI_DOUBLE,recvproc[iswap][i],0,world,&requests[i]); + } + } + if (sendother[iswap]) { + for (i = 0; i < nsend; i++) { + auto k_sendlist_small = Kokkos::subview(k_sendlist,iswap,i,Kokkos::ALL); + n = atomKK->avecKK->pack_comm_kokkos(sendnum[iswap][i],k_sendlist_small, + k_buf_send,pbc_flag[iswap][i],pbc[iswap][i]); + DeviceType().fence(); + MPI_Send(k_buf_send.view().data(),n,MPI_DOUBLE,sendproc[iswap][i],0,world); + } + } + if (sendself[iswap]) { + auto k_sendlist_small = Kokkos::subview(k_sendlist,iswap,nsend,Kokkos::ALL); + n = atomKK->avecKK->pack_comm_kokkos(sendnum[iswap][nsend],k_sendlist_small, + k_buf_send,pbc_flag[iswap][nsend],pbc[iswap][nsend]); + DeviceType().fence(); + } + if (recvother[iswap]) { + for (i = 0; i < nrecv; i++) { + MPI_Waitany(nrecv,requests,&irecv,MPI_STATUS_IGNORE); + auto k_buf_recv_offset = Kokkos::subview(k_buf_recv,std::pair(forward_recv_offset[iswap][irecv],(int)k_buf_recv.extent(0)),Kokkos::ALL); + atomKK->avecKK->unpack_comm_kokkos(recvnum[iswap][irecv],firstrecv[iswap][irecv], + k_buf_recv_offset); + DeviceType().fence(); + } + } + } + } +} + /* ---------------------------------------------------------------------- reverse communication of forces on atoms every timestep other per-atom attributes may also be sent via pack/unpack routines @@ -71,16 +266,117 @@ void CommTiledKokkos::forward_comm(int dummy) void CommTiledKokkos::reverse_comm() { + if (!reverse_comm_classic) { + if (reverse_comm_on_host) reverse_comm_device(); + else reverse_comm_device(); + return; + } + + k_sendlist.sync(); + if (comm_f_only) atomKK->sync(Host,F_MASK); else atomKK->sync(Host,ALL_MASK); + CommTiled::reverse_comm(); + if (comm_f_only) atomKK->modified(Host,F_MASK); else atomKK->modified(Host,ALL_MASK); - atomKK->sync(Device,ALL_MASK); +} + +/* ---------------------------------------------------------------------- */ + +template +void CommTiledKokkos::reverse_comm_device() +{ + int i,irecv,n,nsend,nrecv; + double *buf; + + // exchange data with another set of procs in each swap + // post recvs from all procs except self + // send data to all procs except self + // copy data to self if sendself is set + // wait on all procs except self and unpack received data + // if comm_f_only set, exchange or copy directly from f, don't pack + + k_sendlist.sync(); + + for (int iswap = nswap-1; iswap >= 0; iswap--) { + nsend = nsendproc[iswap] - sendself[iswap]; + nrecv = nrecvproc[iswap] - sendself[iswap]; + + if (comm_f_only) { + if (sendother[iswap]) { + for (i = 0; i < nsend; i++) { + buf = k_buf_recv.view().data() + + reverse_recv_offset[iswap][i]*k_buf_recv.view().extent(1); + MPI_Irecv(buf, + size_reverse_recv[iswap][i],MPI_DOUBLE,sendproc[iswap][i],0,world,&requests[i]); + } + } + if (recvother[iswap]) { + for (i = 0; i < nrecv; i++) { + buf = atomKK->k_f.view().data() + + firstrecv[iswap][i]*atomKK->k_f.view().extent(1); + MPI_Send(buf,size_reverse_send[iswap][i], + MPI_DOUBLE,recvproc[iswap][i],0,world); + } + } + if (sendself[iswap]) { + auto k_sendlist_small = Kokkos::subview(k_sendlist,iswap,nsend,Kokkos::ALL); + atomKK->avecKK->pack_reverse_self(sendnum[iswap][nsend],k_sendlist_small, + firstrecv[iswap][nrecv]); + DeviceType().fence(); + } + if (sendother[iswap]) { + for (i = 0; i < nsend; i++) { + MPI_Waitany(nsend,requests,&irecv,MPI_STATUS_IGNORE); + auto k_sendlist_small = Kokkos::subview(k_sendlist,iswap,irecv,Kokkos::ALL); + auto k_buf_recv_offset = Kokkos::subview(k_buf_recv,std::pair(reverse_recv_offset[iswap][irecv],(int)k_buf_recv.extent(0)),Kokkos::ALL); + atomKK->avecKK->unpack_reverse_kokkos(sendnum[iswap][irecv],k_sendlist_small, + k_buf_recv_offset); + DeviceType().fence(); + } + } + + } else { + if (sendother[iswap]) { + for (i = 0; i < nsend; i++) { + buf = k_buf_recv.view().data() + + reverse_recv_offset[iswap][i]*k_buf_recv.view().extent(1); + MPI_Irecv(buf, + size_reverse_recv[iswap][i],MPI_DOUBLE,sendproc[iswap][i],0,world,&requests[i]); + } + } + if (recvother[iswap]) { + for (i = 0; i < nrecv; i++) { + n = atomKK->avecKK->pack_reverse_kokkos(recvnum[iswap][i],firstrecv[iswap][i],k_buf_send); + DeviceType().fence(); + MPI_Send(k_buf_send.view().data(),n,MPI_DOUBLE,recvproc[iswap][i],0,world); + } + } + if (sendself[iswap]) { + auto k_sendlist_small = Kokkos::subview(k_sendlist,iswap,nsend,Kokkos::ALL); + atomKK->avecKK->pack_reverse_kokkos(recvnum[iswap][nrecv],firstrecv[iswap][nrecv],k_buf_send); + DeviceType().fence(); + atomKK->avecKK->unpack_reverse_kokkos(sendnum[iswap][nsend],k_sendlist_small,k_buf_send); + DeviceType().fence(); + } + if (sendother[iswap]) { + for (i = 0; i < nsend; i++) { + MPI_Waitany(nsend,requests,&irecv,MPI_STATUS_IGNORE); + auto k_sendlist_small = Kokkos::subview(k_sendlist,iswap,irecv,Kokkos::ALL); + auto k_buf_recv_offset = Kokkos::subview(k_buf_recv,std::pair(reverse_recv_offset[iswap][irecv],(int)k_buf_recv.extent(0)),Kokkos::ALL); + atomKK->avecKK->unpack_reverse_kokkos(sendnum[iswap][irecv],k_sendlist_small, + k_buf_recv_offset); + DeviceType().fence(); + } + } + } + } } /* ---------------------------------------------------------------------- @@ -116,6 +412,7 @@ void CommTiledKokkos::borders() atomKK->sync(Host,ALL_MASK); CommTiled::borders(); atomKK->modified(Host,ALL_MASK); + k_sendlist.modify_host(); } /* ---------------------------------------------------------------------- @@ -138,6 +435,26 @@ void CommTiledKokkos::reverse_comm(Pair *pair) CommTiled::reverse_comm(pair); } +/* ---------------------------------------------------------------------- + forward communication invoked by a Bond + nsize used only to set recv buffer limit +------------------------------------------------------------------------- */ + +void CommTiledKokkos::forward_comm(Bond *bond) +{ + CommTiled::forward_comm(bond); +} + +/* ---------------------------------------------------------------------- + reverse communication invoked by a Bond + nsize used only to set recv buffer limit +------------------------------------------------------------------------- */ + +void CommTiledKokkos::reverse_comm(Bond *bond) +{ + CommTiled::reverse_comm(bond); +} + /* ---------------------------------------------------------------------- forward communication invoked by a Fix size/nsize used only to set recv buffer limit @@ -226,3 +543,141 @@ void CommTiledKokkos::forward_comm_array(int nsize, double **array) { CommTiled::forward_comm_array(nsize,array); } + +/* ---------------------------------------------------------------------- + realloc the size of the send buffer as needed with BUFFACTOR and bufextra + if flag = 1, realloc + if flag = 0, don't need to realloc with copy, just free/malloc +------------------------------------------------------------------------- */ + +void CommTiledKokkos::grow_send(int n, int flag) +{ + grow_send_kokkos(n,flag,Host); +} + +/* ---------------------------------------------------------------------- + free/malloc the size of the recv buffer as needed with BUFFACTOR +------------------------------------------------------------------------- */ + +void CommTiledKokkos::grow_recv(int n, int flag) +{ + grow_recv_kokkos(n,flag,Host); +} + +/* ---------------------------------------------------------------------- + realloc the size of the send buffer as needed with BUFFACTOR & BUFEXTRA + if flag = 1, realloc + if flag = 0, don't need to realloc with copy, just free/malloc +------------------------------------------------------------------------- */ + +void CommTiledKokkos::grow_send_kokkos(int n, int flag, ExecutionSpace space) +{ + + maxsend = static_cast (BUFFACTOR * n); + int maxsend_border = (maxsend+BUFEXTRA)/atomKK->avecKK->size_border; + if (flag) { + if (space == Device) + k_buf_send.modify(); + else + k_buf_send.modify(); + + if (ghost_velocity) + k_buf_send.resize(maxsend_border, + atomKK->avecKK->size_border + atomKK->avecKK->size_velocity); + else + k_buf_send.resize(maxsend_border,atomKK->avecKK->size_border); + buf_send = k_buf_send.view().data(); + } else { + if (ghost_velocity) + MemoryKokkos::realloc_kokkos(k_buf_send,"comm:k_buf_send",maxsend_border, + atomKK->avecKK->size_border + atomKK->avecKK->size_velocity); + else + MemoryKokkos::realloc_kokkos(k_buf_send,"comm:k_buf_send",maxsend_border, + atomKK->avecKK->size_border); + buf_send = k_buf_send.view().data(); + } +} + +/* ---------------------------------------------------------------------- + free/malloc the size of the recv buffer as needed with BUFFACTOR +------------------------------------------------------------------------- */ + +void CommTiledKokkos::grow_recv_kokkos(int n, int flag, ExecutionSpace /*space*/) +{ + if (flag) maxrecv = n; + else maxrecv = static_cast (BUFFACTOR * n); + + int maxrecv_border = (maxrecv+BUFEXTRA)/atomKK->avecKK->size_border; + + MemoryKokkos::realloc_kokkos(k_buf_recv,"comm:k_buf_recv",maxrecv_border, + atomKK->avecKK->size_border); + buf_recv = k_buf_recv.view().data(); +} + +/* ---------------------------------------------------------------------- + realloc the size of the iswap sendlist as needed with BUFFACTOR +------------------------------------------------------------------------- */ + +void CommTiledKokkos::grow_list(int iswap, int iwhich, int n) +{ + int size = static_cast (BUFFACTOR * n); + + k_sendlist.sync(); + k_sendlist.modify(); + + if (size > (int)k_sendlist.extent(2)) { + memoryKK->grow_kokkos(k_sendlist,sendlist,maxswap,maxsend,size,"comm:sendlist"); + + for (int i = 0; i < maxswap; i++) + maxsendlist[iswap][iwhich] = size; + } +} + +/* ---------------------------------------------------------------------- + grow info for swap I, to allow for N procs to communicate with + ditto for complementary recv for swap I+1 or I-1, as invoked by caller +------------------------------------------------------------------------- */ + +void CommTiledKokkos::grow_swap_send(int i, int n, int /*nold*/) +{ + delete [] sendproc[i]; + sendproc[i] = new int[n]; + delete [] sendnum[i]; + sendnum[i] = new int[n]; + + delete [] size_reverse_recv[i]; + size_reverse_recv[i] = new int[n]; + delete [] reverse_recv_offset[i]; + reverse_recv_offset[i] = new int[n]; + + delete [] pbc_flag[i]; + pbc_flag[i] = new int[n]; + memory->destroy(pbc[i]); + memory->create(pbc[i],n,6,"comm:pbc_flag"); + memory->destroy(sendbox[i]); + memory->create(sendbox[i],n,6,"comm:sendbox"); + grow_swap_send_multi(i,n); + memory->destroy(sendbox_multiold[i]); + memory->create(sendbox_multiold[i],n,atom->ntypes+1,6,"comm:sendbox_multiold"); + + delete [] maxsendlist[i]; + maxsendlist[i] = new int[n]; + + for (int j = 0; j < n; j++) + maxsendlist[i][j] = BUFMIN; + + if (sendlist && !k_sendlist.d_view.data()) { + for (int ii = 0; ii < maxswap; ii++) { + if (sendlist[ii]) { + for (int jj = 0; jj < nprocmax[ii]; jj++) + memory->destroy(sendlist[ii][jj]); + delete [] sendlist[ii]; + } + } + delete [] sendlist; + } else { + memoryKK->destroy_kokkos(k_sendlist,sendlist); + } + + memoryKK->create_kokkos(k_sendlist,sendlist,maxswap,n,BUFMIN,"comm:sendlist"); +} diff --git a/src/KOKKOS/comm_tiled_kokkos.h b/src/KOKKOS/comm_tiled_kokkos.h index c80436b454..9033714796 100644 --- a/src/KOKKOS/comm_tiled_kokkos.h +++ b/src/KOKKOS/comm_tiled_kokkos.h @@ -25,28 +25,59 @@ class CommTiledKokkos : public CommTiled { CommTiledKokkos(class LAMMPS *); CommTiledKokkos(class LAMMPS *, class Comm *); + ~CommTiledKokkos() override; + + bool exchange_comm_classic; + bool forward_comm_classic; + bool forward_pair_comm_classic; + bool reverse_pair_comm_classic; + bool forward_fix_comm_classic; + bool reverse_comm_classic; + bool exchange_comm_on_host; + bool forward_comm_on_host; + bool reverse_comm_on_host; + using CommTiled::forward_comm; using CommTiled::reverse_comm; + + void init() override; void forward_comm(int dummy = 0) override; // forward comm of atom coords void reverse_comm() override; // reverse comm of forces void exchange() override; // move atoms to new procs void borders() override; // setup list of atoms to comm - void forward_comm(class Pair *) override; // forward comm from a Pair - void reverse_comm(class Pair *) override; // reverse comm from a Pair - void forward_comm(class Fix *, int size=0) override; - // forward comm from a Fix - void reverse_comm(class Fix *, int size=0) override; - // reverse comm from a Fix - void reverse_comm_variable(class Fix *) override; - // variable size reverse comm from a Fix - void forward_comm(class Compute *) override; // forward from a Compute - void reverse_comm(class Compute *) override; // reverse from a Compute - void forward_comm(class Dump *) override; // forward comm from a Dump - void reverse_comm(class Dump *) override; // reverse comm from a Dump + void forward_comm(class Pair *) override; // forward comm from a Pair + void reverse_comm(class Pair *) override; // reverse comm from a Pair + void forward_comm(class Bond *) override; // forward comm from a Bond + void reverse_comm(class Bond *) override; // reverse comm from a Bond + void forward_comm(class Fix *, int size = 0) override; // forward comm from a Fix + void reverse_comm(class Fix *, int size = 0) override; // reverse comm from a Fix + void reverse_comm_variable(class Fix *) override; // variable size reverse comm from a Fix + void forward_comm(class Compute *) override; // forward from a Compute + void reverse_comm(class Compute *) override; // reverse from a Compute + void forward_comm(class Dump *) override; // forward comm from a Dump + void reverse_comm(class Dump *) override; // reverse comm from a Dump void forward_comm_array(int, double **) override; // forward comm of array -}; -} -#endif + template void forward_comm_device(); + template void reverse_comm_device(); + + protected: + + DAT::tdual_int_3d k_sendlist; + //DAT::tdual_int_scalar k_total_send; + DAT::tdual_xfloat_2d k_buf_send,k_buf_recv; + //DAT::tdual_int_scalar k_count; + + void grow_send(int, int) override; + void grow_recv(int, int flag = 0) override; + void grow_send_kokkos(int, int, ExecutionSpace space = Host); + void grow_recv_kokkos(int, int, ExecutionSpace space = Host); + void grow_list(int, int, int) override; + void grow_swap_send(int, int, int) override; // grow swap arrays for send and recv +}; + +} // namespace LAMMPS_NS + +#endif diff --git a/src/KOKKOS/compute_ave_sphere_atom_kokkos.cpp b/src/KOKKOS/compute_ave_sphere_atom_kokkos.cpp index 87fe3621e4..57f1f2bb18 100644 --- a/src/KOKKOS/compute_ave_sphere_atom_kokkos.cpp +++ b/src/KOKKOS/compute_ave_sphere_atom_kokkos.cpp @@ -21,19 +21,12 @@ #include "atom_masks.h" #include "comm.h" #include "domain.h" -#include "error.h" #include "force.h" #include "memory_kokkos.h" -#include "modify.h" -#include "neigh_list.h" #include "neigh_request.h" #include "neighbor_kokkos.h" -#include "pair.h" #include "update.h" -#include -#include - using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/compute_composition_atom_kokkos.cpp b/src/KOKKOS/compute_composition_atom_kokkos.cpp index 2b0e663011..47056951e7 100644 --- a/src/KOKKOS/compute_composition_atom_kokkos.cpp +++ b/src/KOKKOS/compute_composition_atom_kokkos.cpp @@ -19,21 +19,11 @@ #include "atom_kokkos.h" #include "atom_masks.h" -#include "comm.h" -#include "domain.h" -#include "error.h" -#include "force.h" #include "memory_kokkos.h" -#include "modify.h" -#include "neigh_list.h" #include "neigh_request.h" #include "neighbor_kokkos.h" -#include "pair.h" #include "update.h" -#include -#include - using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/compute_coord_atom_kokkos.cpp b/src/KOKKOS/compute_coord_atom_kokkos.cpp index 089a94f498..2d56a53abe 100644 --- a/src/KOKKOS/compute_coord_atom_kokkos.cpp +++ b/src/KOKKOS/compute_coord_atom_kokkos.cpp @@ -20,8 +20,6 @@ #include "compute_orientorder_atom_kokkos.h" #include "error.h" #include "memory_kokkos.h" -#include "modify.h" -#include "neigh_list.h" #include "neigh_request.h" #include "neighbor_kokkos.h" #include "update.h" diff --git a/src/KOKKOS/compute_erotate_sphere_kokkos.cpp b/src/KOKKOS/compute_erotate_sphere_kokkos.cpp index 9fc477b3a0..d18aa3d27a 100644 --- a/src/KOKKOS/compute_erotate_sphere_kokkos.cpp +++ b/src/KOKKOS/compute_erotate_sphere_kokkos.cpp @@ -16,8 +16,6 @@ #include "atom_kokkos.h" #include "atom_masks.h" -#include "error.h" -#include "force.h" #include "update.h" using namespace LAMMPS_NS; diff --git a/src/KOKKOS/compute_orientorder_atom_kokkos.cpp b/src/KOKKOS/compute_orientorder_atom_kokkos.cpp index 35699cb5c1..447f15b830 100644 --- a/src/KOKKOS/compute_orientorder_atom_kokkos.cpp +++ b/src/KOKKOS/compute_orientorder_atom_kokkos.cpp @@ -24,14 +24,11 @@ #include "atom_kokkos.h" #include "atom_masks.h" -#include "kokkos.h" #include "math_const.h" #include "math_special.h" #include "memory_kokkos.h" -#include "neigh_list.h" #include "neigh_request.h" #include "neighbor_kokkos.h" -#include "pair.h" #include "update.h" #include diff --git a/src/KOKKOS/compute_reaxff_atom_kokkos.cpp b/src/KOKKOS/compute_reaxff_atom_kokkos.cpp index 3f6c9242d4..0683e63752 100644 --- a/src/KOKKOS/compute_reaxff_atom_kokkos.cpp +++ b/src/KOKKOS/compute_reaxff_atom_kokkos.cpp @@ -18,16 +18,12 @@ #include "compute_reaxff_atom_kokkos.h" #include "atom.h" -#include "molecule.h" #include "update.h" -#include "force.h" -#include "memory.h" #include "error.h" #include "neigh_list.h" #include "memory_kokkos.h" #include "pair_reaxff_kokkos.h" -#include "reaxff_api.h" using namespace LAMMPS_NS; using namespace ReaxFF; @@ -67,10 +63,10 @@ void ComputeReaxFFAtomKokkos::init() template void ComputeReaxFFAtomKokkos::compute_bonds() { - if (atom->nlocal > nlocal) { + if (atom->nmax > nmax) { memory->destroy(array_atom); - nlocal = atom->nlocal; - memory->create(array_atom, nlocal, 3, "reaxff/atom:array_atom"); + nmax = atom->nmax; + memory->create(array_atom, nmax, 3, "reaxff/atom:array_atom"); } // retrieve bond information from kokkos pair style. the data potentially @@ -85,6 +81,7 @@ void ComputeReaxFFAtomKokkos::compute_bonds() else host_pair()->FindBond(maxnumbonds, groupbit); + const int nlocal = atom->nlocal; nbuf = ((store_bonds ? maxnumbonds*2 : 0) + 3)*nlocal; if (!buf || ((int)k_buf.extent(0) < nbuf)) { @@ -135,6 +132,7 @@ void ComputeReaxFFAtomKokkos::compute_local() int b = 0; int j = 0; auto tag = atom->tag; + const int nlocal = atom->nlocal; for (int i = 0; i < nlocal; ++i) { const int numbonds = static_cast(buf[j+2]); @@ -161,6 +159,7 @@ void ComputeReaxFFAtomKokkos::compute_peratom() compute_bonds(); // extract peratom bond information from buffer + const int nlocal = atom->nlocal; int j = 0; for (int i = 0; i < nlocal; ++i) { @@ -180,7 +179,7 @@ void ComputeReaxFFAtomKokkos::compute_peratom() template double ComputeReaxFFAtomKokkos::memory_usage() { - double bytes = (double)(nlocal*3) * sizeof(double); + double bytes = (double)(nmax*3) * sizeof(double); if (store_bonds) bytes += (double)(nbonds*3) * sizeof(double); bytes += (double)(nbuf > 0 ? nbuf * sizeof(double) : 0); diff --git a/src/KOKKOS/compute_temp_deform_kokkos.cpp b/src/KOKKOS/compute_temp_deform_kokkos.cpp index 55db344d6a..03aba5b10d 100644 --- a/src/KOKKOS/compute_temp_deform_kokkos.cpp +++ b/src/KOKKOS/compute_temp_deform_kokkos.cpp @@ -24,7 +24,6 @@ #include "domain_kokkos.h" #include "error.h" #include "force.h" -#include "memory_kokkos.h" #include "update.h" using namespace LAMMPS_NS; diff --git a/src/KOKKOS/compute_temp_kokkos.cpp b/src/KOKKOS/compute_temp_kokkos.cpp index ebdd6971e0..78a35440c8 100644 --- a/src/KOKKOS/compute_temp_kokkos.cpp +++ b/src/KOKKOS/compute_temp_kokkos.cpp @@ -21,8 +21,6 @@ #include "force.h" #include "update.h" -#include - using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/dihedral_charmm_kokkos.cpp b/src/KOKKOS/dihedral_charmm_kokkos.cpp index 70a74a4846..b385ec7f01 100644 --- a/src/KOKKOS/dihedral_charmm_kokkos.cpp +++ b/src/KOKKOS/dihedral_charmm_kokkos.cpp @@ -33,7 +33,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define TOLERANCE 0.05 +static constexpr double TOLERANCE = 0.05; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/dihedral_charmmfsw_kokkos.cpp b/src/KOKKOS/dihedral_charmmfsw_kokkos.cpp new file mode 100644 index 0000000000..aeb9b022a7 --- /dev/null +++ b/src/KOKKOS/dihedral_charmmfsw_kokkos.cpp @@ -0,0 +1,815 @@ +// clang-format off +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + LAMMPS development team: developers@lammps.org + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + + Contributing author: Mitch Murphy (alphataubio) + + Based on serial dihedral_charmmfsw.cpp lj-fsw sections (force-switched) + provided by Robert Meissner and Lucio Colombi Ciacchi of Bremen + University, Germany, with additional assistance from + Robert A. Latour, Clemson University. + +------------------------------------------------------------------------- */ + +#include "dihedral_charmmfsw_kokkos.h" + +#include "atom_kokkos.h" +#include "atom_masks.h" +#include "error.h" +#include "force.h" +#include "kokkos.h" +#include "math_const.h" +#include "memory_kokkos.h" +#include "neighbor_kokkos.h" +#include "pair.h" + +#include + +using namespace LAMMPS_NS; +using namespace MathConst; + +static constexpr double TOLERANCE = 0.05; + +/* ---------------------------------------------------------------------- */ + +template +DihedralCharmmfswKokkos::DihedralCharmmfswKokkos(LAMMPS *lmp) : DihedralCharmmfsw(lmp) +{ + atomKK = (AtomKokkos *) atom; + neighborKK = (NeighborKokkos *) neighbor; + execution_space = ExecutionSpaceFromDevice::space; + datamask_read = X_MASK | F_MASK | Q_MASK | ENERGY_MASK | VIRIAL_MASK | TYPE_MASK; + datamask_modify = F_MASK | ENERGY_MASK | VIRIAL_MASK; + + k_warning_flag = Kokkos::DualView("Dihedral:warning_flag"); + d_warning_flag = k_warning_flag.template view(); + h_warning_flag = k_warning_flag.h_view; + + centroidstressflag = CENTROID_NOTAVAIL; +} + +/* ---------------------------------------------------------------------- */ + +template +DihedralCharmmfswKokkos::~DihedralCharmmfswKokkos() +{ + if (!copymode) { + memoryKK->destroy_kokkos(k_eatom,eatom); + memoryKK->destroy_kokkos(k_vatom,vatom); + } +} + +/* ---------------------------------------------------------------------- */ + +template +void DihedralCharmmfswKokkos::compute(int eflag_in, int vflag_in) +{ + eflag = eflag_in; + vflag = vflag_in; + + if (lmp->kokkos->neighflag == FULL) + error->all(FLERR,"Dihedral_style charmm/kk requires half neighbor list"); + + ev_init(eflag,vflag,0); + + // ensure pair->ev_tally() will use 1-4 virial contribution + + if (weightflag && vflag_global == VIRIAL_FDOTR) + force->pair->vflag_either = force->pair->vflag_global = 1; + + // reallocate per-atom arrays if necessary + + if (eflag_atom) { + //if(k_eatom.extent(0)destroy_kokkos(k_eatom,eatom); + memoryKK->create_kokkos(k_eatom,eatom,maxeatom,"dihedral:eatom"); + d_eatom = k_eatom.template view(); + k_eatom_pair = Kokkos::DualView("dihedral:eatom_pair",maxeatom); + d_eatom_pair = k_eatom_pair.template view(); + //} + } + if (vflag_atom) { + //if(k_vatom.extent(0)destroy_kokkos(k_vatom,vatom); + memoryKK->create_kokkos(k_vatom,vatom,maxvatom,"dihedral:vatom"); + d_vatom = k_vatom.template view(); + k_vatom_pair = Kokkos::DualView("dihedral:vatom_pair",maxvatom); + d_vatom_pair = k_vatom_pair.template view(); + //} + } + + x = atomKK->k_x.view(); + f = atomKK->k_f.view(); + q = atomKK->k_q.view(); + atomtype = atomKK->k_type.view(); + neighborKK->k_dihedrallist.template sync(); + dihedrallist = neighborKK->k_dihedrallist.view(); + int ndihedrallist = neighborKK->ndihedrallist; + nlocal = atom->nlocal; + newton_bond = force->newton_bond; + qqrd2e = force->qqrd2e; + + h_warning_flag() = 0; + k_warning_flag.template modify(); + k_warning_flag.template sync(); + + copymode = 1; + + // loop over neighbors of my atoms + + EVM_FLOAT evm; + + if (evflag) { + if (newton_bond) { + Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,ndihedrallist),*this,evm); + } else { + Kokkos::parallel_reduce(Kokkos::RangePolicy >(0,ndihedrallist),*this,evm); + } + } else { + if (newton_bond) { + Kokkos::parallel_for(Kokkos::RangePolicy >(0,ndihedrallist),*this); + } else { + Kokkos::parallel_for(Kokkos::RangePolicy >(0,ndihedrallist),*this); + } + } + + // error check + + k_warning_flag.template modify(); + k_warning_flag.template sync(); + if (h_warning_flag()) + error->warning(FLERR,"Dihedral problem"); + + if (eflag_global) { + energy += evm.emol; + force->pair->eng_vdwl += evm.evdwl; + force->pair->eng_coul += evm.ecoul; + } + if (vflag_global) { + virial[0] += evm.v[0]; + virial[1] += evm.v[1]; + virial[2] += evm.v[2]; + virial[3] += evm.v[3]; + virial[4] += evm.v[4]; + virial[5] += evm.v[5]; + + force->pair->virial[0] += evm.vp[0]; + force->pair->virial[1] += evm.vp[1]; + force->pair->virial[2] += evm.vp[2]; + force->pair->virial[3] += evm.vp[3]; + force->pair->virial[4] += evm.vp[4]; + force->pair->virial[5] += evm.vp[5]; + } + + // don't yet have dualviews for eatom and vatom in pair_kokkos, + // so need to manually copy these to pair style + + int n = nlocal; + if (newton_bond) n += atom->nghost; + + if (eflag_atom) { + k_eatom.template modify(); + k_eatom.template sync(); + + k_eatom_pair.template modify(); + k_eatom_pair.template sync(); + for (int i = 0; i < n; i++) + force->pair->eatom[i] += k_eatom_pair.h_view(i); + } + + if (vflag_atom) { + k_vatom.template modify(); + k_vatom.template sync(); + + k_vatom_pair.template modify(); + k_vatom_pair.template sync(); + for (int i = 0; i < n; i++) { + force->pair->vatom[i][0] += k_vatom_pair.h_view(i,0); + force->pair->vatom[i][1] += k_vatom_pair.h_view(i,1); + force->pair->vatom[i][2] += k_vatom_pair.h_view(i,2); + force->pair->vatom[i][3] += k_vatom_pair.h_view(i,3); + force->pair->vatom[i][4] += k_vatom_pair.h_view(i,4); + force->pair->vatom[i][5] += k_vatom_pair.h_view(i,5); + } + } + + copymode = 0; +} + +template +template +KOKKOS_INLINE_FUNCTION +void DihedralCharmmfswKokkos::operator()(TagDihedralCharmmfswCompute, const int &n, EVM_FLOAT& evm) const { + + // The f array is atomic + Kokkos::View::value,Kokkos::MemoryTraits > a_f = f; + + const int i1 = dihedrallist(n,0); + const int i2 = dihedrallist(n,1); + const int i3 = dihedrallist(n,2); + const int i4 = dihedrallist(n,3); + const int type = dihedrallist(n,4); + + // 1st bond + + const F_FLOAT vb1x = x(i1,0) - x(i2,0); + const F_FLOAT vb1y = x(i1,1) - x(i2,1); + const F_FLOAT vb1z = x(i1,2) - x(i2,2); + + // 2nd bond + + const F_FLOAT vb2x = x(i3,0) - x(i2,0); + const F_FLOAT vb2y = x(i3,1) - x(i2,1); + const F_FLOAT vb2z = x(i3,2) - x(i2,2); + + const F_FLOAT vb2xm = -vb2x; + const F_FLOAT vb2ym = -vb2y; + const F_FLOAT vb2zm = -vb2z; + + // 3rd bond + + const F_FLOAT vb3x = x(i4,0) - x(i3,0); + const F_FLOAT vb3y = x(i4,1) - x(i3,1); + const F_FLOAT vb3z = x(i4,2) - x(i3,2); + + const F_FLOAT ax = vb1y*vb2zm - vb1z*vb2ym; + const F_FLOAT ay = vb1z*vb2xm - vb1x*vb2zm; + const F_FLOAT az = vb1x*vb2ym - vb1y*vb2xm; + const F_FLOAT bx = vb3y*vb2zm - vb3z*vb2ym; + const F_FLOAT by = vb3z*vb2xm - vb3x*vb2zm; + const F_FLOAT bz = vb3x*vb2ym - vb3y*vb2xm; + + const F_FLOAT rasq = ax*ax + ay*ay + az*az; + const F_FLOAT rbsq = bx*bx + by*by + bz*bz; + const F_FLOAT rgsq = vb2xm*vb2xm + vb2ym*vb2ym + vb2zm*vb2zm; + const F_FLOAT rg = sqrt(rgsq); + + F_FLOAT rginv,ra2inv,rb2inv; + rginv = ra2inv = rb2inv = 0.0; + if (rg > 0) rginv = 1.0/rg; + if (rasq > 0) ra2inv = 1.0/rasq; + if (rbsq > 0) rb2inv = 1.0/rbsq; + const F_FLOAT rabinv = sqrt(ra2inv*rb2inv); + + F_FLOAT c = (ax*bx + ay*by + az*bz)*rabinv; + F_FLOAT s = rg*rabinv*(ax*vb3x + ay*vb3y + az*vb3z); + + // error check + + if ((c > 1.0 + TOLERANCE || c < (-1.0 - TOLERANCE)) && !d_warning_flag()) + d_warning_flag() = 1; + + if (c > 1.0) c = 1.0; + if (c < -1.0) c = -1.0; + + const int m = d_multiplicity[type]; + F_FLOAT p = 1.0; + F_FLOAT ddf1,df1; + ddf1 = df1 = 0.0; + + for (int i = 0; i < m; i++) { + ddf1 = p*c - df1*s; + df1 = p*s + df1*c; + p = ddf1; + } + + p = p*d_cos_shift[type] + df1*d_sin_shift[type]; + df1 = df1*d_cos_shift[type] - ddf1*d_sin_shift[type]; + df1 *= -m; + p += 1.0; + + if (m == 0) { + p = 1.0 + d_cos_shift[type]; + df1 = 0.0; + } + + E_FLOAT edihedral = 0.0; + if (eflag) edihedral = d_k[type] * p; + + const F_FLOAT fg = vb1x*vb2xm + vb1y*vb2ym + vb1z*vb2zm; + const F_FLOAT hg = vb3x*vb2xm + vb3y*vb2ym + vb3z*vb2zm; + const F_FLOAT fga = fg*ra2inv*rginv; + const F_FLOAT hgb = hg*rb2inv*rginv; + const F_FLOAT gaa = -ra2inv*rg; + const F_FLOAT gbb = rb2inv*rg; + + const F_FLOAT dtfx = gaa*ax; + const F_FLOAT dtfy = gaa*ay; + const F_FLOAT dtfz = gaa*az; + const F_FLOAT dtgx = fga*ax - hgb*bx; + const F_FLOAT dtgy = fga*ay - hgb*by; + const F_FLOAT dtgz = fga*az - hgb*bz; + const F_FLOAT dthx = gbb*bx; + const F_FLOAT dthy = gbb*by; + const F_FLOAT dthz = gbb*bz; + + const F_FLOAT df = -d_k[type] * df1; + + const F_FLOAT sx2 = df*dtgx; + const F_FLOAT sy2 = df*dtgy; + const F_FLOAT sz2 = df*dtgz; + + F_FLOAT f1[3],f2[3],f3[3],f4[3]; + f1[0] = df*dtfx; + f1[1] = df*dtfy; + f1[2] = df*dtfz; + + f2[0] = sx2 - f1[0]; + f2[1] = sy2 - f1[1]; + f2[2] = sz2 - f1[2]; + + f4[0] = df*dthx; + f4[1] = df*dthy; + f4[2] = df*dthz; + + f3[0] = -sx2 - f4[0]; + f3[1] = -sy2 - f4[1]; + f3[2] = -sz2 - f4[2]; + + // apply force to each of 4 atoms + + if (NEWTON_BOND || i1 < nlocal) { + a_f(i1,0) += f1[0]; + a_f(i1,1) += f1[1]; + a_f(i1,2) += f1[2]; + } + + if (NEWTON_BOND || i2 < nlocal) { + a_f(i2,0) += f2[0]; + a_f(i2,1) += f2[1]; + a_f(i2,2) += f2[2]; + } + + if (NEWTON_BOND || i3 < nlocal) { + a_f(i3,0) += f3[0]; + a_f(i3,1) += f3[1]; + a_f(i3,2) += f3[2]; + } + + if (NEWTON_BOND || i4 < nlocal) { + a_f(i4,0) += f4[0]; + a_f(i4,1) += f4[1]; + a_f(i4,2) += f4[2]; + } + + if (EVFLAG) + ev_tally(evm,i1,i2,i3,i4,edihedral,f1,f3,f4, + vb1x,vb1y,vb1z,vb2x,vb2y,vb2z,vb3x,vb3y,vb3z); + + // 1-4 LJ and Coulomb interactions + // tally energy/virial in pair, using newton_bond as newton flag + + if (d_weight[type] > 0.0) { + const int itype = atomtype[i1]; + const int jtype = atomtype[i4]; + + const F_FLOAT delx = x(i1,0) - x(i4,0); + const F_FLOAT dely = x(i1,1) - x(i4,1); + const F_FLOAT delz = x(i1,2) - x(i4,2); + const F_FLOAT rsq = delx*delx + dely*dely + delz*delz; + const F_FLOAT r2inv = 1.0/rsq; + const F_FLOAT r6inv = r2inv*r2inv*r2inv; + + F_FLOAT forcecoul; + if (implicit) forcecoul = qqrd2e * q[i1]*q[i4]*r2inv; + else forcecoul = qqrd2e * q[i1]*q[i4]*sqrt(r2inv); + const F_FLOAT forcelj = r6inv * (d_lj14_1(itype,jtype)*r6inv - d_lj14_2(itype,jtype)); + const F_FLOAT fpair = d_weight[type] * (forcelj+forcecoul)*r2inv; + + const F_FLOAT r = sqrt(rsq); + F_FLOAT ecoul = 0.0; + F_FLOAT evdwl = 0.0; + F_FLOAT evdwl14_12, evdwl14_6; + if (eflag) { + if (dihedflag) + ecoul = d_weight[type] * forcecoul; + else + ecoul = d_weight[type] * qqrd2e * q[i1] * q[i4] * + (sqrt(r2inv) + r * cut_coulinv14 * cut_coulinv14 - 2.0 * cut_coulinv14); + evdwl14_12 = r6inv * d_lj14_3(itype,jtype) * r6inv - + d_lj14_3(itype,jtype) * cut_lj_inner6inv * cut_lj6inv; + evdwl14_6 = + -d_lj14_4(itype,jtype) * r6inv + d_lj14_4(itype,jtype) * cut_lj_inner3inv * cut_lj3inv; + evdwl = evdwl14_12 + evdwl14_6; + evdwl *= d_weight[type]; + } + + if (newton_bond || i1 < nlocal) { + a_f(i1,0) += delx*fpair; + a_f(i1,1) += dely*fpair; + a_f(i1,2) += delz*fpair; + } + if (newton_bond || i4 < nlocal) { + a_f(i4,0) -= delx*fpair; + a_f(i4,1) -= dely*fpair; + a_f(i4,2) -= delz*fpair; + } + + if (EVFLAG) ev_tally(evm,i1,i4,evdwl,ecoul,fpair,delx,dely,delz); + } +} + +template +template +KOKKOS_INLINE_FUNCTION +void DihedralCharmmfswKokkos::operator()(TagDihedralCharmmfswCompute, const int &n) const { + EVM_FLOAT evm; + this->template operator()(TagDihedralCharmmfswCompute(), n, evm); +} + +/* ---------------------------------------------------------------------- */ + +template +void DihedralCharmmfswKokkos::allocate() +{ + DihedralCharmmfsw::allocate(); +} + +/* ---------------------------------------------------------------------- + set coeffs for one or more types +------------------------------------------------------------------------- */ + +template +void DihedralCharmmfswKokkos::coeff(int narg, char **arg) +{ + DihedralCharmmfsw::coeff(narg, arg); + + int nd = atom->ndihedraltypes; + typename AT::tdual_ffloat_1d k_k("DihedralCharmmfsw::k",nd+1); + typename AT::tdual_ffloat_1d k_multiplicity("DihedralCharmmfsw::multiplicity",nd+1); + typename AT::tdual_ffloat_1d k_shift("DihedralCharmmfsw::shift",nd+1); + typename AT::tdual_ffloat_1d k_cos_shift("DihedralCharmmfsw::cos_shift",nd+1); + typename AT::tdual_ffloat_1d k_sin_shift("DihedralCharmmfsw::sin_shift",nd+1); + typename AT::tdual_ffloat_1d k_weight("DihedralCharmmfsw::weight",nd+1); + + d_k = k_k.template view(); + d_multiplicity = k_multiplicity.template view(); + d_shift = k_shift.template view(); + d_cos_shift = k_cos_shift.template view(); + d_sin_shift = k_sin_shift.template view(); + d_weight = k_weight.template view(); + + int n = atom->ndihedraltypes; + for (int i = 1; i <= n; i++) { + k_k.h_view[i] = k[i]; + k_multiplicity.h_view[i] = multiplicity[i]; + k_shift.h_view[i] = shift[i]; + k_cos_shift.h_view[i] = cos_shift[i]; + k_sin_shift.h_view[i] = sin_shift[i]; + k_weight.h_view[i] = weight[i]; + } + + k_k.template modify(); + k_multiplicity.template modify(); + k_shift.template modify(); + k_cos_shift.template modify(); + k_sin_shift.template modify(); + k_weight.template modify(); + + k_k.template sync(); + k_multiplicity.template sync(); + k_shift.template sync(); + k_cos_shift.template sync(); + k_sin_shift.template sync(); + k_weight.template sync(); +} + +/* ---------------------------------------------------------------------- + error check and initialize all values needed for force computation +------------------------------------------------------------------------- */ + +template +void DihedralCharmmfswKokkos::init_style() +{ + DihedralCharmmfsw::init_style(); + + int n = atom->ntypes; + DAT::tdual_ffloat_2d k_lj14_1("DihedralCharmmfsw:lj14_1",n+1,n+1); + DAT::tdual_ffloat_2d k_lj14_2("DihedralCharmmfsw:lj14_2",n+1,n+1); + DAT::tdual_ffloat_2d k_lj14_3("DihedralCharmmfsw:lj14_3",n+1,n+1); + DAT::tdual_ffloat_2d k_lj14_4("DihedralCharmmfsw:lj14_4",n+1,n+1); + + d_lj14_1 = k_lj14_1.template view(); + d_lj14_2 = k_lj14_2.template view(); + d_lj14_3 = k_lj14_3.template view(); + d_lj14_4 = k_lj14_4.template view(); + + + if (weightflag) { + int n = atom->ntypes; + for (int i = 1; i <= n; i++) { + for (int j = 1; j <= n; j++) { + k_lj14_1.h_view(i,j) = lj14_1[i][j]; + k_lj14_2.h_view(i,j) = lj14_2[i][j]; + k_lj14_3.h_view(i,j) = lj14_3[i][j]; + k_lj14_4.h_view(i,j) = lj14_4[i][j]; + } + } + } + + k_lj14_1.template modify(); + k_lj14_2.template modify(); + k_lj14_3.template modify(); + k_lj14_4.template modify(); + + k_lj14_1.template sync(); + k_lj14_2.template sync(); + k_lj14_3.template sync(); + k_lj14_4.template sync(); +} + +/* ---------------------------------------------------------------------- + proc 0 reads coeffs from restart file, bcasts them +------------------------------------------------------------------------- */ + +template +void DihedralCharmmfswKokkos::read_restart(FILE *fp) +{ + DihedralCharmmfsw::read_restart(fp); + + int nd = atom->ndihedraltypes; + typename AT::tdual_ffloat_1d k_k("DihedralCharmmfsw::k",nd+1); + typename AT::tdual_ffloat_1d k_multiplicity("DihedralCharmmfsw::multiplicity",nd+1); + typename AT::tdual_ffloat_1d k_shift("DihedralCharmmfsw::shift",nd+1); + typename AT::tdual_ffloat_1d k_cos_shift("DihedralCharmmfsw::cos_shift",nd+1); + typename AT::tdual_ffloat_1d k_sin_shift("DihedralCharmmfsw::sin_shift",nd+1); + typename AT::tdual_ffloat_1d k_weight("DihedralCharmmfsw::weight",nd+1); + + d_k = k_k.template view(); + d_multiplicity = k_multiplicity.template view(); + d_shift = k_shift.template view(); + d_cos_shift = k_cos_shift.template view(); + d_sin_shift = k_sin_shift.template view(); + d_weight = k_weight.template view(); + + int n = atom->ndihedraltypes; + for (int i = 1; i <= n; i++) { + k_k.h_view[i] = k[i]; + k_multiplicity.h_view[i] = multiplicity[i]; + k_shift.h_view[i] = shift[i]; + k_cos_shift.h_view[i] = cos_shift[i]; + k_sin_shift.h_view[i] = sin_shift[i]; + k_weight.h_view[i] = weight[i]; + } + + k_k.template modify(); + k_multiplicity.template modify(); + k_shift.template modify(); + k_cos_shift.template modify(); + k_sin_shift.template modify(); + k_weight.template modify(); + + k_k.template sync(); + k_multiplicity.template sync(); + k_shift.template sync(); + k_cos_shift.template sync(); + k_sin_shift.template sync(); + k_weight.template sync(); +} + +/* ---------------------------------------------------------------------- + tally energy and virial into global and per-atom accumulators + virial = r1F1 + r2F2 + r3F3 + r4F4 = (r1-r2) F1 + (r3-r2) F3 + (r4-r2) F4 + = (r1-r2) F1 + (r3-r2) F3 + (r4-r3 + r3-r2) F4 + = vb1*f1 + vb2*f3 + (vb3+vb2)*f4 +------------------------------------------------------------------------- */ + +template +//template +KOKKOS_INLINE_FUNCTION +void DihedralCharmmfswKokkos::ev_tally(EVM_FLOAT &evm, const int i1, const int i2, const int i3, const int i4, + F_FLOAT &edihedral, F_FLOAT *f1, F_FLOAT *f3, F_FLOAT *f4, + const F_FLOAT &vb1x, const F_FLOAT &vb1y, const F_FLOAT &vb1z, + const F_FLOAT &vb2x, const F_FLOAT &vb2y, const F_FLOAT &vb2z, + const F_FLOAT &vb3x, const F_FLOAT &vb3y, const F_FLOAT &vb3z) const +{ + E_FLOAT edihedralquarter; + F_FLOAT v[6]; + + if (eflag_either) { + if (eflag_global) { + if (newton_bond) evm.emol += edihedral; + else { + edihedralquarter = 0.25*edihedral; + if (i1 < nlocal) evm.emol += edihedralquarter; + if (i2 < nlocal) evm.emol += edihedralquarter; + if (i3 < nlocal) evm.emol += edihedralquarter; + if (i4 < nlocal) evm.emol += edihedralquarter; + } + } + if (eflag_atom) { + edihedralquarter = 0.25*edihedral; + if (newton_bond || i1 < nlocal) d_eatom[i1] += edihedralquarter; + if (newton_bond || i2 < nlocal) d_eatom[i2] += edihedralquarter; + if (newton_bond || i3 < nlocal) d_eatom[i3] += edihedralquarter; + if (newton_bond || i4 < nlocal) d_eatom[i4] += edihedralquarter; + } + } + + if (vflag_either) { + v[0] = vb1x*f1[0] + vb2x*f3[0] + (vb3x+vb2x)*f4[0]; + v[1] = vb1y*f1[1] + vb2y*f3[1] + (vb3y+vb2y)*f4[1]; + v[2] = vb1z*f1[2] + vb2z*f3[2] + (vb3z+vb2z)*f4[2]; + v[3] = vb1x*f1[1] + vb2x*f3[1] + (vb3x+vb2x)*f4[1]; + v[4] = vb1x*f1[2] + vb2x*f3[2] + (vb3x+vb2x)*f4[2]; + v[5] = vb1y*f1[2] + vb2y*f3[2] + (vb3y+vb2y)*f4[2]; + + if (vflag_global) { + if (newton_bond) { + evm.v[0] += v[0]; + evm.v[1] += v[1]; + evm.v[2] += v[2]; + evm.v[3] += v[3]; + evm.v[4] += v[4]; + evm.v[5] += v[5]; + } else { + if (i1 < nlocal) { + evm.v[0] += 0.25*v[0]; + evm.v[1] += 0.25*v[1]; + evm.v[2] += 0.25*v[2]; + evm.v[3] += 0.25*v[3]; + evm.v[4] += 0.25*v[4]; + evm.v[5] += 0.25*v[5]; + } + if (i2 < nlocal) { + evm.v[0] += 0.25*v[0]; + evm.v[1] += 0.25*v[1]; + evm.v[2] += 0.25*v[2]; + evm.v[3] += 0.25*v[3]; + evm.v[4] += 0.25*v[4]; + evm.v[5] += 0.25*v[5]; + } + if (i3 < nlocal) { + evm.v[0] += 0.25*v[0]; + evm.v[1] += 0.25*v[1]; + evm.v[2] += 0.25*v[2]; + evm.v[3] += 0.25*v[3]; + evm.v[4] += 0.25*v[4]; + evm.v[5] += 0.25*v[5]; + } + if (i4 < nlocal) { + evm.v[0] += 0.25*v[0]; + evm.v[1] += 0.25*v[1]; + evm.v[2] += 0.25*v[2]; + evm.v[3] += 0.25*v[3]; + evm.v[4] += 0.25*v[4]; + evm.v[5] += 0.25*v[5]; + } + } + } + + if (vflag_atom) { + if (newton_bond || i1 < nlocal) { + d_vatom(i1,0) += 0.25*v[0]; + d_vatom(i1,1) += 0.25*v[1]; + d_vatom(i1,2) += 0.25*v[2]; + d_vatom(i1,3) += 0.25*v[3]; + d_vatom(i1,4) += 0.25*v[4]; + d_vatom(i1,5) += 0.25*v[5]; + } + if (newton_bond || i2 < nlocal) { + d_vatom(i2,0) += 0.25*v[0]; + d_vatom(i2,1) += 0.25*v[1]; + d_vatom(i2,2) += 0.25*v[2]; + d_vatom(i2,3) += 0.25*v[3]; + d_vatom(i2,4) += 0.25*v[4]; + d_vatom(i2,5) += 0.25*v[5]; + } + if (newton_bond || i3 < nlocal) { + d_vatom(i3,0) += 0.25*v[0]; + d_vatom(i3,1) += 0.25*v[1]; + d_vatom(i3,2) += 0.25*v[2]; + d_vatom(i3,3) += 0.25*v[3]; + d_vatom(i3,4) += 0.25*v[4]; + d_vatom(i3,5) += 0.25*v[5]; + } + if (newton_bond || i4 < nlocal) { + d_vatom(i4,0) += 0.25*v[0]; + d_vatom(i4,1) += 0.25*v[1]; + d_vatom(i4,2) += 0.25*v[2]; + d_vatom(i4,3) += 0.25*v[3]; + d_vatom(i4,4) += 0.25*v[4]; + d_vatom(i4,5) += 0.25*v[5]; + } + } + } +} + +/* ---------------------------------------------------------------------- + tally eng_vdwl and virial into global and per-atom accumulators + need i < nlocal test since called by bond_quartic and dihedral_charmm +------------------------------------------------------------------------- */ + +template +KOKKOS_INLINE_FUNCTION +void DihedralCharmmfswKokkos::ev_tally(EVM_FLOAT &evm, const int i, const int j, + const F_FLOAT &evdwl, const F_FLOAT &ecoul, const F_FLOAT &fpair, const F_FLOAT &delx, + const F_FLOAT &dely, const F_FLOAT &delz) const +{ + E_FLOAT evdwlhalf,ecoulhalf,epairhalf; + F_FLOAT v[6]; + + + if (eflag_either) { + if (eflag_global) { + if (newton_bond) { + evm.evdwl += evdwl; + evm.ecoul += ecoul; + } else { + evdwlhalf = 0.5*evdwl; + ecoulhalf = 0.5*ecoul; + if (i < nlocal) { + evm.evdwl += evdwlhalf; + evm.ecoul += ecoulhalf; + } + if (j < nlocal) { + evm.evdwl += evdwlhalf; + evm.ecoul += ecoulhalf; + } + } + } + if (eflag_atom) { + epairhalf = 0.5 * (evdwl + ecoul); + if (newton_bond || i < nlocal) d_eatom_pair[i] += epairhalf; + if (newton_bond || j < nlocal) d_eatom_pair[j] += epairhalf; + } + } + + if (vflag_either) { + v[0] = delx*delx*fpair; + v[1] = dely*dely*fpair; + v[2] = delz*delz*fpair; + v[3] = delx*dely*fpair; + v[4] = delx*delz*fpair; + v[5] = dely*delz*fpair; + + if (vflag_global) { + if (newton_bond) { + evm.vp[0] += v[0]; + evm.vp[1] += v[1]; + evm.vp[2] += v[2]; + evm.vp[3] += v[3]; + evm.vp[4] += v[4]; + evm.vp[5] += v[5]; + } else { + if (i < nlocal) { + evm.vp[0] += 0.5*v[0]; + evm.vp[1] += 0.5*v[1]; + evm.vp[2] += 0.5*v[2]; + evm.vp[3] += 0.5*v[3]; + evm.vp[4] += 0.5*v[4]; + evm.vp[5] += 0.5*v[5]; + } + if (j < nlocal) { + evm.vp[0] += 0.5*v[0]; + evm.vp[1] += 0.5*v[1]; + evm.vp[2] += 0.5*v[2]; + evm.vp[3] += 0.5*v[3]; + evm.vp[4] += 0.5*v[4]; + evm.vp[5] += 0.5*v[5]; + } + } + } + + if (vflag_atom) { + if (newton_bond || i < nlocal) { + d_vatom_pair(i,0) += 0.5*v[0]; + d_vatom_pair(i,1) += 0.5*v[1]; + d_vatom_pair(i,2) += 0.5*v[2]; + d_vatom_pair(i,3) += 0.5*v[3]; + d_vatom_pair(i,4) += 0.5*v[4]; + d_vatom_pair(i,5) += 0.5*v[5]; + } + if (newton_bond || j < nlocal) { + d_vatom_pair(j,0) += 0.5*v[0]; + d_vatom_pair(j,1) += 0.5*v[1]; + d_vatom_pair(j,2) += 0.5*v[2]; + d_vatom_pair(j,3) += 0.5*v[3]; + d_vatom_pair(j,4) += 0.5*v[4]; + d_vatom_pair(j,5) += 0.5*v[5]; + } + } + } +} + +/* ---------------------------------------------------------------------- */ + +namespace LAMMPS_NS { +template class DihedralCharmmfswKokkos; +#ifdef LMP_KOKKOS_GPU +template class DihedralCharmmfswKokkos; +#endif +} + diff --git a/src/KOKKOS/dihedral_charmmfsw_kokkos.h b/src/KOKKOS/dihedral_charmmfsw_kokkos.h new file mode 100644 index 0000000000..b1c65ae477 --- /dev/null +++ b/src/KOKKOS/dihedral_charmmfsw_kokkos.h @@ -0,0 +1,118 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + LAMMPS development team: developers@lammps.org + + 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. +------------------------------------------------------------------------- */ + +#ifdef DIHEDRAL_CLASS +// clang-format off +DihedralStyle(charmmfsw/kk,DihedralCharmmfswKokkos); +DihedralStyle(charmmfsw/kk/device,DihedralCharmmfswKokkos); +DihedralStyle(charmmfsw/kk/host,DihedralCharmmfswKokkos); +// clang-format on +#else + +// clang-format off +#ifndef LMP_DIHEDRAL_CHARMMFSW_KOKKOS_H +#define LMP_DIHEDRAL_CHARMMFSW_KOKKOS_H + +#include "dihedral_charmmfsw.h" +#include "kokkos_type.h" +#include "dihedral_charmm_kokkos.h" // needed for s_EVM_FLOAT + +namespace LAMMPS_NS { + +template +struct TagDihedralCharmmfswCompute{}; + +template +class DihedralCharmmfswKokkos : public DihedralCharmmfsw { + public: + typedef DeviceType device_type; + typedef EVM_FLOAT value_type; + typedef ArrayTypes AT; + + DihedralCharmmfswKokkos(class LAMMPS *); + ~DihedralCharmmfswKokkos() override; + void compute(int, int) override; + void coeff(int, char **) override; + void init_style() override; + void read_restart(FILE *) override; + + template + KOKKOS_INLINE_FUNCTION + void operator()(TagDihedralCharmmfswCompute, const int&, EVM_FLOAT&) const; + + template + KOKKOS_INLINE_FUNCTION + void operator()(TagDihedralCharmmfswCompute, const int&) const; + + //template + KOKKOS_INLINE_FUNCTION + void ev_tally(EVM_FLOAT &evm, const int i1, const int i2, const int i3, const int i4, + F_FLOAT &edihedral, F_FLOAT *f1, F_FLOAT *f3, F_FLOAT *f4, + const F_FLOAT &vb1x, const F_FLOAT &vb1y, const F_FLOAT &vb1z, + const F_FLOAT &vb2x, const F_FLOAT &vb2y, const F_FLOAT &vb2z, + const F_FLOAT &vb3x, const F_FLOAT &vb3y, const F_FLOAT &vb3z) const; + + KOKKOS_INLINE_FUNCTION + void ev_tally(EVM_FLOAT &evm, const int i, const int j, + const F_FLOAT &evdwl, const F_FLOAT &ecoul, const F_FLOAT &fpair, const F_FLOAT &delx, + const F_FLOAT &dely, const F_FLOAT &delz) const; + + protected: + + class NeighborKokkos *neighborKK; + + typename AT::t_x_array_randomread x; + typename AT::t_int_1d_randomread atomtype; + typename AT::t_ffloat_1d_randomread q; + typename AT::t_f_array f; + typename AT::t_int_2d dihedrallist; + + typedef typename KKDevice::value KKDeviceType; + Kokkos::DualView k_eatom; + Kokkos::DualView k_vatom; + Kokkos::View > d_eatom; + Kokkos::View > d_vatom; + + Kokkos::DualView k_eatom_pair; + Kokkos::DualView k_vatom_pair; + Kokkos::View > d_eatom_pair; + Kokkos::View > d_vatom_pair; + + int nlocal,newton_bond; + int eflag,vflag; + double qqrd2e; + + Kokkos::DualView k_warning_flag; + typename Kokkos::DualView::t_dev d_warning_flag; + typename Kokkos::DualView::t_host h_warning_flag; + + typename AT::t_ffloat_2d d_lj14_1; + typename AT::t_ffloat_2d d_lj14_2; + typename AT::t_ffloat_2d d_lj14_3; + typename AT::t_ffloat_2d d_lj14_4; + + typename AT::t_ffloat_1d d_k; + typename AT::t_ffloat_1d d_multiplicity; + typename AT::t_ffloat_1d d_shift; + typename AT::t_ffloat_1d d_sin_shift; + typename AT::t_ffloat_1d d_cos_shift; + typename AT::t_ffloat_1d d_weight; + + void allocate() override; +}; + +} + +#endif +#endif + diff --git a/src/KOKKOS/dihedral_class2_kokkos.cpp b/src/KOKKOS/dihedral_class2_kokkos.cpp index 2d6032600b..204a6d0d1a 100644 --- a/src/KOKKOS/dihedral_class2_kokkos.cpp +++ b/src/KOKKOS/dihedral_class2_kokkos.cpp @@ -30,9 +30,8 @@ using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 -#define SMALLER 0.00001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/dihedral_harmonic_kokkos.cpp b/src/KOKKOS/dihedral_harmonic_kokkos.cpp index 8ca0b368df..78860800be 100644 --- a/src/KOKKOS/dihedral_harmonic_kokkos.cpp +++ b/src/KOKKOS/dihedral_harmonic_kokkos.cpp @@ -30,9 +30,7 @@ using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 -#define SMALLER 0.00001 +static constexpr double TOLERANCE = 0.05; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/dihedral_opls_kokkos.cpp b/src/KOKKOS/dihedral_opls_kokkos.cpp index 670faa9e84..ce7502b25a 100644 --- a/src/KOKKOS/dihedral_opls_kokkos.cpp +++ b/src/KOKKOS/dihedral_opls_kokkos.cpp @@ -30,9 +30,9 @@ using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 -#define SMALLER 0.00001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; +static constexpr double SMALLER = 0.00001; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/domain_kokkos.cpp b/src/KOKKOS/domain_kokkos.cpp index 6311d45a3f..aecc12cd12 100644 --- a/src/KOKKOS/domain_kokkos.cpp +++ b/src/KOKKOS/domain_kokkos.cpp @@ -22,8 +22,7 @@ using namespace LAMMPS_NS; -#define BIG 1.0e20 -#define SMALL 1.0e-4 +static constexpr double BIG = 1.0e20; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/dynamical_matrix_kokkos.cpp b/src/KOKKOS/dynamical_matrix_kokkos.cpp index ec2cc17ef2..e4c454c7f2 100644 --- a/src/KOKKOS/dynamical_matrix_kokkos.cpp +++ b/src/KOKKOS/dynamical_matrix_kokkos.cpp @@ -23,27 +23,18 @@ #include "atom_masks.h" #include "bond.h" #include "comm.h" -#include "compute.h" #include "dihedral.h" #include "domain.h" -#include "error.h" -#include "finish.h" #include "force.h" -#include "group.h" #include "improper.h" #include "kokkos.h" #include "kspace.h" -#include "memory.h" #include "modify.h" #include "neighbor.h" #include "pair.h" #include "timer.h" #include "update.h" -#include -#include -#include - using namespace LAMMPS_NS; enum{REGULAR,ESKM}; diff --git a/src/KOKKOS/fft3d_kokkos.cpp b/src/KOKKOS/fft3d_kokkos.cpp index 82e4140f77..5caed42f43 100644 --- a/src/KOKKOS/fft3d_kokkos.cpp +++ b/src/KOKKOS/fft3d_kokkos.cpp @@ -13,8 +13,9 @@ ------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- - Contributing authors: Stan Moore (SNL), Sam Mish (U.C. Davis) + Contributing authors: Stan Moore (SNL), Sam Mish (U.C. Davis), Nick Hagerty (ORNL) ------------------------------------------------------------------------- */ + #include "fft3d_kokkos.h" #include "error.h" @@ -25,9 +26,6 @@ using namespace LAMMPS_NS; -#define MIN(A,B) ((A) < (B) ? (A) : (B)) -#define MAX(A,B) ((A) > (B) ? (A) : (B)) - /* ---------------------------------------------------------------------- */ template @@ -37,27 +35,27 @@ FFT3dKokkos::FFT3dKokkos(LAMMPS *lmp, MPI_Comm comm, int nfast, int int out_ilo, int out_ihi, int out_jlo, int out_jhi, int out_klo, int out_khi, int scaled, int permute, int *nbuf, int usecollective, - int usecuda_aware) : + int usegpu_aware) : Pointers(lmp) { int nthreads = lmp->kokkos->nthreads; int ngpus = lmp->kokkos->ngpus; ExecutionSpace execution_space = ExecutionSpaceFromDevice::space; -#if defined(FFT_MKL) +#if defined(FFT_KOKKOS_MKL) if (ngpus > 0 && execution_space == Device) lmp->error->all(FLERR,"Cannot use the MKL library with Kokkos on GPUs"); -#elif defined(FFT_FFTW3) +#elif defined(FFT_KOKKOS_FFTW3) if (ngpus > 0 && execution_space == Device) lmp->error->all(FLERR,"Cannot use the FFTW library with Kokkos on GPUs"); -#elif defined(FFT_CUFFT) +#elif defined(FFT_KOKKOS_CUFFT) if (ngpus > 0 && execution_space == Host) lmp->error->all(FLERR,"Cannot use the cuFFT library with Kokkos on the host CPUs"); -#elif defined(FFT_HIPFFT) +#elif defined(FFT_KOKKOS_HIPFFT) if (ngpus > 0 && execution_space == Host) lmp->error->all(FLERR,"Cannot use the hipFFT library with Kokkos on the host CPUs"); -#elif defined(FFT_KISSFFT) +#elif defined(FFT_KOKKOS_KISS) // The compiler can't statically determine the stack size needed for // recursive function calls in KISS FFT and the default per-thread // stack size on GPUs needs to be increased to prevent stack overflows @@ -73,7 +71,7 @@ FFT3dKokkos::FFT3dKokkos(LAMMPS *lmp, MPI_Comm comm, int nfast, int plan = fft_3d_create_plan_kokkos(comm,nfast,nmid,nslow, in_ilo,in_ihi,in_jlo,in_jhi,in_klo,in_khi, out_ilo,out_ihi,out_jlo,out_jhi,out_klo,out_khi, - scaled,permute,nbuf,usecollective,nthreads,usecuda_aware); + scaled,permute,nbuf,usecollective,nthreads,usegpu_aware); if (plan == nullptr) error->one(FLERR,"Could not create 3d FFT plan"); } @@ -90,8 +88,8 @@ FFT3dKokkos::~FFT3dKokkos() template void FFT3dKokkos::compute(typename FFT_AT::t_FFT_SCALAR_1d d_in, typename FFT_AT::t_FFT_SCALAR_1d d_out, int flag) { - typename FFT_AT::t_FFT_DATA_1d d_in_data((FFT_DATA_POINTER)d_in.data(),d_in.size()/2); - typename FFT_AT::t_FFT_DATA_1d d_out_data((FFT_DATA_POINTER)d_out.data(),d_out.size()/2); + typename FFT_AT::t_FFT_DATA_1d d_in_data((FFT_KOKKOS_DATA_POINTER)d_in.data(),d_in.size()/2); + typename FFT_AT::t_FFT_DATA_1d d_out_data((FFT_KOKKOS_DATA_POINTER)d_out.data(),d_out.size()/2); fft_3d_kokkos(d_in_data,d_out_data,flag,plan); } @@ -101,7 +99,7 @@ void FFT3dKokkos::compute(typename FFT_AT::t_FFT_SCALAR_1d d_in, typ template void FFT3dKokkos::timing1d(typename FFT_AT::t_FFT_SCALAR_1d d_in, int nsize, int flag) { - typename FFT_AT::t_FFT_DATA_1d d_in_data((FFT_DATA_POINTER)d_in.data(),d_in.size()/2); + typename FFT_AT::t_FFT_DATA_1d d_in_data((FFT_KOKKOS_DATA_POINTER)d_in.data(),d_in.size()/2); fft_3d_1d_only_kokkos(d_in_data,nsize,flag,plan); } @@ -149,20 +147,20 @@ public: KOKKOS_INLINE_FUNCTION void operator() (const int &i) const { -#if defined(FFT_FFTW3) || defined(FFT_CUFFT) || defined(FFT_HIPFFT) +#if defined(FFT_KOKKOS_FFTW3) || defined(FFT_KOKKOS_CUFFT) || defined(FFT_KOKKOS_HIPFFT) FFT_SCALAR* out_ptr = (FFT_SCALAR *)(d_out.data()+i); *(out_ptr++) *= norm; *(out_ptr++) *= norm; -#elif defined(FFT_MKL) +#elif defined(FFT_KOKKOS_MKL) d_out(i) *= norm; -#else // FFT_KISS +#else // FFT_KOKKOS_KISS d_out(i).re *= norm; d_out(i).im *= norm; #endif } }; -#ifdef FFT_KISSFFT +#ifdef FFT_KOKKOS_KISS template struct kiss_fft_functor { public: @@ -219,19 +217,19 @@ void FFT3dKokkos::fft_3d_kokkos(typename FFT_AT::t_FFT_DATA_1d d_in, total = plan->total1; length = plan->length1; - #if defined(FFT_MKL) + #if defined(FFT_KOKKOS_MKL) if (flag == 1) DftiComputeForward(plan->handle_fast,d_data.data()); else DftiComputeBackward(plan->handle_fast,d_data.data()); - #elif defined(FFT_FFTW3) + #elif defined(FFT_KOKKOS_FFTW3) if (flag == 1) - FFTW_API(execute_dft)(plan->plan_fast_forward,(FFT_DATA*)d_data.data(),(FFT_DATA*)d_data.data()); + FFTW_API(execute_dft)(plan->plan_fast_forward,(FFT_KOKKOS_DATA*)d_data.data(),(FFT_KOKKOS_DATA*)d_data.data()); else - FFTW_API(execute_dft)(plan->plan_fast_backward,(FFT_DATA*)d_data.data(),(FFT_DATA*)d_data.data()); - #elif defined(FFT_CUFFT) + FFTW_API(execute_dft)(plan->plan_fast_backward,(FFT_KOKKOS_DATA*)d_data.data(),(FFT_KOKKOS_DATA*)d_data.data()); + #elif defined(FFT_KOKKOS_CUFFT) cufftExec(plan->plan_fast,d_data.data(),d_data.data(),-flag); - #elif defined(FFT_HIPFFT) + #elif defined(FFT_KOKKOS_HIPFFT) hipfftExec(plan->plan_fast,d_data.data(),d_data.data(),-flag); #else typename FFT_AT::t_FFT_DATA_1d d_tmp = @@ -265,19 +263,19 @@ void FFT3dKokkos::fft_3d_kokkos(typename FFT_AT::t_FFT_DATA_1d d_in, total = plan->total2; length = plan->length2; - #if defined(FFT_MKL) + #if defined(FFT_KOKKOS_MKL) if (flag == 1) DftiComputeForward(plan->handle_mid,d_data.data()); else DftiComputeBackward(plan->handle_mid,d_data.data()); - #elif defined(FFT_FFTW3) + #elif defined(FFT_KOKKOS_FFTW3) if (flag == 1) - FFTW_API(execute_dft)(plan->plan_mid_forward,(FFT_DATA*)d_data.data(),(FFT_DATA*)d_data.data()); + FFTW_API(execute_dft)(plan->plan_mid_forward,(FFT_KOKKOS_DATA*)d_data.data(),(FFT_KOKKOS_DATA*)d_data.data()); else - FFTW_API(execute_dft)(plan->plan_mid_backward,(FFT_DATA*)d_data.data(),(FFT_DATA*)d_data.data()); - #elif defined(FFT_CUFFT) + FFTW_API(execute_dft)(plan->plan_mid_backward,(FFT_KOKKOS_DATA*)d_data.data(),(FFT_KOKKOS_DATA*)d_data.data()); + #elif defined(FFT_KOKKOS_CUFFT) cufftExec(plan->plan_mid,d_data.data(),d_data.data(),-flag); - #elif defined(FFT_HIPFFT) + #elif defined(FFT_KOKKOS_HIPFFT) hipfftExec(plan->plan_mid,d_data.data(),d_data.data(),-flag); #else d_tmp = typename FFT_AT::t_FFT_DATA_1d(Kokkos::view_alloc("fft_3d:tmp",Kokkos::WithoutInitializing),d_data.extent(0)); @@ -309,19 +307,19 @@ void FFT3dKokkos::fft_3d_kokkos(typename FFT_AT::t_FFT_DATA_1d d_in, total = plan->total3; length = plan->length3; - #if defined(FFT_MKL) + #if defined(FFT_KOKKOS_MKL) if (flag == 1) DftiComputeForward(plan->handle_slow,d_data.data()); else DftiComputeBackward(plan->handle_slow,d_data.data()); - #elif defined(FFT_FFTW3) + #elif defined(FFT_KOKKOS_FFTW3) if (flag == 1) - FFTW_API(execute_dft)(plan->plan_slow_forward,(FFT_DATA*)d_data.data(),(FFT_DATA*)d_data.data()); + FFTW_API(execute_dft)(plan->plan_slow_forward,(FFT_KOKKOS_DATA*)d_data.data(),(FFT_KOKKOS_DATA*)d_data.data()); else - FFTW_API(execute_dft)(plan->plan_slow_backward,(FFT_DATA*)d_data.data(),(FFT_DATA*)d_data.data()); - #elif defined(FFT_CUFFT) + FFTW_API(execute_dft)(plan->plan_slow_backward,(FFT_KOKKOS_DATA*)d_data.data(),(FFT_KOKKOS_DATA*)d_data.data()); + #elif defined(FFT_KOKKOS_CUFFT) cufftExec(plan->plan_slow,d_data.data(),d_data.data(),-flag); - #elif defined(FFT_HIPFFT) + #elif defined(FFT_KOKKOS_HIPFFT) hipfftExec(plan->plan_slow,d_data.data(),d_data.data(),-flag); #else d_tmp = typename FFT_AT::t_FFT_DATA_1d(Kokkos::view_alloc("fft_3d:tmp",Kokkos::WithoutInitializing),d_data.extent(0)); @@ -375,7 +373,7 @@ void FFT3dKokkos::fft_3d_kokkos(typename FFT_AT::t_FFT_DATA_1d d_in, 2 = permute twice = slow->fast, fast->mid, mid->slow nbuf returns size of internal storage buffers used by FFT usecollective use collective MPI operations for remapping data - usecuda_aware use CUDA-Aware MPI or not + usegpu_aware use GPU-Aware MPI or not ------------------------------------------------------------------------- */ template @@ -386,7 +384,7 @@ struct fft_plan_3d_kokkos* FFT3dKokkos::fft_3d_create_pl int out_ilo, int out_ihi, int out_jlo, int out_jhi, int out_klo, int out_khi, int scaled, int permute, int *nbuf, int usecollective, - int nthreads, int usecuda_aware) + int nthreads, int usegpu_aware) { struct fft_plan_3d_kokkos *plan; int me,nprocs; @@ -418,7 +416,6 @@ struct fft_plan_3d_kokkos* FFT3dKokkos::fft_3d_create_pl // not needed if all procs own entire fast axis initially // first indices = distribution after 1st set of FFTs - if (in_ilo == 0 && in_ihi == nfast-1) flag = 0; else flag = 1; @@ -444,7 +441,7 @@ struct fft_plan_3d_kokkos* FFT3dKokkos::fft_3d_create_pl remapKK->remap_3d_create_plan_kokkos(comm,in_ilo,in_ihi,in_jlo,in_jhi,in_klo,in_khi, first_ilo,first_ihi,first_jlo,first_jhi, first_klo,first_khi,2,0,0,FFT_PRECISION, - usecollective,usecuda_aware); + usecollective,usegpu_aware); if (plan->pre_plan == nullptr) return nullptr; } @@ -469,7 +466,7 @@ struct fft_plan_3d_kokkos* FFT3dKokkos::fft_3d_create_pl first_klo,first_khi, second_ilo,second_ihi,second_jlo,second_jhi, second_klo,second_khi,2,1,0,FFT_PRECISION, - usecollective,usecuda_aware); + usecollective,usegpu_aware); if (plan->mid1_plan == nullptr) return nullptr; // 1d FFTs along mid axis @@ -510,7 +507,7 @@ struct fft_plan_3d_kokkos* FFT3dKokkos::fft_3d_create_pl second_ilo,second_ihi, third_jlo,third_jhi,third_klo,third_khi, third_ilo,third_ihi,2,1,0,FFT_PRECISION, - usecollective,usecuda_aware); + usecollective,usegpu_aware); if (plan->mid2_plan == nullptr) return nullptr; // 1d FFTs along slow axis @@ -538,7 +535,7 @@ struct fft_plan_3d_kokkos* FFT3dKokkos::fft_3d_create_pl third_jlo,third_jhi, out_klo,out_khi,out_ilo,out_ihi, out_jlo,out_jhi,2,(permute+1)%3,0,FFT_PRECISION, - usecollective,usecuda_aware); + usecollective,usegpu_aware); if (plan->post_plan == nullptr) return nullptr; } @@ -609,46 +606,46 @@ struct fft_plan_3d_kokkos* FFT3dKokkos::fft_3d_create_pl // system specific pre-computation of 1d FFT coeffs // and scaling normalization -#if defined(FFT_MKL) - DftiCreateDescriptor( &(plan->handle_fast), FFT_MKL_PREC, DFTI_COMPLEX, 1, +#if defined(FFT_KOKKOS_MKL) + DftiCreateDescriptor( &(plan->handle_fast), FFT_KOKKOS_MKL_PREC, DFTI_COMPLEX, 1, (MKL_LONG)nfast); DftiSetValue(plan->handle_fast, DFTI_NUMBER_OF_TRANSFORMS, (MKL_LONG)plan->total1/nfast); DftiSetValue(plan->handle_fast, DFTI_PLACEMENT,DFTI_INPLACE); DftiSetValue(plan->handle_fast, DFTI_INPUT_DISTANCE, (MKL_LONG)nfast); DftiSetValue(plan->handle_fast, DFTI_OUTPUT_DISTANCE, (MKL_LONG)nfast); -#if defined(FFT_MKL_THREADS) +#if defined(FFT_KOKKOS_MKL_THREADS) DftiSetValue(plan->handle_fast, DFTI_NUMBER_OF_USER_THREADS, nthreads); #endif DftiCommitDescriptor(plan->handle_fast); - DftiCreateDescriptor( &(plan->handle_mid), FFT_MKL_PREC, DFTI_COMPLEX, 1, + DftiCreateDescriptor( &(plan->handle_mid), FFT_KOKKOS_MKL_PREC, DFTI_COMPLEX, 1, (MKL_LONG)nmid); DftiSetValue(plan->handle_mid, DFTI_NUMBER_OF_TRANSFORMS, (MKL_LONG)plan->total2/nmid); DftiSetValue(plan->handle_mid, DFTI_PLACEMENT,DFTI_INPLACE); DftiSetValue(plan->handle_mid, DFTI_INPUT_DISTANCE, (MKL_LONG)nmid); DftiSetValue(plan->handle_mid, DFTI_OUTPUT_DISTANCE, (MKL_LONG)nmid); -#if defined(FFT_MKL_THREADS) +#if defined(FFT_KOKKOS_MKL_THREADS) DftiSetValue(plan->handle_mid, DFTI_NUMBER_OF_USER_THREADS, nthreads); #endif DftiCommitDescriptor(plan->handle_mid); - DftiCreateDescriptor( &(plan->handle_slow), FFT_MKL_PREC, DFTI_COMPLEX, 1, + DftiCreateDescriptor( &(plan->handle_slow), FFT_KOKKOS_MKL_PREC, DFTI_COMPLEX, 1, (MKL_LONG)nslow); DftiSetValue(plan->handle_slow, DFTI_NUMBER_OF_TRANSFORMS, (MKL_LONG)plan->total3/nslow); DftiSetValue(plan->handle_slow, DFTI_PLACEMENT,DFTI_INPLACE); DftiSetValue(plan->handle_slow, DFTI_INPUT_DISTANCE, (MKL_LONG)nslow); DftiSetValue(plan->handle_slow, DFTI_OUTPUT_DISTANCE, (MKL_LONG)nslow); -#if defined(FFT_MKL_THREADS) +#if defined(FFT_KOKKOS_MKL_THREADS) DftiSetValue(plan->handle_slow, DFTI_NUMBER_OF_USER_THREADS, nthreads); #endif DftiCommitDescriptor(plan->handle_slow); -#elif defined(FFT_FFTW3) +#elif defined(FFT_KOKKOS_FFTW3) -#if defined (FFT_FFTW_THREADS) +#if defined (FFT_KOKKOS_FFTW_THREADS) if (nthreads > 1) { FFTW_API(init_threads)(); FFTW_API(plan_with_nthreads)(nthreads); @@ -692,7 +689,7 @@ struct fft_plan_3d_kokkos* FFT3dKokkos::fft_3d_create_pl nullptr,&nslow,1,plan->length3, FFTW_BACKWARD,FFTW_ESTIMATE); -#elif defined(FFT_CUFFT) +#elif defined(FFT_KOKKOS_CUFFT) cufftPlanMany(&(plan->plan_fast), 1, &nfast, &nfast,1,plan->length1, @@ -709,7 +706,7 @@ struct fft_plan_3d_kokkos* FFT3dKokkos::fft_3d_create_pl &nslow,1,plan->length3, CUFFT_TYPE,plan->total3/plan->length3); -#elif defined(FFT_HIPFFT) +#elif defined(FFT_KOKKOS_HIPFFT) hipfftPlanMany(&(plan->plan_fast), 1, &nfast, &nfast,1,plan->length1, @@ -726,7 +723,7 @@ struct fft_plan_3d_kokkos* FFT3dKokkos::fft_3d_create_pl &nslow,1,plan->length3, HIPFFT_TYPE,plan->total3/plan->length3); -#else /* FFT_KISS */ +#else /* FFT_KOKKOS_KISS */ kissfftKK = new KissFFTKokkos(); @@ -781,11 +778,11 @@ void FFT3dKokkos::fft_3d_destroy_plan_kokkos(struct fft_plan_3d_kokk if (plan->mid2_plan) remapKK->remap_3d_destroy_plan_kokkos(plan->mid2_plan); if (plan->post_plan) remapKK->remap_3d_destroy_plan_kokkos(plan->post_plan); -#if defined(FFT_MKL) +#if defined(FFT_KOKKOS_MKL) DftiFreeDescriptor(&(plan->handle_fast)); DftiFreeDescriptor(&(plan->handle_mid)); DftiFreeDescriptor(&(plan->handle_slow)); -#elif defined(FFT_FFTW3) +#elif defined(FFT_KOKKOS_FFTW3) FFTW_API(destroy_plan)(plan->plan_slow_forward); FFTW_API(destroy_plan)(plan->plan_slow_backward); FFTW_API(destroy_plan)(plan->plan_mid_forward); @@ -793,11 +790,11 @@ void FFT3dKokkos::fft_3d_destroy_plan_kokkos(struct fft_plan_3d_kokk FFTW_API(destroy_plan)(plan->plan_fast_forward); FFTW_API(destroy_plan)(plan->plan_fast_backward); -#if defined (FFT_FFTW_THREADS) +#if defined (FFT_KOKKOS_FFTW_THREADS) FFTW_API(cleanup_threads)(); #endif -#elif defined (FFT_KISSFFT) +#elif defined (FFT_KOKKOS_KISS) delete kissfftKK; #endif @@ -855,7 +852,8 @@ void FFT3dKokkos::fft_3d_1d_only_kokkos(typename FFT_AT::t_FFT_DATA_ // fftw3 and Dfti in MKL encode the number of transforms // into the plan, so we cannot operate on a smaller data set -#if defined(FFT_MKL) || defined(FFT_FFTW3) + +#if defined(FFT_KOKKOS_MKL) || defined(FFT_KOKKOS_FFTW3) if ((total1 > nsize) || (total2 > nsize) || (total3 > nsize)) return; #endif @@ -866,7 +864,7 @@ void FFT3dKokkos::fft_3d_1d_only_kokkos(typename FFT_AT::t_FFT_DATA_ // perform 1d FFTs in each of 3 dimensions // data is just an array of 0.0 -#if defined(FFT_MKL) +#if defined(FFT_KOKKOS_MKL) if (flag == -1) { DftiComputeForward(plan->handle_fast,d_data.data()); DftiComputeForward(plan->handle_mid,d_data.data()); @@ -876,21 +874,21 @@ void FFT3dKokkos::fft_3d_1d_only_kokkos(typename FFT_AT::t_FFT_DATA_ DftiComputeBackward(plan->handle_mid,d_data.data()); DftiComputeBackward(plan->handle_slow,d_data.data()); } -#elif defined(FFT_FFTW3) +#elif defined(FFT_KOKKOS_FFTW3) if (flag == -1) { - FFTW_API(execute_dft)(plan->plan_fast_forward,(FFT_DATA*)d_data.data(),(FFT_DATA*)d_data.data()); - FFTW_API(execute_dft)(plan->plan_mid_forward,(FFT_DATA*)d_data.data(),(FFT_DATA*)d_data.data()); - FFTW_API(execute_dft)(plan->plan_slow_forward,(FFT_DATA*)d_data.data(),(FFT_DATA*)d_data.data()); + FFTW_API(execute_dft)(plan->plan_fast_forward,(FFT_KOKKOS_DATA*)d_data.data(),(FFT_KOKKOS_DATA*)d_data.data()); + FFTW_API(execute_dft)(plan->plan_mid_forward,(FFT_KOKKOS_DATA*)d_data.data(),(FFT_KOKKOS_DATA*)d_data.data()); + FFTW_API(execute_dft)(plan->plan_slow_forward,(FFT_KOKKOS_DATA*)d_data.data(),(FFT_KOKKOS_DATA*)d_data.data()); } else { - FFTW_API(execute_dft)(plan->plan_fast_backward,(FFT_DATA*)d_data.data(),(FFT_DATA*)d_data.data()); - FFTW_API(execute_dft)(plan->plan_mid_backward,(FFT_DATA*)d_data.data(),(FFT_DATA*)d_data.data()); - FFTW_API(execute_dft)(plan->plan_slow_backward,(FFT_DATA*)d_data.data(),(FFT_DATA*)d_data.data()); + FFTW_API(execute_dft)(plan->plan_fast_backward,(FFT_KOKKOS_DATA*)d_data.data(),(FFT_KOKKOS_DATA*)d_data.data()); + FFTW_API(execute_dft)(plan->plan_mid_backward,(FFT_KOKKOS_DATA*)d_data.data(),(FFT_KOKKOS_DATA*)d_data.data()); + FFTW_API(execute_dft)(plan->plan_slow_backward,(FFT_KOKKOS_DATA*)d_data.data(),(FFT_KOKKOS_DATA*)d_data.data()); } -#elif defined(FFT_CUFFT) +#elif defined(FFT_KOKKOS_CUFFT) cufftExec(plan->plan_fast,d_data.data(),d_data.data(),-flag); cufftExec(plan->plan_mid,d_data.data(),d_data.data(),-flag); cufftExec(plan->plan_slow,d_data.data(),d_data.data(),-flag); -#elif defined(FFT_HIPFFT) +#elif defined(FFT_KOKKOS_HIPFFT) hipfftExec(plan->plan_fast,d_data.data(),d_data.data(),-flag); hipfftExec(plan->plan_mid,d_data.data(),d_data.data(),-flag); hipfftExec(plan->plan_slow,d_data.data(),d_data.data(),-flag); diff --git a/src/KOKKOS/fft3d_kokkos.h b/src/KOKKOS/fft3d_kokkos.h index a0489f69bb..48b0fd76de 100644 --- a/src/KOKKOS/fft3d_kokkos.h +++ b/src/KOKKOS/fft3d_kokkos.h @@ -45,22 +45,22 @@ struct fft_plan_3d_kokkos { double norm; // normalization factor for rescaling // system specific 1d FFT info -#if defined(FFT_MKL) +#if defined(FFT_KOKKOS_MKL) DFTI_DESCRIPTOR *handle_fast; DFTI_DESCRIPTOR *handle_mid; DFTI_DESCRIPTOR *handle_slow; -#elif defined(FFT_FFTW3) +#elif defined(FFT_KOKKOS_FFTW3) FFTW_API(plan) plan_fast_forward; FFTW_API(plan) plan_fast_backward; FFTW_API(plan) plan_mid_forward; FFTW_API(plan) plan_mid_backward; FFTW_API(plan) plan_slow_forward; FFTW_API(plan) plan_slow_backward; -#elif defined(FFT_CUFFT) +#elif defined(FFT_KOKKOS_CUFFT) cufftHandle plan_fast; cufftHandle plan_mid; cufftHandle plan_slow; -#elif defined(FFT_HIPFFT) +#elif defined(FFT_KOKKOS_HIPFFT) hipfftHandle plan_fast; hipfftHandle plan_mid; hipfftHandle plan_slow; @@ -92,7 +92,7 @@ class FFT3dKokkos : protected Pointers { struct fft_plan_3d_kokkos *plan; RemapKokkos *remapKK; -#ifdef FFT_KISSFFT +#ifdef FFT_KOKKOS_KISS KissFFTKokkos *kissfftKK; #endif diff --git a/src/KOKKOS/fftdata_kokkos.h b/src/KOKKOS/fftdata_kokkos.h index a3812a1cf0..0cb59f49cb 100644 --- a/src/KOKKOS/fftdata_kokkos.h +++ b/src/KOKKOS/fftdata_kokkos.h @@ -12,117 +12,123 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -#include "kokkos_type.h" - -#ifndef MAX -#define MAX(A,B) ((A) > (B) ? (A) : (B)) -#endif - // data types for 2d/3d FFTs #ifndef LMP_FFT_DATA_KOKKOS_H #define LMP_FFT_DATA_KOKKOS_H +#include "kokkos_type.h" #include "lmpfftsettings.h" // ------------------------------------------------------------------------- -// Data types for single-precision complex +// if a user sets FFTW, it means FFTW3 -#if FFT_PRECISION == 1 -#elif FFT_PRECISION == 2 -#else -#error "FFT_PRECISION needs to be either 1 (=single) or 2 (=double)" -#endif - - -// with KOKKOS in CUDA or HIP mode we can only have -// CUFFT/HIPFFT or KISSFFT, thus undefine all other -// FFTs here, since they may be valid in fft3d.cpp - -#ifdef KOKKOS_ENABLE_CUDA -# if defined(FFT_FFTW) -# undef FFT_FFTW +#ifdef LMP_KOKKOS +# ifdef FFT_KOKKOS_FFTW +# undef FFT_KOKKOS_FFTW +# define FFT_KOKKOS_FFTW3 # endif -# if defined(FFT_FFTW3) -# undef FFT_FFTW3 -# endif -# if defined(FFT_MKL) -# undef FFT_MKL -# endif -# if !defined(FFT_CUFFT) && !defined(FFT_KISSFFT) -# define FFT_KISSFFT -# endif -#elif defined(KOKKOS_ENABLE_HIP) -# if defined(FFT_FFTW) -# undef FFT_FFTW -# endif -# if defined(FFT_FFTW3) -# undef FFT_FFTW3 -# endif -# if defined(FFT_MKL) -# undef FFT_MKL -# endif -# if !defined(FFT_HIPFFT) && !defined(FFT_KISSFFT) -# define FFT_KISSFFT -# endif -#else -# if defined(FFT_CUFFT) -# error "Must enable CUDA with KOKKOS to use -DFFT_CUFFT" -# endif -# if defined(FFT_HIPFFT) -# error "Must enable HIP with KOKKOS to use -DFFT_HIPFFT" -# endif -// if user set FFTW, it means FFTW3 -# ifdef FFT_FFTW -# define FFT_FFTW3 -# endif -# ifdef FFT_FFTW_THREADS -# if !defined(FFT_FFTW3) -# error "Must use -DFFT_FFTW3 with -DFFT_FFTW_THREADS" +# ifdef FFT_KOKKOS_FFTW_THREADS +# if !defined(FFT_KOKKOS_FFTW3) +# error "Must use -DFFT_KOKKOS_FFTW3 with -DFFT_KOKKOS_FFTW_THREADS" # endif # endif #endif -#if defined(FFT_MKL) +// with KOKKOS in CUDA or HIP mode we can only have +// CUFFT/HIPFFT or KISS, thus undefine all other +// FFTs here + +#ifdef KOKKOS_ENABLE_CUDA +# if defined(FFT_KOKKOS_FFTW) +# undef FFT_KOKKOS_FFTW +# endif +# if defined(FFT_KOKKOS_FFTW3) +# undef FFT_KOKKOS_FFTW3 +# endif +# if defined(FFT_KOKKOS_MKL) +# undef FFT_KOKKOS_MKL +# endif +# if !defined(FFT_KOKKOS_CUFFT) && !defined(FFT_KOKKOS_KISS) +# define FFT_KOKKOS_KISS +# endif +#elif defined(KOKKOS_ENABLE_HIP) +# if defined(FFT_KOKKOS_FFTW) +# undef FFT_KOKKOS_FFTW +# endif +# if defined(FFT_KOKKOS_FFTW3) +# undef FFT_KOKKOS_FFTW3 +# endif +# if defined(FFT_KOKKOS_MKL) +# undef FFT_KOKKOS_MKL +# endif +# if !defined(FFT_KOKKOS_HIPFFT) && !defined(FFT_KOKKOS_KISS) +# define FFT_KOKKOS_KISS +# endif +#else +# if defined(FFT_KOKKOS_CUFFT) +# error "Must enable CUDA with KOKKOS to use -DFFT_KOKKOS_CUFFT" +# endif +# if defined(FFT_KOKKOS_HIPFFT) +# error "Must enable HIP with KOKKOS to use -DFFT_KOKKOS_HIPFFT" +# endif +#endif + +// set strings for library info output + +#if defined(FFT_KOKKOS_CUFFT) +#define LMP_FFT_KOKKOS_LIB "cuFFT" +#elif defined(FFT_KOKKOS_HIPFFT) +#define LMP_FFT_KOKKOS_LIB "hipFFT" +#elif defined(FFT_KOKKOS_FFTW3) +#define LMP_FFT_KOKKOS_LIB "FFTW3" +#elif defined(FFT_KOKKOS_MKL) +#define LMP_FFT_KOKKOS_LIB "MKL FFT" +#else +#define LMP_FFT_KOKKOS_LIB "KISS FFT" +#endif + + +#if defined(FFT_KOKKOS_MKL) #include "mkl_dfti.h" #if defined(FFT_SINGLE) - typedef float _Complex FFT_DATA; - #define FFT_MKL_PREC DFTI_SINGLE + typedef float _Complex FFT_KOKKOS_DATA; + #define FFT_KOKKOS_MKL_PREC DFTI_SINGLE #else - typedef double _Complex FFT_DATA; - #define FFT_MKL_PREC DFTI_DOUBLE + typedef double _Complex FFT_KOKKOS_DATA; + #define FFT_KOKKOS_MKL_PREC DFTI_DOUBLE #endif -#elif defined(FFT_FFTW3) +#elif defined(FFT_KOKKOS_FFTW3) #include "fftw3.h" #if defined(FFT_SINGLE) - typedef fftwf_complex FFT_DATA; + typedef fftwf_complex FFT_KOKKOS_DATA; #define FFTW_API(function) fftwf_ ## function #else - typedef fftw_complex FFT_DATA; + typedef fftw_complex FFT_KOKKOS_DATA; #define FFTW_API(function) fftw_ ## function #endif -#elif defined(FFT_CUFFT) +#elif defined(FFT_KOKKOS_CUFFT) #include "cufft.h" #if defined(FFT_SINGLE) #define cufftExec cufftExecC2C #define CUFFT_TYPE CUFFT_C2C - typedef cufftComplex FFT_DATA; + typedef cufftComplex FFT_KOKKOS_DATA; #else #define cufftExec cufftExecZ2Z #define CUFFT_TYPE CUFFT_Z2Z - typedef cufftDoubleComplex FFT_DATA; + typedef cufftDoubleComplex FFT_KOKKOS_DATA; #endif -#elif defined(FFT_HIPFFT) +#elif defined(FFT_KOKKOS_HIPFFT) #include #if defined(FFT_SINGLE) #define hipfftExec hipfftExecC2C #define HIPFFT_TYPE HIPFFT_C2C - typedef hipfftComplex FFT_DATA; + typedef hipfftComplex FFT_KOKKOS_DATA; #else #define hipfftExec hipfftExecZ2Z #define HIPFFT_TYPE HIPFFT_Z2Z - typedef hipfftDoubleComplex FFT_DATA; + typedef hipfftDoubleComplex FFT_KOKKOS_DATA; #endif #else #if defined(FFT_SINGLE) @@ -133,17 +139,17 @@ typedef struct { kiss_fft_scalar re; kiss_fft_scalar im; - } FFT_DATA; - #ifndef FFT_KISSFFT - #define FFT_KISSFFT + } FFT_KOKKOS_DATA; + #ifndef FFT_KOKKOS_KISS + #define FFT_KOKKOS_KISS #endif #endif // (double[2]*) is not a 1D pointer -#if defined(FFT_FFTW3) - typedef FFT_SCALAR* FFT_DATA_POINTER; +#if defined(FFT_KOKKOS_FFTW3) + typedef FFT_SCALAR* FFT_KOKKOS_DATA_POINTER; #else - typedef FFT_DATA* FFT_DATA_POINTER; + typedef FFT_KOKKOS_DATA* FFT_KOKKOS_DATA_POINTER; #endif @@ -168,7 +174,7 @@ typedef Kokkos::DualView tdual_ typedef tdual_FFT_SCALAR_3d::t_dev t_FFT_SCALAR_3d; typedef Kokkos:: - DualView tdual_FFT_DATA_1d; + DualView tdual_FFT_DATA_1d; typedef tdual_FFT_DATA_1d::t_dev t_FFT_DATA_1d; typedef tdual_FFT_DATA_1d::t_dev_um t_FFT_DATA_1d_um; @@ -200,7 +206,7 @@ typedef Kokkos::DualView tdual_ typedef tdual_FFT_SCALAR_3d::t_host t_FFT_SCALAR_3d; typedef Kokkos:: - DualView tdual_FFT_DATA_1d; + DualView tdual_FFT_DATA_1d; typedef tdual_FFT_DATA_1d::t_host t_FFT_DATA_1d; typedef tdual_FFT_DATA_1d::t_host_um t_FFT_DATA_1d_um; @@ -216,7 +222,7 @@ typedef struct FFTArrayTypes FFT_DAT; typedef struct FFTArrayTypes FFT_HAT; -#if defined(FFT_KISSFFT) +#if defined(FFT_KOKKOS_KISS) #include "kissfft_kokkos.h" // uses t_FFT_DATA_1d, needs to come last #endif diff --git a/src/KOKKOS/fix_acks2_reaxff_kokkos.cpp b/src/KOKKOS/fix_acks2_reaxff_kokkos.cpp index 9c34908d08..308df20c0e 100644 --- a/src/KOKKOS/fix_acks2_reaxff_kokkos.cpp +++ b/src/KOKKOS/fix_acks2_reaxff_kokkos.cpp @@ -24,13 +24,11 @@ #include "comm.h" #include "error.h" #include "force.h" -#include "integrate.h" #include "kokkos.h" #include "memory_kokkos.h" #include "neigh_list_kokkos.h" #include "neigh_request.h" #include "neighbor.h" -#include "pair_reaxff_kokkos.h" #include "update.h" #include @@ -38,8 +36,7 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define SMALL 0.0001 -#define EV_TO_KCAL_PER_MOL 14.4 +static constexpr double EV_TO_KCAL_PER_MOL = 14.4; /* ---------------------------------------------------------------------- */ @@ -537,7 +534,7 @@ void FixACKS2ReaxFFKokkos::deallocate_array() { memoryKK->destroy_kokkos(k_s,s); memoryKK->destroy_kokkos(k_chi_field,chi_field); - memoryKK->destroy_kokkos(X_diag); + memoryKK->destroy_kokkos(k_X_diag,X_diag); memoryKK->destroy_kokkos(k_d,d); memoryKK->destroy_kokkos(k_q_hat,q_hat); memoryKK->destroy_kokkos(k_y,y); @@ -866,7 +863,7 @@ template KOKKOS_INLINE_FUNCTION void FixACKS2ReaxFFKokkos::compute_x_item(int ii, int &m_fill, const bool &final) const { - // The X_diag array is duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The X_diag array is duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_X_diag = ScatterViewHelper,decltype(dup_X_diag),decltype(ndup_X_diag)>::get(dup_X_diag,ndup_X_diag); auto a_X_diag = v_X_diag.template access>(); @@ -944,7 +941,7 @@ void FixACKS2ReaxFFKokkos::compute_x_team( const typename Kokkos::TeamPolicy::member_type &team, int atoms_per_team, int vector_length) const { - // The X_diag array is duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The X_diag array is duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_X_diag = ScatterViewHelper,decltype(dup_X_diag),decltype(ndup_X_diag)>::get(dup_X_diag,ndup_X_diag); auto a_X_diag = v_X_diag.template access>(); @@ -1458,7 +1455,7 @@ template KOKKOS_INLINE_FUNCTION void FixACKS2ReaxFFKokkos::operator() (TagACKS2SparseMatvec3_Half, const int &ii) const { - // The bb array is duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The bb array is duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_bb = ScatterViewHelper,decltype(dup_bb),decltype(ndup_bb)>::get(dup_bb,ndup_bb); auto a_bb = v_bb.template access>(); diff --git a/src/KOKKOS/fix_acks2_reaxff_kokkos.h b/src/KOKKOS/fix_acks2_reaxff_kokkos.h index c27719c364..cb16b4cd24 100644 --- a/src/KOKKOS/fix_acks2_reaxff_kokkos.h +++ b/src/KOKKOS/fix_acks2_reaxff_kokkos.h @@ -246,9 +246,8 @@ class FixACKS2ReaxFFKokkos : public FixACKS2ReaxFF, public KokkosBase { int count, isuccess; double alpha, beta, omega, cutsq; - int iswap; int first; - typename AT::t_int_2d d_sendlist; + typename AT::t_int_1d d_sendlist; typename AT::t_xfloat_1d_um v_buf; void grow_arrays(int) override; diff --git a/src/KOKKOS/fix_deform_kokkos.cpp b/src/KOKKOS/fix_deform_kokkos.cpp index d49e335986..90c4380da9 100644 --- a/src/KOKKOS/fix_deform_kokkos.cpp +++ b/src/KOKKOS/fix_deform_kokkos.cpp @@ -21,7 +21,6 @@ #include "atom_kokkos.h" #include "atom_masks.h" #include "domain_kokkos.h" -#include "error.h" #include "force.h" #include "input.h" #include "irregular.h" @@ -32,7 +31,6 @@ #include "variable.h" #include -#include using namespace LAMMPS_NS; using namespace FixConst; @@ -120,11 +118,11 @@ void FixDeformKokkos::end_of_step() } else if (set[i].style == WIGGLE) { double delt = (update->ntimestep - update->beginstep) * update->dt; set[i].lo_target = set[i].lo_start - - 0.5*set[i].amplitude * sin(TWOPI*delt/set[i].tperiod); + 0.5*set[i].amplitude * sin(MY_2PI*delt/set[i].tperiod); set[i].hi_target = set[i].hi_start + - 0.5*set[i].amplitude * sin(TWOPI*delt/set[i].tperiod); - h_rate[i] = TWOPI/set[i].tperiod * set[i].amplitude * - cos(TWOPI*delt/set[i].tperiod); + 0.5*set[i].amplitude * sin(MY_2PI*delt/set[i].tperiod); + h_rate[i] = MY_2PI/set[i].tperiod * set[i].amplitude * + cos(MY_2PI*delt/set[i].tperiod); h_ratelo[i] = -0.5*h_rate[i]; } else if (set[i].style == VARIABLE) { double del = input->variable->compute_equal(set[i].hvar); @@ -212,9 +210,9 @@ void FixDeformKokkos::end_of_step() } else if (set[i].style == WIGGLE) { double delt = (update->ntimestep - update->beginstep) * update->dt; set[i].tilt_target = set[i].tilt_start + - set[i].amplitude * sin(TWOPI*delt/set[i].tperiod); - h_rate[i] = TWOPI/set[i].tperiod * set[i].amplitude * - cos(TWOPI*delt/set[i].tperiod); + set[i].amplitude * sin(MY_2PI*delt/set[i].tperiod); + h_rate[i] = MY_2PI/set[i].tperiod * set[i].amplitude * + cos(MY_2PI*delt/set[i].tperiod); } else if (set[i].style == VARIABLE) { double delta_tilt = input->variable->compute_equal(set[i].hvar); set[i].tilt_target = set[i].tilt_start + delta_tilt; diff --git a/src/KOKKOS/fix_dt_reset_kokkos.cpp b/src/KOKKOS/fix_dt_reset_kokkos.cpp index 6e7709ace1..df354f19c8 100644 --- a/src/KOKKOS/fix_dt_reset_kokkos.cpp +++ b/src/KOKKOS/fix_dt_reset_kokkos.cpp @@ -18,19 +18,17 @@ #include "atom_masks.h" #include "error.h" #include "force.h" -#include "input.h" -#include "integrate.h" -#include "kokkos_base.h" -#include "memory_kokkos.h" #include "modify.h" #include "output.h" #include "pair.h" #include "update.h" +#include + using namespace LAMMPS_NS; using namespace FixConst; -#define BIG 1.0e20 +static constexpr double BIG = 1.0e20; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/fix_efield_kokkos.cpp b/src/KOKKOS/fix_efield_kokkos.cpp index ffe1c34e97..4009773982 100644 --- a/src/KOKKOS/fix_efield_kokkos.cpp +++ b/src/KOKKOS/fix_efield_kokkos.cpp @@ -30,8 +30,6 @@ #include "atom_masks.h" #include "kokkos_base.h" -#include - using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/KOKKOS/fix_enforce2d_kokkos.cpp b/src/KOKKOS/fix_enforce2d_kokkos.cpp index 24cf307827..567c6ad160 100644 --- a/src/KOKKOS/fix_enforce2d_kokkos.cpp +++ b/src/KOKKOS/fix_enforce2d_kokkos.cpp @@ -122,7 +122,7 @@ void FixEnforce2DKokkos::post_force(int /*vflag*/) template -template +template KOKKOS_INLINE_FUNCTION void FixEnforce2DKokkos::post_force_item( int i ) const { @@ -130,17 +130,17 @@ void FixEnforce2DKokkos::post_force_item( int i ) const v(i,2) = 0.0; f(i,2) = 0.0; - if (omega_flag) { + if (OMEGA_FLAG) { omega(i,0) = 0.0; omega(i,1) = 0.0; } - if (angmom_flag) { + if (ANGMOM_FLAG) { angmom(i,0) = 0.0; angmom(i,1) = 0.0; } - if (torque_flag) { + if (TORQUE_FLAG) { torque(i,0) = 0.0; torque(i,1) = 0.0; } diff --git a/src/KOKKOS/fix_enforce2d_kokkos.h b/src/KOKKOS/fix_enforce2d_kokkos.h index cd6903f6c9..1c7a33f3b8 100644 --- a/src/KOKKOS/fix_enforce2d_kokkos.h +++ b/src/KOKKOS/fix_enforce2d_kokkos.h @@ -36,7 +36,7 @@ class FixEnforce2DKokkos : public FixEnforce2D { void setup(int) override; void post_force(int) override; - template + template KOKKOS_INLINE_FUNCTION void post_force_item(const int i) const; diff --git a/src/KOKKOS/fix_eos_table_rx_kokkos.cpp b/src/KOKKOS/fix_eos_table_rx_kokkos.cpp index 309eaeeebf..8bf87ca6d3 100644 --- a/src/KOKKOS/fix_eos_table_rx_kokkos.cpp +++ b/src/KOKKOS/fix_eos_table_rx_kokkos.cpp @@ -25,8 +25,6 @@ #include #include "atom_masks.h" -#define MAXLINE 1024 - #ifdef DBL_EPSILON #define MY_EPSILON (10.0*DBL_EPSILON) #else diff --git a/src/KOKKOS/fix_gravity_kokkos.cpp b/src/KOKKOS/fix_gravity_kokkos.cpp index 42a16eda78..01fcc0780c 100644 --- a/src/KOKKOS/fix_gravity_kokkos.cpp +++ b/src/KOKKOS/fix_gravity_kokkos.cpp @@ -16,7 +16,6 @@ #include "atom_kokkos.h" #include "atom_masks.h" -#include "atom_vec.h" #include "input.h" #include "modify.h" #include "update.h" diff --git a/src/KOKKOS/fix_langevin_kokkos.cpp b/src/KOKKOS/fix_langevin_kokkos.cpp index 437dd9daef..e60b1f0ec6 100644 --- a/src/KOKKOS/fix_langevin_kokkos.cpp +++ b/src/KOKKOS/fix_langevin_kokkos.cpp @@ -32,10 +32,8 @@ using namespace LAMMPS_NS; using namespace FixConst; -enum{NOBIAS,BIAS}; -enum{CONSTANT,EQUAL,ATOM}; -#define SINERTIA 0.4 // moment of inertia prefactor for sphere -#define EINERTIA 0.2 // moment of inertia prefactor for ellipsoid +enum { NOBIAS, BIAS }; +enum { CONSTANT, EQUAL, ATOM }; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/fix_langevin_kokkos.h b/src/KOKKOS/fix_langevin_kokkos.h index 4fc22a1df1..fc25a0a748 100644 --- a/src/KOKKOS/fix_langevin_kokkos.h +++ b/src/KOKKOS/fix_langevin_kokkos.h @@ -27,7 +27,6 @@ FixStyle(langevin/kk/host,FixLangevinKokkos); #include "kokkos_type.h" #include "kokkos_base.h" #include "Kokkos_Random.hpp" -#include "comm_kokkos.h" namespace LAMMPS_NS { @@ -103,8 +102,6 @@ namespace LAMMPS_NS { void end_of_step_rmass_item(int) const; private: - class CommKokkos *commKK; - typename ArrayTypes::t_float_1d rmass; typename ArrayTypes::t_float_1d mass; typename ArrayTypes::tdual_double_2d k_franprev; diff --git a/src/KOKKOS/fix_minimize_kokkos.cpp b/src/KOKKOS/fix_minimize_kokkos.cpp index e2106b3d03..585c357992 100644 --- a/src/KOKKOS/fix_minimize_kokkos.cpp +++ b/src/KOKKOS/fix_minimize_kokkos.cpp @@ -19,6 +19,8 @@ #include "domain.h" #include "memory_kokkos.h" +#include + using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/KOKKOS/fix_momentum_kokkos.cpp b/src/KOKKOS/fix_momentum_kokkos.cpp index b9220a417f..fa959cd582 100644 --- a/src/KOKKOS/fix_momentum_kokkos.cpp +++ b/src/KOKKOS/fix_momentum_kokkos.cpp @@ -18,11 +18,8 @@ #include "atom_masks.h" #include "domain_kokkos.h" #include "group.h" -#include "error.h" #include "kokkos_few.h" -#include - using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/KOKKOS/fix_neigh_history_kokkos.cpp b/src/KOKKOS/fix_neigh_history_kokkos.cpp index b4a852ba70..d3df48354e 100644 --- a/src/KOKKOS/fix_neigh_history_kokkos.cpp +++ b/src/KOKKOS/fix_neigh_history_kokkos.cpp @@ -17,7 +17,6 @@ #include "atom_kokkos.h" #include "error.h" #include "memory_kokkos.h" -#include "modify.h" #include "neigh_list_kokkos.h" #include "pair_kokkos.h" #include "atom_vec_kokkos.h" @@ -453,8 +452,12 @@ KOKKOS_INLINE_FUNCTION void FixNeighHistoryKokkos::operator()(TagFixNeighHistoryUnpackExchange, const int &i) const { int index = d_indices(i); + if (index > -1) { int m = (int) d_ubuf(d_buf(i)).i; + if (i >= nrecv1) + m = nextrarecv1 + (int) d_ubuf(d_buf(nextrarecv1 + i - nrecv1)).i; + int n = (int) d_ubuf(d_buf(m++)).i; d_npartner(index) = n; for (int p = 0; p < n; p++) { @@ -471,6 +474,7 @@ void FixNeighHistoryKokkos::operator()(TagFixNeighHistoryUnpackExcha template void FixNeighHistoryKokkos::unpack_exchange_kokkos( DAT::tdual_xfloat_2d &k_buf, DAT::tdual_int_1d &k_indices, int nrecv, + int nrecv1, int nextrarecv1, ExecutionSpace /*space*/) { d_buf = typename AT::t_xfloat_1d_um( @@ -478,6 +482,9 @@ void FixNeighHistoryKokkos::unpack_exchange_kokkos( k_buf.extent(0)*k_buf.extent(1)); d_indices = k_indices.view(); + this->nrecv1 = nrecv1; + this->nextrarecv1 = nextrarecv1; + d_npartner = k_npartner.template view(); d_partner = k_partner.template view(); d_valuepartner = k_valuepartner.template view(); diff --git a/src/KOKKOS/fix_neigh_history_kokkos.h b/src/KOKKOS/fix_neigh_history_kokkos.h index 9c07a953c4..dd1ad769b8 100644 --- a/src/KOKKOS/fix_neigh_history_kokkos.h +++ b/src/KOKKOS/fix_neigh_history_kokkos.h @@ -72,12 +72,14 @@ class FixNeighHistoryKokkos : public FixNeighHistory, public KokkosBase { void unpack_exchange_kokkos(DAT::tdual_xfloat_2d &k_buf, DAT::tdual_int_1d &indices,int nrecv, + int nrecv1,int nrecv1extra, ExecutionSpace space) override; typename DAT::tdual_int_2d k_firstflag; typename DAT::tdual_float_2d k_firstvalue; private: + int nrecv1,nextrarecv1; int nlocal,nsend,beyond_contact; typename AT::t_tagint_1d tag; diff --git a/src/KOKKOS/fix_nh_kokkos.cpp b/src/KOKKOS/fix_nh_kokkos.cpp index 3d2d3ebb71..1b87b3c775 100644 --- a/src/KOKKOS/fix_nh_kokkos.cpp +++ b/src/KOKKOS/fix_nh_kokkos.cpp @@ -18,18 +18,14 @@ #include "fix_nh_kokkos.h" -#include "atom.h" #include "atom_kokkos.h" #include "atom_masks.h" -#include "comm.h" #include "compute.h" #include "domain_kokkos.h" #include "error.h" -#include "fix_deform.h" #include "force.h" #include "irregular.h" #include "kspace.h" -#include "memory_kokkos.h" #include "neighbor.h" #include "update.h" @@ -39,8 +35,8 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define DELTAFLIP 0.1 -#define TILTMAX 1.5 +static constexpr double DELTAFLIP = 0.1; +static constexpr double TILTMAX = 1.5; enum{NOBIAS,BIAS}; enum{NONE,XYZ,XY,YZ,XZ}; diff --git a/src/KOKKOS/fix_nve_kokkos.cpp b/src/KOKKOS/fix_nve_kokkos.cpp index 59cc90c088..11b5184310 100644 --- a/src/KOKKOS/fix_nve_kokkos.cpp +++ b/src/KOKKOS/fix_nve_kokkos.cpp @@ -17,8 +17,6 @@ #include "atom_kokkos.h" #include "atom_masks.h" -#include - using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/KOKKOS/fix_nve_sphere_kokkos.cpp b/src/KOKKOS/fix_nve_sphere_kokkos.cpp index 38f6a40792..aed45c938c 100644 --- a/src/KOKKOS/fix_nve_sphere_kokkos.cpp +++ b/src/KOKKOS/fix_nve_sphere_kokkos.cpp @@ -15,7 +15,8 @@ #include "fix_nve_sphere_kokkos.h" #include "atom_masks.h" #include "atom_kokkos.h" -#include "error.h" + +#include using namespace LAMMPS_NS; diff --git a/src/KOKKOS/fix_nvt_kokkos.cpp b/src/KOKKOS/fix_nvt_kokkos.cpp index 16328c5e3a..7a8badd569 100644 --- a/src/KOKKOS/fix_nvt_kokkos.cpp +++ b/src/KOKKOS/fix_nvt_kokkos.cpp @@ -18,8 +18,6 @@ #include "group.h" #include "modify.h" -#include - using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/KOKKOS/fix_nvt_sllod_kokkos.cpp b/src/KOKKOS/fix_nvt_sllod_kokkos.cpp index 948e3b88f6..ddcc0c728c 100644 --- a/src/KOKKOS/fix_nvt_sllod_kokkos.cpp +++ b/src/KOKKOS/fix_nvt_sllod_kokkos.cpp @@ -18,21 +18,19 @@ #include "fix_nvt_sllod_kokkos.h" -#include "atom.h" -#include "atom.h" #include "atom_kokkos.h" #include "atom_masks.h" #include "compute.h" #include "domain.h" #include "error.h" -#include "fix.h" -#include "fix_deform_kokkos.h" +#include "fix_deform.h" #include "group.h" #include "kokkos_few.h" #include "math_extra.h" -#include "memory_kokkos.h" #include "modify.h" +#include + using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/KOKKOS/fix_property_atom_kokkos.cpp b/src/KOKKOS/fix_property_atom_kokkos.cpp index dcd943cac6..10cea48e90 100644 --- a/src/KOKKOS/fix_property_atom_kokkos.cpp +++ b/src/KOKKOS/fix_property_atom_kokkos.cpp @@ -16,7 +16,6 @@ #include "atom_kokkos.h" #include "atom_masks.h" -#include "error.h" #include "memory_kokkos.h" #include diff --git a/src/KOKKOS/fix_qeq_reaxff_kokkos.cpp b/src/KOKKOS/fix_qeq_reaxff_kokkos.cpp index a2a50d84bb..deb41944bc 100644 --- a/src/KOKKOS/fix_qeq_reaxff_kokkos.cpp +++ b/src/KOKKOS/fix_qeq_reaxff_kokkos.cpp @@ -27,10 +27,8 @@ #include "fix_qeq_reaxff_kokkos.h" -#include "atom.h" #include "atom_kokkos.h" #include "atom_masks.h" -#include "atom_vec_kokkos.h" #include "comm.h" #include "error.h" #include "force.h" @@ -46,8 +44,7 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define SMALL 0.0001 -#define EV_TO_KCAL_PER_MOL 14.4 +static constexpr double EV_TO_KCAL_PER_MOL = 14.4; /* ---------------------------------------------------------------------- */ @@ -928,7 +925,7 @@ void FixQEqReaxFFKokkos::operator()(TagQEqSparseMatvec2_Half,decltype(dup_o),decltype(ndup_o)>::get(dup_o,ndup_o); auto a_o = v_o.template access>(); @@ -1118,12 +1115,11 @@ void FixQEqReaxFFKokkos::operator()(TagQEqCalculateQ, const int &ii) /* ---------------------------------------------------------------------- */ template -int FixQEqReaxFFKokkos::pack_forward_comm_kokkos(int n, DAT::tdual_int_2d k_sendlist, - int iswap_in, DAT::tdual_xfloat_1d &k_buf, +int FixQEqReaxFFKokkos::pack_forward_comm_kokkos(int n, DAT::tdual_int_1d k_sendlist, + DAT::tdual_xfloat_1d &k_buf, int /*pbc_flag*/, int * /*pbc*/) { d_sendlist = k_sendlist.view(); - iswap = iswap_in; d_buf = k_buf.view(); Kokkos::parallel_for(Kokkos::RangePolicy(0,n),*this); if (pack_flag == 3) return n; @@ -1135,7 +1131,7 @@ int FixQEqReaxFFKokkos::pack_forward_comm_kokkos(int n, DAT::tdual_i template KOKKOS_INLINE_FUNCTION void FixQEqReaxFFKokkos::operator()(TagQEqPackForwardComm, const int &i) const { - int j = d_sendlist(iswap, i); + int j = d_sendlist(i); if (pack_flag == 1) { if (!(converged & 1)) @@ -1416,6 +1412,7 @@ KOKKOS_INLINE_FUNCTION void FixQEqReaxFFKokkos::operator()(TagQEqUnpackExchange, const int &i) const { int index = d_indices(i); + if (index > -1) { for (int m = 0; m < nprev; m++) d_s_hist(index,m) = d_buf(i*nprev*2 + m); for (int m = 0; m < nprev; m++) d_t_hist(index,m) = d_buf(i*nprev*2 + nprev+m); @@ -1427,6 +1424,7 @@ void FixQEqReaxFFKokkos::operator()(TagQEqUnpackExchange, const int template void FixQEqReaxFFKokkos::unpack_exchange_kokkos( DAT::tdual_xfloat_2d &k_buf, DAT::tdual_int_1d &k_indices, int nrecv, + int /*nrecv1*/, int /*nextrarecv1*/, ExecutionSpace /*space*/) { k_buf.sync(); diff --git a/src/KOKKOS/fix_qeq_reaxff_kokkos.h b/src/KOKKOS/fix_qeq_reaxff_kokkos.h index 9bc38b0492..92026b209d 100644 --- a/src/KOKKOS/fix_qeq_reaxff_kokkos.h +++ b/src/KOKKOS/fix_qeq_reaxff_kokkos.h @@ -143,6 +143,7 @@ class FixQEqReaxFFKokkos : public FixQEqReaxFF, public KokkosBase { void unpack_exchange_kokkos(DAT::tdual_xfloat_2d &k_buf, DAT::tdual_int_1d &indices,int nrecv, + int nrecv1,int nextrarecv1, ExecutionSpace space) override; struct params_qeq{ @@ -153,7 +154,7 @@ class FixQEqReaxFFKokkos : public FixQEqReaxFF, public KokkosBase { F_FLOAT chi, eta, gamma; }; - int pack_forward_comm_kokkos(int, DAT::tdual_int_2d, int, DAT::tdual_xfloat_1d&, + int pack_forward_comm_kokkos(int, DAT::tdual_int_1d, DAT::tdual_xfloat_1d&, int, int *) override; void unpack_forward_comm_kokkos(int, int, DAT::tdual_xfloat_1d&) override; int pack_forward_comm(int, int *, double *, int, int *) override; @@ -254,9 +255,9 @@ class FixQEqReaxFFKokkos : public FixQEqReaxFF, public KokkosBase { DupScatterView dup_o; NonDupScatterView ndup_o; - int iswap,nsend; + int nsend; int first; - typename AT::t_int_2d d_sendlist; + typename AT::t_int_1d d_sendlist; typename AT::t_xfloat_1d d_buf; typename AT::t_int_1d d_copylist; typename AT::t_int_1d d_indices; diff --git a/src/KOKKOS/fix_reaxff_species_kokkos.cpp b/src/KOKKOS/fix_reaxff_species_kokkos.cpp index 960ba07a86..7d742a8fa4 100644 --- a/src/KOKKOS/fix_reaxff_species_kokkos.cpp +++ b/src/KOKKOS/fix_reaxff_species_kokkos.cpp @@ -23,13 +23,11 @@ #include "comm.h" #include "error.h" #include "force.h" -#include "input.h" -#include "memory_kokkos.h" -#include "neigh_list.h" -#include "neigh_request.h" +#include "kokkos_type.h" +#include "neigh_list_kokkos.h" #include "fix_ave_atom.h" -#include "pair_reaxff_kokkos.h" +#include "pair_reaxff.h" #include "reaxff_defs.h" using namespace LAMMPS_NS; diff --git a/src/KOKKOS/fix_rx_kokkos.cpp b/src/KOKKOS/fix_rx_kokkos.cpp index 0ba56c611e..0d1c250b3d 100644 --- a/src/KOKKOS/fix_rx_kokkos.cpp +++ b/src/KOKKOS/fix_rx_kokkos.cpp @@ -25,13 +25,12 @@ #include "math_special_kokkos.h" #include "memory_kokkos.h" #include "modify.h" -#include "neigh_list_kokkos.h" #include "neigh_request.h" #include "neighbor.h" #include "update.h" #include // DBL_EPSILON -#include +#include using namespace LAMMPS_NS; using namespace FixConst; @@ -85,9 +84,6 @@ FixRxKokkos::~FixRxKokkos() memoryKK->destroy_kokkos(k_dpdThetaLocal, dpdThetaLocal); memoryKK->destroy_kokkos(k_sumWeights, sumWeights); - memoryKK->destroy_kokkos(d_scratchSpace); - - memoryKK->destroy_kokkos(k_cutsq); } /* ---------------------------------------------------------------------- */ @@ -1463,8 +1459,8 @@ void FixRxKokkos::solve_reactions(const int /*vflag*/, const bool is this->scratchSpaceSize = (8*nspecies + 2*nreactions); if (nlocal*scratchSpaceSize > d_scratchSpace.extent(0)) { - memoryKK->destroy_kokkos (d_scratchSpace); - memoryKK->create_kokkos (d_scratchSpace, nlocal*scratchSpaceSize, "FixRxKokkos::d_scratchSpace"); + d_scratchSpace = typename AT::t_double_1d(); + d_scratchSpace = typename AT::t_double_1d("FixRxKokkos::d_scratchSpace", nlocal*scratchSpaceSize); } if (setRatesToZero) @@ -1822,8 +1818,8 @@ void FixRxKokkos::computeLocalTemperature() const int ntypes = atom->ntypes; if (ntypes+1 > (int) k_cutsq.extent(0)) { - memoryKK->destroy_kokkos (k_cutsq); - memoryKK->create_kokkos (k_cutsq, ntypes+1, ntypes+1, "FixRxKokkos::k_cutsq"); + k_cutsq = typename AT::tdual_ffloat_2d(); + k_cutsq = typename AT::tdual_ffloat_2d("FixRxKokkos::k_cutsq", ntypes+1, ntypes+1); d_cutsq = k_cutsq.template view(); } @@ -1843,7 +1839,7 @@ void FixRxKokkos::computeLocalTemperature() if (sumWeightsCt > (int)k_sumWeights.template view().extent(0)) { memoryKK->destroy_kokkos(k_sumWeights, sumWeights); - memoryKK->create_kokkos (k_sumWeights, sumWeightsCt, "FixRxKokkos::sumWeights"); + memoryKK->create_kokkos(k_sumWeights, sumWeights, sumWeightsCt, "FixRxKokkos::sumWeights"); d_sumWeights = k_sumWeights.template view(); h_sumWeights = k_sumWeights.h_view; } diff --git a/src/KOKKOS/fix_setforce_kokkos.cpp b/src/KOKKOS/fix_setforce_kokkos.cpp index 9f193bc6e4..e8f376643f 100644 --- a/src/KOKKOS/fix_setforce_kokkos.cpp +++ b/src/KOKKOS/fix_setforce_kokkos.cpp @@ -17,7 +17,6 @@ #include "atom_kokkos.h" #include "update.h" #include "modify.h" -#include "domain.h" #include "region.h" #include "input.h" #include "variable.h" @@ -26,8 +25,6 @@ #include "atom_masks.h" #include "kokkos_base.h" -#include - using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/KOKKOS/fix_shake_kokkos.cpp b/src/KOKKOS/fix_shake_kokkos.cpp index c31e38a05e..b25e2dad59 100644 --- a/src/KOKKOS/fix_shake_kokkos.cpp +++ b/src/KOKKOS/fix_shake_kokkos.cpp @@ -14,20 +14,12 @@ #include "fix_shake_kokkos.h" -#include "fix_rattle.h" #include "atom_kokkos.h" -#include "atom_vec.h" -#include "molecule.h" #include "update.h" -#include "respa.h" -#include "modify.h" #include "domain.h" #include "force.h" -#include "bond.h" -#include "angle.h" #include "comm.h" #include "group.h" -#include "fix_respa.h" #include "math_const.h" #include "memory_kokkos.h" #include "error.h" @@ -35,17 +27,11 @@ #include "atom_masks.h" #include -#include using namespace LAMMPS_NS; using namespace FixConst; using namespace MathConst; -#define RVOUS 1 // 0 for irregular, 1 for all2all - -#define BIG 1.0e20 -#define MASSDELTA 0.1 - /* ---------------------------------------------------------------------- */ template @@ -643,7 +629,7 @@ KOKKOS_INLINE_FUNCTION void FixShakeKokkos::shake(int ilist, EV_FLOAT& ev) const { - // The f array is duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The f array is duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_f = ScatterViewHelper,decltype(dup_f),decltype(ndup_f)>::get(dup_f,ndup_f); auto a_f = v_f.template access>(); @@ -753,7 +739,7 @@ KOKKOS_INLINE_FUNCTION void FixShakeKokkos::shake3(int ilist, EV_FLOAT& ev) const { - // The f array is duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The f array is duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_f = ScatterViewHelper,decltype(dup_f),decltype(ndup_f)>::get(dup_f,ndup_f); auto a_f = v_f.template access>(); @@ -933,7 +919,7 @@ KOKKOS_INLINE_FUNCTION void FixShakeKokkos::shake4(int ilist, EV_FLOAT& ev) const { - // The f array is duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The f array is duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_f = ScatterViewHelper,decltype(dup_f),decltype(ndup_f)>::get(dup_f,ndup_f); auto a_f = v_f.template access>(); @@ -1190,7 +1176,7 @@ KOKKOS_INLINE_FUNCTION void FixShakeKokkos::shake3angle(int ilist, EV_FLOAT& ev) const { - // The f array is duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The f array is duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_f = ScatterViewHelper,decltype(dup_f),decltype(ndup_f)>::get(dup_f,ndup_f); auto a_f = v_f.template access>(); @@ -1581,8 +1567,8 @@ void FixShakeKokkos::pack_exchange_item(const int &mysend, int &offs else offset++; } else { - d_buf[mysend] = nsend + offset; int m = nsend + offset; + d_buf[mysend] = m; d_buf[m++] = flag; if (flag == 1) { d_buf[m++] = d_shake_atom(i,0); @@ -1703,6 +1689,8 @@ void FixShakeKokkos::operator()(TagFixShakeUnpackExchange, const int if (index > -1) { int m = d_buf[i]; + if (i >= nrecv1) + m = nextrarecv1 + d_buf[nextrarecv1 + i - nrecv1]; int flag = d_shake_flag[index] = static_cast (d_buf[m++]); if (flag == 1) { @@ -1739,6 +1727,7 @@ void FixShakeKokkos::operator()(TagFixShakeUnpackExchange, const int template void FixShakeKokkos::unpack_exchange_kokkos( DAT::tdual_xfloat_2d &k_buf, DAT::tdual_int_1d &k_indices, int nrecv, + int nrecv1, int nextrarecv1, ExecutionSpace /*space*/) { k_buf.sync(); @@ -1749,6 +1738,9 @@ void FixShakeKokkos::unpack_exchange_kokkos( k_buf.extent(0)*k_buf.extent(1)); d_indices = k_indices.view(); + this->nrecv1 = nrecv1; + this->nextrarecv1 = nextrarecv1; + k_shake_flag.template sync(); k_shake_atom.template sync(); k_shake_type.template sync(); @@ -1807,12 +1799,11 @@ int FixShakeKokkos::unpack_exchange(int nlocal, double *buf) /* ---------------------------------------------------------------------- */ template -int FixShakeKokkos::pack_forward_comm_kokkos(int n, DAT::tdual_int_2d k_sendlist, - int iswap_in, DAT::tdual_xfloat_1d &k_buf, - int pbc_flag, int* pbc) +int FixShakeKokkos::pack_forward_comm_kokkos(int n, DAT::tdual_int_1d k_sendlist, + DAT::tdual_xfloat_1d &k_buf, + int pbc_flag, int* pbc) { d_sendlist = k_sendlist.view(); - iswap = iswap_in; d_buf = k_buf.view(); if (domain->triclinic == 0) { @@ -1836,7 +1827,7 @@ template template KOKKOS_INLINE_FUNCTION void FixShakeKokkos::operator()(TagFixShakePackForwardComm, const int &i) const { - const int j = d_sendlist(iswap, i); + const int j = d_sendlist(i); if (PBC_FLAG == 0) { d_buf[3*i] = d_xshake(j,0); diff --git a/src/KOKKOS/fix_shake_kokkos.h b/src/KOKKOS/fix_shake_kokkos.h index 7c830e94d8..31a6c340be 100644 --- a/src/KOKKOS/fix_shake_kokkos.h +++ b/src/KOKKOS/fix_shake_kokkos.h @@ -66,7 +66,7 @@ class FixShakeKokkos : public FixShake, public KokkosBase { int pack_exchange(int, double *) override; int unpack_exchange(int, double *) override; - int pack_forward_comm_kokkos(int, DAT::tdual_int_2d, int, DAT::tdual_xfloat_1d&, + int pack_forward_comm_kokkos(int, DAT::tdual_int_1d, DAT::tdual_xfloat_1d&, int, int *) override; void unpack_forward_comm_kokkos(int, int, DAT::tdual_xfloat_1d&) override; int pack_forward_comm(int, int *, double *, int, int *) override; @@ -110,9 +110,12 @@ class FixShakeKokkos : public FixShake, public KokkosBase { void unpack_exchange_kokkos(DAT::tdual_xfloat_2d &k_buf, DAT::tdual_int_1d &indices,int nrecv, + int nrecv1,int nrecv1extra, ExecutionSpace space) override; protected: + int nrecv1,nextrarecv1; + typename AT::t_x_array d_x; typename AT::t_v_array d_v; typename AT::t_f_array d_f; @@ -208,9 +211,9 @@ class FixShakeKokkos : public FixShake, public KokkosBase { KOKKOS_INLINE_FUNCTION void v_tally(EV_FLOAT&, int, int *, double, double *) const; - int iswap,first,nsend; + int first,nsend; - typename AT::t_int_2d d_sendlist; + typename AT::t_int_1d d_sendlist; typename AT::t_xfloat_1d_um d_buf; typename AT::t_int_1d d_exchange_sendlist; @@ -257,4 +260,3 @@ struct FixShakeKokkosPackExchangeFunctor { #endif #endif - diff --git a/src/KOKKOS/fix_shardlow_kokkos.cpp b/src/KOKKOS/fix_shardlow_kokkos.cpp index 37ffd15cdf..a64adbcc38 100644 --- a/src/KOKKOS/fix_shardlow_kokkos.cpp +++ b/src/KOKKOS/fix_shardlow_kokkos.cpp @@ -43,12 +43,12 @@ #include "domain.h" #include "error.h" #include "force.h" -#include "memory_kokkos.h" #include "neigh_list_kokkos.h" #include "neigh_request.h" #include "neighbor.h" #include "npair_ssa_kokkos.h" #include "pair_dpd_fdt_energy_kokkos.h" +#include "random_external_state.h" #include "update.h" #include @@ -57,8 +57,8 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace random_external_state; -#define EPSILON 1.0e-10 -#define EPSILON_SQUARED ((EPSILON) * (EPSILON)) +static constexpr double EPSILON = 1.0e-10; +static constexpr double EPSILON_SQUARED = EPSILON * EPSILON; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/fix_spring_self_kokkos.cpp b/src/KOKKOS/fix_spring_self_kokkos.cpp index 2da2fa9f14..9ba796b1ab 100644 --- a/src/KOKKOS/fix_spring_self_kokkos.cpp +++ b/src/KOKKOS/fix_spring_self_kokkos.cpp @@ -20,17 +20,10 @@ #include "atom_kokkos.h" #include "update.h" -#include "modify.h" #include "domain_kokkos.h" -#include "region.h" -#include "input.h" -#include "variable.h" #include "memory_kokkos.h" #include "error.h" #include "atom_masks.h" -#include "kokkos_base.h" - -#include using namespace LAMMPS_NS; using namespace FixConst; @@ -188,8 +181,8 @@ void FixSpringSelfKokkos::pack_exchange_item(const int &mysend, int { const int i = d_exchange_sendlist(mysend); - d_buf[mysend] = nsend + offset; int m = nsend + offset; + d_buf[mysend] = m; d_buf[m++] = d_xoriginal(i,0); d_buf[m++] = d_xoriginal(i,1); d_buf[m++] = d_xoriginal(i,2); @@ -258,6 +251,8 @@ void FixSpringSelfKokkos::operator()(TagFixSpringSelfUnpackExchange, if (index > -1) { int m = d_buf[i]; + if (i >= nrecv1) + m = nextrarecv1 + d_buf[nextrarecv1 + i - nrecv1]; d_xoriginal(index,0) = static_cast (d_buf[m++]); d_xoriginal(index,1) = static_cast (d_buf[m++]); @@ -270,6 +265,7 @@ void FixSpringSelfKokkos::operator()(TagFixSpringSelfUnpackExchange, template void FixSpringSelfKokkos::unpack_exchange_kokkos( DAT::tdual_xfloat_2d &k_buf, DAT::tdual_int_1d &k_indices, int nrecv, + int nrecv1, int nextrarecv1, ExecutionSpace /*space*/) { k_buf.sync(); @@ -280,6 +276,9 @@ void FixSpringSelfKokkos::unpack_exchange_kokkos( k_buf.extent(0)*k_buf.extent(1)); d_indices = k_indices.view(); + this->nrecv1 = nrecv1; + this->nextrarecv1 = nextrarecv1; + k_xoriginal.template sync(); copymode = 1; diff --git a/src/KOKKOS/fix_spring_self_kokkos.h b/src/KOKKOS/fix_spring_self_kokkos.h index b23e92249b..add5a80bc7 100644 --- a/src/KOKKOS/fix_spring_self_kokkos.h +++ b/src/KOKKOS/fix_spring_self_kokkos.h @@ -58,6 +58,7 @@ class FixSpringSelfKokkos : public FixSpringSelf, public KokkosBase { void unpack_exchange_kokkos(DAT::tdual_xfloat_2d &k_buf, DAT::tdual_int_1d &indices,int nrecv, + int nrecv1,int nrecv1extra, ExecutionSpace space) override; @@ -65,6 +66,8 @@ class FixSpringSelfKokkos : public FixSpringSelf, public KokkosBase { int unpack_exchange(int, double *) override; protected: + int nrecv1,nextrarecv1; + DAT::tdual_x_array k_xoriginal; typename AT::t_x_array d_xoriginal; diff --git a/src/KOKKOS/fix_temp_berendsen_kokkos.cpp b/src/KOKKOS/fix_temp_berendsen_kokkos.cpp index b986b3189a..8aaf586194 100644 --- a/src/KOKKOS/fix_temp_berendsen_kokkos.cpp +++ b/src/KOKKOS/fix_temp_berendsen_kokkos.cpp @@ -15,11 +15,9 @@ #include "fix_temp_berendsen_kokkos.h" #include "atom_kokkos.h" -#include "comm.h" #include "compute.h" #include "error.h" #include "force.h" -#include "group.h" #include "input.h" #include "modify.h" #include "update.h" @@ -27,7 +25,6 @@ #include "atom_masks.h" #include -#include using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/KOKKOS/fix_temp_rescale_kokkos.cpp b/src/KOKKOS/fix_temp_rescale_kokkos.cpp index 3a1c6ddd26..5c295634e7 100644 --- a/src/KOKKOS/fix_temp_rescale_kokkos.cpp +++ b/src/KOKKOS/fix_temp_rescale_kokkos.cpp @@ -15,11 +15,9 @@ #include "fix_temp_rescale_kokkos.h" #include "atom_kokkos.h" -#include "comm.h" #include "compute.h" #include "error.h" #include "force.h" -#include "group.h" #include "input.h" #include "modify.h" #include "update.h" @@ -27,7 +25,6 @@ #include "atom_masks.h" #include -#include using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/KOKKOS/fix_viscous_kokkos.cpp b/src/KOKKOS/fix_viscous_kokkos.cpp index 80ddff2fce..86a5a35910 100644 --- a/src/KOKKOS/fix_viscous_kokkos.cpp +++ b/src/KOKKOS/fix_viscous_kokkos.cpp @@ -16,12 +16,8 @@ #include "atom_kokkos.h" #include "update.h" -#include "modify.h" -#include "input.h" -#include "memory_kokkos.h" #include "error.h" #include "atom_masks.h" -#include "kokkos_base.h" using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/KOKKOS/fix_wall_flow_kokkos.cpp b/src/KOKKOS/fix_wall_flow_kokkos.cpp new file mode 100644 index 0000000000..e86cad54b4 --- /dev/null +++ b/src/KOKKOS/fix_wall_flow_kokkos.cpp @@ -0,0 +1,293 @@ +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + LAMMPS development team: developers@lammps.org + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing authors: Vladislav Galigerov (HSE), + Daniil Pavlov (MIPT) +------------------------------------------------------------------------- */ + +#include "fix_wall_flow_kokkos.h" +#include "atom_kokkos.h" +#include "atom_masks.h" +#include "comm.h" +#include "math_const.h" +#include "memory_kokkos.h" + +#include + +using namespace LAMMPS_NS; + +template +FixWallFlowKokkos::FixWallFlowKokkos(LAMMPS *lmp, int narg, char **arg) : + FixWallFlow(lmp, narg, arg), rand_pool(rndseed + comm->me) +{ + kokkosable = 1; + exchange_comm_device = sort_device = 1; + atomKK = (AtomKokkos *) atom; + execution_space = ExecutionSpaceFromDevice::space; + datamask_read = X_MASK | RMASS_MASK | TYPE_MASK | MASK_MASK; + datamask_modify = V_MASK; + + memory->destroy(current_segment); + current_segment = nullptr; + grow_arrays(atomKK->nmax); + + d_walls = d_walls_t("FixWallFlowKokkos::walls", walls.size()); + auto h_walls = Kokkos::create_mirror_view(d_walls); + for (int i = 0; i < (int) walls.size(); ++i) h_walls(i) = walls[i]; + Kokkos::deep_copy(d_walls, h_walls); +} + +template FixWallFlowKokkos::~FixWallFlowKokkos() +{ + if (copymode) return; + memoryKK->destroy_kokkos(k_current_segment, current_segment); +} + +template void FixWallFlowKokkos::init() +{ + atomKK->sync(execution_space, datamask_read); + k_current_segment.template sync(); + d_x = atomKK->k_x.template view(); + + copymode = 1; + Kokkos::parallel_for(Kokkos::RangePolicy(0, atom->nlocal), *this); + copymode = 0; + + k_current_segment.template modify(); +} + +template +KOKKOS_INLINE_FUNCTION void FixWallFlowKokkos::operator()(TagFixWallFlowInit, + const int &i) const +{ + double pos = d_x(i, flowax); + d_current_segment(i) = compute_current_segment_kk(pos); +} + +template void FixWallFlowKokkos::end_of_step() +{ + atomKK->sync(execution_space, datamask_read); + k_current_segment.template sync(); + + d_x = atomKK->k_x.template view(); + d_v = atomKK->k_v.template view(); + d_type = atomKK->k_type.template view(); + d_mask = atomKK->k_mask.template view(); + d_mass = atomKK->k_mass.template view(); + d_rmass = atomKK->k_rmass.template view(); + + copymode = 1; + if (d_rmass.data()) { + Kokkos::parallel_for( + Kokkos::RangePolicy>(0, atom->nlocal), *this); + } else { + Kokkos::parallel_for( + Kokkos::RangePolicy>(0, atom->nlocal), *this); + } + copymode = 0; + atomKK->modified(execution_space, datamask_modify); + k_current_segment.template modify(); +} + +template +template +KOKKOS_INLINE_FUNCTION void FixWallFlowKokkos::operator()(TagFixWallFlowEndOfStep, + const int &atom_i) const +{ + if (d_mask[atom_i] & groupbit) { + double pos = d_x(atom_i, flowax); + int prev_segment = d_current_segment(atom_i); + d_current_segment(atom_i) = compute_current_segment_kk(pos); + if (prev_segment != d_current_segment(atom_i)) { generate_velocity_kk(atom_i); } + } +} + +template +template +KOKKOS_INLINE_FUNCTION void FixWallFlowKokkos::generate_velocity_kk(int atom_i) const +{ + const int newton_iteration_count = 10; + double mass = get_mass(MTag(), atom_i); + const double gamma = 1.0 / std::sqrt(2.0 * kT / mass); + double delta = gamma * flowvel; + + const double edd = std::exp(-delta * delta) / MathConst::MY_PIS + delta * std::erf(delta); + const double probability_threshold = 0.5 * (1. + delta / edd); + + double direction = 1.0; + + rand_type_t rand_gen = rand_pool.get_state(); + + if (/*random->uniform()*/ rand_gen.drand() > probability_threshold) { + delta = -delta; + direction = -direction; + } + + const double xi_0 = rand_gen.drand(); //random->uniform(); + const double F_inf = edd + delta; + const double xi = xi_0 * F_inf; + const double x_0 = (std::sqrt(delta * delta + 2) - delta) * 0.5; + double x = x_0; + for (int i = 0; i < newton_iteration_count; ++i) { + x -= (std::exp(x * x) * MathConst::MY_PIS * (xi - delta * std::erfc(x)) - 1.0) / (x + delta) * + 0.5; + } + + const double nu = x + delta; + const double v = nu / gamma; + + d_v(atom_i, flowax) = v * direction; + d_v(atom_i, (flowax + 1) % 3) = + /*random->gaussian()*/ rand_gen.normal() / (gamma * MathConst::MY_SQRT2); + d_v(atom_i, (flowax + 2) % 3) = + /*random->gaussian()*/ rand_gen.normal() / (gamma * MathConst::MY_SQRT2); + + rand_pool.free_state(rand_gen); +} + +template +KOKKOS_INLINE_FUNCTION int +FixWallFlowKokkos::compute_current_segment_kk(double pos) const +{ + int result = 0; + for (; result < (int) d_walls.extent(0) - 1; ++result) { + if (pos >= d_walls[result] && pos < d_walls[result + 1]) { return result; } + } + return -1; // -1 is "out of box" region +} + +template void FixWallFlowKokkos::grow_arrays(int nmax) +{ + k_current_segment.template sync(); + memoryKK->grow_kokkos(k_current_segment, current_segment, nmax, "WallFlowKK::current_segment"); + k_current_segment.template modify(); + + d_current_segment = k_current_segment.template view(); + h_current_segment = k_current_segment.template view(); +} + +template void FixWallFlowKokkos::copy_arrays(int i, int j, int) +{ + k_current_segment.template sync(); + h_current_segment(j) = h_current_segment(i); + k_current_segment.template modify(); +} + +/* ---------------------------------------------------------------------- + sort local atom-based arrays +------------------------------------------------------------------------- */ + +template +void FixWallFlowKokkos::sort_kokkos(Kokkos::BinSort &Sorter) +{ + // always sort on the device + + k_current_segment.sync_device(); + + Sorter.sort(LMPDeviceType(), k_current_segment.d_view); + + k_current_segment.modify_device(); +} + +template int FixWallFlowKokkos::pack_exchange(int i, double *buf) +{ + k_current_segment.sync_host(); + buf[0] = static_cast(h_current_segment(i)); + return 1; +} + +template +KOKKOS_INLINE_FUNCTION void FixWallFlowKokkos::operator()(TagFixWallFlowPackExchange, + const int &mysend) const +{ + const int send_i = d_sendlist(mysend); + const int segment = d_current_segment(send_i); + d_buf(mysend) = static_cast(segment); + + const int copy_i = d_copylist(mysend); + if (copy_i > -1) { d_current_segment(send_i) = d_current_segment(copy_i); } +} + +template +int FixWallFlowKokkos::pack_exchange_kokkos(const int &nsend, + DAT::tdual_xfloat_2d &k_buf, + DAT::tdual_int_1d k_sendlist, + DAT::tdual_int_1d k_copylist, + ExecutionSpace /*space*/) +{ + k_current_segment.template sync(); + + k_buf.template sync(); + k_sendlist.template sync(); + k_copylist.template sync(); + + d_sendlist = k_sendlist.view(); + d_copylist = k_copylist.view(); + + d_buf = typename ArrayTypes::t_xfloat_1d_um(k_buf.template view().data(), + k_buf.extent(0) * k_buf.extent(1)); + + copymode = 1; + + Kokkos::parallel_for(Kokkos::RangePolicy(0, nsend), + *this); + + copymode = 0; + + k_buf.template modify(); + k_current_segment.template modify(); + + return nsend; +} + +template int FixWallFlowKokkos::unpack_exchange(int i, double *buf) +{ + k_current_segment.sync_host(); + h_current_segment(i) = static_cast(buf[0]); + k_current_segment.modify_host(); + return 1; +} + +template +KOKKOS_INLINE_FUNCTION void FixWallFlowKokkos::operator()(TagFixWallFlowUnpackExchange, + const int &i) const +{ + int index = d_indices(i); + if (index > -1) { d_current_segment(index) = static_cast(d_buf(i)); } +} + +template +void FixWallFlowKokkos::unpack_exchange_kokkos(DAT::tdual_xfloat_2d &k_buf, + DAT::tdual_int_1d &k_indices, int nrecv, + int /*nrecv1*/, int /*nextrarecv1*/, + ExecutionSpace /*space*/) +{ + d_buf = typename ArrayTypes::t_xfloat_1d_um(k_buf.template view().data(), + k_buf.extent(0) * k_buf.extent(1)); + d_indices = k_indices.view(); + + copymode = 1; + Kokkos::parallel_for(Kokkos::RangePolicy(0, nrecv), + *this); + copymode = 0; + + k_current_segment.template modify(); +} + +namespace LAMMPS_NS { +template class FixWallFlowKokkos; +#ifdef LMP_KOKKOS_GPU +template class FixWallFlowKokkos; +#endif +} // namespace LAMMPS_NS diff --git a/src/KOKKOS/fix_wall_flow_kokkos.h b/src/KOKKOS/fix_wall_flow_kokkos.h new file mode 100644 index 0000000000..3535c74eb7 --- /dev/null +++ b/src/KOKKOS/fix_wall_flow_kokkos.h @@ -0,0 +1,129 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + LAMMPS development team: developers@lammps.org + + 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. +------------------------------------------------------------------------- */ + +#ifdef FIX_CLASS +// clang-format off +FixStyle(wall/flow/kk,FixWallFlowKokkos); +FixStyle(wall/flow/kk/device,FixWallFlowKokkos); +FixStyle(wall/flow/kk/host,FixWallFlowKokkos); +// clang-format on +#else + +// clang-format off +#ifndef LMP_FIX_WALL_FLOW_KOKKOS_H +#define LMP_FIX_WALL_FLOW_KOKKOS_H + +#include "fix_wall_flow.h" +#include "kokkos_type.h" +#include "kokkos_base.h" +#include "Kokkos_Random.hpp" + +namespace LAMMPS_NS { + +struct TagFixWallFlowInit{}; +template +struct TagFixWallFlowEndOfStep{}; +struct TagFixWallFlowPackExchange{}; +struct TagFixWallFlowUnpackExchange{}; + +template +class FixWallFlowKokkos : public FixWallFlow, public KokkosBase { + public: + typedef DeviceType device_type; + typedef ArrayTypes AT; + struct MassTag{}; + struct RMassTag{}; + FixWallFlowKokkos(class LAMMPS *, int, char **); + ~FixWallFlowKokkos(); + + void init() override; + void end_of_step() override; + void grow_arrays(int) override; + void copy_arrays(int, int, int) override; + void sort_kokkos(Kokkos::BinSort &Sorter) override; + int pack_exchange(int, double *) override; + int unpack_exchange(int, double *) override; + + KOKKOS_INLINE_FUNCTION + void operator() (TagFixWallFlowInit, const int&) const; + + template + KOKKOS_INLINE_FUNCTION + void operator()(TagFixWallFlowEndOfStep, const int&) const; + + KOKKOS_INLINE_FUNCTION + void operator()(TagFixWallFlowPackExchange, const int&) const; + + KOKKOS_INLINE_FUNCTION + void operator()(TagFixWallFlowUnpackExchange, const int&) const; + + int pack_exchange_kokkos(const int &nsend,DAT::tdual_xfloat_2d &buf, + DAT::tdual_int_1d k_sendlist, + DAT::tdual_int_1d k_copylist, + ExecutionSpace space) override; + + void unpack_exchange_kokkos(DAT::tdual_xfloat_2d &k_buf, + DAT::tdual_int_1d &indices,int nrecv, + int /*nrecv1*/, int /*nextrarecv1*/, + ExecutionSpace space) override; + protected: + typename AT::t_x_array d_x; + typename AT::t_v_array d_v; + typename AT::t_int_1d d_type; + typename AT::t_int_1d d_mask; + + typename AT::t_float_1d d_mass; + typename AT::t_float_1d d_rmass; + + typedef typename AT::t_xfloat_1d d_walls_t; + typedef Kokkos::Random_XorShift64_Pool rand_pool_t; + typedef typename rand_pool_t::generator_type rand_type_t; + + typename AT::tdual_int_1d k_current_segment; + typename AT::t_int_1d d_current_segment; + typename HAT::t_int_1d h_current_segment; + + typename AT::t_int_1d d_sendlist; + typename AT::t_xfloat_1d d_buf; + typename AT::t_int_1d d_copylist; + typename AT::t_int_1d d_indices; + + d_walls_t d_walls; + + rand_pool_t rand_pool; + + template + KOKKOS_INLINE_FUNCTION + void generate_velocity_kk(int atom_i) const; + + KOKKOS_INLINE_FUNCTION + int compute_current_segment_kk(double pos) const; + + KOKKOS_INLINE_FUNCTION + double get_mass(MassTag, int atom_i) const + { + return d_mass(d_type(atom_i)); + } + + KOKKOS_INLINE_FUNCTION + double get_mass(RMassTag, int atom_i) const + { + return d_rmass(atom_i); + } +}; + +} + +#endif +#endif + diff --git a/src/KOKKOS/fix_wall_gran_kokkos.cpp b/src/KOKKOS/fix_wall_gran_kokkos.cpp index f870b0f240..3ff97084fe 100644 --- a/src/KOKKOS/fix_wall_gran_kokkos.cpp +++ b/src/KOKKOS/fix_wall_gran_kokkos.cpp @@ -15,7 +15,6 @@ #include "atom_kokkos.h" #include "error.h" #include "memory_kokkos.h" -#include "atom_vec_kokkos.h" #include "atom_masks.h" #include "update.h" @@ -419,6 +418,7 @@ void FixWallGranKokkos::operator()(TagFixWallGranUnpackExchange, con template void FixWallGranKokkos::unpack_exchange_kokkos( DAT::tdual_xfloat_2d &k_buf, DAT::tdual_int_1d &k_indices, int nrecv, + int /*nrecv1*/, int /*nextrarecv1*/, ExecutionSpace /*space*/) { d_buf = typename ArrayTypes::t_xfloat_1d_um( @@ -430,7 +430,6 @@ void FixWallGranKokkos::unpack_exchange_kokkos( copymode = 1; - Kokkos::parallel_for(Kokkos::RangePolicy(0,nrecv),*this); copymode = 0; diff --git a/src/KOKKOS/fix_wall_gran_kokkos.h b/src/KOKKOS/fix_wall_gran_kokkos.h index c7d566ec72..ae54fdb085 100644 --- a/src/KOKKOS/fix_wall_gran_kokkos.h +++ b/src/KOKKOS/fix_wall_gran_kokkos.h @@ -62,12 +62,13 @@ class FixWallGranKokkos : public FixWallGranOld, public KokkosBase { void operator()(TagFixWallGranUnpackExchange, const int&) const; int pack_exchange_kokkos(const int &nsend,DAT::tdual_xfloat_2d &buf, - DAT::tdual_int_1d k_sendlist, - DAT::tdual_int_1d k_copylist, - ExecutionSpace space) override; + DAT::tdual_int_1d k_sendlist, + DAT::tdual_int_1d k_copylist, + ExecutionSpace space) override; void unpack_exchange_kokkos(DAT::tdual_xfloat_2d &k_buf, DAT::tdual_int_1d &indices,int nrecv, + int nrecv1,int nrecv1extra, ExecutionSpace space) override; private: @@ -91,6 +92,7 @@ class FixWallGranKokkos : public FixWallGranOld, public KokkosBase { typename AT::t_int_1d d_copylist; typename AT::t_int_1d d_indices; }; + } #endif diff --git a/src/KOKKOS/fix_wall_gran_old.cpp b/src/KOKKOS/fix_wall_gran_old.cpp index 8c02e6146d..f832a80d11 100644 --- a/src/KOKKOS/fix_wall_gran_old.cpp +++ b/src/KOKKOS/fix_wall_gran_old.cpp @@ -37,16 +37,16 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace MathConst; -#define PI27SQ 266.47931882941264802866 // 27*PI**2 -#define THREEROOT3 5.19615242270663202362 // 3*sqrt(3) -#define SIXROOT6 14.69693845669906728801 // 6*sqrt(6) -#define INVROOT6 0.40824829046386307274 // 1/sqrt(6) -#define FOURTHIRDS 1.333333333333333 // 4/3 -#define THREEQUARTERS 0.75 // 3/4 -#define TWOPI 6.28318530717959 // 2*PI +static constexpr double PI27SQ = 266.47931882941264802866; // 27*PI**2 +static constexpr double THREEROOT3 = 5.19615242270663202362; // 3*sqrt(3) +static constexpr double SIXROOT6 = 14.69693845669906728801; // 6*sqrt(6) +static constexpr double INVROOT6 = 0.40824829046386307274; // 1/sqrt(6) +static constexpr double FOURTHIRDS = 1.333333333333333; // 4/3 +static constexpr double THREEQUARTERS = 0.75; // 3/4 +static constexpr double TWOPI = 6.28318530717959; // 2*PI -#define BIG 1.0e20 -#define EPSILON 1e-10 +static constexpr double BIG = 1.0e20; +static constexpr double EPSILON = 1e-10; // XYZ PLANE need to be 0,1,2 @@ -68,8 +68,8 @@ FixWallGranOld::FixWallGranOld(LAMMPS *lmp, int narg, char **arg) : { if (narg < 4) error->all(FLERR,"Illegal fix wall/gran command"); - if (!atom->sphere_flag) - error->all(FLERR,"Fix wall/gran requires atom style sphere"); + if (!atom->omega_flag) error->all(FLERR,"Fix {} requires atom attribute omega", style); + if (!atom->radius_flag) error->all(FLERR,"Fix {} requires atom attribute radius", style); create_attribute = 1; limit_damping = 0; @@ -81,7 +81,7 @@ FixWallGranOld::FixWallGranOld(LAMMPS *lmp, int narg, char **arg) : else if (strcmp(arg[3],"hooke/history") == 0) pairstyle = HOOKE_HISTORY; else if (strcmp(arg[3],"hertz/history") == 0) pairstyle = HERTZ_HISTORY; else if (strcmp(arg[3],"granular") == 0) pairstyle = GRANULAR; - else error->all(FLERR,"Invalid fix wall/gran interaction style"); + else error->all(FLERR,"Invalid fix {} interaction style: {}", style, arg[3]); use_history = restart_peratom = 1; if (pairstyle == HOOKE) use_history = restart_peratom = 0; @@ -1704,4 +1704,3 @@ double FixWallGranOld::pulloff_distance(double radius) dist = a*a/radius - 2*sqrt(MY_PI*coh*a/E); return dist; } - diff --git a/src/KOKKOS/fix_wall_lj93_kokkos.cpp b/src/KOKKOS/fix_wall_lj93_kokkos.cpp index dff47f1c30..93bcc9abc9 100644 --- a/src/KOKKOS/fix_wall_lj93_kokkos.cpp +++ b/src/KOKKOS/fix_wall_lj93_kokkos.cpp @@ -13,7 +13,7 @@ ------------------------------------------------------------------------- */ #include "fix_wall_lj93_kokkos.h" -#include + #include "atom_kokkos.h" #include "error.h" #include "atom_masks.h" @@ -51,8 +51,6 @@ void FixWallLJ93Kokkos::wall_particle(int m_in, int which, double co x = atomKK->k_x.view(); f = atomKK->k_f.view(); mask = atomKK->k_mask.view(); - DAT::tdual_int_scalar k_oneflag = DAT::tdual_int_scalar("fix:oneflag"); - d_oneflag = k_oneflag.view(); int nlocal = atom->nlocal; @@ -66,10 +64,6 @@ void FixWallLJ93Kokkos::wall_particle(int m_in, int which, double co copymode = 0; atomKK->modified(execution_space, F_MASK); - - k_oneflag.template modify(); - k_oneflag.template sync(); - if (k_oneflag.h_view()) error->one(FLERR,"Particle on or inside fix wall surface"); } template @@ -80,10 +74,8 @@ void FixWallLJ93Kokkos::wall_particle_item(int i, value_type ewall) if (side < 0) delta = x(i,dim) - coord; else delta = coord - x(i,dim); if (delta >= cutoff[m]) return; - if (delta <= 0.0) { - d_oneflag() = 1; - return; - } + if (delta <= 0.0) + Kokkos::abort("Particle on or inside fix wall surface"); double rinv = 1.0/delta; double r2inv = rinv*rinv; double r4inv = r2inv*r2inv; diff --git a/src/KOKKOS/fix_wall_lj93_kokkos.h b/src/KOKKOS/fix_wall_lj93_kokkos.h index 2bc78f3781..720e586f5d 100644 --- a/src/KOKKOS/fix_wall_lj93_kokkos.h +++ b/src/KOKKOS/fix_wall_lj93_kokkos.h @@ -50,7 +50,6 @@ class FixWallLJ93Kokkos : public FixWallLJ93 { typename AT::t_x_array x; typename AT::t_f_array f; typename AT::t_int_1d mask; - typename AT::t_int_scalar d_oneflag; }; template diff --git a/src/KOKKOS/fix_wall_reflect_kokkos.cpp b/src/KOKKOS/fix_wall_reflect_kokkos.cpp index a8a01c1926..731ce11f10 100644 --- a/src/KOKKOS/fix_wall_reflect_kokkos.cpp +++ b/src/KOKKOS/fix_wall_reflect_kokkos.cpp @@ -21,8 +21,6 @@ #include "update.h" #include "variable.h" -#include - using namespace LAMMPS_NS; enum{XLO=0,XHI=1,YLO=2,YHI=3,ZLO=4,ZHI=5}; diff --git a/src/KOKKOS/grid3d_kokkos.cpp b/src/KOKKOS/grid3d_kokkos.cpp index 87f2baff84..26882f20ca 100644 --- a/src/KOKKOS/grid3d_kokkos.cpp +++ b/src/KOKKOS/grid3d_kokkos.cpp @@ -24,7 +24,7 @@ using namespace LAMMPS_NS; -#define DELTA 16 +static constexpr int DELTA = 16; /* ---------------------------------------------------------------------- NOTES: diff --git a/src/KOKKOS/improper_class2_kokkos.cpp b/src/KOKKOS/improper_class2_kokkos.cpp index f1ed6fdbc0..862ba2a52f 100644 --- a/src/KOKKOS/improper_class2_kokkos.cpp +++ b/src/KOKKOS/improper_class2_kokkos.cpp @@ -27,8 +27,7 @@ using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/improper_harmonic_kokkos.cpp b/src/KOKKOS/improper_harmonic_kokkos.cpp index 1d217461d0..a075238f22 100644 --- a/src/KOKKOS/improper_harmonic_kokkos.cpp +++ b/src/KOKKOS/improper_harmonic_kokkos.cpp @@ -28,8 +28,8 @@ using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/kokkos.cpp b/src/KOKKOS/kokkos.cpp index b8bcd80a00..58b9436af6 100644 --- a/src/KOKKOS/kokkos.cpp +++ b/src/KOKKOS/kokkos.cpp @@ -57,7 +57,7 @@ KokkosLMP::KokkosLMP(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) reverse_pair_comm_changed = 0; forward_fix_comm_changed = 0; reverse_comm_changed = 0; - sort_changed = 0; + sort_changed = atom_map_changed = 0; delete memory; memory = new MemoryKokkos(lmp); @@ -225,6 +225,7 @@ KokkosLMP::KokkosLMP(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) exchange_comm_classic = forward_comm_classic = reverse_comm_classic = 0; forward_pair_comm_classic = reverse_pair_comm_classic = forward_fix_comm_classic = 0; sort_classic = 0; + atom_map_classic = 0; exchange_comm_on_host = forward_comm_on_host = reverse_comm_on_host = 0; } else { @@ -240,6 +241,7 @@ KokkosLMP::KokkosLMP(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) exchange_comm_classic = forward_comm_classic = reverse_comm_classic = 1; forward_pair_comm_classic = reverse_pair_comm_classic = forward_fix_comm_classic = 1; sort_classic = 1; + atom_map_classic = 1; exchange_comm_on_host = forward_comm_on_host = reverse_comm_on_host = 0; } @@ -503,6 +505,14 @@ void KokkosLMP::accelerator(int narg, char **arg) else error->all(FLERR,"Illegal package kokkos command"); sort_changed = 0; iarg += 2; + } else if (strcmp(arg[iarg],"atom/map") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal package kokkos command"); + else if (strcmp(arg[iarg+1],"no") == 0) atom_map_classic = 1; + else if (strcmp(arg[iarg+1],"host") == 0) atom_map_classic = 1; + else if (strcmp(arg[iarg+1],"device") == 0) atom_map_classic = 0; + else error->all(FLERR,"Illegal package kokkos command"); + atom_map_changed = 0; + iarg += 2; } 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"); @@ -563,6 +573,10 @@ void KokkosLMP::accelerator(int narg, char **arg) sort_classic = 1; sort_changed = 1; } + if (atom_map_classic == 0) { + atom_map_classic = 1; + atom_map_changed = 1; + } } // if "gpu/aware on" and "pair/only off", and comm flags were changed previously, change them back @@ -599,6 +613,10 @@ void KokkosLMP::accelerator(int narg, char **arg) sort_classic = 0; sort_changed = 0; } + if (atom_map_changed) { + atom_map_classic = 0; + atom_map_changed = 0; + } } #endif diff --git a/src/KOKKOS/kokkos.h b/src/KOKKOS/kokkos.h index 5406feab9b..748aff7f83 100644 --- a/src/KOKKOS/kokkos.h +++ b/src/KOKKOS/kokkos.h @@ -34,6 +34,7 @@ class KokkosLMP : protected Pointers { int forward_fix_comm_classic; int reverse_comm_classic; int sort_classic; + int atom_map_classic; int exchange_comm_on_host; int forward_comm_on_host; int reverse_comm_on_host; @@ -44,6 +45,7 @@ class KokkosLMP : protected Pointers { int forward_fix_comm_changed; int reverse_comm_changed; int sort_changed; + int atom_map_changed; int nthreads,ngpus; int auto_sync; int gpu_aware_flag; diff --git a/src/KOKKOS/kokkos_base.h b/src/KOKKOS/kokkos_base.h index 1e22a38657..22ed1687a9 100644 --- a/src/KOKKOS/kokkos_base.h +++ b/src/KOKKOS/kokkos_base.h @@ -26,18 +26,18 @@ class KokkosBase { KokkosBase() {} // Pair - virtual int pack_forward_comm_kokkos(int, DAT::tdual_int_2d, - int, DAT::tdual_xfloat_1d &, + virtual int pack_forward_comm_kokkos(int, DAT::tdual_int_1d, + DAT::tdual_xfloat_1d &, int, int *) {return 0;}; virtual void unpack_forward_comm_kokkos(int, int, DAT::tdual_xfloat_1d &) {} virtual int pack_reverse_comm_kokkos(int, int, DAT::tdual_xfloat_1d &) {return 0;}; - virtual void unpack_reverse_comm_kokkos(int, DAT::tdual_int_2d, - int, DAT::tdual_xfloat_1d &) {} + virtual void unpack_reverse_comm_kokkos(int, DAT::tdual_int_1d, + DAT::tdual_xfloat_1d &) {} // Fix - virtual int pack_forward_comm_fix_kokkos(int, DAT::tdual_int_2d, - int, DAT::tdual_xfloat_1d &, + virtual int pack_forward_comm_fix_kokkos(int, DAT::tdual_int_1d, + DAT::tdual_xfloat_1d &, int, int *) {return 0;}; virtual void unpack_forward_comm_fix_kokkos(int, int, DAT::tdual_xfloat_1d &) {} @@ -47,6 +47,7 @@ class KokkosBase { ExecutionSpace /*space*/) { return 0; } virtual void unpack_exchange_kokkos(DAT::tdual_xfloat_2d & /*k_buf*/, DAT::tdual_int_1d & /*indices*/, int /*nrecv*/, + int /*nrecv1*/, int /*nextrarecv1*/, ExecutionSpace /*space*/) {} // Region diff --git a/src/KOKKOS/kokkos_type.h b/src/KOKKOS/kokkos_type.h index 1009e43196..cc4e00819f 100644 --- a/src/KOKKOS/kokkos_type.h +++ b/src/KOKKOS/kokkos_type.h @@ -689,6 +689,14 @@ typedef tdual_int_2d_dl::t_dev_um t_int_2d_um_dl; typedef tdual_int_2d_dl::t_dev_const_um t_int_2d_const_um_dl; typedef tdual_int_2d_dl::t_dev_const_randomread t_int_2d_randomread_dl; +typedef Kokkos:: + DualView tdual_int_3d; +typedef tdual_int_3d::t_dev t_int_3d; +typedef tdual_int_3d::t_dev_const t_int_3d_const; +typedef tdual_int_3d::t_dev_um t_int_3d_um; +typedef tdual_int_3d::t_dev_const_um t_int_3d_const_um; +typedef tdual_int_3d::t_dev_const_randomread t_int_3d_randomread; + typedef Kokkos:: DualView tdual_tagint_1d; @@ -1006,6 +1014,13 @@ typedef tdual_int_2d_dl::t_host_um t_int_2d_um_dl; typedef tdual_int_2d_dl::t_host_const_um t_int_2d_const_um_dl; typedef tdual_int_2d_dl::t_host_const_randomread t_int_2d_randomread_dl; +typedef Kokkos::DualView tdual_int_3d; +typedef tdual_int_3d::t_host t_int_3d; +typedef tdual_int_3d::t_host_const t_int_3d_const; +typedef tdual_int_3d::t_host_um t_int_3d_um; +typedef tdual_int_3d::t_host_const_um t_int_3d_const_um; +typedef tdual_int_3d::t_host_const_randomread t_int_3d_randomread; + typedef Kokkos::DualView tdual_tagint_1d; typedef tdual_tagint_1d::t_host t_tagint_1d; typedef tdual_tagint_1d::t_host_const t_tagint_1d_const; diff --git a/src/KOKKOS/meam_dens_init_kokkos.h b/src/KOKKOS/meam_dens_init_kokkos.h index 60bb6553d8..68e69430fd 100644 --- a/src/KOKKOS/meam_dens_init_kokkos.h +++ b/src/KOKKOS/meam_dens_init_kokkos.h @@ -481,7 +481,7 @@ void MEAMKokkos::calc_rho1(int i, int /*ntype*/, typename AT::t_int_1d type, typename AT::t_int_1d d_map, typename AT::t_x_array x, typename AT::t_int_1d d_numneigh, int offset) const { - // The rho0, etc. arrays are duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The rho0, etc. arrays are duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_rho0 = ScatterViewHelper,decltype(dup_rho0),decltype(ndup_rho0)>::get(dup_rho0,ndup_rho0); auto a_rho0 = v_rho0.template access>(); auto v_arho2b = ScatterViewHelper,decltype(dup_arho2b),decltype(ndup_arho2b)>::get(dup_arho2b,ndup_arho2b); diff --git a/src/KOKKOS/meam_force_kokkos.h b/src/KOKKOS/meam_force_kokkos.h index d086230fc7..a546ab54d4 100644 --- a/src/KOKKOS/meam_force_kokkos.h +++ b/src/KOKKOS/meam_force_kokkos.h @@ -131,7 +131,7 @@ KOKKOS_INLINE_FUNCTION void MEAMKokkos::operator()(TagMEAMForce, decltype(dup_f), decltype(ndup_f)>::get( @@ -601,8 +601,31 @@ KOKKOS_INLINE_FUNCTION void MEAMKokkos::operator()(TagMEAMForce::operator()(TagMEAMForce } /* ---------------------------------------------------------------------- - grow or shrink 1st dim of a 1d array - last dim must stay the same + grow or shrink a 1d array ------------------------------------------------------------------------- */ template @@ -80,6 +79,10 @@ TYPE grow_kokkos(TYPE &data, typename TYPE::value_type *&array, return data; } +/* ---------------------------------------------------------------------- + destroy a 1d array +------------------------------------------------------------------------- */ + template void destroy_kokkos(TYPE data, typename TYPE::value_type* &array) { @@ -92,71 +95,6 @@ void destroy_kokkos(TYPE data, typename TYPE::value_type* &array) create a 2d array ------------------------------------------------------------------------- */ -template -TYPE destroy_kokkos(TYPE &data) -{ - /*if (data.data()!=nullptr) - free(data.data());*/ - data = TYPE(); - return data; -} - -template -TYPE create_kokkos(TYPE &data, int n1, const char *name) -{ - /*typename TYPE::non_const_value_type* ptr = (typename TYPE::non_const_value_type*) - malloc(n1*sizeof(typename TYPE::non_const_value_type)*4);*/ - data = TYPE(std::string(name),n1); - return data; -} - -template -TYPE create_kokkos(TYPE &data, int n1, int n2, const char *name) -{ - /*typename TYPE::non_const_value_type* ptr = (typename TYPE::non_const_value_type*) - malloc(n1*n2*sizeof(typename TYPE::non_const_value_type)*4);*/ - data = TYPE(std::string(name),n1,n2); - return data; -} - -template -TYPE create_kokkos(TYPE &data, int n1, int n2, int n3 ,const char *name) -{ - /*typename TYPE::non_const_value_type* ptr = (typename TYPE::non_const_value_type*) - malloc(n1*n2*n3*sizeof(typename TYPE::non_const_value_type)*4);*/ - data = TYPE(std::string(name),n1,n2,n3); - return data; -} - -template -TYPE create_kokkos(TYPE &data, int n1, int n2, int n3, int n4 ,const char *name) -{ - /*typename TYPE::non_const_value_type* ptr = (typename TYPE::non_const_value_type*) - malloc(n1*n2*n3*n4*sizeof(typename TYPE::non_const_value_type)*4);*/ - data = TYPE(std::string(name),n1,n2,n3,n4); - return data; -} - -template -TYPE create_kokkos(TYPE &data, int n1, int n2, int n3, int n4, int n5 ,const char *name) -{ - /*typename TYPE::non_const_value_type* ptr = (typename TYPE::non_const_value_type*) - malloc(n1*n2*n3*n4*n5*sizeof(typename TYPE::non_const_value_type)*4);*/ - data = TYPE(std::string(name),n1,n2,n3,n4,n5); - return data; -} - -template -TYPE create_kokkos(TYPE &data, int n1, int n2, int n3, int n4, int n5 , int n6 ,const char *name) -{ - /*typename TYPE::non_const_value_type* ptr = (typename TYPE::non_const_value_type*) - malloc(n1*n2*n3*n4*n5*n6*sizeof(typename TYPE::non_const_value_type)*4);*/ - data = TYPE(std::string(name) ,n1,n2,n3,n4,n5,n6); - return data; -} - - - template TYPE create_kokkos(TYPE &data, HTYPE &h_data, int n1, int n2, const char *name) @@ -202,20 +140,87 @@ template return data; } -template - TYPE create_kokkos(TYPE &data, HTYPE &h_data, int n1, int n2, int n3, - const char *name) +template +TYPE create_kokkos(TYPE &data, typename TYPE::value_type **&array, + int n1, const char *name) { - data = TYPE(std::string(name),n1,n2,n3); - h_data = Kokkos::create_mirror_view(data); + data = TYPE(std::string(name),n1); + bigint nbytes = ((bigint) sizeof(typename TYPE::value_type *)) * n1; + array = (typename TYPE::value_type **) smalloc(nbytes,name); + + for (int i = 0; i < n1; i++) + if (data.h_view.extent(1) == 0) + array[i] = nullptr; + else + array[i] = &data.h_view(i,0); + return data; } +/* ---------------------------------------------------------------------- + grow or shrink a 2d array +------------------------------------------------------------------------- */ + +template +TYPE grow_kokkos(TYPE &data, typename TYPE::value_type **&array, + int n1, int n2, const char *name) +{ + if (array == nullptr) return create_kokkos(data,array,n1,n2,name); + data.resize(n1,n2); + bigint nbytes = ((bigint) sizeof(typename TYPE::value_type *)) * n1; + array = (typename TYPE::value_type**) srealloc(array,nbytes,name); + + for (int i = 0; i < n1; i++) + if (n2 == 0) + array[i] = nullptr; + else + array[i] = &data.h_view(i,0); + + return data; +} + +template +TYPE grow_kokkos(TYPE &data, typename TYPE::value_type **&array, + int n1, const char *name) +{ + if (array == nullptr) return create_kokkos(data,array,n1,name); + + data.resize(n1); + + bigint nbytes = ((bigint) sizeof(typename TYPE::value_type *)) * n1; + array = (typename TYPE::value_type **) srealloc(array,nbytes,name); + + for (int i = 0; i < n1; i++) + if (data.h_view.extent(1) == 0) + array[i] = nullptr; + else + array[i] = &data.h_view(i,0); + + return data; +} + +/* ---------------------------------------------------------------------- + destroy a 2d array +------------------------------------------------------------------------- */ + +template +void destroy_kokkos(TYPE data, typename TYPE::value_type** &array) +{ + if (array == nullptr) return; + data = TYPE(); + sfree(array); + array = nullptr; +} + +/* ---------------------------------------------------------------------- + create a 3d array +------------------------------------------------------------------------- */ + template TYPE create_kokkos(TYPE &data, typename TYPE::value_type ***&array, int n1, int n2, int n3, const char *name) { - data = TYPE(std::string(name),n1,n2); + data = TYPE(std::string(name),n1,n2,n3); bigint nbytes = ((bigint) sizeof(typename TYPE::value_type **)) * n1; array = (typename TYPE::value_type ***) smalloc(nbytes,name); @@ -263,79 +268,46 @@ template return data; } +template + TYPE create_kokkos(TYPE &data, HTYPE &h_data, int n1, int n2, int n3, + const char *name) +{ + data = TYPE(std::string(name),n1,n2,n3); + h_data = Kokkos::create_mirror_view(data); + return data; +} + + /* ---------------------------------------------------------------------- - grow or shrink 1st dim of a 2d array - last dim must stay the same + grow or shrink a 3d array ------------------------------------------------------------------------- */ template -TYPE grow_kokkos(TYPE &data, typename TYPE::value_type **&array, - int n1, int n2, const char *name) +TYPE grow_kokkos(TYPE &data, typename TYPE::value_type ***&array, + int n1, int n2, int n3, const char *name) { - if (array == nullptr) return create_kokkos(data,array,n1,n2,name); - data.resize(n1,n2); - bigint nbytes = ((bigint) sizeof(typename TYPE::value_type *)) * n1; - array = (typename TYPE::value_type**) srealloc(array,nbytes,name); + if (array == nullptr) return create_kokkos(data,array,n1,n2,n3,name); + data.resize(n1,n2,n3); + bigint nbytes = ((bigint) sizeof(typename TYPE::value_type **)) * n1; + array = (typename TYPE::value_type ***) smalloc(nbytes,name); - for (int i = 0; i < n1; i++) - if (n2 == 0) + for (int i = 0; i < n1; i++) { + if (n2 == 0) { array[i] = nullptr; - else - array[i] = &data.h_view(i,0); - + } else { + nbytes = ((bigint) sizeof(typename TYPE::value_type *)) * n2; + array[i] = (typename TYPE::value_type **) smalloc(nbytes,name); + for (int j = 0; j < n2; j++) { + if (n3 == 0) + array[i][j] = nullptr; + else + array[i][j] = &data.h_view(i,j,0); + } + } + } return data; } -template -TYPE create_kokkos(TYPE &data, typename TYPE::value_type **&array, - int n1, const char *name) -{ - data = TYPE(std::string(name),n1); - bigint nbytes = ((bigint) sizeof(typename TYPE::value_type *)) * n1; - array = (typename TYPE::value_type **) smalloc(nbytes,name); - - for (int i = 0; i < n1; i++) - if (data.h_view.extent(1) == 0) - array[i] = nullptr; - else - array[i] = &data.h_view(i,0); - - return data; -} - -template -TYPE grow_kokkos(TYPE &data, typename TYPE::value_type **&array, - int n1, const char *name) -{ - if (array == nullptr) return create_kokkos(data,array,n1,name); - - data.resize(n1); - - bigint nbytes = ((bigint) sizeof(typename TYPE::value_type *)) * n1; - array = (typename TYPE::value_type **) srealloc(array,nbytes,name); - - for (int i = 0; i < n1; i++) - if (data.h_view.extent(1) == 0) - array[i] = nullptr; - else - array[i] = &data.h_view(i,0); - - return data; -} - -/* ---------------------------------------------------------------------- - destroy a 2d array -------------------------------------------------------------------------- */ - -template -void destroy_kokkos(TYPE data, typename TYPE::value_type** &array) -{ - if (array == nullptr) return; - data = TYPE(); - sfree(array); - array = nullptr; -} - /* ---------------------------------------------------------------------- destroy a 3d array ------------------------------------------------------------------------- */ @@ -374,6 +346,65 @@ static double memory_usage(TYPE &data) return data.span() * sizeof(typename TYPE::value_type); } +/* ---------------------------------------------------------------------- + legacy functions +------------------------------------------------------------------------- */ + +template +TYPE destroy_kokkos(TYPE &data) +{ + data = TYPE(); + return data; +} + +template +TYPE create_kokkos(TYPE &data, int n1, const char *name) +{ + data = TYPE(); + data = TYPE(std::string(name),n1); + return data; +} + +template +TYPE create_kokkos(TYPE &data, int n1, int n2, const char *name) +{ + data = TYPE(); + data = TYPE(std::string(name),n1,n2); + return data; +} + +template +TYPE create_kokkos(TYPE &data, int n1, int n2, int n3 ,const char *name) +{ + data = TYPE(); + data = TYPE(std::string(name),n1,n2,n3); + return data; +} + +template +TYPE create_kokkos(TYPE &data, int n1, int n2, int n3, int n4 ,const char *name) +{ + data = TYPE(); + data = TYPE(std::string(name),n1,n2,n3,n4); + return data; +} + +template +TYPE create_kokkos(TYPE &data, int n1, int n2, int n3, int n4, int n5 ,const char *name) +{ + data = TYPE(); + data = TYPE(std::string(name),n1,n2,n3,n4,n5); + return data; +} + +template +TYPE create_kokkos(TYPE &data, int n1, int n2, int n3, int n4, int n5 , int n6 ,const char *name) +{ + data = TYPE(); + data = TYPE(std::string(name) ,n1,n2,n3,n4,n5,n6); + return data; +} + }; } diff --git a/src/KOKKOS/min_cg_kokkos.cpp b/src/KOKKOS/min_cg_kokkos.cpp index d9a7088c3b..17cce19a70 100644 --- a/src/KOKKOS/min_cg_kokkos.cpp +++ b/src/KOKKOS/min_cg_kokkos.cpp @@ -13,21 +13,22 @@ ------------------------------------------------------------------------- */ #include "min_cg_kokkos.h" -#include -#include -#include "update.h" -#include "output.h" -#include "timer.h" + #include "atom_kokkos.h" #include "atom_masks.h" #include "error.h" #include "fix_minimize_kokkos.h" +#include "output.h" +#include "timer.h" +#include "update.h" + +#include using namespace LAMMPS_NS; // EPS_ENERGY = minimum normalization for energy tolerance -#define EPS_ENERGY 1.0e-8 +static constexpr double EPS_ENERGY = 1.0e-8; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/min_linesearch_kokkos.cpp b/src/KOKKOS/min_linesearch_kokkos.cpp index 2d424957c5..61aa3900cd 100644 --- a/src/KOKKOS/min_linesearch_kokkos.cpp +++ b/src/KOKKOS/min_linesearch_kokkos.cpp @@ -38,13 +38,12 @@ using namespace LAMMPS_NS; // EMACH = machine accuracy limit of energy changes (1.0e-8) // EPS_QUAD = tolerance for quadratic projection -#define ALPHA_MAX 1.0 -#define ALPHA_REDUCE 0.5 -#define BACKTRACK_SLOPE 0.4 -#define QUADRATIC_TOL 0.1 -//#define EMACH 1.0e-8 -#define EMACH 1.0e-8 -#define EPS_QUAD 1.0e-28 +static constexpr double ALPHA_MAX = 1.0; +static constexpr double ALPHA_REDUCE = 0.5; +static constexpr double BACKTRACK_SLOPE = 0.4; +static constexpr double QUADRATIC_TOL = 0.1; +static constexpr double EMACH = 1.0e-8; +static constexpr double EPS_QUAD = 1.0e-28; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/mliap_data_kokkos.cpp b/src/KOKKOS/mliap_data_kokkos.cpp index e5b34ecaa0..fd5a852114 100644 --- a/src/KOKKOS/mliap_data_kokkos.cpp +++ b/src/KOKKOS/mliap_data_kokkos.cpp @@ -22,8 +22,6 @@ #include "kokkos_type.h" #include "pair_mliap_kokkos.h" #include "atom_masks.h" -#include "mliap_descriptor.h" -#include "lammps.h" #include "kokkos.h" /* ---------------------------------------------------------------------- */ @@ -59,7 +57,6 @@ MLIAPDataKokkos::~MLIAPDataKokkos() { memoryKK->destroy_kokkos(k_pair_i,pair_i); memoryKK->destroy_kokkos(k_jelems,jelems); memoryKK->destroy_kokkos(k_elems,elems); - memoryKK->destroy_kokkos(k_ij); memoryKK->destroy_kokkos(k_rij,rij); memoryKK->destroy_kokkos(k_graddesc,graddesc); } @@ -72,7 +69,6 @@ void MLIAPDataKokkos::generate_neighdata(class NeighList *list_in, i list = list_in; // grow nmax gradforce array if necessary - if (atom->nmax > nmax) { nmax = atom->nmax; if (gradgradflag > -1){ @@ -149,13 +145,13 @@ void MLIAPDataKokkos::generate_neighdata(class NeighList *list_in, i auto type = atomKK->k_type.view(); auto map=k_pairmliap->k_map.template view(); - Kokkos::parallel_scan(nlistatoms, KOKKOS_LAMBDA (int ii, int &update, const bool final) { + Kokkos::parallel_scan(natomneigh, KOKKOS_LAMBDA (int ii, int &update, const bool final) { if (final) d_ij(ii) = update; update += d_numneighs(ii); }); - Kokkos::parallel_for(nlistatoms, KOKKOS_LAMBDA (int ii) { + Kokkos::parallel_for(natomneigh, KOKKOS_LAMBDA (int ii) { int ij = d_ij(ii); const int i = d_ilist[ii]; const double xtmp = x(i, 0); @@ -186,10 +182,12 @@ void MLIAPDataKokkos::generate_neighdata(class NeighList *list_in, i d_iatoms[ii] = i; d_ielems[ii] = ielem; }); + Kokkos::parallel_for(nmax, KOKKOS_LAMBDA (int i) { const int itype = type(i); d_elems(i) = map(itype); }); + modified(execution_space, NUMNEIGHS_MASK | IATOMS_MASK | IELEMS_MASK | ELEMS_MASK | JATOMS_MASK | PAIR_I_MASK | JELEMS_MASK | RIJ_MASK | IJ_MASK ); eflag = eflag_in; vflag = vflag_in; @@ -203,15 +201,15 @@ void MLIAPDataKokkos::grow_neigharrays() { f = atom->f; f_device = atomKK->k_f.view().data(); // grow neighbor arrays if necessary - - if (natomneigh_max < nlistatoms) { - natomneigh_max = nlistatoms; + natomneigh = list->inum; + if (list->ghost == 1) natomneigh += list->gnum; + if (natomneigh_max < natomneigh) { + natomneigh_max = natomneigh; memoryKK->destroy_kokkos(k_iatoms,iatoms); memoryKK->create_kokkos(k_iatoms, iatoms, natomneigh_max, "mliap_data:iatoms"); memoryKK->destroy_kokkos(k_ielems,ielems); memoryKK->create_kokkos(k_ielems, ielems, natomneigh_max, "mliap_data:ielems"); - memoryKK->destroy_kokkos(k_ij); memoryKK->create_kokkos(k_ij, natomneigh_max, "mliap_data:ij"); memoryKK->destroy_kokkos(k_numneighs,numneighs); memoryKK->create_kokkos(k_numneighs, numneighs, natomneigh_max, "mliap_data:numneighs"); @@ -227,7 +225,7 @@ void MLIAPDataKokkos::grow_neigharrays() { auto d_cutsq=k_pairmliap->k_cutsq.template view(); auto h_cutsq=k_pairmliap->k_cutsq.template view(); auto d_numneighs = k_numneighs.template view(); - Kokkos::parallel_reduce(nlistatoms, KOKKOS_LAMBDA (int ii, int &contrib) { + Kokkos::parallel_reduce(natomneigh, KOKKOS_LAMBDA (int ii, int &contrib) { const int i = d_ilist[ii]; int count=0; const double xtmp = x(i, 0); diff --git a/src/KOKKOS/mliap_descriptor_kokkos.h b/src/KOKKOS/mliap_descriptor_kokkos.h index 075f0e9fed..d4ab72ff96 100644 --- a/src/KOKKOS/mliap_descriptor_kokkos.h +++ b/src/KOKKOS/mliap_descriptor_kokkos.h @@ -29,13 +29,11 @@ template class MLIAPDescriptorKokkos : virtual protected Poin MLIAPDescriptorKokkos(LAMMPS *lmp, MLIAPDescriptor *descriptor_in) : Pointers(lmp), descriptor(descriptor_in) { - memoryKK->destroy_kokkos(k_wjelem); } void init_data() { int num_elems = descriptor->nelements; - memoryKK->destroy_kokkos(k_wjelem); memoryKK->create_kokkos(k_wjelem, num_elems, "MLIAPDescriptorKokkos::k_wjelem"); for (int i = 0; i < num_elems; ++i) k_wjelem.h_view(i) = descriptor->wjelem[i]; k_wjelem.modify(); @@ -44,7 +42,6 @@ template class MLIAPDescriptorKokkos : virtual protected Poin virtual ~MLIAPDescriptorKokkos() { - memoryKK->destroy_kokkos(k_wjelem); } MLIAPDescriptor *descriptor; diff --git a/src/KOKKOS/mliap_descriptor_so3_kokkos.cpp b/src/KOKKOS/mliap_descriptor_so3_kokkos.cpp index ff9e5d2aa6..1cf368e952 100644 --- a/src/KOKKOS/mliap_descriptor_so3_kokkos.cpp +++ b/src/KOKKOS/mliap_descriptor_so3_kokkos.cpp @@ -21,19 +21,12 @@ #include "atom_kokkos.h" #include "comm.h" #include "error.h" -#include "memory.h" #include "mliap_data_kokkos.h" #include "mliap_so3_kokkos.h" #include "pair_mliap.h" -#include "tokenizer.h" - -#include using namespace LAMMPS_NS; -#define MAXLINE 1024 -#define MAXWORD 3 - /* ---------------------------------------------------------------------- */ template MLIAPDescriptorSO3Kokkos::MLIAPDescriptorSO3Kokkos(LAMMPS *lmp, char *paramfilename) diff --git a/src/KOKKOS/mliap_model_kokkos.h b/src/KOKKOS/mliap_model_kokkos.h index 72077f5988..4840798cc1 100644 --- a/src/KOKKOS/mliap_model_kokkos.h +++ b/src/KOKKOS/mliap_model_kokkos.h @@ -29,14 +29,12 @@ template class MLIAPModelKokkos : protected Pointers { MLIAPModelKokkos(LAMMPS *lmp, MLIAPModel *model_in) : Pointers(lmp), model(model_in) {} virtual ~MLIAPModelKokkos() { - memoryKK->destroy_kokkos(k_coeffelem); model->coeffelem = nullptr; } void set_k_coeffelem() { double **tmp = nullptr; - memoryKK->destroy_kokkos(k_coeffelem); memoryKK->create_kokkos(k_coeffelem, tmp, model->nelements, model->nparams, "MLIAPModelKokkos::coeffelem"); for (int i = 0; i < model->nelements; ++i) diff --git a/src/KOKKOS/mliap_model_linear_kokkos.cpp b/src/KOKKOS/mliap_model_linear_kokkos.cpp index b294dad294..f4fef82023 100644 --- a/src/KOKKOS/mliap_model_linear_kokkos.cpp +++ b/src/KOKKOS/mliap_model_linear_kokkos.cpp @@ -19,7 +19,6 @@ #include "mliap_model_linear_kokkos.h" #include "mliap_data_kokkos.h" -#include "error.h" using namespace LAMMPS_NS; diff --git a/src/KOKKOS/mliap_so3_kokkos.cpp b/src/KOKKOS/mliap_so3_kokkos.cpp index 1fb5ffb52e..155bee9294 100644 --- a/src/KOKKOS/mliap_so3_kokkos.cpp +++ b/src/KOKKOS/mliap_so3_kokkos.cpp @@ -21,7 +21,6 @@ #include "error.h" #include "math_const.h" #include "math_special_kokkos.h" -#include "memory.h" #include "memory_kokkos.h" #include "mliap_so3_math.h" @@ -32,7 +31,7 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecialKokkos; -#define SMALL 1.0e-8 +static constexpr double SMALL = 1.0e-8; /* ---------------------------------------------------------------------- */ @@ -60,44 +59,6 @@ MLIAP_SO3Kokkos::MLIAP_SO3Kokkos(LAMMPS *lmp, double vrcut, int vlma template MLIAP_SO3Kokkos::~MLIAP_SO3Kokkos() { - memoryKK->destroy_kokkos(m_ellpl1); - memoryKK->destroy_kokkos(m_ellm1); - memoryKK->destroy_kokkos(m_pfac); - memoryKK->destroy_kokkos(m_Ylms); - memoryKK->destroy_kokkos(m_dfac0); - memoryKK->destroy_kokkos(m_dfac1); - memoryKK->destroy_kokkos(m_dfac2); - memoryKK->destroy_kokkos(m_dfac3); - memoryKK->destroy_kokkos(m_dfac4); - memoryKK->destroy_kokkos(m_dfac5); - memoryKK->destroy_kokkos(m_w); - memoryKK->destroy_kokkos(m_g_array); - - memoryKK->destroy_kokkos(m_rootpq); - memoryKK->destroy_kokkos(m_idxu_block); - memoryKK->destroy_kokkos(m_idxylm); - - memoryKK->destroy_kokkos(m_rip_array); - memoryKK->destroy_kokkos(m_rip_darray); - - memoryKK->destroy_kokkos(m_sbes_array); - memoryKK->destroy_kokkos(m_sbes_darray); - - memoryKK->destroy_kokkos(m_plist_r); - - memoryKK->destroy_kokkos(m_ulist_r); - memoryKK->destroy_kokkos(m_ulist_i); - - memoryKK->destroy_kokkos(m_dYlm_r); - memoryKK->destroy_kokkos(m_dYlm_i); - - memoryKK->destroy_kokkos(k_dplist_r); - - memoryKK->destroy_kokkos(m_dclist); - - memoryKK->destroy_kokkos(m_clisttot_r); - memoryKK->destroy_kokkos(m_clisttot_i); - t_numneighs = int_1d(); t_jelems = int_1d(); t_wjelem = float_1d(); @@ -121,9 +82,7 @@ void MLIAP_SO3Kokkos::init() int totali; totali = m_lmax + 1; - memoryKK->destroy_kokkos(m_ellpl1); memoryKK->create_kokkos(m_ellpl1, totali, "MLIAP_SO3Kokkos:m_ellpl1"); - memoryKK->destroy_kokkos(m_ellm1); memoryKK->create_kokkos(m_ellm1, totali, "MLIAP_SO3Kokkos:m_ellm1"); alloc_init = 2.0 * totali * sizeof(double); using range=Kokkos::RangePolicy; @@ -139,9 +98,7 @@ void MLIAP_SO3Kokkos::init() m_pfac_l1 = m_lmax + 2; m_pfac_l2 = (m_lmax + 2) * (m_lmax + 2) + 1; totali = m_pfac_l1 * m_pfac_l2; - memoryKK->destroy_kokkos(m_pfac); memoryKK->create_kokkos(m_pfac, totali, "MLIAP_SO3Kokkos:m_pfac"); - memoryKK->destroy_kokkos(m_Ylms); memoryKK->create_kokkos(m_Ylms, totali, "MLIAP_SO3Kokkos:m_Ylms"); alloc_init += 2 * totali * sizeof(double); @@ -161,17 +118,11 @@ void MLIAP_SO3Kokkos::init() m_dfac_l1 = m_lmax + 1; m_dfac_l2 = m_numYlms + 1; totali = m_dfac_l1 * m_dfac_l2; - memoryKK->destroy_kokkos(m_dfac0); memoryKK->create_kokkos(m_dfac0, totali, "MLIAP_SO3Kokkos:m_dfac0"); - memoryKK->destroy_kokkos(m_dfac1); memoryKK->create_kokkos(m_dfac1, totali, "MLIAP_SO3Kokkos:m_dfac1"); - memoryKK->destroy_kokkos(m_dfac2); memoryKK->create_kokkos(m_dfac2, totali, "MLIAP_SO3Kokkos:m_dfac2"); - memoryKK->destroy_kokkos(m_dfac3); memoryKK->create_kokkos(m_dfac3, totali, "MLIAP_SO3Kokkos:m_dfac3"); - memoryKK->destroy_kokkos(m_dfac4); memoryKK->create_kokkos(m_dfac4, totali, "MLIAP_SO3Kokkos:m_dfac4"); - memoryKK->destroy_kokkos(m_dfac5); memoryKK->create_kokkos(m_dfac5, totali, "MLIAP_SO3Kokkos:m_dfac5"); alloc_init += 6.0 * totali * sizeof(double); @@ -197,12 +148,10 @@ void MLIAP_SO3Kokkos::init() }); totali = m_nmax * m_nmax; - memoryKK->destroy_kokkos(m_w); memoryKK->create_kokkos(m_w, totali, "MLIAP_SO3Kokkos:w"); alloc_init += totali * sizeof(double); totali = m_nmax * m_Nmax; - memoryKK->destroy_kokkos(m_g_array); memoryKK->create_kokkos(m_g_array, totali, "MLIAP_SO3Kokkos:g_array"); alloc_init += totali * sizeof(double); @@ -218,7 +167,6 @@ void MLIAP_SO3Kokkos::init() twolmax = 2 * (m_lmax + 1); int m_ldim = twolmax + 1; totali = m_ldim * m_ldim; - memoryKK->destroy_kokkos(m_rootpq); memoryKK->create_kokkos(m_rootpq, totali, "MLIAP_SO3Kokkos:rootpq"); alloc_init += totali * sizeof(double); @@ -229,12 +177,10 @@ void MLIAP_SO3Kokkos::init() rootpq[p * ldim + q] = sqrt(static_cast(p) / q); }); - memoryKK->destroy_kokkos(m_idxu_block); memoryKK->create_kokkos(m_idxu_block, m_ldim, "MLIAP_SO3Kokkos:idxu_bloc"); alloc_init += totali * sizeof(double); totali = square(m_lmax + 2); - memoryKK->destroy_kokkos(m_idxylm); memoryKK->create_kokkos(m_idxylm, totali, "MLIAP_SO3Kokkos:idxylm"); alloc_init += totali * sizeof(double); @@ -278,7 +224,6 @@ void MLIAP_SO3Kokkos::init_arrays(int nlocal, int ncoefs) int totali = nlocal * ncoefs; if ( nlocal > (int)m_plist_r.extent(0)) { - memoryKK->destroy_kokkos(m_plist_r); memoryKK->create_kokkos(m_plist_r, nlocal, ncoefs, "MLIAP_SO3Kokkos:m_plist_r"); alloc_arrays = totali * sizeof(double); } @@ -286,26 +231,19 @@ void MLIAP_SO3Kokkos::init_arrays(int nlocal, int ncoefs) int num_of_temp = std::min(nlocal, m_chunk_size); if ((int)m_ulist_r.extent(0) < num_of_temp ) { totali = m_idxu_count; - memoryKK->destroy_kokkos(m_ulist_r); memoryKK->create_kokkos(m_ulist_r, num_of_temp, totali, "MLIAP_SO3Kokkos:m_ulist_r"); - memoryKK->destroy_kokkos(m_ulist_i); memoryKK->create_kokkos(m_ulist_i, num_of_temp, totali, "MLIAP_SO3Kokkos:m_ulist_i"); alloc_arrays += 2.0 * totali * num_of_temp * sizeof(double); totali = m_numYlms * 3; - memoryKK->destroy_kokkos(m_dYlm_r); memoryKK->create_kokkos(m_dYlm_r, num_of_temp, m_numYlms, 3, "MLIAP_SO3Kokkos:m_dYlm_r"); - memoryKK->destroy_kokkos(m_dYlm_i); memoryKK->create_kokkos(m_dYlm_i, num_of_temp, m_numYlms, 3, "MLIAP_SO3Kokkos:m_dYlm_i"); alloc_arrays += 2.0 * m_numYlms * 3 * num_of_temp * sizeof(double); - memoryKK->destroy_kokkos(m_dclist); memoryKK->create_kokkos(m_dclist, num_of_temp, m_nmax, m_numYlms, 3, "MLIAP_SO3Kokkos:k_dclist_r"); alloc_arrays += m_nmax * m_numYlms * 3 * num_of_temp* sizeof(double); - memoryKK->destroy_kokkos(m_clisttot_r); memoryKK->create_kokkos(m_clisttot_r, num_of_temp, m_nmax, m_numYlms, "MLIAP_SO3Kokkos:m_clisttot_r"); - memoryKK->destroy_kokkos(m_clisttot_i); memoryKK->create_kokkos(m_clisttot_i, num_of_temp, m_nmax, m_numYlms, "MLIAP_SO3Kokkos:m_clisttot_i"); alloc_arrays += 2.0 * m_nmax * m_numYlms * num_of_temp * sizeof(double); m_init_arrays = 1; @@ -850,21 +788,15 @@ void MLIAP_SO3Kokkos::spectrum_dxdr(int nlocal, DAT::tdual_int_1d nu bigint totali; if ( nlocal > (int)m_clisttot_r.extent(0)){ - memoryKK->destroy_kokkos(m_clisttot_r); memoryKK->create_kokkos(m_clisttot_r, nlocal, m_nmax, m_numYlms, "MLIAP_SO3Kokkos:m_clisttot_r"); - memoryKK->destroy_kokkos(m_clisttot_i); memoryKK->create_kokkos(m_clisttot_i, nlocal, m_nmax, m_numYlms, "MLIAP_SO3Kokkos:m_clisttot_i"); int num_of_temp = std::min(nlocal, m_chunk_size); int delta=num_of_temp-m_ulist_r.extent(0); if (delta > 0){ - memoryKK->destroy_kokkos(m_ulist_r); memoryKK->create_kokkos(m_ulist_r, num_of_temp, m_idxu_count, "MLIAP_SO3Kokkos:m_ulist_r"); - memoryKK->destroy_kokkos(m_ulist_i); memoryKK->create_kokkos(m_ulist_i, num_of_temp, m_idxu_count, "MLIAP_SO3Kokkos:m_ulist_i"); alloc_arrays += 2.0 * m_idxu_count * delta * sizeof(double); - memoryKK->destroy_kokkos(m_dYlm_r); memoryKK->create_kokkos(m_dYlm_r, num_of_temp, m_numYlms, 3, "MLIAP_SO3Kokkos:m_dYlm_r"); - memoryKK->destroy_kokkos(m_dYlm_i); memoryKK->create_kokkos(m_dYlm_i, num_of_temp, m_numYlms, 3, "MLIAP_SO3Kokkos:m_dYlm_i"); alloc_arrays += 2.0 * m_numYlms * 3 * delta * sizeof(double); } @@ -872,18 +804,13 @@ void MLIAP_SO3Kokkos::spectrum_dxdr(int nlocal, DAT::tdual_int_1d nu totali = totaln * m_Nmax * (m_lmax + 1); if ( totali > (int)m_sbes_array.extent(0)) { - memoryKK->destroy_kokkos(m_sbes_array); memoryKK->create_kokkos(m_sbes_array, totali, "MLIAP_SO3Kokkos:m_sbes_array"); - memoryKK->destroy_kokkos(m_sbes_darray); memoryKK->create_kokkos(m_sbes_darray, totali, "MLIAP_SO3Kokkos:m_sbes_darray"); totali = totaln * m_nmax * (m_lmax + 1); - memoryKK->destroy_kokkos(m_rip_array); memoryKK->create_kokkos(m_rip_array, totali, "MLIAP_SO3Kokkos:m_rip_array"); - memoryKK->destroy_kokkos(m_rip_darray); memoryKK->create_kokkos(m_rip_darray, totali, "MLIAP_SO3Kokkos:m_rip_darray"); - memoryKK->destroy_kokkos(k_dplist_r); memoryKK->create_kokkos(k_dplist_r, (int)totaln, ncoefs, 3, "MLIAP_SO3Kokkos:m_dplist_r"); } diff --git a/src/KOKKOS/mliap_unified_couple_kokkos.pyx b/src/KOKKOS/mliap_unified_couple_kokkos.pyx index 97d807ac33..385a770bb3 100644 --- a/src/KOKKOS/mliap_unified_couple_kokkos.pyx +++ b/src/KOKKOS/mliap_unified_couple_kokkos.pyx @@ -13,6 +13,7 @@ from libc.stdint cimport uintptr_t cimport cython from cpython.ref cimport PyObject from libc.stdlib cimport malloc, free +from libc.string cimport memcpy cdef extern from "lammps.h" namespace "LAMMPS_NS": @@ -451,15 +452,24 @@ cdef public object mliap_unified_connect_kokkos(char *fname, MLIAPDummyModel * m cdef int nelements = len(unified.element_types) cdef char **elements = malloc(nelements * sizeof(char*)) + cdef char * c_str + cdef char * s + cdef ssize_t slen if not elements: raise MemoryError("failed to allocate memory for element names") - cdef char *elem_name for i, elem in enumerate(unified.element_types): - elem_name_bytes = elem.encode('UTF-8') - elem_name = elem_name_bytes - elements[i] = &elem_name[0] + py_str = elem.encode('UTF-8') + s = py_str + slen = len(py_str) + c_str = malloc((slen+1)*sizeof(char)) + if not c_str: + raise MemoryError("failed to allocate memory for element names") + memcpy(c_str, s, slen) + c_str[slen] = 0 + elements[i] = c_str + unified_int.descriptor.set_elements(elements, nelements) unified_int.model.nelements = nelements diff --git a/src/KOKKOS/mliap_unified_kokkos.cpp b/src/KOKKOS/mliap_unified_kokkos.cpp index 4c38e4f1d6..e85f836254 100644 --- a/src/KOKKOS/mliap_unified_kokkos.cpp +++ b/src/KOKKOS/mliap_unified_kokkos.cpp @@ -315,7 +315,6 @@ void LAMMPS_NS::update_pair_forces(MLIAPDataKokkosDevice *data, double *fij) int i = pair_i[ii]; int j = j_atoms[ii]; // must not count any contribution where i is not a local atom - if (i < nlocal) { Kokkos::atomic_add(&f[i*3+0], fij[ii3+0]); Kokkos::atomic_add(&f[i*3+1], fij[ii3+1]); Kokkos::atomic_add(&f[i*3+2], fij[ii3+2]); @@ -352,7 +351,6 @@ void LAMMPS_NS::update_pair_forces(MLIAPDataKokkosDevice *data, double *fij) Kokkos::atomic_add(&d_vatom(j,3), 0.5*v[3]); Kokkos::atomic_add(&d_vatom(j,4), 0.5*v[4]); Kokkos::atomic_add(&d_vatom(j,5), 0.5*v[5]); - } } } }); @@ -382,11 +380,9 @@ void LAMMPS_NS::update_atom_energy(MLIAPDataKokkosDevice *data, double *ei) Kokkos::parallel_reduce(nlocal, KOKKOS_LAMBDA(int i, double &local_sum){ double e = ei[i]; - // must not count any contribution where i is not a local atom - if (i < nlocal) { - d_eatoms[i] = e; - local_sum += e; - } + + d_eatoms[i] = e; + local_sum += e; },*data->energy); } diff --git a/src/KOKKOS/modify_kokkos.cpp b/src/KOKKOS/modify_kokkos.cpp index 8d8ffca671..26ee88ff51 100644 --- a/src/KOKKOS/modify_kokkos.cpp +++ b/src/KOKKOS/modify_kokkos.cpp @@ -21,7 +21,7 @@ using namespace LAMMPS_NS; -#define BIG 1.0e20 +static constexpr double BIG = 1.0e20; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/nbin_kokkos.cpp b/src/KOKKOS/nbin_kokkos.cpp index e65cf4ecb7..79ae9c6632 100644 --- a/src/KOKKOS/nbin_kokkos.cpp +++ b/src/KOKKOS/nbin_kokkos.cpp @@ -22,9 +22,6 @@ using namespace LAMMPS_NS; -#define SMALL 1.0e-6 -#define CUT2BIN_RATIO 100 - /* ---------------------------------------------------------------------- */ template diff --git a/src/KOKKOS/nbin_ssa_kokkos.cpp b/src/KOKKOS/nbin_ssa_kokkos.cpp index 6e7390d3c6..63c2fe22c1 100644 --- a/src/KOKKOS/nbin_ssa_kokkos.cpp +++ b/src/KOKKOS/nbin_ssa_kokkos.cpp @@ -18,13 +18,12 @@ ------------------------------------------------------------------------- */ #include "nbin_ssa_kokkos.h" -#include "neighbor.h" + #include "atom_kokkos.h" #include "domain.h" #include "update.h" #include "atom_masks.h" - -// #include "memory_kokkos.h" +#include "kokkos_type.h" using namespace LAMMPS_NS; diff --git a/src/KOKKOS/neigh_bond_kokkos.cpp b/src/KOKKOS/neigh_bond_kokkos.cpp index b749590779..9e1c8c273b 100644 --- a/src/KOKKOS/neigh_bond_kokkos.cpp +++ b/src/KOKKOS/neigh_bond_kokkos.cpp @@ -27,6 +27,7 @@ #include "force.h" #include "memory_kokkos.h" #include "modify.h" +#include "neighbor.h" #include "output.h" #include "thermo.h" #include "update.h" @@ -35,8 +36,8 @@ #include using namespace LAMMPS_NS; -#define BONDDELTA 10000 -#define LB_FACTOR 1.5 +static constexpr int BONDDELTA = 10000; +static constexpr double LB_FACTOR = 1.5; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/neigh_bond_kokkos.h b/src/KOKKOS/neigh_bond_kokkos.h index 480726c602..f60903f73e 100644 --- a/src/KOKKOS/neigh_bond_kokkos.h +++ b/src/KOKKOS/neigh_bond_kokkos.h @@ -15,9 +15,7 @@ #ifndef LMP_NEIGH_BOND_KOKKOS_H #define LMP_NEIGH_BOND_KOKKOS_H -#include "neighbor.h" #include "kokkos_type.h" -#include "domain_kokkos.h" #include "pointers.h" #include diff --git a/src/KOKKOS/neighbor_kokkos.cpp b/src/KOKKOS/neighbor_kokkos.cpp index efb1247560..214b2e86d9 100644 --- a/src/KOKKOS/neighbor_kokkos.cpp +++ b/src/KOKKOS/neighbor_kokkos.cpp @@ -18,16 +18,14 @@ #include "atom_kokkos.h" #include "atom_masks.h" #include "bond.h" -#include "comm.h" +#include "domain.h" #include "dihedral.h" #include "error.h" -#include "fix.h" #include "force.h" #include "improper.h" #include "kokkos.h" #include "memory_kokkos.h" #include "neigh_request.h" -#include "pair.h" #include "style_nbin.h" #include "style_npair.h" #include "style_nstencil.h" diff --git a/src/KOKKOS/npair_skip_kokkos.cpp b/src/KOKKOS/npair_skip_kokkos.cpp index 15c0487010..91a2cfa17e 100644 --- a/src/KOKKOS/npair_skip_kokkos.cpp +++ b/src/KOKKOS/npair_skip_kokkos.cpp @@ -16,7 +16,6 @@ #include "atom_kokkos.h" #include "atom_masks.h" -#include "atom_vec.h" #include "neigh_list_kokkos.h" using namespace LAMMPS_NS; diff --git a/src/KOKKOS/pair_adp_kokkos.cpp b/src/KOKKOS/pair_adp_kokkos.cpp index 86ba3d267e..1297d62651 100644 --- a/src/KOKKOS/pair_adp_kokkos.cpp +++ b/src/KOKKOS/pair_adp_kokkos.cpp @@ -472,12 +472,11 @@ void PairADPKokkos::interpolate(int n, double delta, double *f, t_ho /* ---------------------------------------------------------------------- */ template -int PairADPKokkos::pack_forward_comm_kokkos(int n, DAT::tdual_int_2d k_sendlist, - int iswap_in, DAT::tdual_xfloat_1d &buf, +int PairADPKokkos::pack_forward_comm_kokkos(int n, DAT::tdual_int_1d k_sendlist, + DAT::tdual_xfloat_1d &buf, int /*pbc_flag*/, int * /*pbc*/) { d_sendlist = k_sendlist.view(); - iswap = iswap_in; v_buf = buf.view(); Kokkos::parallel_for(Kokkos::RangePolicy(0,n),*this); return n*10; @@ -486,7 +485,7 @@ int PairADPKokkos::pack_forward_comm_kokkos(int n, DAT::tdual_int_2d template KOKKOS_INLINE_FUNCTION void PairADPKokkos::operator()(TagPairADPPackForwardComm, const int &i) const { - int j = d_sendlist(iswap, i); + int j = d_sendlist(i); v_buf[10 * i] = d_fp(j); v_buf[10 * i + 1] = d_mu(j, 0); v_buf[10 * i + 2] = d_mu(j, 1); @@ -671,7 +670,7 @@ void PairADPKokkos::operator()(TagPairADPKernelA,decltype(dup_rho),decltype(ndup_rho)>::get(dup_rho,ndup_rho); auto a_rho = v_rho.template access>(); @@ -929,7 +928,7 @@ template KOKKOS_INLINE_FUNCTION void PairADPKokkos::operator()(TagPairADPKernelC, const int &ii, EV_FLOAT& ev) const { - // The f array is duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The f array is duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_f = ScatterViewHelper,decltype(dup_f),decltype(ndup_f)>::get(dup_f,ndup_f); auto a_f = v_f.template access>(); @@ -1087,7 +1086,7 @@ void PairADPKokkos::ev_tally_xyz(EV_FLOAT &ev, const int &i, const i const int EFLAG = eflag; const int VFLAG = vflag_either; - // The eatom and vatom arrays are duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The eatom and vatom arrays are duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_eatom = ScatterViewHelper,decltype(dup_eatom),decltype(ndup_eatom)>::get(dup_eatom,ndup_eatom); auto a_eatom = v_eatom.template access>(); diff --git a/src/KOKKOS/pair_adp_kokkos.h b/src/KOKKOS/pair_adp_kokkos.h index 5714bdb699..41328a567e 100644 --- a/src/KOKKOS/pair_adp_kokkos.h +++ b/src/KOKKOS/pair_adp_kokkos.h @@ -108,7 +108,7 @@ class PairADPKokkos : public PairADP, public KokkosBase const F_FLOAT &epair, const F_FLOAT &fx, const F_FLOAT &fy, const F_FLOAT &fz, const F_FLOAT &delx, const F_FLOAT &dely, const F_FLOAT &delz) const; - int pack_forward_comm_kokkos(int, DAT::tdual_int_2d, int, DAT::tdual_xfloat_1d&, + int pack_forward_comm_kokkos(int, DAT::tdual_int_1d, DAT::tdual_xfloat_1d&, int, int *) override; void unpack_forward_comm_kokkos(int, int, DAT::tdual_xfloat_1d&) override; int pack_forward_comm(int, int *, double *, int, int *) override; @@ -185,9 +185,8 @@ class PairADPKokkos : public PairADP, public KokkosBase typename AT::t_int_1d d_ilist; typename AT::t_int_1d d_numneigh; - int iswap; int first; - typename AT::t_int_2d d_sendlist; + typename AT::t_int_1d d_sendlist; typename AT::t_xfloat_1d_um v_buf; int neighflag,newton_pair; diff --git a/src/KOKKOS/pair_buck_coul_cut_kokkos.cpp b/src/KOKKOS/pair_buck_coul_cut_kokkos.cpp index a859b232be..ebe49b59a0 100644 --- a/src/KOKKOS/pair_buck_coul_cut_kokkos.cpp +++ b/src/KOKKOS/pair_buck_coul_cut_kokkos.cpp @@ -25,14 +25,12 @@ #include "kokkos.h" #include "math_const.h" #include "memory_kokkos.h" -#include "neigh_list.h" #include "neigh_request.h" #include "neighbor.h" #include "respa.h" #include "update.h" #include -#include using namespace LAMMPS_NS; using namespace MathConst; diff --git a/src/KOKKOS/pair_buck_coul_long_kokkos.cpp b/src/KOKKOS/pair_buck_coul_long_kokkos.cpp index 2f1d4a79b2..a13361d09f 100644 --- a/src/KOKKOS/pair_buck_coul_long_kokkos.cpp +++ b/src/KOKKOS/pair_buck_coul_long_kokkos.cpp @@ -21,6 +21,7 @@ #include "atom_kokkos.h" #include "atom_masks.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "kokkos.h" #include "memory_kokkos.h" @@ -34,15 +35,7 @@ #include using namespace LAMMPS_NS; - - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/pair_buck_kokkos.cpp b/src/KOKKOS/pair_buck_kokkos.cpp index b549fcd329..88b0445dc8 100644 --- a/src/KOKKOS/pair_buck_kokkos.cpp +++ b/src/KOKKOS/pair_buck_kokkos.cpp @@ -24,14 +24,12 @@ #include "force.h" #include "kokkos.h" #include "memory_kokkos.h" -#include "neigh_list.h" #include "neigh_request.h" #include "neighbor.h" #include "respa.h" #include "update.h" #include -#include using namespace LAMMPS_NS; diff --git a/src/KOKKOS/pair_coul_cut_kokkos.cpp b/src/KOKKOS/pair_coul_cut_kokkos.cpp index 283a4b2b69..1796bd93fd 100644 --- a/src/KOKKOS/pair_coul_cut_kokkos.cpp +++ b/src/KOKKOS/pair_coul_cut_kokkos.cpp @@ -20,7 +20,6 @@ #include "force.h" #include "kokkos.h" #include "memory_kokkos.h" -#include "neigh_list.h" #include "neigh_request.h" #include "neighbor.h" diff --git a/src/KOKKOS/pair_coul_debye_kokkos.cpp b/src/KOKKOS/pair_coul_debye_kokkos.cpp index 4c0e610e89..eb61716640 100644 --- a/src/KOKKOS/pair_coul_debye_kokkos.cpp +++ b/src/KOKKOS/pair_coul_debye_kokkos.cpp @@ -24,14 +24,10 @@ #include "force.h" #include "kokkos.h" #include "memory_kokkos.h" -#include "neigh_list.h" #include "neigh_request.h" #include "neighbor.h" -#include "respa.h" -#include "update.h" #include -#include using namespace LAMMPS_NS; diff --git a/src/KOKKOS/pair_coul_dsf_kokkos.cpp b/src/KOKKOS/pair_coul_dsf_kokkos.cpp index da4c7b1b4c..9e0db27f36 100644 --- a/src/KOKKOS/pair_coul_dsf_kokkos.cpp +++ b/src/KOKKOS/pair_coul_dsf_kokkos.cpp @@ -20,7 +20,7 @@ #include "atom_kokkos.h" #include "atom_masks.h" -#include "error.h" +#include "ewald_const.h" #include "force.h" #include "kokkos.h" #include "math_const.h" @@ -32,16 +32,9 @@ #include using namespace LAMMPS_NS; +using namespace EwaldConst; using namespace MathConst; -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 - /* ---------------------------------------------------------------------- */ template diff --git a/src/KOKKOS/pair_coul_long_kokkos.cpp b/src/KOKKOS/pair_coul_long_kokkos.cpp index ed9b4c31c1..0452a08b8f 100644 --- a/src/KOKKOS/pair_coul_long_kokkos.cpp +++ b/src/KOKKOS/pair_coul_long_kokkos.cpp @@ -21,6 +21,7 @@ #include "atom_kokkos.h" #include "atom_masks.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "kokkos.h" #include "memory_kokkos.h" @@ -34,15 +35,7 @@ #include using namespace LAMMPS_NS; - - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/pair_coul_wolf_kokkos.cpp b/src/KOKKOS/pair_coul_wolf_kokkos.cpp index 2ccf7a5a15..af5067db16 100644 --- a/src/KOKKOS/pair_coul_wolf_kokkos.cpp +++ b/src/KOKKOS/pair_coul_wolf_kokkos.cpp @@ -20,7 +20,6 @@ #include "atom_kokkos.h" #include "atom_masks.h" -#include "error.h" #include "force.h" #include "kokkos.h" #include "math_const.h" diff --git a/src/KOKKOS/pair_dpd_ext_kokkos.cpp b/src/KOKKOS/pair_dpd_ext_kokkos.cpp index 7264877d70..636235d1c8 100644 --- a/src/KOKKOS/pair_dpd_ext_kokkos.cpp +++ b/src/KOKKOS/pair_dpd_ext_kokkos.cpp @@ -37,7 +37,7 @@ using namespace LAMMPS_NS; -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; template @@ -228,7 +228,7 @@ template KOKKOS_INLINE_FUNCTION void PairDPDExtKokkos::operator() (TagDPDExtKokkos, const int &ii, EV_FLOAT &ev) const { - // The f array is duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The f array is duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_f = ScatterViewHelper,decltype(dup_f),decltype(ndup_f)>::get(dup_f,ndup_f); auto a_f = v_f.template access>(); @@ -354,7 +354,7 @@ void PairDPDExtKokkos::ev_tally_xyz(EV_FLOAT &ev, const int &i, cons const F_FLOAT &fx, const F_FLOAT &fy, const F_FLOAT &fz, const F_FLOAT &delx, const F_FLOAT &dely, const F_FLOAT &delz) const { - // The eatom and vatom arrays are duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The eatom and vatom arrays are duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_eatom = ScatterViewHelper,decltype(dup_eatom),decltype(ndup_eatom)>::get(dup_eatom,ndup_eatom); auto a_eatom = v_eatom.template access>(); diff --git a/src/KOKKOS/pair_dpd_ext_tstat_kokkos.cpp b/src/KOKKOS/pair_dpd_ext_tstat_kokkos.cpp index dcf88d1763..213b344fbb 100644 --- a/src/KOKKOS/pair_dpd_ext_tstat_kokkos.cpp +++ b/src/KOKKOS/pair_dpd_ext_tstat_kokkos.cpp @@ -37,7 +37,7 @@ using namespace LAMMPS_NS; -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; template @@ -232,7 +232,7 @@ template KOKKOS_INLINE_FUNCTION void PairDPDExtTstatKokkos::operator() (TagDPDExtTstatKokkos, const int &ii, EV_FLOAT &ev) const { - // The f array is duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The f array is duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_f = ScatterViewHelper,decltype(dup_f),decltype(ndup_f)>::get(dup_f,ndup_f); auto a_f = v_f.template access>(); @@ -346,7 +346,7 @@ void PairDPDExtTstatKokkos::v_tally_xyz(EV_FLOAT &ev, const int &i, const F_FLOAT &delx, const F_FLOAT &dely, const F_FLOAT &delz) const { - // The vatom array is duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The vatom array is duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_vatom = ScatterViewHelper,decltype(dup_vatom),decltype(ndup_vatom)>::get(dup_vatom,ndup_vatom); auto a_vatom = v_vatom.template access>(); diff --git a/src/KOKKOS/pair_dpd_fdt_energy_kokkos.cpp b/src/KOKKOS/pair_dpd_fdt_energy_kokkos.cpp index a0ee204aeb..dd1591bf4b 100644 --- a/src/KOKKOS/pair_dpd_fdt_energy_kokkos.cpp +++ b/src/KOKKOS/pair_dpd_fdt_energy_kokkos.cpp @@ -34,7 +34,7 @@ using namespace LAMMPS_NS; -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/pair_dpd_kokkos.cpp b/src/KOKKOS/pair_dpd_kokkos.cpp index 3db8a06f6d..f888b5f6ce 100644 --- a/src/KOKKOS/pair_dpd_kokkos.cpp +++ b/src/KOKKOS/pair_dpd_kokkos.cpp @@ -37,7 +37,7 @@ using namespace LAMMPS_NS; -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; template @@ -228,7 +228,7 @@ template KOKKOS_INLINE_FUNCTION void PairDPDKokkos::operator() (TagDPDKokkos, const int &ii, EV_FLOAT &ev) const { - // The f array is duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The f array is duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_f = ScatterViewHelper,decltype(dup_f),decltype(ndup_f)>::get(dup_f,ndup_f); auto a_f = v_f.template access>(); @@ -319,7 +319,7 @@ void PairDPDKokkos::ev_tally(EV_FLOAT &ev, const int &i, const int & const F_FLOAT &epair, const F_FLOAT &fpair, const F_FLOAT &delx, const F_FLOAT &dely, const F_FLOAT &delz) const { - // The eatom and vatom arrays are duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The eatom and vatom arrays are duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_eatom = ScatterViewHelper,decltype(dup_eatom),decltype(ndup_eatom)>::get(dup_eatom,ndup_eatom); auto a_eatom = v_eatom.template access>(); diff --git a/src/KOKKOS/pair_dpd_tstat_kokkos.cpp b/src/KOKKOS/pair_dpd_tstat_kokkos.cpp index 9058c23628..63dbda3b59 100644 --- a/src/KOKKOS/pair_dpd_tstat_kokkos.cpp +++ b/src/KOKKOS/pair_dpd_tstat_kokkos.cpp @@ -37,7 +37,7 @@ using namespace LAMMPS_NS; -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; template @@ -231,7 +231,7 @@ template KOKKOS_INLINE_FUNCTION void PairDPDTstatKokkos::operator() (TagDPDTstatKokkos, const int &ii, EV_FLOAT &ev) const { - // The f array is duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The f array is duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_f = ScatterViewHelper,decltype(dup_f),decltype(ndup_f)>::get(dup_f,ndup_f); auto a_f = v_f.template access>(); @@ -312,7 +312,7 @@ void PairDPDTstatKokkos::v_tally(EV_FLOAT &ev, const int &i, const i const F_FLOAT &dely, const F_FLOAT &delz) const { - // The vatom array is duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The vatom array is duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_vatom = ScatterViewHelper,decltype(dup_vatom),decltype(ndup_vatom)>::get(dup_vatom,ndup_vatom); auto a_vatom = v_vatom.template access>(); diff --git a/src/KOKKOS/pair_eam_alloy_kokkos.cpp b/src/KOKKOS/pair_eam_alloy_kokkos.cpp index 0dfe56c365..b02faced1e 100644 --- a/src/KOKKOS/pair_eam_alloy_kokkos.cpp +++ b/src/KOKKOS/pair_eam_alloy_kokkos.cpp @@ -449,12 +449,11 @@ void PairEAMAlloyKokkos::interpolate(int n, double delta, double *f, /* ---------------------------------------------------------------------- */ template -int PairEAMAlloyKokkos::pack_forward_comm_kokkos(int n, DAT::tdual_int_2d k_sendlist, - int iswap_in, DAT::tdual_xfloat_1d &buf, +int PairEAMAlloyKokkos::pack_forward_comm_kokkos(int n, DAT::tdual_int_1d k_sendlist, + DAT::tdual_xfloat_1d &buf, int /*pbc_flag*/, int * /*pbc*/) { d_sendlist = k_sendlist.view(); - iswap = iswap_in; v_buf = buf.view(); Kokkos::parallel_for(Kokkos::RangePolicy(0,n),*this); return n; @@ -463,7 +462,7 @@ int PairEAMAlloyKokkos::pack_forward_comm_kokkos(int n, DAT::tdual_i template KOKKOS_INLINE_FUNCTION void PairEAMAlloyKokkos::operator()(TagPairEAMAlloyPackForwardComm, const int &i) const { - int j = d_sendlist(iswap, i); + int j = d_sendlist(i); v_buf[i] = d_fp[j]; } @@ -566,7 +565,7 @@ void PairEAMAlloyKokkos::operator()(TagPairEAMAlloyKernelA,decltype(dup_rho),decltype(ndup_rho)>::get(dup_rho,ndup_rho); auto a_rho = v_rho.template access>(); @@ -733,7 +732,7 @@ template KOKKOS_INLINE_FUNCTION void PairEAMAlloyKokkos::operator()(TagPairEAMAlloyKernelC, const int &ii, EV_FLOAT& ev) const { - // The f array is duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The f array is duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_f = ScatterViewHelper,decltype(dup_f),decltype(ndup_f)>::get(dup_f,ndup_f); auto a_f = v_f.template access>(); @@ -943,7 +942,7 @@ void PairEAMAlloyKokkos::operator()(TagPairEAMAlloyKernelC,decltype(dup_f),decltype(ndup_f)>::get(dup_f,ndup_f); auto a_f = v_f.template access>(); @@ -1076,7 +1075,7 @@ void PairEAMAlloyKokkos::ev_tally(EV_FLOAT &ev, const int &i, const const int EFLAG = eflag; const int VFLAG = vflag_either; - // The eatom and vatom arrays are duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The eatom and vatom arrays are duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_eatom = ScatterViewHelper,decltype(dup_eatom),decltype(ndup_eatom)>::get(dup_eatom,ndup_eatom); auto a_eatom = v_eatom.template access>(); diff --git a/src/KOKKOS/pair_eam_alloy_kokkos.h b/src/KOKKOS/pair_eam_alloy_kokkos.h index 2eb40189ac..572dc1aca8 100644 --- a/src/KOKKOS/pair_eam_alloy_kokkos.h +++ b/src/KOKKOS/pair_eam_alloy_kokkos.h @@ -122,7 +122,7 @@ class PairEAMAlloyKokkos : public PairEAM, public KokkosBase { const F_FLOAT &epair, const F_FLOAT &fpair, const F_FLOAT &delx, const F_FLOAT &dely, const F_FLOAT &delz) const; - int pack_forward_comm_kokkos(int, DAT::tdual_int_2d, int, DAT::tdual_xfloat_1d&, + int pack_forward_comm_kokkos(int, DAT::tdual_int_1d, DAT::tdual_xfloat_1d&, int, int *) override; void unpack_forward_comm_kokkos(int, int, DAT::tdual_xfloat_1d&) override; int pack_forward_comm(int, int *, double *, int, int *) override; @@ -190,9 +190,8 @@ class PairEAMAlloyKokkos : public PairEAM, public KokkosBase { typename AT::t_int_1d d_ilist; typename AT::t_int_1d d_numneigh; - int iswap; int first; - typename AT::t_int_2d d_sendlist; + typename AT::t_int_1d d_sendlist; typename AT::t_xfloat_1d_um v_buf; int neighflag,newton_pair; diff --git a/src/KOKKOS/pair_eam_fs_kokkos.cpp b/src/KOKKOS/pair_eam_fs_kokkos.cpp index 58ff615c04..4da146e68e 100644 --- a/src/KOKKOS/pair_eam_fs_kokkos.cpp +++ b/src/KOKKOS/pair_eam_fs_kokkos.cpp @@ -449,12 +449,11 @@ void PairEAMFSKokkos::interpolate(int n, double delta, double *f, t_ /* ---------------------------------------------------------------------- */ template -int PairEAMFSKokkos::pack_forward_comm_kokkos(int n, DAT::tdual_int_2d k_sendlist, - int iswap_in, DAT::tdual_xfloat_1d &buf, +int PairEAMFSKokkos::pack_forward_comm_kokkos(int n, DAT::tdual_int_1d k_sendlist, + DAT::tdual_xfloat_1d &buf, int /*pbc_flag*/, int * /*pbc*/) { d_sendlist = k_sendlist.view(); - iswap = iswap_in; v_buf = buf.view(); Kokkos::parallel_for(Kokkos::RangePolicy(0,n),*this); return n; @@ -463,7 +462,7 @@ int PairEAMFSKokkos::pack_forward_comm_kokkos(int n, DAT::tdual_int_ template KOKKOS_INLINE_FUNCTION void PairEAMFSKokkos::operator()(TagPairEAMFSPackForwardComm, const int &i) const { - int j = d_sendlist(iswap, i); + int j = d_sendlist(i); v_buf[i] = d_fp[j]; } @@ -566,7 +565,7 @@ void PairEAMFSKokkos::operator()(TagPairEAMFSKernelA,decltype(dup_rho),decltype(ndup_rho)>::get(dup_rho,ndup_rho); auto a_rho = v_rho.template access>(); @@ -733,7 +732,7 @@ template KOKKOS_INLINE_FUNCTION void PairEAMFSKokkos::operator()(TagPairEAMFSKernelC, const int &ii, EV_FLOAT& ev) const { - // The f array is duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The f array is duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_f = ScatterViewHelper,decltype(dup_f),decltype(ndup_f)>::get(dup_f,ndup_f); auto a_f = v_f.template access>(); @@ -943,7 +942,7 @@ void PairEAMFSKokkos::operator()(TagPairEAMFSKernelC,decltype(dup_f),decltype(ndup_f)>::get(dup_f,ndup_f); auto a_f = v_f.template access>(); @@ -1076,7 +1075,7 @@ void PairEAMFSKokkos::ev_tally(EV_FLOAT &ev, const int &i, const int const int EFLAG = eflag; const int VFLAG = vflag_either; - // The eatom and vatom arrays are duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The eatom and vatom arrays are duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_eatom = ScatterViewHelper,decltype(dup_eatom),decltype(ndup_eatom)>::get(dup_eatom,ndup_eatom); auto a_eatom = v_eatom.template access>(); diff --git a/src/KOKKOS/pair_eam_fs_kokkos.h b/src/KOKKOS/pair_eam_fs_kokkos.h index bd03ab0015..8e4ee7851e 100644 --- a/src/KOKKOS/pair_eam_fs_kokkos.h +++ b/src/KOKKOS/pair_eam_fs_kokkos.h @@ -122,7 +122,7 @@ class PairEAMFSKokkos : public PairEAM, public KokkosBase { const F_FLOAT &epair, const F_FLOAT &fpair, const F_FLOAT &delx, const F_FLOAT &dely, const F_FLOAT &delz) const; - int pack_forward_comm_kokkos(int, DAT::tdual_int_2d, int, DAT::tdual_xfloat_1d&, + int pack_forward_comm_kokkos(int, DAT::tdual_int_1d, DAT::tdual_xfloat_1d&, int, int *) override; void unpack_forward_comm_kokkos(int, int, DAT::tdual_xfloat_1d&) override; int pack_forward_comm(int, int *, double *, int, int *) override; @@ -190,9 +190,8 @@ class PairEAMFSKokkos : public PairEAM, public KokkosBase { typename AT::t_int_1d d_ilist; typename AT::t_int_1d d_numneigh; - int iswap; int first; - typename AT::t_int_2d d_sendlist; + typename AT::t_int_1d d_sendlist; typename AT::t_xfloat_1d_um v_buf; int neighflag,newton_pair; diff --git a/src/KOKKOS/pair_eam_kokkos.cpp b/src/KOKKOS/pair_eam_kokkos.cpp index 864f736066..54ffa84f2d 100644 --- a/src/KOKKOS/pair_eam_kokkos.cpp +++ b/src/KOKKOS/pair_eam_kokkos.cpp @@ -444,12 +444,11 @@ void PairEAMKokkos::interpolate(int n, double delta, double *f, t_ho /* ---------------------------------------------------------------------- */ template -int PairEAMKokkos::pack_forward_comm_kokkos(int n, DAT::tdual_int_2d k_sendlist, - int iswap_in, DAT::tdual_xfloat_1d &buf, +int PairEAMKokkos::pack_forward_comm_kokkos(int n, DAT::tdual_int_1d k_sendlist, + DAT::tdual_xfloat_1d &buf, int /*pbc_flag*/, int * /*pbc*/) { d_sendlist = k_sendlist.view(); - iswap = iswap_in; v_buf = buf.view(); Kokkos::parallel_for(Kokkos::RangePolicy(0,n),*this); return n; @@ -458,7 +457,7 @@ int PairEAMKokkos::pack_forward_comm_kokkos(int n, DAT::tdual_int_2d template KOKKOS_INLINE_FUNCTION void PairEAMKokkos::operator()(TagPairEAMPackForwardComm, const int &i) const { - int j = d_sendlist(iswap, i); + int j = d_sendlist(i); v_buf[i] = d_fp[j]; } @@ -561,7 +560,7 @@ void PairEAMKokkos::operator()(TagPairEAMKernelA,decltype(dup_rho),decltype(ndup_rho)>::get(dup_rho,ndup_rho); auto a_rho = v_rho.template access>(); @@ -728,7 +727,7 @@ template KOKKOS_INLINE_FUNCTION void PairEAMKokkos::operator()(TagPairEAMKernelC, const int &ii, EV_FLOAT& ev) const { - // The f array is duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The f array is duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_f = ScatterViewHelper,decltype(dup_f),decltype(ndup_f)>::get(dup_f,ndup_f); auto a_f = v_f.template access>(); @@ -938,7 +937,7 @@ void PairEAMKokkos::operator()(TagPairEAMKernelC,decltype(dup_f),decltype(ndup_f)>::get(dup_f,ndup_f); auto a_f = v_f.template access>(); @@ -1071,7 +1070,7 @@ void PairEAMKokkos::ev_tally(EV_FLOAT &ev, const int &i, const int & const int EFLAG = eflag; const int VFLAG = vflag_either; - // The eatom and vatom arrays are duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The eatom and vatom arrays are duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_eatom = ScatterViewHelper,decltype(dup_eatom),decltype(ndup_eatom)>::get(dup_eatom,ndup_eatom); auto a_eatom = v_eatom.template access>(); diff --git a/src/KOKKOS/pair_eam_kokkos.h b/src/KOKKOS/pair_eam_kokkos.h index 9d066d40a0..950db43fb2 100644 --- a/src/KOKKOS/pair_eam_kokkos.h +++ b/src/KOKKOS/pair_eam_kokkos.h @@ -120,7 +120,7 @@ class PairEAMKokkos : public PairEAM, public KokkosBase { const F_FLOAT &epair, const F_FLOAT &fpair, const F_FLOAT &delx, const F_FLOAT &dely, const F_FLOAT &delz) const; - int pack_forward_comm_kokkos(int, DAT::tdual_int_2d, int, DAT::tdual_xfloat_1d&, + int pack_forward_comm_kokkos(int, DAT::tdual_int_1d, DAT::tdual_xfloat_1d&, int, int *) override; void unpack_forward_comm_kokkos(int, int, DAT::tdual_xfloat_1d&) override; int pack_forward_comm(int, int *, double *, int, int *) override; @@ -186,9 +186,8 @@ class PairEAMKokkos : public PairEAM, public KokkosBase { typename AT::t_int_1d d_ilist; typename AT::t_int_1d d_numneigh; - int iswap; int first; - typename AT::t_int_2d d_sendlist; + typename AT::t_int_1d d_sendlist; typename AT::t_xfloat_1d_um v_buf; int neighflag,newton_pair; diff --git a/src/KOKKOS/pair_exp6_rx_kokkos.cpp b/src/KOKKOS/pair_exp6_rx_kokkos.cpp index b4576db89a..dad7413669 100644 --- a/src/KOKKOS/pair_exp6_rx_kokkos.cpp +++ b/src/KOKKOS/pair_exp6_rx_kokkos.cpp @@ -42,8 +42,8 @@ using namespace LAMMPS_NS; using namespace MathSpecialKokkos; -#define MAXLINE 1024 -#define DELTA 4 +static constexpr int MAXLINE = 1024; +static constexpr int DELTA = 4; #ifdef DBL_EPSILON #define MY_EPSILON (10.0*DBL_EPSILON) @@ -1702,7 +1702,8 @@ void PairExp6rxKokkos::read_file(char *file) // one set of params can span multiple lines int n,nwords,ispecies; - char line[MAXLINE],*ptr; + char line[MAXLINE] = {'\0'}; + char *ptr; int eof = 0; while (true) { diff --git a/src/KOKKOS/pair_hybrid_kokkos.cpp b/src/KOKKOS/pair_hybrid_kokkos.cpp index eabce17a1c..84d43bcec8 100644 --- a/src/KOKKOS/pair_hybrid_kokkos.cpp +++ b/src/KOKKOS/pair_hybrid_kokkos.cpp @@ -14,14 +14,10 @@ ------------------------------------------------------------------------- */ #include "pair_hybrid_kokkos.h" -#include + #include "atom_kokkos.h" #include "force.h" -#include "pair.h" -#include "neighbor.h" -#include "neigh_request.h" #include "update.h" -#include "memory_kokkos.h" #include "respa.h" #include "atom_masks.h" #include "kokkos.h" diff --git a/src/KOKKOS/pair_kokkos.h b/src/KOKKOS/pair_kokkos.h index 398266cb61..87324b49b9 100644 --- a/src/KOKKOS/pair_kokkos.h +++ b/src/KOKKOS/pair_kokkos.h @@ -627,7 +627,7 @@ struct PairComputeFunctor { const int itype = c.type(i); const F_FLOAT qtmp = c.q(i); - if (ZEROFLAG) { + if (NEIGHFLAG == FULL && ZEROFLAG) { Kokkos::single(Kokkos::PerThread(team), [&] (){ f(i,0) = 0.0; f(i,1) = 0.0; @@ -674,7 +674,7 @@ struct PairComputeFunctor { const int J_CONTRIB = ((NEIGHFLAG == HALF || NEIGHFLAG == HALFTHREAD) && j < c.nlocal); const E_FLOAT factor = J_CONTRIB?1.0:0.5; - if ((NEIGHFLAG == HALF || NEIGHFLAG == HALFTHREAD) && j < c.nlocal) { + if (J_CONTRIB) { a_f(j,0) -= fx; a_f(j,1) -= fy; a_f(j,2) -= fz; @@ -746,8 +746,10 @@ struct PairComputeFunctor { a_f(i,1) += fev.f[1]; a_f(i,2) += fev.f[2]; - if (c.eflag_global) + if (c.eflag_global) { ev.evdwl += fev.evdwl; + ev.ecoul += fev.ecoul; + } if (c.vflag_global) { ev.v[0] += fev.v[0]; @@ -761,7 +763,7 @@ struct PairComputeFunctor { if (NEIGHFLAG == FULL) { if (c.eflag_atom) - a_eatom(i) += fev.evdwl; + a_eatom(i) += fev.evdwl + fev.ecoul; if (c.vflag_atom) { a_vatom(i,0) += fev.v[0]; diff --git a/src/KOKKOS/pair_lj_charmm_coul_charmm_implicit_kokkos.cpp b/src/KOKKOS/pair_lj_charmm_coul_charmm_implicit_kokkos.cpp index f8fb7cdda4..a2c8943340 100644 --- a/src/KOKKOS/pair_lj_charmm_coul_charmm_implicit_kokkos.cpp +++ b/src/KOKKOS/pair_lj_charmm_coul_charmm_implicit_kokkos.cpp @@ -21,6 +21,7 @@ #include "atom_kokkos.h" #include "atom_masks.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "kokkos.h" #include "memory_kokkos.h" @@ -33,15 +34,7 @@ #include using namespace LAMMPS_NS; - - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/pair_lj_charmm_coul_charmm_kokkos.cpp b/src/KOKKOS/pair_lj_charmm_coul_charmm_kokkos.cpp index 526e15c222..24551e27ce 100644 --- a/src/KOKKOS/pair_lj_charmm_coul_charmm_kokkos.cpp +++ b/src/KOKKOS/pair_lj_charmm_coul_charmm_kokkos.cpp @@ -21,6 +21,7 @@ #include "atom_kokkos.h" #include "atom_masks.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "kokkos.h" #include "memory_kokkos.h" @@ -34,15 +35,7 @@ #include using namespace LAMMPS_NS; - - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/pair_lj_charmm_coul_long_kokkos.cpp b/src/KOKKOS/pair_lj_charmm_coul_long_kokkos.cpp index 4caab0ef55..90ab8adf26 100644 --- a/src/KOKKOS/pair_lj_charmm_coul_long_kokkos.cpp +++ b/src/KOKKOS/pair_lj_charmm_coul_long_kokkos.cpp @@ -21,6 +21,7 @@ #include "atom_kokkos.h" #include "atom_masks.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "kokkos.h" #include "memory_kokkos.h" @@ -34,15 +35,7 @@ #include using namespace LAMMPS_NS; - - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ @@ -214,9 +207,7 @@ compute_evdwl(const F_FLOAT& rsq, const int& /*i*/, const int& /*j*/, (cut_ljsq + 2.0*rsq - 3.0*cut_lj_innersq) / denom_lj; englj *= switch1; } - return englj; - } /* ---------------------------------------------------------------------- @@ -488,4 +479,3 @@ template class PairLJCharmmCoulLongKokkos; template class PairLJCharmmCoulLongKokkos; #endif } - diff --git a/src/KOKKOS/pair_lj_charmmfsw_coul_long_kokkos.cpp b/src/KOKKOS/pair_lj_charmmfsw_coul_long_kokkos.cpp new file mode 100644 index 0000000000..c07a089a35 --- /dev/null +++ b/src/KOKKOS/pair_lj_charmmfsw_coul_long_kokkos.cpp @@ -0,0 +1,490 @@ +// clang-format off +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + LAMMPS development team: developers@lammps.org + + Copyright (2003) Sandia Corporation. Under the terms of Contract + DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains + certain rights in this software. This software is distributed under + the GNU General Public License. + + See the README file in the top-level LAMMPS directory. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing author: Mitch Murphy (alphataubio) + + Based on serial kspace lj-fsw sections (force-switched) provided by + Robert Meissner and Lucio Colombi Ciacchi of Bremen University, Germany, + with additional assistance from Robert A. Latour, Clemson University + + ------------------------------------------------------------------------- */ + +#include "pair_lj_charmmfsw_coul_long_kokkos.h" + +#include "atom_kokkos.h" +#include "atom_masks.h" +#include "error.h" +#include "ewald_const.h" +#include "force.h" +#include "kokkos.h" +#include "memory_kokkos.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "neighbor.h" +#include "respa.h" +#include "update.h" + +#include +#include + +using namespace LAMMPS_NS; +using namespace EwaldConst; + +/* ---------------------------------------------------------------------- */ + +template +PairLJCharmmfswCoulLongKokkos::PairLJCharmmfswCoulLongKokkos(LAMMPS *lmp):PairLJCharmmfswCoulLong(lmp) +{ + respa_enable = 0; + + kokkosable = 1; + atomKK = (AtomKokkos *) atom; + execution_space = ExecutionSpaceFromDevice::space; + datamask_read = X_MASK | F_MASK | TYPE_MASK | Q_MASK | ENERGY_MASK | VIRIAL_MASK; + datamask_modify = F_MASK | ENERGY_MASK | VIRIAL_MASK; +} + +/* ---------------------------------------------------------------------- */ + +template +PairLJCharmmfswCoulLongKokkos::~PairLJCharmmfswCoulLongKokkos() +{ + if (copymode) return; + + if (allocated) { + memoryKK->destroy_kokkos(k_eatom,eatom); + memoryKK->destroy_kokkos(k_vatom,vatom); + memoryKK->destroy_kokkos(k_cutsq,cutsq); + } +} + +/* ---------------------------------------------------------------------- */ + +template +void PairLJCharmmfswCoulLongKokkos::compute(int eflag_in, int vflag_in) +{ + eflag = eflag_in; + vflag = vflag_in; + + if (neighflag == FULL) no_virial_fdotr_compute = 1; + + ev_init(eflag,vflag,0); + + // reallocate per-atom arrays if necessary + + if (eflag_atom) { + memoryKK->destroy_kokkos(k_eatom,eatom); + memoryKK->create_kokkos(k_eatom,eatom,maxeatom,"pair:eatom"); + d_eatom = k_eatom.view(); + } + if (vflag_atom) { + memoryKK->destroy_kokkos(k_vatom,vatom); + memoryKK->create_kokkos(k_vatom,vatom,maxvatom,"pair:vatom"); + d_vatom = k_vatom.view(); + } + + atomKK->sync(execution_space,datamask_read); + k_cutsq.template sync(); + k_params.template sync(); + if (eflag || vflag) atomKK->modified(execution_space,datamask_modify); + else atomKK->modified(execution_space,F_MASK); + + x = atomKK->k_x.view(); + c_x = atomKK->k_x.view(); + f = atomKK->k_f.view(); + q = atomKK->k_q.view(); + type = atomKK->k_type.view(); + nlocal = atom->nlocal; + nall = atom->nlocal + atom->nghost; + special_lj[0] = force->special_lj[0]; + special_lj[1] = force->special_lj[1]; + special_lj[2] = force->special_lj[2]; + special_lj[3] = force->special_lj[3]; + special_coul[0] = force->special_coul[0]; + special_coul[1] = force->special_coul[1]; + special_coul[2] = force->special_coul[2]; + special_coul[3] = force->special_coul[3]; + qqrd2e = force->qqrd2e; + newton_pair = force->newton_pair; + + // loop over neighbors of my atoms + + copymode = 1; + + EV_FLOAT ev; + if (ncoultablebits) + ev = pair_compute,CoulLongTable<1> > + (this,(NeighListKokkos*)list); + else + ev = pair_compute,CoulLongTable<0> > + (this,(NeighListKokkos*)list); + + + if (eflag) { + eng_vdwl += ev.evdwl; + eng_coul += ev.ecoul; + } + if (vflag_global) { + virial[0] += ev.v[0]; + virial[1] += ev.v[1]; + virial[2] += ev.v[2]; + virial[3] += ev.v[3]; + virial[4] += ev.v[4]; + virial[5] += ev.v[5]; + } + + if (eflag_atom) { + k_eatom.template modify(); + k_eatom.template sync(); + } + + if (vflag_atom) { + k_vatom.template modify(); + k_vatom.template sync(); + } + + if (vflag_fdotr) pair_virial_fdotr_compute(this); + + copymode = 0; +} + +/* ---------------------------------------------------------------------- + compute LJ CHARMM pair force between atoms i and j + ---------------------------------------------------------------------- */ +template +template +KOKKOS_INLINE_FUNCTION +F_FLOAT PairLJCharmmfswCoulLongKokkos:: +compute_fpair(const F_FLOAT& rsq, const int& /*i*/, const int& /*j*/, + const int& itype, const int& jtype) const { + const F_FLOAT r2inv = 1.0/rsq; + const F_FLOAT r6inv = r2inv*r2inv*r2inv; + F_FLOAT forcelj, switch1; + + forcelj = r6inv * + ((STACKPARAMS?m_params[itype][jtype].lj1:params(itype,jtype).lj1)*r6inv - + (STACKPARAMS?m_params[itype][jtype].lj2:params(itype,jtype).lj2)); + + if (rsq > cut_lj_innersq) { + switch1 = (cut_ljsq-rsq) * (cut_ljsq-rsq) * + (cut_ljsq + 2.0*rsq - 3.0*cut_lj_innersq) / denom_lj; + forcelj = forcelj*switch1; + } + + return forcelj*r2inv; +} + +/* ---------------------------------------------------------------------- + compute LJ CHARMM pair potential energy between atoms i and j + ---------------------------------------------------------------------- */ +template +template +KOKKOS_INLINE_FUNCTION +F_FLOAT PairLJCharmmfswCoulLongKokkos:: +compute_evdwl(const F_FLOAT& rsq, const int& /*i*/, const int& /*j*/, + const int& itype, const int& jtype) const { + const F_FLOAT r2inv = 1.0/rsq; + const F_FLOAT r6inv = r2inv*r2inv*r2inv; + const F_FLOAT r = sqrt(rsq); + const F_FLOAT rinv = 1.0/r; + const F_FLOAT r3inv = rinv*rinv*rinv; + F_FLOAT englj, englj12, englj6; + + if (rsq > cut_lj_innersq) { + englj12 = (STACKPARAMS?m_params[itype][jtype].lj3:params(itype,jtype).lj3)*cut_lj6* + denom_lj12 * (r6inv - cut_lj6inv)*(r6inv - cut_lj6inv); + englj6 = -(STACKPARAMS?m_params[itype][jtype].lj4:params(itype,jtype).lj4)* + cut_lj3*denom_lj6 * (r3inv - cut_lj3inv)*(r3inv - cut_lj3inv); + englj = englj12 + englj6; + } else { + englj12 = r6inv*(STACKPARAMS?m_params[itype][jtype].lj3:params(itype,jtype).lj3)*r6inv - + (STACKPARAMS?m_params[itype][jtype].lj3:params(itype,jtype).lj3)*cut_lj_inner6inv*cut_lj6inv; + englj6 = -(STACKPARAMS?m_params[itype][jtype].lj4:params(itype,jtype).lj4)*r6inv + + (STACKPARAMS?m_params[itype][jtype].lj4:params(itype,jtype).lj4)* + cut_lj_inner3inv*cut_lj3inv; + englj = englj12 + englj6; + } + return englj; +} + +/* ---------------------------------------------------------------------- + compute coulomb pair force between atoms i and j + ---------------------------------------------------------------------- */ +template +template +KOKKOS_INLINE_FUNCTION +F_FLOAT PairLJCharmmfswCoulLongKokkos:: +compute_fcoul(const F_FLOAT& rsq, const int& /*i*/, const int&j, + const int& /*itype*/, const int& /*jtype*/, + const F_FLOAT& factor_coul, const F_FLOAT& qtmp) const { + if (Specialisation::DoTable && rsq > tabinnersq) { + union_int_float_t rsq_lookup; + rsq_lookup.f = rsq; + const int itable = (rsq_lookup.i & ncoulmask) >> ncoulshiftbits; + const F_FLOAT fraction = (rsq_lookup.f - d_rtable[itable]) * d_drtable[itable]; + const F_FLOAT table = d_ftable[itable] + fraction*d_dftable[itable]; + F_FLOAT forcecoul = qtmp*q[j] * table; + if (factor_coul < 1.0) { + const F_FLOAT table = d_ctable[itable] + fraction*d_dctable[itable]; + const F_FLOAT prefactor = qtmp*q[j] * table; + forcecoul -= (1.0-factor_coul)*prefactor; + } + return forcecoul/rsq; + } else { + const F_FLOAT r = sqrt(rsq); + const F_FLOAT grij = g_ewald * r; + const F_FLOAT expm2 = exp(-grij*grij); + const F_FLOAT t = 1.0 / (1.0 + EWALD_P*grij); + const F_FLOAT rinv = 1.0/r; + const F_FLOAT erfc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * expm2; + const F_FLOAT prefactor = qqrd2e * qtmp*q[j]*rinv; + F_FLOAT forcecoul = prefactor * (erfc + EWALD_F*grij*expm2); + if (factor_coul < 1.0) forcecoul -= (1.0-factor_coul)*prefactor; + + return forcecoul*rinv*rinv; + } +} + +/* ---------------------------------------------------------------------- + compute coulomb pair potential energy between atoms i and j + ---------------------------------------------------------------------- */ +template +template +KOKKOS_INLINE_FUNCTION +F_FLOAT PairLJCharmmfswCoulLongKokkos:: +compute_ecoul(const F_FLOAT& rsq, const int& /*i*/, const int&j, + const int& /*itype*/, const int& /*jtype*/, const F_FLOAT& factor_coul, const F_FLOAT& qtmp) const { + if (Specialisation::DoTable && rsq > tabinnersq) { + union_int_float_t rsq_lookup; + rsq_lookup.f = rsq; + const int itable = (rsq_lookup.i & ncoulmask) >> ncoulshiftbits; + const F_FLOAT fraction = (rsq_lookup.f - d_rtable[itable]) * d_drtable[itable]; + const F_FLOAT table = d_etable[itable] + fraction*d_detable[itable]; + F_FLOAT ecoul = qtmp*q[j] * table; + if (factor_coul < 1.0) { + const F_FLOAT table = d_ctable[itable] + fraction*d_dctable[itable]; + const F_FLOAT prefactor = qtmp*q[j] * table; + ecoul -= (1.0-factor_coul)*prefactor; + } + return ecoul; + } else { + const F_FLOAT r = sqrt(rsq); + const F_FLOAT grij = g_ewald * r; + const F_FLOAT expm2 = exp(-grij*grij); + const F_FLOAT t = 1.0 / (1.0 + EWALD_P*grij); + const F_FLOAT erfc = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * expm2; + const F_FLOAT prefactor = qqrd2e * qtmp*q[j]/r; + F_FLOAT ecoul = prefactor * erfc; + if (factor_coul < 1.0) ecoul -= (1.0-factor_coul)*prefactor; + return ecoul; + } +} + +/* ---------------------------------------------------------------------- + allocate all arrays +------------------------------------------------------------------------- */ + +template +void PairLJCharmmfswCoulLongKokkos::allocate() +{ + PairLJCharmmfswCoulLong::allocate(); + + int n = atom->ntypes; + + memory->destroy(cutsq); + memoryKK->create_kokkos(k_cutsq,cutsq,n+1,n+1,"pair:cutsq"); + d_cutsq = k_cutsq.template view(); + + d_cut_ljsq = typename AT::t_ffloat_2d("pair:cut_ljsq",n+1,n+1); + + d_cut_coulsq = typename AT::t_ffloat_2d("pair:cut_coulsq",n+1,n+1); + + k_params = Kokkos::DualView("PairLJCharmmfswCoulLong::params",n+1,n+1); + params = k_params.template view(); +} + +template +void PairLJCharmmfswCoulLongKokkos::init_tables(double cut_coul, double *cut_respa) +{ + Pair::init_tables(cut_coul,cut_respa); + + typedef typename ArrayTypes::t_ffloat_1d table_type; + typedef typename ArrayTypes::t_ffloat_1d host_table_type; + + int ntable = 1; + for (int i = 0; i < ncoultablebits; i++) ntable *= 2; + + + // Copy rtable and drtable + { + host_table_type h_table("HostTable",ntable); + table_type d_table("DeviceTable",ntable); + for (int i = 0; i < ntable; i++) { + h_table(i) = rtable[i]; + } + Kokkos::deep_copy(d_table,h_table); + d_rtable = d_table; + } + + { + host_table_type h_table("HostTable",ntable); + table_type d_table("DeviceTable",ntable); + for (int i = 0; i < ntable; i++) { + h_table(i) = drtable[i]; + } + Kokkos::deep_copy(d_table,h_table); + d_drtable = d_table; + } + + { + host_table_type h_table("HostTable",ntable); + table_type d_table("DeviceTable",ntable); + + // Copy ftable and dftable + for (int i = 0; i < ntable; i++) { + h_table(i) = ftable[i]; + } + Kokkos::deep_copy(d_table,h_table); + d_ftable = d_table; + } + + { + host_table_type h_table("HostTable",ntable); + table_type d_table("DeviceTable",ntable); + + for (int i = 0; i < ntable; i++) { + h_table(i) = dftable[i]; + } + Kokkos::deep_copy(d_table,h_table); + d_dftable = d_table; + } + + { + host_table_type h_table("HostTable",ntable); + table_type d_table("DeviceTable",ntable); + + // Copy ctable and dctable + for (int i = 0; i < ntable; i++) { + h_table(i) = ctable[i]; + } + Kokkos::deep_copy(d_table,h_table); + d_ctable = d_table; + } + + { + host_table_type h_table("HostTable",ntable); + table_type d_table("DeviceTable",ntable); + + for (int i = 0; i < ntable; i++) { + h_table(i) = dctable[i]; + } + Kokkos::deep_copy(d_table,h_table); + d_dctable = d_table; + } + + { + host_table_type h_table("HostTable",ntable); + table_type d_table("DeviceTable",ntable); + + // Copy etable and detable + for (int i = 0; i < ntable; i++) { + h_table(i) = etable[i]; + } + Kokkos::deep_copy(d_table,h_table); + d_etable = d_table; + } + + { + host_table_type h_table("HostTable",ntable); + table_type d_table("DeviceTable",ntable); + + for (int i = 0; i < ntable; i++) { + h_table(i) = detable[i]; + } + Kokkos::deep_copy(d_table,h_table); + d_detable = d_table; + } +} + +/* ---------------------------------------------------------------------- + init specific to this pair style +------------------------------------------------------------------------- */ + +template +void PairLJCharmmfswCoulLongKokkos::init_style() +{ + PairLJCharmmfswCoulLong::init_style(); + + Kokkos::deep_copy(d_cut_ljsq,cut_ljsq); + Kokkos::deep_copy(d_cut_coulsq,cut_coulsq); + + // error if rRESPA with inner levels + + if (update->whichflag == 1 && utils::strmatch(update->integrate_style,"^respa")) { + int respa = 0; + if (((Respa *) update->integrate)->level_inner >= 0) respa = 1; + if (((Respa *) update->integrate)->level_middle >= 0) respa = 2; + if (respa) + error->all(FLERR,"Cannot use Kokkos pair style with rRESPA inner/middle"); + } + + // adjust neighbor list request for KOKKOS + + neighflag = lmp->kokkos->neighflag; + auto request = neighbor->find_request(this); + request->set_kokkos_host(std::is_same_v && + !std::is_same_v); + request->set_kokkos_device(std::is_same_v); + if (neighflag == FULL) request->enable_full(); +} + +/* ---------------------------------------------------------------------- + init for one type pair i,j and corresponding j,i +------------------------------------------------------------------------- */ + +template +double PairLJCharmmfswCoulLongKokkos::init_one(int i, int j) +{ + double cutone = PairLJCharmmfswCoulLong::init_one(i,j); + + k_params.h_view(i,j).lj1 = lj1[i][j]; + k_params.h_view(i,j).lj2 = lj2[i][j]; + k_params.h_view(i,j).lj3 = lj3[i][j]; + k_params.h_view(i,j).lj4 = lj4[i][j]; + //k_params.h_view(i,j).offset = offset[i][j]; + k_params.h_view(i,j).cut_ljsq = cut_ljsq; + k_params.h_view(i,j).cut_coulsq = cut_coulsq; + + k_params.h_view(j,i) = k_params.h_view(i,j); + if (i(); + k_params.template modify(); + + return cutone; +} + +namespace LAMMPS_NS { +template class PairLJCharmmfswCoulLongKokkos; +#ifdef LMP_KOKKOS_GPU +template class PairLJCharmmfswCoulLongKokkos; +#endif +} diff --git a/src/KOKKOS/pair_lj_charmmfsw_coul_long_kokkos.h b/src/KOKKOS/pair_lj_charmmfsw_coul_long_kokkos.h new file mode 100644 index 0000000000..7533f40dbc --- /dev/null +++ b/src/KOKKOS/pair_lj_charmmfsw_coul_long_kokkos.h @@ -0,0 +1,145 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + LAMMPS development team: developers@lammps.org + + 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. +------------------------------------------------------------------------- */ + +#ifdef PAIR_CLASS +// clang-format off +PairStyle(lj/charmmfsw/coul/long/kk,PairLJCharmmfswCoulLongKokkos); +PairStyle(lj/charmmfsw/coul/long/kk/device,PairLJCharmmfswCoulLongKokkos); +PairStyle(lj/charmmfsw/coul/long/kk/host,PairLJCharmmfswCoulLongKokkos); +// clang-format on +#else + +// clang-format off +#ifndef LMP_PAIR_LJ_CHARMMFSW_COUL_LONG_KOKKOS_H +#define LMP_PAIR_LJ_CHARMMFSW_COUL_LONG_KOKKOS_H + +#include "pair_kokkos.h" +#include "pair_lj_charmmfsw_coul_long.h" +#include "neigh_list_kokkos.h" + +namespace LAMMPS_NS { + +template +class PairLJCharmmfswCoulLongKokkos : public PairLJCharmmfswCoulLong { + public: + enum {EnabledNeighFlags=FULL|HALFTHREAD|HALF}; + enum {COUL_FLAG=1}; + typedef DeviceType device_type; + typedef ArrayTypes AT; + PairLJCharmmfswCoulLongKokkos(class LAMMPS *); + ~PairLJCharmmfswCoulLongKokkos() override; + + void compute(int, int) override; + + void init_tables(double cut_coul, double *cut_respa) override; + void init_style() override; + double init_one(int, int) override; + + protected: + template + KOKKOS_INLINE_FUNCTION + F_FLOAT compute_fpair(const F_FLOAT& rsq, const int& i, const int&j, + const int& itype, const int& jtype) const; + + template + KOKKOS_INLINE_FUNCTION + F_FLOAT compute_fcoul(const F_FLOAT& rsq, const int& i, const int&j, const int& itype, + const int& jtype, const F_FLOAT& factor_coul, const F_FLOAT& qtmp) const; + + template + KOKKOS_INLINE_FUNCTION + F_FLOAT compute_evdwl(const F_FLOAT& rsq, const int& i, const int&j, + const int& itype, const int& jtype) const; + + template + KOKKOS_INLINE_FUNCTION + F_FLOAT compute_ecoul(const F_FLOAT& rsq, const int& i, const int&j, + const int& itype, const int& jtype, const F_FLOAT& factor_coul, const F_FLOAT& qtmp) const; + + Kokkos::DualView k_params; + typename Kokkos::DualView::t_dev_const_um params; + // hardwired to space for 12 atom types + params_lj_coul m_params[MAX_TYPES_STACKPARAMS+1][MAX_TYPES_STACKPARAMS+1]; + + F_FLOAT m_cutsq[MAX_TYPES_STACKPARAMS+1][MAX_TYPES_STACKPARAMS+1]; + F_FLOAT m_cut_ljsq[MAX_TYPES_STACKPARAMS+1][MAX_TYPES_STACKPARAMS+1]; + F_FLOAT m_cut_coulsq[MAX_TYPES_STACKPARAMS+1][MAX_TYPES_STACKPARAMS+1]; + typename AT::t_x_array_randomread x; + typename AT::t_x_array c_x; + typename AT::t_f_array f; + typename AT::t_int_1d_randomread type; + typename AT::t_float_1d_randomread q; + + DAT::tdual_efloat_1d k_eatom; + DAT::tdual_virial_array k_vatom; + typename AT::t_efloat_1d d_eatom; + typename AT::t_virial_array d_vatom; + + int newton_pair; + + typename AT::tdual_ffloat_2d k_cutsq; + typename AT::t_ffloat_2d d_cutsq; + typename AT::t_ffloat_2d d_cut_ljsq; + typename AT::t_ffloat_2d d_cut_coulsq; + + typename AT::t_ffloat_1d_randomread + d_rtable, d_drtable, d_ftable, d_dftable, + d_ctable, d_dctable, d_etable, d_detable; + + int neighflag; + int nlocal,nall,eflag,vflag; + + double special_coul[4]; + double special_lj[4]; + double qqrd2e; + + void allocate() override; + + friend struct PairComputeFunctor>; + friend struct PairComputeFunctor>; + friend struct PairComputeFunctor>; + friend struct PairComputeFunctor>; + friend struct PairComputeFunctor>; + friend struct PairComputeFunctor>; + friend struct PairComputeFunctor>; + friend struct PairComputeFunctor>; + friend EV_FLOAT pair_compute_neighlist>(PairLJCharmmfswCoulLongKokkos*,NeighListKokkos*); + friend EV_FLOAT pair_compute_neighlist>(PairLJCharmmfswCoulLongKokkos*,NeighListKokkos*); + friend EV_FLOAT pair_compute_neighlist>(PairLJCharmmfswCoulLongKokkos*,NeighListKokkos*); + friend EV_FLOAT pair_compute_neighlist>(PairLJCharmmfswCoulLongKokkos*,NeighListKokkos*); + friend EV_FLOAT pair_compute>(PairLJCharmmfswCoulLongKokkos*, + NeighListKokkos*); + friend struct PairComputeFunctor>; + friend struct PairComputeFunctor>; + friend struct PairComputeFunctor>; + friend struct PairComputeFunctor>; + friend struct PairComputeFunctor>; + friend struct PairComputeFunctor>; + friend struct PairComputeFunctor>; + friend struct PairComputeFunctor>; + friend EV_FLOAT pair_compute_neighlist>(PairLJCharmmfswCoulLongKokkos*,NeighListKokkos*); + friend EV_FLOAT pair_compute_neighlist>(PairLJCharmmfswCoulLongKokkos*,NeighListKokkos*); + friend EV_FLOAT pair_compute_neighlist>(PairLJCharmmfswCoulLongKokkos*,NeighListKokkos*); + friend EV_FLOAT pair_compute_neighlist>(PairLJCharmmfswCoulLongKokkos*,NeighListKokkos*); + friend EV_FLOAT pair_compute>(PairLJCharmmfswCoulLongKokkos*, + NeighListKokkos*); + friend void pair_virial_fdotr_compute(PairLJCharmmfswCoulLongKokkos*); + +}; + +} + +#endif +#endif + diff --git a/src/KOKKOS/pair_lj_class2_coul_long_kokkos.cpp b/src/KOKKOS/pair_lj_class2_coul_long_kokkos.cpp index e861d1cec2..b5d55a023a 100644 --- a/src/KOKKOS/pair_lj_class2_coul_long_kokkos.cpp +++ b/src/KOKKOS/pair_lj_class2_coul_long_kokkos.cpp @@ -17,6 +17,7 @@ #include "atom_kokkos.h" #include "atom_masks.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "kokkos.h" #include "memory_kokkos.h" @@ -30,15 +31,7 @@ #include using namespace LAMMPS_NS; - - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/pair_lj_cut_coul_cut_kokkos.cpp b/src/KOKKOS/pair_lj_cut_coul_cut_kokkos.cpp index 7c61c684e4..626f05106c 100644 --- a/src/KOKKOS/pair_lj_cut_coul_cut_kokkos.cpp +++ b/src/KOKKOS/pair_lj_cut_coul_cut_kokkos.cpp @@ -20,14 +20,12 @@ #include "force.h" #include "kokkos.h" #include "memory_kokkos.h" -#include "neigh_list.h" #include "neigh_request.h" #include "neighbor.h" #include "respa.h" #include "update.h" #include -#include using namespace LAMMPS_NS; diff --git a/src/KOKKOS/pair_lj_cut_coul_dsf_kokkos.cpp b/src/KOKKOS/pair_lj_cut_coul_dsf_kokkos.cpp index bd430db764..0e415819c6 100644 --- a/src/KOKKOS/pair_lj_cut_coul_dsf_kokkos.cpp +++ b/src/KOKKOS/pair_lj_cut_coul_dsf_kokkos.cpp @@ -21,6 +21,7 @@ #include "atom_kokkos.h" #include "atom_masks.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "kokkos.h" #include "math_const.h" @@ -35,15 +36,8 @@ #include using namespace LAMMPS_NS; -using namespace MathConst; - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; +using MathConst::MY_PIS; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/pair_lj_cut_coul_long_kokkos.cpp b/src/KOKKOS/pair_lj_cut_coul_long_kokkos.cpp index ce2bf480d8..5124d40505 100644 --- a/src/KOKKOS/pair_lj_cut_coul_long_kokkos.cpp +++ b/src/KOKKOS/pair_lj_cut_coul_long_kokkos.cpp @@ -17,6 +17,7 @@ #include "atom_kokkos.h" #include "atom_masks.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "kokkos.h" #include "math_const.h" @@ -32,15 +33,7 @@ using namespace LAMMPS_NS; using namespace MathConst; - - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/pair_lj_cut_kokkos.cpp b/src/KOKKOS/pair_lj_cut_kokkos.cpp index 9a1ced9da3..566d74088c 100644 --- a/src/KOKKOS/pair_lj_cut_kokkos.cpp +++ b/src/KOKKOS/pair_lj_cut_kokkos.cpp @@ -20,14 +20,11 @@ #include "force.h" #include "kokkos.h" #include "memory_kokkos.h" -#include "neigh_list.h" #include "neigh_request.h" #include "neighbor.h" #include "respa.h" #include "update.h" -#include - using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/pair_lj_expand_coul_long_kokkos.cpp b/src/KOKKOS/pair_lj_expand_coul_long_kokkos.cpp index acb1cf253e..a5c6fcc552 100644 --- a/src/KOKKOS/pair_lj_expand_coul_long_kokkos.cpp +++ b/src/KOKKOS/pair_lj_expand_coul_long_kokkos.cpp @@ -21,6 +21,7 @@ #include "atom_kokkos.h" #include "atom_masks.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "kokkos.h" #include "math_const.h" @@ -36,15 +37,7 @@ using namespace LAMMPS_NS; using namespace MathConst; - - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/pair_meam_kokkos.cpp b/src/KOKKOS/pair_meam_kokkos.cpp index 4361a387ba..9082c410e0 100644 --- a/src/KOKKOS/pair_meam_kokkos.cpp +++ b/src/KOKKOS/pair_meam_kokkos.cpp @@ -338,11 +338,10 @@ void PairMEAMKokkos::init_style() /* ---------------------------------------------------------------------- */ template -int PairMEAMKokkos::pack_forward_comm_kokkos(int n, DAT::tdual_int_2d k_sendlist, int iswap_in, DAT::tdual_xfloat_1d &buf, +int PairMEAMKokkos::pack_forward_comm_kokkos(int n, DAT::tdual_int_1d k_sendlist, DAT::tdual_xfloat_1d &buf, int /*pbc_flag*/, int * /*pbc*/) { d_sendlist = k_sendlist.view(); - iswap = iswap_in; v_buf = buf.view(); Kokkos::parallel_for(Kokkos::RangePolicy(0,n),*this); return n*comm_forward; @@ -353,7 +352,7 @@ int PairMEAMKokkos::pack_forward_comm_kokkos(int n, DAT::tdual_int_2 template KOKKOS_INLINE_FUNCTION void PairMEAMKokkos::operator()(TagPairMEAMPackForwardComm, const int &i) const { - int j = d_sendlist(iswap, i); + int j = d_sendlist(i); int m = i*comm_forward; v_buf[m++] = d_rho0[j]; v_buf[m++] = d_rho1[j]; @@ -782,10 +781,9 @@ int PairMEAMKokkos::pack_reverse_comm(int n, int first, double *buf) /* ---------------------------------------------------------------------- */ template -void PairMEAMKokkos::unpack_reverse_comm_kokkos(int n, DAT::tdual_int_2d k_sendlist, int iswap_in, DAT::tdual_xfloat_1d &buf) +void PairMEAMKokkos::unpack_reverse_comm_kokkos(int n, DAT::tdual_int_1d k_sendlist, DAT::tdual_xfloat_1d &buf) { d_sendlist = k_sendlist.view(); - iswap = iswap_in; v_buf = buf.view(); Kokkos::parallel_for(Kokkos::RangePolicy(0,n),*this); } @@ -795,7 +793,7 @@ void PairMEAMKokkos::unpack_reverse_comm_kokkos(int n, DAT::tdual_in template KOKKOS_INLINE_FUNCTION void PairMEAMKokkos::operator()(TagPairMEAMUnpackReverseComm, const int &i) const { - int j = d_sendlist(iswap, i); + int j = d_sendlist(i); //int m = i*30; int m = i*comm_reverse; diff --git a/src/KOKKOS/pair_meam_kokkos.h b/src/KOKKOS/pair_meam_kokkos.h index 0d0d7667f3..66b5700a72 100644 --- a/src/KOKKOS/pair_meam_kokkos.h +++ b/src/KOKKOS/pair_meam_kokkos.h @@ -76,15 +76,15 @@ class PairMEAMKokkos : public PairMEAM, public KokkosBase { KOKKOS_INLINE_FUNCTION void operator()(TagPairMEAMOffsets, const int, int&) const; - int pack_forward_comm_kokkos(int, DAT::tdual_int_2d, int, DAT::tdual_xfloat_1d&, + int pack_forward_comm_kokkos(int, DAT::tdual_int_1d, DAT::tdual_xfloat_1d&, int, int *) override; int pack_forward_comm(int, int *, double *, int, int *) override; void unpack_forward_comm_kokkos(int, int, DAT::tdual_xfloat_1d&) override; void unpack_forward_comm(int, int, double *) override; int pack_reverse_comm_kokkos(int, int, DAT::tdual_xfloat_1d&) override; int pack_reverse_comm(int, int, double *) override; - void unpack_reverse_comm_kokkos(int, DAT::tdual_int_2d, - int, DAT::tdual_xfloat_1d&) override; + void unpack_reverse_comm_kokkos(int, DAT::tdual_int_1d, + DAT::tdual_xfloat_1d&) override; void unpack_reverse_comm(int, int *, double *) override; protected: @@ -108,10 +108,10 @@ class PairMEAMKokkos : public PairMEAM, public KokkosBase { typename AT::t_neighbors_2d d_neighbors_half; typename AT::t_int_1d d_numneigh_full; typename AT::t_neighbors_2d d_neighbors_full; - typename AT::t_int_2d d_sendlist; + typename AT::t_int_1d d_sendlist; typename AT::t_xfloat_1d_um v_buf; - int iswap,first; + int first; int neighflag,nlocal,nall,eflag,vflag; typename ArrayTypes::t_ffloat_1d d_rho, d_rho0, d_rho1, d_rho2, d_rho3, d_frhop; diff --git a/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp b/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp index f487b0c84e..2a20c9e013 100644 --- a/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp +++ b/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp @@ -43,8 +43,6 @@ using MathConst::MY_PI; enum{NONE,RLINEAR,RSQ}; -#define MAXLINE 1024 - #ifdef DBL_EPSILON #define MY_EPSILON (10.0*DBL_EPSILON) #else @@ -648,12 +646,11 @@ void PairMultiLucyRXKokkos::getMixingWeights(int id, double &mixWtSi /* ---------------------------------------------------------------------- */ template -int PairMultiLucyRXKokkos::pack_forward_comm_kokkos(int n, DAT::tdual_int_2d k_sendlist, int iswap_in, DAT::tdual_xfloat_1d &buf, int /*pbc_flag*/, int * /*pbc*/) +int PairMultiLucyRXKokkos::pack_forward_comm_kokkos(int n, DAT::tdual_int_1d k_sendlist, DAT::tdual_xfloat_1d &buf, int /*pbc_flag*/, int * /*pbc*/) { atomKK->sync(execution_space,DPDRHO_MASK); d_sendlist = k_sendlist.view(); - iswap = iswap_in; v_buf = buf.view(); Kokkos::parallel_for(Kokkos::RangePolicy(0,n),*this); return n; @@ -662,7 +659,7 @@ int PairMultiLucyRXKokkos::pack_forward_comm_kokkos(int n, DAT::tdua template KOKKOS_INLINE_FUNCTION void PairMultiLucyRXKokkos::operator()(TagPairMultiLucyRXPackForwardComm, const int &i) const { - int j = d_sendlist(iswap, i); + int j = d_sendlist(i); v_buf[i] = rho[j]; } diff --git a/src/KOKKOS/pair_multi_lucy_rx_kokkos.h b/src/KOKKOS/pair_multi_lucy_rx_kokkos.h index c335ed526f..753012e0c7 100644 --- a/src/KOKKOS/pair_multi_lucy_rx_kokkos.h +++ b/src/KOKKOS/pair_multi_lucy_rx_kokkos.h @@ -61,7 +61,7 @@ class PairMultiLucyRXKokkos : public PairMultiLucyRX, public KokkosBase { void compute_style(int, int); void init_style() override; - int pack_forward_comm_kokkos(int, DAT::tdual_int_2d, int, DAT::tdual_xfloat_1d&, + int pack_forward_comm_kokkos(int, DAT::tdual_int_1d, DAT::tdual_xfloat_1d&, int, int *) override; void unpack_forward_comm_kokkos(int, int, DAT::tdual_xfloat_1d&) override; int pack_forward_comm(int, int *, double *, int, int *) override; @@ -181,9 +181,8 @@ class PairMultiLucyRXKokkos : public PairMultiLucyRX, public KokkosBase { typename AT::tdual_ffloat_2d k_cutsq; typename AT::t_ffloat_2d d_cutsq; - int iswap; int first; - typename AT::t_int_2d d_sendlist; + typename AT::t_int_1d d_sendlist; typename AT::t_xfloat_1d_um v_buf; friend void pair_virial_fdotr_compute(PairMultiLucyRXKokkos*); diff --git a/src/KOKKOS/pair_pace_extrapolation_kokkos.cpp b/src/KOKKOS/pair_pace_extrapolation_kokkos.cpp index ef747ef95c..e7d376c870 100644 --- a/src/KOKKOS/pair_pace_extrapolation_kokkos.cpp +++ b/src/KOKKOS/pair_pace_extrapolation_kokkos.cpp @@ -1652,7 +1652,7 @@ template KOKKOS_INLINE_FUNCTION void PairPACEExtrapolationKokkos::operator() (TagPairPACEComputeForce, const int& ii, EV_FLOAT& ev) const { - // The f array is duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The f array is duplicated for OpenMP, atomic for GPU, and neither for Serial const auto v_f = ScatterViewHelper,decltype(dup_f),decltype(ndup_f)>::get(dup_f,ndup_f); const auto a_f = v_f.template access>(); @@ -1721,7 +1721,7 @@ void PairPACEExtrapolationKokkos::v_tally_xyz(EV_FLOAT &ev, const in const F_FLOAT &fx, const F_FLOAT &fy, const F_FLOAT &fz, const F_FLOAT &delx, const F_FLOAT &dely, const F_FLOAT &delz) const { - // The vatom array is duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The vatom array is duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_vatom = ScatterViewHelper,decltype(dup_vatom),decltype(ndup_vatom)>::get(dup_vatom,ndup_vatom); auto a_vatom = v_vatom.template access>(); diff --git a/src/KOKKOS/pair_pace_kokkos.cpp b/src/KOKKOS/pair_pace_kokkos.cpp index 4046649375..4407d1231e 100644 --- a/src/KOKKOS/pair_pace_kokkos.cpp +++ b/src/KOKKOS/pair_pace_kokkos.cpp @@ -1561,7 +1561,7 @@ template KOKKOS_INLINE_FUNCTION void PairPACEKokkos::operator() (TagPairPACEComputeForce, const int& ii, EV_FLOAT& ev) const { - // The f array is duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The f array is duplicated for OpenMP, atomic for GPU, and neither for Serial const auto v_f = ScatterViewHelper,decltype(dup_f),decltype(ndup_f)>::get(dup_f,ndup_f); const auto a_f = v_f.template access>(); @@ -1630,7 +1630,7 @@ void PairPACEKokkos::v_tally_xyz(EV_FLOAT &ev, const int &i, const i const F_FLOAT &fx, const F_FLOAT &fy, const F_FLOAT &fz, const F_FLOAT &delx, const F_FLOAT &dely, const F_FLOAT &delz) const { - // The vatom array is duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The vatom array is duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_vatom = ScatterViewHelper,decltype(dup_vatom),decltype(ndup_vatom)>::get(dup_vatom,ndup_vatom); auto a_vatom = v_vatom.template access>(); diff --git a/src/KOKKOS/pair_reaxff_kokkos.cpp b/src/KOKKOS/pair_reaxff_kokkos.cpp index 505681acb3..7dd86e07a9 100644 --- a/src/KOKKOS/pair_reaxff_kokkos.cpp +++ b/src/KOKKOS/pair_reaxff_kokkos.cpp @@ -1149,7 +1149,7 @@ template KOKKOS_INLINE_FUNCTION void PairReaxFFKokkos::operator()(TagPairReaxComputeLJCoulomb, const int &ii, EV_FLOAT_REAX& ev) const { - // The f array is duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The f array is duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_f = ScatterViewHelper,decltype(dup_f),decltype(ndup_f)>::get(dup_f,ndup_f); auto a_f = v_f.template access>(); @@ -1345,7 +1345,7 @@ template KOKKOS_INLINE_FUNCTION void PairReaxFFKokkos::operator()(TagPairReaxComputeTabulatedLJCoulomb, const int &ii, EV_FLOAT_REAX& ev) const { - // The f array is duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The f array is duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_f = ScatterViewHelper,decltype(dup_f),decltype(ndup_f)>::get(dup_f,ndup_f); auto a_f = v_f.template access>(); @@ -3834,7 +3834,7 @@ void PairReaxFFKokkos::ev_tally(EV_FLOAT_REAX &ev, const int &i, con const F_FLOAT &epair, const F_FLOAT &fpair, const F_FLOAT &delx, const F_FLOAT &dely, const F_FLOAT &delz) const { - // The eatom and vatom arrays are duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The eatom and vatom arrays are duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_eatom = ScatterViewHelper,decltype(dup_eatom),decltype(ndup_eatom)>::get(dup_eatom,ndup_eatom); auto a_eatom = v_eatom.template access>(); @@ -3890,7 +3890,7 @@ KOKKOS_INLINE_FUNCTION void PairReaxFFKokkos::e_tally(EV_FLOAT_REAX & /*ev*/, const int &i, const int &j, const F_FLOAT &epair) const { - // The eatom array is duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The eatom array is duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_eatom = ScatterViewHelper,decltype(dup_eatom),decltype(ndup_eatom)>::get(dup_eatom,ndup_eatom); auto a_eatom = v_eatom.template access>(); @@ -3908,7 +3908,7 @@ KOKKOS_INLINE_FUNCTION void PairReaxFFKokkos::e_tally_single(EV_FLOAT_REAX & /*ev*/, const int &i, const F_FLOAT &epair) const { - // The eatom array is duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The eatom array is duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_eatom = ScatterViewHelper,decltype(dup_eatom),decltype(ndup_eatom)>::get(dup_eatom,ndup_eatom); auto a_eatom = v_eatom.template access>(); @@ -3959,7 +3959,7 @@ KOKKOS_INLINE_FUNCTION void PairReaxFFKokkos::v_tally3(EV_FLOAT_REAX &ev, const int &i, const int &j, const int &k, F_FLOAT *fj, F_FLOAT *fk, F_FLOAT *drij, F_FLOAT *drik) const { - // The eatom and vatom arrays are duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The eatom and vatom arrays are duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_vatom = ScatterViewHelper,decltype(dup_vatom),decltype(ndup_vatom)>::get(dup_vatom,ndup_vatom); auto a_vatom = v_vatom.template access>(); @@ -3999,7 +3999,7 @@ KOKKOS_INLINE_FUNCTION void PairReaxFFKokkos::v_tally4(EV_FLOAT_REAX &ev, const int &i, const int &j, const int &k, const int &l, F_FLOAT *fi, F_FLOAT *fj, F_FLOAT *fk, F_FLOAT *dril, F_FLOAT *drjl, F_FLOAT *drkl) const { - // The vatom array is duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The vatom array is duplicated for OpenMP, atomic for GPU, and neither for Serial F_FLOAT v[6]; diff --git a/src/KOKKOS/pair_snap_kokkos_impl.h b/src/KOKKOS/pair_snap_kokkos_impl.h index 7b9fda60db..839240c62f 100644 --- a/src/KOKKOS/pair_snap_kokkos_impl.h +++ b/src/KOKKOS/pair_snap_kokkos_impl.h @@ -1265,7 +1265,7 @@ template KOKKOS_INLINE_FUNCTION void PairSNAPKokkos::operator() (TagPairSNAPComputeForce, const int& ii, EV_FLOAT& ev) const { - // The f array is duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The f array is duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_f = ScatterViewHelper,decltype(dup_f),decltype(ndup_f)>::get(dup_f,ndup_f); auto a_f = v_f.template access>(); @@ -1365,7 +1365,7 @@ void PairSNAPKokkos::v_tally_xyz(EV_FLOAT const F_FLOAT &fx, const F_FLOAT &fy, const F_FLOAT &fz, const F_FLOAT &delx, const F_FLOAT &dely, const F_FLOAT &delz) const { - // The vatom array is duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The vatom array is duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_vatom = ScatterViewHelper,decltype(dup_vatom),decltype(ndup_vatom)>::get(dup_vatom,ndup_vatom); auto a_vatom = v_vatom.template access>(); diff --git a/src/KOKKOS/pair_sw_kokkos.cpp b/src/KOKKOS/pair_sw_kokkos.cpp index 93b3919795..01b856a7b5 100644 --- a/src/KOKKOS/pair_sw_kokkos.cpp +++ b/src/KOKKOS/pair_sw_kokkos.cpp @@ -37,9 +37,6 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define MAXLINE 1024 -#define DELTA 4 - /* ---------------------------------------------------------------------- */ template @@ -235,7 +232,7 @@ template KOKKOS_INLINE_FUNCTION void PairSWKokkos::operator()(TagPairSWCompute, const int &ii, EV_FLOAT& ev) const { - // The f array is duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The f array is duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_f = ScatterViewHelper,decltype(dup_f),decltype(ndup_f)>::get(dup_f,ndup_f); auto a_f = v_f.template access>(); @@ -532,7 +529,7 @@ void PairSWKokkos::ev_tally(EV_FLOAT &ev, const int &i, const int &j const F_FLOAT &dely, const F_FLOAT &delz) const { - // The eatom and vatom arrays are duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The eatom and vatom arrays are duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_eatom = ScatterViewHelper,decltype(dup_eatom),decltype(ndup_eatom)>::get(dup_eatom,ndup_eatom); auto a_eatom = v_eatom.template access>(); @@ -596,7 +593,7 @@ void PairSWKokkos::ev_tally3(EV_FLOAT &ev, const int &i, const int & { F_FLOAT epairthird,v[6]; - // The eatom and vatom arrays are duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The eatom and vatom arrays are duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_eatom = ScatterViewHelper,decltype(dup_eatom),decltype(ndup_eatom)>::get(dup_eatom,ndup_eatom); auto a_eatom = v_eatom.template access>(); diff --git a/src/KOKKOS/pair_tersoff_kokkos.cpp b/src/KOKKOS/pair_tersoff_kokkos.cpp index e860b0232d..1a0d45e435 100644 --- a/src/KOKKOS/pair_tersoff_kokkos.cpp +++ b/src/KOKKOS/pair_tersoff_kokkos.cpp @@ -336,7 +336,7 @@ template KOKKOS_INLINE_FUNCTION void PairTersoffKokkos::tersoff_compute(const int &ii, EV_FLOAT& ev) const { - // The f array is duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The f array is duplicated for OpenMP, atomic for GPU, and neither for Serial const auto v_f = ScatterViewHelper,decltype(dup_f),decltype(ndup_f)>::get(dup_f,ndup_f); const auto a_f = v_f.template access>(); @@ -1003,7 +1003,7 @@ void PairTersoffKokkos::ev_tally(EV_FLOAT &ev, const int &i, const i const F_FLOAT &epair, const F_FLOAT &fpair, const F_FLOAT &delx, const F_FLOAT &dely, const F_FLOAT &delz) const { - // The eatom and vatom arrays are duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The eatom and vatom arrays are duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_eatom = ScatterViewHelper,decltype(dup_eatom),decltype(ndup_eatom)>::get(dup_eatom,ndup_eatom); auto a_eatom = v_eatom.template access>(); @@ -1061,7 +1061,7 @@ void PairTersoffKokkos::v_tally3(EV_FLOAT &ev, const int &i, const int &j, const int &k, F_FLOAT *fj, F_FLOAT *fk, F_FLOAT *drij, F_FLOAT *drik) const { - // The vatom array is duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The vatom array is duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_vatom = ScatterViewHelper,decltype(dup_vatom),decltype(ndup_vatom)>::get(dup_vatom,ndup_vatom); auto a_vatom = v_vatom.template access>(); diff --git a/src/KOKKOS/pair_tersoff_mod_kokkos.cpp b/src/KOKKOS/pair_tersoff_mod_kokkos.cpp index 02a51af3d7..b941755d4b 100644 --- a/src/KOKKOS/pair_tersoff_mod_kokkos.cpp +++ b/src/KOKKOS/pair_tersoff_mod_kokkos.cpp @@ -326,7 +326,7 @@ template KOKKOS_INLINE_FUNCTION void PairTersoffMODKokkos::tersoff_mod_compute(const int &ii, EV_FLOAT& ev) const { - // The f array is duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The f array is duplicated for OpenMP, atomic for GPU, and neither for Serial const auto v_f = ScatterViewHelper,decltype(dup_f),decltype(ndup_f)>::get(dup_f,ndup_f); const auto a_f = v_f.template access>(); @@ -899,7 +899,7 @@ void PairTersoffMODKokkos::ev_tally(EV_FLOAT &ev, const int &i, cons const F_FLOAT &epair, const F_FLOAT &fpair, const F_FLOAT &delx, const F_FLOAT &dely, const F_FLOAT &delz) const { - // The eatom and vatom arrays are duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The eatom and vatom arrays are duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_eatom = ScatterViewHelper,decltype(dup_eatom),decltype(ndup_eatom)>::get(dup_eatom,ndup_eatom); auto a_eatom = v_eatom.template access>(); @@ -956,7 +956,7 @@ KOKKOS_INLINE_FUNCTION void PairTersoffMODKokkos::v_tally3(EV_FLOAT &ev, const int &i, const int &j, const int &k, F_FLOAT *fj, F_FLOAT *fk, F_FLOAT *drij, F_FLOAT *drik) const { - // The vatom array is duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The vatom array is duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_vatom = ScatterViewHelper,decltype(dup_vatom),decltype(ndup_vatom)>::get(dup_vatom,ndup_vatom); auto a_vatom = v_vatom.template access>(); diff --git a/src/KOKKOS/pair_tersoff_zbl_kokkos.cpp b/src/KOKKOS/pair_tersoff_zbl_kokkos.cpp index 8bad880a4f..08d6cb17d7 100644 --- a/src/KOKKOS/pair_tersoff_zbl_kokkos.cpp +++ b/src/KOKKOS/pair_tersoff_zbl_kokkos.cpp @@ -339,7 +339,7 @@ template KOKKOS_INLINE_FUNCTION void PairTersoffZBLKokkos::tersoff_zbl_compute(const int &ii, EV_FLOAT& ev) const { - // The f array is duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The f array is duplicated for OpenMP, atomic for GPU, and neither for Serial const auto v_f = ScatterViewHelper,decltype(dup_f),decltype(ndup_f)>::get(dup_f,ndup_f); const auto a_f = v_f.template access>(); @@ -963,7 +963,7 @@ void PairTersoffZBLKokkos::ev_tally(EV_FLOAT &ev, const int &i, cons const F_FLOAT &epair, const F_FLOAT &fpair, const F_FLOAT &delx, const F_FLOAT &dely, const F_FLOAT &delz) const { - // The eatom and vatom arrays are duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The eatom and vatom arrays are duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_eatom = ScatterViewHelper,decltype(dup_eatom),decltype(ndup_eatom)>::get(dup_eatom,ndup_eatom); auto a_eatom = v_eatom.template access>(); @@ -1021,7 +1021,7 @@ void PairTersoffZBLKokkos::v_tally3(EV_FLOAT &ev, const int &i, const int &j, const int &k, F_FLOAT *fj, F_FLOAT *fk, F_FLOAT *drij, F_FLOAT *drik) const { - // The vatom array is duplicated for OpenMP, atomic for CUDA, and neither for Serial + // The vatom array is duplicated for OpenMP, atomic for GPU, and neither for Serial auto v_vatom = ScatterViewHelper,decltype(dup_vatom),decltype(ndup_vatom)>::get(dup_vatom,ndup_vatom); auto a_vatom = v_vatom.template access>(); diff --git a/src/KOKKOS/pair_vashishta_kokkos.cpp b/src/KOKKOS/pair_vashishta_kokkos.cpp index 8400807ec6..0beb7902eb 100644 --- a/src/KOKKOS/pair_vashishta_kokkos.cpp +++ b/src/KOKKOS/pair_vashishta_kokkos.cpp @@ -36,9 +36,6 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define MAXLINE 1024 -#define DELTA 4 - /* ---------------------------------------------------------------------- */ template diff --git a/src/KOKKOS/pppm_kokkos.cpp b/src/KOKKOS/pppm_kokkos.cpp index baa85dc585..73e2c1f06f 100644 --- a/src/KOKKOS/pppm_kokkos.cpp +++ b/src/KOKKOS/pppm_kokkos.cpp @@ -20,6 +20,7 @@ #include "atom_kokkos.h" #include "atom_masks.h" +#include "comm.h" #include "domain.h" #include "error.h" #include "fft3d_kokkos.h" @@ -39,22 +40,14 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecialKokkos; -#define MAXORDER 7 -#define OFFSET 16384 -#define LARGE 10000.0 -#define SMALL 0.00001 -#define EPS_HOC 1.0e-7 +static constexpr int MAXORDER = 7; +static constexpr int OFFSET = 16384; +static constexpr double SMALL = 0.00001; +static constexpr double EPS_HOC = 1.0e-7; +static constexpr FFT_SCALAR ZEROF = 0.0; -enum{REVERSE_RHO}; -enum{FORWARD_IK,FORWARD_IK_PERATOM}; - -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#define ONEF 1.0f -#else -#define ZEROF 0.0 -#define ONEF 1.0 -#endif +enum { REVERSE_RHO }; +enum { FORWARD_IK, FORWARD_IK_PERATOM }; /* ---------------------------------------------------------------------- */ @@ -113,6 +106,13 @@ PPPMKokkos::PPPMKokkos(LAMMPS *lmp) : PPPM(lmp) fft1 = nullptr; fft2 = nullptr; remap = nullptr; + +#if defined (LMP_KOKKOS_GPU) + #if defined(FFT_KOKKOS_KISS) + if (comm->me == 0) + error->warning(FLERR,"Using default KISS FFT with Kokkos GPU backends may give suboptimal performance"); + #endif +#endif } /* ---------------------------------------------------------------------- @@ -285,7 +285,7 @@ void PPPMKokkos::init() estimated_accuracy); mesg += fmt::format(" estimated relative force accuracy = {:.8g}\n", estimated_accuracy/two_charge_force); - mesg += " using " LMP_FFT_PREC " precision " LMP_FFT_LIB "\n"; + mesg += " using " LMP_FFT_PREC " precision " LMP_FFT_KOKKOS_LIB "\n"; mesg += fmt::format(" 3d grid and FFT values/proc = {} {}\n", ngrid_max,nfft_both_max); utils::logmesg(lmp,mesg); diff --git a/src/KOKKOS/pppm_kokkos.h b/src/KOKKOS/pppm_kokkos.h index d621313873..d29f036d45 100644 --- a/src/KOKKOS/pppm_kokkos.h +++ b/src/KOKKOS/pppm_kokkos.h @@ -33,36 +33,6 @@ KSpaceStyle(pppm/kk/host,PPPMKokkos); // clang-format off -// fix up FFT defines for KOKKOS with CUDA and HIP - -#ifdef KOKKOS_ENABLE_CUDA -# if defined(FFT_FFTW) -# undef FFT_FFTW -# endif -# if defined(FFT_FFTW3) -# undef FFT_FFTW3 -# endif -# if defined(FFT_MKL) -# undef FFT_MKL -# endif -# if !defined(FFT_CUFFT) && !defined(FFT_KISSFFT) -# define FFT_KISSFFT -# endif -#elif defined(KOKKOS_ENABLE_HIP) -# if defined(FFT_FFTW) -# undef FFT_FFTW -# endif -# if defined(FFT_FFTW3) -# undef FFT_FFTW3 -# endif -# if defined(FFT_MKL) -# undef FFT_MKL -# endif -# if !defined(FFT_HIPFFT) && !defined(FFT_KISSFFT) -# define FFT_KISSFFT -# endif -#endif - #include "pppm.h" namespace LAMMPS_NS { diff --git a/src/KOKKOS/region_block_kokkos.cpp b/src/KOKKOS/region_block_kokkos.cpp index c53fae7b03..8df33c32db 100644 --- a/src/KOKKOS/region_block_kokkos.cpp +++ b/src/KOKKOS/region_block_kokkos.cpp @@ -18,12 +18,11 @@ using namespace LAMMPS_NS; -#define BIG 1.0e20 - /* ---------------------------------------------------------------------- */ template -RegBlockKokkos::RegBlockKokkos(LAMMPS *lmp, int narg, char **arg) : RegBlock(lmp, narg, arg) +RegBlockKokkos::RegBlockKokkos(LAMMPS *lmp, int narg, char **arg) + : RegBlock(lmp, narg, arg) { atomKK = (AtomKokkos*) atom; } diff --git a/src/KOKKOS/remap_kokkos.cpp b/src/KOKKOS/remap_kokkos.cpp index efc6742a25..0d539ada83 100644 --- a/src/KOKKOS/remap_kokkos.cpp +++ b/src/KOKKOS/remap_kokkos.cpp @@ -19,9 +19,6 @@ using namespace LAMMPS_NS; -#define MIN(A,B) ((A) < (B) ? (A) : (B)) -#define MAX(A,B) ((A) > (B) ? (A) : (B)) - /* ---------------------------------------------------------------------- */ template @@ -38,13 +35,13 @@ RemapKokkos::RemapKokkos(LAMMPS *lmp, MPI_Comm comm, int out_klo, int out_khi, int nqty, int permute, int memory, int precision, int usecollective, - int usecuda_aware) : Pointers(lmp) + int usegpu_aware) : Pointers(lmp) { plan = remap_3d_create_plan_kokkos(comm, in_ilo,in_ihi,in_jlo,in_jhi,in_klo,in_khi, out_ilo,out_ihi,out_jlo,out_jhi,out_klo,out_khi, nqty,permute,memory,precision,usecollective, - usecuda_aware); + usegpu_aware); if (plan == nullptr) error->one(FLERR,"Could not create 3d remap plan"); } @@ -121,7 +118,7 @@ void RemapKokkos::remap_3d_kokkos(typename FFT_AT::t_FFT_SCALAR_1d d // post all recvs into scratch space FFT_SCALAR* v_scratch = d_scratch.data(); - if (!plan->usecuda_aware) { + if (!plan->usegpu_aware) { plan->h_scratch = Kokkos::create_mirror_view(d_scratch); v_scratch = plan->h_scratch.data(); } @@ -134,7 +131,7 @@ void RemapKokkos::remap_3d_kokkos(typename FFT_AT::t_FFT_SCALAR_1d d } FFT_SCALAR* v_sendbuf = plan->d_sendbuf.data(); - if (!plan->usecuda_aware) { + if (!plan->usegpu_aware) { plan->h_sendbuf = Kokkos::create_mirror_view(plan->d_sendbuf); v_sendbuf = plan->h_sendbuf.data(); } @@ -146,7 +143,7 @@ void RemapKokkos::remap_3d_kokkos(typename FFT_AT::t_FFT_SCALAR_1d d plan->pack(d_in,in_offset, plan->d_sendbuf,0,&plan->packplan[isend]); - if (!plan->usecuda_aware) + if (!plan->usegpu_aware) Kokkos::deep_copy(plan->h_sendbuf,plan->d_sendbuf); MPI_Send(v_sendbuf,plan->send_size[isend],MPI_FFT_SCALAR, @@ -178,7 +175,7 @@ void RemapKokkos::remap_3d_kokkos(typename FFT_AT::t_FFT_SCALAR_1d d int scratch_offset = plan->recv_bufloc[irecv]; int out_offset = plan->recv_offset[irecv]; - if (!plan->usecuda_aware) + if (!plan->usegpu_aware) Kokkos::deep_copy(d_scratch,plan->h_scratch); plan->unpack(d_scratch,scratch_offset, @@ -209,7 +206,7 @@ void RemapKokkos::remap_3d_kokkos(typename FFT_AT::t_FFT_SCALAR_1d d 1 = single precision (4 bytes per datum) 2 = double precision (8 bytes per datum) usecollective whether to use collective MPI or point-to-point - usecuda_aware whether to use CUDA-Aware MPI or not + usegpu_aware whether to use GPU-Aware MPI or not ------------------------------------------------------------------------- */ template @@ -220,7 +217,7 @@ struct remap_plan_3d_kokkos* RemapKokkos::remap_3d_creat int out_ilo, int out_ihi, int out_jlo, int out_jhi, int out_klo, int out_khi, int nqty, int permute, int memory, int /*precision*/, - int usecollective, int usecuda_aware) + int usecollective, int usegpu_aware) { struct remap_plan_3d_kokkos *plan; @@ -238,7 +235,7 @@ struct remap_plan_3d_kokkos* RemapKokkos::remap_3d_creat plan = new struct remap_plan_3d_kokkos; if (plan == nullptr) return nullptr; plan->usecollective = usecollective; - plan->usecuda_aware = usecuda_aware; + plan->usegpu_aware = usegpu_aware; // store parameters in local data structs diff --git a/src/KOKKOS/remap_kokkos.h b/src/KOKKOS/remap_kokkos.h index a62c14f00b..77a3b1a37a 100644 --- a/src/KOKKOS/remap_kokkos.h +++ b/src/KOKKOS/remap_kokkos.h @@ -54,7 +54,7 @@ struct remap_plan_3d_kokkos { int usecollective; // use collective or point-to-point MPI int commringlen; // length of commringlist int *commringlist; // ranks on communication ring of this plan - int usecuda_aware; // use CUDA-Aware MPI or not + int usegpu_aware; // use GPU-Aware MPI or not }; template diff --git a/src/KOKKOS/third_order_kokkos.cpp b/src/KOKKOS/third_order_kokkos.cpp index 04c467777f..569a94a773 100644 --- a/src/KOKKOS/third_order_kokkos.cpp +++ b/src/KOKKOS/third_order_kokkos.cpp @@ -23,27 +23,18 @@ #include "atom_masks.h" #include "bond.h" #include "comm.h" -#include "compute.h" #include "dihedral.h" #include "domain.h" -#include "error.h" -#include "finish.h" #include "force.h" -#include "group.h" #include "improper.h" #include "kokkos.h" #include "kspace.h" -#include "memory.h" #include "modify.h" #include "neighbor.h" #include "pair.h" #include "timer.h" #include "update.h" -#include -#include -#include - using namespace LAMMPS_NS; enum{REGULAR,ESKM}; diff --git a/src/KOKKOS/verlet_kokkos.cpp b/src/KOKKOS/verlet_kokkos.cpp index 7570f1d8fa..858df5df6c 100644 --- a/src/KOKKOS/verlet_kokkos.cpp +++ b/src/KOKKOS/verlet_kokkos.cpp @@ -29,7 +29,6 @@ #include "update.h" #include "modify_kokkos.h" #include "timer.h" -#include "memory_kokkos.h" #include "kokkos.h" using namespace LAMMPS_NS; diff --git a/src/KSPACE/ewald.cpp b/src/KSPACE/ewald.cpp index 93470c60ac..930cc68ba9 100644 --- a/src/KSPACE/ewald.cpp +++ b/src/KSPACE/ewald.cpp @@ -35,7 +35,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.00001 +static constexpr double SMALL = 0.00001; /* ---------------------------------------------------------------------- */ diff --git a/src/KSPACE/ewald_dipole.cpp b/src/KSPACE/ewald_dipole.cpp index 7a3a1da8ff..e4982b1d56 100644 --- a/src/KSPACE/ewald_dipole.cpp +++ b/src/KSPACE/ewald_dipole.cpp @@ -36,7 +36,7 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define SMALL 0.00001 +static constexpr double SMALL = 0.00001; /* ---------------------------------------------------------------------- */ diff --git a/src/KSPACE/ewald_dipole_spin.cpp b/src/KSPACE/ewald_dipole_spin.cpp index c679e164f7..93821db9ba 100644 --- a/src/KSPACE/ewald_dipole_spin.cpp +++ b/src/KSPACE/ewald_dipole_spin.cpp @@ -34,7 +34,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.00001 +static constexpr double SMALL = 0.00001; /* ---------------------------------------------------------------------- */ diff --git a/src/KSPACE/ewald_disp.cpp b/src/KSPACE/ewald_disp.cpp index 31149134ad..9c81b21448 100644 --- a/src/KSPACE/ewald_disp.cpp +++ b/src/KSPACE/ewald_disp.cpp @@ -38,7 +38,7 @@ using namespace MathConst; using namespace MathSpecial; using namespace MathExtra; -#define SMALL 0.00001 +static constexpr double SMALL = 0.00001; //#define DEBUG diff --git a/src/KSPACE/msm.cpp b/src/KSPACE/msm.cpp index 041a5d5242..60bb768911 100644 --- a/src/KSPACE/msm.cpp +++ b/src/KSPACE/msm.cpp @@ -30,18 +30,17 @@ #include "neighbor.h" #include "pair.h" -#include #include +#include using namespace LAMMPS_NS; using namespace MathConst; -#define MAX_LEVELS 10 -#define OFFSET 16384 -#define SMALL 0.00001 +static constexpr int MAX_LEVELS = 10; +static constexpr int OFFSET = 16384; -enum{REVERSE_RHO,REVERSE_AD,REVERSE_AD_PERATOM}; -enum{FORWARD_RHO,FORWARD_AD,FORWARD_AD_PERATOM}; +enum { REVERSE_RHO, REVERSE_AD, REVERSE_AD_PERATOM }; +enum { FORWARD_RHO, FORWARD_AD, FORWARD_AD_PERATOM }; /* ---------------------------------------------------------------------- */ @@ -140,10 +139,6 @@ void MSM::init() if ((order < 4) || (order > 10) || (order%2 != 0)) error->all(FLERR,"MSM order must be 4, 6, 8, or 10"); - if (sizeof(FFT_SCALAR) != 8) - error->all(FLERR,"Cannot (yet) use single precision with MSM " - "(remove -DFFT_SINGLE from Makefile and re-compile)"); - // compute two charge force two_charge(); @@ -1607,8 +1602,7 @@ void MSM::direct(int n) qtmp = qgridn[icz][icy][icx]; // charge on center grid point esum = 0.0; - if (vflag_either && !scalar_pressure_flag) - v0sum = v1sum = v2sum = v3sum = v4sum = v5sum = 0.0; + v0sum = v1sum = v2sum = v3sum = v4sum = v5sum = 0.0; // use hemisphere to avoid double computation of pair-wise // interactions in direct sum (no computations in -z direction) diff --git a/src/KSPACE/msm_cg.cpp b/src/KSPACE/msm_cg.cpp index 4a8daedf10..e680c05cb2 100644 --- a/src/KSPACE/msm_cg.cpp +++ b/src/KSPACE/msm_cg.cpp @@ -31,8 +31,8 @@ using namespace LAMMPS_NS; -#define OFFSET 16384 -#define SMALLQ 0.00001 +static constexpr int OFFSET = 16384; +static constexpr double SMALLQ = 0.00001; enum{REVERSE_RHO,REVERSE_AD,REVERSE_AD_PERATOM}; enum{FORWARD_RHO,FORWARD_AD,FORWARD_AD_PERATOM}; diff --git a/src/KSPACE/pair_born_coul_long.cpp b/src/KSPACE/pair_born_coul_long.cpp index d31f655ce0..0165beba0d 100644 --- a/src/KSPACE/pair_born_coul_long.cpp +++ b/src/KSPACE/pair_born_coul_long.cpp @@ -21,6 +21,7 @@ #include "atom.h" #include "comm.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "kspace.h" #include "math_const.h" @@ -33,14 +34,7 @@ using namespace LAMMPS_NS; using namespace MathConst; - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/KSPACE/pair_buck_coul_long.cpp b/src/KSPACE/pair_buck_coul_long.cpp index 1516aab571..a6a86f3d45 100644 --- a/src/KSPACE/pair_buck_coul_long.cpp +++ b/src/KSPACE/pair_buck_coul_long.cpp @@ -17,6 +17,7 @@ #include "atom.h" #include "comm.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "kspace.h" #include "math_const.h" @@ -29,14 +30,7 @@ using namespace LAMMPS_NS; using namespace MathConst; - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/KSPACE/pair_buck_long_coul_long.cpp b/src/KSPACE/pair_buck_long_coul_long.cpp index 820b76b96f..e7cce1071a 100644 --- a/src/KSPACE/pair_buck_long_coul_long.cpp +++ b/src/KSPACE/pair_buck_long_coul_long.cpp @@ -21,6 +21,7 @@ #include "atom.h" #include "comm.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "kspace.h" #include "math_extra.h" @@ -35,14 +36,7 @@ using namespace LAMMPS_NS; using namespace MathExtra; - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/KSPACE/pair_coul_long.cpp b/src/KSPACE/pair_coul_long.cpp index 6b91050e3e..ef1b60ac56 100644 --- a/src/KSPACE/pair_coul_long.cpp +++ b/src/KSPACE/pair_coul_long.cpp @@ -20,6 +20,7 @@ #include "atom.h" #include "comm.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "kspace.h" #include "memory.h" @@ -30,14 +31,7 @@ #include using namespace LAMMPS_NS; - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/KSPACE/pair_coul_streitz.cpp b/src/KSPACE/pair_coul_streitz.cpp index bd7fd20656..b499df3946 100644 --- a/src/KSPACE/pair_coul_streitz.cpp +++ b/src/KSPACE/pair_coul_streitz.cpp @@ -35,9 +35,8 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define DELTA 4 -#define PGDELTA 1 -#define MAXNEIGH 24 +static constexpr int DELTA = 4; +static constexpr int MAXNEIGH = 24; /* ---------------------------------------------------------------------- */ diff --git a/src/KSPACE/pair_lj_charmm_coul_long.cpp b/src/KSPACE/pair_lj_charmm_coul_long.cpp index cdb8ead70a..ef367f8742 100644 --- a/src/KSPACE/pair_lj_charmm_coul_long.cpp +++ b/src/KSPACE/pair_lj_charmm_coul_long.cpp @@ -21,6 +21,7 @@ #include "atom.h" #include "comm.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "kspace.h" #include "memory.h" @@ -33,14 +34,7 @@ #include using namespace LAMMPS_NS; - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/KSPACE/pair_lj_charmmfsw_coul_long.cpp b/src/KSPACE/pair_lj_charmmfsw_coul_long.cpp index b7635c49c7..a0889d92ea 100644 --- a/src/KSPACE/pair_lj_charmmfsw_coul_long.cpp +++ b/src/KSPACE/pair_lj_charmmfsw_coul_long.cpp @@ -25,6 +25,7 @@ #include "atom.h" #include "comm.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "kspace.h" #include "memory.h" @@ -37,14 +38,7 @@ #include using namespace LAMMPS_NS; - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ @@ -76,6 +70,8 @@ PairLJCharmmfswCoulLong::PairLJCharmmfswCoulLong(LAMMPS *lmp) : Pair(lmp) PairLJCharmmfswCoulLong::~PairLJCharmmfswCoulLong() { + if (copymode) return; + // switch qqr2e back from CHARMM value to LAMMPS value if (update && strcmp(update->unit_style,"real") == 0) { @@ -85,8 +81,6 @@ PairLJCharmmfswCoulLong::~PairLJCharmmfswCoulLong() force->qqr2e = force->qqr2e_lammps_real; } - if (copymode) return; - if (allocated) { memory->destroy(setflag); memory->destroy(cutsq); diff --git a/src/KSPACE/pair_lj_cut_coul_long.cpp b/src/KSPACE/pair_lj_cut_coul_long.cpp index c474816075..969f235c55 100644 --- a/src/KSPACE/pair_lj_cut_coul_long.cpp +++ b/src/KSPACE/pair_lj_cut_coul_long.cpp @@ -21,6 +21,7 @@ #include "atom.h" #include "comm.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "kspace.h" #include "math_const.h" @@ -35,14 +36,7 @@ using namespace LAMMPS_NS; using namespace MathConst; - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/KSPACE/pair_lj_cut_tip4p_long.cpp b/src/KSPACE/pair_lj_cut_tip4p_long.cpp index 817b335b3a..32a04e2761 100644 --- a/src/KSPACE/pair_lj_cut_tip4p_long.cpp +++ b/src/KSPACE/pair_lj_cut_tip4p_long.cpp @@ -29,19 +29,13 @@ #include "neigh_list.h" #include "memory.h" #include "error.h" +#include "ewald_const.h" #include #include using namespace LAMMPS_NS; - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/KSPACE/pair_lj_long_coul_long.cpp b/src/KSPACE/pair_lj_long_coul_long.cpp index 5f77009d6c..5f3c0327db 100644 --- a/src/KSPACE/pair_lj_long_coul_long.cpp +++ b/src/KSPACE/pair_lj_long_coul_long.cpp @@ -23,6 +23,7 @@ #include "atom.h" #include "comm.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "kspace.h" #include "math_extra.h" @@ -37,14 +38,7 @@ using namespace LAMMPS_NS; using namespace MathExtra; - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/KSPACE/pair_lj_long_tip4p_long.cpp b/src/KSPACE/pair_lj_long_tip4p_long.cpp index 8c331922f6..187b22a78a 100644 --- a/src/KSPACE/pair_lj_long_tip4p_long.cpp +++ b/src/KSPACE/pair_lj_long_tip4p_long.cpp @@ -29,19 +29,13 @@ #include "neigh_list.h" #include "memory.h" #include "error.h" +#include "ewald_const.h" #include #include using namespace LAMMPS_NS; - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/KSPACE/pair_tip4p_long.cpp b/src/KSPACE/pair_tip4p_long.cpp index 83eeccca9c..637a272e49 100644 --- a/src/KSPACE/pair_tip4p_long.cpp +++ b/src/KSPACE/pair_tip4p_long.cpp @@ -31,17 +31,10 @@ #include "neigh_list.h" #include "memory.h" #include "error.h" - +#include "ewald_const.h" using namespace LAMMPS_NS; - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/KSPACE/pppm.cpp b/src/KSPACE/pppm.cpp index ac516ff18c..4fe5075f44 100644 --- a/src/KSPACE/pppm.cpp +++ b/src/KSPACE/pppm.cpp @@ -24,14 +24,12 @@ #include "angle.h" #include "atom.h" #include "bond.h" -#include "comm.h" #include "domain.h" #include "error.h" #include "fft3d_wrap.h" #include "force.h" #include "grid3d.h" #include "math_const.h" -#include "math_extra.h" #include "math_special.h" #include "memory.h" #include "neighbor.h" @@ -45,22 +43,15 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define MAXORDER 7 -#define OFFSET 16384 -#define LARGE 10000.0 -#define SMALL 0.00001 -#define EPS_HOC 1.0e-7 +static constexpr int MAXORDER = 7; +static constexpr int OFFSET = 16384; +static constexpr double LARGE = 10000.0; +static constexpr double SMALL = 0.00001; +static constexpr double EPS_HOC = 1.0e-7; +static constexpr FFT_SCALAR ZEROF = 0.0; -enum{REVERSE_RHO}; -enum{FORWARD_IK,FORWARD_AD,FORWARD_IK_PERATOM,FORWARD_AD_PERATOM}; - -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#define ONEF 1.0f -#else -#define ZEROF 0.0 -#define ONEF 1.0 -#endif +enum { REVERSE_RHO }; +enum { FORWARD_IK, FORWARD_AD, FORWARD_IK_PERATOM, FORWARD_AD_PERATOM }; /* ---------------------------------------------------------------------- */ diff --git a/src/KSPACE/pppm_cg.cpp b/src/KSPACE/pppm_cg.cpp index 845abe0078..cebf9e0000 100644 --- a/src/KSPACE/pppm_cg.cpp +++ b/src/KSPACE/pppm_cg.cpp @@ -26,7 +26,6 @@ #include "math_const.h" #include "memory.h" #include "neighbor.h" -#include "remap.h" #include #include @@ -34,17 +33,13 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define OFFSET 16384 -#define SMALLQ 0.00001 +static constexpr int OFFSET = 16384; +static constexpr double SMALLQ = 0.00001; enum{REVERSE_RHO}; enum{FORWARD_IK,FORWARD_AD,FORWARD_IK_PERATOM,FORWARD_AD_PERATOM}; -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#else -#define ZEROF 0.0 -#endif +static constexpr FFT_SCALAR ZEROF = 0.0; /* ---------------------------------------------------------------------- */ diff --git a/src/KSPACE/pppm_dipole.cpp b/src/KSPACE/pppm_dipole.cpp index e0d13f2b9a..99a0efd75e 100644 --- a/src/KSPACE/pppm_dipole.cpp +++ b/src/KSPACE/pppm_dipole.cpp @@ -40,22 +40,14 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define MAXORDER 7 -#define OFFSET 16384 -#define LARGE 10000.0 -#define SMALL 0.00001 -#define EPS_HOC 1.0e-7 +static constexpr int MAXORDER = 7; +static constexpr int OFFSET = 16384; +static constexpr double SMALL = 0.00001; +static constexpr double EPS_HOC = 1.0e-7; +static constexpr FFT_SCALAR ZEROF = 0.0; -enum{REVERSE_MU}; -enum{FORWARD_MU,FORWARD_MU_PERATOM}; - -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#define ONEF 1.0f -#else -#define ZEROF 0.0 -#define ONEF 1.0 -#endif +enum { REVERSE_MU }; +enum { FORWARD_MU, FORWARD_MU_PERATOM }; /* ---------------------------------------------------------------------- */ diff --git a/src/KSPACE/pppm_dipole_spin.cpp b/src/KSPACE/pppm_dipole_spin.cpp index e96378180a..8f195a8a41 100644 --- a/src/KSPACE/pppm_dipole_spin.cpp +++ b/src/KSPACE/pppm_dipole_spin.cpp @@ -35,22 +35,12 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define MAXORDER 7 -#define OFFSET 16384 -#define LARGE 10000.0 -#define SMALL 0.00001 -#define EPS_HOC 1.0e-7 +static constexpr int MAXORDER = 7; -enum{REVERSE_MU}; -enum{FORWARD_MU,FORWARD_MU_PERATOM}; +enum { REVERSE_MU }; +enum { FORWARD_MU, FORWARD_MU_PERATOM }; -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#define ONEF 1.0f -#else -#define ZEROF 0.0 -#define ONEF 1.0 -#endif +static constexpr FFT_SCALAR ZEROF = 0.0; /* ---------------------------------------------------------------------- */ diff --git a/src/KSPACE/pppm_disp.cpp b/src/KSPACE/pppm_disp.cpp index a738db98d2..b70dae45f9 100644 --- a/src/KSPACE/pppm_disp.cpp +++ b/src/KSPACE/pppm_disp.cpp @@ -40,11 +40,11 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define MAXORDER 7 -#define OFFSET 16384 -#define SMALL 0.00001 -#define LARGE 10000.0 -#define EPS_HOC 1.0e-7 +static constexpr int MAXORDER = 7; +static constexpr int OFFSET = 16384; +static constexpr double SMALL = 0.00001; +static constexpr double LARGE = 10000.0; +static constexpr FFT_SCALAR ZEROF = 0.0; enum{REVERSE_RHO,REVERSE_RHO_GEOM,REVERSE_RHO_ARITH,REVERSE_RHO_NONE}; enum{FORWARD_IK,FORWARD_AD,FORWARD_IK_PERATOM,FORWARD_AD_PERATOM, @@ -55,14 +55,6 @@ enum{FORWARD_IK,FORWARD_AD,FORWARD_IK_PERATOM,FORWARD_AD_PERATOM, FORWARD_IK_NONE,FORWARD_AD_NONE,FORWARD_IK_PERATOM_NONE, FORWARD_AD_PERATOM_NONE}; -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#define ONEF 1.0f -#else -#define ZEROF 0.0 -#define ONEF 1.0 -#endif - /* ---------------------------------------------------------------------- */ PPPMDisp::PPPMDisp(LAMMPS *lmp) : KSpace(lmp), diff --git a/src/KSPACE/pppm_disp.h b/src/KSPACE/pppm_disp.h index a222e041d9..1a271e59d2 100644 --- a/src/KSPACE/pppm_disp.h +++ b/src/KSPACE/pppm_disp.h @@ -25,8 +25,8 @@ KSpaceStyle(pppm/disp,PPPMDisp); namespace LAMMPS_NS { -#define EWALD_MAXORDER 6 -#define EWALD_FUNCS 4 +static constexpr int EWALD_MAXORDER = 6; +static constexpr int EWALD_FUNCS = 4; class PPPMDisp : public KSpace { public: diff --git a/src/KSPACE/pppm_disp_tip4p.cpp b/src/KSPACE/pppm_disp_tip4p.cpp index c5ed2f26d6..9e2184f2a9 100644 --- a/src/KSPACE/pppm_disp_tip4p.cpp +++ b/src/KSPACE/pppm_disp_tip4p.cpp @@ -29,15 +29,8 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define OFFSET 16384 - -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#define ONEF 1.0f -#else -#define ZEROF 0.0 -#define ONEF 1.0 -#endif +static constexpr int OFFSET = 16384; +static constexpr FFT_SCALAR ZEROF = 0.0; /* ---------------------------------------------------------------------- */ @@ -490,7 +483,7 @@ void PPPMDispTIP4P::fieldforce_c_peratom() Fix handling of TIP4P dipole compared to PPPMDisp::slabcorr ------------------------------------------------------------------------- */ -#define SMALL 0.00001 +static constexpr double SMALL = 0.00001; void PPPMDispTIP4P::slabcorr(int /*eflag*/) { diff --git a/src/KSPACE/pppm_stagger.cpp b/src/KSPACE/pppm_stagger.cpp index d44f2428c8..b740d21daa 100644 --- a/src/KSPACE/pppm_stagger.cpp +++ b/src/KSPACE/pppm_stagger.cpp @@ -33,19 +33,12 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define OFFSET 16384 -#define EPS_HOC 1.0e-7 +static constexpr int OFFSET = 16384; +static constexpr double EPS_HOC = 1.0e-7; +static constexpr FFT_SCALAR ZEROF = 0.0; -enum{REVERSE_RHO}; -enum{FORWARD_IK,FORWARD_AD,FORWARD_IK_PERATOM,FORWARD_AD_PERATOM}; - -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#define ONEF 1.0f -#else -#define ZEROF 0.0 -#define ONEF 1.0 -#endif +enum{ REVERSE_RHO }; +enum{ FORWARD_IK, FORWARD_AD, FORWARD_IK_PERATOM, FORWARD_AD_PERATOM }; /* ---------------------------------------------------------------------- */ diff --git a/src/KSPACE/pppm_tip4p.cpp b/src/KSPACE/pppm_tip4p.cpp index 730b604d7a..2a34db2b77 100644 --- a/src/KSPACE/pppm_tip4p.cpp +++ b/src/KSPACE/pppm_tip4p.cpp @@ -29,15 +29,8 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define OFFSET 16384 - -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#define ONEF 1.0f -#else -#define ZEROF 0.0 -#define ONEF 1.0 -#endif +static constexpr FFT_SCALAR ZEROF = 0.0; +static constexpr int OFFSET = 16384; /* ---------------------------------------------------------------------- */ @@ -483,7 +476,7 @@ void PPPMTIP4P::fieldforce_peratom() Fix handling of TIP4P dipole compared to PPPMDisp::slabcorr ------------------------------------------------------------------------- */ -#define SMALL 0.00001 +static constexpr double SMALL = 0.00001; void PPPMTIP4P::slabcorr() { diff --git a/src/LEPTON/angle_lepton.cpp b/src/LEPTON/angle_lepton.cpp index 59310f5637..6efded950f 100644 --- a/src/LEPTON/angle_lepton.cpp +++ b/src/LEPTON/angle_lepton.cpp @@ -27,6 +27,8 @@ #include "neighbor.h" #include +#include +#include #include "Lepton.h" #include "lepton_utils.h" @@ -44,6 +46,7 @@ AngleLepton::AngleLepton(LAMMPS *_lmp) : { writedata = 1; reinitflag = 0; + auto_offset = 1; } /* ---------------------------------------------------------------------- */ @@ -90,10 +93,21 @@ template void AngleLepton::eval() { std::vector angleforce; std::vector anglepot; - for (const auto &expr : expressions) { - auto parsed = Lepton::Parser::parse(LeptonUtils::substitute(expr, lmp)); - angleforce.emplace_back(parsed.differentiate("theta").createCompiledExpression()); - if (EFLAG) anglepot.emplace_back(parsed.createCompiledExpression()); + std::vector has_ref; + try { + for (const auto &expr : expressions) { + auto parsed = Lepton::Parser::parse(LeptonUtils::substitute(expr, lmp)); + angleforce.emplace_back(parsed.differentiate("theta").createCompiledExpression()); + has_ref.push_back(true); + try { + angleforce.back().getVariableReference("theta"); + } catch (Lepton::Exception &) { + has_ref.back() = false; + } + if (EFLAG) anglepot.emplace_back(parsed.createCompiledExpression()); + } + } catch (std::exception &e) { + error->all(FLERR, e.what()); } const double *const *const x = atom->x; @@ -142,8 +156,7 @@ template void AngleLepton::eval() const double dtheta = acos(c) - theta0[type]; const int idx = type2expression[type]; - angleforce[idx].getVariableReference("theta") = dtheta; - + if (has_ref[idx]) angleforce[idx].getVariableReference("theta") = dtheta; const double a = -angleforce[idx].evaluate() * s; const double a11 = a * c / rsq1; const double a12 = -a / (r1 * r2); @@ -179,7 +192,11 @@ template void AngleLepton::eval() double eangle = 0.0; if (EFLAG) { - anglepot[idx].getVariableReference("theta") = dtheta; + try { + anglepot[idx].getVariableReference("theta") = dtheta; + } catch (Lepton::Exception &) { + ; // ignore -> constant force + } eangle = anglepot[idx].evaluate() - offset[type]; } if (EVFLAG) @@ -202,6 +219,24 @@ void AngleLepton::allocate() for (int i = 1; i < np1; i++) setflag[i] = 0; } +/* ---------------------------------------------------------------------- + global settings +------------------------------------------------------------------------- */ + +void AngleLepton::settings(int narg, char **arg) +{ + auto_offset = 1; + if (narg > 0) { + if (strcmp(arg[0],"auto_offset") == 0) { + auto_offset = 1; + } else if (strcmp(arg[0],"no_offset") == 0) { + auto_offset = 0; + } else { + error->all(FLERR, "Unknown angle style lepton setting {}", arg[0]); + } + } +} + /* ---------------------------------------------------------------------- set coeffs for one or more types ------------------------------------------------------------------------- */ @@ -224,9 +259,20 @@ void AngleLepton::coeff(int narg, char **arg) auto parsed = Lepton::Parser::parse(LeptonUtils::substitute(exp_one, lmp)); auto anglepot = parsed.createCompiledExpression(); auto angleforce = parsed.differentiate("theta").createCompiledExpression(); - anglepot.getVariableReference("theta") = 0.0; - angleforce.getVariableReference("theta") = 0.0; - offset_one = anglepot.evaluate(); + try { + anglepot.getVariableReference("theta") = 0.0; + } catch (Lepton::Exception &) { + if (comm->me == 0) + error->warning(FLERR, "Lepton potential expression {} does not depend on 'theta'", exp_one); + } + try { + angleforce.getVariableReference("theta") = 0.0; + } catch (Lepton::Exception &) { + if (comm->me == 0) + error->warning(FLERR, "Force from Lepton expression {} does not depend on 'theta'", + exp_one); + } + if (auto_offset) offset_one = anglepot.evaluate(); angleforce.evaluate(); } catch (std::exception &e) { error->all(FLERR, e.what()); @@ -284,6 +330,7 @@ void AngleLepton::write_restart(FILE *fp) fwrite(&n, sizeof(int), 1, fp); fwrite(exp.c_str(), sizeof(char), n, fp); } + fwrite(&auto_offset, sizeof(int), 1, fp); } /* ---------------------------------------------------------------------- @@ -323,6 +370,9 @@ void AngleLepton::read_restart(FILE *fp) expressions.emplace_back(buf); } + if (comm->me == 0) utils::sfread(FLERR, &auto_offset, sizeof(int), 1, fp, nullptr, error); + MPI_Bcast(&auto_offset, 1, MPI_INT, 0, world); + delete[] buf; } @@ -363,7 +413,11 @@ double AngleLepton::single(int type, int i1, int i2, int i3) const auto &expr = expressions[type2expression[type]]; auto parsed = Lepton::Parser::parse(LeptonUtils::substitute(expr, lmp)); auto anglepot = parsed.createCompiledExpression(); - anglepot.getVariableReference("theta") = dtheta; + try { + anglepot.getVariableReference("theta") = dtheta; + } catch (Lepton::Exception &) { + ; // ignore -> constant potential + } return anglepot.evaluate() - offset[type]; } diff --git a/src/LEPTON/angle_lepton.h b/src/LEPTON/angle_lepton.h index 67d2718fb6..4f0e5729ed 100644 --- a/src/LEPTON/angle_lepton.h +++ b/src/LEPTON/angle_lepton.h @@ -29,6 +29,7 @@ class AngleLepton : public Angle { AngleLepton(class LAMMPS *); ~AngleLepton() override; void compute(int, int) override; + void settings(int, char **) override; void coeff(int, char **) override; double equilibrium_angle(int) override; void write_restart(FILE *) override; @@ -42,6 +43,7 @@ class AngleLepton : public Angle { double *theta0; int *type2expression; double *offset; + int auto_offset; virtual void allocate(); diff --git a/src/LEPTON/bond_lepton.cpp b/src/LEPTON/bond_lepton.cpp index 773607782d..63c66011a1 100644 --- a/src/LEPTON/bond_lepton.cpp +++ b/src/LEPTON/bond_lepton.cpp @@ -25,6 +25,8 @@ #include "neighbor.h" #include +#include +#include #include "Lepton.h" #include "lepton_utils.h" @@ -37,6 +39,7 @@ BondLepton::BondLepton(LAMMPS *_lmp) : { writedata = 1; reinitflag = 0; + auto_offset = 1; } /* ---------------------------------------------------------------------- */ @@ -82,10 +85,17 @@ template void BondLepton::eval() { std::vector bondforce; std::vector bondpot; + std::vector has_ref; try { for (const auto &expr : expressions) { auto parsed = Lepton::Parser::parse(LeptonUtils::substitute(expr, lmp)); bondforce.emplace_back(parsed.differentiate("r").createCompiledExpression()); + has_ref.push_back(true); + try { + bondforce.back().getVariableReference("r"); + } catch (Lepton::Exception &) { + has_ref.back() = false; + } if (EFLAG) bondpot.emplace_back(parsed.createCompiledExpression()); } } catch (std::exception &e) { @@ -116,7 +126,7 @@ template void BondLepton::eval() double fbond = 0.0; if (r > 0.0) { - bondforce[idx].getVariableReference("r") = dr; + if (has_ref[idx]) bondforce[idx].getVariableReference("r") = dr; fbond = -bondforce[idx].evaluate() / r; } @@ -136,7 +146,11 @@ template void BondLepton::eval() double ebond = 0.0; if (EFLAG) { - bondpot[idx].getVariableReference("r") = dr; + try { + bondpot[idx].getVariableReference("r") = dr; + } catch (Lepton::Exception &) { + ; // ignore -> constant potential + } ebond = bondpot[idx].evaluate() - offset[type]; } if (EVFLAG) ev_tally(i1, i2, nlocal, NEWTON_BOND, ebond, fbond, delx, dely, delz); @@ -157,6 +171,24 @@ void BondLepton::allocate() for (int i = 1; i < np1; i++) setflag[i] = 0; } +/* ---------------------------------------------------------------------- + global settings +------------------------------------------------------------------------- */ + +void BondLepton::settings(int narg, char **arg) +{ + auto_offset = 1; + if (narg > 0) { + if (strcmp(arg[0],"auto_offset") == 0) { + auto_offset = 1; + } else if (strcmp(arg[0],"no_offset") == 0) { + auto_offset = 0; + } else { + error->all(FLERR, "Unknown bond style lepton setting {}", arg[0]); + } + } +} + /* ---------------------------------------------------------------------- set coeffs for one or more types ------------------------------------------------------------------------- */ @@ -179,9 +211,19 @@ void BondLepton::coeff(int narg, char **arg) auto parsed = Lepton::Parser::parse(LeptonUtils::substitute(exp_one, lmp)); auto bondpot = parsed.createCompiledExpression(); auto bondforce = parsed.differentiate("r").createCompiledExpression(); - bondpot.getVariableReference("r") = 0.0; - bondforce.getVariableReference("r") = 0.0; - offset_one = bondpot.evaluate(); + try { + bondpot.getVariableReference("r") = 0.0; + } catch (Lepton::Exception &e) { + if (comm->me == 0) + error->warning(FLERR, "Lepton potential expression {} does not depend on 'r'", exp_one); + } + try { + bondforce.getVariableReference("r") = 0.0; + } catch (Lepton::Exception &e) { + if (comm->me == 0) + error->warning(FLERR, "Force from Lepton expression {} does not depend on 'r'", exp_one); + } + if (auto_offset) offset_one = bondpot.evaluate(); bondforce.evaluate(); } catch (std::exception &e) { error->all(FLERR, e.what()); @@ -239,6 +281,7 @@ void BondLepton::write_restart(FILE *fp) fwrite(&n, sizeof(int), 1, fp); fwrite(exp.c_str(), sizeof(char), n, fp); } + fwrite(&auto_offset, sizeof(int), 1, fp); } /* ---------------------------------------------------------------------- @@ -278,6 +321,9 @@ void BondLepton::read_restart(FILE *fp) expressions.emplace_back(buf); } + if (comm->me == 0) utils::sfread(FLERR, &auto_offset, sizeof(int), 1, fp, nullptr, error); + MPI_Bcast(&auto_offset, 1, MPI_INT, 0, world); + delete[] buf; } @@ -302,8 +348,12 @@ double BondLepton::single(int type, double rsq, int /*i*/, int /*j*/, double &ff auto parsed = Lepton::Parser::parse(LeptonUtils::substitute(expr, lmp)); auto bondpot = parsed.createCompiledExpression(); auto bondforce = parsed.differentiate("r").createCompiledExpression(); - bondforce.getVariableReference("r") = dr; - bondpot.getVariableReference("r") = dr; + try { + bondpot.getVariableReference("r") = dr; + bondforce.getVariableReference("r") = dr; + } catch (Lepton::Exception &) { + ; // ignore -> constant potential or force + } // force and energy diff --git a/src/LEPTON/bond_lepton.h b/src/LEPTON/bond_lepton.h index 9e693298a7..e59648a3f0 100644 --- a/src/LEPTON/bond_lepton.h +++ b/src/LEPTON/bond_lepton.h @@ -29,6 +29,7 @@ class BondLepton : public Bond { BondLepton(class LAMMPS *); ~BondLepton() override; void compute(int, int) override; + void settings(int, char **) override; void coeff(int, char **) override; double equilibrium_distance(int) override; void write_restart(FILE *) override; @@ -42,6 +43,7 @@ class BondLepton : public Bond { double *r0; int *type2expression; double *offset; + int auto_offset; virtual void allocate(); diff --git a/src/LEPTON/dihedral_lepton.cpp b/src/LEPTON/dihedral_lepton.cpp index 6470e43033..16975a8f52 100644 --- a/src/LEPTON/dihedral_lepton.cpp +++ b/src/LEPTON/dihedral_lepton.cpp @@ -29,6 +29,7 @@ #include "neighbor.h" #include +#include #include "Lepton.h" #include "lepton_utils.h" @@ -92,10 +93,17 @@ template void DihedralLepton::eval() { std::vector dihedralforce; std::vector dihedralpot; + std::vector has_ref; try { for (const auto &expr : expressions) { auto parsed = Lepton::Parser::parse(LeptonUtils::substitute(expr, lmp)); dihedralforce.emplace_back(parsed.differentiate("phi").createCompiledExpression()); + has_ref.push_back(true); + try { + dihedralforce.back().getVariableReference("phi"); + } catch (Lepton::Exception &) { + has_ref.back() = false; + } if (EFLAG) dihedralpot.emplace_back(parsed.createCompiledExpression()); } } catch (std::exception &e) { @@ -278,7 +286,7 @@ template void DihedralLepton::eval() } const int idx = type2expression[type]; - dihedralforce[idx].getVariableReference("phi") = phi; + if (has_ref[idx]) dihedralforce[idx].getVariableReference("phi") = phi; double m_du_dphi = -dihedralforce[idx].evaluate(); // ----- Step 4: Calculate the force direction in real space ----- @@ -322,7 +330,11 @@ template void DihedralLepton::eval() double edihedral = 0.0; if (EFLAG) { - dihedralpot[idx].getVariableReference("phi") = phi; + try { + dihedralpot[idx].getVariableReference("phi") = phi; + } catch (Lepton::Exception &) { + ; // ignore -> constant potential + } edihedral = dihedralpot[idx].evaluate(); } if (EVFLAG) @@ -362,8 +374,18 @@ void DihedralLepton::coeff(int narg, char **arg) auto parsed = Lepton::Parser::parse(LeptonUtils::substitute(exp_one, lmp)); auto dihedralpot = parsed.createCompiledExpression(); auto dihedralforce = parsed.differentiate("phi").createCompiledExpression(); - dihedralpot.getVariableReference("phi") = 0.0; - dihedralforce.getVariableReference("phi") = 0.0; + try { + dihedralpot.getVariableReference("phi") = 0.0; + } catch (Lepton::Exception &) { + if (comm->me == 0) + error->warning(FLERR, "Lepton potential expression {} does not depend on 'phi'", exp_one); + } + try { + dihedralforce.getVariableReference("phi") = 0.0; + } catch (Lepton::Exception &) { + if (comm->me == 0) + error->warning(FLERR, "Force from Lepton expression {} does not depend on 'phi'", exp_one); + } dihedralforce.evaluate(); } catch (std::exception &e) { error->all(FLERR, e.what()); diff --git a/src/LEPTON/fix_wall_lepton.cpp b/src/LEPTON/fix_wall_lepton.cpp index a81d3c4edb..320efb090e 100644 --- a/src/LEPTON/fix_wall_lepton.cpp +++ b/src/LEPTON/fix_wall_lepton.cpp @@ -13,11 +13,14 @@ #include "fix_wall_lepton.h" #include "atom.h" +#include "comm.h" #include "error.h" #include "Lepton.h" #include "lepton_utils.h" +#include + using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ @@ -41,8 +44,18 @@ void FixWallLepton::post_constructor() auto parsed = Lepton::Parser::parse(LeptonUtils::substitute(exp_one, lmp)); auto wallpot = parsed.createCompiledExpression(); auto wallforce = parsed.differentiate("r").createCompiledExpression(); - wallpot.getVariableReference("r") = 0.0; - wallforce.getVariableReference("r") = 0.0; + try { + wallpot.getVariableReference("r") = 0.0; + } catch (Lepton::Exception &) { + if (comm->me == 0) + error->warning(FLERR, "Lepton potential expression {} does not depend on 'r'", exp_one); + } + try { + wallforce.getVariableReference("r") = 0.0; + } catch (Lepton::Exception &) { + if (comm->me == 0) + error->warning(FLERR, "Force from Lepton expression {} does not depend on 'r'", exp_one); + } wallpot.evaluate(); wallforce.evaluate(); } catch (std::exception &e) { diff --git a/src/LEPTON/lepton_utils.cpp b/src/LEPTON/lepton_utils.cpp index 89e69beddd..c4e527d7d7 100644 --- a/src/LEPTON/lepton_utils.cpp +++ b/src/LEPTON/lepton_utils.cpp @@ -17,7 +17,6 @@ #include "lepton_utils.h" -#include "error.h" #include "input.h" #include "lammps.h" #include "pair_zbl_const.h" diff --git a/src/LEPTON/pair_lepton.cpp b/src/LEPTON/pair_lepton.cpp index a8af0ce576..90003e9091 100644 --- a/src/LEPTON/pair_lepton.cpp +++ b/src/LEPTON/pair_lepton.cpp @@ -23,11 +23,12 @@ #include "force.h" #include "memory.h" #include "neigh_list.h" -#include "update.h" #include "Lepton.h" #include "lepton_utils.h" + #include +#include #include using namespace LAMMPS_NS; @@ -105,11 +106,17 @@ template void PairLepton::eval() std::vector pairforce; std::vector pairpot; + std::vector has_ref; try { for (const auto &expr : expressions) { auto parsed = Lepton::Parser::parse(LeptonUtils::substitute(expr, lmp), functions); pairforce.emplace_back(parsed.differentiate("r").createCompiledExpression()); - pairforce.back().getVariableReference("r"); + has_ref.push_back(true); + try { + pairforce.back().getVariableReference("r"); + } catch (Lepton::Exception &) { + has_ref.back() = false; + } if (EFLAG) pairpot.emplace_back(parsed.createCompiledExpression()); } } catch (std::exception &e) { @@ -142,8 +149,7 @@ template void PairLepton::eval() if (rsq < cutsq[itype][jtype]) { const double r = sqrt(rsq); const int idx = type2expression[itype][jtype]; - double &r_for = pairforce[idx].getVariableReference("r"); - r_for = r; + if (has_ref[idx]) pairforce[idx].getVariableReference("r") = r; const double fpair = -pairforce[idx].evaluate() / r * factor_lj; fxtmp += delx * fpair; @@ -157,7 +163,11 @@ template void PairLepton::eval() double evdwl = 0.0; if (EFLAG) { - pairpot[idx].getVariableReference("r") = r; + try { + pairpot[idx].getVariableReference("r") = r; + } catch (Lepton::Exception &) { + ; // ignore -> constant potential + } evdwl = pairpot[idx].evaluate() - offset[itype][jtype]; evdwl *= factor_lj; } @@ -229,8 +239,12 @@ void PairLepton::coeff(int narg, char **arg) auto parsed = Lepton::Parser::parse(LeptonUtils::substitute(exp_one, lmp), functions); auto pairforce = parsed.differentiate("r").createCompiledExpression(); auto pairpot = parsed.createCompiledExpression(); - pairpot.getVariableReference("r") = 1.0; - pairforce.getVariableReference("r") = 1.0; + try { + pairpot.getVariableReference("r") = 1.0; + pairforce.getVariableReference("r") = 1.0; + } catch (Lepton::Exception &) { + ; // ignore -> constant potential or force + } pairpot.evaluate(); pairforce.evaluate(); } catch (std::exception &e) { @@ -270,7 +284,11 @@ double PairLepton::init_one(int i, int j) try { auto expr = LeptonUtils::substitute(expressions[type2expression[i][j]], lmp); auto pairpot = Lepton::Parser::parse(expr, functions).createCompiledExpression(); - pairpot.getVariableReference("r") = cut[i][j]; + try { + pairpot.getVariableReference("r") = cut[i][j]; + } catch (Lepton::Exception &) { + ; // ignore -> constant potential + } offset[i][j] = pairpot.evaluate(); } catch (std::exception &) { } @@ -429,9 +447,12 @@ double PairLepton::single(int /* i */, int /* j */, int itype, int jtype, double auto pairforce = parsed.differentiate("r").createCompiledExpression(); const double r = sqrt(rsq); - pairpot.getVariableReference("r") = r; - pairforce.getVariableReference("r") = r; - + try { + pairpot.getVariableReference("r") = r; + pairforce.getVariableReference("r") = r; + } catch (Lepton::Exception &) { + ; // ignore -> constant potential or force + } fforce = -pairforce.evaluate() / r * factor_lj; return (pairpot.evaluate() - offset[itype][jtype]) * factor_lj; } diff --git a/src/LEPTON/pair_lepton_coul.cpp b/src/LEPTON/pair_lepton_coul.cpp index 841565e874..bb6b8ed55f 100644 --- a/src/LEPTON/pair_lepton_coul.cpp +++ b/src/LEPTON/pair_lepton_coul.cpp @@ -21,14 +21,16 @@ #include "comm.h" #include "error.h" #include "force.h" -#include "memory.h" #include "neigh_list.h" #include "neighbor.h" -#include "update.h" #include "Lepton.h" #include "lepton_utils.h" + +#include #include +#include +#include using namespace LAMMPS_NS; @@ -79,25 +81,30 @@ template void PairLeptonCoul::eval() std::vector pairforce; std::vector pairpot; - std::vector> have_q; + std::vector> has_ref; try { for (const auto &expr : expressions) { auto parsed = Lepton::Parser::parse(LeptonUtils::substitute(expr, lmp), functions); pairforce.emplace_back(parsed.differentiate("r").createCompiledExpression()); + has_ref.push_back({true, true, true}); + try { + pairforce.back().getVariableReference("r"); + } catch (Lepton::Exception &) { + has_ref.back()[0] = false; + } if (EFLAG) pairpot.emplace_back(parsed.createCompiledExpression()); - pairforce.back().getVariableReference("r"); - have_q.emplace_back(true, true); // check if there are references to charges + try { pairforce.back().getVariableReference("qi"); - } catch (std::exception &) { - have_q.back().first = false; + } catch (Lepton::Exception &) { + has_ref.back()[1] = false; } try { pairforce.back().getVariableReference("qj"); - } catch (std::exception &) { - have_q.back().second = false; + } catch (Lepton::Exception &) { + has_ref.back()[2] = false; } } } catch (std::exception &e) { @@ -130,9 +137,9 @@ template void PairLeptonCoul::eval() if (rsq < cutsq[itype][jtype]) { const double r = sqrt(rsq); const int idx = type2expression[itype][jtype]; - pairforce[idx].getVariableReference("r") = r; - if (have_q[idx].first) pairforce[idx].getVariableReference("qi") = q2e * q[i]; - if (have_q[idx].second) pairforce[idx].getVariableReference("qj") = q2e * q[j]; + if (has_ref[idx][0]) pairforce[idx].getVariableReference("r") = r; + if (has_ref[idx][1]) pairforce[idx].getVariableReference("qi") = q2e * q[i]; + if (has_ref[idx][2]) pairforce[idx].getVariableReference("qj") = q2e * q[j]; const double fpair = -pairforce[idx].evaluate() / r * factor_coul; fxtmp += delx * fpair; @@ -146,9 +153,14 @@ template void PairLeptonCoul::eval() double ecoul = 0.0; if (EFLAG) { - pairpot[idx].getVariableReference("r") = r; - if (have_q[idx].first) pairpot[idx].getVariableReference("qi") = q2e * q[i]; - if (have_q[idx].second) pairpot[idx].getVariableReference("qj") = q2e * q[j]; + try { + pairpot[idx].getVariableReference("r") = r; + } catch (Lepton::Exception &) { + ; // ignore -> constant potential + } + if (has_ref[idx][1]) pairpot[idx].getVariableReference("qi") = q2e * q[i]; + if (has_ref[idx][2]) pairpot[idx].getVariableReference("qj") = q2e * q[j]; + ecoul = pairpot[idx].evaluate(); ecoul *= factor_coul; } @@ -249,18 +261,22 @@ double PairLeptonCoul::single(int i, int j, int itype, int jtype, double rsq, do const double r = sqrt(rsq); const double q2e = sqrt(force->qqrd2e); - pairpot.getVariableReference("r") = r; - pairforce.getVariableReference("r") = r; + try { + pairpot.getVariableReference("r") = r; + pairforce.getVariableReference("r") = r; + } catch (Lepton::Exception &) { + ; // ignore -> constant potential or force + } try { pairpot.getVariableReference("qi") = q2e * atom->q[i]; pairforce.getVariableReference("qi") = q2e * atom->q[i]; - } catch (std::exception &) { + } catch (Lepton::Exception &) { /* ignore */ } try { pairpot.getVariableReference("qj") = q2e * atom->q[j]; pairforce.getVariableReference("qj") = q2e * atom->q[j]; - } catch (std::exception &) { + } catch (Lepton::Exception &) { /* ignore */ } diff --git a/src/LEPTON/pair_lepton_sphere.cpp b/src/LEPTON/pair_lepton_sphere.cpp index 29514aed38..63b082774f 100644 --- a/src/LEPTON/pair_lepton_sphere.cpp +++ b/src/LEPTON/pair_lepton_sphere.cpp @@ -21,14 +21,15 @@ #include "comm.h" #include "error.h" #include "force.h" -#include "memory.h" #include "neigh_list.h" #include "neighbor.h" -#include "update.h" #include "Lepton.h" #include "lepton_utils.h" + +#include #include +#include using namespace LAMMPS_NS; @@ -77,25 +78,30 @@ template void PairLeptonSphere::eval() std::vector pairforce; std::vector pairpot; - std::vector> have_rad; + std::vector> has_ref; try { for (const auto &expr : expressions) { auto parsed = Lepton::Parser::parse(LeptonUtils::substitute(expr, lmp), functions); pairforce.emplace_back(parsed.differentiate("r").createCompiledExpression()); + has_ref.push_back({true, true, true}); + try { + pairforce.back().getVariableReference("r"); + } catch (Lepton::Exception &) { + has_ref.back()[0] = false; + } if (EFLAG) pairpot.emplace_back(parsed.createCompiledExpression()); - pairforce.back().getVariableReference("r"); - have_rad.emplace_back(true, true); - // check if there are references to charges + // check if there are references to radii + try { pairforce.back().getVariableReference("radi"); - } catch (std::exception &) { - have_rad.back().first = false; + } catch (Lepton::Exception &) { + has_ref.back()[1] = false; } try { pairforce.back().getVariableReference("radj"); - } catch (std::exception &) { - have_rad.back().second = false; + } catch (Lepton::Exception &) { + has_ref.back()[2] = false; } } } catch (std::exception &e) { @@ -128,9 +134,9 @@ template void PairLeptonSphere::eval() if (rsq < cutsq[itype][jtype]) { const double r = sqrt(rsq); const int idx = type2expression[itype][jtype]; - pairforce[idx].getVariableReference("r") = r; - if (have_rad[idx].first) pairforce[idx].getVariableReference("radi") = radius[i]; - if (have_rad[idx].second) pairforce[idx].getVariableReference("radj") = radius[j]; + if (has_ref[idx][0]) pairforce[idx].getVariableReference("r") = r; + if (has_ref[idx][1]) pairforce[idx].getVariableReference("radi") = radius[i]; + if (has_ref[idx][2]) pairforce[idx].getVariableReference("radj") = radius[j]; const double fpair = -pairforce[idx].evaluate() / r * factor_lj; fxtmp += delx * fpair; @@ -144,9 +150,14 @@ template void PairLeptonSphere::eval() double evdwl = 0.0; if (EFLAG) { - pairpot[idx].getVariableReference("r") = r; - if (have_rad[idx].first) pairpot[idx].getVariableReference("radi") = radius[i]; - if (have_rad[idx].second) pairpot[idx].getVariableReference("radj") = radius[j]; + try { + pairpot[idx].getVariableReference("r") = r; + } catch (Lepton::Exception &) { + ; // ignore -> constant potential + } + if (has_ref[idx][1]) pairpot[idx].getVariableReference("radi") = radius[i]; + if (has_ref[idx][2]) pairpot[idx].getVariableReference("radj") = radius[j]; + evdwl = pairpot[idx].evaluate(); evdwl *= factor_lj; } @@ -211,19 +222,23 @@ double PairLeptonSphere::single(int i, int j, int itype, int jtype, double rsq, auto pairforce = parsed.differentiate("r").createCompiledExpression(); const double r = sqrt(rsq); - pairpot.getVariableReference("r") = r; - pairforce.getVariableReference("r") = r; + try { + pairpot.getVariableReference("r") = r; + pairforce.getVariableReference("r") = r; + } catch (Lepton::Exception &) { + ; // ignore -> constant potential or force + } try { pairpot.getVariableReference("radi") = atom->radius[i]; pairforce.getVariableReference("radi") = atom->radius[i]; - } catch (std::exception &) { - /* ignore */ + } catch (Lepton::Exception &) { + ; // ignore } try { pairpot.getVariableReference("radj") = atom->radius[j]; pairforce.getVariableReference("radj") = atom->radius[j]; - } catch (std::exception &) { - /* ignore */ + } catch (Lepton::Exception &) { + ; // ignore } fforce = -pairforce.evaluate() / r * factor_lj; diff --git a/src/MACHDYN/atom_vec_smd.cpp b/src/MACHDYN/atom_vec_smd.cpp index d1bae9ecb7..760dd963eb 100644 --- a/src/MACHDYN/atom_vec_smd.cpp +++ b/src/MACHDYN/atom_vec_smd.cpp @@ -30,8 +30,8 @@ using namespace LAMMPS_NS; -#define NMAT_FULL 9 -#define NMAT_SYMM 6 +static constexpr int NMAT_FULL = 9; +static constexpr int NMAT_SYMM = 6; /* ---------------------------------------------------------------------- */ diff --git a/src/MACHDYN/fix_smd_adjust_dt.cpp b/src/MACHDYN/fix_smd_adjust_dt.cpp index d2728f1042..30006ec7cc 100644 --- a/src/MACHDYN/fix_smd_adjust_dt.cpp +++ b/src/MACHDYN/fix_smd_adjust_dt.cpp @@ -37,7 +37,7 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define BIG 1.0e20 +static constexpr double BIG = 1.0e20; /* ---------------------------------------------------------------------- */ diff --git a/src/MACHDYN/fix_smd_tlsph_reference_configuration.cpp b/src/MACHDYN/fix_smd_tlsph_reference_configuration.cpp index b236952e60..72ad76eccd 100644 --- a/src/MACHDYN/fix_smd_tlsph_reference_configuration.cpp +++ b/src/MACHDYN/fix_smd_tlsph_reference_configuration.cpp @@ -48,7 +48,7 @@ using namespace FixConst; using namespace SMD_Kernels; using namespace SMD_Math; -#define DELTA 16384 +static constexpr int DELTA = 16384; #define INSERT_PREDEFINED_CRACKS false diff --git a/src/MACHDYN/fix_smd_wall_surface.cpp b/src/MACHDYN/fix_smd_wall_surface.cpp index facc03d471..25e76e1dab 100644 --- a/src/MACHDYN/fix_smd_wall_surface.cpp +++ b/src/MACHDYN/fix_smd_wall_surface.cpp @@ -26,14 +26,15 @@ #include "text_file_reader.h" #include +#include #include using namespace LAMMPS_NS; using namespace FixConst; using namespace Eigen; using namespace std; -#define DELTA 16384 -#define EPSILON 1.0e-6 + +static constexpr double EPSILON = 1.0e-6; /* ---------------------------------------------------------------------- */ diff --git a/src/MACHDYN/pair_smd_hertz.cpp b/src/MACHDYN/pair_smd_hertz.cpp index bf526f5e4e..99e8ae6426 100644 --- a/src/MACHDYN/pair_smd_hertz.cpp +++ b/src/MACHDYN/pair_smd_hertz.cpp @@ -43,8 +43,6 @@ using namespace LAMMPS_NS; -#define SQRT2 1.414213562e0 - /* ---------------------------------------------------------------------- */ PairHertz::PairHertz(LAMMPS *lmp) : diff --git a/src/MACHDYN/pair_smd_tlsph.cpp b/src/MACHDYN/pair_smd_tlsph.cpp index 845fed3352..a1c8fbf1ea 100644 --- a/src/MACHDYN/pair_smd_tlsph.cpp +++ b/src/MACHDYN/pair_smd_tlsph.cpp @@ -51,11 +51,9 @@ using namespace Eigen; using namespace LAMMPS_NS; using namespace SMD_Math; -#define JAUMANN false -#define DETF_MIN 0.2 // maximum compression deformation allow -#define DETF_MAX 2.0 // maximum tension deformation allowed -#define TLSPH_DEBUG 0 -#define PLASTIC_STRAIN_AVERAGE_WINDOW 100.0 +static constexpr bool JAUMANN = false; +static constexpr double DETF_MIN = 0.2; // maximum compression deformation allow +static constexpr double DETF_MAX = 2.0; // maximum tension deformation allowed /* ---------------------------------------------------------------------- */ diff --git a/src/MACHDYN/pair_smd_triangulated_surface.cpp b/src/MACHDYN/pair_smd_triangulated_surface.cpp index e1ebc2562d..dc777cc66f 100644 --- a/src/MACHDYN/pair_smd_triangulated_surface.cpp +++ b/src/MACHDYN/pair_smd_triangulated_surface.cpp @@ -46,8 +46,6 @@ using namespace std; using namespace LAMMPS_NS; using namespace Eigen; -#define SQRT2 1.414213562e0 - /* ---------------------------------------------------------------------- */ PairTriSurf::PairTriSurf(LAMMPS *lmp) : diff --git a/src/MACHDYN/pair_smd_ulsph.cpp b/src/MACHDYN/pair_smd_ulsph.cpp index a06be48283..20897a7852 100644 --- a/src/MACHDYN/pair_smd_ulsph.cpp +++ b/src/MACHDYN/pair_smd_ulsph.cpp @@ -48,7 +48,6 @@ using namespace SMD_Math; #include using namespace Eigen; -#define ARTIFICIAL_STRESS false #define FORMAT1 "%60s : %g\n" #define FORMAT2 "\n.............................. %s \n" diff --git a/src/MAKE/MACHINES/Makefile.frontier_kokkos b/src/MAKE/MACHINES/Makefile.frontier_kokkos index 86cddd12b7..b58a3d871c 100644 --- a/src/MAKE/MACHINES/Makefile.frontier_kokkos +++ b/src/MAKE/MACHINES/Makefile.frontier_kokkos @@ -55,7 +55,7 @@ MPI_LIB = -L${MPICH_DIR}/lib -lmpi -L${CRAY_MPICH_ROOTDIR}/gtl/lib -lmpi_gtl_hsa MY_HIP_EXE = $(shell which hipcc) MY_HIP_PATH = $(dir ${MY_HIP_EXE}) -FFT_INC = -DFFT_HIPFFT +FFT_INC = -DFFT_KOKKOS_HIPFFT FFT_PATH = FFT_LIB = -L${MY_HIP_PATH}../lib -lhipfft diff --git a/src/MAKE/MACHINES/Makefile.perlmutter_kokkos b/src/MAKE/MACHINES/Makefile.perlmutter_kokkos index 43162b88dd..cdf2daa471 100644 --- a/src/MAKE/MACHINES/Makefile.perlmutter_kokkos +++ b/src/MAKE/MACHINES/Makefile.perlmutter_kokkos @@ -54,7 +54,7 @@ MPI_LIB = -L${MPICH_DIR}/lib -lmpi -L${CRAY_MPICH_ROOTDIR}/gtl/lib -lmpi_gtl_cud # PATH = path for FFT library # LIB = name of FFT library -FFT_INC = -DFFT_CUFFT +FFT_INC = -DFFT_KOKKOS_CUFFT FFT_PATH = FFT_LIB = ${CRAY_CUDATOOLKIT_POST_LINK_OPTS} -lcufft diff --git a/src/MAKE/MACHINES/Makefile.summit_kokkos b/src/MAKE/MACHINES/Makefile.summit_kokkos index 557ebd22b2..d554e09a5a 100644 --- a/src/MAKE/MACHINES/Makefile.summit_kokkos +++ b/src/MAKE/MACHINES/Makefile.summit_kokkos @@ -57,7 +57,7 @@ MPI_LIB = -L${MY_MPI_PATH}../lib -lmpi_ibm # PATH = path for FFT library # LIB = name of FFT library -FFT_INC = -DFFT_CUFFT +FFT_INC = -DFFT_KOKKOS_CUFFT FFT_PATH = FFT_LIB = -lcufft diff --git a/src/MAKE/OPTIONS/Makefile.kokkos_cuda_mpi b/src/MAKE/OPTIONS/Makefile.kokkos_cuda_mpi index e78be1acdc..88c07fc2c5 100644 --- a/src/MAKE/OPTIONS/Makefile.kokkos_cuda_mpi +++ b/src/MAKE/OPTIONS/Makefile.kokkos_cuda_mpi @@ -57,7 +57,7 @@ MPI_LIB = # PATH = path for FFT library # LIB = name of FFT library -FFT_INC = -DFFT_CUFFT +FFT_INC = -DFFT_KOKKOS_CUFFT FFT_PATH = FFT_LIB = -lcufft diff --git a/src/MANYBODY/pair_airebo.cpp b/src/MANYBODY/pair_airebo.cpp index 129b9d2218..41c8faf752 100644 --- a/src/MANYBODY/pair_airebo.cpp +++ b/src/MANYBODY/pair_airebo.cpp @@ -41,8 +41,10 @@ using namespace LAMMPS_NS; using namespace MathSpecial; -#define TOL 1.0e-9 -#define PGDELTA 1 +static constexpr double TOL = 1.0e-9; +static constexpr int PGDELTA = 1; + +static const char *style[3] = {"airebo", "rebo", "airebo/morse"}; /* ---------------------------------------------------------------------- */ @@ -150,7 +152,7 @@ void PairAIREBO::allocate() void PairAIREBO::settings(int narg, char **arg) { if (narg != 1 && narg != 3 && narg != 4) - error->all(FLERR,"Illegal pair_style command"); + error->all(FLERR,"Illegal pair_style {} command", style[variant]); cutlj = utils::numeric(FLERR,arg[0],false,lmp); @@ -175,12 +177,7 @@ void PairAIREBO::coeff(int narg, char **arg) if (!allocated) allocate(); if (narg != 3 + atom->ntypes) - error->all(FLERR,"Incorrect args for pair coefficients"); - - // ensure I,J args are * * - - if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) - error->all(FLERR,"Incorrect args for pair coefficients"); + error->all(FLERR,"Incorrect number of args for pair coefficient."); // read args that map atom types to C and H // map[i] = which element (0,1) the Ith atom type is, -1 if "NULL" @@ -193,7 +190,7 @@ void PairAIREBO::coeff(int narg, char **arg) map[i-2] = 0; } else if (strcmp(arg[i],"H") == 0) { map[i-2] = 1; - } else error->all(FLERR,"Incorrect args for pair coefficients"); + } else error->all(FLERR,"Element {} not supported by pair style {}", arg[i], style[variant]); } // read potential file and initialize fitting splines @@ -228,13 +225,13 @@ void PairAIREBO::coeff(int narg, char **arg) void PairAIREBO::init_style() { if (atom->tag_enable == 0) - error->all(FLERR,"Pair style AIREBO requires atom IDs"); + error->all(FLERR,"Pair style {} requires atom IDs", style[variant]); if (force->newton_pair == 0) - error->all(FLERR,"Pair style AIREBO requires newton pair on"); + error->all(FLERR,"Pair style {} requires newton pair on", style[variant]); // need a full neighbor list, including neighbors of ghosts - neighbor->add_request(this,NeighConst::REQ_FULL|NeighConst::REQ_GHOST); + neighbor->add_request(this, NeighConst::REQ_FULL | NeighConst::REQ_GHOST); // local REBO neighbor list // create pages if first time or if neighbor pgsize/oneatom has changed diff --git a/src/MANYBODY/pair_comb.cpp b/src/MANYBODY/pair_comb.cpp index 126544ddc5..609e4efcf8 100644 --- a/src/MANYBODY/pair_comb.cpp +++ b/src/MANYBODY/pair_comb.cpp @@ -43,9 +43,8 @@ using namespace MathConst; using namespace MathExtra; using namespace MathSpecial; -#define DELTA 4 -#define PGDELTA 1 -#define MAXNEIGH 24 +static constexpr int DELTA = 4; +static constexpr int MAXNEIGH = 24; /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_comb3.cpp b/src/MANYBODY/pair_comb3.cpp index a6a6ed37fd..b4228dbb4f 100644 --- a/src/MANYBODY/pair_comb3.cpp +++ b/src/MANYBODY/pair_comb3.cpp @@ -43,9 +43,8 @@ using namespace MathConst; using namespace MathExtra; using namespace MathSpecial; -#define DELTA 4 -#define PGDELTA 1 -#define MAXNEIGH 24 +static constexpr int DELTA = 4; +static constexpr int MAXNEIGH = 24; /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_eam.cpp b/src/MANYBODY/pair_eam.cpp index a3d4257cc2..669a5cadbb 100644 --- a/src/MANYBODY/pair_eam.cpp +++ b/src/MANYBODY/pair_eam.cpp @@ -33,8 +33,6 @@ using namespace LAMMPS_NS; -#define MAXLINE 1024 - /* ---------------------------------------------------------------------- */ PairEAM::PairEAM(LAMMPS *lmp) : Pair(lmp) diff --git a/src/MANYBODY/pair_eam_cd.cpp b/src/MANYBODY/pair_eam_cd.cpp index 1746435fad..798292eb1d 100644 --- a/src/MANYBODY/pair_eam_cd.cpp +++ b/src/MANYBODY/pair_eam_cd.cpp @@ -32,7 +32,7 @@ using namespace LAMMPS_NS; -#define MAXLINE 1024 // This sets the maximum line length in EAM input files. +static constexpr int MAXLINE = 1024; // This sets the maximum line length in EAM input files. PairEAMCD::PairEAMCD(LAMMPS *lmp, int _cdeamVersion) : PairEAM(lmp), PairEAMAlloy(lmp), cdeamVersion(_cdeamVersion) diff --git a/src/MANYBODY/pair_edip.cpp b/src/MANYBODY/pair_edip.cpp index 974dc9ab84..1eac053ebd 100644 --- a/src/MANYBODY/pair_edip.cpp +++ b/src/MANYBODY/pair_edip.cpp @@ -39,11 +39,9 @@ using namespace LAMMPS_NS; -#define MAXLINE 1024 -#define DELTA 4 - -#define GRIDDENSITY 8000 -#define GRIDSTART 0.1 +static constexpr int DELTA = 4; +static constexpr int GRIDDENSITY = 8000; +static constexpr double GRIDSTART = 0.1; // max number of interaction per atom for f(Z) environment potential diff --git a/src/MANYBODY/pair_edip_multi.cpp b/src/MANYBODY/pair_edip_multi.cpp index 00be0ad829..32e21861f3 100644 --- a/src/MANYBODY/pair_edip_multi.cpp +++ b/src/MANYBODY/pair_edip_multi.cpp @@ -38,8 +38,7 @@ using namespace LAMMPS_NS; using namespace MathExtra; -#define MAXLINE 1024 -#define DELTA 4 +static constexpr int DELTA = 4; static const char cite_pair_edip[] = "pair edip/multi: doi:10.1103/PhysRevB.86.144118, doi:10.1088/0953-8984/22/3/035802\n\n" diff --git a/src/MANYBODY/pair_extep.cpp b/src/MANYBODY/pair_extep.cpp index 755b4d0132..7ed65f0f71 100644 --- a/src/MANYBODY/pair_extep.cpp +++ b/src/MANYBODY/pair_extep.cpp @@ -37,9 +37,8 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathExtra; -#define MAXLINE 1024 -#define DELTA 4 -#define PGDELTA 1 +static constexpr int DELTA = 4; +static constexpr int PGDELTA = 1; /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_gw.cpp b/src/MANYBODY/pair_gw.cpp index 1fd98b80f0..471896851a 100644 --- a/src/MANYBODY/pair_gw.cpp +++ b/src/MANYBODY/pair_gw.cpp @@ -37,7 +37,7 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathExtra; -#define DELTA 4 +static constexpr int DELTA = 4; /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_gw_zbl.cpp b/src/MANYBODY/pair_gw_zbl.cpp index 5e61778c68..a08cf0907f 100644 --- a/src/MANYBODY/pair_gw_zbl.cpp +++ b/src/MANYBODY/pair_gw_zbl.cpp @@ -32,8 +32,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define MAXLINE 1024 -#define DELTA 4 +static constexpr int DELTA = 4; /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_lcbop.cpp b/src/MANYBODY/pair_lcbop.cpp index ed085c4b98..1e19363212 100644 --- a/src/MANYBODY/pair_lcbop.cpp +++ b/src/MANYBODY/pair_lcbop.cpp @@ -33,9 +33,9 @@ using namespace LAMMPS_NS; -#define MAXLINE 1024 -#define TOL 1.0e-9 -#define PGDELTA 1 +static constexpr int MAXLINE = 1024; +static constexpr double TOL = 1.0e-9; +static constexpr int PGDELTA = 1; /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_local_density.cpp b/src/MANYBODY/pair_local_density.cpp index 71a7e658d2..da405e9118 100644 --- a/src/MANYBODY/pair_local_density.cpp +++ b/src/MANYBODY/pair_local_density.cpp @@ -34,8 +34,6 @@ using namespace LAMMPS_NS; -#define MAXLINE 1024 - static const char cite_pair_local_density[] = "pair_style local/density command: doi:10.1063/1.4958629, doi:10.1021/acs.jpcb.7b12446\n\n" "@Article{Sanyal16,\n" diff --git a/src/MANYBODY/pair_meam_spline.cpp b/src/MANYBODY/pair_meam_spline.cpp index 1c17f434f2..e3d17f6fae 100644 --- a/src/MANYBODY/pair_meam_spline.cpp +++ b/src/MANYBODY/pair_meam_spline.cpp @@ -46,6 +46,7 @@ #include #include +#include using namespace LAMMPS_NS; @@ -440,8 +441,6 @@ void PairMEAMSpline::coeff(int narg, char **arg) } } -#define MAXLINE 1024 - void PairMEAMSpline::read_file(const char* filename) { int nmultichoose2; // = (n+1)*n/2; diff --git a/src/MANYBODY/pair_meam_sw_spline.cpp b/src/MANYBODY/pair_meam_sw_spline.cpp index 3e3e813c5b..a19e1cc0fa 100644 --- a/src/MANYBODY/pair_meam_sw_spline.cpp +++ b/src/MANYBODY/pair_meam_sw_spline.cpp @@ -33,6 +33,7 @@ #include #include +#include using namespace LAMMPS_NS; @@ -384,8 +385,6 @@ void PairMEAMSWSpline::coeff(int narg, char **arg) set coeffs for one or more type pairs ------------------------------------------------------------------------- */ -#define MAXLINE 1024 - void PairMEAMSWSpline::read_file(const char* filename) { if (comm->me == 0) { diff --git a/src/MANYBODY/pair_nb3b_harmonic.cpp b/src/MANYBODY/pair_nb3b_harmonic.cpp index 5bc930c186..51e554694c 100644 --- a/src/MANYBODY/pair_nb3b_harmonic.cpp +++ b/src/MANYBODY/pair_nb3b_harmonic.cpp @@ -34,8 +34,8 @@ using namespace LAMMPS_NS; using MathConst::MY_PI; -#define DELTA 4 -#define SMALL 0.001 +static constexpr int DELTA = 4; +static constexpr double SMALL = 0.001; static const char *substyle[] = {"nb3n/harmonic", "nb3b/screened"}; diff --git a/src/MANYBODY/pair_nb3b_screened.cpp b/src/MANYBODY/pair_nb3b_screened.cpp index d66945d563..9480ae9f15 100644 --- a/src/MANYBODY/pair_nb3b_screened.cpp +++ b/src/MANYBODY/pair_nb3b_screened.cpp @@ -20,7 +20,7 @@ #include -#define SMALL 0.001 +static constexpr double SMALL = 0.001; using namespace LAMMPS_NS; diff --git a/src/MANYBODY/pair_polymorphic.cpp b/src/MANYBODY/pair_polymorphic.cpp index 03ef6cb49f..535fb766bc 100644 --- a/src/MANYBODY/pair_polymorphic.cpp +++ b/src/MANYBODY/pair_polymorphic.cpp @@ -38,10 +38,6 @@ using namespace LAMMPS_NS; using namespace MathExtra; -#define MAXLINE 1024 -#define DELTA 4 - - /* ---------------------------------------------------------------------- */ PairPolymorphic::PairParameters::PairParameters() diff --git a/src/MANYBODY/pair_rebomos.cpp b/src/MANYBODY/pair_rebomos.cpp new file mode 100644 index 0000000000..0941ca0a3a --- /dev/null +++ b/src/MANYBODY/pair_rebomos.cpp @@ -0,0 +1,1123 @@ +// clang-format off +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + LAMMPS Development team: developers@lammps.org + + 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. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + References: + + This code: + Stewart J A and Spearot D E (2013) Atomistic simulations of nanoindentation on the basal plane of crystalline molybdenum disulfide. Modelling Simul. Mater. Sci. Eng. 21. + + Based on: + Liang T, Phillpot S R and Sinnott S B (2009) Parameterization of a reactive many-body potential for Mo2S systems. Phys. Rev. B79 245110. + Liang T, Phillpot S R and Sinnott S B (2012) Erratum: Parameterization of a reactive many-body potential for Mo-S systems. (Phys. Rev. B79 245110 (2009)) Phys. Rev. B85 199903(E). + + LAMMPS file contributing authors: James Stewart, Khanh Dang and Douglas Spearot (University of Arkansas) +------------------------------------------------------------------------- */ + +// clang-format on + +#include "pair_rebomos.h" + +#include "atom.h" +#include "comm.h" +#include "error.h" +#include "force.h" +#include "math_special.h" +#include "memory.h" +#include "my_page.h" +#include "neigh_list.h" +#include "neighbor.h" +#include "potential_file_reader.h" +#include "text_file_reader.h" + +#include +#include + +using namespace LAMMPS_NS; +using MathSpecial::cube; +using MathSpecial::powint; +using MathSpecial::square; + +static constexpr double TOL = 1.0e-9; +static constexpr int PGDELTA = 1; + +/* ---------------------------------------------------------------------- */ + +PairREBOMoS::PairREBOMoS(LAMMPS *lmp) : + Pair(lmp), lj1(nullptr), lj2(nullptr), lj3(nullptr), lj4(nullptr), ipage(nullptr), + REBO_numneigh(nullptr), REBO_firstneigh(nullptr), nM(nullptr), nS(nullptr) +{ + single_enable = 0; + restartinfo = 0; + one_coeff = 1; + ghostneigh = 1; + manybody_flag = 1; + centroidstressflag = CENTROID_NOTAVAIL; + + cut3rebo = 0.0; + maxlocal = 0; + pgsize = oneatom = 0; +} + +// clang-format off + +/* ---------------------------------------------------------------------- + Check if allocated, since class can be destructed when incomplete +------------------------------------------------------------------------- */ + +PairREBOMoS::~PairREBOMoS() +{ + memory->destroy(REBO_numneigh); + memory->sfree(REBO_firstneigh); + delete[] ipage; + memory->destroy(nM); + memory->destroy(nS); + + if (allocated) { + memory->destroy(setflag); + memory->destroy(cutsq); + memory->destroy(cutghost); + + memory->destroy(lj1); + memory->destroy(lj2); + memory->destroy(lj3); + memory->destroy(lj4); + } +} + +/* ---------------------------------------------------------------------- */ + +void PairREBOMoS::compute(int eflag, int vflag) +{ + ev_init(eflag,vflag); + + REBO_neigh(); + FREBO(eflag); + FLJ(eflag); + + if (vflag_fdotr) virial_fdotr_compute(); +} + +/* ---------------------------------------------------------------------- + allocate all arrays +------------------------------------------------------------------------- */ + +void PairREBOMoS::allocate() +{ + allocated = 1; + int n = atom->ntypes; + + memory->create(setflag,n+1,n+1,"pair:setflag"); + for (int i = 1; i <= n; i++) + for (int j = i; j <= n; j++) + setflag[i][j] = 0; + + memory->create(cutsq,n+1,n+1,"pair:cutsq"); + memory->create(cutghost,n+1,n+1,"pair:cutghost"); + + // only sized by M,S = 2 types + + memory->create(lj1,2,2,"pair:lj1"); + memory->create(lj2,2,2,"pair:lj2"); + memory->create(lj3,2,2,"pair:lj3"); + memory->create(lj4,2,2,"pair:lj4"); + + map = new int[n+1]; +} + +/* ---------------------------------------------------------------------- + global settings +------------------------------------------------------------------------- */ + +void PairREBOMoS::settings(int narg, char ** /* arg */) +{ + if (narg != 0) error->all(FLERR,"Illegal pair_style command"); +} + +/* ---------------------------------------------------------------------- + set coeffs for one or more type pairs +------------------------------------------------------------------------- */ + +void PairREBOMoS::coeff(int narg, char **arg) +{ + if (!allocated) allocate(); + + if (narg != 3 + atom->ntypes) + error->all(FLERR,"Incorrect args for pair coefficients"); + + // insure I,J args are * * + + if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) + error->all(FLERR,"Incorrect args for pair coefficients"); + + // read args that map atom types to Mo and S + // map[i] = which element (0,1) the Ith atom type is, -1 if NULL + + for (int i = 3; i < narg; i++) { + if (strcmp(arg[i],"NULL") == 0) { + map[i-2] = -1; + continue; + } else if (strcmp(arg[i],"Mo") == 0) { + map[i-2] = 0; + } else if (strcmp(arg[i],"M") == 0) { // backward compatibility + map[i-2] = 0; + } else if (strcmp(arg[i],"S") == 0) { + map[i-2] = 1; + } else error->all(FLERR,"Incorrect args for pair coefficients"); + } + + // read potential file and initialize fitting splines + + read_file(arg[2]); + + // clear setflag since coeff() called once with I,J = * * + + int n = atom->ntypes; + for (int i = 1; i <= n; i++) + for (int j = i; j <= n; j++) + setflag[i][j] = 0; + + // set setflag i,j for type pairs where both are mapped to elements + + int count = 0; + for (int i = 1; i <= n; i++) + for (int j = i; j <= n; j++) + if (map[i] >= 0 && map[j] >= 0) { + setflag[i][j] = 1; + count++; + } + + if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); +} + +/* ---------------------------------------------------------------------- + init specific to this pair style +------------------------------------------------------------------------- */ + +void PairREBOMoS::init_style() +{ + if (atom->tag_enable == 0) + error->all(FLERR,"Pair style REBOMoS requires atom IDs"); + if (force->newton_pair == 0) + error->all(FLERR,"Pair style REBOMoS requires newton pair on"); + + // need a full neighbor list, including neighbors of ghosts + + neighbor->add_request(this,NeighConst::REQ_FULL|NeighConst::REQ_GHOST); + + // local REBO neighbor list + // create pages if first time or if neighbor pgsize/oneatom has changed + + int create = 0; + if (ipage == nullptr) create = 1; + if (pgsize != neighbor->pgsize) create = 1; + if (oneatom != neighbor->oneatom) create = 1; + + if (create) { + delete[] ipage; + pgsize = neighbor->pgsize; + oneatom = neighbor->oneatom; + + int nmypage= comm->nthreads; + ipage = new MyPage[nmypage]; + for (int i = 0; i < nmypage; i++) + ipage[i].init(oneatom,pgsize,PGDELTA); + } +} + +/* ---------------------------------------------------------------------- + init for one type pair i,j and corresponding j,i +------------------------------------------------------------------------- */ + +double PairREBOMoS::init_one(int i, int j) +{ + if (setflag[i][j] == 0) error->all(FLERR,"All pair coeffs are not set"); + + // convert to Mo,S types + + int ii = map[i]; + int jj = map[j]; + + // use Mo-Mo values for these cutoffs since M atoms are biggest + + // cut3rebo = 3 REBO distances + + cut3rebo = 3.0 * rcmax[0][0]; + + // cutghost = REBO cutoff used in REBO_neigh() for neighbors of ghosts + + cutghost[i][j] = rcmax[ii][jj]; + lj1[ii][jj] = 48.0 * epsilon[ii][jj] * powint(sigma[ii][jj],12); + lj2[ii][jj] = 24.0 * epsilon[ii][jj] * powint(sigma[ii][jj],6); + lj3[ii][jj] = 4.0 * epsilon[ii][jj] * powint(sigma[ii][jj],12); + lj4[ii][jj] = 4.0 * epsilon[ii][jj] * powint(sigma[ii][jj],6); + + cutghost[j][i] = cutghost[i][j]; + lj1[jj][ii] = lj1[ii][jj]; + lj2[jj][ii] = lj2[ii][jj]; + lj3[jj][ii] = lj3[ii][jj]; + lj4[jj][ii] = lj4[ii][jj]; + + return cut3rebo; +} + +/* ---------------------------------------------------------------------- + create REBO neighbor list from main neighbor list + REBO neighbor list stores neighbors of ghost atoms +------------------------------------------------------------------------- */ + +void PairREBOMoS::REBO_neigh() +{ + int i,j,ii,jj,n,allnum,jnum,itype,jtype; + double xtmp,ytmp,ztmp,delx,dely,delz,rsq,dS; + int *ilist,*jlist,*numneigh,**firstneigh; + int *neighptr; + + double **x = atom->x; + int *type = atom->type; + + if (atom->nmax > maxlocal) { + maxlocal = atom->nmax; + memory->destroy(REBO_numneigh); + memory->sfree(REBO_firstneigh); + memory->destroy(nM); + memory->destroy(nS); + memory->create(REBO_numneigh,maxlocal,"REBOMoS:numneigh"); + REBO_firstneigh = (int **) memory->smalloc(maxlocal*sizeof(int *), + "REBOMoS:firstneigh"); + memory->create(nM,maxlocal,"REBOMoS:nM"); + memory->create(nS,maxlocal,"REBOMoS:nS"); + } + + allnum = list->inum + list->gnum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + + // store all REBO neighs of owned and ghost atoms + // scan full neighbor list of I + + ipage->reset(); + + for (ii = 0; ii < allnum; ii++) { + i = ilist[ii]; + + n = 0; + neighptr = ipage->vget(); + + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + itype = map[type[i]]; + nM[i] = nS[i] = 0.0; + jlist = firstneigh[i]; + jnum = numneigh[i]; + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + j &= NEIGHMASK; + jtype = map[type[j]]; + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + rsq = delx*delx + dely*dely + delz*delz; + + if (rsq < rcmaxsq[itype][jtype]) { + neighptr[n++] = j; + if (jtype == 0) + nM[i] += Sp(sqrt(rsq),rcmin[itype][jtype],rcmax[itype][jtype],dS); + else + nS[i] += Sp(sqrt(rsq),rcmin[itype][jtype],rcmax[itype][jtype],dS); + } + } + + REBO_firstneigh[i] = neighptr; + REBO_numneigh[i] = n; + ipage->vgot(n); + if (ipage->status()) + error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + } +} + +/* ---------------------------------------------------------------------- + REBO forces and energy +------------------------------------------------------------------------- */ + +void PairREBOMoS::FREBO(int eflag) +{ + int i,j,k,ii,inum,itype,jtype; + tagint itag, jtag; + double delx,dely,delz,evdwl,fpair,xtmp,ytmp,ztmp; + double rsq,rij,wij; + double Qij,Aij,alphaij,VR,pre,dVRdi,VA,bij,dVAdi,dVA; + double dwij,del[3]; + int *ilist,*REBO_neighs; + + evdwl = 0.0; + + double **x = atom->x; + double **f = atom->f; + int *type = atom->type; + tagint *tag = atom->tag; + int nlocal = atom->nlocal; + + inum = list->inum; + ilist = list->ilist; + + // two-body interactions from REBO neighbor list, skip half of them + + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + itag = tag[i]; + itype = map[type[i]]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + REBO_neighs = REBO_firstneigh[i]; + + for (k = 0; k < REBO_numneigh[i]; k++) { + j = REBO_neighs[k]; + jtag = tag[j]; + + if (itag > jtag) { + if ((itag+jtag) % 2 == 0) continue; + } else if (itag < jtag) { + if ((itag+jtag) % 2 == 1) continue; + } else { + if (x[j][2] < ztmp) continue; + if (x[j][2] == ztmp && x[j][1] < ytmp) continue; + if (x[j][2] == ztmp && x[j][1] == ytmp && x[j][0] < xtmp) continue; + } + + jtype = map[type[j]]; + + delx = x[i][0] - x[j][0]; + dely = x[i][1] - x[j][1]; + delz = x[i][2] - x[j][2]; + rsq = delx*delx + dely*dely + delz*delz; + rij = sqrt(rsq); + wij = Sp(rij,rcmin[itype][jtype],rcmax[itype][jtype],dwij); + if (wij <= TOL) continue; + + Qij = Q[itype][jtype]; + Aij = A[itype][jtype]; + alphaij = alpha[itype][jtype]; + + VR = wij*(1.0+(Qij/rij)) * Aij*exp(-alphaij*rij); + pre = wij*Aij * exp(-alphaij*rij); + dVRdi = pre * ((-alphaij)-(Qij/rsq)-(Qij*alphaij/rij)); + dVRdi += VR/wij * dwij; + + VA = dVA = 0.0; + VA = -wij * BIJc[itype][jtype] * exp(-Beta[itype][jtype]*rij); + + dVA = -Beta[itype][jtype] * VA; + dVA += VA/wij * dwij; + + del[0] = delx; + del[1] = dely; + del[2] = delz; + bij = bondorder(i,j,del,rij,VA,f); + dVAdi = bij*dVA; + + fpair = -(dVRdi+dVAdi) / rij; + f[i][0] += delx*fpair; + f[i][1] += dely*fpair; + f[i][2] += delz*fpair; + f[j][0] -= delx*fpair; + f[j][1] -= dely*fpair; + f[j][2] -= delz*fpair; + + if (eflag) evdwl = VR + bij*VA; + if (evflag) ev_tally(i,j,nlocal,/*newton_pair*/1,evdwl,0.0,fpair,delx,dely,delz); + } + } +} + +/* ---------------------------------------------------------------------- + compute LJ forces and energy +------------------------------------------------------------------------- */ + +void PairREBOMoS::FLJ(int eflag) +{ + int i,j,ii,jj,inum,jnum,itype,jtype; + tagint itag,jtag; + double evdwl,fpair,xtmp,ytmp,ztmp; + double rij,delij[3],rijsq; + double VLJ,dVLJ; + double vdw,dvdw; + double r2inv,r6inv; + int *ilist,*jlist,*numneigh,**firstneigh; + double c2,c3,dr,drp,r6; + + // I-J interaction from full neighbor list + // skip 1/2 of interactions since only consider each pair once + + evdwl = 0.0; + + double **x = atom->x; + double **f = atom->f; + tagint *tag = atom->tag; + int *type = atom->type; + int nlocal = atom->nlocal; + + inum = list->inum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + + // loop over neighbors of my atoms + + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + itag = tag[i]; + itype = map[type[i]]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + jlist = firstneigh[i]; + jnum = numneigh[i]; + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + j &= NEIGHMASK; + jtag = tag[j]; + + if (itag > jtag) { + if ((itag+jtag) % 2 == 0) continue; + } else if (itag < jtag) { + if ((itag+jtag) % 2 == 1) continue; + } else { + if (x[j][2] < ztmp) continue; + if (x[j][2] == ztmp && x[j][1] < ytmp) continue; + if (x[j][2] == ztmp && x[j][1] == ytmp && x[j][0] < xtmp) continue; + } + jtype = map[type[j]]; + + delij[0] = xtmp - x[j][0]; + delij[1] = ytmp - x[j][1]; + delij[2] = ztmp - x[j][2]; + rijsq = delij[0]*delij[0] + delij[1]*delij[1] + delij[2]*delij[2]; + rij = sqrt(rijsq); + + // compute LJ forces and energy + + // Outside Rmax + if (rij > rcLJmax[itype][jtype] || rij < rcLJmin[itype][jtype]){ + VLJ = 0; + dVLJ = 0; + } + + // Inside Rmax and above 0.95*sigma + else if (rij <= rcLJmax[itype][jtype] && rij >= 0.95*sigma[itype][jtype]){ + r2inv = 1.0/rijsq; + r6inv = r2inv*r2inv*r2inv; + VLJ = r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype]); + dVLJ = -r6inv*(lj1[itype][jtype]*r6inv - lj2[itype][jtype])/rij; + } + + // Below 0.95*sigma + else if (rij < 0.95*sigma[itype][jtype] && rij >= rcLJmin[itype][jtype]){ + dr = 0.95*sigma[itype][jtype] - rcLJmin[itype][jtype]; + r6 = powint((sigma[itype][jtype]/(0.95*sigma[itype][jtype])),6); + vdw = 4*epsilon[itype][jtype]*r6*(r6 - 1.0); + dvdw = (-4*epsilon[itype][jtype]/(0.95*sigma[itype][jtype]))*r6*(12.0*r6 - 6.0); + c2 = ((3.0/dr)*vdw - dvdw)/dr; + c3 = (vdw/(dr*dr) - c2)/dr; + + drp = rij - rcLJmin[itype][jtype]; + VLJ = drp*drp*(drp*c3 + c2); + dVLJ = drp*(3.0*drp*c3 + 2.0*c2); + } + + fpair = -dVLJ/rij; + f[i][0] += delij[0]*fpair; + f[i][1] += delij[1]*fpair; + f[i][2] += delij[2]*fpair; + f[j][0] -= delij[0]*fpair; + f[j][1] -= delij[1]*fpair; + f[j][2] -= delij[2]*fpair; + + if (eflag) evdwl = VLJ; + if (evflag) ev_tally(i,j,nlocal,/*newton_pair*/1,evdwl,0.0,fpair,delij[0],delij[1],delij[2]); + + } + } +} + +/* ---------------------------------------------------------------------- + Bij function + + The bond order term modified the attractive portion of the REBO + potential based on the number of atoms around a specific pair + and the bond angle between sets of three atoms. + + The functions G(cos(theta)) and P(N) are evaluated and their + derivatives are also computed for use in the force calculation. +------------------------------------------------------------------------- */ + +double PairREBOMoS::bondorder(int i, int j, double rij[3], double rijmag, double VA, double **f) +{ + int atomi,atomj,atomk,atoml; + int k,l; + int itype, jtype, ktype, ltype; + double rik[3], rjl[3], rji[3], rki[3],rlj[3], dwjl, bij; + double NijM,NijS,NjiM,NjiS,wik,dwik,wjl; + double rikmag,rjlmag,cosjik,cosijl,g,tmp2; + double Etmp,pij,tmp,dwij,dS; + double dgdc,pji; + double dcosjikdri[3],dcosijldri[3],dcosjikdrk[3]; + double dp; + double dcosjikdrj[3],dcosijldrj[3],dcosijldrl[3]; + double fi[3],fj[3],fk[3],fl[3]; + double PijS, PjiS; + int *REBO_neighs; + + double **x = atom->x; + int *type = atom->type; + + atomi = i; + atomj = j; + itype = map[type[i]]; + jtype = map[type[j]]; + Sp(rijmag,rcmin[itype][jtype],rcmax[itype][jtype],dwij); + NijM = nM[i]; + NijS = nS[i]; + NjiM = nM[j]; + NjiS = nS[j]; + bij = 0.0; + tmp = 0.0; + tmp2 = 0.0; + dgdc = 0.0; + Etmp = 0.0; + + REBO_neighs = REBO_firstneigh[i]; + for (k = 0; k < REBO_numneigh[i]; k++) { + atomk = REBO_neighs[k]; + if (atomk != atomj) { + ktype = map[type[atomk]]; + rik[0] = x[atomi][0]-x[atomk][0]; + rik[1] = x[atomi][1]-x[atomk][1]; + rik[2] = x[atomi][2]-x[atomk][2]; + rikmag = sqrt((rik[0]*rik[0])+(rik[1]*rik[1])+(rik[2]*rik[2])); + wik = Sp(rikmag,rcmin[itype][ktype],rcmax[itype][ktype],dS); + cosjik = ((rij[0]*rik[0])+(rij[1]*rik[1])+(rij[2]*rik[2])) / (rijmag*rikmag); + cosjik = MIN(cosjik,1.0); + cosjik = MAX(cosjik,-1.0); + + // evaluate g and derivative dg + + g = gSpline(cosjik,itype,dgdc); + Etmp = Etmp+(wik*g); + } + } + + dp = 0.0; + PijS = PijSpline(NijM,NijS,itype,dp); + pij = 1.0/sqrt(1.0+Etmp+PijS); + tmp = -0.5*cube(pij); + + // derivative calculations + + REBO_neighs = REBO_firstneigh[i]; + for (k = 0; k < REBO_numneigh[i]; k++) { + atomk = REBO_neighs[k]; + if (atomk != atomj) { + ktype = map[type[atomk]]; + rik[0] = x[atomi][0]-x[atomk][0]; + rik[1] = x[atomi][1]-x[atomk][1]; + rik[2] = x[atomi][2]-x[atomk][2]; + rikmag = sqrt((rik[0]*rik[0])+(rik[1]*rik[1])+(rik[2]*rik[2])); + wik = Sp(rikmag,rcmin[itype][ktype],rcmax[itype][ktype],dwik); + cosjik = (rij[0]*rik[0] + rij[1]*rik[1] + rij[2]*rik[2]) / (rijmag*rikmag); + cosjik = MIN(cosjik,1.0); + cosjik = MAX(cosjik,-1.0); + + dcosjikdri[0] = ((rij[0]+rik[0])/(rijmag*rikmag)) - + (cosjik*((rij[0]/(rijmag*rijmag))+(rik[0]/(rikmag*rikmag)))); + dcosjikdri[1] = ((rij[1]+rik[1])/(rijmag*rikmag)) - + (cosjik*((rij[1]/(rijmag*rijmag))+(rik[1]/(rikmag*rikmag)))); + dcosjikdri[2] = ((rij[2]+rik[2])/(rijmag*rikmag)) - + (cosjik*((rij[2]/(rijmag*rijmag))+(rik[2]/(rikmag*rikmag)))); + dcosjikdrk[0] = (-rij[0]/(rijmag*rikmag)) + + (cosjik*(rik[0]/(rikmag*rikmag))); + dcosjikdrk[1] = (-rij[1]/(rijmag*rikmag)) + + (cosjik*(rik[1]/(rikmag*rikmag))); + dcosjikdrk[2] = (-rij[2]/(rijmag*rikmag)) + + (cosjik*(rik[2]/(rikmag*rikmag))); + dcosjikdrj[0] = (-rik[0]/(rijmag*rikmag)) + + (cosjik*(rij[0]/(rijmag*rijmag))); + dcosjikdrj[1] = (-rik[1]/(rijmag*rikmag)) + + (cosjik*(rij[1]/(rijmag*rijmag))); + dcosjikdrj[2] = (-rik[2]/(rijmag*rikmag)) + + (cosjik*(rij[2]/(rijmag*rijmag))); + + g = gSpline(cosjik,itype,dgdc); + tmp2 = VA*0.5*(tmp*wik*dgdc); + fj[0] = -tmp2*dcosjikdrj[0]; + fj[1] = -tmp2*dcosjikdrj[1]; + fj[2] = -tmp2*dcosjikdrj[2]; + fi[0] = -tmp2*dcosjikdri[0]; + fi[1] = -tmp2*dcosjikdri[1]; + fi[2] = -tmp2*dcosjikdri[2]; + fk[0] = -tmp2*dcosjikdrk[0]; + fk[1] = -tmp2*dcosjikdrk[1]; + fk[2] = -tmp2*dcosjikdrk[2]; + + // coordination forces + + // dwik forces (from partial derivative) + + tmp2 = VA*0.5*(tmp*dwik*g)/rikmag; + fi[0] -= tmp2*rik[0]; + fi[1] -= tmp2*rik[1]; + fi[2] -= tmp2*rik[2]; + fk[0] += tmp2*rik[0]; + fk[1] += tmp2*rik[1]; + fk[2] += tmp2*rik[2]; + + // PIJ forces (from coordination P(N) term) + + tmp2 = VA*0.5*(tmp*dp*dwik)/rikmag; + fi[0] -= tmp2*rik[0]; + fi[1] -= tmp2*rik[1]; + fi[2] -= tmp2*rik[2]; + fk[0] += tmp2*rik[0]; + fk[1] += tmp2*rik[1]; + fk[2] += tmp2*rik[2]; + + // dgdN forces are removed + + f[atomi][0] += fi[0]; f[atomi][1] += fi[1]; f[atomi][2] += fi[2]; + f[atomj][0] += fj[0]; f[atomj][1] += fj[1]; f[atomj][2] += fj[2]; + f[atomk][0] += fk[0]; f[atomk][1] += fk[1]; f[atomk][2] += fk[2]; + + if (vflag_either) { + rji[0] = -rij[0]; rji[1] = -rij[1]; rji[2] = -rij[2]; + rki[0] = -rik[0]; rki[1] = -rik[1]; rki[2] = -rik[2]; + v_tally3(atomi,atomj,atomk,fj,fk,rji,rki); + } + } + } + + // PIJ force contribution additional term + tmp2 = -VA*0.5*(tmp*dp*dwij)/rijmag; + + f[atomi][0] += rij[0]*tmp2; + f[atomi][1] += rij[1]*tmp2; + f[atomi][2] += rij[2]*tmp2; + f[atomj][0] -= rij[0]*tmp2; + f[atomj][1] -= rij[1]*tmp2; + f[atomj][2] -= rij[2]*tmp2; + + if (vflag_either) v_tally2(atomi,atomj,tmp2,rij); + + tmp = 0.0; + tmp2 = 0.0; + Etmp = 0.0; + + REBO_neighs = REBO_firstneigh[j]; + for (l = 0; l < REBO_numneigh[j]; l++) { + atoml = REBO_neighs[l]; + if (atoml != atomi) { + ltype = map[type[atoml]]; + rjl[0] = x[atomj][0]-x[atoml][0]; + rjl[1] = x[atomj][1]-x[atoml][1]; + rjl[2] = x[atomj][2]-x[atoml][2]; + rjlmag = sqrt((rjl[0]*rjl[0])+(rjl[1]*rjl[1])+(rjl[2]*rjl[2])); + wjl = Sp(rjlmag,rcmin[jtype][ltype],rcmax[jtype][ltype],dS); + cosijl = -1.0*((rij[0]*rjl[0])+(rij[1]*rjl[1])+(rij[2]*rjl[2])) / (rijmag*rjlmag); + cosijl = MIN(cosijl,1.0); + cosijl = MAX(cosijl,-1.0); + + // evaluate g and derivative dg + + g = gSpline(cosijl,jtype,dgdc); + Etmp = Etmp+(wjl*g); + } + } + + dp = 0.0; + PjiS = PijSpline(NjiM,NjiS,jtype,dp); + pji = 1.0/sqrt(1.0+Etmp+PjiS); + tmp = -0.5*cube(pji); + + REBO_neighs = REBO_firstneigh[j]; + for (l = 0; l < REBO_numneigh[j]; l++) { + atoml = REBO_neighs[l]; + if (atoml != atomi) { + ltype = map[type[atoml]]; + rjl[0] = x[atomj][0]-x[atoml][0]; + rjl[1] = x[atomj][1]-x[atoml][1]; + rjl[2] = x[atomj][2]-x[atoml][2]; + rjlmag = sqrt((rjl[0]*rjl[0])+(rjl[1]*rjl[1])+(rjl[2]*rjl[2])); + wjl = Sp(rjlmag,rcmin[jtype][ltype],rcmax[jtype][ltype],dwjl); + cosijl = (-1.0*((rij[0]*rjl[0])+(rij[1]*rjl[1])+(rij[2]*rjl[2]))) / (rijmag*rjlmag); + cosijl = MIN(cosijl,1.0); + cosijl = MAX(cosijl,-1.0); + + dcosijldri[0] = (-rjl[0]/(rijmag*rjlmag)) - (cosijl*rij[0]/(rijmag*rijmag)); + dcosijldri[1] = (-rjl[1]/(rijmag*rjlmag)) - (cosijl*rij[1]/(rijmag*rijmag)); + dcosijldri[2] = (-rjl[2]/(rijmag*rjlmag)) - (cosijl*rij[2]/(rijmag*rijmag)); + dcosijldrj[0] = ((-rij[0]+rjl[0])/(rijmag*rjlmag)) + + (cosijl*((rij[0]/square(rijmag))-(rjl[0]/(rjlmag*rjlmag)))); + dcosijldrj[1] = ((-rij[1]+rjl[1])/(rijmag*rjlmag)) + + (cosijl*((rij[1]/square(rijmag))-(rjl[1]/(rjlmag*rjlmag)))); + dcosijldrj[2] = ((-rij[2]+rjl[2])/(rijmag*rjlmag)) + + (cosijl*((rij[2]/square(rijmag))-(rjl[2]/(rjlmag*rjlmag)))); + dcosijldrl[0] = (rij[0]/(rijmag*rjlmag))+(cosijl*rjl[0]/(rjlmag*rjlmag)); + dcosijldrl[1] = (rij[1]/(rijmag*rjlmag))+(cosijl*rjl[1]/(rjlmag*rjlmag)); + dcosijldrl[2] = (rij[2]/(rijmag*rjlmag))+(cosijl*rjl[2]/(rjlmag*rjlmag)); + + // evaluate g and derivatives dg + + g = gSpline(cosijl,jtype,dgdc); + tmp2 = VA*0.5*(tmp*wjl*dgdc); + fi[0] = -tmp2*dcosijldri[0]; + fi[1] = -tmp2*dcosijldri[1]; + fi[2] = -tmp2*dcosijldri[2]; + fj[0] = -tmp2*dcosijldrj[0]; + fj[1] = -tmp2*dcosijldrj[1]; + fj[2] = -tmp2*dcosijldrj[2]; + fl[0] = -tmp2*dcosijldrl[0]; + fl[1] = -tmp2*dcosijldrl[1]; + fl[2] = -tmp2*dcosijldrl[2]; + + // coordination forces + + // dwik forces (from partial derivative) + + tmp2 = VA*0.5*(tmp*dwjl*g)/rjlmag; + fj[0] -= tmp2*rjl[0]; + fj[1] -= tmp2*rjl[1]; + fj[2] -= tmp2*rjl[2]; + fl[0] += tmp2*rjl[0]; + fl[1] += tmp2*rjl[1]; + fl[2] += tmp2*rjl[2]; + + // PIJ forces (coordination) + + tmp2 = VA*0.5*(tmp*dp*dwjl)/rjlmag; + fj[0] -= tmp2*rjl[0]; + fj[1] -= tmp2*rjl[1]; + fj[2] -= tmp2*rjl[2]; + fl[0] += tmp2*rjl[0]; + fl[1] += tmp2*rjl[1]; + fl[2] += tmp2*rjl[2]; + + // dgdN forces are removed + + f[atomi][0] += fi[0]; f[atomi][1] += fi[1]; f[atomi][2] += fi[2]; + f[atomj][0] += fj[0]; f[atomj][1] += fj[1]; f[atomj][2] += fj[2]; + f[atoml][0] += fl[0]; f[atoml][1] += fl[1]; f[atoml][2] += fl[2]; + + if (vflag_either) { + rlj[0] = -rjl[0]; rlj[1] = -rjl[1]; rlj[2] = -rjl[2]; + v_tally3(atomi,atomj,atoml,fi,fl,rij,rlj); + } + } + } + + // PIJ force contribution additional term + + tmp2 = -VA*0.5*(tmp*dp*dwij)/rijmag; + f[atomi][0] += rij[0]*tmp2; + f[atomi][1] += rij[1]*tmp2; + f[atomi][2] += rij[2]*tmp2; + f[atomj][0] -= rij[0]*tmp2; + f[atomj][1] -= rij[1]*tmp2; + f[atomj][2] -= rij[2]*tmp2; + + if (vflag_either) v_tally2(atomi,atomj,tmp2,rij); + + bij = (0.5*(pij+pji)); + return bij; +} + +/* ---------------------------------------------------------------------- + G calculation +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + read REBO potential file +------------------------------------------------------------------------- */ + +void PairREBOMoS::read_file(char *filename) +{ + // REBO Parameters (Mo-S REBO) + + double rcmin_MM,rcmin_MS,rcmin_SS,rcmax_MM,rcmax_MS,rcmax_SS; + double Q_MM,Q_MS,Q_SS,alpha_MM,alpha_MS,alpha_SS,A_MM,A_MS,A_SS; + double BIJc_MM1,BIJc_MS1,BIJc_SS1; + double Beta_MM1,Beta_MS1,Beta_SS1; + double M_bg0,M_bg1,M_bg2,M_bg3,M_bg4,M_bg5,M_bg6; + double S_bg0,S_bg1,S_bg2,S_bg3,S_bg4,S_bg5,S_bg6; + double M_b0,M_b1,M_b2,M_b3,M_b4,M_b5,M_b6; + double S_b0,S_b1,S_b2,S_b3,S_b4,S_b5,S_b6; + double M_a0,M_a1,M_a2,M_a3; + double S_a0,S_a1,S_a2,S_a3; + + // LJ Parameters (Mo-S REBO) + + double epsilon_MM,epsilon_SS; + double sigma_MM,sigma_SS; + + // read file on proc 0 + + if (comm->me == 0) { + PotentialFileReader reader(lmp, filename, "rebomos"); + + // read parameters + + std::vector params { + &rcmin_MM, + &rcmin_MS, + &rcmin_SS, + &rcmax_MM, + &rcmax_MS, + &rcmax_SS, + &Q_MM, + &Q_MS, + &Q_SS, + &alpha_MM, + &alpha_MS, + &alpha_SS, + &A_MM, + &A_MS, + &A_SS, + &BIJc_MM1, + &BIJc_MS1, + &BIJc_SS1, + &Beta_MM1, + &Beta_MS1, + &Beta_SS1, + &M_b0, + &M_b1, + &M_b2, + &M_b3, + &M_b4, + &M_b5, + &M_b6, + &M_bg0, + &M_bg1, + &M_bg2, + &M_bg3, + &M_bg4, + &M_bg5, + &M_bg6, + &S_b0, + &S_b1, + &S_b2, + &S_b3, + &S_b4, + &S_b5, + &S_b6, + &S_bg0, + &S_bg1, + &S_bg2, + &S_bg3, + &S_bg4, + &S_bg5, + &S_bg6, + &M_a0, + &M_a1, + &M_a2, + &M_a3, + &S_a0, + &S_a1, + &S_a2, + &S_a3, + + // LJ parameters + &epsilon_MM, + &epsilon_SS, + &sigma_MM, + &sigma_SS, + }; + + try { + for (auto ¶m : params) { + *param = reader.next_double(); + } + } catch (TokenizerException &e) { + error->one(FLERR, "reading rebomos potential file {}\nREASON: {}\n", filename, e.what()); + } catch (FileReaderException &fre) { + error->one(FLERR, "reading rebomos potential file {}\nREASON: {}\n", filename, fre.what()); + } + + // store read-in values in arrays + + // REBO + + rcmin[0][0] = rcmin_MM; + rcmin[0][1] = rcmin_MS; + rcmin[1][0] = rcmin[0][1]; + rcmin[1][1] = rcmin_SS; + + rcmax[0][0] = rcmax_MM; + rcmax[0][1] = rcmax_MS; + rcmax[1][0] = rcmax[0][1]; + rcmax[1][1] = rcmax_SS; + + rcmaxsq[0][0] = rcmax[0][0]*rcmax[0][0]; + rcmaxsq[1][0] = rcmax[1][0]*rcmax[1][0]; + rcmaxsq[0][1] = rcmax[0][1]*rcmax[0][1]; + rcmaxsq[1][1] = rcmax[1][1]*rcmax[1][1]; + + Q[0][0] = Q_MM; + Q[0][1] = Q_MS; + Q[1][0] = Q[0][1]; + Q[1][1] = Q_SS; + + alpha[0][0] = alpha_MM; + alpha[0][1] = alpha_MS; + alpha[1][0] = alpha[0][1]; + alpha[1][1] = alpha_SS; + + A[0][0] = A_MM; + A[0][1] = A_MS; + A[1][0] = A[0][1]; + A[1][1] = A_SS; + + BIJc[0][0] = BIJc_MM1; + BIJc[0][1] = BIJc_MS1; + BIJc[1][0] = BIJc_MS1; + BIJc[1][1] = BIJc_SS1; + + Beta[0][0] = Beta_MM1; + Beta[0][1] = Beta_MS1; + Beta[1][0] = Beta_MS1; + Beta[1][1] = Beta_SS1; + + b0[0] = M_b0; + b1[0] = M_b1; + b2[0] = M_b2; + b3[0] = M_b3; + b4[0] = M_b4; + b5[0] = M_b5; + b6[0] = M_b6; + + bg0[0] = M_bg0; + bg1[0] = M_bg1; + bg2[0] = M_bg2; + bg3[0] = M_bg3; + bg4[0] = M_bg4; + bg5[0] = M_bg5; + bg6[0] = M_bg6; + + b0[1] = S_b0; + b1[1] = S_b1; + b2[1] = S_b2; + b3[1] = S_b3; + b4[1] = S_b4; + b5[1] = S_b5; + b6[1] = S_b6; + + bg0[1] = S_bg0; + bg1[1] = S_bg1; + bg2[1] = S_bg2; + bg3[1] = S_bg3; + bg4[1] = S_bg4; + bg5[1] = S_bg5; + bg6[1] = S_bg6; + + a0[0] = M_a0; + a1[0] = M_a1; + a2[0] = M_a2; + a3[0] = M_a3; + + a0[1] = S_a0; + a1[1] = S_a1; + a2[1] = S_a2; + a3[1] = S_a3; + + // LJ + + sigma[0][0] = sigma_MM; + sigma[0][1] = (sigma_MM + sigma_SS)/2; + sigma[1][0] = sigma[0][1]; + sigma[1][1] = sigma_SS; + + epsilon[0][0] = epsilon_MM; + epsilon[0][1] = sqrt(epsilon_MM*epsilon_SS); + epsilon[1][0] = epsilon[0][1]; + epsilon[1][1] = epsilon_SS; + + rcLJmin[0][0] = rcmin_MM; + rcLJmin[0][1] = rcmin_MS; + rcLJmin[1][0] = rcmin[0][1]; + rcLJmin[1][1] = rcmin_SS; + + rcLJmax[0][0] = 2.5*sigma[0][0]; + rcLJmax[0][1] = 2.5*sigma[0][1]; + rcLJmax[1][0] = rcLJmax[0][1]; + rcLJmax[1][1] = 2.5*sigma[1][1]; + } + + // broadcast read-in and setup values + + MPI_Bcast(&rcmin[0][0],4,MPI_DOUBLE,0,world); + MPI_Bcast(&rcmax[0][0],4,MPI_DOUBLE,0,world); + MPI_Bcast(&rcmaxsq[0][0],4,MPI_DOUBLE,0,world); + MPI_Bcast(&rcmaxp[0][0],4,MPI_DOUBLE,0,world); + + MPI_Bcast(&Q[0][0],4,MPI_DOUBLE,0,world); + MPI_Bcast(&alpha[0][0],4,MPI_DOUBLE,0,world); + MPI_Bcast(&A[0][0],4,MPI_DOUBLE,0,world); + MPI_Bcast(&BIJc[0][0],4,MPI_DOUBLE,0,world); + MPI_Bcast(&Beta[0][0],4,MPI_DOUBLE,0,world); + + MPI_Bcast(&b0[0],2,MPI_DOUBLE,0,world); + MPI_Bcast(&b1[0],2,MPI_DOUBLE,0,world); + MPI_Bcast(&b2[0],2,MPI_DOUBLE,0,world); + MPI_Bcast(&b3[0],2,MPI_DOUBLE,0,world); + MPI_Bcast(&b4[0],2,MPI_DOUBLE,0,world); + MPI_Bcast(&b5[0],2,MPI_DOUBLE,0,world); + MPI_Bcast(&b6[0],2,MPI_DOUBLE,0,world); + + MPI_Bcast(&a0[0],2,MPI_DOUBLE,0,world); + MPI_Bcast(&a1[0],2,MPI_DOUBLE,0,world); + MPI_Bcast(&a2[0],2,MPI_DOUBLE,0,world); + MPI_Bcast(&a3[0],2,MPI_DOUBLE,0,world); + + MPI_Bcast(&bg0[0],2,MPI_DOUBLE,0,world); + MPI_Bcast(&bg1[0],2,MPI_DOUBLE,0,world); + MPI_Bcast(&bg2[0],2,MPI_DOUBLE,0,world); + MPI_Bcast(&bg3[0],2,MPI_DOUBLE,0,world); + MPI_Bcast(&bg4[0],2,MPI_DOUBLE,0,world); + MPI_Bcast(&bg5[0],2,MPI_DOUBLE,0,world); + MPI_Bcast(&bg6[0],2,MPI_DOUBLE,0,world); + + MPI_Bcast(&rcLJmin[0][0],4,MPI_DOUBLE,0,world); + MPI_Bcast(&rcLJmax[0][0],4,MPI_DOUBLE,0,world); + MPI_Bcast(&epsilon[0][0],4,MPI_DOUBLE,0,world); + MPI_Bcast(&sigma[0][0],4,MPI_DOUBLE,0,world); +} + +/* ---------------------------------------------------------------------- + memory usage of local atom-based arrays +------------------------------------------------------------------------- */ + +double PairREBOMoS::memory_usage() +{ + double bytes = 0.0; + bytes += (double)maxlocal * sizeof(int); + bytes += (double)maxlocal * sizeof(int *); + + for (int i = 0; i < comm->nthreads; i++) + bytes += ipage[i].size(); + + bytes += 3.0 * maxlocal * sizeof(double); + return bytes; +} diff --git a/src/MANYBODY/pair_rebomos.h b/src/MANYBODY/pair_rebomos.h new file mode 100644 index 0000000000..856a52ca81 --- /dev/null +++ b/src/MANYBODY/pair_rebomos.h @@ -0,0 +1,216 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + LAMMPS Development team: developers@lammps.org + + 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. +------------------------------------------------------------------------- */ + +#ifdef PAIR_CLASS +// clang-format off +PairStyle(rebomos,PairREBOMoS); +// clang-format on +#else + +#ifndef LMP_PAIR_REBOMOS_H +#define LMP_PAIR_REBOMOS_H + +#include "math_const.h" +#include "pair.h" + +#include + +namespace LAMMPS_NS { + +class PairREBOMoS : public Pair { + public: + PairREBOMoS(class LAMMPS *); + ~PairREBOMoS() override; + void compute(int, int) override; + void settings(int, char **) override; + void coeff(int, char **) override; + void init_style() override; + double init_one(int, int) override; + double memory_usage() override; + + protected: + double **lj1, **lj2, **lj3, **lj4; // pre-computed LJ coeffs for M,S types + double cut3rebo; // maximum distance for 3rd REBO neigh + + int maxlocal; // size of numneigh, firstneigh arrays + int pgsize; // size of neighbor page + int oneatom; // max # of neighbors for one atom + MyPage *ipage; // neighbor list pages + int *REBO_numneigh; // # of pair neighbors for each atom + int **REBO_firstneigh; // ptr to 1st neighbor of each atom + + double *nM, *nS; // sum of weighting fns with REBO neighs + + double rcmin[2][2], rcmax[2][2], rcmaxsq[2][2], rcmaxp[2][2]; + double Q[2][2], alpha[2][2], A[2][2], BIJc[2][2], Beta[2][2]; + double b0[2], b1[2], b2[2], b3[2], b4[2], b5[2], b6[2]; + double bg0[2], bg1[2], bg2[2], bg3[2], bg4[2], bg5[2], bg6[2]; + double a0[2], a1[2], a2[2], a3[2]; + double rcLJmin[2][2], rcLJmax[2][2]; + double epsilon[2][2], sigma[2][2]; + + void REBO_neigh(); + void FREBO(int); + void FLJ(int); + + double bondorder(int, int, double *, double, double, double **); + + inline double gSpline(const double costh, const int typei, double &dgdc) const + { + const double b0i = b0[typei]; + const double b1i = b1[typei]; + const double b2i = b2[typei]; + const double b3i = b3[typei]; + const double b4i = b4[typei]; + const double b5i = b5[typei]; + const double b6i = b6[typei]; + double g = 0.0; + + if (costh >= -1.0 && costh < 0.5) { + g = b6i * costh; + double dg = 6.0 * b6i * costh; + g += b5i; + dg += 5.0 * b5i; + g *= costh; + dg *= costh; + g += b4i; + dg += 4.0 * b4i; + g *= costh; + dg *= costh; + g += b3i; + dg += 3.0 * b3i; + g *= costh; + dg *= costh; + g += b2i; + dg += 2.0 * b2i; + g *= costh; + dg *= costh; + g += b1i; + dg += b1i; + g *= costh; + g += b0i; + dgdc = dg; + + } else if (costh >= 0.5 && costh <= 1.0) { + double gcos = b6i * costh; + double dgcos = 6.0 * b6i * costh; + gcos += b5i; + dgcos += 5.0 * b5i; + gcos *= costh; + dgcos *= costh; + gcos += b4i; + dgcos += 4.0 * b4i; + gcos *= costh; + dgcos *= costh; + gcos += b3i; + dgcos += 3.0 * b3i; + gcos *= costh; + dgcos *= costh; + gcos += b2i; + dgcos += 2.0 * b2i; + gcos *= costh; + dgcos *= costh; + gcos += b1i; + dgcos += b1i; + gcos *= costh; + gcos += b0i; + + const double bg0i = bg0[typei]; + const double bg1i = bg1[typei]; + const double bg2i = bg2[typei]; + const double bg3i = bg3[typei]; + const double bg4i = bg4[typei]; + const double bg5i = bg5[typei]; + const double bg6i = bg6[typei]; + double gamma = bg6i * costh; + double dgamma = 6.0 * bg6i * costh; + gamma += bg5i; + dgamma += 5.0 * bg5i; + gamma *= costh; + dgamma *= costh; + gamma += bg4i; + dgamma += 4.0 * bg4i; + gamma *= costh; + dgamma *= costh; + gamma += bg3i; + dgamma += 3.0 * bg3i; + gamma *= costh; + dgamma *= costh; + gamma += bg2i; + dgamma += 2.0 * bg2i; + gamma *= costh; + dgamma *= costh; + gamma += bg1i; + dgamma += bg1i; + gamma *= costh; + gamma += bg0i; + + const double tmp = MathConst::MY_2PI * (costh - 0.5); + const double psi = 0.5 * (1 - cos(tmp)); + const double dpsi = MathConst::MY_PI * sin(tmp); + g = gcos + psi * (gamma - gcos); + dgdc = dgcos + dpsi * (gamma - gcos) + psi * (dgamma - dgcos); + } else { + dgdc = 0.0; + } + return g; + } + + /* ---------------------------------------------------------------------- + Pij calculation + ------------------------------------------------------------------------- */ + + inline double PijSpline(const double NM, const double NS, const int typei, double &dp) const + { + const double N = NM + NS; + + dp = -a0[typei] + a1[typei] * a2[typei] * exp(-a2[typei] * N); + return -a0[typei] * (N - 1) - a1[typei] * exp(-a2[typei] * N) + a3[typei]; + } + + void read_file(char *); + void allocate(); + + // ---------------------------------------------------------------------- + // S'(t) and S(t) cutoff functions + // added to header for inlining + // ---------------------------------------------------------------------- + + /* ---------------------------------------------------------------------- + cutoff function Sprime + return cutoff and dX = derivative + no side effects + ------------------------------------------------------------------------- */ + + inline double Sp(double Xij, double Xmin, double Xmax, double &dX) const + { + double cutoff; + + const double t = (Xij - Xmin) / (Xmax - Xmin); + if (t <= 0.0) { + cutoff = 1.0; + dX = 0.0; + } else if (t >= 1.0) { + cutoff = 0.0; + dX = 0.0; + } else { + cutoff = 0.5 * (1.0 + cos(t * MathConst::MY_PI)); + dX = (-0.5 * MathConst::MY_PI * sin(t * MathConst::MY_PI)) / (Xmax - Xmin); + } + return cutoff; + }; +}; +} // namespace LAMMPS_NS + +#endif +#endif diff --git a/src/MANYBODY/pair_sw.cpp b/src/MANYBODY/pair_sw.cpp index 540fd8772c..18b642967c 100644 --- a/src/MANYBODY/pair_sw.cpp +++ b/src/MANYBODY/pair_sw.cpp @@ -33,7 +33,7 @@ using namespace LAMMPS_NS; -#define DELTA 4 +static constexpr int DELTA = 4; /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_sw_angle_table.cpp b/src/MANYBODY/pair_sw_angle_table.cpp index 21f1967c0d..12592f4af6 100644 --- a/src/MANYBODY/pair_sw_angle_table.cpp +++ b/src/MANYBODY/pair_sw_angle_table.cpp @@ -26,7 +26,6 @@ #include "math_const.h" #include "memory.h" #include "neigh_list.h" -#include "neighbor.h" #include "table_file_reader.h" #include "potential_file_reader.h" @@ -39,7 +38,7 @@ using MathConst::DEG2RAD; using MathConst::MY_PI; using MathConst::RAD2DEG; -#define DELTA 4 +static constexpr int DELTA = 4; enum { LINEAR, SPLINE }; diff --git a/src/MANYBODY/pair_tersoff.cpp b/src/MANYBODY/pair_tersoff.cpp index c7c45bc865..e3c8c83416 100644 --- a/src/MANYBODY/pair_tersoff.cpp +++ b/src/MANYBODY/pair_tersoff.cpp @@ -40,7 +40,7 @@ using namespace MathConst; using namespace MathSpecial; using namespace MathExtra; -#define DELTA 4 +static constexpr int DELTA = 4; /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_tersoff_mod.cpp b/src/MANYBODY/pair_tersoff_mod.cpp index 010ff8df87..f4ae623bae 100644 --- a/src/MANYBODY/pair_tersoff_mod.cpp +++ b/src/MANYBODY/pair_tersoff_mod.cpp @@ -35,7 +35,7 @@ using namespace MathConst; using namespace MathExtra; using namespace MathSpecial; -#define DELTA 4 +static constexpr int DELTA = 4; /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_tersoff_mod_c.cpp b/src/MANYBODY/pair_tersoff_mod_c.cpp index bdec854c41..e7fef3ccfa 100644 --- a/src/MANYBODY/pair_tersoff_mod_c.cpp +++ b/src/MANYBODY/pair_tersoff_mod_c.cpp @@ -28,7 +28,7 @@ using namespace LAMMPS_NS; -#define DELTA 4 +static constexpr int DELTA = 4; /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_tersoff_table.cpp b/src/MANYBODY/pair_tersoff_table.cpp index 325542f97e..b2aec2653c 100644 --- a/src/MANYBODY/pair_tersoff_table.cpp +++ b/src/MANYBODY/pair_tersoff_table.cpp @@ -39,18 +39,16 @@ using namespace LAMMPS_NS; using MathConst::MY_PI; -#define MAXLINE 1024 -#define DELTA 4 - -#define GRIDSTART 0.1 -#define GRIDDENSITY_FCUTOFF 5000 -#define GRIDDENSITY_EXP 12000 -#define GRIDDENSITY_GTETA 12000 -#define GRIDDENSITY_BIJ 7500 +static constexpr int DELTA = 4; +static constexpr double GRIDSTART = 0.1; +static constexpr int GRIDDENSITY_FCUTOFF = 5000; +static constexpr int GRIDDENSITY_EXP = 12000; +static constexpr int GRIDDENSITY_GTETA = 12000; +static constexpr int GRIDDENSITY_BIJ = 7500; // max number of interaction per atom for environment potential -#define leadingDimensionInteractionList 64 +static constexpr int leadingDimensionInteractionList = 64; /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_tersoff_zbl.cpp b/src/MANYBODY/pair_tersoff_zbl.cpp index daf2718cb1..9c4dabc219 100644 --- a/src/MANYBODY/pair_tersoff_zbl.cpp +++ b/src/MANYBODY/pair_tersoff_zbl.cpp @@ -34,7 +34,7 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define DELTA 4 +static constexpr int DELTA = 4; /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_threebody_table.cpp b/src/MANYBODY/pair_threebody_table.cpp index 57f7021816..20b26edbfa 100644 --- a/src/MANYBODY/pair_threebody_table.cpp +++ b/src/MANYBODY/pair_threebody_table.cpp @@ -35,7 +35,7 @@ using namespace LAMMPS_NS; using MathConst::MY_PI; -#define DELTA 4 +static constexpr int DELTA = 4; /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_vashishta.cpp b/src/MANYBODY/pair_vashishta.cpp index 531f15d263..79df1f36d7 100644 --- a/src/MANYBODY/pair_vashishta.cpp +++ b/src/MANYBODY/pair_vashishta.cpp @@ -33,7 +33,7 @@ using namespace LAMMPS_NS; -#define DELTA 4 +static constexpr int DELTA = 4; /* ---------------------------------------------------------------------- */ diff --git a/src/MC/fix_bond_break.cpp b/src/MC/fix_bond_break.cpp index 6589f93e23..bb3e725c96 100644 --- a/src/MC/fix_bond_break.cpp +++ b/src/MC/fix_bond_break.cpp @@ -32,7 +32,7 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define DELTA 16 +static constexpr int DELTA = 16; /* ---------------------------------------------------------------------- */ diff --git a/src/MC/fix_bond_create.cpp b/src/MC/fix_bond_create.cpp index adecc9f252..8922bde55f 100644 --- a/src/MC/fix_bond_create.cpp +++ b/src/MC/fix_bond_create.cpp @@ -34,8 +34,8 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace MathConst; -#define BIG 1.0e20 -#define DELTA 16 +static constexpr double BIG = 1.0e20; +static constexpr int DELTA = 16; /* ---------------------------------------------------------------------- */ diff --git a/src/MC/fix_charge_regulation.cpp b/src/MC/fix_charge_regulation.cpp index a828f276ea..4358513095 100644 --- a/src/MC/fix_charge_regulation.cpp +++ b/src/MC/fix_charge_regulation.cpp @@ -46,6 +46,7 @@ #include #include +#include #include using namespace LAMMPS_NS; @@ -66,9 +67,9 @@ static const char cite_fix_charge_regulation[] = enum{CONSTANT,EQUAL}; // parsing input variables // large energy value used to signal overlap -#define MAXENERGYSIGNAL 1.0e100 -#define MAXENERGYTEST 1.0e50 -#define SMALL 0.0000001 +static constexpr double MAXENERGYSIGNAL = 1.0e100; +static constexpr double MAXENERGYTEST = 1.0e50; +static constexpr double SMALL = 0.0000001; #define NA_RHO0 0.602214 // Avogadro's constant times reference concentration (N_A * mol / liter) [nm^-3] /* ---------------------------------------------------------------------- */ @@ -191,6 +192,11 @@ int FixChargeRegulation::setmask() { void FixChargeRegulation::init() { + if (!atom->mass) error->all(FLERR, "Fix charge/regulation requires per atom type masses"); + if (atom->rmass_flag && (comm->me == 0)) + error->warning(FLERR, "Fix charge/regulation will use per atom type masses for " + "velocity initialization"); + triclinic = domain->triclinic; int ipe = modify->find_compute("thermo_pe"); c_pe = modify->compute[ipe]; diff --git a/src/MC/fix_gcmc.cpp b/src/MC/fix_gcmc.cpp index 2e29b403fd..bd7e46b3d1 100644 --- a/src/MC/fix_gcmc.cpp +++ b/src/MC/fix_gcmc.cpp @@ -45,6 +45,7 @@ #include #include +#include using namespace LAMMPS_NS; using namespace FixConst; @@ -52,14 +53,14 @@ using namespace MathConst; // large energy value used to signal overlap -#define MAXENERGYSIGNAL 1.0e100 +static constexpr double MAXENERGYSIGNAL = 1.0e100; // this must be lower than MAXENERGYSIGNAL // by a large amount, so that it is still // less than total energy when negative // energy contributions are added to MAXENERGYSIGNAL -#define MAXENERGYTEST 1.0e50 +static constexpr double MAXENERGYTEST = 1.0e50; enum { EXCHATOM, EXCHMOL }; // exchmode enum { NONE, MOVEATOM, MOVEMOL }; // movemode @@ -463,6 +464,10 @@ int FixGCMC::setmask() void FixGCMC::init() { + if (!atom->mass) error->all(FLERR, "Fix gcmc requires per atom type masses"); + if (atom->rmass_flag && (comm->me == 0)) + error->warning(FLERR, "Fix gcmc will use per atom type masses for velocity initialization"); + triclinic = domain->triclinic; // set index and check validity of region diff --git a/src/MC/fix_mol_swap.cpp b/src/MC/fix_mol_swap.cpp index a47cf039d1..f496d4a9c5 100644 --- a/src/MC/fix_mol_swap.cpp +++ b/src/MC/fix_mol_swap.cpp @@ -38,7 +38,7 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define BIG 1.0e20 +static constexpr double BIG = 1.0e20; /* ---------------------------------------------------------------------- */ diff --git a/src/MC/fix_sgcmc.cpp b/src/MC/fix_sgcmc.cpp index a70f3240db..ae0e69d77e 100644 --- a/src/MC/fix_sgcmc.cpp +++ b/src/MC/fix_sgcmc.cpp @@ -235,11 +235,13 @@ int FixSemiGrandCanonicalMC::setmask() *********************************************************************/ void FixSemiGrandCanonicalMC::init() { - // Make sure the user has defined only one Monte-Carlo fix. - int count = 0; - for (int i = 0; i < modify->nfix; i++) - if (strcmp(modify->fix[i]->style,"sgcmc") == 0) count++; - if (count > 1) error->all(FLERR, "More than one fix sgcmc defined."); + if (!atom->mass) error->all(FLERR, "Fix sgcmc requires per atom type masses"); + if (atom->rmass_flag && (comm->me == 0)) + error->warning(FLERR, "Fix sgcmc will use per atom type masses for velocity initialization"); + + // Make sure the user has defined only one Semi-Grand Monte-Carlo fix. + if (modify->get_fix_by_style("sgcmc").size() > 1) + error->all(FLERR, "More than one fix sgcmc defined."); // Save a pointer to the EAM potential. pairEAM = dynamic_cast(force->pair); @@ -248,7 +250,8 @@ void FixSemiGrandCanonicalMC::init() utils::logmesg(lmp, " SGC - Using naive total energy calculation for MC -> SLOW!\n"); if (comm->nprocs > 1) - error->all(FLERR, "Can not run fix vcsgc with naive total energy calculation and more than one MPI process."); + error->all(FLERR, "Can not run fix sgcmc with naive total energy calculation " + "and more than one MPI process."); // Create a compute that will provide the total energy of the system. // This is needed by computeTotalEnergy(). diff --git a/src/MC/fix_widom.cpp b/src/MC/fix_widom.cpp index 7869b213a0..9871dc8f60 100644 --- a/src/MC/fix_widom.cpp +++ b/src/MC/fix_widom.cpp @@ -45,12 +45,12 @@ #include #include +#include using namespace LAMMPS_NS; using namespace FixConst; using MathConst::MY_2PI; -#define MAXENERGYTEST 1.0e50 enum { EXCHATOM, EXCHMOL }; // exchmode /* ---------------------------------------------------------------------- */ @@ -281,6 +281,10 @@ int FixWidom::setmask() void FixWidom::init() { + if (!atom->mass) error->all(FLERR, "Fix widom requires per atom type masses"); + if (atom->rmass_flag && (comm->me == 0)) + error->warning(FLERR, "Fix widom will use per atom type masses for velocity initialization"); + triclinic = domain->triclinic; // set index and check validity of region diff --git a/src/MC/pair_dsmc.cpp b/src/MC/pair_dsmc.cpp index 4773ac7653..1c152906b3 100644 --- a/src/MC/pair_dsmc.cpp +++ b/src/MC/pair_dsmc.cpp @@ -271,6 +271,8 @@ void PairDSMC::coeff(int narg, char **arg) void PairDSMC::init_style() { + if (!atom->mass) error->all(FLERR, "Pair style dsmc requires per atom type masses"); + ncellsx = ncellsy = ncellsz = 1; while (((domain->boxhi[0] - domain->boxlo[0])/ncellsx) > max_cell_size) ncellsx++; diff --git a/src/MDI/fix_mdi_engine.cpp b/src/MDI/fix_mdi_engine.cpp index 0494d08b2d..fe896d906f 100644 --- a/src/MDI/fix_mdi_engine.cpp +++ b/src/MDI/fix_mdi_engine.cpp @@ -19,7 +19,6 @@ #include "fix_mdi_engine.h" #include "error.h" -#include "update.h" #include "mdi_engine.h" diff --git a/src/MDI/fix_mdi_qm.cpp b/src/MDI/fix_mdi_qm.cpp index ff2c667f1c..46071c5c90 100644 --- a/src/MDI/fix_mdi_qm.cpp +++ b/src/MDI/fix_mdi_qm.cpp @@ -22,12 +22,14 @@ #include "modify.h" #include "update.h" +#include + using namespace LAMMPS_NS; using namespace FixConst; enum { NATIVE, REAL, METAL }; // LAMMPS units which MDI supports -#define MAXELEMENT 118 +static constexpr int MAXELEMENT = 118; // prototype for non-class compare function for sorting QM IDs diff --git a/src/MDI/fix_mdi_qmmm.cpp b/src/MDI/fix_mdi_qmmm.cpp index 958b5ec312..d45290811f 100644 --- a/src/MDI/fix_mdi_qmmm.cpp +++ b/src/MDI/fix_mdi_qmmm.cpp @@ -12,6 +12,7 @@ ------------------------------------------------------------------------- */ #include "fix_mdi_qmmm.h" + #include "atom.h" #include "comm.h" #include "domain.h" @@ -25,13 +26,16 @@ #include "pair.h" #include "update.h" +#include +#include + using namespace LAMMPS_NS; using namespace FixConst; enum { NATIVE, REAL, METAL }; // LAMMPS units which MDI supports enum { DIRECT, POTENTIAL }; // mode of QMMM coupling -#define MAXELEMENT 118 +static constexpr int MAXELEMENT = 118; // prototype for non-class compare function for sorting QM IDs diff --git a/src/MDI/mdi_command.h b/src/MDI/mdi_command.h index 88e1901ab1..0bdfe81279 100644 --- a/src/MDI/mdi_command.h +++ b/src/MDI/mdi_command.h @@ -21,7 +21,7 @@ CommandStyle(mdi,MDICommand); #define LMP_MDI_COMMAND_H #include "command.h" -#include "mdi.h" +#include namespace LAMMPS_NS { diff --git a/src/MDI/mdi_engine.cpp b/src/MDI/mdi_engine.cpp index f7025549cd..6d7c604fa6 100644 --- a/src/MDI/mdi_engine.cpp +++ b/src/MDI/mdi_engine.cpp @@ -25,12 +25,10 @@ #include "error.h" #include "fix_mdi_engine.h" #include "force.h" -#include "group.h" #include "input.h" #include "integrate.h" #include "irregular.h" #include "library.h" -#include "library_mdi.h" #include "memory.h" #include "min.h" #include "modify.h" @@ -54,7 +52,7 @@ enum { DEFAULT, MD, OPT }; // top-level MDI engine modes enum { TYPE, CHARGE, MASS, COORD, VELOCITY, FORCE, ADDFORCE }; -#define MAXELEMENT 118 +static constexpr int MAXELEMENT = 118; /* ---------------------------------------------------------------------- trigger LAMMPS to start acting as an MDI engine diff --git a/src/MDI/mdi_plugin.cpp b/src/MDI/mdi_plugin.cpp index 92b78b6afb..6294292229 100644 --- a/src/MDI/mdi_plugin.cpp +++ b/src/MDI/mdi_plugin.cpp @@ -21,9 +21,7 @@ #include "error.h" #include "input.h" #include "memory.h" -#include "modify.h" -#include #include #include diff --git a/src/MEAM/meam.h b/src/MEAM/meam.h index 5a131bdc34..7aca094912 100644 --- a/src/MEAM/meam.h +++ b/src/MEAM/meam.h @@ -17,7 +17,7 @@ #include #include -constexpr int maxelt = 5; +constexpr int MAXELT = 8; namespace LAMMPS_NS { class Memory; @@ -88,30 +88,30 @@ class MEAM { // stheta_meam = sin(theta/2) in radian used in line, zigzag, and trimer reference structures // ctheta_meam = cos(theta/2) in radian used in line, zigzag, and trimer reference structures - double Ec_meam[maxelt][maxelt], re_meam[maxelt][maxelt]; - double A_meam[maxelt], alpha_meam[maxelt][maxelt], rho0_meam[maxelt]; - double delta_meam[maxelt][maxelt]; - double beta0_meam[maxelt], beta1_meam[maxelt]; - double beta2_meam[maxelt], beta3_meam[maxelt]; - double t0_meam[maxelt], t1_meam[maxelt]; - double t2_meam[maxelt], t3_meam[maxelt]; - double rho_ref_meam[maxelt]; - int ibar_meam[maxelt], ielt_meam[maxelt]; - lattice_t lattce_meam[maxelt][maxelt]; - int nn2_meam[maxelt][maxelt]; - int zbl_meam[maxelt][maxelt]; - int eltind[maxelt][maxelt]; + double Ec_meam[MAXELT][MAXELT], re_meam[MAXELT][MAXELT]; + double A_meam[MAXELT], alpha_meam[MAXELT][MAXELT], rho0_meam[MAXELT]; + double delta_meam[MAXELT][MAXELT]; + double beta0_meam[MAXELT], beta1_meam[MAXELT]; + double beta2_meam[MAXELT], beta3_meam[MAXELT]; + double t0_meam[MAXELT], t1_meam[MAXELT]; + double t2_meam[MAXELT], t3_meam[MAXELT]; + double rho_ref_meam[MAXELT]; + int ibar_meam[MAXELT], ielt_meam[MAXELT]; + lattice_t lattce_meam[MAXELT][MAXELT]; + int nn2_meam[MAXELT][MAXELT]; + int zbl_meam[MAXELT][MAXELT]; + int eltind[MAXELT][MAXELT]; int neltypes; double **phir; double **phirar, **phirar1, **phirar2, **phirar3, **phirar4, **phirar5, **phirar6; - double attrac_meam[maxelt][maxelt], repuls_meam[maxelt][maxelt]; + double attrac_meam[MAXELT][MAXELT], repuls_meam[MAXELT][MAXELT]; - double Cmin_meam[maxelt][maxelt][maxelt]; - double Cmax_meam[maxelt][maxelt][maxelt]; - double rc_meam, delr_meam, ebound_meam[maxelt][maxelt]; + double Cmin_meam[MAXELT][MAXELT][MAXELT]; + double Cmax_meam[MAXELT][MAXELT][MAXELT]; + double rc_meam, delr_meam, ebound_meam[MAXELT][MAXELT]; int augt1, ialloy, mix_ref_t, erose_form; int emb_lin_neg, bkgd_dyn; double gsmooth_factor; @@ -124,8 +124,8 @@ class MEAM { // MS-MEAM parameters - double t1m_meam[maxelt], t2m_meam[maxelt], t3m_meam[maxelt]; - double beta1m_meam[maxelt], beta2m_meam[maxelt], beta3m_meam[maxelt]; + double t1m_meam[MAXELT], t2m_meam[MAXELT], t3m_meam[MAXELT]; + double beta1m_meam[MAXELT], beta2m_meam[MAXELT], beta3m_meam[MAXELT]; //int msmeamflag; // made public for pair style settings public: @@ -142,8 +142,8 @@ class MEAM { double *scrfcn, *dscrfcn, *fcpair; //angle for trimer, zigzag, line reference structures - double stheta_meam[maxelt][maxelt]; - double ctheta_meam[maxelt][maxelt]; + double stheta_meam[MAXELT][MAXELT]; + double ctheta_meam[MAXELT][MAXELT]; protected: // meam_funcs.cpp diff --git a/src/MEAM/meam_force.cpp b/src/MEAM/meam_force.cpp index 23230e0fbc..6fc3fd762f 100644 --- a/src/MEAM/meam_force.cpp +++ b/src/MEAM/meam_force.cpp @@ -65,11 +65,11 @@ void MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, double rhoa2mj,drhoa2mj,rhoa2mi,drhoa2mi; double rhoa3mj, drhoa3mj, rhoa3mi, drhoa3mi; double arg1i1m, arg1j1m, arg1i2m, arg1j2m, arg1i3m, arg1j3m, arg3i3m, arg3j3m; - double drho1mdr1, drho1mdr2, drho1mds1, drho1mds2; + double drho1mdr1, drho1mdr2; double drho1mdrm1[3], drho1mdrm2[3]; - double drho2mdr1, drho2mdr2, drho2mds1, drho2mds2; + double drho2mdr1, drho2mdr2; double drho2mdrm1[3], drho2mdrm2[3]; - double drho3mdr1, drho3mdr2, drho3mds1, drho3mds2; + double drho3mdr1, drho3mdr2; double drho3mdrm1[3], drho3mdrm2[3]; third = 1.0 / 3.0; @@ -527,78 +527,75 @@ void MEAM::meam_force(int i, int eflag_global, int eflag_atom, int vflag_global, drho3ds2 = a3 * rhoa3i * arg1j3 - a3a * rhoa3i * arg3j3; if (msmeamflag) { - drho1mds1 = a1 * rhoa1mj * arg1i1m; - drho1mds2 = a1 * rhoa1mi * arg1j1m; - drho2mds1 = a2 * rhoa2mj * arg1i2m - 2.0 / 3.0 * arho2mb[i] * rhoa2mj; - drho2mds2 = a2 * rhoa2mi * arg1j2m - 2.0 / 3.0 * arho2mb[j] * rhoa2mi; - drho3mds1 = a3 * rhoa3mj * arg1i3m - a3a * rhoa3mj * arg3i3m; - drho3mds2 = a3 * rhoa3mi * arg1j3m - a3a * rhoa3mi * arg3j3m; - drho3mds1 *= -1; - drho3mds2 *= -1; - } else { - drho1mds1 = 0.0; - drho1mds2 = 0.0; - drho2mds1 = 0.0; - drho2mds2 = 0.0; - drho3mds1 = 0.0; - drho3mds2 = 0.0; - } - if (ialloy == 1) { + const double drho1mds1 = -a1 * rhoa1mj * arg1i1m; + const double drho1mds2 = -a1 * rhoa1mi * arg1j1m; + const double drho2mds1 = a2 * rhoa2mj * arg1i2m - 2.0 / 3.0 * arho2mb[i] * rhoa2mj; + const double drho2mds2 = a2 * rhoa2mi * arg1j2m - 2.0 / 3.0 * arho2mb[j] * rhoa2mi; + const double drho3mds1 = -a3 * rhoa3mj * arg1i3m + a3a * rhoa3mj * arg3i3m; + const double drho3mds2 = -a3 * rhoa3mi * arg1j3m + a3a * rhoa3mi * arg3j3m; - a1i = fdiv_zero(rhoa0j, tsq_ave[i][0]); - a1j = fdiv_zero(rhoa0i, tsq_ave[j][0]); - a2i = fdiv_zero(rhoa0j, tsq_ave[i][1]); - a2j = fdiv_zero(rhoa0i, tsq_ave[j][1]); - a3i = fdiv_zero(rhoa0j, tsq_ave[i][2]); - a3j = fdiv_zero(rhoa0i, tsq_ave[j][2]); + t1i = 1.0; + t2i = 1.0; + t3i = 1.0; + t1j = 1.0; + t2j = 1.0; + t3j = 1.0; + dt1dr1 = 0.0; + dt1dr2 = 0.0; + dt2dr1 = 0.0; + dt2dr2 = 0.0; + dt3dr1 = 0.0; + dt3dr2 = 0.0; - dt1ds1 = a1i * (t1mj - t1i * MathSpecial::square(t1mj)); - dt1ds2 = a1j * (t1mi - t1j * MathSpecial::square(t1mi)); - dt2ds1 = a2i * (t2mj - t2i * MathSpecial::square(t2mj)); - dt2ds2 = a2j * (t2mi - t2j * MathSpecial::square(t2mi)); - dt3ds1 = a3i * (t3mj - t3i * MathSpecial::square(t3mj)); - dt3ds2 = a3j * (t3mi - t3j * MathSpecial::square(t3mi)); - - } else if (ialloy == 2) { - - dt1ds1 = 0.0; - dt1ds2 = 0.0; - dt2ds1 = 0.0; - dt2ds2 = 0.0; - dt3ds1 = 0.0; - dt3ds2 = 0.0; + // these formulae are simplifed by substituting t=1, dt=0 from above + drhods1 = dgamma1[i] * drho0ds1 + dgamma2[i] + * ((drho1ds1 - drho1mds1) + (drho2ds1 - drho2mds1) + (drho3ds1 - drho3mds1)); + drhods2 = dgamma1[j] * drho0ds2 + dgamma2[j] + * ((drho1ds2 - drho1mds2) + (drho2ds2 - drho2mds2) + (drho3ds2 - drho3mds2)); } else { - ai = 0.0; - if (!iszero(rho0[i])) - ai = rhoa0j / rho0[i]; - aj = 0.0; - if (!iszero(rho0[j])) - aj = rhoa0i / rho0[j]; + if (ialloy == 1) { - dt1ds1 = ai * (t1mj - t1i); - dt1ds2 = aj * (t1mi - t1j); - dt2ds1 = ai * (t2mj - t2i); - dt2ds2 = aj * (t2mi - t2j); - dt3ds1 = ai * (t3mj - t3i); - dt3ds2 = aj * (t3mi - t3j); - } + a1i = fdiv_zero(rhoa0j, tsq_ave[i][0]); + a1j = fdiv_zero(rhoa0i, tsq_ave[j][0]); + a2i = fdiv_zero(rhoa0j, tsq_ave[i][1]); + a2j = fdiv_zero(rhoa0i, tsq_ave[j][1]); + a3i = fdiv_zero(rhoa0j, tsq_ave[i][2]); + a3j = fdiv_zero(rhoa0i, tsq_ave[j][2]); + + dt1ds1 = a1i * (t1mj - t1i * MathSpecial::square(t1mj)); + dt1ds2 = a1j * (t1mi - t1j * MathSpecial::square(t1mi)); + dt2ds1 = a2i * (t2mj - t2i * MathSpecial::square(t2mj)); + dt2ds2 = a2j * (t2mi - t2j * MathSpecial::square(t2mi)); + dt3ds1 = a3i * (t3mj - t3i * MathSpecial::square(t3mj)); + dt3ds2 = a3j * (t3mi - t3j * MathSpecial::square(t3mi)); + + } else if (ialloy == 2) { + + dt1ds1 = 0.0; + dt1ds2 = 0.0; + dt2ds1 = 0.0; + dt2ds2 = 0.0; + dt3ds1 = 0.0; + dt3ds2 = 0.0; + + } else { + + ai = 0.0; + if (!iszero(rho0[i])) ai = rhoa0j / rho0[i]; + aj = 0.0; + if (!iszero(rho0[j])) aj = rhoa0i / rho0[j]; + + dt1ds1 = ai * (t1mj - t1i); + dt1ds2 = aj * (t1mi - t1j); + dt2ds1 = ai * (t2mj - t2i); + dt2ds2 = aj * (t2mi - t2j); + dt3ds1 = ai * (t3mj - t3i); + dt3ds2 = aj * (t3mi - t3j); + } - if (msmeamflag) { - drhods1 = dgamma1[i] * drho0ds1 + - dgamma2[i] * (dt1ds1 * rho1[i] + t1i * (drho1ds1 - drho1mds1) + - dt2ds1 * rho2[i] + t2i * (drho2ds1 - drho2mds1) + - dt3ds1 * rho3[i] + t3i * (drho3ds1 - drho3mds1)) - - dgamma3[i] * (shpi[0] * dt1ds1 + shpi[1] * dt2ds1 + shpi[2] * dt3ds1); - drhods2 = dgamma1[j] * drho0ds2 + - dgamma2[j] * (dt1ds2 * rho1[j] + t1j * (drho1ds2 - drho1mds2) + - dt2ds2 * rho2[j] + t2j * (drho2ds2 - drho2mds2) + - dt3ds2 * rho3[j] + t3j * (drho3ds2 - drho3mds2)) - - dgamma3[j] * (shpj[0] * dt1ds2 + shpj[1] * dt2ds2 + shpj[2] * dt3ds2); - } - else { drhods1 = dgamma1[i] * drho0ds1 + dgamma2[i] * (dt1ds1 * rho1[i] + t1i * drho1ds1 + dt2ds1 * rho2[i] + t2i * drho2ds1 + dt3ds1 * rho3[i] + t3i * drho3ds1) - diff --git a/src/MEAM/meam_impl.cpp b/src/MEAM/meam_impl.cpp index 473b491b01..41248c192b 100644 --- a/src/MEAM/meam_impl.cpp +++ b/src/MEAM/meam_impl.cpp @@ -42,12 +42,12 @@ MEAM::MEAM(Memory *mem) : memory(mem) copymode = 0; neltypes = 0; - for (int i = 0; i < maxelt; i++) { + for (int i = 0; i < MAXELT; i++) { A_meam[i] = rho0_meam[i] = beta0_meam[i] = beta1_meam[i] = beta2_meam[i] = beta3_meam[i] = t0_meam[i] = t1_meam[i] = t2_meam[i] = t3_meam[i] = rho_ref_meam[i] = ibar_meam[i] = ielt_meam[i] = t1m_meam[i] = t2m_meam[i] = t3m_meam[i] = beta1m_meam[i] = beta2m_meam[i] = beta3m_meam[i] = 0.0; - for (int j = 0; j < maxelt; j++) { + for (int j = 0; j < MAXELT; j++) { lattce_meam[i][j] = FCC; Ec_meam[i][j] = re_meam[i][j] = alpha_meam[i][j] = delta_meam[i][j] = ebound_meam[i][j] = attrac_meam[i][j] = repuls_meam[i][j] = 0.0; diff --git a/src/MEAM/meam_setup_done.cpp b/src/MEAM/meam_setup_done.cpp index 4adfd68f19..ce756051e4 100644 --- a/src/MEAM/meam_setup_done.cpp +++ b/src/MEAM/meam_setup_done.cpp @@ -33,7 +33,7 @@ void MEAM::meam_setup_done(double* cutmax) *cutmax = cutforce; // Augment t1 term - for (int i = 0; i < maxelt; i++) + for (int i = 0; i < MAXELT; i++) t1_meam[i] = t1_meam[i] + augt1 * 3.0 / 5.0 * t3_meam[i]; // Compute off-diagonal alloy parameters diff --git a/src/MEAM/meam_setup_global.cpp b/src/MEAM/meam_setup_global.cpp index 299fc4da61..1487a53b2e 100644 --- a/src/MEAM/meam_setup_global.cpp +++ b/src/MEAM/meam_setup_global.cpp @@ -38,7 +38,7 @@ void MEAM::meam_setup_global(int nelt, lattice_t *lat, int *ielement, double * / double *b2m, double *b3m, double *t1m, double *t2m, double *t3m) { int i; - double tmplat[maxelt]; + double tmplat[MAXELT]; neltypes = nelt; @@ -123,4 +123,7 @@ void MEAM::meam_setup_global(int nelt, lattice_t *lat, int *ielement, double * / // for trimer, zigzag, line refernece structure, sungkwang setall2d(stheta_meam, 1.0); // stheta = sin(theta/2*pi/180) where theta is 180, so 1.0 setall2d(ctheta_meam, 0.0); // stheta = cos(theta/2*pi/180) where theta is 180, so 0 + + if (msmeamflag) ialloy = 1; + } diff --git a/src/MEAM/pair_meam.cpp b/src/MEAM/pair_meam.cpp index 2f095754af..d9d2b53885 100644 --- a/src/MEAM/pair_meam.cpp +++ b/src/MEAM/pair_meam.cpp @@ -34,7 +34,7 @@ using namespace LAMMPS_NS; -#define MAXLINE 1024 +static constexpr int MAXLINE = 1024; static const int nkeywords = 22; static const char *keywords[] = { @@ -206,7 +206,12 @@ void PairMEAM::coeff(int narg, char **arg) // check for presence of first meam file std::string lib_file = utils::get_potential_file_path(arg[2]); - if (lib_file.empty()) error->all(FLERR, "Cannot open MEAM library file {}", lib_file); + if (lib_file.empty()) { + if (msmeamflag) + error->all(FLERR, "Cannot open MS-MEAM library file {}", lib_file); + else + error->all(FLERR, "Cannot open MEAM library file {}", lib_file); + } // find meam parameter file in arguments: // first word that is a file or "NULL" after the MEAM library file @@ -226,7 +231,12 @@ void PairMEAM::coeff(int narg, char **arg) break; } } - if (paridx < 0) error->all(FLERR, "No MEAM parameter file in pair coefficients"); + if (paridx < 0) { + if (msmeamflag) + error->all(FLERR, "No MS-MEAM parameter file in pair coefficients"); + else + error->all(FLERR, "No MEAM parameter file in pair coefficients"); + } if ((narg - paridx - 1) != atom->ntypes) error->all(FLERR, "Incorrect args for pair style {} coefficients", myname); @@ -241,11 +251,10 @@ void PairMEAM::coeff(int narg, char **arg) nlibelements = paridx - 3; if (nlibelements < 1) error->all(FLERR, "Incorrect args for pair coefficients"); - if (nlibelements > maxelt) + if (nlibelements > MAXELT) error->all(FLERR, "Too many elements extracted from MEAM library (current limit: {}). " - "Increase 'maxelt' in meam.h and recompile.", - maxelt); + "Increase 'MAXELT' in meam.h and recompile.", MAXELT); for (int i = 0; i < nlibelements; i++) { if (std::any_of(libelements.begin(), libelements.end(), [&](const std::string &elem) { diff --git a/src/MEAM/pair_meam_ms.cpp b/src/MEAM/pair_meam_ms.cpp index 982a54f546..e5cb960b59 100644 --- a/src/MEAM/pair_meam_ms.cpp +++ b/src/MEAM/pair_meam_ms.cpp @@ -12,6 +12,7 @@ ------------------------------------------------------------------------- */ #include "pair_meam_ms.h" + #include "meam.h" using namespace LAMMPS_NS; diff --git a/src/MESONT/angle_mesocnt.cpp b/src/MESONT/angle_mesocnt.cpp index 06ec135e3c..c6dae4b0fb 100644 --- a/src/MESONT/angle_mesocnt.cpp +++ b/src/MESONT/angle_mesocnt.cpp @@ -30,6 +30,7 @@ #include "update.h" #include +#include using namespace LAMMPS_NS; using MathConst::DEG2RAD; diff --git a/src/MESONT/bond_mesocnt.cpp b/src/MESONT/bond_mesocnt.cpp index 1623c4b1fc..5f468bd720 100644 --- a/src/MESONT/bond_mesocnt.cpp +++ b/src/MESONT/bond_mesocnt.cpp @@ -24,7 +24,6 @@ #include "force.h" #include "math_const.h" #include "memory.h" -#include "neighbor.h" #include "update.h" #include diff --git a/src/MESONT/pair_mesocnt.cpp b/src/MESONT/pair_mesocnt.cpp index 521c8c5f60..21b04268c4 100644 --- a/src/MESONT/pair_mesocnt.cpp +++ b/src/MESONT/pair_mesocnt.cpp @@ -34,26 +34,25 @@ #include #include #include -#include +#include +#include #include -#include using namespace LAMMPS_NS; using namespace MathExtra; using MathConst::MY_2PI; using MathConst::MY_PI; -#define MAXLINE 1024 -#define SELF_CUTOFF 3 -#define SMALL 1.0e-6 -#define SWITCH 1.0e-4 -#define RHOMIN 10.0 +static constexpr int SELF_CUTOFF = 3; +static constexpr double SMALL = 1.0e-6; +static constexpr double SWITCH = 1.0e-4; +static constexpr double RHOMIN = 10.0; -#define QUAD_FINF 129 -#define QUAD_FSEMI 10 +static constexpr int QUAD_FINF = 129; +static constexpr int QUAD_FSEMI = 10; -#define BISECTION_STEPS 1000000 -#define BISECTION_EPS 1.0e-15 +static constexpr int BISECTION_STEPS = 1000000; +static constexpr double BISECTION_EPS = 1.0e-15; /* ---------------------------------------------------------------------- */ diff --git a/src/MESONT/pair_mesocnt_viscous.cpp b/src/MESONT/pair_mesocnt_viscous.cpp index be3715be25..f7ad7b0aa6 100644 --- a/src/MESONT/pair_mesocnt_viscous.cpp +++ b/src/MESONT/pair_mesocnt_viscous.cpp @@ -25,7 +25,6 @@ #include "math_const.h" #include "math_extra.h" #include "memory.h" -#include "neigh_list.h" #include "neighbor.h" #include "update.h" @@ -35,11 +34,11 @@ using namespace LAMMPS_NS; using namespace MathExtra; using MathConst::MY_PI; -#define SELF_CUTOFF 3 -#define RHOMIN 10.0 +static constexpr int SELF_CUTOFF = 3; +static constexpr double RHOMIN = 10.0; -#define QUAD_FINF 129 -#define QUAD_FSEMI 10 +static constexpr int QUAD_FINF = 129; +static constexpr int QUAD_FSEMI = 10; /* ---------------------------------------------------------------------- */ diff --git a/src/MGPT/mgpt_readpot.cpp b/src/MGPT/mgpt_readpot.cpp index ab25a9e190..3cc5d5d693 100644 --- a/src/MGPT/mgpt_readpot.cpp +++ b/src/MGPT/mgpt_readpot.cpp @@ -156,7 +156,7 @@ static void getparmindata(const char *potin_file,int nvol[1],double vol0[1],doub void potdata::readpot(const char *parmin_file,const char *potin_file,const double vol) { FILE *in; - double x0,x1,dx,dr; + double x0,x1,dx; int nx; double r0x,r1x,drx; @@ -348,7 +348,7 @@ void potdata::readpot(const char *parmin_file,const char *potin_file,const doubl nrx = (int) ((r1x-r0x)/drx + 1.1); /* Really: 1+round((r1-r0)/dr) */ if (ii == 0) { - r0 = r0x; r1 = r1x; dr = drx; nr = nrx; + r0 = r0x; r1 = r1x; nr = nrx; vpairtab = new double[nx*nr]; } else { /* Check that {r0,r1,dr,nr}x == {r0,r1,dr,nr} */ @@ -373,15 +373,12 @@ void potdata::readpot(const char *parmin_file,const char *potin_file,const doubl double r0rws = r0rwstab[i]; double r00 = r0rws*rws,rp = 1.8*rws; if (bscreen == 0) r0rws = 10.0; - double alp = al,alm = al; - if (mode == 2 || mode == 4 || mode == 6) alm = 125.0; + double alp = al; al = alp; double r = r0 + j*(r1-r0)/(nr-1); double rrws = r/rws; - //double rsqr = r*r; - // double fl(double r,int mode,double rp,double p1,double al,double r0) double flr = fl(r,mode,rp,p1,al,r00,pn); double fl2 = flr*flr; double v2a = vatab[i]*fl2*fl2; @@ -390,17 +387,11 @@ void potdata::readpot(const char *parmin_file,const char *potin_file,const doubl if (bscreen == 1 && rrws >= r0rws) { double arg = rrws/r0rwstab[i]; - double arg1 = arg - 1.0; - double arg12 = arg1*arg1; - double f,dp; + double f; if (mode <= 2) { f = fgauss(arg,al); - dp=2.*al*arg*arg1; - } - else { + } else { f = hgauss(arg,al); - double arg13 = arg1*arg12; - dp=2.0*al*al*arg*arg13/(1.+al*arg12); } fscr = f*f; } diff --git a/src/MGPT/pair_mgpt.cpp b/src/MGPT/pair_mgpt.cpp index c924cbea84..986c3e4aef 100644 --- a/src/MGPT/pair_mgpt.cpp +++ b/src/MGPT/pair_mgpt.cpp @@ -39,7 +39,7 @@ using namespace LAMMPS_NS; -//#define TIMING_ON +// #define TIMING_ON #ifdef TIMING_ON #include @@ -49,13 +49,11 @@ using namespace LAMMPS_NS; #include #endif -static double gettime(int x = 0) { +static double gettime() { if (1) { - /* struct timeval tv; gettimeofday(&tv,nullptr); return tv.tv_sec + 1e-6 * tv.tv_usec; - */ /* const double x = 1.0 / CLOCKS_PER_SEC; return clock() * x; @@ -68,16 +66,17 @@ static double gettime(int x = 0) { return x*invfreq; */ + /* const double invfreq = 1.0 / 1.6e9; unsigned long long int x = GetTimeBase(); return x*invfreq; - + */ } else return 0.0; } #else -static double gettime(int /*x*/ = 0) { return 0.0; } +static double gettime() { return 0.0; } #endif @@ -569,6 +568,7 @@ void PairMGPT::force_debug_4(double xx[][3], #ifdef __bg__ #define const #endif +#ifdef TIMING_ON static int ntr_calls = 0; static trtrace3_fun tr_internal; static void tr_count(const double * restrict A, @@ -578,6 +578,7 @@ static void tr_count(const double * restrict A, tr_internal(A,B1,t1,B2,t2,B3,t3); ntr_calls++; } +#endif #ifdef __bg__ #undef const #endif @@ -589,34 +590,33 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, double *e_s,double *e_p,double *e_t,double *e_q, int evflag,int newton_pair) { Hash bond_hash(100000); - int i,j,k,m,ix,jx,kx,mx,p; + int i,j,k,m,ix,jx,kx,p; double e_single,e_pair,e_triplet,e_triplet_c,e_quad; double volvir2; - +#ifdef TIMING_ON double nbc = 0.0,tbl = 0.0,tbm = 0.0; - const int lmax_local = lmax; - - //if(evflag) printf("##### ev flag is set... wasting cycles...\n"); - +#endif *e_s = -99.0; *e_p = -99.0; *e_t = -99.0; *e_q = -99.0; - double t0,t1; - - t0 = gettime(1); +#ifdef TIMING_ON + double t0 = gettime(); +#endif e_single = e_pair = e_triplet = e_triplet_c = e_quad = 0.0; volvir2 = 0.0; t_make_t = t_make_b = t_make_b2 = t_trace = 0.0; n_make = n_make_b2 = n_trace = 0.0; - double tx0,tx1,tsort = 0.0,tpair = 0.0,tlookup = 0.0; +#ifdef TIMING_ON + double tsort = 0.0, tpair = 0.0,tlookup = 0.0; double ttriplet = 0.0,tquad = 0.0,tmem = 0.0; double ntsort = 0.0,ntpair = 0.0,ntlookup = 0.0; double nttriplet = 0.0,ntquad = 0.0,ntmem = 0.0,ntquaditer = 0.0; double mcount = 0.0,mcount2 = 0.0, qcount = 0.0; +#endif double fix,fjx,fkx,fmx,dfix,dfjx,dfkx,dfmx; double fiy,fjy,fky,fmy,dfiy,dfjy,dfky,dfmy; @@ -670,8 +670,9 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, double trd1y,trd2y,trd3y,trd4y; double trd1z,trd2z,trd3z,trd4z; - - tx0 = gettime(); +#ifdef TIMING_ON + double tx0 = gettime(); +#endif double rhoinv; { @@ -751,9 +752,11 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, first = (int *) memory->smalloc(sizeof(int) * (ntot+1),"mgpt: first"); nlist_short = (int *) memory->smalloc(sizeof(int) * nneitot,"mgpt: nlist_short"); - tx1 = gettime(); +#ifdef TIMING_ON + double tx1 = gettime(); tmem += tx1-tx0; ntmem++; +#endif //printf("[%3d] Starting calculation...\n",comm->me); @@ -762,7 +765,9 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, fiy = fjy = fky = fmy = 0.0; fiz = fjz = fkz = fmz = 0.0; +#ifdef TIMING_ON int c_p = 0, c_t = 0, c_q = 0; +#endif if (false) if (domain->triclinic) { @@ -786,7 +791,9 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, const int c1 = c1_outside(ss[i],triclinic,alpha); +#ifdef TIMING_ON tx0 = gettime(); +#endif for (jx = 0; jxH.m[1][0]), @@ -1042,8 +1055,9 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, } if (T12 != nullptr) { - //printf("T12 i,j,k = %d,%d,%d\n",i,j,k); +#ifdef TIMING_ON mcount++; +#endif if (three_body_energies && evflag) { tr1 = transtrace(T12->H1H2,T12->H1H2); double dvir = (2.0*(dvir_ij + dvir_jk)*splinepot.vd + @@ -1098,8 +1112,9 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, } if (T23 != nullptr) { - //printf("T23 i,j,k = %d,%d,%d\n",i,j,k); +#ifdef TIMING_ON mcount++; +#endif if (three_body_energies && evflag) { tr2 = transtrace(T23->H1H2,T23->H1H2); double dvir = (2.0*(dvir_jk + dvir_ki)*splinepot.vd + @@ -1154,8 +1169,9 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, } if (T31 != nullptr) { - //printf("T31 i,j,k = %d,%d,%d\n",i,j,k); +#ifdef TIMING_ON mcount++; +#endif if (three_body_energies && evflag) { tr3 = transtrace(T31->H1H2,T31->H1H2); double dvir = (2.0*(dvir_ki + dvir_ij)*splinepot.vd + @@ -1214,8 +1230,9 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, double de_triplet = (splinepot.vc*v33 + splinepot.vd*v43) * e_scale * w3; e_triplet = e_triplet + de_triplet; e_triplet_c = e_triplet_c + splinepot.vc*v33 * e_scale * w3; +#ifdef TIMING_ON c_t++; - +#endif //printf("xxxx %6d %6d %6d :: %20.10e\n",1,2,3,de_triplet); if (evflag) { @@ -1246,16 +1263,20 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, fkx = fkx+fsave[2][0]; fky = fky+fsave[2][1]; fkz = fkz+fsave[2][2]; } +#ifdef TIMING_ON tx1 = gettime(); ttriplet += tx1 - tx0; nttriplet++; +#endif } else { triplet_defer = 1; } if (four_body_energies || four_body_forces) if (j < i) { /* Search for quadruplet */ +#ifdef TIMING_ON tx0 = gettime(); +#endif mj = first[j]; mk = first[k]; @@ -1342,8 +1363,9 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, vir4 = vir4 + dvir; xvir4 = xvir4 + dvir; } +#ifdef TIMING_ON qcount++; - +#endif { const double ve = splinepot.ve; @@ -1371,8 +1393,9 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, vir4 = vir4 + dvir; xvir4 = xvir4 + dvir; } +#ifdef TIMING_ON qcount++; - +#endif { const double ve = splinepot.ve; @@ -1401,8 +1424,9 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, vir4 = vir4 + dvir; xvir4 = xvir4 + dvir; } +#ifdef TIMING_ON qcount++; - +#endif { const double ve = splinepot.ve; @@ -1425,11 +1449,13 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, double de_quad = splinepot.ve*(tr1 + tr2 + tr3)/anorm4 * e_scale * w4; e_quad = e_quad + de_quad; +#ifdef TIMING_ON if ((T12 && T45) || (T23 && T56) || (T31 && T64)) { c_q++; } +#endif if (evflag) { double drim[3],drjm[3],drkm[3]; @@ -1479,10 +1505,12 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, } } +#ifdef TIMING_ON tx1 = gettime(); tquad += tx1 - tx0; ntquad++; ntquaditer++; +#endif } @@ -1514,12 +1542,12 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, for (int pp = 0; pp<3; pp++) vatom[i][pp] = vatom[i][pp] - rhoinv*splinepot.devol0*e_scale; } - } - } +#ifdef TIMING_ON tx0 = gettime(); +#endif for (i = 0; if[i][p] = atom->f[i][p] + ff[i][p]; @@ -1529,20 +1557,16 @@ void PairMGPT::compute_x(const int *nnei,const int * const *nlist, if (ss != xx) memory->sfree(ss); memory->sfree(ff); memory->sfree(xx); +#ifdef TIMING_ON tx1 = gettime(); tmem += tx1-tx0; ntmem++; - t1 = gettime(1); + double t1 = gettime(); - //printf("compute_x: c_p = %d c_t = %d c_q = %d\n",c_p,c_t,c_q); - - -#ifdef TIMING_ON if (comm->me == 0) { double tsum = (tmem+tsort+tpair+tlookup+ttriplet+tquad); double nsum = (ntmem+ntsort+ntpair+ntlookup+nttriplet+ntquad); - //double adj = ((t1-t0)-tsum)/nsum; /* Use adj = 6ns for RDTSC, and 58ns for gettimeofday, on monkfish.llnl.gov, 2.4GHz Intel @@ -1832,7 +1856,7 @@ void PairMGPT::coeff(int narg, char **arg) single_precision = 0; /* Parse arguments */ { - int volpres_tag = 0,precision_tag = 0,nbody_tag = 0; + int nbody_tag = 0; int iarg = 5; while (iarg < narg) { @@ -1848,7 +1872,6 @@ void PairMGPT::coeff(int narg, char **arg) "The value is \"%s\".\n",FLERR,arg[iarg+1]); error->all(FLERR,line); } - volpres_tag = 1; iarg += 2; if (comm->me == 0) printf("* volpress: volpres_flag = %d [%s %s]\n",volpres_flag,arg[iarg-2],arg[iarg-1]); } else if (strcmp(arg[iarg],"nbody") == 0) { @@ -1884,7 +1907,6 @@ void PairMGPT::coeff(int narg, char **arg) "The value is \"%s\".\n",FLERR,arg[iarg+1]); error->all(FLERR,line); } - precision_tag = 1; iarg += 2; if (comm->me == 0) printf("* precision: single_flag = %d [%s %s]\n",single_precision,arg[iarg-2],arg[iarg-1]); } else { diff --git a/src/MGPT/pair_mgpt.h b/src/MGPT/pair_mgpt.h index 409643c059..3168a3c41d 100644 --- a/src/MGPT/pair_mgpt.h +++ b/src/MGPT/pair_mgpt.h @@ -273,6 +273,8 @@ public: void allocate(); struct Matrix { + Matrix() = default; + Matrix(const Matrix &) = default; static int sz; double m[8][8]; diff --git a/src/MISC/pair_agni.cpp b/src/MISC/pair_agni.cpp index 8597e5db93..cbc6cf6c92 100644 --- a/src/MISC/pair_agni.cpp +++ b/src/MISC/pair_agni.cpp @@ -47,9 +47,6 @@ static const char cite_pair_agni[] = " year = {2019},\n" "}\n\n"; -#define MAXLINE 10240 -#define MAXWORD 40 - /* ---------------------------------------------------------------------- */ PairAGNI::PairAGNI(LAMMPS *lmp) : Pair(lmp) diff --git a/src/MISC/pair_srp.cpp b/src/MISC/pair_srp.cpp index ddcfb92e9c..31f5b85760 100644 --- a/src/MISC/pair_srp.cpp +++ b/src/MISC/pair_srp.cpp @@ -47,8 +47,8 @@ Please contact Timothy Sirk for questions (tim.sirk@us.army.mil). using namespace LAMMPS_NS; -#define SMALL 1.0e-10 -#define BIG 1e10 +static constexpr double SMALL = 1.0e-10; +static constexpr double BIG = 1e10; #define ONETWOBIT 0x40000000 static const char cite_srp[] = diff --git a/src/ML-IAP/compute_mliap.cpp b/src/ML-IAP/compute_mliap.cpp index 46b2958924..ac9d2dd1c4 100644 --- a/src/ML-IAP/compute_mliap.cpp +++ b/src/ML-IAP/compute_mliap.cpp @@ -19,13 +19,13 @@ #include "compute_mliap.h" #include "mliap_data.h" -#include "mliap_model_linear.h" -#include "mliap_model_quadratic.h" #include "mliap_descriptor_snap.h" #include "mliap_descriptor_so3.h" #ifdef MLIAP_ACE #include "mliap_descriptor_ace.h" #endif +#include "mliap_model_linear.h" +#include "mliap_model_quadratic.h" #ifdef MLIAP_PYTHON #include "mliap_model_python.h" #endif @@ -44,17 +44,17 @@ using namespace LAMMPS_NS; -enum{SCALAR,VECTOR,ARRAY}; +enum { SCALAR, VECTOR, ARRAY }; ComputeMLIAP::ComputeMLIAP(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg), mliaparray(nullptr), - mliaparrayall(nullptr), map(nullptr) + Compute(lmp, narg, arg), mliaparray(nullptr), mliaparrayall(nullptr), list(nullptr), + map(nullptr), model(nullptr), descriptor(nullptr), data(nullptr), c_pe(nullptr), + c_virial(nullptr) { array_flag = 1; extarray = 0; - if (narg < 4) - error->all(FLERR,"Illegal compute mliap command"); + if (narg < 4) utils::missing_cmd_args(FLERR, "compute mliap", error); // default values @@ -141,7 +141,6 @@ ComputeMLIAP::ComputeMLIAP(LAMMPS *lmp, int narg, char **arg) : ComputeMLIAP::~ComputeMLIAP() { - modify->delete_compute(id_virial); memory->destroy(mliaparray); @@ -191,23 +190,13 @@ void ComputeMLIAP::init() // find compute for reference energy - std::string id_pe = std::string("thermo_pe"); - int ipe = modify->find_compute(id_pe); - if (ipe == -1) - error->all(FLERR,"compute thermo_pe does not exist."); - c_pe = modify->compute[ipe]; + c_pe = modify->get_compute_by_id("thermo_pe"); + if (!c_pe) error->all(FLERR,"Compute thermo_pe does not exist."); // add compute for reference virial tensor id_virial = id + std::string("_press"); - std::string pcmd = id_virial + " all pressure NULL virial"; - modify->add_compute(pcmd); - - int ivirial = modify->find_compute(id_virial); - if (ivirial == -1) - error->all(FLERR,"compute mliap_press does not exist."); - c_virial = modify->compute[ivirial]; - + c_virial = modify->add_compute(id_virial + " all pressure NULL virial"); } diff --git a/src/ML-IAP/mliap_descriptor_snap.cpp b/src/ML-IAP/mliap_descriptor_snap.cpp index cec03fca76..e8f6eec977 100644 --- a/src/ML-IAP/mliap_descriptor_snap.cpp +++ b/src/ML-IAP/mliap_descriptor_snap.cpp @@ -31,8 +31,7 @@ using namespace LAMMPS_NS; -#define MAXLINE 1024 -#define MAXWORD 3 +static constexpr int MAXLINE = 1024; /* ---------------------------------------------------------------------- */ @@ -380,7 +379,8 @@ void MLIAPDescriptorSNAP::read_paramfile(char *paramfilename) utils::getsyserror()); } - char line[MAXLINE], *ptr; + char line[MAXLINE] = {'\0'}; + char *ptr; int eof = 0; int n; diff --git a/src/ML-IAP/mliap_descriptor_so3.cpp b/src/ML-IAP/mliap_descriptor_so3.cpp index 4f976f06be..676c53a4a8 100644 --- a/src/ML-IAP/mliap_descriptor_so3.cpp +++ b/src/ML-IAP/mliap_descriptor_so3.cpp @@ -30,8 +30,7 @@ using namespace LAMMPS_NS; -#define MAXLINE 1024 -#define MAXWORD 3 +static constexpr int MAXLINE = 1024; /* ---------------------------------------------------------------------- */ @@ -90,7 +89,8 @@ void MLIAPDescriptorSO3::read_paramfile(char *paramfilename) utils::getsyserror()); } - char line[MAXLINE], *ptr; + char line[MAXLINE] = {'\0'}; + char *ptr; int eof = 0; int n, nwords; diff --git a/src/ML-IAP/mliap_model.cpp b/src/ML-IAP/mliap_model.cpp index a93090d364..232bf18bbd 100644 --- a/src/ML-IAP/mliap_model.cpp +++ b/src/ML-IAP/mliap_model.cpp @@ -26,8 +26,7 @@ using namespace LAMMPS_NS; -#define MAXLINE 1024 -#define MAXWORD 3 +static constexpr int MAXLINE = 1024; /* ---------------------------------------------------------------------- */ @@ -93,7 +92,8 @@ void MLIAPModelSimple::read_coeffs(char *coefffilename) utils::getsyserror()); } - char line[MAXLINE], *ptr; + char line[MAXLINE] = {'\0'}; + char *ptr; int eof = 0; int n; diff --git a/src/ML-IAP/mliap_model_nn.cpp b/src/ML-IAP/mliap_model_nn.cpp index 6c039f9a07..6695109f91 100644 --- a/src/ML-IAP/mliap_model_nn.cpp +++ b/src/ML-IAP/mliap_model_nn.cpp @@ -28,7 +28,7 @@ using namespace LAMMPS_NS; -#define MAXLINE 1024 +static constexpr int MAXLINE = 1024; /* ---------------------------------------------------------------------- */ @@ -75,7 +75,8 @@ void MLIAPModelNN::read_coeffs(char *coefffilename) utils::getsyserror()); } - char line[MAXLINE], *ptr; + char line[MAXLINE] = {'\0'}; + char *ptr; int n, eof = 0, nwords = 0; while (nwords == 0) { if (comm->me == 0) { diff --git a/src/ML-IAP/mliap_so3.cpp b/src/ML-IAP/mliap_so3.cpp index 72ca466ab3..bfdde4b968 100644 --- a/src/ML-IAP/mliap_so3.cpp +++ b/src/ML-IAP/mliap_so3.cpp @@ -31,7 +31,7 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define SMALL 1.0e-8 +static constexpr double SMALL = 1.0e-8; /* ---------------------------------------------------------------------- */ diff --git a/src/ML-IAP/mliap_unified.cpp b/src/ML-IAP/mliap_unified.cpp index de1d0bcb7d..7697204e44 100644 --- a/src/ML-IAP/mliap_unified.cpp +++ b/src/ML-IAP/mliap_unified.cpp @@ -254,10 +254,8 @@ void LAMMPS_NS::update_pair_energy(MLIAPData *data, double *eij) double e = 0.5 * eij[ii]; // must not count any contribution where i is not a local atom - if (i < nlocal) { - data->eatoms[i] += e; - e_total += e; - } + data->eatoms[i] += e; + e_total += e; } data->energy = e_total; } @@ -277,17 +275,14 @@ void LAMMPS_NS::update_pair_forces(MLIAPData *data, double *fij) int i = data->pair_i[ii]; int j = data->jatoms[ii]; - // must not count any contribution where i is not a local atom - if (i < nlocal) { - f[i][0] += fij[ii3]; - f[i][1] += fij[ii3 + 1]; - f[i][2] += fij[ii3 + 2]; - f[j][0] -= fij[ii3]; - f[j][1] -= fij[ii3 + 1]; - f[j][2] -= fij[ii3 + 2]; + f[i][0] += fij[ii3]; + f[i][1] += fij[ii3 + 1]; + f[i][2] += fij[ii3 + 2]; + f[j][0] -= fij[ii3]; + f[j][1] -= fij[ii3 + 1]; + f[j][2] -= fij[ii3 + 2]; - if (data->vflag) data->pairmliap->v_tally(i, j, &fij[ii3], data->rij[ii]); - } + if (data->vflag) data->pairmliap->v_tally(i, j, &fij[ii3], data->rij[ii]); } } diff --git a/src/ML-IAP/mliap_unified_couple.pyx b/src/ML-IAP/mliap_unified_couple.pyx index 3148b96b51..6c8331d0fa 100644 --- a/src/ML-IAP/mliap_unified_couple.pyx +++ b/src/ML-IAP/mliap_unified_couple.pyx @@ -8,6 +8,7 @@ import lammps.mliap cimport cython from cpython.ref cimport PyObject from libc.stdlib cimport malloc, free +from libc.string cimport memcpy cdef extern from "lammps.h" namespace "LAMMPS_NS": @@ -387,15 +388,26 @@ cdef public object mliap_unified_connect(char *fname, MLIAPDummyModel * model, cdef int nelements = len(unified.element_types) cdef char **elements = malloc(nelements * sizeof(char*)) + cdef char * c_str + cdef char * s + cdef ssize_t slen if not elements: raise MemoryError("failed to allocate memory for element names") - cdef char *elem_name for i, elem in enumerate(unified.element_types): - elem_name_bytes = elem.encode('UTF-8') - elem_name = elem_name_bytes - elements[i] = &elem_name[0] + py_str = elem.encode('UTF-8') + + s = py_str + slen = len(py_str) + c_str = malloc((slen+1)*sizeof(char)) + if not c_str: + raise MemoryError("failed to allocate memory for element names") + memcpy(c_str, s, slen) + c_str[slen] = 0 + + elements[i] = c_str + unified_int.descriptor.set_elements(elements, nelements) unified_int.model.nelements = nelements diff --git a/src/ML-PACE/compute_pace.cpp b/src/ML-PACE/compute_pace.cpp index b96432cfe3..fee9a0fa0e 100644 --- a/src/ML-PACE/compute_pace.cpp +++ b/src/ML-PACE/compute_pace.cpp @@ -11,24 +11,21 @@ ------------------------------------------------------------------------- */ #include "compute_pace.h" -#include "ace-evaluator/ace_evaluator.h" + #include "ace-evaluator/ace_c_basis.h" -#include "ace-evaluator/ace_abstract_basis.h" +#include "ace-evaluator/ace_evaluator.h" #include "ace-evaluator/ace_types.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 "memory.h" #include "error.h" +#include "force.h" +#include "memory.h" +#include "modify.h" +#include "neigh_list.h" +#include "neighbor.h" +#include "pair.h" +#include "update.h" namespace LAMMPS_NS { struct ACECimpl { @@ -41,14 +38,14 @@ struct ACECimpl { ACECTildeBasisSet *basis_set; ACECTildeEvaluator *ace; }; -} +} // namespace LAMMPS_NS using namespace LAMMPS_NS; enum { SCALAR, VECTOR, ARRAY }; ComputePACE::ComputePACE(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg), cutsq(nullptr), list(nullptr), pace(nullptr), paceall(nullptr), - pace_peratom(nullptr), map(nullptr), cg(nullptr), c_pe(nullptr), c_virial(nullptr) + Compute(lmp, narg, arg), cutsq(nullptr), list(nullptr), pace(nullptr), paceall(nullptr), + pace_peratom(nullptr), map(nullptr), c_pe(nullptr), c_virial(nullptr), acecimpl(nullptr) { array_flag = 1; extarray = 0; @@ -111,6 +108,8 @@ ComputePACE::ComputePACE(LAMMPS *lmp, int narg, char **arg) : ComputePACE::~ComputePACE() { + modify->delete_compute(id_virial); + delete acecimpl; memory->destroy(pace); memory->destroy(paceall); @@ -132,10 +131,7 @@ void ComputePACE::init() // need an occasional full neighbor list neighbor->add_request(this, NeighConst::REQ_FULL | NeighConst::REQ_OCCASIONAL); - int count = 0; - for (int i = 0; i < modify->ncompute; i++) - if (strcmp(modify->compute[i]->style,"pace") == 0) count++; - if (count > 1 && comm->me == 0) + if (modify->get_compute_by_style("pace").size() > 1 && comm->me == 0) error->warning(FLERR,"More than one compute pace"); // allocate memory for global array @@ -145,22 +141,13 @@ void ComputePACE::init() // find compute for reference energy - std::string id_pe = std::string("thermo_pe"); - int ipe = modify->find_compute(id_pe); - if (ipe == -1) - error->all(FLERR,"compute thermo_pe does not exist."); - c_pe = modify->compute[ipe]; + c_pe = modify->get_compute_by_id("thermo_pe"); + if (!c_pe) error->all(FLERR,"Compute thermo_pe does not exist."); // add compute for reference virial tensor - std::string id_virial = std::string("pace_press"); - std::string pcmd = id_virial + " all pressure NULL virial"; - modify->add_compute(pcmd); - - int ivirial = modify->find_compute(id_virial); - if (ivirial == -1) - error->all(FLERR,"compute pace_press does not exist."); - c_virial = modify->compute[ivirial]; + id_virial = id + std::string("_press"); + c_virial = modify->add_compute(id_virial + " all pressure NULL virial"); } /* ---------------------------------------------------------------------- */ diff --git a/src/ML-PACE/compute_pace.h b/src/ML-PACE/compute_pace.h index 496c8a16d3..23243b0066 100644 --- a/src/ML-PACE/compute_pace.h +++ b/src/ML-PACE/compute_pace.h @@ -43,10 +43,11 @@ class ComputePACE : public Compute { double **pace_peratom; int *map; // map types to [0,nelements) int bikflag, bik_rows, dgradflag, dgrad_rows; - double *cg; double cutmax; + Compute *c_pe; Compute *c_virial; + std::string id_virial; void dbdotr_compute(); struct ACECimpl *acecimpl; diff --git a/src/ML-PACE/pair_pace_extrapolation.cpp b/src/ML-PACE/pair_pace_extrapolation.cpp index d9b8d3588a..ec42d232af 100644 --- a/src/ML-PACE/pair_pace_extrapolation.cpp +++ b/src/ML-PACE/pair_pace_extrapolation.cpp @@ -29,15 +29,12 @@ Copyright 2022 Yury Lysogorskiy^1, Anton Bochkarev^1, Matous Mrovec^1, Ralf Drau #include "force.h" #include "math_const.h" #include "memory.h" -#include "modify.h" #include "neigh_list.h" -#include "neigh_request.h" #include "neighbor.h" #include "update.h" -#include -#include #include +#include #include "ace/ace_b_basis.h" #include "ace/ace_b_evaluator.h" diff --git a/src/ML-PACE/pair_pace_extrapolation.h b/src/ML-PACE/pair_pace_extrapolation.h index 2dcec04d4b..440d999029 100644 --- a/src/ML-PACE/pair_pace_extrapolation.h +++ b/src/ML-PACE/pair_pace_extrapolation.h @@ -28,7 +28,6 @@ PairStyle(pace/extrapolation,PairPACEExtrapolation) #define LMP_PAIR_PACE_AL_H #include "pair.h" -#include namespace LAMMPS_NS { diff --git a/src/ML-POD/fitpod_command.cpp b/src/ML-POD/fitpod_command.cpp index 87de65c3e2..ef39962e0b 100644 --- a/src/ML-POD/fitpod_command.cpp +++ b/src/ML-POD/fitpod_command.cpp @@ -33,8 +33,7 @@ using namespace LAMMPS_NS; using MathSpecial::powint; -#define MAXLINE 1024 - +static constexpr int MAXLINE = 1024; static constexpr double SMALL = 1.0e-10; FitPOD::FitPOD(LAMMPS *_lmp) : Command(_lmp), podptr(nullptr) @@ -151,7 +150,8 @@ int FitPOD::read_data_file(double *fitting_weights, std::string &file_format, // loop through lines of training data file and parse keywords - char line[MAXLINE],*ptr; + char line[MAXLINE] = {'\0'}; + char *ptr; int eof = 0; while (true) { if (comm->me == 0) { @@ -252,7 +252,8 @@ int FitPOD::get_number_atom_exyz(std::vector& num_atom, int& num_atom_sum, error->one(FLERR,"Cannot open POD coefficient file {}: ", filename, utils::getsyserror()); } - char line[MAXLINE],*ptr; + char line[MAXLINE] = {'\0'}; + char *ptr; int eof = 0; int num_configs = 0; num_atom_sum = 0; @@ -324,7 +325,8 @@ void FitPOD::read_exyz_file(double *lattice, double *stress, double *energy, dou error->one(FLERR,"Cannot open POD coefficient file {}: ", filename, utils::getsyserror()); } - char line[MAXLINE],*ptr; + char line[MAXLINE] = {'\0'}; + char *ptr; int eof = 0; int cfi = 0; int nat = 0; diff --git a/src/ML-POD/mlpod.cpp b/src/ML-POD/mlpod.cpp index f20498b50b..088b9abadc 100644 --- a/src/ML-POD/mlpod.cpp +++ b/src/ML-POD/mlpod.cpp @@ -35,7 +35,7 @@ using MathConst::MY_PI; using MathSpecial::cube; using MathSpecial::powint; -#define MAXLINE 1024 +static constexpr int MAXLINE = 1024; MLPOD::podstruct::podstruct() : twobody{4, 8, 6}, threebody{4, 8, 5, 4}, fourbody{0, 0, 0, 0}, pbc(nullptr), @@ -302,7 +302,8 @@ void MLPOD::read_pod(const std::string &pod_file) // loop through lines of POD file and parse keywords - char line[MAXLINE],*ptr; + char line[MAXLINE] = {'\0'}; + char *ptr; int eof = 0; while (true) { if (comm->me == 0) { @@ -639,7 +640,8 @@ void MLPOD::read_coeff_file(const std::string &coeff_file) // check format for first line of file - char line[MAXLINE],*ptr; + char line[MAXLINE] = {'\0'}; + char *ptr; int eof = 0; int nwords = 0; while (nwords == 0) { diff --git a/src/ML-RANN/pair_rann.cpp b/src/ML-RANN/pair_rann.cpp index f2948cbb43..4ec1f45703 100644 --- a/src/ML-RANN/pair_rann.cpp +++ b/src/ML-RANN/pair_rann.cpp @@ -55,7 +55,7 @@ DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 #include "rann_fingerprint_radialscreenedspin.h" #include "rann_fingerprint_radialspin.h" -#define MAXLINE 1024 +static constexpr int MAXLINE = 1024; using namespace LAMMPS_NS; @@ -616,7 +616,8 @@ void PairRANN::read_weight(std::vector line,std::vector line,std::vector line1,FILE* fp,char *filename,int *linenum) { int i,j,l; - char linetemp[MAXLINE],*ptr; + char linetemp[MAXLINE] = {'\0'}; + char *ptr; for (l=0;lone(filename,*linenum-1,"networklayers must be defined before biases."); diff --git a/src/ML-SNAP/compute_sna_atom.cpp b/src/ML-SNAP/compute_sna_atom.cpp index b1b4a46482..c3582f200c 100644 --- a/src/ML-SNAP/compute_sna_atom.cpp +++ b/src/ML-SNAP/compute_sna_atom.cpp @@ -26,6 +26,7 @@ #include "memory.h" #include "error.h" +#include #include using namespace LAMMPS_NS; diff --git a/src/ML-SNAP/compute_snap.cpp b/src/ML-SNAP/compute_snap.cpp index 3141791f6c..99a9a96361 100644 --- a/src/ML-SNAP/compute_snap.cpp +++ b/src/ML-SNAP/compute_snap.cpp @@ -30,14 +30,13 @@ using namespace LAMMPS_NS; -enum{SCALAR,VECTOR,ARRAY}; +enum { SCALAR, VECTOR, ARRAY }; ComputeSnap::ComputeSnap(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg), cutsq(nullptr), list(nullptr), snap(nullptr), - snapall(nullptr), snap_peratom(nullptr), radelem(nullptr), wjelem(nullptr), - sinnerelem(nullptr), dinnerelem(nullptr), snaptr(nullptr) + Compute(lmp, narg, arg), cutsq(nullptr), list(nullptr), snap(nullptr), snapall(nullptr), + snap_peratom(nullptr), radelem(nullptr), wjelem(nullptr), map(nullptr), sinnerelem(nullptr), + dinnerelem(nullptr), snaptr(nullptr), c_pe(nullptr), c_virial(nullptr) { - array_flag = 1; extarray = 0; @@ -172,22 +171,18 @@ ComputeSnap::ComputeSnap(LAMMPS *lmp, int narg, char **arg) : } if (switchinnerflag && !(sinnerflag && dinnerflag)) - error->all( - FLERR, - "Illegal compute {} command: switchinnerflag = 1, missing sinner/dinner keyword", - style); + error->all(FLERR, "Illegal compute {} command: switchinnerflag = 1, " + "missing sinner/dinner keyword", style); if (!switchinnerflag && (sinnerflag || dinnerflag)) - error->all( - FLERR, - "Illegal compute {} command: switchinnerflag = 0, unexpected sinner/dinner keyword", - style); + error->all(FLERR, "Illegal compute {} command: switchinnerflag = 0, " + "unexpected sinner/dinner keyword", style); if (dgradflag && !bikflag) - error->all(FLERR,"Illegal compute snap command: dgradflag=1 requires bikflag=1"); + error->all(FLERR, "Illegal compute snap command: dgradflag=1 requires bikflag=1"); if (dgradflag && quadraticflag) - error->all(FLERR,"Illegal compute snap command: dgradflag=1 not implemented for quadratic SNAP"); + error->all(FLERR, "Illegal compute snap command: dgradflag=1 not implemented for quadratic SNAP"); snaptr = new SNA(lmp, rfac0, twojmax, rmin0, switchflag, bzeroflag, chemflag, bnormflag, wselfallflag, nelements, switchinnerflag); @@ -210,7 +205,8 @@ ComputeSnap::ComputeSnap(LAMMPS *lmp, int narg, char **arg) : if (dgradflag) { size_array_rows = bik_rows + 3*natoms*natoms + 1; size_array_cols = nvalues + 3; - error->warning(FLERR,"dgradflag=1 creates a N^2 array, beware of large systems."); + if (comm->me == 0) + error->warning(FLERR, "dgradflag=1 creates a N^2 array, beware of large systems."); } else size_array_cols = nvalues*atom->ntypes + 1; lastcol = size_array_cols-1; @@ -249,7 +245,8 @@ void ComputeSnap::init() error->all(FLERR,"Compute snap requires a pair style be defined"); if (cutmax > force->pair->cutforce) - error->all(FLERR,"Compute snap cutoff is longer than pairwise cutoff"); + error->all(FLERR,"Compute snap cutoff {} is longer than pairwise cutoff {}", + cutmax, force->pair->cutforce); // need an occasional full neighbor list @@ -261,31 +258,19 @@ void ComputeSnap::init() // allocate memory for global array - memory->create(snap,size_array_rows,size_array_cols, - "snap:snap"); - memory->create(snapall,size_array_rows,size_array_cols, - "snap:snapall"); + memory->create(snap,size_array_rows,size_array_cols, "snap:snap"); + memory->create(snapall,size_array_rows,size_array_cols, "snap:snapall"); array = snapall; - // find compute for reference energy + // find compute for global reference potential energy - std::string id_pe = std::string("thermo_pe"); - int ipe = modify->find_compute(id_pe); - if (ipe == -1) - error->all(FLERR,"compute thermo_pe does not exist."); - c_pe = modify->compute[ipe]; + c_pe = modify->get_compute_by_id("thermo_pe"); + if (!c_pe) error->all(FLERR,"compute thermo_pe does not exist."); - // add compute for reference virial tensor - - std::string id_virial = std::string("snap_press"); - std::string pcmd = id_virial + " all pressure NULL virial"; - modify->add_compute(pcmd); - - int ivirial = modify->find_compute(id_virial); - if (ivirial == -1) - error->all(FLERR,"compute snap_press does not exist."); - c_virial = modify->compute[ivirial]; + // add compute for global reference virial tensor + id_virial = id + std::string("_press"); + c_virial = modify->add_compute(id_virial + " all pressure NULL virial"); } @@ -309,8 +294,7 @@ void ComputeSnap::compute_array() if (atom->nmax > nmax) { memory->destroy(snap_peratom); nmax = atom->nmax; - memory->create(snap_peratom,nmax,size_peratom, - "snap:snap_peratom"); + memory->create(snap_peratom,nmax,size_peratom, "snap:snap_peratom"); } // clear global array diff --git a/src/ML-SNAP/compute_snap.h b/src/ML-SNAP/compute_snap.h index 2b8b972bbc..fe0b35d9e3 100644 --- a/src/ML-SNAP/compute_snap.h +++ b/src/ML-SNAP/compute_snap.h @@ -28,6 +28,7 @@ class ComputeSnap : public Compute { public: ComputeSnap(class LAMMPS *, int, char **); ~ComputeSnap() override; + void init() override; void init_list(int, class NeighList *) override; void compute_array() override; @@ -56,10 +57,10 @@ class ComputeSnap : public Compute { Compute *c_pe; Compute *c_virial; + std::string id_virial; void dbdotr_compute(); }; - } // namespace LAMMPS_NS #endif diff --git a/src/ML-SNAP/pair_snap.cpp b/src/ML-SNAP/pair_snap.cpp index 3029e9212d..ff6409095d 100644 --- a/src/ML-SNAP/pair_snap.cpp +++ b/src/ML-SNAP/pair_snap.cpp @@ -29,8 +29,7 @@ using namespace LAMMPS_NS; -#define MAXLINE 1024 -#define MAXWORD 3 +static constexpr int MAXLINE = 1024; /* ---------------------------------------------------------------------- */ @@ -475,7 +474,8 @@ void PairSNAP::read_files(char *coefffilename, char *paramfilename) coefffilename, utils::getsyserror()); } - char line[MAXLINE],*ptr; + char line[MAXLINE] = {'\0'}; + char *ptr; int eof = 0; int nwords = 0; while (nwords == 0) { diff --git a/src/MOFFF/angle_class2_p6.cpp b/src/MOFFF/angle_class2_p6.cpp index bfa6a068f5..39dec0d9d6 100644 --- a/src/MOFFF/angle_class2_p6.cpp +++ b/src/MOFFF/angle_class2_p6.cpp @@ -34,7 +34,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/MOFFF/angle_cosine_buck6d.cpp b/src/MOFFF/angle_cosine_buck6d.cpp index dbdf39292e..0ab9cbbf1f 100644 --- a/src/MOFFF/angle_cosine_buck6d.cpp +++ b/src/MOFFF/angle_cosine_buck6d.cpp @@ -34,7 +34,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/MOFFF/improper_inversion_harmonic.cpp b/src/MOFFF/improper_inversion_harmonic.cpp index 817b35332a..c0de968626 100644 --- a/src/MOFFF/improper_inversion_harmonic.cpp +++ b/src/MOFFF/improper_inversion_harmonic.cpp @@ -31,13 +31,9 @@ #include "memory.h" #include "error.h" - using namespace LAMMPS_NS; using namespace MathConst; -#define TOLERANCE 0.05 -#define SMALL 0.001 - /* ---------------------------------------------------------------------- */ ImproperInversionHarmonic::ImproperInversionHarmonic(LAMMPS *lmp) : Improper(lmp) diff --git a/src/MOFFF/pair_buck6d_coul_gauss_long.cpp b/src/MOFFF/pair_buck6d_coul_gauss_long.cpp index a750fea084..2ccc921448 100644 --- a/src/MOFFF/pair_buck6d_coul_gauss_long.cpp +++ b/src/MOFFF/pair_buck6d_coul_gauss_long.cpp @@ -36,7 +36,7 @@ using namespace LAMMPS_NS; -#define EWALD_F 1.12837917 +static constexpr double EWALD_F = 1.12837917; /* ---------------------------------------------------------------------- */ diff --git a/src/MOLECULE/angle_table.cpp b/src/MOLECULE/angle_table.cpp index c5e65be402..b1984a6918 100644 --- a/src/MOLECULE/angle_table.cpp +++ b/src/MOLECULE/angle_table.cpp @@ -38,8 +38,8 @@ using MathConst::RAD2DEG; enum { LINEAR, SPLINE }; -#define SMALL 0.001 -#define TINY 1.E-10 +static constexpr double SMALL = 0.001; +static constexpr double TINY = 1.E-10; /* ---------------------------------------------------------------------- */ diff --git a/src/MOLECULE/bond_gromos.cpp b/src/MOLECULE/bond_gromos.cpp index badb808007..1917f18686 100644 --- a/src/MOLECULE/bond_gromos.cpp +++ b/src/MOLECULE/bond_gromos.cpp @@ -24,6 +24,7 @@ #include "memory.h" #include "neighbor.h" +#include #include using namespace LAMMPS_NS; diff --git a/src/MOLECULE/bond_table.cpp b/src/MOLECULE/bond_table.cpp index 4068e98e8d..67cd3769ca 100644 --- a/src/MOLECULE/bond_table.cpp +++ b/src/MOLECULE/bond_table.cpp @@ -33,7 +33,7 @@ using namespace LAMMPS_NS; enum { NONE, LINEAR, SPLINE }; -#define BIGNUM 1.0e300 +static constexpr double BIGNUM = 1.0e300; /* ---------------------------------------------------------------------- */ diff --git a/src/MOLECULE/pair_hbond_dreiding_lj.cpp b/src/MOLECULE/pair_hbond_dreiding_lj.cpp index 496e368452..dbd7db7780 100644 --- a/src/MOLECULE/pair_hbond_dreiding_lj.cpp +++ b/src/MOLECULE/pair_hbond_dreiding_lj.cpp @@ -37,8 +37,8 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define SMALL 0.001 -#define CHUNK 8 +static constexpr double SMALL = 0.001; +static constexpr int CHUNK = 8; /* ---------------------------------------------------------------------- */ diff --git a/src/MOLECULE/pair_hbond_dreiding_morse.cpp b/src/MOLECULE/pair_hbond_dreiding_morse.cpp index 7ec2db073d..5cc45ea234 100644 --- a/src/MOLECULE/pair_hbond_dreiding_morse.cpp +++ b/src/MOLECULE/pair_hbond_dreiding_morse.cpp @@ -37,8 +37,8 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define SMALL 0.001 -#define CHUNK 8 +static constexpr double SMALL = 0.001; +static constexpr int CHUNK = 8; /* ---------------------------------------------------------------------- */ diff --git a/src/MOLECULE/pair_tip4p_cut.cpp b/src/MOLECULE/pair_tip4p_cut.cpp index 6d27c1a164..73a5651e6b 100644 --- a/src/MOLECULE/pair_tip4p_cut.cpp +++ b/src/MOLECULE/pair_tip4p_cut.cpp @@ -30,6 +30,7 @@ #include "neighbor.h" #include +#include using namespace LAMMPS_NS; diff --git a/src/MOLFILE/molfile_interface.cpp b/src/MOLFILE/molfile_interface.cpp index 8f5ac8545e..84aa63cefc 100644 --- a/src/MOLFILE/molfile_interface.cpp +++ b/src/MOLFILE/molfile_interface.cpp @@ -26,7 +26,6 @@ #include #include -#include #if vmdplugin_ABIVERSION < 16 #error "unsupported VMD molfile plugin ABI version" diff --git a/src/MOLFILE/reader_molfile.cpp b/src/MOLFILE/reader_molfile.cpp index 441a152ad9..43154d658b 100644 --- a/src/MOLFILE/reader_molfile.cpp +++ b/src/MOLFILE/reader_molfile.cpp @@ -29,7 +29,7 @@ using namespace LAMMPS_NS; typedef MolfileInterface MFI; using namespace MathConst; -#define SMALL 1.0e-6 +static constexpr double SMALL = 1.0e-6; // true if the difference between two floats is "small". // cannot use fabsf() since it is not fully portable. diff --git a/src/OPENMP/angle_charmm_omp.cpp b/src/OPENMP/angle_charmm_omp.cpp index 9eb91bcb27..bb5dcca0da 100644 --- a/src/OPENMP/angle_charmm_omp.cpp +++ b/src/OPENMP/angle_charmm_omp.cpp @@ -28,7 +28,7 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/angle_class2_omp.cpp b/src/OPENMP/angle_class2_omp.cpp index 300f8f2b3c..9480d2ebfb 100644 --- a/src/OPENMP/angle_class2_omp.cpp +++ b/src/OPENMP/angle_class2_omp.cpp @@ -28,7 +28,7 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/angle_cosine_delta_omp.cpp b/src/OPENMP/angle_cosine_delta_omp.cpp index 98b6a7ac56..cc8370d053 100644 --- a/src/OPENMP/angle_cosine_delta_omp.cpp +++ b/src/OPENMP/angle_cosine_delta_omp.cpp @@ -28,7 +28,7 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/angle_cosine_omp.cpp b/src/OPENMP/angle_cosine_omp.cpp index 1985633c38..62320b7c6c 100644 --- a/src/OPENMP/angle_cosine_omp.cpp +++ b/src/OPENMP/angle_cosine_omp.cpp @@ -24,12 +24,9 @@ #include "force.h" #include "neighbor.h" - #include "suffix.h" using namespace LAMMPS_NS; -#define SMALL 0.001 - /* ---------------------------------------------------------------------- */ AngleCosineOMP::AngleCosineOMP(class LAMMPS *lmp) diff --git a/src/OPENMP/angle_cosine_periodic_omp.cpp b/src/OPENMP/angle_cosine_periodic_omp.cpp index 48532c8f6c..3d546af278 100644 --- a/src/OPENMP/angle_cosine_periodic_omp.cpp +++ b/src/OPENMP/angle_cosine_periodic_omp.cpp @@ -30,8 +30,6 @@ using namespace LAMMPS_NS; using namespace MathSpecial; -#define SMALL 0.001 - /* ---------------------------------------------------------------------- */ AngleCosinePeriodicOMP::AngleCosinePeriodicOMP(class LAMMPS *lmp) diff --git a/src/OPENMP/angle_cosine_shift_exp_omp.cpp b/src/OPENMP/angle_cosine_shift_exp_omp.cpp index 5831f59fab..c131efd839 100644 --- a/src/OPENMP/angle_cosine_shift_exp_omp.cpp +++ b/src/OPENMP/angle_cosine_shift_exp_omp.cpp @@ -28,7 +28,7 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/angle_cosine_shift_omp.cpp b/src/OPENMP/angle_cosine_shift_omp.cpp index 020f7583ff..47fed634aa 100644 --- a/src/OPENMP/angle_cosine_shift_omp.cpp +++ b/src/OPENMP/angle_cosine_shift_omp.cpp @@ -28,7 +28,7 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/angle_cosine_squared_omp.cpp b/src/OPENMP/angle_cosine_squared_omp.cpp index 9d98455fe4..9b849c62a3 100644 --- a/src/OPENMP/angle_cosine_squared_omp.cpp +++ b/src/OPENMP/angle_cosine_squared_omp.cpp @@ -24,12 +24,9 @@ #include "force.h" #include "neighbor.h" - #include "suffix.h" using namespace LAMMPS_NS; -#define SMALL 0.001 - /* ---------------------------------------------------------------------- */ AngleCosineSquaredOMP::AngleCosineSquaredOMP(class LAMMPS *lmp) diff --git a/src/OPENMP/angle_dipole_omp.cpp b/src/OPENMP/angle_dipole_omp.cpp index 3a8099ac73..3c771df69f 100644 --- a/src/OPENMP/angle_dipole_omp.cpp +++ b/src/OPENMP/angle_dipole_omp.cpp @@ -25,12 +25,9 @@ #include "force.h" #include "neighbor.h" - #include "suffix.h" using namespace LAMMPS_NS; -#define SMALL 0.001 - /* ---------------------------------------------------------------------- */ AngleDipoleOMP::AngleDipoleOMP(class LAMMPS *lmp) diff --git a/src/OPENMP/angle_fourier_omp.cpp b/src/OPENMP/angle_fourier_omp.cpp index 0c85264342..a11d3b6327 100644 --- a/src/OPENMP/angle_fourier_omp.cpp +++ b/src/OPENMP/angle_fourier_omp.cpp @@ -24,12 +24,9 @@ #include "force.h" #include "neighbor.h" - #include "suffix.h" using namespace LAMMPS_NS; -#define SMALL 0.001 - /* ---------------------------------------------------------------------- */ AngleFourierOMP::AngleFourierOMP(class LAMMPS *lmp) diff --git a/src/OPENMP/angle_fourier_simple_omp.cpp b/src/OPENMP/angle_fourier_simple_omp.cpp index a8f234918b..ad63fa0862 100644 --- a/src/OPENMP/angle_fourier_simple_omp.cpp +++ b/src/OPENMP/angle_fourier_simple_omp.cpp @@ -28,7 +28,7 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define SMALL 0.0001 +static constexpr double SMALL = 0.0001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/angle_harmonic_omp.cpp b/src/OPENMP/angle_harmonic_omp.cpp index e83146a3ad..5d779fbe21 100644 --- a/src/OPENMP/angle_harmonic_omp.cpp +++ b/src/OPENMP/angle_harmonic_omp.cpp @@ -28,7 +28,7 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/angle_lepton_omp.cpp b/src/OPENMP/angle_lepton_omp.cpp index 7e86a9e9bb..918fb57871 100644 --- a/src/OPENMP/angle_lepton_omp.cpp +++ b/src/OPENMP/angle_lepton_omp.cpp @@ -16,13 +16,16 @@ ------------------------------------------------------------------------- */ #include "angle_lepton_omp.h" + #include "atom.h" #include "comm.h" +#include "error.h" #include "force.h" #include "neighbor.h" #include "suffix.h" #include +#include #include "Lepton.h" #include "lepton_utils.h" @@ -91,10 +94,17 @@ void AngleLeptonOMP::eval(int nfrom, int nto, ThrData *const thr) { std::vector angleforce; std::vector anglepot; + std::vector has_ref; try { for (const auto &expr : expressions) { auto parsed = Lepton::Parser::parse(LeptonUtils::substitute(expr, Pointers::lmp)); angleforce.emplace_back(parsed.differentiate("theta").createCompiledExpression()); + has_ref.push_back(true); + try { + angleforce.back().getVariableReference("theta"); + } catch (Lepton::Exception &) { + has_ref.back() = false; + } if (EFLAG) anglepot.emplace_back(parsed.createCompiledExpression()); } } catch (std::exception &e) { @@ -146,8 +156,7 @@ void AngleLeptonOMP::eval(int nfrom, int nto, ThrData *const thr) const double dtheta = acos(c) - theta0[type]; const int idx = type2expression[type]; - angleforce[idx].getVariableReference("theta") = dtheta; - + if (has_ref[idx]) angleforce[idx].getVariableReference("theta") = dtheta; const double a = -angleforce[idx].evaluate() * s; const double a11 = a * c / rsq1; const double a12 = -a / (r1 * r2); @@ -183,7 +192,11 @@ void AngleLeptonOMP::eval(int nfrom, int nto, ThrData *const thr) double eangle = 0.0; if (EFLAG) { - anglepot[idx].getVariableReference("theta") = dtheta; + try { + anglepot[idx].getVariableReference("theta") = dtheta; + } catch (Lepton::Exception &) { + ; // ignore -> constant force + } eangle = anglepot[idx].evaluate() - offset[type]; } if (EVFLAG) diff --git a/src/OPENMP/angle_quartic_omp.cpp b/src/OPENMP/angle_quartic_omp.cpp index bb9a9837d2..7c1d1b4a17 100644 --- a/src/OPENMP/angle_quartic_omp.cpp +++ b/src/OPENMP/angle_quartic_omp.cpp @@ -28,7 +28,7 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/angle_spica_omp.cpp b/src/OPENMP/angle_spica_omp.cpp index 728e2ff435..f1dd7d40b5 100644 --- a/src/OPENMP/angle_spica_omp.cpp +++ b/src/OPENMP/angle_spica_omp.cpp @@ -30,7 +30,7 @@ using namespace LAMMPS_NS; using namespace LJSPICAParms; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/angle_table_omp.cpp b/src/OPENMP/angle_table_omp.cpp index d75bd8a694..11436723b1 100644 --- a/src/OPENMP/angle_table_omp.cpp +++ b/src/OPENMP/angle_table_omp.cpp @@ -29,7 +29,7 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/bond_lepton_omp.cpp b/src/OPENMP/bond_lepton_omp.cpp index 0029062366..995e2fac09 100644 --- a/src/OPENMP/bond_lepton_omp.cpp +++ b/src/OPENMP/bond_lepton_omp.cpp @@ -18,11 +18,13 @@ #include "bond_lepton_omp.h" #include "atom.h" #include "comm.h" +#include "error.h" #include "force.h" #include "neighbor.h" #include "suffix.h" #include +#include #include "Lepton.h" #include "lepton_utils.h" @@ -89,10 +91,17 @@ void BondLeptonOMP::eval(int nfrom, int nto, ThrData *const thr) { std::vector bondforce; std::vector bondpot; + std::vector has_ref; try { for (const auto &expr : expressions) { auto parsed = Lepton::Parser::parse(LeptonUtils::substitute(expr, Pointers::lmp)); bondforce.emplace_back(parsed.differentiate("r").createCompiledExpression()); + has_ref.push_back(true); + try { + bondforce.back().getVariableReference("r"); + } catch (Lepton::Exception &) { + has_ref.back() = false; + } if (EFLAG) bondpot.emplace_back(parsed.createCompiledExpression()); } } catch (std::exception &e) { @@ -122,7 +131,7 @@ void BondLeptonOMP::eval(int nfrom, int nto, ThrData *const thr) double fbond = 0.0; if (r > 0.0) { - bondforce[idx].getVariableReference("r") = dr; + if (has_ref[idx]) bondforce[idx].getVariableReference("r") = dr; fbond = -bondforce[idx].evaluate() / r; } @@ -142,7 +151,11 @@ void BondLeptonOMP::eval(int nfrom, int nto, ThrData *const thr) double ebond = 0.0; if (EFLAG) { - bondpot[idx].getVariableReference("r") = dr; + try { + bondpot[idx].getVariableReference("r") = dr; + } catch (Lepton::Exception &) { + ; // ignore -> constant potential + } ebond = bondpot[idx].evaluate() - offset[type]; } if (EVFLAG) diff --git a/src/OPENMP/dihedral_charmm_omp.cpp b/src/OPENMP/dihedral_charmm_omp.cpp index e78a3e8919..d0c38c8774 100644 --- a/src/OPENMP/dihedral_charmm_omp.cpp +++ b/src/OPENMP/dihedral_charmm_omp.cpp @@ -30,8 +30,7 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/dihedral_class2_omp.cpp b/src/OPENMP/dihedral_class2_omp.cpp index 8ec39ceee8..ffcdf4fa1a 100644 --- a/src/OPENMP/dihedral_class2_omp.cpp +++ b/src/OPENMP/dihedral_class2_omp.cpp @@ -29,8 +29,8 @@ #include "omp_compat.h" using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.0000001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.0000001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/dihedral_cosine_shift_exp_omp.cpp b/src/OPENMP/dihedral_cosine_shift_exp_omp.cpp index 106db995c4..0cffc3e245 100644 --- a/src/OPENMP/dihedral_cosine_shift_exp_omp.cpp +++ b/src/OPENMP/dihedral_cosine_shift_exp_omp.cpp @@ -29,8 +29,7 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/dihedral_fourier_omp.cpp b/src/OPENMP/dihedral_fourier_omp.cpp index aae1eec559..34a145a06d 100644 --- a/src/OPENMP/dihedral_fourier_omp.cpp +++ b/src/OPENMP/dihedral_fourier_omp.cpp @@ -29,7 +29,7 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define TOLERANCE 0.05 +static constexpr double TOLERANCE = 0.05; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/dihedral_harmonic_omp.cpp b/src/OPENMP/dihedral_harmonic_omp.cpp index 8737c61cdd..fe3fb988ce 100644 --- a/src/OPENMP/dihedral_harmonic_omp.cpp +++ b/src/OPENMP/dihedral_harmonic_omp.cpp @@ -29,8 +29,7 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/dihedral_helix_omp.cpp b/src/OPENMP/dihedral_helix_omp.cpp index d778285974..64ba0b9af5 100644 --- a/src/OPENMP/dihedral_helix_omp.cpp +++ b/src/OPENMP/dihedral_helix_omp.cpp @@ -31,9 +31,9 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define TOLERANCE 0.05 -#define SMALL 0.001 -#define SMALLER 0.00001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; +static constexpr double SMALLER = 0.00001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/dihedral_lepton_omp.cpp b/src/OPENMP/dihedral_lepton_omp.cpp index 13a1328058..206749fcfa 100644 --- a/src/OPENMP/dihedral_lepton_omp.cpp +++ b/src/OPENMP/dihedral_lepton_omp.cpp @@ -18,12 +18,14 @@ #include "dihedral_lepton_omp.h" #include "atom.h" #include "comm.h" +#include "error.h" #include "force.h" +#include "math_extra.h" #include "neighbor.h" #include "suffix.h" -#include "math_extra.h" #include +#include #include "Lepton.h" #include "lepton_utils.h" @@ -94,10 +96,17 @@ void DihedralLeptonOMP::eval(int nfrom, int nto, ThrData *const thr) { std::vector dihedralforce; std::vector dihedralpot; + std::vector has_ref; try { for (const auto &expr : expressions) { auto parsed = Lepton::Parser::parse(LeptonUtils::substitute(expr, Pointers::lmp)); dihedralforce.emplace_back(parsed.differentiate("phi").createCompiledExpression()); + has_ref.push_back(true); + try { + dihedralforce.back().getVariableReference("phi"); + } catch (Lepton::Exception &) { + has_ref.back() = false; + } if (EFLAG) dihedralpot.emplace_back(parsed.createCompiledExpression()); } } catch (std::exception &e) { @@ -106,7 +115,7 @@ void DihedralLeptonOMP::eval(int nfrom, int nto, ThrData *const thr) const double *const *const x = atom->x; auto *_noalias const f = (dbl3_t *) thr->get_f()[0]; - const int * const * const dihedrallist = neighbor->dihedrallist; + const int *const *const dihedrallist = neighbor->dihedrallist; const int nlocal = atom->nlocal; // The dihedral angle "phi" is the angle between n123 and n234 @@ -279,7 +288,7 @@ void DihedralLeptonOMP::eval(int nfrom, int nto, ThrData *const thr) } const int idx = type2expression[type]; - dihedralforce[idx].getVariableReference("phi") = phi; + if (has_ref[idx]) dihedralforce[idx].getVariableReference("phi") = phi; double m_du_dphi = -dihedralforce[idx].evaluate(); // ----- Step 4: Calculate the force direction in real space ----- @@ -323,7 +332,11 @@ void DihedralLeptonOMP::eval(int nfrom, int nto, ThrData *const thr) double edihedral = 0.0; if (EFLAG) { - dihedralpot[idx].getVariableReference("phi") = phi; + try { + dihedralpot[idx].getVariableReference("phi") = phi; + } catch (Lepton::Exception &) { + ; // ignore -> constant potential + } edihedral = dihedralpot[idx].evaluate(); } if (EVFLAG) diff --git a/src/OPENMP/dihedral_multi_harmonic_omp.cpp b/src/OPENMP/dihedral_multi_harmonic_omp.cpp index d3f4447d08..57c4b77565 100644 --- a/src/OPENMP/dihedral_multi_harmonic_omp.cpp +++ b/src/OPENMP/dihedral_multi_harmonic_omp.cpp @@ -29,8 +29,8 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/dihedral_nharmonic_omp.cpp b/src/OPENMP/dihedral_nharmonic_omp.cpp index f9a3f1328d..34e54f6c7c 100644 --- a/src/OPENMP/dihedral_nharmonic_omp.cpp +++ b/src/OPENMP/dihedral_nharmonic_omp.cpp @@ -29,8 +29,8 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/dihedral_opls_omp.cpp b/src/OPENMP/dihedral_opls_omp.cpp index fbdc408c4d..ccfd2ea42c 100644 --- a/src/OPENMP/dihedral_opls_omp.cpp +++ b/src/OPENMP/dihedral_opls_omp.cpp @@ -29,9 +29,9 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 -#define SMALLER 0.00001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; +static constexpr double SMALLER = 0.00001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/dihedral_quadratic_omp.cpp b/src/OPENMP/dihedral_quadratic_omp.cpp index 43d97da5f2..52b7c331fd 100644 --- a/src/OPENMP/dihedral_quadratic_omp.cpp +++ b/src/OPENMP/dihedral_quadratic_omp.cpp @@ -31,9 +31,9 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define TOLERANCE 0.05 -#define SMALL 0.001 -#define SMALLER 0.00001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; +static constexpr double SMALLER = 0.00001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/dihedral_table_omp.cpp b/src/OPENMP/dihedral_table_omp.cpp index 7405ae4a13..df1ca292c9 100644 --- a/src/OPENMP/dihedral_table_omp.cpp +++ b/src/OPENMP/dihedral_table_omp.cpp @@ -34,9 +34,6 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathExtra; -#define TOLERANCE 0.05 -#define SMALL 0.001 - // -------------------------------------------- // ------- Calculate the dihedral angle ------- // -------------------------------------------- diff --git a/src/OPENMP/ewald_omp.cpp b/src/OPENMP/ewald_omp.cpp index ee2963659a..8674017592 100644 --- a/src/OPENMP/ewald_omp.cpp +++ b/src/OPENMP/ewald_omp.cpp @@ -31,8 +31,6 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.00001 - /* ---------------------------------------------------------------------- */ EwaldOMP::EwaldOMP(LAMMPS *lmp) : Ewald(lmp), ThrOMP(lmp, THR_KSPACE) diff --git a/src/OPENMP/fix_nh_omp.cpp b/src/OPENMP/fix_nh_omp.cpp index a7fe2738ca..7ef69af0fe 100644 --- a/src/OPENMP/fix_nh_omp.cpp +++ b/src/OPENMP/fix_nh_omp.cpp @@ -22,7 +22,6 @@ #include "compute.h" #include "domain.h" #include "error.h" -#include "modify.h" #include @@ -33,7 +32,7 @@ using namespace FixConst; enum{NOBIAS,BIAS}; enum{ISO,ANISO,TRICLINIC}; -#define TILTMAX 1.5 +static constexpr double TILTMAX = 1.5; typedef struct { double x,y,z; } dbl3_t; diff --git a/src/OPENMP/fix_nh_sphere_omp.cpp b/src/OPENMP/fix_nh_sphere_omp.cpp index 93a674cbce..beaa4fd1cb 100644 --- a/src/OPENMP/fix_nh_sphere_omp.cpp +++ b/src/OPENMP/fix_nh_sphere_omp.cpp @@ -28,7 +28,7 @@ using namespace FixConst; enum{NOBIAS,BIAS}; -#define INERTIA 0.4 // moment of inertia prefactor for sphere +static constexpr double INERTIA = 0.4; // moment of inertia prefactor for sphere typedef struct { double x,y,z; } dbl3_t; @@ -37,8 +37,8 @@ typedef struct { double x,y,z; } dbl3_t; FixNHSphereOMP::FixNHSphereOMP(LAMMPS *lmp, int narg, char **arg) : FixNHOMP(lmp, narg, arg) { - if (!atom->sphere_flag) - error->all(FLERR,"Fix nvt/nph/npt sphere requires atom style sphere"); + if (!atom->omega_flag) error->all(FLERR,"Fix {} requires atom attribute omega", style); + if (!atom->radius_flag) error->all(FLERR,"Fix {} requires atom attribute radius", style); } /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/fix_nve_sphere_omp.cpp b/src/OPENMP/fix_nve_sphere_omp.cpp index be3fc8d147..8c65a0df6a 100644 --- a/src/OPENMP/fix_nve_sphere_omp.cpp +++ b/src/OPENMP/fix_nve_sphere_omp.cpp @@ -25,7 +25,7 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace MathExtra; -#define INERTIA 0.4 // moment of inertia prefactor for sphere +static constexpr double INERTIA = 0.4; // moment of inertia prefactor for sphere enum{NONE,DIPOLE}; enum{NODLM,DLM}; diff --git a/src/OPENMP/fix_omp.cpp b/src/OPENMP/fix_omp.cpp index 3a249bad82..f7828f43ee 100644 --- a/src/OPENMP/fix_omp.cpp +++ b/src/OPENMP/fix_omp.cpp @@ -161,12 +161,15 @@ void FixOMP::init() { // OPENMP package cannot be used with atom_style template if (atom->molecular == Atom::TEMPLATE) - error->all(FLERR,"OPENMP package does not (yet) work with " - "atom_style template"); + error->all(FLERR,"OPENMP package does not (yet) work with atom_style template"); // adjust number of data objects when the number of OpenMP // threads has been changed somehow const int nthreads = comm->nthreads; +#if defined(_OPENMP) + // make certain threads are initialized correctly. avoids segfaults with LAMMPS-GUI + if (nthreads != omp_get_max_threads()) omp_set_num_threads(nthreads); +#endif if (_nthr != nthreads) { if (comm->me == 0) utils::logmesg(lmp,"Re-init OPENMP for {} OpenMP thread(s)\n", nthreads); @@ -212,7 +215,7 @@ void FixOMP::init() // kspace_split < 0 : master partition, does not do kspace // kspace_split > 0 : slave partition, only does kspace - if (strstr(update->integrate_style,"verlet/split") != nullptr) { + if (utils::strmatch(update->integrate_style, "^verlet/split")) { if (universe->iworld == 0) kspace_split = -1; else kspace_split = 1; } else { diff --git a/src/OPENMP/fix_rigid_nh_omp.cpp b/src/OPENMP/fix_rigid_nh_omp.cpp index 19e5d4f240..f5e4a1f49d 100644 --- a/src/OPENMP/fix_rigid_nh_omp.cpp +++ b/src/OPENMP/fix_rigid_nh_omp.cpp @@ -30,7 +30,6 @@ #include "kspace.h" #include "math_const.h" #include "math_extra.h" -#include "modify.h" #include "rigid_const.h" #include "update.h" diff --git a/src/OPENMP/improper_class2_omp.cpp b/src/OPENMP/improper_class2_omp.cpp index b7387ea75a..8233f0bee6 100644 --- a/src/OPENMP/improper_class2_omp.cpp +++ b/src/OPENMP/improper_class2_omp.cpp @@ -29,9 +29,6 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 - /* ---------------------------------------------------------------------- */ ImproperClass2OMP::ImproperClass2OMP(class LAMMPS *lmp) diff --git a/src/OPENMP/improper_cossq_omp.cpp b/src/OPENMP/improper_cossq_omp.cpp index 3bfc86bcab..4ccc0d730a 100644 --- a/src/OPENMP/improper_cossq_omp.cpp +++ b/src/OPENMP/improper_cossq_omp.cpp @@ -29,8 +29,8 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/improper_cvff_omp.cpp b/src/OPENMP/improper_cvff_omp.cpp index 310806d872..b7fe9ffb03 100644 --- a/src/OPENMP/improper_cvff_omp.cpp +++ b/src/OPENMP/improper_cvff_omp.cpp @@ -29,8 +29,8 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/improper_fourier_omp.cpp b/src/OPENMP/improper_fourier_omp.cpp index b70e3fb0ac..000bc02066 100644 --- a/src/OPENMP/improper_fourier_omp.cpp +++ b/src/OPENMP/improper_fourier_omp.cpp @@ -29,8 +29,8 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/improper_harmonic_omp.cpp b/src/OPENMP/improper_harmonic_omp.cpp index d17fe9407d..12c2699663 100644 --- a/src/OPENMP/improper_harmonic_omp.cpp +++ b/src/OPENMP/improper_harmonic_omp.cpp @@ -29,8 +29,8 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/improper_ring_omp.cpp b/src/OPENMP/improper_ring_omp.cpp index 899727c685..a1b4e31cee 100644 --- a/src/OPENMP/improper_ring_omp.cpp +++ b/src/OPENMP/improper_ring_omp.cpp @@ -31,8 +31,7 @@ using namespace LAMMPS_NS; using namespace MathSpecial; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/improper_umbrella_omp.cpp b/src/OPENMP/improper_umbrella_omp.cpp index e5d03863df..50c1ce4676 100644 --- a/src/OPENMP/improper_umbrella_omp.cpp +++ b/src/OPENMP/improper_umbrella_omp.cpp @@ -29,8 +29,8 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/msm_cg_omp.cpp b/src/OPENMP/msm_cg_omp.cpp index 6904830fed..00230c9ece 100644 --- a/src/OPENMP/msm_cg_omp.cpp +++ b/src/OPENMP/msm_cg_omp.cpp @@ -38,8 +38,8 @@ using namespace LAMMPS_NS; -#define OFFSET 16384 -#define SMALLQ 0.00001 +static constexpr int OFFSET = 16384; +static constexpr double SMALLQ = 0.00001; enum{REVERSE_RHO,REVERSE_AD,REVERSE_AD_PERATOM}; enum{FORWARD_RHO,FORWARD_AD,FORWARD_AD_PERATOM}; diff --git a/src/OPENMP/npair_bin_omp.cpp b/src/OPENMP/npair_bin_omp.cpp index 5b2189dec2..7922d76612 100644 --- a/src/OPENMP/npair_bin_omp.cpp +++ b/src/OPENMP/npair_bin_omp.cpp @@ -25,6 +25,8 @@ #include "my_page.h" #include "neigh_list.h" +#include + using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/npair_multi_old_omp.cpp b/src/OPENMP/npair_multi_old_omp.cpp index d45f2d1f5f..fa790e177a 100644 --- a/src/OPENMP/npair_multi_old_omp.cpp +++ b/src/OPENMP/npair_multi_old_omp.cpp @@ -24,6 +24,8 @@ #include "my_page.h" #include "neigh_list.h" +#include + using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/npair_multi_omp.cpp b/src/OPENMP/npair_multi_omp.cpp index 3f8604572c..cbc21ebc29 100644 --- a/src/OPENMP/npair_multi_omp.cpp +++ b/src/OPENMP/npair_multi_omp.cpp @@ -26,6 +26,8 @@ #include "neigh_list.h" #include "neighbor.h" +#include + using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/npair_nsq_omp.cpp b/src/OPENMP/npair_nsq_omp.cpp index c482fc8f2d..5d6aa518b0 100644 --- a/src/OPENMP/npair_nsq_omp.cpp +++ b/src/OPENMP/npair_nsq_omp.cpp @@ -27,6 +27,8 @@ #include "neigh_list.h" #include "neighbor.h" +#include + using namespace LAMMPS_NS; using namespace NeighConst; diff --git a/src/OPENMP/npair_respa_bin_omp.cpp b/src/OPENMP/npair_respa_bin_omp.cpp index c958167ba0..a069affb06 100644 --- a/src/OPENMP/npair_respa_bin_omp.cpp +++ b/src/OPENMP/npair_respa_bin_omp.cpp @@ -25,6 +25,8 @@ #include "my_page.h" #include "neigh_list.h" +#include + using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/npair_respa_nsq_omp.cpp b/src/OPENMP/npair_respa_nsq_omp.cpp index 6815b21544..deba473678 100644 --- a/src/OPENMP/npair_respa_nsq_omp.cpp +++ b/src/OPENMP/npair_respa_nsq_omp.cpp @@ -26,6 +26,8 @@ #include "my_page.h" #include "neigh_list.h" +#include + using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_airebo_omp.cpp b/src/OPENMP/pair_airebo_omp.cpp index 0872678518..6736b10f8f 100644 --- a/src/OPENMP/pair_airebo_omp.cpp +++ b/src/OPENMP/pair_airebo_omp.cpp @@ -34,12 +34,11 @@ using namespace LAMMPS_NS; using namespace MathSpecial; -#define TOL 1.0e-9 +static constexpr double TOL = 1.0e-9; /* ---------------------------------------------------------------------- */ -PairAIREBOOMP::PairAIREBOOMP(LAMMPS *lmp) : - PairAIREBO(lmp), ThrOMP(lmp, THR_PAIR) +PairAIREBOOMP::PairAIREBOOMP(LAMMPS *lmp) : PairAIREBO(lmp), ThrOMP(lmp, THR_PAIR) { suffix_flag |= Suffix::OMP; respa_enable = 0; @@ -1121,12 +1120,9 @@ double PairAIREBOOMP::bondorder_thr(int i, int j, double rij[3], double rijmag, cosjik = MIN(cosjik,1.0); cosjik = MAX(cosjik,-1.0); - dcosjikdri[0] = ((rij[0]+rik[0])*invrijkm) - - (cosjik*((rij[0]*invrijm2)+(rik[0]*invrikm2))); - dcosjikdri[1] = ((rij[1]+rik[1])*invrijkm) - - (cosjik*((rij[1]*invrijm2)+(rik[1]*invrikm2))); - dcosjikdri[2] = ((rij[2]+rik[2])*invrijkm) - - (cosjik*((rij[2]*invrijm2)+(rik[2]*invrikm2))); + dcosjikdri[0] = ((rij[0]+rik[0])*invrijkm) - (cosjik*((rij[0]*invrijm2)+(rik[0]*invrikm2))); + dcosjikdri[1] = ((rij[1]+rik[1])*invrijkm) - (cosjik*((rij[1]*invrijm2)+(rik[1]*invrikm2))); + dcosjikdri[2] = ((rij[2]+rik[2])*invrijkm) - (cosjik*((rij[2]*invrijm2)+(rik[2]*invrikm2))); dcosjikdrk[0] = (-rij[0]*invrijkm) + (cosjik*(rik[0]*invrikm2)); dcosjikdrk[1] = (-rij[1]*invrijkm) + (cosjik*(rik[1]*invrikm2)); dcosjikdrk[2] = (-rij[2]*invrijkm) + (cosjik*(rik[2]*invrikm2)); diff --git a/src/OPENMP/pair_born_coul_long_omp.cpp b/src/OPENMP/pair_born_coul_long_omp.cpp index 0f51a3a5cc..30efb6e633 100644 --- a/src/OPENMP/pair_born_coul_long_omp.cpp +++ b/src/OPENMP/pair_born_coul_long_omp.cpp @@ -17,6 +17,7 @@ #include "atom.h" #include "comm.h" +#include "ewald_const.h" #include "force.h" #include "neigh_list.h" #include "suffix.h" @@ -24,15 +25,9 @@ #include #include "omp_compat.h" -using namespace LAMMPS_NS; -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace LAMMPS_NS; +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_brownian_omp.cpp b/src/OPENMP/pair_brownian_omp.cpp index 45288f13dd..ecb80456d1 100644 --- a/src/OPENMP/pair_brownian_omp.cpp +++ b/src/OPENMP/pair_brownian_omp.cpp @@ -36,12 +36,6 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define EPSILON 1.0e-10 - -// same as fix_wall.cpp - -enum{EDGE,CONSTANT,VARIABLE}; - /* ---------------------------------------------------------------------- */ PairBrownianOMP::PairBrownianOMP(LAMMPS *lmp) : @@ -93,7 +87,7 @@ void PairBrownianOMP::compute(int eflag, int vflag) for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; diff --git a/src/OPENMP/pair_brownian_poly_omp.cpp b/src/OPENMP/pair_brownian_poly_omp.cpp index 91a496979d..f9db86043a 100644 --- a/src/OPENMP/pair_brownian_poly_omp.cpp +++ b/src/OPENMP/pair_brownian_poly_omp.cpp @@ -36,12 +36,6 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define EPSILON 1.0e-10 - -// same as fix_wall.cpp - -enum{EDGE,CONSTANT,VARIABLE}; - /* ---------------------------------------------------------------------- */ PairBrownianPolyOMP::PairBrownianPolyOMP(LAMMPS *lmp) : @@ -93,7 +87,7 @@ void PairBrownianPolyOMP::compute(int eflag, int vflag) for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; diff --git a/src/OPENMP/pair_buck_coul_long_omp.cpp b/src/OPENMP/pair_buck_coul_long_omp.cpp index da4b0bb5b0..2bbb7a1cd8 100644 --- a/src/OPENMP/pair_buck_coul_long_omp.cpp +++ b/src/OPENMP/pair_buck_coul_long_omp.cpp @@ -17,6 +17,7 @@ #include "atom.h" #include "comm.h" +#include "ewald_const.h" #include "force.h" #include "neigh_list.h" #include "suffix.h" @@ -25,14 +26,7 @@ #include "omp_compat.h" using namespace LAMMPS_NS; - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_buck_long_coul_long_omp.cpp b/src/OPENMP/pair_buck_long_coul_long_omp.cpp index bb1bdd9f2a..c03bfcd33c 100644 --- a/src/OPENMP/pair_buck_long_coul_long_omp.cpp +++ b/src/OPENMP/pair_buck_long_coul_long_omp.cpp @@ -16,6 +16,7 @@ #include "atom.h" #include "comm.h" +#include "ewald_const.h" #include "force.h" #include "math_extra.h" #include "neigh_list.h" @@ -27,14 +28,7 @@ #include "omp_compat.h" using namespace LAMMPS_NS; using namespace MathExtra; - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_comb_omp.cpp b/src/OPENMP/pair_comb_omp.cpp index aceff6e111..87d467a846 100644 --- a/src/OPENMP/pair_comb_omp.cpp +++ b/src/OPENMP/pair_comb_omp.cpp @@ -32,7 +32,7 @@ using namespace LAMMPS_NS; using MathExtra::dot3; -#define MAXNEIGH 24 +static constexpr int MAXNEIGH = 24; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_coul_dsf_omp.cpp b/src/OPENMP/pair_coul_dsf_omp.cpp index 4609288d24..d19263c3bb 100644 --- a/src/OPENMP/pair_coul_dsf_omp.cpp +++ b/src/OPENMP/pair_coul_dsf_omp.cpp @@ -13,26 +13,23 @@ Contributing author: Axel Kohlmeyer (Temple U) ------------------------------------------------------------------------- */ -#include "omp_compat.h" #include "pair_coul_dsf_omp.h" -#include + #include "atom.h" #include "comm.h" +#include "ewald_const.h" #include "force.h" #include "neigh_list.h" - -#include "suffix.h" #include "math_const.h" -using namespace LAMMPS_NS; -using namespace MathConst; -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +#include "omp_compat.h" +#include "suffix.h" + +#include + +using namespace LAMMPS_NS; +using namespace EwaldConst; +using MathConst::MY_PIS; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_coul_long_omp.cpp b/src/OPENMP/pair_coul_long_omp.cpp index b8c7423e76..eb7e2236f3 100644 --- a/src/OPENMP/pair_coul_long_omp.cpp +++ b/src/OPENMP/pair_coul_long_omp.cpp @@ -17,6 +17,7 @@ #include "atom.h" #include "comm.h" +#include "ewald_const.h" #include "force.h" #include "neigh_list.h" #include "suffix.h" @@ -24,15 +25,9 @@ #include #include "omp_compat.h" -using namespace LAMMPS_NS; -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace LAMMPS_NS; +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_coul_long_soft_omp.cpp b/src/OPENMP/pair_coul_long_soft_omp.cpp index 3670a219b6..ccfe1e8963 100644 --- a/src/OPENMP/pair_coul_long_soft_omp.cpp +++ b/src/OPENMP/pair_coul_long_soft_omp.cpp @@ -17,6 +17,7 @@ #include "atom.h" #include "comm.h" +#include "ewald_const.h" #include "force.h" #include "neigh_list.h" #include "suffix.h" @@ -24,15 +25,9 @@ #include #include "omp_compat.h" -using namespace LAMMPS_NS; -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace LAMMPS_NS; +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_dpd_ext_omp.cpp b/src/OPENMP/pair_dpd_ext_omp.cpp index f900512e26..9c53984b68 100644 --- a/src/OPENMP/pair_dpd_ext_omp.cpp +++ b/src/OPENMP/pair_dpd_ext_omp.cpp @@ -28,7 +28,7 @@ #include "omp_compat.h" using namespace LAMMPS_NS; -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_dpd_ext_tstat_omp.cpp b/src/OPENMP/pair_dpd_ext_tstat_omp.cpp index b55a9d39c6..41234dbcc9 100644 --- a/src/OPENMP/pair_dpd_ext_tstat_omp.cpp +++ b/src/OPENMP/pair_dpd_ext_tstat_omp.cpp @@ -28,7 +28,7 @@ #include "omp_compat.h" using namespace LAMMPS_NS; -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_dpd_omp.cpp b/src/OPENMP/pair_dpd_omp.cpp index f267bde1b0..c4226b5f9d 100644 --- a/src/OPENMP/pair_dpd_omp.cpp +++ b/src/OPENMP/pair_dpd_omp.cpp @@ -27,7 +27,7 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_dpd_tstat_omp.cpp b/src/OPENMP/pair_dpd_tstat_omp.cpp index 2396bf5756..86ecd86528 100644 --- a/src/OPENMP/pair_dpd_tstat_omp.cpp +++ b/src/OPENMP/pair_dpd_tstat_omp.cpp @@ -28,7 +28,7 @@ #include "omp_compat.h" using namespace LAMMPS_NS; -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_edip_omp.cpp b/src/OPENMP/pair_edip_omp.cpp index 7c31f0db78..a96f276916 100644 --- a/src/OPENMP/pair_edip_omp.cpp +++ b/src/OPENMP/pair_edip_omp.cpp @@ -28,8 +28,8 @@ using namespace LAMMPS_NS; static constexpr int leadDimInteractionList = 64; -#define GRIDDENSITY 8000 -#define GRIDSTART 0.1 +static constexpr int GRIDDENSITY = 8000; +static constexpr double GRIDSTART = 0.1; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_hbond_dreiding_lj_omp.cpp b/src/OPENMP/pair_hbond_dreiding_lj_omp.cpp index e7ba4d72c6..b0f6dcfb5b 100644 --- a/src/OPENMP/pair_hbond_dreiding_lj_omp.cpp +++ b/src/OPENMP/pair_hbond_dreiding_lj_omp.cpp @@ -33,7 +33,7 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_hbond_dreiding_morse_omp.cpp b/src/OPENMP/pair_hbond_dreiding_morse_omp.cpp index 99e2d2c5b1..0e43e2a037 100644 --- a/src/OPENMP/pair_hbond_dreiding_morse_omp.cpp +++ b/src/OPENMP/pair_hbond_dreiding_morse_omp.cpp @@ -33,7 +33,7 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_lepton_coul_omp.cpp b/src/OPENMP/pair_lepton_coul_omp.cpp index bc34bc00af..ae737ef1cb 100644 --- a/src/OPENMP/pair_lepton_coul_omp.cpp +++ b/src/OPENMP/pair_lepton_coul_omp.cpp @@ -16,15 +16,19 @@ #include "atom.h" #include "comm.h" +#include "error.h" #include "force.h" #include "neigh_list.h" #include "suffix.h" -#include - #include "Lepton.h" #include "lepton_utils.h" #include "omp_compat.h" + +#include +#include +#include + using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ @@ -101,25 +105,30 @@ void PairLeptonCoulOMP::eval(int iifrom, int iito, ThrData *const thr) std::vector pairforce; std::vector pairpot; - std::vector> have_q; + std::vector> has_ref; try { for (const auto &expr : expressions) { auto parsed = Lepton::Parser::parse(LeptonUtils::substitute(expr, Pointers::lmp), functions); pairforce.emplace_back(parsed.differentiate("r").createCompiledExpression()); + has_ref.push_back({true, true, true}); + try { + pairforce.back().getVariableReference("r"); + } catch (Lepton::Exception &) { + has_ref.back()[0] = false; + } if (EFLAG) pairpot.emplace_back(parsed.createCompiledExpression()); - pairforce.back().getVariableReference("r"); - have_q.emplace_back(true, true); // check if there are references to charges + try { pairforce.back().getVariableReference("qi"); - } catch (std::exception &) { - have_q.back().first = false; + } catch (Lepton::Exception &) { + has_ref.back()[1] = false; } try { pairforce.back().getVariableReference("qj"); - } catch (std::exception &) { - have_q.back().second = false; + } catch (Lepton::Exception &) { + has_ref.back()[2] = false; } } } catch (std::exception &e) { @@ -152,9 +161,9 @@ void PairLeptonCoulOMP::eval(int iifrom, int iito, ThrData *const thr) if (rsq < cutsq[itype][jtype]) { const double r = sqrt(rsq); const int idx = type2expression[itype][jtype]; - pairforce[idx].getVariableReference("r") = r; - if (have_q[idx].first) pairforce[idx].getVariableReference("qi") = q2e * q[i]; - if (have_q[idx].second) pairforce[idx].getVariableReference("qj") = q2e * q[j]; + if (has_ref[idx][0]) pairforce[idx].getVariableReference("r") = r; + if (has_ref[idx][1]) pairforce[idx].getVariableReference("qi") = q2e * q[i]; + if (has_ref[idx][2]) pairforce[idx].getVariableReference("qj") = q2e * q[j]; const double fpair = -pairforce[idx].evaluate() / r * factor_coul; fxtmp += delx * fpair; @@ -168,9 +177,14 @@ void PairLeptonCoulOMP::eval(int iifrom, int iito, ThrData *const thr) double ecoul = 0.0; if (EFLAG) { - pairpot[idx].getVariableReference("r") = r; - if (have_q[idx].first) pairpot[idx].getVariableReference("qi") = q2e * q[i]; - if (have_q[idx].second) pairpot[idx].getVariableReference("qj") = q2e * q[j]; + try { + pairpot[idx].getVariableReference("r") = r; + } catch (Lepton::Exception &) { + ; // ignore -> constant potential + } + if (has_ref[idx][1]) pairpot[idx].getVariableReference("qi") = q2e * q[i]; + if (has_ref[idx][2]) pairpot[idx].getVariableReference("qj") = q2e * q[j]; + ecoul = pairpot[idx].evaluate(); ecoul *= factor_coul; } diff --git a/src/OPENMP/pair_lepton_omp.cpp b/src/OPENMP/pair_lepton_omp.cpp index b57b0fe11e..3b07a7b757 100644 --- a/src/OPENMP/pair_lepton_omp.cpp +++ b/src/OPENMP/pair_lepton_omp.cpp @@ -16,15 +16,18 @@ #include "atom.h" #include "comm.h" +#include "error.h" #include "force.h" #include "neigh_list.h" #include "suffix.h" -#include - #include "Lepton.h" #include "lepton_utils.h" #include "omp_compat.h" + +#include +#include + using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ @@ -96,10 +99,17 @@ void PairLeptonOMP::eval(int iifrom, int iito, ThrData *const thr) std::vector pairforce; std::vector pairpot; + std::vector have_ref; try { for (const auto &expr : expressions) { auto parsed = Lepton::Parser::parse(LeptonUtils::substitute(expr, Pointers::lmp), functions); pairforce.emplace_back(parsed.differentiate("r").createCompiledExpression()); + have_ref.push_back(true); + try { + pairforce.back().getVariableReference("r"); + } catch (Lepton::Exception &) { + have_ref.back() = false; + } if (EFLAG) pairpot.emplace_back(parsed.createCompiledExpression()); } } catch (std::exception &e) { @@ -132,7 +142,7 @@ void PairLeptonOMP::eval(int iifrom, int iito, ThrData *const thr) if (rsq < cutsq[itype][jtype]) { const double r = sqrt(rsq); const int idx = type2expression[itype][jtype]; - pairforce[idx].getVariableReference("r") = r; + if (have_ref[idx]) pairforce[idx].getVariableReference("r") = r; const double fpair = -pairforce[idx].evaluate() / r * factor_lj; fxtmp += delx * fpair; @@ -146,7 +156,11 @@ void PairLeptonOMP::eval(int iifrom, int iito, ThrData *const thr) double evdwl = 0.0; if (EFLAG) { - pairpot[idx].getVariableReference("r") = r; + try { + pairpot[idx].getVariableReference("r") = r; + } catch (Lepton::Exception &) { + ; // ignore -> constant potential + } evdwl = pairpot[idx].evaluate() - offset[itype][jtype]; evdwl *= factor_lj; } diff --git a/src/OPENMP/pair_lepton_sphere_omp.cpp b/src/OPENMP/pair_lepton_sphere_omp.cpp index 6d3a4827b3..6de9714f3e 100644 --- a/src/OPENMP/pair_lepton_sphere_omp.cpp +++ b/src/OPENMP/pair_lepton_sphere_omp.cpp @@ -16,15 +16,19 @@ #include "atom.h" #include "comm.h" +#include "error.h" #include "force.h" #include "neigh_list.h" #include "suffix.h" -#include - #include "Lepton.h" #include "lepton_utils.h" #include "omp_compat.h" + +#include +#include +#include + using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ @@ -99,25 +103,30 @@ void PairLeptonSphereOMP::eval(int iifrom, int iito, ThrData *const thr) std::vector pairforce; std::vector pairpot; - std::vector> have_rad; + std::vector> has_ref; try { for (const auto &expr : expressions) { auto parsed = Lepton::Parser::parse(LeptonUtils::substitute(expr, Pointers::lmp), functions); pairforce.emplace_back(parsed.differentiate("r").createCompiledExpression()); + has_ref.push_back({true, true, true}); + try { + pairforce.back().getVariableReference("r"); + } catch (Lepton::Exception &) { + has_ref.back()[0] = false; + } if (EFLAG) pairpot.emplace_back(parsed.createCompiledExpression()); - pairforce.back().getVariableReference("r"); - have_rad.emplace_back(true, true); - // check if there are references to charges + // check if there are references to radii + try { pairforce.back().getVariableReference("radi"); - } catch (std::exception &) { - have_rad.back().first = false; + } catch (Lepton::Exception &) { + has_ref.back()[1] = false; } try { pairforce.back().getVariableReference("radj"); - } catch (std::exception &) { - have_rad.back().second = false; + } catch (Lepton::Exception &) { + has_ref.back()[2] = false; } } } catch (std::exception &e) { @@ -150,9 +159,9 @@ void PairLeptonSphereOMP::eval(int iifrom, int iito, ThrData *const thr) if (rsq < cutsq[itype][jtype]) { const double r = sqrt(rsq); const int idx = type2expression[itype][jtype]; - pairforce[idx].getVariableReference("r") = r; - if (have_rad[idx].first) pairforce[idx].getVariableReference("radi") = radius[i]; - if (have_rad[idx].second) pairforce[idx].getVariableReference("radj") = radius[j]; + if (has_ref[idx][0]) pairforce[idx].getVariableReference("r") = r; + if (has_ref[idx][1]) pairforce[idx].getVariableReference("radi") = radius[i]; + if (has_ref[idx][2]) pairforce[idx].getVariableReference("radj") = radius[j]; const double fpair = -pairforce[idx].evaluate() / r * factor_lj; fxtmp += delx * fpair; @@ -166,9 +175,14 @@ void PairLeptonSphereOMP::eval(int iifrom, int iito, ThrData *const thr) double evdwl = 0.0; if (EFLAG) { - pairpot[idx].getVariableReference("r") = r; - if (have_rad[idx].first) pairpot[idx].getVariableReference("radi") = radius[i]; - if (have_rad[idx].second) pairpot[idx].getVariableReference("radj") = radius[j]; + try { + pairpot[idx].getVariableReference("r") = r; + } catch (Lepton::Exception &) { + ; // ignore -> constant potential + } + if (has_ref[idx][1]) pairpot[idx].getVariableReference("radi") = radius[i]; + if (has_ref[idx][2]) pairpot[idx].getVariableReference("radj") = radius[j]; + evdwl = pairpot[idx].evaluate(); evdwl *= factor_lj; } diff --git a/src/OPENMP/pair_lj_class2_coul_long_omp.cpp b/src/OPENMP/pair_lj_class2_coul_long_omp.cpp index 0791cce8f3..b15a0cc129 100644 --- a/src/OPENMP/pair_lj_class2_coul_long_omp.cpp +++ b/src/OPENMP/pair_lj_class2_coul_long_omp.cpp @@ -17,6 +17,7 @@ #include "atom.h" #include "comm.h" +#include "ewald_const.h" #include "force.h" #include "neigh_list.h" #include "suffix.h" @@ -25,14 +26,7 @@ #include "omp_compat.h" using namespace LAMMPS_NS; - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_lj_cut_coul_dsf_omp.cpp b/src/OPENMP/pair_lj_cut_coul_dsf_omp.cpp index f82dfa8d33..d43c161d07 100644 --- a/src/OPENMP/pair_lj_cut_coul_dsf_omp.cpp +++ b/src/OPENMP/pair_lj_cut_coul_dsf_omp.cpp @@ -17,6 +17,7 @@ #include "atom.h" #include "comm.h" +#include "ewald_const.h" #include "force.h" #include "math_const.h" #include "neigh_list.h" @@ -25,16 +26,10 @@ #include #include "omp_compat.h" -using namespace LAMMPS_NS; -using namespace MathConst; -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace LAMMPS_NS; +using namespace EwaldConst; +using MathConst::MY_PIS; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_lj_cut_coul_long_omp.cpp b/src/OPENMP/pair_lj_cut_coul_long_omp.cpp index 49ad3a508c..a1ad688b62 100644 --- a/src/OPENMP/pair_lj_cut_coul_long_omp.cpp +++ b/src/OPENMP/pair_lj_cut_coul_long_omp.cpp @@ -17,6 +17,7 @@ #include "atom.h" #include "comm.h" +#include "ewald_const.h" #include "force.h" #include "neigh_list.h" #include "suffix.h" @@ -24,15 +25,9 @@ #include #include "omp_compat.h" -using namespace LAMMPS_NS; -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace LAMMPS_NS; +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_lj_cut_coul_long_soft_omp.cpp b/src/OPENMP/pair_lj_cut_coul_long_soft_omp.cpp index c8f3635b4f..650f828a0a 100644 --- a/src/OPENMP/pair_lj_cut_coul_long_soft_omp.cpp +++ b/src/OPENMP/pair_lj_cut_coul_long_soft_omp.cpp @@ -17,6 +17,7 @@ #include "atom.h" #include "comm.h" +#include "ewald_const.h" #include "force.h" #include "neigh_list.h" #include "suffix.h" @@ -24,15 +25,9 @@ #include #include "omp_compat.h" -using namespace LAMMPS_NS; -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace LAMMPS_NS; +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_lj_cut_thole_long_omp.cpp b/src/OPENMP/pair_lj_cut_thole_long_omp.cpp index 1ad97a4416..fd9f80f465 100644 --- a/src/OPENMP/pair_lj_cut_thole_long_omp.cpp +++ b/src/OPENMP/pair_lj_cut_thole_long_omp.cpp @@ -34,18 +34,18 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define EWALD_F 1.12837917 -#define EWALD_P 9.95473818e-1 -#define B0 -0.1335096380159268 -#define B1 -2.57839507e-1 -#define B2 -1.37203639e-1 -#define B3 -8.88822059e-3 -#define B4 -5.80844129e-3 -#define B5 1.14652755e-1 +static constexpr double EWALD_F = 1.12837917; +static constexpr double EWALD_P = 9.95473818e-1; +static constexpr double B0 = -0.1335096380159268; +static constexpr double B1 = -2.57839507e-1; +static constexpr double B2 = -1.37203639e-1; +static constexpr double B3 = -8.88822059e-3; +static constexpr double B4 = -5.80844129e-3; +static constexpr double B5 = 1.14652755e-1; -#define EPSILON 1.0e-20 -#define EPS_EWALD 1.0e-6 -#define EPS_EWALD_SQR 1.0e-12 +static constexpr double EPSILON = 1.0e-20; +static constexpr double EPS_EWALD = 1.0e-6; +static constexpr double EPS_EWALD_SQR = 1.0e-12; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_lj_cut_tip4p_cut_omp.cpp b/src/OPENMP/pair_lj_cut_tip4p_cut_omp.cpp index 04e94ded0e..c54e681686 100644 --- a/src/OPENMP/pair_lj_cut_tip4p_cut_omp.cpp +++ b/src/OPENMP/pair_lj_cut_tip4p_cut_omp.cpp @@ -28,14 +28,6 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 - /* ---------------------------------------------------------------------- */ PairLJCutTIP4PCutOMP::PairLJCutTIP4PCutOMP(LAMMPS *lmp) : diff --git a/src/OPENMP/pair_lj_cut_tip4p_long_omp.cpp b/src/OPENMP/pair_lj_cut_tip4p_long_omp.cpp index b346154df0..8f824ca272 100644 --- a/src/OPENMP/pair_lj_cut_tip4p_long_omp.cpp +++ b/src/OPENMP/pair_lj_cut_tip4p_long_omp.cpp @@ -13,28 +13,25 @@ Contributing author: Axel Kohlmeyer (Temple U) ------------------------------------------------------------------------- */ -#include "omp_compat.h" #include "pair_lj_cut_tip4p_long_omp.h" -#include + #include "atom.h" -#include "domain.h" #include "comm.h" -#include "force.h" -#include "neighbor.h" +#include "domain.h" #include "error.h" +#include "ewald_const.h" +#include "force.h" #include "memory.h" #include "neigh_list.h" - +#include "neighbor.h" #include "suffix.h" -using namespace LAMMPS_NS; -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +#include + +#include "omp_compat.h" + +using namespace LAMMPS_NS; +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_lj_cut_tip4p_long_soft_omp.cpp b/src/OPENMP/pair_lj_cut_tip4p_long_soft_omp.cpp index c19828bf04..a646a2dec1 100644 --- a/src/OPENMP/pair_lj_cut_tip4p_long_soft_omp.cpp +++ b/src/OPENMP/pair_lj_cut_tip4p_long_soft_omp.cpp @@ -13,28 +13,25 @@ Contributing author: Axel Kohlmeyer (Temple U) ------------------------------------------------------------------------- */ -#include "omp_compat.h" -#include #include "pair_lj_cut_tip4p_long_soft_omp.h" + #include "atom.h" -#include "domain.h" #include "comm.h" -#include "force.h" -#include "neighbor.h" +#include "domain.h" #include "error.h" +#include "ewald_const.h" +#include "force.h" #include "memory.h" #include "neigh_list.h" - +#include "neighbor.h" #include "suffix.h" -using namespace LAMMPS_NS; -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +#include + +#include "omp_compat.h" + +using namespace LAMMPS_NS; +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_lj_expand_sphere_omp.cpp b/src/OPENMP/pair_lj_expand_sphere_omp.cpp index c19d3e7a7f..40f878cdc2 100644 --- a/src/OPENMP/pair_lj_expand_sphere_omp.cpp +++ b/src/OPENMP/pair_lj_expand_sphere_omp.cpp @@ -21,6 +21,8 @@ #include "neigh_list.h" #include "suffix.h" +#include + #include "omp_compat.h" using namespace LAMMPS_NS; using MathSpecial::powint; diff --git a/src/OPENMP/pair_lj_long_coul_long_omp.cpp b/src/OPENMP/pair_lj_long_coul_long_omp.cpp index e1f9e5fea4..1a930b1125 100644 --- a/src/OPENMP/pair_lj_long_coul_long_omp.cpp +++ b/src/OPENMP/pair_lj_long_coul_long_omp.cpp @@ -17,6 +17,7 @@ #include "atom.h" #include "comm.h" +#include "ewald_const.h" #include "force.h" #include "math_extra.h" #include "neigh_list.h" @@ -26,16 +27,10 @@ #include #include "omp_compat.h" + using namespace LAMMPS_NS; using namespace MathExtra; - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_lj_long_tip4p_long_omp.cpp b/src/OPENMP/pair_lj_long_tip4p_long_omp.cpp index b452960386..b8206bd21f 100644 --- a/src/OPENMP/pair_lj_long_tip4p_long_omp.cpp +++ b/src/OPENMP/pair_lj_long_tip4p_long_omp.cpp @@ -19,6 +19,7 @@ #include "comm.h" #include "domain.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "memory.h" #include "neigh_list.h" @@ -28,15 +29,9 @@ #include #include "omp_compat.h" -using namespace LAMMPS_NS; -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace LAMMPS_NS; +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_lubricate_omp.cpp b/src/OPENMP/pair_lubricate_omp.cpp index 2145744a5b..5ba66ff266 100644 --- a/src/OPENMP/pair_lubricate_omp.cpp +++ b/src/OPENMP/pair_lubricate_omp.cpp @@ -32,10 +32,6 @@ using namespace LAMMPS_NS; using namespace MathConst; -// same as fix_wall.cpp - -enum{EDGE,CONSTANT,VARIABLE}; - /* ---------------------------------------------------------------------- */ PairLubricateOMP::PairLubricateOMP(LAMMPS *lmp) : @@ -74,7 +70,7 @@ void PairLubricateOMP::compute(int eflag, int vflag) for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; diff --git a/src/OPENMP/pair_lubricate_poly_omp.cpp b/src/OPENMP/pair_lubricate_poly_omp.cpp index 5b98ec7b14..ebb2d65496 100644 --- a/src/OPENMP/pair_lubricate_poly_omp.cpp +++ b/src/OPENMP/pair_lubricate_poly_omp.cpp @@ -32,10 +32,6 @@ using namespace LAMMPS_NS; using namespace MathConst; -// same as fix_wall.cpp - -enum{EDGE,CONSTANT,VARIABLE}; - /* ---------------------------------------------------------------------- */ PairLubricatePolyOMP::PairLubricatePolyOMP(LAMMPS *_lmp) : @@ -74,7 +70,7 @@ void PairLubricatePolyOMP::compute(int eflag, int vflag) for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; diff --git a/src/OPENMP/pair_nm_cut_coul_long_omp.cpp b/src/OPENMP/pair_nm_cut_coul_long_omp.cpp index 6694a1237b..313905c967 100644 --- a/src/OPENMP/pair_nm_cut_coul_long_omp.cpp +++ b/src/OPENMP/pair_nm_cut_coul_long_omp.cpp @@ -17,6 +17,7 @@ #include "atom.h" #include "comm.h" +#include "ewald_const.h" #include "force.h" #include "neigh_list.h" #include "suffix.h" @@ -24,15 +25,9 @@ #include #include "omp_compat.h" -using namespace LAMMPS_NS; -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace LAMMPS_NS; +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_rebomos_omp.cpp b/src/OPENMP/pair_rebomos_omp.cpp new file mode 100644 index 0000000000..06b979d41a --- /dev/null +++ b/src/OPENMP/pair_rebomos_omp.cpp @@ -0,0 +1,701 @@ +// clang-format off +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + LAMMPS Development team: developers@lammps.org + + 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. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + References: + + This code: + Stewart J A and Spearot D E (2013) Atomistic simulations of nanoindentation on the basal plane of crystalline molybdenum disulfide. Modelling Simul. Mater. Sci. Eng. 21. + + Based on: + Liang T, Phillpot S R and Sinnott S B (2009) Parameterization of a reactive many-body potential for Mo2S systems. Phys. Rev. B79 245110. + Liang T, Phillpot S R and Sinnott S B (2012) Erratum: Parameterization of a reactive many-body potential for Mo-S systems. (Phys. Rev. B79 245110 (2009)) Phys. Rev. B85 199903(E). + + LAMMPS file contributing authors: James Stewart, Khanh Dang and Douglas Spearot (University of Arkansas) +------------------------------------------------------------------------- */ + +// clang-format on + +#include "pair_rebomos_omp.h" + +#include "atom.h" +#include "comm.h" +#include "error.h" +#include "math_special.h" +#include "memory.h" +#include "my_page.h" +#include "neigh_list.h" + +#include "suffix.h" + +#include + +#include "omp_compat.h" +#if defined(_OPENMP) +#include +#endif + +using namespace LAMMPS_NS; +using MathSpecial::cube; +using MathSpecial::powint; +using MathSpecial::square; + +static constexpr double TOL = 1.0e-9; + +/* ---------------------------------------------------------------------- */ + +PairREBOMoSOMP::PairREBOMoSOMP(LAMMPS *lmp) : PairREBOMoS(lmp), ThrOMP(lmp, THR_PAIR) +{ + suffix_flag |= Suffix::OMP; + respa_enable = 0; +} + +// clang-format off + +/* ---------------------------------------------------------------------- */ + +void PairREBOMoSOMP::compute(int eflag, int vflag) +{ + ev_init(eflag,vflag); + + REBO_neigh_thr(); + + const int nall = atom->nlocal + atom->nghost; + const int nthreads = comm->nthreads; + const int inum = list->inum; + +#if defined(_OPENMP) +#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(eflag,vflag) +#endif + { + int ifrom, ito, tid; + + loop_setup_thr(ifrom, ito, tid, inum, nthreads); + ThrData *thr = fix->get_thr(tid); + thr->timer(Timer::START); + ev_setup_thr(eflag, vflag, nall, eatom, vatom, nullptr, thr); + + FREBO_thr(ifrom,ito,eflag,thr); + FLJ_thr(ifrom,ito,eflag,thr); + + thr->timer(Timer::PAIR); + reduce_thr(this, eflag, vflag, thr); + } // end of omp parallel region +} + +/* ---------------------------------------------------------------------- + create REBO neighbor list from main neighbor list + REBO neighbor list stores neighbors of ghost atoms +------------------------------------------------------------------------- */ + +void PairREBOMoSOMP::REBO_neigh_thr() +{ + const int nthreads = comm->nthreads; + + if (atom->nmax > maxlocal) { + maxlocal = atom->nmax; + memory->destroy(REBO_numneigh); + memory->sfree(REBO_firstneigh); + memory->destroy(nM); + memory->destroy(nS); + memory->create(REBO_numneigh,maxlocal,"REBOMoS:numneigh"); + REBO_firstneigh = (int **) memory->smalloc(maxlocal*sizeof(int *), + "REBOMoS:firstneigh"); + memory->create(nM,maxlocal,"REBOMoS:nM"); + memory->create(nS,maxlocal,"REBOMoS:nS"); + } + +#if defined(_OPENMP) +#pragma omp parallel LMP_DEFAULT_NONE +#endif + { + int i,j,ii,jj,n,jnum,itype,jtype; + double xtmp,ytmp,ztmp,delx,dely,delz,rsq,dS; + int *ilist,*jlist,*numneigh,**firstneigh; + int *neighptr; + + double **x = atom->x; + int *type = atom->type; + + const int allnum = list->inum + list->gnum; + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + +#if defined(_OPENMP) + const int tid = omp_get_thread_num(); +#else + const int tid = 0; +#endif + + const int iidelta = 1 + allnum/nthreads; + const int iifrom = tid*iidelta; + const int iito = ((iifrom+iidelta)>allnum) ? allnum : (iifrom+iidelta); + + // store all REBO neighs of owned and ghost atoms + // scan full neighbor list of I + + // each thread has its own page allocator + MyPage &ipg = ipage[tid]; + ipg.reset(); + + for (ii = iifrom; ii < iito; ii++) { + i = ilist[ii]; + + n = 0; + neighptr = ipg.vget(); + + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + itype = map[type[i]]; + nM[i] = nS[i] = 0.0; + jlist = firstneigh[i]; + jnum = numneigh[i]; + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + j &= NEIGHMASK; + jtype = map[type[j]]; + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + rsq = delx*delx + dely*dely + delz*delz; + + if (rsq < rcmaxsq[itype][jtype]) { + neighptr[n++] = j; + if (jtype == 0) + nM[i] += Sp(sqrt(rsq),rcmin[itype][jtype],rcmax[itype][jtype],dS); + else + nS[i] += Sp(sqrt(rsq),rcmin[itype][jtype],rcmax[itype][jtype],dS); + } + } + + REBO_firstneigh[i] = neighptr; + REBO_numneigh[i] = n; + ipg.vgot(n); + if (ipg.status()) + error->one(FLERR,"REBO list overflow, boost neigh_modify one"); + } + } +} + +/* ---------------------------------------------------------------------- + REBO forces and energy +------------------------------------------------------------------------- */ + +void PairREBOMoSOMP::FREBO_thr(int ifrom, int ito, int eflag, ThrData * const thr) +{ + int i,j,k,ii,itype,jtype; + tagint itag, jtag; + double delx,dely,delz,evdwl,fpair,xtmp,ytmp,ztmp; + double rsq,rij,wij; + double Qij,Aij,alphaij,VR,pre,dVRdi,VA,bij,dVAdi,dVA; + double dwij,del[3]; + int *ilist,*REBO_neighs; + + evdwl = 0.0; + + const double * const * const x = atom->x; + double * const * const f = thr->get_f(); + const int * const type = atom->type; + const tagint * const tag = atom->tag; + const int nlocal = atom->nlocal; + + ilist = list->ilist; + + // two-body interactions from REBO neighbor list, skip half of them + + for (ii = ifrom; ii < ito; ii++) { + i = ilist[ii]; + itag = tag[i]; + itype = map[type[i]]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + REBO_neighs = REBO_firstneigh[i]; + + for (k = 0; k < REBO_numneigh[i]; k++) { + j = REBO_neighs[k]; + jtag = tag[j]; + + if (itag > jtag) { + if ((itag+jtag) % 2 == 0) continue; + } else if (itag < jtag) { + if ((itag+jtag) % 2 == 1) continue; + } else { + if (x[j][2] < ztmp) continue; + if (x[j][2] == ztmp && x[j][1] < ytmp) continue; + if (x[j][2] == ztmp && x[j][1] == ytmp && x[j][0] < xtmp) continue; + } + + jtype = map[type[j]]; + + delx = x[i][0] - x[j][0]; + dely = x[i][1] - x[j][1]; + delz = x[i][2] - x[j][2]; + rsq = delx*delx + dely*dely + delz*delz; + rij = sqrt(rsq); + wij = Sp(rij,rcmin[itype][jtype],rcmax[itype][jtype],dwij); + if (wij <= TOL) continue; + + Qij = Q[itype][jtype]; + Aij = A[itype][jtype]; + alphaij = alpha[itype][jtype]; + + VR = wij*(1.0+(Qij/rij)) * Aij*exp(-alphaij*rij); + pre = wij*Aij * exp(-alphaij*rij); + dVRdi = pre * ((-alphaij)-(Qij/rsq)-(Qij*alphaij/rij)); + dVRdi += VR/wij * dwij; + + VA = dVA = 0.0; + VA = -wij * BIJc[itype][jtype] * exp(-Beta[itype][jtype]*rij); + + dVA = -Beta[itype][jtype] * VA; + dVA += VA/wij * dwij; + + del[0] = delx; + del[1] = dely; + del[2] = delz; + bij = bondorder_thr(i,j,del,rij,VA,thr); + dVAdi = bij*dVA; + + fpair = -(dVRdi+dVAdi) / rij; + f[i][0] += delx*fpair; + f[i][1] += dely*fpair; + f[i][2] += delz*fpair; + f[j][0] -= delx*fpair; + f[j][1] -= dely*fpair; + f[j][2] -= delz*fpair; + + if (eflag) evdwl = VR + bij*VA; + if (evflag) ev_tally_thr(this,i,j,nlocal,/* newton_pair */1,evdwl,0.0,fpair,delx,dely,delz,thr); + } + } +} + +/* ---------------------------------------------------------------------- + compute LJ forces and energy +------------------------------------------------------------------------- */ + +void PairREBOMoSOMP::FLJ_thr(int ifrom, int ito, int eflag, ThrData * const thr) +{ + int i,j,ii,jj,jnum,itype,jtype; + tagint itag,jtag; + double evdwl,fpair,xtmp,ytmp,ztmp; + double rij,delij[3],rijsq; + double VLJ,dVLJ; + double vdw,dvdw; + double r2inv,r6inv; + int *ilist,*jlist,*numneigh,**firstneigh; + double c2,c3,dr,drp,r6; + + // I-J interaction from full neighbor list + // skip 1/2 of interactions since only consider each pair once + + evdwl = 0.0; + + const double * const * const x = atom->x; + double * const * const f = thr->get_f(); + const tagint * const tag = atom->tag; + const int * const type = atom->type; + const int nlocal = atom->nlocal; + + ilist = list->ilist; + numneigh = list->numneigh; + firstneigh = list->firstneigh; + + // loop over neighbors of my atoms + + for (ii = ifrom; ii < ito; ii++) { + i = ilist[ii]; + itag = tag[i]; + itype = map[type[i]]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + jlist = firstneigh[i]; + jnum = numneigh[i]; + + for (jj = 0; jj < jnum; jj++) { + j = jlist[jj]; + j &= NEIGHMASK; + jtag = tag[j]; + + if (itag > jtag) { + if ((itag+jtag) % 2 == 0) continue; + } else if (itag < jtag) { + if ((itag+jtag) % 2 == 1) continue; + } else { + if (x[j][2] < ztmp) continue; + if (x[j][2] == ztmp && x[j][1] < ytmp) continue; + if (x[j][2] == ztmp && x[j][1] == ytmp && x[j][0] < xtmp) continue; + } + jtype = map[type[j]]; + + delij[0] = xtmp - x[j][0]; + delij[1] = ytmp - x[j][1]; + delij[2] = ztmp - x[j][2]; + rijsq = delij[0]*delij[0] + delij[1]*delij[1] + delij[2]*delij[2]; + rij = sqrt(rijsq); + + // compute LJ forces and energy + + // Outside Rmax + if (rij > rcLJmax[itype][jtype] || rij < rcLJmin[itype][jtype]){ + VLJ = 0; + dVLJ = 0; + } + + // Inside Rmax and above 0.95*sigma + else if (rij <= rcLJmax[itype][jtype] && rij >= 0.95*sigma[itype][jtype]){ + r2inv = 1.0/rijsq; + r6inv = r2inv*r2inv*r2inv; + VLJ = r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype]); + dVLJ = -r6inv*(lj1[itype][jtype]*r6inv - lj2[itype][jtype])/rij; + } + + // Below 0.95*sigma + else if (rij < 0.95*sigma[itype][jtype] && rij >= rcLJmin[itype][jtype]){ + dr = 0.95*sigma[itype][jtype] - rcLJmin[itype][jtype]; + r6 = powint((sigma[itype][jtype]/(0.95*sigma[itype][jtype])),6); + vdw = 4*epsilon[itype][jtype]*r6*(r6 - 1.0); + dvdw = (-4*epsilon[itype][jtype]/(0.95*sigma[itype][jtype]))*r6*(12.0*r6 - 6.0); + c2 = ((3.0/dr)*vdw - dvdw)/dr; + c3 = (vdw/(dr*dr) - c2)/dr; + + drp = rij - rcLJmin[itype][jtype]; + VLJ = drp*drp*(drp*c3 + c2); + dVLJ = drp*(3.0*drp*c3 + 2.0*c2); + } + + fpair = -dVLJ/rij; + f[i][0] += delij[0]*fpair; + f[i][1] += delij[1]*fpair; + f[i][2] += delij[2]*fpair; + f[j][0] -= delij[0]*fpair; + f[j][1] -= delij[1]*fpair; + f[j][2] -= delij[2]*fpair; + + if (eflag) evdwl = VLJ; + if (evflag) ev_tally_thr(this,i,j,nlocal,/*newton_pair*/1,evdwl,0.0,fpair,delij[0],delij[1],delij[2],thr); + + } + } +} + +/* ---------------------------------------------------------------------- + Bij function + + The bond order term modified the attractive portion of the REBO + potential based on the number of atoms around a specific pair + and the bond angle between sets of three atoms. + + The functions G(cos(theta)) and P(N) are evaluated and their + derivatives are also computed for use in the force calculation. +------------------------------------------------------------------------- */ + +double PairREBOMoSOMP::bondorder_thr(int i, int j, double rij[3], double rijmag, double VA, ThrData *thr) +{ + int atomi,atomj,atomk,atoml; + int k,l; + int itype, jtype, ktype, ltype; + double rik[3], rjl[3], rji[3], rki[3],rlj[3], dwjl, bij; + double NijM,NijS,NjiM,NjiS,wik,dwik,wjl; + double rikmag,rjlmag,cosjik,cosijl,g,tmp2; + double Etmp,pij,tmp,dwij,dS; + double dgdc,pji; + double dcosjikdri[3],dcosijldri[3],dcosjikdrk[3]; + double dp; + double dcosjikdrj[3],dcosijldrj[3],dcosijldrl[3]; + double fi[3],fj[3],fk[3],fl[3]; + double PijS, PjiS; + int *REBO_neighs; + + const double * const * const x = atom->x; + double * const * const f = thr->get_f(); + const int * const type = atom->type; + + atomi = i; + atomj = j; + itype = map[type[i]]; + jtype = map[type[j]]; + Sp(rijmag,rcmin[itype][jtype],rcmax[itype][jtype],dwij); + NijM = nM[i]; + NijS = nS[i]; + NjiM = nM[j]; + NjiS = nS[j]; + bij = 0.0; + tmp = 0.0; + tmp2 = 0.0; + dgdc = 0.0; + Etmp = 0.0; + + REBO_neighs = REBO_firstneigh[i]; + for (k = 0; k < REBO_numneigh[i]; k++) { + atomk = REBO_neighs[k]; + if (atomk != atomj) { + ktype = map[type[atomk]]; + rik[0] = x[atomi][0]-x[atomk][0]; + rik[1] = x[atomi][1]-x[atomk][1]; + rik[2] = x[atomi][2]-x[atomk][2]; + rikmag = sqrt((rik[0]*rik[0])+(rik[1]*rik[1])+(rik[2]*rik[2])); + wik = Sp(rikmag,rcmin[itype][ktype],rcmax[itype][ktype],dS); + cosjik = ((rij[0]*rik[0])+(rij[1]*rik[1])+(rij[2]*rik[2])) / (rijmag*rikmag); + cosjik = MIN(cosjik,1.0); + cosjik = MAX(cosjik,-1.0); + + // evaluate g and derivative dg + + g = gSpline(cosjik,itype,dgdc); + Etmp = Etmp+(wik*g); + } + } + + dp = 0.0; + PijS = PijSpline(NijM,NijS,itype,dp); + pij = 1.0/sqrt(1.0+Etmp+PijS); + tmp = -0.5*cube(pij); + + // derivative calculations + + REBO_neighs = REBO_firstneigh[i]; + for (k = 0; k < REBO_numneigh[i]; k++) { + atomk = REBO_neighs[k]; + if (atomk != atomj) { + ktype = map[type[atomk]]; + rik[0] = x[atomi][0]-x[atomk][0]; + rik[1] = x[atomi][1]-x[atomk][1]; + rik[2] = x[atomi][2]-x[atomk][2]; + rikmag = sqrt((rik[0]*rik[0])+(rik[1]*rik[1])+(rik[2]*rik[2])); + wik = Sp(rikmag,rcmin[itype][ktype],rcmax[itype][ktype],dwik); + cosjik = (rij[0]*rik[0] + rij[1]*rik[1] + rij[2]*rik[2]) / (rijmag*rikmag); + cosjik = MIN(cosjik,1.0); + cosjik = MAX(cosjik,-1.0); + + dcosjikdri[0] = ((rij[0]+rik[0])/(rijmag*rikmag)) - + (cosjik*((rij[0]/(rijmag*rijmag))+(rik[0]/(rikmag*rikmag)))); + dcosjikdri[1] = ((rij[1]+rik[1])/(rijmag*rikmag)) - + (cosjik*((rij[1]/(rijmag*rijmag))+(rik[1]/(rikmag*rikmag)))); + dcosjikdri[2] = ((rij[2]+rik[2])/(rijmag*rikmag)) - + (cosjik*((rij[2]/(rijmag*rijmag))+(rik[2]/(rikmag*rikmag)))); + dcosjikdrk[0] = (-rij[0]/(rijmag*rikmag)) + + (cosjik*(rik[0]/(rikmag*rikmag))); + dcosjikdrk[1] = (-rij[1]/(rijmag*rikmag)) + + (cosjik*(rik[1]/(rikmag*rikmag))); + dcosjikdrk[2] = (-rij[2]/(rijmag*rikmag)) + + (cosjik*(rik[2]/(rikmag*rikmag))); + dcosjikdrj[0] = (-rik[0]/(rijmag*rikmag)) + + (cosjik*(rij[0]/(rijmag*rijmag))); + dcosjikdrj[1] = (-rik[1]/(rijmag*rikmag)) + + (cosjik*(rij[1]/(rijmag*rijmag))); + dcosjikdrj[2] = (-rik[2]/(rijmag*rikmag)) + + (cosjik*(rij[2]/(rijmag*rijmag))); + + g = gSpline(cosjik,itype,dgdc); + tmp2 = VA*0.5*(tmp*wik*dgdc); + fj[0] = -tmp2*dcosjikdrj[0]; + fj[1] = -tmp2*dcosjikdrj[1]; + fj[2] = -tmp2*dcosjikdrj[2]; + fi[0] = -tmp2*dcosjikdri[0]; + fi[1] = -tmp2*dcosjikdri[1]; + fi[2] = -tmp2*dcosjikdri[2]; + fk[0] = -tmp2*dcosjikdrk[0]; + fk[1] = -tmp2*dcosjikdrk[1]; + fk[2] = -tmp2*dcosjikdrk[2]; + + // coordination forces + + // dwik forces (from partial derivative) + + tmp2 = VA*0.5*(tmp*dwik*g)/rikmag; + fi[0] -= tmp2*rik[0]; + fi[1] -= tmp2*rik[1]; + fi[2] -= tmp2*rik[2]; + fk[0] += tmp2*rik[0]; + fk[1] += tmp2*rik[1]; + fk[2] += tmp2*rik[2]; + + // PIJ forces (from coordination P(N) term) + + tmp2 = VA*0.5*(tmp*dp*dwik)/rikmag; + fi[0] -= tmp2*rik[0]; + fi[1] -= tmp2*rik[1]; + fi[2] -= tmp2*rik[2]; + fk[0] += tmp2*rik[0]; + fk[1] += tmp2*rik[1]; + fk[2] += tmp2*rik[2]; + + // dgdN forces are removed + + f[atomi][0] += fi[0]; f[atomi][1] += fi[1]; f[atomi][2] += fi[2]; + f[atomj][0] += fj[0]; f[atomj][1] += fj[1]; f[atomj][2] += fj[2]; + f[atomk][0] += fk[0]; f[atomk][1] += fk[1]; f[atomk][2] += fk[2]; + + if (vflag_either) { + rji[0] = -rij[0]; rji[1] = -rij[1]; rji[2] = -rij[2]; + rki[0] = -rik[0]; rki[1] = -rik[1]; rki[2] = -rik[2]; + v_tally3_thr(this,atomi,atomj,atomk,fj,fk,rji,rki,thr); + } + } + } + + // PIJ force contribution additional term + tmp2 = -VA*0.5*(tmp*dp*dwij)/rijmag; + + f[atomi][0] += rij[0]*tmp2; + f[atomi][1] += rij[1]*tmp2; + f[atomi][2] += rij[2]*tmp2; + f[atomj][0] -= rij[0]*tmp2; + f[atomj][1] -= rij[1]*tmp2; + f[atomj][2] -= rij[2]*tmp2; + + if (vflag_either) v_tally2_thr(this,atomi,atomj,tmp2,rij,thr); + + tmp = 0.0; + tmp2 = 0.0; + Etmp = 0.0; + + REBO_neighs = REBO_firstneigh[j]; + for (l = 0; l < REBO_numneigh[j]; l++) { + atoml = REBO_neighs[l]; + if (atoml != atomi) { + ltype = map[type[atoml]]; + rjl[0] = x[atomj][0]-x[atoml][0]; + rjl[1] = x[atomj][1]-x[atoml][1]; + rjl[2] = x[atomj][2]-x[atoml][2]; + rjlmag = sqrt((rjl[0]*rjl[0])+(rjl[1]*rjl[1])+(rjl[2]*rjl[2])); + wjl = Sp(rjlmag,rcmin[jtype][ltype],rcmax[jtype][ltype],dS); + cosijl = -1.0*((rij[0]*rjl[0])+(rij[1]*rjl[1])+(rij[2]*rjl[2])) / (rijmag*rjlmag); + cosijl = MIN(cosijl,1.0); + cosijl = MAX(cosijl,-1.0); + + // evaluate g and derivative dg + + g = gSpline(cosijl,jtype,dgdc); + Etmp = Etmp+(wjl*g); + } + } + + dp = 0.0; + PjiS = PijSpline(NjiM,NjiS,jtype,dp); + pji = 1.0/sqrt(1.0+Etmp+PjiS); + tmp = -0.5*cube(pji); + + REBO_neighs = REBO_firstneigh[j]; + for (l = 0; l < REBO_numneigh[j]; l++) { + atoml = REBO_neighs[l]; + if (atoml != atomi) { + ltype = map[type[atoml]]; + rjl[0] = x[atomj][0]-x[atoml][0]; + rjl[1] = x[atomj][1]-x[atoml][1]; + rjl[2] = x[atomj][2]-x[atoml][2]; + rjlmag = sqrt((rjl[0]*rjl[0])+(rjl[1]*rjl[1])+(rjl[2]*rjl[2])); + wjl = Sp(rjlmag,rcmin[jtype][ltype],rcmax[jtype][ltype],dwjl); + cosijl = (-1.0*((rij[0]*rjl[0])+(rij[1]*rjl[1])+(rij[2]*rjl[2]))) / (rijmag*rjlmag); + cosijl = MIN(cosijl,1.0); + cosijl = MAX(cosijl,-1.0); + + dcosijldri[0] = (-rjl[0]/(rijmag*rjlmag)) - + (cosijl*rij[0]/(rijmag*rijmag)); + dcosijldri[1] = (-rjl[1]/(rijmag*rjlmag)) - + (cosijl*rij[1]/(rijmag*rijmag)); + dcosijldri[2] = (-rjl[2]/(rijmag*rjlmag)) - + (cosijl*rij[2]/(rijmag*rijmag)); + dcosijldrj[0] = ((-rij[0]+rjl[0])/(rijmag*rjlmag)) + + (cosijl*((rij[0]/square(rijmag))-(rjl[0]/(rjlmag*rjlmag)))); + dcosijldrj[1] = ((-rij[1]+rjl[1])/(rijmag*rjlmag)) + + (cosijl*((rij[1]/square(rijmag))-(rjl[1]/(rjlmag*rjlmag)))); + dcosijldrj[2] = ((-rij[2]+rjl[2])/(rijmag*rjlmag)) + + (cosijl*((rij[2]/square(rijmag))-(rjl[2]/(rjlmag*rjlmag)))); + dcosijldrl[0] = (rij[0]/(rijmag*rjlmag))+(cosijl*rjl[0]/(rjlmag*rjlmag)); + dcosijldrl[1] = (rij[1]/(rijmag*rjlmag))+(cosijl*rjl[1]/(rjlmag*rjlmag)); + dcosijldrl[2] = (rij[2]/(rijmag*rjlmag))+(cosijl*rjl[2]/(rjlmag*rjlmag)); + + // evaluate g and derivatives dg + + g = gSpline(cosijl,jtype,dgdc); + tmp2 = VA*0.5*(tmp*wjl*dgdc); + fi[0] = -tmp2*dcosijldri[0]; + fi[1] = -tmp2*dcosijldri[1]; + fi[2] = -tmp2*dcosijldri[2]; + fj[0] = -tmp2*dcosijldrj[0]; + fj[1] = -tmp2*dcosijldrj[1]; + fj[2] = -tmp2*dcosijldrj[2]; + fl[0] = -tmp2*dcosijldrl[0]; + fl[1] = -tmp2*dcosijldrl[1]; + fl[2] = -tmp2*dcosijldrl[2]; + + // coordination forces + + // dwik forces (from partial derivative) + + tmp2 = VA*0.5*(tmp*dwjl*g)/rjlmag; + fj[0] -= tmp2*rjl[0]; + fj[1] -= tmp2*rjl[1]; + fj[2] -= tmp2*rjl[2]; + fl[0] += tmp2*rjl[0]; + fl[1] += tmp2*rjl[1]; + fl[2] += tmp2*rjl[2]; + + // PIJ forces (coordination) + + tmp2 = VA*0.5*(tmp*dp*dwjl)/rjlmag; + fj[0] -= tmp2*rjl[0]; + fj[1] -= tmp2*rjl[1]; + fj[2] -= tmp2*rjl[2]; + fl[0] += tmp2*rjl[0]; + fl[1] += tmp2*rjl[1]; + fl[2] += tmp2*rjl[2]; + + // dgdN forces are removed + + f[atomi][0] += fi[0]; f[atomi][1] += fi[1]; f[atomi][2] += fi[2]; + f[atomj][0] += fj[0]; f[atomj][1] += fj[1]; f[atomj][2] += fj[2]; + f[atoml][0] += fl[0]; f[atoml][1] += fl[1]; f[atoml][2] += fl[2]; + + if (vflag_either) { + rlj[0] = -rjl[0]; rlj[1] = -rjl[1]; rlj[2] = -rjl[2]; + v_tally3_thr(this,atomi,atomj,atoml,fi,fl,rij,rlj,thr); + } + } + } + + // PIJ force contribution additional term + + tmp2 = -VA*0.5*(tmp*dp*dwij)/rijmag; + f[atomi][0] += rij[0]*tmp2; + f[atomi][1] += rij[1]*tmp2; + f[atomi][2] += rij[2]*tmp2; + f[atomj][0] -= rij[0]*tmp2; + f[atomj][1] -= rij[1]*tmp2; + f[atomj][2] -= rij[2]*tmp2; + + if (vflag_either) v_tally2_thr(this,atomi,atomj,tmp2,rij,thr); + + bij = (0.5*(pij+pji)); + return bij; +} + +/* ---------------------------------------------------------------------- + memory usage of local atom-based arrays +------------------------------------------------------------------------- */ + +double PairREBOMoSOMP::memory_usage() +{ + double bytes = memory_usage_thr(); + bytes += PairREBOMoS::memory_usage(); + + return bytes; +} diff --git a/src/OPENMP/pair_rebomos_omp.h b/src/OPENMP/pair_rebomos_omp.h new file mode 100644 index 0000000000..ea87f51950 --- /dev/null +++ b/src/OPENMP/pair_rebomos_omp.h @@ -0,0 +1,46 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + LAMMPS Development team: developers@lammps.org + + 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. +------------------------------------------------------------------------- */ + +#ifdef PAIR_CLASS +// clang-format off +PairStyle(rebomos/omp,PairREBOMoSOMP); +// clang-format on +#else + +#ifndef LMP_PAIR_REBOMOS_OMP_H +#define LMP_PAIR_REBOMOS_OMP_H + +#include "pair_rebomos.h" +#include "thr_omp.h" + +namespace LAMMPS_NS { + +class PairREBOMoSOMP : public PairREBOMoS, public ThrOMP { + public: + PairREBOMoSOMP(class LAMMPS *); + + void compute(int, int) override; + double memory_usage() override; + + protected: + void FREBO_thr(int ifrom, int ito, int eflag, ThrData *const thr); + void FLJ_thr(int ifrom, int ito, int eflag, ThrData *const thr); + + void REBO_neigh_thr(); + + double bondorder_thr(int, int, double *, double, double, ThrData *const thr); +}; +} // namespace LAMMPS_NS + +#endif +#endif diff --git a/src/OPENMP/pair_soft_omp.cpp b/src/OPENMP/pair_soft_omp.cpp index 0be8c80dcf..309d11a6f9 100644 --- a/src/OPENMP/pair_soft_omp.cpp +++ b/src/OPENMP/pair_soft_omp.cpp @@ -28,7 +28,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 1.0e-4 +static constexpr double SMALL = 1.0e-4; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_tersoff_table_omp.cpp b/src/OPENMP/pair_tersoff_table_omp.cpp index 5c44aa3329..edd5b73d89 100644 --- a/src/OPENMP/pair_tersoff_table_omp.cpp +++ b/src/OPENMP/pair_tersoff_table_omp.cpp @@ -26,15 +26,15 @@ #include "omp_compat.h" using namespace LAMMPS_NS; -#define GRIDSTART 0.1 -#define GRIDDENSITY_FCUTOFF 5000 -#define GRIDDENSITY_EXP 12000 -#define GRIDDENSITY_GTETA 12000 -#define GRIDDENSITY_BIJ 7500 +static constexpr double GRIDSTART = 0.1; +static constexpr int GRIDDENSITY_FCUTOFF = 5000; +static constexpr int GRIDDENSITY_EXP = 12000; +static constexpr int GRIDDENSITY_GTETA = 12000; +static constexpr int GRIDDENSITY_BIJ = 7500; // max number of interaction per atom for environment potential -#define leadingDimensionInteractionList 64 +static constexpr int leadingDimensionInteractionList = 64; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_tersoff_zbl_omp.cpp b/src/OPENMP/pair_tersoff_zbl_omp.cpp index cefa89665a..524d7fe509 100644 --- a/src/OPENMP/pair_tersoff_zbl_omp.cpp +++ b/src/OPENMP/pair_tersoff_zbl_omp.cpp @@ -34,7 +34,7 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define DELTA 4 +static constexpr int DELTA = 4; /* ---------------------------------------------------------------------- Fermi-like smoothing function diff --git a/src/OPENMP/pair_tip4p_cut_omp.cpp b/src/OPENMP/pair_tip4p_cut_omp.cpp index 497743daff..d43559fc81 100644 --- a/src/OPENMP/pair_tip4p_cut_omp.cpp +++ b/src/OPENMP/pair_tip4p_cut_omp.cpp @@ -26,15 +26,8 @@ #include "neigh_list.h" #include "suffix.h" -using namespace LAMMPS_NS; -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_tip4p_long_omp.cpp b/src/OPENMP/pair_tip4p_long_omp.cpp index 8c0648cc4a..186549a999 100644 --- a/src/OPENMP/pair_tip4p_long_omp.cpp +++ b/src/OPENMP/pair_tip4p_long_omp.cpp @@ -13,28 +13,25 @@ Contributing author: Axel Kohlmeyer (Temple U) ------------------------------------------------------------------------- */ -#include "omp_compat.h" -#include #include "pair_tip4p_long_omp.h" + #include "atom.h" -#include "domain.h" #include "comm.h" -#include "force.h" -#include "neighbor.h" +#include "domain.h" #include "error.h" +#include "ewald_const.h" +#include "force.h" #include "memory.h" #include "neigh_list.h" - +#include "neighbor.h" #include "suffix.h" -using namespace LAMMPS_NS; -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +#include + +#include "omp_compat.h" + +using namespace LAMMPS_NS; +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_tip4p_long_soft_omp.cpp b/src/OPENMP/pair_tip4p_long_soft_omp.cpp index 4a7d6bdfe2..d2fa95a10c 100644 --- a/src/OPENMP/pair_tip4p_long_soft_omp.cpp +++ b/src/OPENMP/pair_tip4p_long_soft_omp.cpp @@ -22,19 +22,14 @@ #include "force.h" #include "neighbor.h" #include "error.h" +#include "ewald_const.h" #include "memory.h" #include "neigh_list.h" #include "suffix.h" -using namespace LAMMPS_NS; -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace LAMMPS_NS; +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pppm_cg_omp.cpp b/src/OPENMP/pppm_cg_omp.cpp index 4c751a16f7..6630510003 100644 --- a/src/OPENMP/pppm_cg_omp.cpp +++ b/src/OPENMP/pppm_cg_omp.cpp @@ -38,15 +38,8 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#define ONEF 1.0f -#else -#define ZEROF 0.0 -#define ONEF 1.0 -#endif - -#define EPS_HOC 1.0e-7 +static constexpr FFT_SCALAR ZEROF = 0.0; +static constexpr double EPS_HOC = 1.0e-7; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pppm_disp_omp.cpp b/src/OPENMP/pppm_disp_omp.cpp index 24bf2d9564..45959dadba 100644 --- a/src/OPENMP/pppm_disp_omp.cpp +++ b/src/OPENMP/pppm_disp_omp.cpp @@ -38,15 +38,8 @@ using namespace LAMMPS_NS; using namespace MathConst; -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#define ONEF 1.0f -#else -#define ZEROF 0.0 -#define ONEF 1.0 -#endif - -#define OFFSET 16384 +static constexpr FFT_SCALAR ZEROF = 0.0; +static constexpr int OFFSET = 16384; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pppm_disp_tip4p_omp.cpp b/src/OPENMP/pppm_disp_tip4p_omp.cpp index ab6342a047..bcc083e809 100644 --- a/src/OPENMP/pppm_disp_tip4p_omp.cpp +++ b/src/OPENMP/pppm_disp_tip4p_omp.cpp @@ -37,13 +37,8 @@ using namespace LAMMPS_NS; using namespace MathConst; -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#else -#define ZEROF 0.0 -#endif - -#define OFFSET 16384 +static constexpr FFT_SCALAR ZEROF = 0.0; +static constexpr int OFFSET = 16384; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pppm_omp.cpp b/src/OPENMP/pppm_omp.cpp index 86e65da101..a178483b8a 100644 --- a/src/OPENMP/pppm_omp.cpp +++ b/src/OPENMP/pppm_omp.cpp @@ -38,13 +38,8 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#else -#define ZEROF 0.0 -#endif - -#define EPS_HOC 1.0e-7 +static constexpr FFT_SCALAR ZEROF = 0.0; +static constexpr double EPS_HOC = 1.0e-7; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pppm_tip4p_omp.cpp b/src/OPENMP/pppm_tip4p_omp.cpp index 66ce44b5ef..420a116816 100644 --- a/src/OPENMP/pppm_tip4p_omp.cpp +++ b/src/OPENMP/pppm_tip4p_omp.cpp @@ -39,14 +39,10 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#else -#define ZEROF 0.0 -#endif +static constexpr FFT_SCALAR ZEROF = 0.0; -#define EPS_HOC 1.0e-7 -#define OFFSET 16384 +static constexpr double EPS_HOC = 1.0e-7; +static constexpr int OFFSET = 16384; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/reaxff_torsion_angles_omp.cpp b/src/OPENMP/reaxff_torsion_angles_omp.cpp index 3b730e26d4..945a670a51 100644 --- a/src/OPENMP/reaxff_torsion_angles_omp.cpp +++ b/src/OPENMP/reaxff_torsion_angles_omp.cpp @@ -34,8 +34,6 @@ #include -#define MIN_SINE 1e-10 - using namespace LAMMPS_NS; namespace ReaxFF { diff --git a/src/OPT/pair_lj_charmm_coul_long_opt.cpp b/src/OPT/pair_lj_charmm_coul_long_opt.cpp index f5d38148a6..cc1bb71f9b 100644 --- a/src/OPT/pair_lj_charmm_coul_long_opt.cpp +++ b/src/OPT/pair_lj_charmm_coul_long_opt.cpp @@ -20,21 +20,16 @@ ------------------------------------------------------------------------- */ #include "pair_lj_charmm_coul_long_opt.h" -#include #include "atom.h" +#include "ewald_const.h" #include "force.h" #include "neigh_list.h" -using namespace LAMMPS_NS; +#include -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define EWALD_A1 0.254829592 -#define EWALD_A2 -0.284496736 -#define EWALD_A3 1.421413741 -#define EWALD_A4 -1.453152027 -#define EWALD_A5 1.061405429 +using namespace LAMMPS_NS; +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ @@ -158,9 +153,7 @@ void PairLJCharmmCoulLongOpt::eval() grij = g_ewald * r; expm2 = exp(-grij*grij); t = 1.0 / (1.0 + EWALD_P*grij); - erfc = t * - (EWALD_A1+t*(EWALD_A2+t*(EWALD_A3+t*(EWALD_A4+t*EWALD_A5)))) * - expm2; + erfc = t * (A1 + t*(A2 + t*(A3 + t*(A4 + t*A5)))) * expm2; prefactor = qqrd2e * tmp_coef3/r; forcecoul = prefactor * (erfc + EWALD_F*grij*expm2); } else { @@ -247,9 +240,7 @@ void PairLJCharmmCoulLongOpt::eval() grij = g_ewald * r; expm2 = exp(-grij*grij); t = 1.0 / (1.0 + EWALD_P*grij); - erfc = t * - (EWALD_A1+t*(EWALD_A2+t*(EWALD_A3+t*(EWALD_A4+t*EWALD_A5)))) * - expm2; + erfc = t * (A1 + t*(A2 + t*(A3 + t*(A4 + t*A5)))) * expm2; prefactor = qqrd2e * tmp_coef3/r; forcecoul = prefactor * (erfc + EWALD_F*grij*expm2); if (factor_coul < 1.0) { diff --git a/src/OPT/pair_lj_cut_coul_long_opt.cpp b/src/OPT/pair_lj_cut_coul_long_opt.cpp index 7ae43658d9..ea4ce7bede 100644 --- a/src/OPT/pair_lj_cut_coul_long_opt.cpp +++ b/src/OPT/pair_lj_cut_coul_long_opt.cpp @@ -13,20 +13,16 @@ ------------------------------------------------------------------------- */ #include "pair_lj_cut_coul_long_opt.h" -#include + #include "atom.h" +#include "ewald_const.h" #include "force.h" #include "neigh_list.h" -using namespace LAMMPS_NS; +#include -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace LAMMPS_NS; +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/OPT/pair_lj_cut_tip4p_long_opt.cpp b/src/OPT/pair_lj_cut_tip4p_long_opt.cpp index 5e484fd866..9a9e536bfe 100644 --- a/src/OPT/pair_lj_cut_tip4p_long_opt.cpp +++ b/src/OPT/pair_lj_cut_tip4p_long_opt.cpp @@ -17,24 +17,20 @@ ------------------------------------------------------------------------- */ #include "pair_lj_cut_tip4p_long_opt.h" -#include + #include "atom.h" #include "domain.h" #include "force.h" #include "error.h" +#include "ewald_const.h" #include "memory.h" #include "neighbor.h" #include "neigh_list.h" -using namespace LAMMPS_NS; +#include -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace LAMMPS_NS; +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/OPT/pair_lj_long_coul_long_opt.cpp b/src/OPT/pair_lj_long_coul_long_opt.cpp index a7aa232882..afadf107f4 100644 --- a/src/OPT/pair_lj_long_coul_long_opt.cpp +++ b/src/OPT/pair_lj_long_coul_long_opt.cpp @@ -19,6 +19,7 @@ #include "pair_lj_long_coul_long_opt.h" #include "atom.h" +#include "ewald_const.h" #include "force.h" #include "math_extra.h" #include "neigh_list.h" @@ -28,14 +29,7 @@ using namespace LAMMPS_NS; using namespace MathExtra; - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/ORIENT/fix_orient_bcc.cpp b/src/ORIENT/fix_orient_bcc.cpp index 2d801b0bdc..25fec2e606 100644 --- a/src/ORIENT/fix_orient_bcc.cpp +++ b/src/ORIENT/fix_orient_bcc.cpp @@ -38,7 +38,7 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace MathConst; -#define BIG 1000000000 +static constexpr int BIG = 1000000000; static const char cite_fix_orient_bcc[] = "fix orient/bcc command: doi:10.1016/j.commatsci.2016.02.016\n\n" diff --git a/src/ORIENT/fix_orient_fcc.cpp b/src/ORIENT/fix_orient_fcc.cpp index cdb3fd689d..78a8485278 100644 --- a/src/ORIENT/fix_orient_fcc.cpp +++ b/src/ORIENT/fix_orient_fcc.cpp @@ -35,7 +35,7 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace MathConst; -#define BIG 1000000000 +static constexpr int BIG = 1000000000; static const char cite_fix_orient_fcc[] = "fix orient/fcc command: doi:10.1038/nmat1559\n\n" diff --git a/src/PHONON/fix_phonon.cpp b/src/PHONON/fix_phonon.cpp index 6b5294d308..786931a549 100644 --- a/src/PHONON/fix_phonon.cpp +++ b/src/PHONON/fix_phonon.cpp @@ -45,9 +45,9 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define MAXLINE 512 +static constexpr int MAXLINE = 512; -enum{FORWARD=-1,BACKWARD=1}; +enum{ FORWARD=-1, BACKWARD=1 }; static const char cite_fix_phonon[] = "fix phonon command: doi:10.1016/j.cpc.2011.04.019\n\n" @@ -555,7 +555,7 @@ void FixPhonon::readmap() } // read from map file for others - char line[MAXLINE]; + char line[MAXLINE] = {'\0'}; FILE *fp = fopen(mapfile, "r"); if (fp == nullptr) error->all(FLERR,"Cannot open input map file {}: {}", mapfile, utils::getsyserror()); diff --git a/src/POEMS/fix_poems.cpp b/src/POEMS/fix_poems.cpp index 55199a7191..eb9c790422 100644 --- a/src/POEMS/fix_poems.cpp +++ b/src/POEMS/fix_poems.cpp @@ -36,15 +36,15 @@ #include #include -#include +#include using namespace LAMMPS_NS; using namespace FixConst; #define MAXBODY 2 // currently 2 since only linear chains allowed -#define DELTA 128 -#define TOLERANCE 1.0e-6 -#define EPSILON 1.0e-7 + +static constexpr double TOLERANCE = 1.0e-6; +static constexpr double EPSILON = 1.0e-7; static const char cite_fix_poems[] = "fix poems command: doi:10.1016/j.ijnonlinmec.2008.04.003\n\n" diff --git a/src/PTM/compute_ptm_atom.cpp b/src/PTM/compute_ptm_atom.cpp index e66bc1a17d..4d6cd4bc01 100644 --- a/src/PTM/compute_ptm_atom.cpp +++ b/src/PTM/compute_ptm_atom.cpp @@ -28,7 +28,6 @@ under #include "memory.h" #include "modify.h" #include "neigh_list.h" -#include "neigh_request.h" #include "neighbor.h" #include "update.h" diff --git a/src/PTM/ptm_convex_hull_incremental.cpp b/src/PTM/ptm_convex_hull_incremental.cpp index 25ff54c787..abae00778c 100644 --- a/src/PTM/ptm_convex_hull_incremental.cpp +++ b/src/PTM/ptm_convex_hull_incremental.cpp @@ -17,10 +17,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI namespace ptm { -#define VISIBLE 1 -#define INVISIBLE 2 -#define BOTH 3 -#define TOLERANCE 1E-8 +enum { VISIBLE=1, INVISIBLE, BOTH }; +static constexpr double TOLERANCE = 1E-8; static double norm_squared(double *p) { diff --git a/src/PTM/ptm_convex_hull_incremental.h b/src/PTM/ptm_convex_hull_incremental.h index 796c787937..81fc92d829 100644 --- a/src/PTM/ptm_convex_hull_incremental.h +++ b/src/PTM/ptm_convex_hull_incremental.h @@ -11,7 +11,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #define PTM_CONVEX_HULL_INCREMENTAL_H #include "ptm_constants.h" -#include #include namespace ptm { diff --git a/src/PYTHON/python_impl.cpp b/src/PYTHON/python_impl.cpp index 0db468d701..87a57187bf 100644 --- a/src/PYTHON/python_impl.cpp +++ b/src/PYTHON/python_impl.cpp @@ -17,7 +17,6 @@ #include "python_impl.h" -#include "comm.h" #include "error.h" #include "input.h" #include "memory.h" diff --git a/src/QEQ/fix_qeq.cpp b/src/QEQ/fix_qeq.cpp index 22632cf786..411bdfb60b 100644 --- a/src/QEQ/fix_qeq.cpp +++ b/src/QEQ/fix_qeq.cpp @@ -27,9 +27,7 @@ #include "memory.h" #include "modify.h" #include "neigh_list.h" -#include "pair.h" #include "respa.h" -#include "suffix.h" #include "text_file_reader.h" #include "update.h" diff --git a/src/QEQ/fix_qeq_fire.cpp b/src/QEQ/fix_qeq_fire.cpp index 34ef51d947..5df793b153 100644 --- a/src/QEQ/fix_qeq_fire.cpp +++ b/src/QEQ/fix_qeq_fire.cpp @@ -34,12 +34,12 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define DELAYSTEP 0 -#define DT_GROW 1.1 -#define DT_SHRINK 0.5 -#define ALPHA0 0.8 -#define ALPHA_SHRINK 0.10 -#define TMAX 10.0 +static constexpr int DELAYSTEP = 0; +static constexpr double DT_GROW = 1.1; +static constexpr double DT_SHRINK = 0.5; +static constexpr double ALPHA0 = 0.8; +static constexpr double ALPHA_SHRINK = 0.10; +static constexpr double TMAX = 10.0; /* ---------------------------------------------------------------------- */ diff --git a/src/REACTION/README b/src/REACTION/README index 99a5d604ec..b9199d6d47 100644 --- a/src/REACTION/README +++ b/src/REACTION/README @@ -25,4 +25,5 @@ The REACTER methodology is detailed in: https://doi.org/10.1021/acs.macromol.0c02012 This package was created by Jacob Gissinger -(jacob.r.gissinger@gmail.com) at the NASA Langley Research Center. +(jgissing@stevens.edu) while at the NASA Langley Research Center +and Stevens Institute of Technology. diff --git a/src/REACTION/fix_bond_react.cpp b/src/REACTION/fix_bond_react.cpp index d124b06dc2..d8561b3959 100644 --- a/src/REACTION/fix_bond_react.cpp +++ b/src/REACTION/fix_bond_react.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -13,7 +12,7 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- -Contributing Author: Jacob Gissinger (jacob.r.gissinger@gmail.com) +Contributing Author: Jacob Gissinger (jgissing@stevens.edu) ------------------------------------------------------------------------- */ #include "fix_bond_react.h" @@ -58,30 +57,31 @@ using namespace FixConst; using namespace MathConst; static const char cite_fix_bond_react[] = - "fix bond/react: reacter.org doi:10.1016/j.polymer.2017.09.038, doi:10.1021/acs.macromol.0c02012\n\n" - "@Article{Gissinger17,\n" - " author = {J. R. Gissinger and B. D. Jensen and K. E. Wise},\n" - " title = {Modeling Chemical Reactions in Classical Molecular Dynamics Simulations},\n" - " journal = {Polymer},\n" - " year = 2017,\n" - " volume = 128,\n" - " pages = {211--217}\n" - "}\n\n" - "@Article{Gissinger20,\n" - " author = {J. R. Gissinger, B. D. Jensen, K. E. Wise},\n" - " title = {{REACTER}: A Heuristic Method for Reactive Molecular Dynamics},\n" - " journal = {Macromolecules},\n" - " year = 2020,\n" - " volume = 53,\n" - " number = 22,\n" - " pages = {9953--9961}\n" - "}\n\n"; + "fix bond/react: reacter.org doi:10.1016/j.polymer.2017.09.038, " + "doi:10.1021/acs.macromol.0c02012\n\n" + "@Article{Gissinger17,\n" + " author = {J. R. Gissinger and B. D. Jensen and K. E. Wise},\n" + " title = {Modeling Chemical Reactions in Classical Molecular Dynamics Simulations},\n" + " journal = {Polymer},\n" + " year = 2017,\n" + " volume = 128,\n" + " pages = {211--217}\n" + "}\n\n" + "@Article{Gissinger20,\n" + " author = {J. R. Gissinger, B. D. Jensen, K. E. Wise},\n" + " title = {{REACTER}: A Heuristic Method for Reactive Molecular Dynamics},\n" + " journal = {Macromolecules},\n" + " year = 2020,\n" + " volume = 53,\n" + " number = 22,\n" + " pages = {9953--9961}\n" + "}\n\n"; -#define BIG 1.0e20 -#define DELTA 16 -#define MAXGUESS 20 // max # of guesses allowed by superimpose algorithm -#define MAXCONARGS 14 // max # of arguments for any type of constraint + rxnID -#define NUMVARVALS 5 // max # of keyword values that have variables as input +static constexpr double BIG = 1.0e20; +static constexpr int DELTA = 16; +static constexpr int MAXGUESS = 20; // max # of guesses allowed by superimpose algorithm +static constexpr int MAXCONARGS = 14; // max # of arguments for any type of constraint + rxnID +static constexpr int NUMVARVALS = 5; // max # of keyword values that have variables as input // various statuses of superimpose algorithm: // ACCEPT: site successfully matched to pre-reacted template @@ -90,24 +90,25 @@ static const char cite_fix_bond_react[] = // CONTINUE: a neighbor has been assigned, skip to next neighbor // GUESSFAIL: a guess has failed (if no more restore points, status = 'REJECT') // RESTORE: restore mode, load most recent restore point -enum{ACCEPT,REJECT,PROCEED,CONTINUE,GUESSFAIL,RESTORE}; +enum { ACCEPT, REJECT, PROCEED, CONTINUE, GUESSFAIL, RESTORE }; // types of available reaction constraints -enum{DISTANCE,ANGLE,DIHEDRAL,ARRHENIUS,RMSD,CUSTOM}; +enum { DISTANCE, ANGLE, DIHEDRAL, ARRHENIUS, RMSD, CUSTOM }; // ID type used by constraint -enum{ATOM,FRAG}; +enum { ATOM, FRAG }; // keyword values that accept variables as input -enum{NEVERY,RMIN,RMAX,PROB,NRATE}; +enum { NEVERY, RMIN, RMAX, PROB, NRATE }; // flag for one-proc vs shared reaction sites -enum{LOCAL,GLOBAL}; +enum { LOCAL, GLOBAL }; // values for molecule_keyword -enum{OFF,INTER,INTRA}; +enum { OFF, INTER, INTRA }; /* ---------------------------------------------------------------------- */ +// clang-format off FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) @@ -670,15 +671,6 @@ FixBondReact::~FixBondReact() memory->destroy(ghostly_rxn_count); memory->destroy(reaction_count_total); - if (newton_bond == 0) { - memory->destroy(xspecial); - memory->destroy(nxspecial); - memory->destroy(onemol_xspecial); - memory->destroy(onemol_nxspecial); - memory->destroy(twomol_xspecial); - memory->destroy(twomol_nxspecial); - } - if (attempted_rxn == 1) { memory->destroy(restore_pt); memory->destroy(restore); @@ -827,11 +819,10 @@ void FixBondReact::init() nlevels_respa = (dynamic_cast(update->integrate))->nlevels; // check cutoff for iatomtype,jatomtype - for (int i = 0; i < nreacts; i++) { - if (!utils::strmatch(force->pair_style,"^hybrid")) - if (force->pair == nullptr || cutsq[i][1] > force->pair->cutsq[iatomtype[i]][jatomtype[i]]) + if (!utils::strmatch(force->pair_style,"^hybrid")) + for (int i = 0; i < nreacts; i++) + if (force->pair == nullptr || (closeneigh[i] < 0 && cutsq[i][1] > force->pair->cutsq[iatomtype[i]][jatomtype[i]])) error->all(FLERR,"Fix bond/react: Fix bond/react cutoff is longer than pairwise cutoff"); - } // need a half neighbor list, built every Nevery steps neighbor->add_request(this, NeighConst::REQ_OCCASIONAL); @@ -931,29 +922,10 @@ void FixBondReact::post_integrate() neighbor->build_one(list,1); - // here we define a full special list, independent of Newton setting - if (newton_bond == 1) { - nxspecial = atom->nspecial; - xspecial = atom->special; - } else { - int nall = atom->nlocal + atom->nghost; - memory->destroy(nxspecial); - memory->destroy(xspecial); - memory->create(nxspecial,nall,3,"bond/react:nxspecial"); - memory->create(xspecial,nall,atom->maxspecial,"bond/react:xspecial"); - for (int i = 0; i < atom->nlocal; i++) { - nxspecial[i][0] = atom->num_bond[i]; - for (int j = 0; j < nxspecial[i][0]; j++) { - xspecial[i][j] = atom->bond_atom[i][j]; - } - nxspecial[i][1] = atom->nspecial[i][1]; - nxspecial[i][2] = atom->nspecial[i][2]; - int joffset = nxspecial[i][0] - atom->nspecial[i][0]; - for (int j = nxspecial[i][0]; j < nxspecial[i][2]; j++) { - xspecial[i][j+joffset] = atom->special[i][j]; - } - } - } + // here we define a full special list + // may need correction for unusual special bond settings + nxspecial = atom->nspecial; + xspecial = atom->special; int j; for (rxnID = 0; rxnID < nreacts; rxnID++) { @@ -2541,49 +2513,15 @@ int FixBondReact::get_chirality(double four_coords[12]) /* ---------------------------------------------------------------------- Get xspecials for current molecule templates + may need correction when specials defined explicitly in molecule templates ------------------------------------------------------------------------- */ void FixBondReact::get_molxspecials() { - if (newton_bond == 1) { - onemol_nxspecial = onemol->nspecial; - onemol_xspecial = onemol->special; - twomol_nxspecial = twomol->nspecial; - twomol_xspecial = twomol->special; - } else { - memory->destroy(onemol_nxspecial); - memory->destroy(onemol_xspecial); - memory->create(onemol_nxspecial,onemol->natoms,3,"bond/react:onemol_nxspecial"); - memory->create(onemol_xspecial,onemol->natoms,atom->maxspecial,"bond/react:onemol_xspecial"); - for (int i = 0; i < onemol->natoms; i++) { - onemol_nxspecial[i][0] = onemol->num_bond[i]; - for (int j = 0; j < onemol_nxspecial[i][0]; j++) { - onemol_xspecial[i][j] = onemol->bond_atom[i][j]; - } - onemol_nxspecial[i][1] = onemol->nspecial[i][1]; - onemol_nxspecial[i][2] = onemol->nspecial[i][2]; - int joffset = onemol_nxspecial[i][0] - onemol->nspecial[i][0]; - for (int j = onemol_nxspecial[i][0]; j < onemol_nxspecial[i][2]; j++) { - onemol_xspecial[i][j+joffset] = onemol->special[i][j]; - } - } - memory->destroy(twomol_nxspecial); - memory->destroy(twomol_xspecial); - memory->create(twomol_nxspecial,twomol->natoms,3,"bond/react:twomol_nxspecial"); - memory->create(twomol_xspecial,twomol->natoms,atom->maxspecial,"bond/react:twomol_xspecial"); - for (int i = 0; i < twomol->natoms; i++) { - twomol_nxspecial[i][0] = twomol->num_bond[i]; - for (int j = 0; j < twomol_nxspecial[i][0]; j++) { - twomol_xspecial[i][j] = twomol->bond_atom[i][j]; - } - twomol_nxspecial[i][1] = twomol->nspecial[i][1]; - twomol_nxspecial[i][2] = twomol->nspecial[i][2]; - int joffset = twomol_nxspecial[i][0] - twomol->nspecial[i][0]; - for (int j = twomol_nxspecial[i][0]; j < twomol_nxspecial[i][2]; j++) { - twomol_xspecial[i][j+joffset] = twomol->special[i][j]; - } - } - } + onemol_nxspecial = onemol->nspecial; + onemol_xspecial = onemol->special; + twomol_nxspecial = twomol->nspecial; + twomol_xspecial = twomol->special; } /* ---------------------------------------------------------------------- @@ -2682,16 +2620,43 @@ void FixBondReact::find_landlocked_atoms(int myrxn) } // also, if atoms change number of bonds, but aren't landlocked, that could be bad + int warnflag = 0; if (comm->me == 0) for (int i = 0; i < twomol->natoms; i++) { if ((create_atoms[i][myrxn] == 0) && (twomol_nxspecial[i][0] != onemol_nxspecial[equivalences[i][1][myrxn]-1][0]) && - (landlocked_atoms[i][myrxn] == 0)) - error->warning(FLERR, "Fix bond/react: Atom affected by reaction {} is too close " - "to template edge",rxn_name[myrxn]); - break; + (landlocked_atoms[i][myrxn] == 0)) { + warnflag = 1; + break; + } } + // also, if an atom changes any of its bonds, but is not landlocked, that could be bad + int thereflag; + if (comm->me == 0) + for (int i = 0; i < twomol->natoms; i++) { + if (landlocked_atoms[i][myrxn] == 1) continue; + for (int j = 0; j < twomol_nxspecial[i][0]; j++) { + int oneneighID = equivalences[twomol_xspecial[i][j]-1][1][myrxn]; + int ii = equivalences[i][1][myrxn] - 1; + thereflag = 0; + for (int k = 0; k < onemol_nxspecial[ii][0]; k++) { + if (oneneighID == onemol_xspecial[ii][k]) { + thereflag = 1; + break; + } + } + if (thereflag == 0) { + warnflag = 1; + break; + } + } + if (warnflag == 1) break; + } + + if (comm->me == 0 && warnflag == 1) error->warning(FLERR, "Fix bond/react: Atom affected " + "by reaction {} is too close to template edge",rxn_name[myrxn]); + // finally, if a created atom is not landlocked, bad! for (int i = 0; i < twomol->natoms; i++) { if (create_atoms[i][myrxn] == 1 && landlocked_atoms[i][myrxn] == 0) { @@ -3349,7 +3314,7 @@ void FixBondReact::update_everything() dynamic_cast(ihistory)->clear_cache(); // Angles! First let's delete all angle info: - if (force->angle && twomol->angleflag) { + if (force->angle) { int *num_angle = atom->num_angle; int **angle_type = atom->angle_type; tagint **angle_atom1 = atom->angle_atom1; @@ -3390,33 +3355,35 @@ void FixBondReact::update_everything() } } // now let's add the new angle info. - for (int j = 0; j < twomol->natoms; j++) { - int jj = equivalences[j][1][rxnID]-1; - if (atom->map(update_mega_glove[jj+1][i]) < nlocal && atom->map(update_mega_glove[jj+1][i]) >= 0) { - if (landlocked_atoms[j][rxnID] == 1) { - num_angle[atom->map(update_mega_glove[jj+1][i])] = twomol->num_angle[j]; - delta_angle += twomol->num_angle[j]; - for (int p = 0; p < twomol->num_angle[j]; p++) { - angle_type[atom->map(update_mega_glove[jj+1][i])][p] = twomol->angle_type[j][p]; - angle_atom1[atom->map(update_mega_glove[jj+1][i])][p] = update_mega_glove[equivalences[twomol->angle_atom1[j][p]-1][1][rxnID]][i]; - angle_atom2[atom->map(update_mega_glove[jj+1][i])][p] = update_mega_glove[equivalences[twomol->angle_atom2[j][p]-1][1][rxnID]][i]; - angle_atom3[atom->map(update_mega_glove[jj+1][i])][p] = update_mega_glove[equivalences[twomol->angle_atom3[j][p]-1][1][rxnID]][i]; + if (twomol->angleflag) { + for (int j = 0; j < twomol->natoms; j++) { + int jj = equivalences[j][1][rxnID]-1; + if (atom->map(update_mega_glove[jj+1][i]) < nlocal && atom->map(update_mega_glove[jj+1][i]) >= 0) { + if (landlocked_atoms[j][rxnID] == 1) { + num_angle[atom->map(update_mega_glove[jj+1][i])] = twomol->num_angle[j]; + delta_angle += twomol->num_angle[j]; + for (int p = 0; p < twomol->num_angle[j]; p++) { + angle_type[atom->map(update_mega_glove[jj+1][i])][p] = twomol->angle_type[j][p]; + angle_atom1[atom->map(update_mega_glove[jj+1][i])][p] = update_mega_glove[equivalences[twomol->angle_atom1[j][p]-1][1][rxnID]][i]; + angle_atom2[atom->map(update_mega_glove[jj+1][i])][p] = update_mega_glove[equivalences[twomol->angle_atom2[j][p]-1][1][rxnID]][i]; + angle_atom3[atom->map(update_mega_glove[jj+1][i])][p] = update_mega_glove[equivalences[twomol->angle_atom3[j][p]-1][1][rxnID]][i]; + } } - } - if (landlocked_atoms[j][rxnID] == 0) { - for (int p = 0; p < twomol->num_angle[j]; p++) { - if (landlocked_atoms[twomol->angle_atom1[j][p]-1][rxnID] == 1 || - landlocked_atoms[twomol->angle_atom2[j][p]-1][rxnID] == 1 || - landlocked_atoms[twomol->angle_atom3[j][p]-1][rxnID] == 1) { - insert_num = num_angle[atom->map(update_mega_glove[jj+1][i])]; - angle_type[atom->map(update_mega_glove[jj+1][i])][insert_num] = twomol->angle_type[j][p]; - angle_atom1[atom->map(update_mega_glove[jj+1][i])][insert_num] = update_mega_glove[equivalences[twomol->angle_atom1[j][p]-1][1][rxnID]][i]; - angle_atom2[atom->map(update_mega_glove[jj+1][i])][insert_num] = update_mega_glove[equivalences[twomol->angle_atom2[j][p]-1][1][rxnID]][i]; - angle_atom3[atom->map(update_mega_glove[jj+1][i])][insert_num] = update_mega_glove[equivalences[twomol->angle_atom3[j][p]-1][1][rxnID]][i]; - num_angle[atom->map(update_mega_glove[jj+1][i])]++; - if (num_angle[atom->map(update_mega_glove[jj+1][i])] > atom->angle_per_atom) - error->one(FLERR,"Fix bond/react topology/atom exceed system topology/atom"); - delta_angle++; + if (landlocked_atoms[j][rxnID] == 0) { + for (int p = 0; p < twomol->num_angle[j]; p++) { + if (landlocked_atoms[twomol->angle_atom1[j][p]-1][rxnID] == 1 || + landlocked_atoms[twomol->angle_atom2[j][p]-1][rxnID] == 1 || + landlocked_atoms[twomol->angle_atom3[j][p]-1][rxnID] == 1) { + insert_num = num_angle[atom->map(update_mega_glove[jj+1][i])]; + angle_type[atom->map(update_mega_glove[jj+1][i])][insert_num] = twomol->angle_type[j][p]; + angle_atom1[atom->map(update_mega_glove[jj+1][i])][insert_num] = update_mega_glove[equivalences[twomol->angle_atom1[j][p]-1][1][rxnID]][i]; + angle_atom2[atom->map(update_mega_glove[jj+1][i])][insert_num] = update_mega_glove[equivalences[twomol->angle_atom2[j][p]-1][1][rxnID]][i]; + angle_atom3[atom->map(update_mega_glove[jj+1][i])][insert_num] = update_mega_glove[equivalences[twomol->angle_atom3[j][p]-1][1][rxnID]][i]; + num_angle[atom->map(update_mega_glove[jj+1][i])]++; + if (num_angle[atom->map(update_mega_glove[jj+1][i])] > atom->angle_per_atom) + error->one(FLERR,"Fix bond/react topology/atom exceed system topology/atom"); + delta_angle++; + } } } } @@ -3426,7 +3393,7 @@ void FixBondReact::update_everything() } // Dihedrals! first let's delete all dihedral info for landlocked atoms - if (force->dihedral && twomol->dihedralflag) { + if (force->dihedral) { int *num_dihedral = atom->num_dihedral; int **dihedral_type = atom->dihedral_type; tagint **dihedral_atom1 = atom->dihedral_atom1; @@ -3470,36 +3437,38 @@ void FixBondReact::update_everything() } } // now let's add new dihedral info - for (int j = 0; j < twomol->natoms; j++) { - int jj = equivalences[j][1][rxnID]-1; - if (atom->map(update_mega_glove[jj+1][i]) < nlocal && atom->map(update_mega_glove[jj+1][i]) >= 0) { - if (landlocked_atoms[j][rxnID] == 1) { - num_dihedral[atom->map(update_mega_glove[jj+1][i])] = twomol->num_dihedral[j]; - delta_dihed += twomol->num_dihedral[j]; - for (int p = 0; p < twomol->num_dihedral[j]; p++) { - dihedral_type[atom->map(update_mega_glove[jj+1][i])][p] = twomol->dihedral_type[j][p]; - dihedral_atom1[atom->map(update_mega_glove[jj+1][i])][p] = update_mega_glove[equivalences[twomol->dihedral_atom1[j][p]-1][1][rxnID]][i]; - dihedral_atom2[atom->map(update_mega_glove[jj+1][i])][p] = update_mega_glove[equivalences[twomol->dihedral_atom2[j][p]-1][1][rxnID]][i]; - dihedral_atom3[atom->map(update_mega_glove[jj+1][i])][p] = update_mega_glove[equivalences[twomol->dihedral_atom3[j][p]-1][1][rxnID]][i]; - dihedral_atom4[atom->map(update_mega_glove[jj+1][i])][p] = update_mega_glove[equivalences[twomol->dihedral_atom4[j][p]-1][1][rxnID]][i]; + if (twomol->dihedralflag) { + for (int j = 0; j < twomol->natoms; j++) { + int jj = equivalences[j][1][rxnID]-1; + if (atom->map(update_mega_glove[jj+1][i]) < nlocal && atom->map(update_mega_glove[jj+1][i]) >= 0) { + if (landlocked_atoms[j][rxnID] == 1) { + num_dihedral[atom->map(update_mega_glove[jj+1][i])] = twomol->num_dihedral[j]; + delta_dihed += twomol->num_dihedral[j]; + for (int p = 0; p < twomol->num_dihedral[j]; p++) { + dihedral_type[atom->map(update_mega_glove[jj+1][i])][p] = twomol->dihedral_type[j][p]; + dihedral_atom1[atom->map(update_mega_glove[jj+1][i])][p] = update_mega_glove[equivalences[twomol->dihedral_atom1[j][p]-1][1][rxnID]][i]; + dihedral_atom2[atom->map(update_mega_glove[jj+1][i])][p] = update_mega_glove[equivalences[twomol->dihedral_atom2[j][p]-1][1][rxnID]][i]; + dihedral_atom3[atom->map(update_mega_glove[jj+1][i])][p] = update_mega_glove[equivalences[twomol->dihedral_atom3[j][p]-1][1][rxnID]][i]; + dihedral_atom4[atom->map(update_mega_glove[jj+1][i])][p] = update_mega_glove[equivalences[twomol->dihedral_atom4[j][p]-1][1][rxnID]][i]; + } } - } - if (landlocked_atoms[j][rxnID] == 0) { - for (int p = 0; p < twomol->num_dihedral[j]; p++) { - if (landlocked_atoms[twomol->dihedral_atom1[j][p]-1][rxnID] == 1 || - landlocked_atoms[twomol->dihedral_atom2[j][p]-1][rxnID] == 1 || - landlocked_atoms[twomol->dihedral_atom3[j][p]-1][rxnID] == 1 || - landlocked_atoms[twomol->dihedral_atom4[j][p]-1][rxnID] == 1) { - insert_num = num_dihedral[atom->map(update_mega_glove[jj+1][i])]; - dihedral_type[atom->map(update_mega_glove[jj+1][i])][insert_num] = twomol->dihedral_type[j][p]; - dihedral_atom1[atom->map(update_mega_glove[jj+1][i])][insert_num] = update_mega_glove[equivalences[twomol->dihedral_atom1[j][p]-1][1][rxnID]][i]; - dihedral_atom2[atom->map(update_mega_glove[jj+1][i])][insert_num] = update_mega_glove[equivalences[twomol->dihedral_atom2[j][p]-1][1][rxnID]][i]; - dihedral_atom3[atom->map(update_mega_glove[jj+1][i])][insert_num] = update_mega_glove[equivalences[twomol->dihedral_atom3[j][p]-1][1][rxnID]][i]; - dihedral_atom4[atom->map(update_mega_glove[jj+1][i])][insert_num] = update_mega_glove[equivalences[twomol->dihedral_atom4[j][p]-1][1][rxnID]][i]; - num_dihedral[atom->map(update_mega_glove[jj+1][i])]++; - if (num_dihedral[atom->map(update_mega_glove[jj+1][i])] > atom->dihedral_per_atom) - error->one(FLERR,"Fix bond/react topology/atom exceed system topology/atom"); - delta_dihed++; + if (landlocked_atoms[j][rxnID] == 0) { + for (int p = 0; p < twomol->num_dihedral[j]; p++) { + if (landlocked_atoms[twomol->dihedral_atom1[j][p]-1][rxnID] == 1 || + landlocked_atoms[twomol->dihedral_atom2[j][p]-1][rxnID] == 1 || + landlocked_atoms[twomol->dihedral_atom3[j][p]-1][rxnID] == 1 || + landlocked_atoms[twomol->dihedral_atom4[j][p]-1][rxnID] == 1) { + insert_num = num_dihedral[atom->map(update_mega_glove[jj+1][i])]; + dihedral_type[atom->map(update_mega_glove[jj+1][i])][insert_num] = twomol->dihedral_type[j][p]; + dihedral_atom1[atom->map(update_mega_glove[jj+1][i])][insert_num] = update_mega_glove[equivalences[twomol->dihedral_atom1[j][p]-1][1][rxnID]][i]; + dihedral_atom2[atom->map(update_mega_glove[jj+1][i])][insert_num] = update_mega_glove[equivalences[twomol->dihedral_atom2[j][p]-1][1][rxnID]][i]; + dihedral_atom3[atom->map(update_mega_glove[jj+1][i])][insert_num] = update_mega_glove[equivalences[twomol->dihedral_atom3[j][p]-1][1][rxnID]][i]; + dihedral_atom4[atom->map(update_mega_glove[jj+1][i])][insert_num] = update_mega_glove[equivalences[twomol->dihedral_atom4[j][p]-1][1][rxnID]][i]; + num_dihedral[atom->map(update_mega_glove[jj+1][i])]++; + if (num_dihedral[atom->map(update_mega_glove[jj+1][i])] > atom->dihedral_per_atom) + error->one(FLERR,"Fix bond/react topology/atom exceed system topology/atom"); + delta_dihed++; + } } } } @@ -3509,7 +3478,7 @@ void FixBondReact::update_everything() } // finally IMPROPERS!!!! first let's delete all improper info for landlocked atoms - if (force->improper && twomol->improperflag) { + if (force->improper) { int *num_improper = atom->num_improper; int **improper_type = atom->improper_type; tagint **improper_atom1 = atom->improper_atom1; @@ -3553,36 +3522,38 @@ void FixBondReact::update_everything() } } // now let's add new improper info - for (int j = 0; j < twomol->natoms; j++) { - int jj = equivalences[j][1][rxnID]-1; - if (atom->map(update_mega_glove[jj+1][i]) < nlocal && atom->map(update_mega_glove[jj+1][i]) >= 0) { - if (landlocked_atoms[j][rxnID] == 1) { - num_improper[atom->map(update_mega_glove[jj+1][i])] = twomol->num_improper[j]; - delta_imprp += twomol->num_improper[j]; - for (int p = 0; p < twomol->num_improper[j]; p++) { - improper_type[atom->map(update_mega_glove[jj+1][i])][p] = twomol->improper_type[j][p]; - improper_atom1[atom->map(update_mega_glove[jj+1][i])][p] = update_mega_glove[equivalences[twomol->improper_atom1[j][p]-1][1][rxnID]][i]; - improper_atom2[atom->map(update_mega_glove[jj+1][i])][p] = update_mega_glove[equivalences[twomol->improper_atom2[j][p]-1][1][rxnID]][i]; - improper_atom3[atom->map(update_mega_glove[jj+1][i])][p] = update_mega_glove[equivalences[twomol->improper_atom3[j][p]-1][1][rxnID]][i]; - improper_atom4[atom->map(update_mega_glove[jj+1][i])][p] = update_mega_glove[equivalences[twomol->improper_atom4[j][p]-1][1][rxnID]][i]; + if (twomol->improperflag) { + for (int j = 0; j < twomol->natoms; j++) { + int jj = equivalences[j][1][rxnID]-1; + if (atom->map(update_mega_glove[jj+1][i]) < nlocal && atom->map(update_mega_glove[jj+1][i]) >= 0) { + if (landlocked_atoms[j][rxnID] == 1) { + num_improper[atom->map(update_mega_glove[jj+1][i])] = twomol->num_improper[j]; + delta_imprp += twomol->num_improper[j]; + for (int p = 0; p < twomol->num_improper[j]; p++) { + improper_type[atom->map(update_mega_glove[jj+1][i])][p] = twomol->improper_type[j][p]; + improper_atom1[atom->map(update_mega_glove[jj+1][i])][p] = update_mega_glove[equivalences[twomol->improper_atom1[j][p]-1][1][rxnID]][i]; + improper_atom2[atom->map(update_mega_glove[jj+1][i])][p] = update_mega_glove[equivalences[twomol->improper_atom2[j][p]-1][1][rxnID]][i]; + improper_atom3[atom->map(update_mega_glove[jj+1][i])][p] = update_mega_glove[equivalences[twomol->improper_atom3[j][p]-1][1][rxnID]][i]; + improper_atom4[atom->map(update_mega_glove[jj+1][i])][p] = update_mega_glove[equivalences[twomol->improper_atom4[j][p]-1][1][rxnID]][i]; + } } - } - if (landlocked_atoms[j][rxnID] == 0) { - for (int p = 0; p < twomol->num_improper[j]; p++) { - if (landlocked_atoms[twomol->improper_atom1[j][p]-1][rxnID] == 1 || - landlocked_atoms[twomol->improper_atom2[j][p]-1][rxnID] == 1 || - landlocked_atoms[twomol->improper_atom3[j][p]-1][rxnID] == 1 || - landlocked_atoms[twomol->improper_atom4[j][p]-1][rxnID] == 1) { - insert_num = num_improper[atom->map(update_mega_glove[jj+1][i])]; - improper_type[atom->map(update_mega_glove[jj+1][i])][insert_num] = twomol->improper_type[j][p]; - improper_atom1[atom->map(update_mega_glove[jj+1][i])][insert_num] = update_mega_glove[equivalences[twomol->improper_atom1[j][p]-1][1][rxnID]][i]; - improper_atom2[atom->map(update_mega_glove[jj+1][i])][insert_num] = update_mega_glove[equivalences[twomol->improper_atom2[j][p]-1][1][rxnID]][i]; - improper_atom3[atom->map(update_mega_glove[jj+1][i])][insert_num] = update_mega_glove[equivalences[twomol->improper_atom3[j][p]-1][1][rxnID]][i]; - improper_atom4[atom->map(update_mega_glove[jj+1][i])][insert_num] = update_mega_glove[equivalences[twomol->improper_atom4[j][p]-1][1][rxnID]][i]; - num_improper[atom->map(update_mega_glove[jj+1][i])]++; - if (num_improper[atom->map(update_mega_glove[jj+1][i])] > atom->improper_per_atom) - error->one(FLERR,"Fix bond/react topology/atom exceed system topology/atom"); - delta_imprp++; + if (landlocked_atoms[j][rxnID] == 0) { + for (int p = 0; p < twomol->num_improper[j]; p++) { + if (landlocked_atoms[twomol->improper_atom1[j][p]-1][rxnID] == 1 || + landlocked_atoms[twomol->improper_atom2[j][p]-1][rxnID] == 1 || + landlocked_atoms[twomol->improper_atom3[j][p]-1][rxnID] == 1 || + landlocked_atoms[twomol->improper_atom4[j][p]-1][rxnID] == 1) { + insert_num = num_improper[atom->map(update_mega_glove[jj+1][i])]; + improper_type[atom->map(update_mega_glove[jj+1][i])][insert_num] = twomol->improper_type[j][p]; + improper_atom1[atom->map(update_mega_glove[jj+1][i])][insert_num] = update_mega_glove[equivalences[twomol->improper_atom1[j][p]-1][1][rxnID]][i]; + improper_atom2[atom->map(update_mega_glove[jj+1][i])][insert_num] = update_mega_glove[equivalences[twomol->improper_atom2[j][p]-1][1][rxnID]][i]; + improper_atom3[atom->map(update_mega_glove[jj+1][i])][insert_num] = update_mega_glove[equivalences[twomol->improper_atom3[j][p]-1][1][rxnID]][i]; + improper_atom4[atom->map(update_mega_glove[jj+1][i])][insert_num] = update_mega_glove[equivalences[twomol->improper_atom4[j][p]-1][1][rxnID]][i]; + num_improper[atom->map(update_mega_glove[jj+1][i])]++; + if (num_improper[atom->map(update_mega_glove[jj+1][i])] > atom->improper_per_atom) + error->one(FLERR,"Fix bond/react topology/atom exceed system topology/atom"); + delta_imprp++; + } } } } @@ -3895,7 +3866,8 @@ int FixBondReact::insert_atoms(tagint **my_update_mega_glove, int iupdate) // guess a somewhat reasonable initial velocity based on reaction site // further control is possible using bond_react_MASTER_group // compute |velocity| corresponding to a given temperature t, using specific atom's mass - double vtnorm = sqrt(t / (force->mvv2e / (dimension * force->boltz)) / atom->mass[twomol->type[m]]); + double mymass = atom->rmass ? atom->rmass[n] : atom->mass[twomol->type[m]]; + double vtnorm = sqrt(t / (force->mvv2e / (dimension * force->boltz)) / mymass); v[n][0] = random[rxnID]->uniform(); v[n][1] = random[rxnID]->uniform(); v[n][2] = random[rxnID]->uniform(); @@ -3950,7 +3922,8 @@ read map file void FixBondReact::read_map_file(int myrxn) { int rv; - char line[MAXLINE],keyword[MAXLINE]; + char line[MAXLINE] = {'\0'}; + char keyword[MAXLINE] = {'\0'}; char *eof,*ptr; // skip 1st line of file diff --git a/src/REACTION/fix_bond_react.h b/src/REACTION/fix_bond_react.h index 534261e11d..8c9fc9dce4 100644 --- a/src/REACTION/fix_bond_react.h +++ b/src/REACTION/fix_bond_react.h @@ -12,7 +12,7 @@ ------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- - Contributing Author: Jacob Gissinger (jacob.r.gissinger@gmail.com) + Contributing Author: Jacob Gissinger (jgissing@stevens.edu) ------------------------------------------------------------------------- */ #ifdef FIX_CLASS @@ -139,7 +139,7 @@ class FixBondReact : public Fix { int avail_guesses; // num of restore points available int *guess_branch; // used when there is more than two choices when guessing int **restore_pt; // contains info about restore points - tagint **restore; // contaings info about restore points + tagint **restore; // contains info about restore points int *pioneer_count; // counts pioneers int **edge; // atoms in molecule templates with incorrect valences diff --git a/src/REAXFF/compute_reaxff_atom.cpp b/src/REAXFF/compute_reaxff_atom.cpp index 1834de0b4b..0371f75120 100644 --- a/src/REAXFF/compute_reaxff_atom.cpp +++ b/src/REAXFF/compute_reaxff_atom.cpp @@ -17,8 +17,8 @@ ------------------------------------------------------------------------- */ #include "compute_reaxff_atom.h" + #include "atom.h" -#include "molecule.h" #include "update.h" #include "force.h" #include "memory.h" @@ -43,7 +43,7 @@ ComputeReaxFFAtom::ComputeReaxFFAtom(LAMMPS *lmp, int narg, char **arg) : // initialize output - nlocal = -1; + nmax = -1; nbonds = 0; prev_nbonds = -1; @@ -162,20 +162,22 @@ void ComputeReaxFFAtom::compute_bonds() { invoked_bonds = update->ntimestep; - if (atom->nlocal > nlocal) { + if (atom->nmax > nmax) { memory->destroy(abo); memory->destroy(neighid); memory->destroy(bondcount); memory->destroy(array_atom); - nlocal = atom->nlocal; + nmax = atom->nmax; if (store_bonds) { - memory->create(abo, nlocal, MAXREAXBOND, "reaxff/atom:abo"); - memory->create(neighid, nlocal, MAXREAXBOND, "reaxff/atom:neighid"); + memory->create(abo, nmax, MAXREAXBOND, "reaxff/atom:abo"); + memory->create(neighid, nmax, MAXREAXBOND, "reaxff/atom:neighid"); } - memory->create(bondcount, nlocal, "reaxff/atom:bondcount"); - memory->create(array_atom, nlocal, 3, "reaxff/atom:array_atom"); + memory->create(bondcount, nmax, "reaxff/atom:bondcount"); + memory->create(array_atom, nmax, 3, "reaxff/atom:array_atom"); } + const int nlocal = atom->nlocal; + for (int i = 0; i < nlocal; i++) { bondcount[i] = 0; for (int j = 0; store_bonds && j < MAXREAXBOND; j++) { @@ -208,6 +210,8 @@ void ComputeReaxFFAtom::compute_local() int b = 0; + const int nlocal = atom->nlocal; + for (int i = 0; i < nlocal; ++i) { const int numbonds = bondcount[i]; @@ -230,6 +234,8 @@ void ComputeReaxFFAtom::compute_peratom() compute_bonds(); } + const int nlocal = atom->nlocal; + for (int i = 0; i < nlocal; ++i) { auto ptr = array_atom[i]; ptr[0] = reaxff->api->workspace->total_bond_order[i]; @@ -244,10 +250,10 @@ void ComputeReaxFFAtom::compute_peratom() double ComputeReaxFFAtom::memory_usage() { - double bytes = (double)(nlocal*3) * sizeof(double); - bytes += (double)(nlocal) * sizeof(int); + double bytes = (double)(nmax*3) * sizeof(double); + bytes += (double)(nmax) * sizeof(int); if (store_bonds) { - bytes += (double)(2*nlocal*MAXREAXBOND) * sizeof(double); + bytes += (double)(2*nmax*MAXREAXBOND) * sizeof(double); bytes += (double)(nbonds*3) * sizeof(double); } return bytes; diff --git a/src/REAXFF/compute_reaxff_atom.h b/src/REAXFF/compute_reaxff_atom.h index 1f9aaec1ae..f27555e565 100644 --- a/src/REAXFF/compute_reaxff_atom.h +++ b/src/REAXFF/compute_reaxff_atom.h @@ -40,7 +40,7 @@ class ComputeReaxFFAtom : public Compute { protected: bigint invoked_bonds; // last timestep on which compute_bonds() was invoked - int nlocal; + int nmax; int nbonds; int prev_nbonds; int nsub; diff --git a/src/REAXFF/fix_acks2_reaxff.cpp b/src/REAXFF/fix_acks2_reaxff.cpp index 68de1c8ed1..4fd86605fa 100644 --- a/src/REAXFF/fix_acks2_reaxff.cpp +++ b/src/REAXFF/fix_acks2_reaxff.cpp @@ -33,6 +33,7 @@ #include #include +#include using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/REAXFF/fix_reaxff.cpp b/src/REAXFF/fix_reaxff.cpp index bec16b5d04..ede0d79f87 100644 --- a/src/REAXFF/fix_reaxff.cpp +++ b/src/REAXFF/fix_reaxff.cpp @@ -29,9 +29,8 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define MAX_REAX_BONDS 30 -#define MIN_REAX_BONDS 15 -#define MIN_REAX_HBONDS 25 +static constexpr int MIN_REAX_BONDS = 15; +static constexpr int MIN_REAX_HBONDS = 25; /* ---------------------------------------------------------------------- */ diff --git a/src/REAXFF/reaxff_ffield.cpp b/src/REAXFF/reaxff_ffield.cpp index 6ca8dc6256..b941d7d0f0 100644 --- a/src/REAXFF/reaxff_ffield.cpp +++ b/src/REAXFF/reaxff_ffield.cpp @@ -30,7 +30,6 @@ #include "error.h" #include "memory.h" #include "text_file_reader.h" -#include "tokenizer.h" #include "utils.h" #include diff --git a/src/REPLICA/fix_alchemy.cpp b/src/REPLICA/fix_alchemy.cpp index 2fe4417161..b14c6bc22d 100644 --- a/src/REPLICA/fix_alchemy.cpp +++ b/src/REPLICA/fix_alchemy.cpp @@ -21,7 +21,6 @@ #include "input.h" #include "memory.h" #include "modify.h" -#include "respa.h" #include "universe.h" #include "update.h" #include "variable.h" diff --git a/src/REPLICA/fix_hyper_global.cpp b/src/REPLICA/fix_hyper_global.cpp index d262c49fda..79d901893e 100644 --- a/src/REPLICA/fix_hyper_global.cpp +++ b/src/REPLICA/fix_hyper_global.cpp @@ -32,8 +32,8 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define DELTABOND 16384 -#define VECLEN 5 +static constexpr int DELTABOND = 16384; +static constexpr int VECLEN = 5; // possible enhancements // should there be a virial contribution from boosted bond? diff --git a/src/REPLICA/fix_hyper_local.cpp b/src/REPLICA/fix_hyper_local.cpp index d0cfc4bb01..dde4940403 100644 --- a/src/REPLICA/fix_hyper_local.cpp +++ b/src/REPLICA/fix_hyper_local.cpp @@ -35,11 +35,11 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define DELTABOND 16384 -#define DELTABIAS 16 -#define COEFFINIT 1.0 -#define FCCBONDS 12 -#define BIG 1.0e20 +static constexpr int DELTABOND = 16384; +static constexpr int DELTABIAS = 16; +static constexpr double COEFFINIT = 1.0; +static constexpr int FCCBONDS = 12; +static constexpr double BIG = 1.0e20; enum{STRAIN,STRAINDOMAIN,BIASFLAG,BIASCOEFF}; enum{IGNORE,WARN,ERROR}; diff --git a/src/REPLICA/fix_neb.cpp b/src/REPLICA/fix_neb.cpp index f2962d9b9d..9c920f26dc 100644 --- a/src/REPLICA/fix_neb.cpp +++ b/src/REPLICA/fix_neb.cpp @@ -40,7 +40,7 @@ using namespace MathConst; enum { SINGLE_PROC_DIRECT, SINGLE_PROC_MAP, MULTI_PROC }; enum { NEIGHBOR, IDEAL, EQUAL }; -#define BUFSIZE 8 +static constexpr int BUFSIZE = 8; /* ---------------------------------------------------------------------- */ @@ -139,7 +139,15 @@ FixNEB::FixNEB(LAMMPS *lmp, int narg, char **arg) : uworld = universe->uworld; - if ((neb_mode == IDEAL) || (neb_mode == EQUAL)) { + // set comm mode for inter-replica exchange of coords + // may change from SINGLE_PROC_MAP to SINGLE_PROC_DIRECT only in Fix::init() + + if (nreplica == nprocs_universe) + cmode = SINGLE_PROC_MAP; + else + cmode = MULTI_PROC; + + if (cmode == MULTI_PROC) { int *iroots = new int[nreplica]; MPI_Group uworldgroup, rootgroup; @@ -150,7 +158,7 @@ FixNEB::FixNEB(LAMMPS *lmp, int narg, char **arg) : if (rootgroup != MPI_GROUP_NULL) MPI_Group_free(&rootgroup); if (uworldgroup != MPI_GROUP_NULL) MPI_Group_free(&uworldgroup); delete[] iroots; - } + } else rootworld = MPI_COMM_NULL; // create a new compute pe style // id = fix-ID + pe, compute group = all @@ -193,8 +201,10 @@ FixNEB::~FixNEB() memory->destroy(counts); memory->destroy(displacements); - if ((neb_mode == IDEAL) || (neb_mode == EQUAL)) { + if (cmode == MULTI_PROC) if (rootworld != MPI_COMM_NULL) MPI_Comm_free(&rootworld); + + if ((neb_mode == IDEAL) || (neb_mode == EQUAL)) { memory->destroy(nlenall); } if (neb_mode == EQUAL) memory->destroy(vengall); @@ -227,14 +237,10 @@ void FixNEB::init() if (count > MAXSMALLINT) error->all(FLERR, "Too many active NEB atoms"); nebatoms = count; - // comm mode for inter-replica exchange of coords + // change comm mode for inter-replica exchange of coords to direct if possible - if (nreplica == nprocs_universe && nebatoms == atom->natoms && atom->sortfreq == 0) + if ((cmode == SINGLE_PROC_MAP) && (nebatoms == atom->natoms) && (atom->sortfreq == 0)) cmode = SINGLE_PROC_DIRECT; - else if (nreplica == nprocs_universe) - cmode = SINGLE_PROC_MAP; - else - cmode = MULTI_PROC; // ntotal = total # of atoms in system, NEB atoms or not @@ -298,9 +304,8 @@ void FixNEB::min_post_force(int /*vflag*/) int procFirst; procFirst = universe->root_proc[0]; MPI_Bcast(&vIni, 1, MPI_DOUBLE, procFirst, uworld); - } else { + } else { // cmode == MULTI_PROC if (me == 0) MPI_Bcast(&vIni, 1, MPI_DOUBLE, 0, rootworld); - MPI_Bcast(&vIni, 1, MPI_DOUBLE, 0, world); } } @@ -812,7 +817,7 @@ void FixNEB::calculate_ideal_positions() if ((neb_mode == EQUAL) && (rclimber > 0.0)) { if ((cmode == SINGLE_PROC_DIRECT) || (cmode == SINGLE_PROC_MAP)) { MPI_Allgather(&veng, 1, MPI_DOUBLE, &vengall[0], 1, MPI_DOUBLE, uworld); - } else { + } else { // cmode == MULTI_PROC if (me == 0) MPI_Allgather(&veng, 1, MPI_DOUBLE, &vengall[0], 1, MPI_DOUBLE, rootworld); MPI_Bcast(vengall, nreplica, MPI_DOUBLE, 0, world); } @@ -823,7 +828,7 @@ void FixNEB::calculate_ideal_positions() } else if ((neb_mode == IDEAL) || (neb_mode == EQUAL)) { if ((cmode == SINGLE_PROC_DIRECT) || (cmode == SINGLE_PROC_MAP)) { MPI_Allgather(&nlen, 1, MPI_DOUBLE, &nlenall[0], 1, MPI_DOUBLE, uworld); - } else { + } else { // cmode == MULTI_PROC if (me == 0) MPI_Allgather(&nlen, 1, MPI_DOUBLE, &nlenall[0], 1, MPI_DOUBLE, rootworld); MPI_Bcast(nlenall, nreplica, MPI_DOUBLE, 0, world); } diff --git a/src/REPLICA/fix_pimd_langevin.cpp b/src/REPLICA/fix_pimd_langevin.cpp index bd8c76d52f..c6886fbed7 100644 --- a/src/REPLICA/fix_pimd_langevin.cpp +++ b/src/REPLICA/fix_pimd_langevin.cpp @@ -35,12 +35,12 @@ #include "force.h" #include "group.h" #include "math_const.h" +#include "math_special.h" #include "memory.h" #include "modify.h" #include "random_mars.h" #include "universe.h" #include "update.h" -#include "utils.h" #include #include @@ -48,7 +48,10 @@ using namespace LAMMPS_NS; using namespace FixConst; using MathConst::MY_PI; +using MathConst::MY_2PI; using MathConst::THIRD; +using MathConst::MY_SQRT2; +using MathSpecial::powint; enum { PIMD, NMPIMD }; enum { PHYSICAL, NORMAL }; @@ -436,7 +439,7 @@ void FixPIMDLangevin::init() planck = force->hplanck; } planck *= sp; - hbar = planck / (2.0 * MY_PI); + hbar = planck / (MY_2PI); double beta = 1.0 / (force->boltz * temp); double _fbond = 1.0 * np * np / (beta * beta * hbar * hbar); @@ -738,10 +741,11 @@ void FixPIMDLangevin::collect_xc() } } + const double sqrtnp = sqrt((double)np); for (int i = 0; i < nlocal; i++) { - xcall[3 * (tag[i] - 1) + 0] = x[i][0] / sqrt(np); - xcall[3 * (tag[i] - 1) + 1] = x[i][1] / sqrt(np); - xcall[3 * (tag[i] - 1) + 2] = x[i][2] / sqrt(np); + xcall[3 * (tag[i] - 1) + 0] = x[i][0] / sqrtnp; + xcall[3 * (tag[i] - 1) + 1] = x[i][1] / sqrtnp; + xcall[3 * (tag[i] - 1) + 2] = x[i][2] / sqrtnp; } if (cmode == MULTI_PROC) { @@ -1107,19 +1111,20 @@ void FixPIMDLangevin::nmpimd_init() } // Set up eigenvectors for degenerated modes + const double sqrtnp = sqrt((double)np); for (int j = 0; j < np; j++) { for (int i = 1; i < int(np / 2) + 1; i++) { - M_x2xp[i][j] = sqrt(2.0) * cos(2.0 * MY_PI * double(i) * double(j) / double(np)) / sqrt(np); + M_x2xp[i][j] = MY_SQRT2 * cos(MY_2PI * double(i) * double(j) / double(np)) / sqrtnp; } for (int i = int(np / 2) + 1; i < np; i++) { - M_x2xp[i][j] = sqrt(2.0) * sin(2.0 * MY_PI * double(i) * double(j) / double(np)) / sqrt(np); + M_x2xp[i][j] = MY_SQRT2 * sin(MY_2PI * double(i) * double(j) / double(np)) / sqrtnp; } } // Set up eigenvectors for non-degenerated modes for (int i = 0; i < np; i++) { - M_x2xp[0][i] = 1.0 / sqrt(np); - if (np % 2 == 0) M_x2xp[np / 2][i] = 1.0 / sqrt(np) * pow(-1.0, i); + M_x2xp[0][i] = 1.0 / sqrtnp; + if (np % 2 == 0) M_x2xp[np / 2][i] = 1.0 / sqrtnp * powint(-1.0, i); } // Set up Ut diff --git a/src/REPLICA/neb.cpp b/src/REPLICA/neb.cpp index 11933164eb..d9144a9489 100644 --- a/src/REPLICA/neb.cpp +++ b/src/REPLICA/neb.cpp @@ -36,32 +36,16 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define MAXLINE 256 -#define CHUNK 1024 -#define ATTRIBUTE_PERLINE 4 +static constexpr int MAXLINE = 256; +static constexpr int CHUNK = 1024; +static constexpr int ATTRIBUTE_PERLINE = 4; enum { DEFAULT, TERSE, VERBOSE }; /* ---------------------------------------------------------------------- */ -NEB::NEB(LAMMPS *lmp) : Command(lmp), fp(nullptr), all(nullptr), rdist(nullptr) {} - -/* ---------------------------------------------------------------------- - internal NEB constructor, called from TAD -------------------------------------------------------------------------- */ - -NEB::NEB(LAMMPS *lmp, double etol_in, double ftol_in, int n1steps_in, int n2steps_in, int nevery_in, - double *buf_init, double *buf_final) : - Command(lmp), - fp(nullptr), all(nullptr), rdist(nullptr) +NEB::NEB(LAMMPS *lmp) : Command(lmp), fp(nullptr), all(nullptr), rdist(nullptr) { - double delx, dely, delz; - - etol = etol_in; - ftol = ftol_in; - n1steps = n1steps_in; - n2steps = n2steps_in; - nevery = nevery_in; print_mode = DEFAULT; // replica info @@ -71,8 +55,25 @@ NEB::NEB(LAMMPS *lmp, double etol_in, double ftol_in, int n1steps_in, int n2step me_universe = universe->me; uworld = universe->uworld; MPI_Comm_rank(world, &me); +} - // generate linear interpolate replica +/* ---------------------------------------------------------------------- + internal NEB constructor, called from TAD +------------------------------------------------------------------------- */ + +NEB::NEB(LAMMPS *lmp, double etol_in, double ftol_in, int n1steps_in, int n2steps_in, int nevery_in, + double *buf_init, double *buf_final) : + NEB(lmp) +{ + double delx, dely, delz; + + etol = etol_in; + ftol = ftol_in; + n1steps = n1steps_in; + n2steps = n2steps_in; + nevery = nevery_in; + + // generate linear interpolated replica double fraction = ireplica / (nreplica - 1.0); double **x = atom->x; int nlocal = atom->nlocal; @@ -129,19 +130,11 @@ void NEB::command(int narg, char **arg) if (nevery <= 0) error->universe_all(FLERR, fmt::format("Illegal NEB command every parameter: {}", nevery)); if (n1steps % nevery) - error->universe_all(FLERR, fmt::format("NEB N1 value {} incompatible with every {}", - n1steps, nevery)); + error->universe_all(FLERR, + fmt::format("NEB N1 value {} incompatible with every {}", n1steps, nevery)); if (n2steps % nevery) - error->universe_all(FLERR, fmt::format("NEB N2 value {} incompatible with every {}", - n2steps, nevery)); - - // replica info - - nreplica = universe->nworlds; - ireplica = universe->iworld; - me_universe = universe->me; - uworld = universe->uworld; - MPI_Comm_rank(world, &me); + error->universe_all(FLERR, + fmt::format("NEB N2 value {} incompatible with every {}", n2steps, nevery)); // error checks @@ -437,7 +430,7 @@ void NEB::readfile(char *file, int flag) int i, nchunk, eofflag, nlines; tagint tag; char *eof, *start, *next, *buf; - char line[MAXLINE]; + char line[MAXLINE] = {'\0'}; double delx, dely, delz; if (me_universe == 0 && universe->uscreen) diff --git a/src/REPLICA/temper.cpp b/src/REPLICA/temper.cpp index adbdb4d742..77bc45e6e3 100644 --- a/src/REPLICA/temper.cpp +++ b/src/REPLICA/temper.cpp @@ -33,7 +33,6 @@ #include "update.h" #include -#include using namespace LAMMPS_NS; diff --git a/src/REPLICA/temper_npt.cpp b/src/REPLICA/temper_npt.cpp index d814bf6725..aa72047fe7 100644 --- a/src/REPLICA/temper_npt.cpp +++ b/src/REPLICA/temper_npt.cpp @@ -35,7 +35,6 @@ #include "update.h" #include -#include using namespace LAMMPS_NS; diff --git a/src/RIGID/compute_rigid_local.cpp b/src/RIGID/compute_rigid_local.cpp index bd0db29d20..ea45389e7b 100644 --- a/src/RIGID/compute_rigid_local.cpp +++ b/src/RIGID/compute_rigid_local.cpp @@ -24,7 +24,7 @@ using namespace LAMMPS_NS; -#define DELTA 10000 +static constexpr int DELTA = 10000; enum{ID,MOL,MASS,X,Y,Z,XU,YU,ZU,VX,VY,VZ,FX,FY,FZ,IX,IY,IZ, TQX,TQY,TQZ,OMEGAX,OMEGAY,OMEGAZ,ANGMOMX,ANGMOMY,ANGMOMZ, diff --git a/src/RIGID/fix_rigid.cpp b/src/RIGID/fix_rigid.cpp index bd3c53e3ec..7a63c52220 100644 --- a/src/RIGID/fix_rigid.cpp +++ b/src/RIGID/fix_rigid.cpp @@ -2300,7 +2300,7 @@ void FixRigid::readfile(int which, double *vec, double **array1, double **array2 int nlines; FILE *fp; char *eof,*start,*next,*buf; - char line[MAXLINE]; + char line[MAXLINE] = {'\0'}; // open file and read and parse first non-empty, non-comment line containing the number of bodies if (comm->me == 0) { diff --git a/src/RIGID/fix_rigid_small.cpp b/src/RIGID/fix_rigid_small.cpp index 5905e44595..9e185a4de2 100644 --- a/src/RIGID/fix_rigid_small.cpp +++ b/src/RIGID/fix_rigid_small.cpp @@ -49,7 +49,7 @@ using namespace FixConst; using namespace MathConst; using namespace RigidConst; -#define RVOUS 1 // 0 for irregular, 1 for all2all +static constexpr int RVOUS = 1; // 0 for irregular, 1 for all2all /* ---------------------------------------------------------------------- */ @@ -2470,7 +2470,7 @@ void FixRigidSmall::readfile(int which, double **array, int *inbody) int nchunk,eofflag,nlines,xbox,ybox,zbox; FILE *fp; char *eof,*start,*next,*buf; - char line[MAXLINE]; + char line[MAXLINE] = {'\0'}; // create local hash with key/value pairs // key = mol ID of bodies my atoms own diff --git a/src/RIGID/fix_shake.cpp b/src/RIGID/fix_shake.cpp index 15bd5d207f..73c29d86bd 100644 --- a/src/RIGID/fix_shake.cpp +++ b/src/RIGID/fix_shake.cpp @@ -39,7 +39,7 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace MathConst; -#define RVOUS 1 // 0 for irregular, 1 for all2all +static constexpr int RVOUS = 1; // 0 for irregular, 1 for all2all static constexpr double BIG = 1.0e20; static constexpr double MASSDELTA = 0.1; diff --git a/src/SHOCK/fix_append_atoms.cpp b/src/SHOCK/fix_append_atoms.cpp index 9ab788b352..677b3b55fd 100644 --- a/src/SHOCK/fix_append_atoms.cpp +++ b/src/SHOCK/fix_append_atoms.cpp @@ -14,8 +14,6 @@ #include "fix_append_atoms.h" -#include -#include #include "atom.h" #include "atom_vec.h" #include "comm.h" @@ -27,11 +25,13 @@ #include "error.h" #include "force.h" +#include +#include + using namespace LAMMPS_NS; using namespace FixConst; -#define BIG 1.0e30 -#define EPSILON 1.0e-6 +static constexpr double BIG = 1.0e30; /* ---------------------------------------------------------------------- */ @@ -43,7 +43,7 @@ FixAppendAtoms::FixAppendAtoms(LAMMPS *lmp, int narg, char **arg) : next_reneighbor = -1; time_depend = 1; - if (narg < 4) error->all(FLERR,"Illegal fix append/atoms command"); + if (narg < 4) utils::missing_cmd_args(FLERR,"fix append/atoms", error); // default settings @@ -121,8 +121,7 @@ FixAppendAtoms::FixAppendAtoms(LAMMPS *lmp, int narg, char **arg) : } else if (strcmp(arg[iarg],"spatial") == 0) { if (iarg+3 > narg) error->all(FLERR,"Illegal fix append/atoms command"); if (strcmp(arg[iarg+1],"f_") == 0) - error->all(FLERR, - "Bad fix ID in fix append/atoms command"); + error->all(FLERR, "Bad fix ID in fix append/atoms command"); spatflag = 1; spatialid = utils::strdup(arg[iarg+1]+2); spatlead = utils::numeric(FLERR,arg[iarg+2],false,lmp); @@ -208,14 +207,14 @@ FixAppendAtoms::FixAppendAtoms(LAMMPS *lmp, int narg, char **arg) : FixAppendAtoms::~FixAppendAtoms() { - delete [] basistype; + delete[] basistype; if (ranflag) delete randomx; if (spatflag) delete[] spatialid; if (tempflag) { delete randomt; - delete [] gfactor1; - delete [] gfactor2; + delete[] gfactor1; + delete[] gfactor2; } } @@ -239,22 +238,30 @@ void FixAppendAtoms::initial_integrate(int /*vflag*/) /* ---------------------------------------------------------------------- */ +void FixAppendAtoms::init() +{ + if (spatflag) { + Fix *ifix = modify->get_fix_by_id(spatialid); + if (!ifix) error->all(FLERR,"Fix ID {} for fix ave/chunk does not exist", spatialid); + if (!utils::strmatch(ifix->style, "^ave/chunk")) + error->all(FLERR,"Fix {} for spatial keyword is not fix style ave/chunk", spatialid);} +} + +/* ---------------------------------------------------------------------- */ + void FixAppendAtoms::setup(int vflag) { /*** CALL TO CREATE GROUP? SEE POST_FORCE ***/ post_force(vflag); } - /* ---------------------------------------------------------------------- */ int FixAppendAtoms::get_spatial() { if (update->ntimestep % freq == 0) { - int ifix = modify->find_fix(spatialid); - if (ifix < 0) - error->all(FLERR,"Fix ID for fix ave/spatial does not exist"); - Fix *fix = modify->fix[ifix]; + Fix *fix = modify->get_fix_by_id(spatialid); + if (!fix) error->all(FLERR,"Fix ID {} for fix ave/chunk does not exist", spatialid); int failed = 0; int count = 0; @@ -319,8 +326,8 @@ int FixAppendAtoms::get_spatial() if (domain->boxhi[2] - shockfront_loc < spatlead) advance = 1; - delete [] pos; - delete [] val; + delete[] pos; + delete[] val; } advance_sum = 0; @@ -433,22 +440,14 @@ void FixAppendAtoms::pre_exchange() xmin = ymin = zmin = BIG; xmax = ymax = zmax = -BIG; - domain->lattice->bbox(1,bboxlo[0],bboxlo[1],bboxlo[2], - xmin,ymin,zmin,xmax,ymax,zmax); - domain->lattice->bbox(1,bboxhi[0],bboxlo[1],bboxlo[2], - xmin,ymin,zmin,xmax,ymax,zmax); - domain->lattice->bbox(1,bboxlo[0],bboxhi[1],bboxlo[2], - xmin,ymin,zmin,xmax,ymax,zmax); - domain->lattice->bbox(1,bboxhi[0],bboxhi[1],bboxlo[2], - xmin,ymin,zmin,xmax,ymax,zmax); - domain->lattice->bbox(1,bboxlo[0],bboxlo[1],bboxhi[2], - xmin,ymin,zmin,xmax,ymax,zmax); - domain->lattice->bbox(1,bboxhi[0],bboxlo[1],bboxhi[2], - xmin,ymin,zmin,xmax,ymax,zmax); - domain->lattice->bbox(1,bboxlo[0],bboxhi[1],bboxhi[2], - xmin,ymin,zmin,xmax,ymax,zmax); - domain->lattice->bbox(1,bboxhi[0],bboxhi[1],bboxhi[2], - xmin,ymin,zmin,xmax,ymax,zmax); + domain->lattice->bbox(1,bboxlo[0],bboxlo[1],bboxlo[2],xmin,ymin,zmin,xmax,ymax,zmax); + domain->lattice->bbox(1,bboxhi[0],bboxlo[1],bboxlo[2],xmin,ymin,zmin,xmax,ymax,zmax); + domain->lattice->bbox(1,bboxlo[0],bboxhi[1],bboxlo[2],xmin,ymin,zmin,xmax,ymax,zmax); + domain->lattice->bbox(1,bboxhi[0],bboxhi[1],bboxlo[2],xmin,ymin,zmin,xmax,ymax,zmax); + domain->lattice->bbox(1,bboxlo[0],bboxlo[1],bboxhi[2],xmin,ymin,zmin,xmax,ymax,zmax); + domain->lattice->bbox(1,bboxhi[0],bboxlo[1],bboxhi[2],xmin,ymin,zmin,xmax,ymax,zmax); + domain->lattice->bbox(1,bboxlo[0],bboxhi[1],bboxhi[2],xmin,ymin,zmin,xmax,ymax,zmax); + domain->lattice->bbox(1,bboxhi[0],bboxhi[1],bboxhi[2],xmin,ymin,zmin,xmax,ymax,zmax); int ilo,ihi,jlo,jhi,klo,khi; ilo = static_cast (xmin); diff --git a/src/SHOCK/fix_append_atoms.h b/src/SHOCK/fix_append_atoms.h index 5fbe9e904b..a7e89a3976 100644 --- a/src/SHOCK/fix_append_atoms.h +++ b/src/SHOCK/fix_append_atoms.h @@ -29,6 +29,7 @@ class FixAppendAtoms : public Fix { FixAppendAtoms(class LAMMPS *, int, char **); ~FixAppendAtoms() override; int setmask() override; + void init() override; void setup(int) override; void pre_exchange() override; void initial_integrate(int) override; diff --git a/src/SMTBQ/pair_smatb.cpp b/src/SMTBQ/pair_smatb.cpp index 85446b7a62..ab6aee557e 100644 --- a/src/SMTBQ/pair_smatb.cpp +++ b/src/SMTBQ/pair_smatb.cpp @@ -26,6 +26,7 @@ #include "neighbor.h" #include +#include using namespace LAMMPS_NS; diff --git a/src/SMTBQ/pair_smatb_single.cpp b/src/SMTBQ/pair_smatb_single.cpp index 756941b2b7..4506a1093c 100644 --- a/src/SMTBQ/pair_smatb_single.cpp +++ b/src/SMTBQ/pair_smatb_single.cpp @@ -26,6 +26,7 @@ #include "neighbor.h" #include +#include using namespace LAMMPS_NS; diff --git a/src/SMTBQ/pair_smtbq.cpp b/src/SMTBQ/pair_smtbq.cpp index 4f924a6fca..3696a3ab6c 100644 --- a/src/SMTBQ/pair_smtbq.cpp +++ b/src/SMTBQ/pair_smtbq.cpp @@ -60,6 +60,7 @@ #include #include +#include #include #include @@ -70,11 +71,8 @@ using namespace MathConst; using namespace MathExtra; using namespace MathSpecial; -#define MAXLINE 2048 -#define MAXTOKENS 2048 -#define DELTA 4 -#define PGDELTA 1 -#define MAXNEIGH 24 +static constexpr int PGDELTA = 1; +static constexpr int MAXNEIGH = 24; static constexpr char SMTBQ_SEPARATORS[] = "' \t\n\r"; diff --git a/src/SPIN/fix_neb_spin.cpp b/src/SPIN/fix_neb_spin.cpp index ea8ce9c1fc..0d7703d06f 100644 --- a/src/SPIN/fix_neb_spin.cpp +++ b/src/SPIN/fix_neb_spin.cpp @@ -42,7 +42,7 @@ using namespace FixConst; enum{SINGLE_PROC_DIRECT,SINGLE_PROC_MAP,MULTI_PROC}; -#define BUFSIZE 8 +static constexpr int BUFSIZE = 8; /* ---------------------------------------------------------------------- */ diff --git a/src/SPIN/min_spin.cpp b/src/SPIN/min_spin.cpp index a2202cba32..2843efeb4b 100644 --- a/src/SPIN/min_spin.cpp +++ b/src/SPIN/min_spin.cpp @@ -36,9 +36,8 @@ using namespace MathConst; // EPS_ENERGY = minimum normalization for energy tolerance -#define EPS_ENERGY 1.0e-8 - -#define DELAYSTEP 5 +static constexpr double EPS_ENERGY = 1.0e-8; +static constexpr int DELAYSTEP = 5; /* ---------------------------------------------------------------------- */ diff --git a/src/SPIN/min_spin_cg.cpp b/src/SPIN/min_spin_cg.cpp index ee72609ed9..ed7ab6c329 100644 --- a/src/SPIN/min_spin_cg.cpp +++ b/src/SPIN/min_spin_cg.cpp @@ -54,9 +54,8 @@ static const char cite_minstyle_spin_cg[] = // EPS_ENERGY = minimum normalization for energy tolerance -#define EPS_ENERGY 1.0e-8 - -#define DELAYSTEP 5 +static constexpr double EPS_ENERGY = 1.0e-8; +static constexpr int DELAYSTEP = 5; /* ---------------------------------------------------------------------- */ diff --git a/src/SPIN/min_spin_lbfgs.cpp b/src/SPIN/min_spin_lbfgs.cpp index ae9d33a705..e4f0dce8b9 100644 --- a/src/SPIN/min_spin_lbfgs.cpp +++ b/src/SPIN/min_spin_lbfgs.cpp @@ -54,9 +54,8 @@ static const char cite_minstyle_spin_lbfgs[] = // EPS_ENERGY = minimum normalization for energy tolerance -#define EPS_ENERGY 1.0e-8 - -#define DELAYSTEP 5 +static constexpr double EPS_ENERGY = 1.0e-8; +static constexpr int DELAYSTEP = 5; /* ---------------------------------------------------------------------- */ diff --git a/src/SPIN/neb_spin.cpp b/src/SPIN/neb_spin.cpp index e7ef9ff7ea..fb8b7d8353 100644 --- a/src/SPIN/neb_spin.cpp +++ b/src/SPIN/neb_spin.cpp @@ -44,6 +44,7 @@ #include #include +#include using namespace LAMMPS_NS; @@ -62,10 +63,11 @@ static const char cite_neb_spin[] = "doi={10.1016/j.cpc.2015.07.001}\n" "}\n\n"; -#define MAXLINE 256 -#define CHUNK 1024 +static constexpr int MAXLINE = 256; +static constexpr int CHUNK = 1024; + // 8 attributes: tag, spin norm, position (3), spin direction (3) -#define ATTRIBUTE_PERLINE 8 +static constexpr int ATTRIBUTE_PERLINE = 8; /* ---------------------------------------------------------------------- */ @@ -374,7 +376,7 @@ void NEBSpin::readfile(char *file, int flag) int i,nchunk,eofflag,nlines; tagint tag; char *eof,*start,*next,*buf; - char line[MAXLINE]; + char line[MAXLINE] = {'\0'}; double musp,xx,yy,zz,spx,spy,spz; if (me_universe == 0 && universe->uscreen) diff --git a/src/SPIN/pair_spin_dipole_long.cpp b/src/SPIN/pair_spin_dipole_long.cpp index 849d5c4a9d..f3ef997d01 100644 --- a/src/SPIN/pair_spin_dipole_long.cpp +++ b/src/SPIN/pair_spin_dipole_long.cpp @@ -22,6 +22,7 @@ #include "atom.h" #include "comm.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "kspace.h" #include "math_const.h" @@ -33,14 +34,7 @@ using namespace LAMMPS_NS; using namespace MathConst; - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ diff --git a/src/SRD/fix_srd.cpp b/src/SRD/fix_srd.cpp index e96321a7a3..9b153a1c28 100644 --- a/src/SRD/fix_srd.cpp +++ b/src/SRD/fix_srd.cpp @@ -52,13 +52,13 @@ enum { BIG_MOVE, SRD_MOVE, SRD_ROTATE }; enum { CUBIC_ERROR, CUBIC_WARN }; enum { SHIFT_NO, SHIFT_YES, SHIFT_POSSIBLE }; -#define EINERTIA 0.2 // moment of inertia prefactor for ellipsoid +static constexpr double EINERTIA = 0.2; // moment of inertia prefactor for ellipsoid -#define ATOMPERBIN 30 -#define BIG 1.0e20 -#define VBINSIZE 5 -#define TOLERANCE 0.00001 -#define MAXITER 20 +static constexpr int ATOMPERBIN = 30; +static constexpr double BIG = 1.0e20; +static constexpr int VBINSIZE = 5; +static constexpr double TOLERANCE = 0.00001; +static constexpr int MAXITER = 20; static const char cite_fix_srd[] = "fix srd command: doi:10.1063/1.3419070\n\n" diff --git a/src/UEF/dump_cfg_uef.cpp b/src/UEF/dump_cfg_uef.cpp index d72225b238..776c4675f3 100644 --- a/src/UEF/dump_cfg_uef.cpp +++ b/src/UEF/dump_cfg_uef.cpp @@ -26,9 +26,7 @@ using namespace LAMMPS_NS; -#define UNWRAPEXPAND 10.0 -#define ONEFIELD 32 -#define DELTA 1048576 +static constexpr double UNWRAPEXPAND = 10.0; /* ---------------------------------------------------------------------- * base method is mostly fine, just need to find the FixNHUef diff --git a/src/VORONOI/compute_voronoi_atom.cpp b/src/VORONOI/compute_voronoi_atom.cpp index b4f1aa3055..ca4ad4a85c 100644 --- a/src/VORONOI/compute_voronoi_atom.cpp +++ b/src/VORONOI/compute_voronoi_atom.cpp @@ -35,7 +35,7 @@ using namespace LAMMPS_NS; using namespace voro; -#define FACESDELTA 10000 +static constexpr int FACESDELTA = 10000; /* ---------------------------------------------------------------------- */ diff --git a/src/VTK/dump_vtk.cpp b/src/VTK/dump_vtk.cpp index 172a092629..12fc4ad1ea 100644 --- a/src/VTK/dump_vtk.cpp +++ b/src/VTK/dump_vtk.cpp @@ -93,8 +93,8 @@ enum{X,Y,Z, // required for vtk, must come first enum{LT,LE,GT,GE,EQ,NEQ,XOR}; enum{VTK,VTP,VTU,PVTP,PVTU}; // file formats -#define ONEFIELD 32 -#define DELTA 1048576 +static constexpr int ONEFIELD = 32; +static constexpr int DELTA = 1048576; #if (VTK_MAJOR_VERSION < 5) || (VTK_MAJOR_VERSION > 9) #error This code has only been tested with VTK 5, 6, 7, 8, and 9 @@ -2096,7 +2096,7 @@ int DumpVTK::modify_param(int narg, char **arg) if (refreshflag) error->all(FLERR,"Dump_modify can only have one refresh"); refreshflag = 1; - refresh = argi.copy_name(); + idrefresh = argi.copy_name(); return 2; } diff --git a/src/YAFF/angle_cross.cpp b/src/YAFF/angle_cross.cpp index 46833b7f74..d3e127e935 100644 --- a/src/YAFF/angle_cross.cpp +++ b/src/YAFF/angle_cross.cpp @@ -32,7 +32,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/YAFF/angle_mm3.cpp b/src/YAFF/angle_mm3.cpp index af199f6fe9..3ff7df1653 100644 --- a/src/YAFF/angle_mm3.cpp +++ b/src/YAFF/angle_mm3.cpp @@ -32,7 +32,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/YAFF/improper_distharm.cpp b/src/YAFF/improper_distharm.cpp index 27516fa416..257cbce1b3 100644 --- a/src/YAFF/improper_distharm.cpp +++ b/src/YAFF/improper_distharm.cpp @@ -28,12 +28,8 @@ #include "memory.h" #include "error.h" - using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 - /* ---------------------------------------------------------------------- */ ImproperDistHarm::ImproperDistHarm(LAMMPS *lmp) : Improper(lmp) diff --git a/src/YAFF/improper_sqdistharm.cpp b/src/YAFF/improper_sqdistharm.cpp index 1cd8515d9a..f4beab3587 100644 --- a/src/YAFF/improper_sqdistharm.cpp +++ b/src/YAFF/improper_sqdistharm.cpp @@ -28,12 +28,8 @@ #include "memory.h" #include "error.h" - using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 - /* ---------------------------------------------------------------------- */ ImproperSQDistHarm::ImproperSQDistHarm(LAMMPS *lmp) : Improper(lmp) diff --git a/src/YAFF/pair_lj_switch3_coulgauss_long.cpp b/src/YAFF/pair_lj_switch3_coulgauss_long.cpp index dbbab7e5fe..5fe9b886bf 100644 --- a/src/YAFF/pair_lj_switch3_coulgauss_long.cpp +++ b/src/YAFF/pair_lj_switch3_coulgauss_long.cpp @@ -21,6 +21,7 @@ #include "atom.h" #include "comm.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "kspace.h" #include "math_const.h" @@ -33,14 +34,7 @@ using namespace LAMMPS_NS; using namespace MathConst; - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ @@ -130,6 +124,7 @@ void PairLJSwitch3CoulGaussLong::compute(int eflag, int vflag) jtype = type[j]; if (rsq < cutsq[itype][jtype]) { + forcecoul = forcecoul2 = forcelj = 0.0; r2inv = 1.0/rsq; if (rsq < cut_coulsq) { @@ -155,7 +150,7 @@ void PairLJSwitch3CoulGaussLong::compute(int eflag, int vflag) forcecoul -= (1.0-factor_coul)*prefactor; } } - } else forcecoul = 0.0; + } if (rsq < cut_ljsq[itype][jtype]) { // Lennard-Jones potential @@ -166,7 +161,6 @@ void PairLJSwitch3CoulGaussLong::compute(int eflag, int vflag) if (lj2[itype][jtype]==0.0) { // This means a point charge is considered, so the correction is zero erfc2 = 0.0; - forcecoul2 = 0.0; prefactor2 = 0.0; } else { rrij = lj2[itype][jtype]*r; @@ -175,7 +169,7 @@ void PairLJSwitch3CoulGaussLong::compute(int eflag, int vflag) prefactor2 = -qqrd2e*qtmp*q[j]/r; forcecoul2 = prefactor2*(erfc2+EWALD_F*rrij*expn2); } - } else forcelj = 0.0; + } if (rsq < cut_coulsq) { if (!ncoultablebits || rsq <= tabinnersq) @@ -586,6 +580,8 @@ double PairLJSwitch3CoulGaussLong::single(int i, int j, int itype, int jtype, r2inv = 1.0/rsq; r = sqrt(rsq); + forcecoul = forcecoul2 = 0.0; + if (rsq < cut_coulsq) { if (!ncoultablebits || rsq <= tabinnersq) { grij = g_ewald * r; @@ -616,7 +612,6 @@ double PairLJSwitch3CoulGaussLong::single(int i, int j, int itype, int jtype, forcelj = r6inv*(12.0*lj3[itype][jtype]*r6inv-6.0*lj4[itype][jtype]); if (lj2[itype][jtype] == 0.0) { erfc2 = 0.0; - forcecoul2 = 0.0; prefactor2 = 0.0; } else { rrij = lj2[itype][jtype]*r; diff --git a/src/YAFF/pair_mm3_switch3_coulgauss_long.cpp b/src/YAFF/pair_mm3_switch3_coulgauss_long.cpp index 96e4e4c35f..c4f31f2059 100644 --- a/src/YAFF/pair_mm3_switch3_coulgauss_long.cpp +++ b/src/YAFF/pair_mm3_switch3_coulgauss_long.cpp @@ -21,6 +21,7 @@ #include "atom.h" #include "comm.h" #include "error.h" +#include "ewald_const.h" #include "force.h" #include "kspace.h" #include "math_const.h" @@ -33,14 +34,7 @@ using namespace LAMMPS_NS; using namespace MathConst; - -#define EWALD_F 1.12837917 -#define EWALD_P 0.3275911 -#define A1 0.254829592 -#define A2 -0.284496736 -#define A3 1.421413741 -#define A4 -1.453152027 -#define A5 1.061405429 +using namespace EwaldConst; /* ---------------------------------------------------------------------- */ @@ -130,6 +124,7 @@ void PairMM3Switch3CoulGaussLong::compute(int eflag, int vflag) jtype = type[j]; if (rsq < cutsq[itype][jtype]) { + forcecoul = forcecoul2 = forcelj = 0.0; r2inv = 1.0/rsq; if (rsq < cut_coulsq) { @@ -155,7 +150,7 @@ void PairMM3Switch3CoulGaussLong::compute(int eflag, int vflag) forcecoul -= (1.0-factor_coul)*prefactor; } } - } else forcecoul = 0.0; + } if (rsq < cut_ljsq[itype][jtype]) { // Repulsive exponential part @@ -170,7 +165,6 @@ void PairMM3Switch3CoulGaussLong::compute(int eflag, int vflag) // This means a point charge is considered, so the correction is zero expn2 = 0.0; erfc2 = 0.0; - forcecoul2 = 0.0; prefactor2 = 0.0; } else { rrij = lj2[itype][jtype]*r; @@ -179,7 +173,7 @@ void PairMM3Switch3CoulGaussLong::compute(int eflag, int vflag) prefactor2 = -qqrd2e*qtmp*q[j]/r; forcecoul2 = prefactor2*(erfc2+EWALD_F*rrij*expn2); } - } else forcelj = 0.0; + } if (rsq < cut_coulsq) { if (!ncoultablebits || rsq <= tabinnersq) @@ -587,6 +581,8 @@ double PairMM3Switch3CoulGaussLong::single(int i, int j, int itype, int jtype, r2inv = 1.0/rsq; r = sqrt(rsq); + forcecoul = forcecoul2 = 0.0; + if (rsq < cut_coulsq) { if (!ncoultablebits || rsq <= tabinnersq) { grij = g_ewald * r; @@ -610,7 +606,7 @@ double PairMM3Switch3CoulGaussLong::single(int i, int j, int itype, int jtype, forcecoul -= (1.0-factor_coul)*prefactor; } } - } else forcecoul = 0.0; + } if (rsq < cut_ljsq[itype][jtype]) { expb = lj3[itype][jtype]*exp(-lj1[itype][jtype]*r); @@ -621,7 +617,6 @@ double PairMM3Switch3CoulGaussLong::single(int i, int j, int itype, int jtype, if (lj2[itype][jtype] == 0.0) { expn2 = 0.0; erfc2 = 0.0; - forcecoul2 = 0.0; prefactor2 = 0.0; } else { rrij = lj2[itype][jtype]*r; diff --git a/src/angle.cpp b/src/angle.cpp index 93d217237e..79893cc52f 100644 --- a/src/angle.cpp +++ b/src/angle.cpp @@ -24,7 +24,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define FOURTH 0.25 +static constexpr double FOURTH = 0.25; /* ---------------------------------------------------------------------- */ diff --git a/src/angle_hybrid.cpp b/src/angle_hybrid.cpp index 7419139942..e79776b0d2 100644 --- a/src/angle_hybrid.cpp +++ b/src/angle_hybrid.cpp @@ -24,7 +24,7 @@ using namespace LAMMPS_NS; -#define EXTRA 1000 +static constexpr int EXTRA = 1000; /* ---------------------------------------------------------------------- */ diff --git a/src/angle_write.cpp b/src/angle_write.cpp index fb0e65ccf5..48420ae7be 100644 --- a/src/angle_write.cpp +++ b/src/angle_write.cpp @@ -25,7 +25,6 @@ #include "error.h" #include "force.h" #include "input.h" -#include "lammps.h" #include "math_const.h" #include "update.h" @@ -35,7 +34,7 @@ using MathConst::DEG2RAD; using MathConst::RAD2DEG; static constexpr double epsilon = 6.5e-6; -#define MAXLINE 1024 +static constexpr int MAXLINE = 1024; /* ---------------------------------------------------------------------- */ void AngleWrite::command(int narg, char **arg) @@ -147,7 +146,7 @@ void AngleWrite::command(int narg, char **arg) writer->input->one("mass * 1.0"); writer->input->one(fmt::format("angle_style {}", force->angle_style)); FILE *coeffs; - char line[MAXLINE]; + char line[MAXLINE] = {'\0'}; coeffs = fopen(coeffs_file.c_str(), "r"); for (int i = 0; i < atom->nangletypes; ++i) { fgets(line, MAXLINE, coeffs); diff --git a/src/atom.cpp b/src/atom.cpp index b604c54e6b..085ca88b4e 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -26,6 +26,7 @@ #include "input.h" #include "label_map.h" #include "math_const.h" +#include "math_extra.h" #include "memory.h" #include "modify.h" #include "molecule.h" @@ -47,9 +48,8 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define DELTA 1 -#define EPSILON 1.0e-6 -#define MAXLINE 256 +static constexpr int DELTA = 1; +static constexpr double EPSILON = 1.0e-6; /* ---------------------------------------------------------------------- one instance per AtomVec style in style_atom.h @@ -234,6 +234,7 @@ Atom::Atom(LAMMPS *_lmp) : Pointers(_lmp), atom_style(nullptr), avec(nullptr), a darray = nullptr; icols = dcols = nullptr; ivname = dvname = ianame = daname = nullptr; + ivghost = dvghost = iaghost = daghost = nullptr; // initialize atom style and array existence flags @@ -333,6 +334,10 @@ Atom::~Atom() memory->sfree(darray); memory->sfree(icols); memory->sfree(dcols); + memory->destroy(ivghost); + memory->destroy(dvghost); + memory->destroy(iaghost); + memory->destroy(daghost); // delete user-defined molecules @@ -618,7 +623,7 @@ void Atom::set_atomflag_defaults() // identical list as 2nd customization in atom.h labelmapflag = 0; - sphere_flag = ellipsoid_flag = line_flag = tri_flag = body_flag = 0; + ellipsoid_flag = line_flag = tri_flag = body_flag = 0; quat_flag = 0; peri_flag = electron_flag = 0; wavepacket_flag = sph_flag = 0; @@ -2112,6 +2117,15 @@ std::vectorAtom::get_molecule_by_id(const std::string &id) void Atom::add_molecule_atom(Molecule *onemol, int iatom, int ilocal, tagint offset) { if (onemol->qflag && q_flag) q[ilocal] = onemol->q[iatom]; + if (onemol->muflag && mu_flag) { + double r[3], rotmat[3][3]; + MathExtra::quat_to_mat(onemol->quat_external, rotmat); + MathExtra::matvec(rotmat, onemol->mu[iatom], r); + mu[ilocal][0] = r[0]; + mu[ilocal][1] = r[1]; + mu[ilocal][2] = r[2]; + mu[ilocal][3] = sqrt(r[0] * r[0] + r[1] * r[1] + r[2] * r[2]); + } if (onemol->radiusflag && radius_flag) radius[ilocal] = onemol->radius[iatom]; if (onemol->rmassflag && rmass_flag) rmass[ilocal] = onemol->rmass[iatom]; else if (rmass_flag) @@ -2599,6 +2613,18 @@ void Atom::update_callback(int ifix) if (extra_border[i] > ifix) extra_border[i]--; } +/** \brief Find a custom per-atom property with given name +\verbatim embed:rst + +This function returns the list index of a custom per-atom property +with the name "name", also returning by reference its data type and +number of values per atom. +\endverbatim + * \param name Name of the property (w/o a "i_" or "d_" or "i2_" or "d2_" prefix) + * \param &flag Returns data type of property: 0 for int, 1 for double + * \param &cols Returns number of values: 0 for a single value, 1 or more for a vector of values + * \return index of property in the respective list of properties + */ /* ---------------------------------------------------------------------- find custom per-atom vector with name return index if found, -1 if not found @@ -2642,6 +2668,33 @@ int Atom::find_custom(const char *name, int &flag, int &cols) return -1; } +/** \brief Find a custom per-atom property with given name and retrieve ghost property +\verbatim embed:rst + +This function returns the list index of a custom per-atom property +with the name "name", also returning by reference its data type, +number of values per atom, and if it is communicated to ghost particles. +Classes rarely need to check on ghost communication and so `find_custom` +is typically preferred to this function. See :doc:`pair amoeba ` +for an example where checking ghost communication is necessary. +\endverbatim + * \param name Name of the property (w/o a "i_" or "d_" or "i2_" or "d2_" prefix) + * \param &flag Returns data type of property: 0 for int, 1 for double + * \param &cols Returns number of values: 0 for a single value, 1 or more for a vector of values + * \param &ghost Returns whether property is communicated to ghost atoms: 0 for no, 1 for yes + * \return index of property in the respective list of properties + */ +int Atom::find_custom_ghost(const char *name, int &flag, int &cols, int &ghost) +{ + int i = find_custom(name, flag, cols); + if (i == -1) return i; + if ((flag == 0) && (cols == 0)) ghost = ivghost[i]; + else if ((flag == 1) && (cols == 0)) ghost = dvghost[i]; + else if ((flag == 0) && (cols == 1)) ghost = iaghost[i]; + else if ((flag == 1) && (cols == 1)) ghost = daghost[i]; + return i; +} + /** \brief Add a custom per-atom property with the given name and type and size \verbatim embed:rst @@ -2652,9 +2705,10 @@ This function is called, e.g. from :doc:`fix property/atom `. * \param name Name of the property (w/o a "i_" or "d_" or "i2_" or "d2_" prefix) * \param flag Data type of property: 0 for int, 1 for double * \param cols Number of values: 0 for a single value, 1 or more for a vector of values + * \param ghost Whether property is communicated to ghost atoms: 0 for no, 1 for yes * \return index of property in the respective list of properties */ -int Atom::add_custom(const char *name, int flag, int cols) +int Atom::add_custom(const char *name, int flag, int cols, int ghost) { int index = -1; @@ -2663,6 +2717,8 @@ int Atom::add_custom(const char *name, int flag, int cols) nivector++; ivname = (char **) memory->srealloc(ivname,nivector*sizeof(char *),"atom:ivname"); ivname[index] = utils::strdup(name); + ivghost = (int *) memory->srealloc(ivghost,nivector*sizeof(int),"atom:ivghost"); + ivghost[index] = ghost; ivector = (int **) memory->srealloc(ivector,nivector*sizeof(int *),"atom:ivector"); memory->create(ivector[index],nmax,"atom:ivector"); @@ -2671,6 +2727,8 @@ int Atom::add_custom(const char *name, int flag, int cols) ndvector++; dvname = (char **) memory->srealloc(dvname,ndvector*sizeof(char *),"atom:dvname"); dvname[index] = utils::strdup(name); + dvghost = (int *) memory->srealloc(dvghost,ndvector*sizeof(int),"atom:dvghost"); + dvghost[index] = ghost; dvector = (double **) memory->srealloc(dvector,ndvector*sizeof(double *),"atom:dvector"); memory->create(dvector[index],nmax,"atom:dvector"); @@ -2679,6 +2737,8 @@ int Atom::add_custom(const char *name, int flag, int cols) niarray++; ianame = (char **) memory->srealloc(ianame,niarray*sizeof(char *),"atom:ianame"); ianame[index] = utils::strdup(name); + iaghost = (int *) memory->srealloc(iaghost,niarray*sizeof(int),"atom:iaghost"); + iaghost[index] = ghost; iarray = (int ***) memory->srealloc(iarray,niarray*sizeof(int **),"atom:iarray"); memory->create(iarray[index],nmax,cols,"atom:iarray"); icols = (int *) memory->srealloc(icols,niarray*sizeof(int),"atom:icols"); @@ -2689,6 +2749,8 @@ int Atom::add_custom(const char *name, int flag, int cols) ndarray++; daname = (char **) memory->srealloc(daname,ndarray*sizeof(char *),"atom:daname"); daname[index] = utils::strdup(name); + daghost = (int *) memory->srealloc(daghost,ndarray*sizeof(int),"atom:daghost"); + daghost[index] = ghost; darray = (double ***) memory->srealloc(darray,ndarray*sizeof(double **),"atom:darray"); memory->create(darray[index],nmax,cols,"atom:darray"); dcols = (int *) memory->srealloc(dcols,ndarray*sizeof(int),"atom:dcols"); @@ -2697,6 +2759,7 @@ int Atom::add_custom(const char *name, int flag, int cols) if (index < 0) error->all(FLERR,"Invalid call to Atom::add_custom()"); + return index; } diff --git a/src/atom.h b/src/atom.h index 548168ac59..f238b2d5b1 100644 --- a/src/atom.h +++ b/src/atom.h @@ -180,7 +180,7 @@ class Atom : protected Pointers { // 1 if variable is used, 0 if not int labelmapflag, types_style; - int sphere_flag, ellipsoid_flag, line_flag, tri_flag, body_flag; + int ellipsoid_flag, line_flag, tri_flag, body_flag; int peri_flag, electron_flag; int wavepacket_flag, sph_flag; @@ -242,6 +242,7 @@ class Atom : protected Pointers { int *icols, *dcols; char **ivname, **dvname, **ianame, **daname; int nivector, ndvector, niarray, ndarray; + int *ivghost, *dvghost, *iaghost, *daghost; // molecule templates // each template can be a set of consecutive molecules @@ -363,7 +364,8 @@ class Atom : protected Pointers { void update_callback(int); int find_custom(const char *, int &, int &); - virtual int add_custom(const char *, int, int); + int find_custom_ghost(const char *, int &, int &, int &); + virtual int add_custom(const char *, int, int, int ghost = 0); virtual void remove_custom(int, int, int); void *extract(const char *); diff --git a/src/atom_map.cpp b/src/atom_map.cpp index c28b886335..37b46182c1 100644 --- a/src/atom_map.cpp +++ b/src/atom_map.cpp @@ -22,7 +22,7 @@ using namespace LAMMPS_NS; -#define EXTRA 1000 +static constexpr int EXTRA = 1000; /* ---------------------------------------------------------------------- allocate and initialize array or hash table for global -> local map diff --git a/src/atom_vec.cpp b/src/atom_vec.cpp index bfda951823..8ea1d145eb 100644 --- a/src/atom_vec.cpp +++ b/src/atom_vec.cpp @@ -1714,7 +1714,7 @@ void AtomVec::data_atom(double *coord, imageint imagetmp, const std::vectortag_enable && (tag[nlocal] <= 0)) || (!atom->tag_enable && (tag[nlocal] != 0))) error->one(FLERR, "Invalid atom ID {} in line {} of Atoms section of data file", tag[nlocal], nlocal + 1); diff --git a/src/atom_vec_line.cpp b/src/atom_vec_line.cpp index ff09bed6d0..cd747d0862 100644 --- a/src/atom_vec_line.cpp +++ b/src/atom_vec_line.cpp @@ -44,7 +44,6 @@ AtomVecLine::AtomVecLine(LAMMPS *lmp) : AtomVec(lmp) atom->line_flag = 1; atom->molecule_flag = atom->rmass_flag = 1; atom->radius_flag = atom->omega_flag = atom->torque_flag = 1; - atom->sphere_flag = 1; nlocal_bonus = nghost_bonus = nmax_bonus = 0; bonus = nullptr; diff --git a/src/atom_vec_sphere.cpp b/src/atom_vec_sphere.cpp index 8769c316d9..3c7be5d3ee 100644 --- a/src/atom_vec_sphere.cpp +++ b/src/atom_vec_sphere.cpp @@ -19,8 +19,6 @@ #include "math_const.h" #include "modify.h" -#include - using namespace LAMMPS_NS; using namespace MathConst; @@ -32,7 +30,6 @@ AtomVecSphere::AtomVecSphere(LAMMPS *lmp) : AtomVec(lmp) molecular = Atom::ATOMIC; radvary = 0; - atom->sphere_flag = 1; atom->radius_flag = atom->rmass_flag = atom->omega_flag = atom->torque_flag = 1; // strings with peratom variables to include in each AtomVec method @@ -60,13 +57,10 @@ AtomVecSphere::AtomVecSphere(LAMMPS *lmp) : AtomVec(lmp) void AtomVecSphere::process_args(int narg, char **arg) { - if (narg != 0 && narg != 1) error->all(FLERR, "Illegal atom_style sphere command"); + if (narg > 1) error->all(FLERR, "Illegal atom_style sphere command"); radvary = 0; - if (narg == 1) { - radvary = utils::numeric(FLERR, arg[0], true, lmp); - if (radvary < 0 || radvary > 1) error->all(FLERR, "Illegal atom_style sphere command"); - } + if (narg == 1) radvary = utils::logical(FLERR, arg[0], true, lmp); // dynamic particle radius and mass must be communicated every step diff --git a/src/atom_vec_tri.cpp b/src/atom_vec_tri.cpp index a46609b02c..205e94d792 100644 --- a/src/atom_vec_tri.cpp +++ b/src/atom_vec_tri.cpp @@ -47,7 +47,6 @@ AtomVecTri::AtomVecTri(LAMMPS *lmp) : AtomVec(lmp) atom->molecule_flag = atom->rmass_flag = 1; atom->radius_flag = atom->omega_flag = atom->angmom_flag = 1; atom->torque_flag = 1; - atom->sphere_flag = 1; nlocal_bonus = nghost_bonus = nmax_bonus = 0; bonus = nullptr; diff --git a/src/bond_hybrid.cpp b/src/bond_hybrid.cpp index 4e477ab3a6..401358dda0 100644 --- a/src/bond_hybrid.cpp +++ b/src/bond_hybrid.cpp @@ -24,7 +24,7 @@ using namespace LAMMPS_NS; -#define EXTRA 1000 +static constexpr int EXTRA = 1000; /* ---------------------------------------------------------------------- */ diff --git a/src/comm.cpp b/src/comm.cpp index a6ac1c4bc8..02999fd541 100644 --- a/src/comm.cpp +++ b/src/comm.cpp @@ -42,7 +42,7 @@ using namespace LAMMPS_NS; -#define BUFEXTRA 1024 +static constexpr int BUFEXTRA = 1024; enum{ONELEVEL,TWOLEVEL,NUMA,CUSTOM}; enum{CART,CARTREORDER,XYZ}; @@ -420,6 +420,7 @@ void Comm::set_processors(int narg, char **arg) error->all(FLERR,"Specified processors != physical processors"); int iarg = 3; + numa_nodes = 2; while (iarg < narg) { if (strcmp(arg[iarg],"grid") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal processors command"); @@ -514,6 +515,12 @@ void Comm::set_processors(int narg, char **arg) outfile = utils::strdup(arg[iarg+1]); iarg += 2; + } else if (strcmp(arg[iarg],"numa_nodes") == 0) { + if (iarg+2 > narg) error->all(FLERR,"Illegal processors command"); + numa_nodes = utils::inumeric(FLERR,arg[iarg+1],false,lmp); + if (numa_nodes < 1) numa_nodes = 2; + iarg += 2; + } else error->all(FLERR,"Illegal processors command"); } @@ -565,7 +572,7 @@ void Comm::set_proc_grid(int outflag) otherflag,other_style,other_procgrid,other_coregrid); } else if (gridflag == NUMA) { - pmap->numa_grid(nprocs,user_procgrid,procgrid,coregrid); + pmap->numa_grid(numa_nodes,nprocs,user_procgrid,procgrid,coregrid); } else if (gridflag == CUSTOM) { pmap->custom_grid(customfile,nprocs,user_procgrid,procgrid); diff --git a/src/comm.h b/src/comm.h index 5d803c1afa..fde4c3b81f 100644 --- a/src/comm.h +++ b/src/comm.h @@ -146,6 +146,7 @@ class Comm : protected Pointers { char xyz[4]; // xyz mapping of procs to 3d grid char *customfile; // file with custom proc map char *outfile; // proc grid/map output file + int numa_nodes; // Number of numa domains per socket for 3d grid int otherflag; // 1 if this partition dependent on another int other_style; // style of dependency diff --git a/src/comm_brick.cpp b/src/comm_brick.cpp index 08d372187e..cf38271029 100644 --- a/src/comm_brick.cpp +++ b/src/comm_brick.cpp @@ -35,9 +35,9 @@ using namespace LAMMPS_NS; -#define BUFFACTOR 1.5 -#define BUFMIN 1024 -#define BIG 1.0e20 +static constexpr double BUFFACTOR = 1.5; +static constexpr int BUFMIN = 1024; +static constexpr double BIG = 1.0e20; /* ---------------------------------------------------------------------- */ diff --git a/src/comm_tiled.cpp b/src/comm_tiled.cpp index f2d91c07fa..b864e0523d 100644 --- a/src/comm_tiled.cpp +++ b/src/comm_tiled.cpp @@ -36,12 +36,10 @@ using namespace LAMMPS_NS; -#define BUFFACTOR 1.5 -#define BUFFACTOR 1.5 -#define BUFMIN 1024 -#define EPSILON 1.0e-6 - -#define DELTA_PROCS 16 +static constexpr double BUFFACTOR = 1.5; +static constexpr int BUFMIN = 1024; +static constexpr double EPSILON = 1.0e-6; +static constexpr int DELTA_PROCS = 16; /* ---------------------------------------------------------------------- */ @@ -49,14 +47,9 @@ CommTiled::CommTiled(LAMMPS *lmp) : Comm(lmp) { style = Comm::TILED; layout = Comm::LAYOUT_UNIFORM; - pbc_flag = nullptr; - buf_send = nullptr; - buf_recv = nullptr; - overlap = nullptr; - rcbinfo = nullptr; - cutghostmulti = nullptr; - cutghostmultiold = nullptr; - init_buffers(); + init_pointers(); + init_buffers_flag = 0; + maxswap = 0; } /* ---------------------------------------------------------------------- */ @@ -71,7 +64,9 @@ CommTiled::CommTiled(LAMMPS * /*lmp*/, Comm *oldcomm) : Comm(*oldcomm) style = Comm::TILED; layout = oldcomm->layout; Comm::copy_arrays(oldcomm); - init_buffers(); + init_pointers(); + init_buffers_flag = 0; + maxswap = 0; } /* ---------------------------------------------------------------------- */ @@ -87,24 +82,59 @@ CommTiled::~CommTiled() memory->destroy(cutghostmultiold); } +/* ---------------------------------------------------------------------- + initialize comm pointers to nullptr +------------------------------------------------------------------------- */ + +void CommTiled::init_pointers() +{ + buf_send = buf_recv = nullptr; + overlap = nullptr; + rcbinfo = nullptr; + cutghostmulti = nullptr; + cutghostmultiold = nullptr; + + nsendproc = nullptr; + nrecvproc = nullptr; + sendother = nullptr; + recvother = nullptr; + sendself = nullptr; + sendproc = nullptr; + recvproc = nullptr; + sendnum = nullptr; + recvnum = nullptr; + size_forward_recv = nullptr; + firstrecv = nullptr; + size_reverse_send = nullptr; + size_reverse_recv = nullptr; + forward_recv_offset = nullptr; + reverse_recv_offset = nullptr; + pbc_flag = nullptr; + pbc = nullptr; + sendbox = nullptr; + sendbox_multi = nullptr; + sendbox_multiold = nullptr; + maxsendlist = nullptr; + sendlist = nullptr; + requests = nullptr; + nprocmax = nullptr; + nexchproc = nullptr; + nexchprocmax = nullptr; + exchproc = nullptr; + exchnum = nullptr; +} + /* ---------------------------------------------------------------------- initialize comm buffers and other data structs local to CommTiled ------------------------------------------------------------------------- */ void CommTiled::init_buffers() { - buf_send = buf_recv = nullptr; maxsend = maxrecv = BUFMIN; grow_send(maxsend,2); - memory->create(buf_recv,maxrecv,"comm:buf_recv"); + grow_recv(maxrecv,1); maxoverlap = 0; - overlap = nullptr; - rcbinfo = nullptr; - cutghostmulti = nullptr; - cutghostmultiold = nullptr; - sendbox_multi = nullptr; - sendbox_multiold = nullptr; // Note this may skip growing multi arrays, will call again in init() maxswap = 6; @@ -115,6 +145,11 @@ void CommTiled::init_buffers() void CommTiled::init() { + if (!init_buffers_flag) { + init_buffers(); + init_buffers_flag = 1; + } + Comm::init(); // cannot set nswap in init_buffers() b/c @@ -2238,12 +2273,15 @@ void CommTiled::grow_send(int n, int flag) } /* ---------------------------------------------------------------------- - free/malloc the size of the recv buffer as needed with BUFFACTOR + free/malloc the size of the recv buffer as needed + flag = 0, realloc with BUFFACTOR + flag = 1, free/malloc w/out BUFFACTOR ------------------------------------------------------------------------- */ -void CommTiled::grow_recv(int n) +void CommTiled::grow_recv(int n, int flag) { - maxrecv = static_cast (BUFFACTOR * n); + if (flag) maxrecv = n; + else maxrecv = static_cast (BUFFACTOR * n); memory->destroy(buf_recv); memory->create(buf_recv,maxrecv,"comm:buf_recv"); } @@ -2430,8 +2468,10 @@ void CommTiled::deallocate_swap(int n) delete [] maxsendlist[i]; - for (int j = 0; j < nprocmax[i]; j++) memory->destroy(sendlist[i][j]); - delete [] sendlist[i]; + if (sendlist && sendlist[i]) { + for (int j = 0; j < nprocmax[i]; j++) memory->destroy(sendlist[i][j]); + delete [] sendlist[i]; + } } delete [] sendproc; diff --git a/src/comm_tiled.h b/src/comm_tiled.h index c9434e6164..857cddf033 100644 --- a/src/comm_tiled.h +++ b/src/comm_tiled.h @@ -51,7 +51,7 @@ class CommTiled : public Comm { double memory_usage() override; - private: + protected: int nswap; // # of swaps to perform = 2*dim int maxswap; // largest nswap can be = 6 @@ -117,8 +117,9 @@ class CommTiled : public Comm { double *sublo, *subhi; int dimension; - // NOTE: init_buffers is called from a constructor and must not be made virtual + void init_pointers(); void init_buffers(); + int init_buffers_flag; // box drop and other functions @@ -145,11 +146,11 @@ class CommTiled : public Comm { int point_drop_tiled_recurse(double *, int, int); int closer_subbox_edge(int, double *); - void grow_send(int, int); // reallocate send buffer - void grow_recv(int); // free/allocate recv buffer - void grow_list(int, int, int); // reallocate sendlist for one swap/proc + virtual void grow_send(int, int); // reallocate send buffer + virtual void grow_recv(int, int flag = 0); // free/allocate recv buffer + virtual void grow_list(int, int, int); // reallocate sendlist for one swap/proc void allocate_swap(int); // allocate swap arrays - void grow_swap_send(int, int, int); // grow swap arrays for send and recv + virtual void grow_swap_send(int, int, int); // grow swap arrays for send and recv void grow_swap_send_multi(int, int); // grow multi swap arrays for send and recv void grow_swap_recv(int, int); void deallocate_swap(int); // deallocate swap arrays diff --git a/src/compute.cpp b/src/compute.cpp index d47d1d5292..a12373fd51 100644 --- a/src/compute.cpp +++ b/src/compute.cpp @@ -26,8 +26,7 @@ using namespace LAMMPS_NS; -#define DELTA 4 -#define BIG MAXTAGINT +static constexpr int DELTA = 4; // allocate space for static class instance variable and initialize it diff --git a/src/compute_aggregate_atom.cpp b/src/compute_aggregate_atom.cpp index 5a489092b7..8c6f7165a2 100644 --- a/src/compute_aggregate_atom.cpp +++ b/src/compute_aggregate_atom.cpp @@ -31,7 +31,6 @@ #include "update.h" #include -#include using namespace LAMMPS_NS; diff --git a/src/compute_angle_local.cpp b/src/compute_angle_local.cpp index 3600562664..3e8b15fd64 100644 --- a/src/compute_angle_local.cpp +++ b/src/compute_angle_local.cpp @@ -31,7 +31,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define DELTA 10000 +static constexpr int DELTA = 10000; enum{THETA,ENG,VARIABLE}; diff --git a/src/compute_bond_local.cpp b/src/compute_bond_local.cpp index f2603e8cdd..9ed591f73f 100644 --- a/src/compute_bond_local.cpp +++ b/src/compute_bond_local.cpp @@ -31,8 +31,7 @@ using namespace LAMMPS_NS; -#define DELTA 10000 -#define EPSILON 1.0e-12 +static constexpr int DELTA = 10000; enum{DIST,DX,DY,DZ,VELVIB,OMEGA,ENGTRANS,ENGVIB,ENGROT,ENGPOT,FORCE,FX,FY,FZ,VARIABLE,BN}; @@ -375,13 +374,6 @@ int ComputeBondLocal::compute_bonds(int flag) engrot = 0.5 * inertia * omegasq; - // sanity check: engtotal = engtrans + engvib + engrot - - //engtot = 0.5 * (mass1*MathExtra::lensq3(v[atom1]) + - // mass2*MathExtra::lensq3(v[atom2])); - //if (fabs(engtot-engtrans-engvib-engrot) > EPSILON) - // error->one(FLERR,"Sanity check on 3 energy components failed"); - // scale energies by units mvv2e = force->mvv2e; diff --git a/src/compute_centroid_stress_atom.cpp b/src/compute_centroid_stress_atom.cpp index 5226af1998..c6854737a8 100644 --- a/src/compute_centroid_stress_atom.cpp +++ b/src/compute_centroid_stress_atom.cpp @@ -303,8 +303,8 @@ void ComputeCentroidStressAtom::compute_peratom() // add in per-atom contributions from relevant fixes // skip if vatom = nullptr // possible during setup phase if fix has not initialized its vatom yet - // e.g. fix ave/spatial defined before fix shake, - // and fix ave/spatial uses a per-atom stress from this compute as input + // e.g. fix ave/chunk defined before fix shake, + // and fix ave/chunk uses a per-atom stress from this compute as input // fix styles are CENTROID_SAME, CENTROID_AVAIL or CENTROID_NOTAVAIL if (fixflag) { diff --git a/src/compute_chunk_atom.cpp b/src/compute_chunk_atom.cpp index fc70a3246f..a1d595a086 100644 --- a/src/compute_chunk_atom.cpp +++ b/src/compute_chunk_atom.cpp @@ -46,7 +46,7 @@ enum { NODISCARD, MIXED, YESDISCARD }; enum { ONCE, NFREQ, EVERY }; // used in several files enum { LIMITMAX, LIMITEXACT }; -#define IDMAX (1024 * 1024) +static constexpr int IDMAX = (1024 * 1024); /* ---------------------------------------------------------------------- */ diff --git a/src/compute_cluster_atom.cpp b/src/compute_cluster_atom.cpp index ba0f263747..0021d32e2c 100644 --- a/src/compute_cluster_atom.cpp +++ b/src/compute_cluster_atom.cpp @@ -25,7 +25,6 @@ #include "update.h" #include -#include using namespace LAMMPS_NS; diff --git a/src/compute_cna_atom.cpp b/src/compute_cna_atom.cpp index a09a671c07..b92dca8f86 100644 --- a/src/compute_cna_atom.cpp +++ b/src/compute_cna_atom.cpp @@ -29,7 +29,6 @@ #include "update.h" #include -#include using namespace LAMMPS_NS; diff --git a/src/compute_count_type.cpp b/src/compute_count_type.cpp index 3d4815f9ff..d430b23e11 100644 --- a/src/compute_count_type.cpp +++ b/src/compute_count_type.cpp @@ -14,12 +14,12 @@ #include "compute_count_type.h" #include "atom.h" -#include "domain.h" #include "error.h" #include "force.h" -#include "group.h" #include "update.h" +#include + using namespace LAMMPS_NS; enum { ATOM, BOND, ANGLE, DIHEDRAL, IMPROPER }; diff --git a/src/compute_dihedral_local.cpp b/src/compute_dihedral_local.cpp index a6bcbccf00..894d0e33e4 100644 --- a/src/compute_dihedral_local.cpp +++ b/src/compute_dihedral_local.cpp @@ -30,10 +30,9 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define DELTA 10000 -#define SMALL 0.001 +static constexpr int DELTA = 10000; -enum{PHI,VARIABLE}; +enum { PHI, VARIABLE }; /* ---------------------------------------------------------------------- */ diff --git a/src/compute_dipole_chunk.h b/src/compute_dipole_chunk.h index 603e6a4353..3ed875283f 100644 --- a/src/compute_dipole_chunk.h +++ b/src/compute_dipole_chunk.h @@ -23,7 +23,6 @@ ComputeStyle(dipole/chunk,ComputeDipoleChunk); #include "compute_chunk.h" namespace LAMMPS_NS { -class Fix; class ComputeDipoleChunk : public ComputeChunk { public: @@ -43,8 +42,6 @@ class ComputeDipoleChunk : public ComputeChunk { void allocate() override; }; - } // namespace LAMMPS_NS - #endif #endif diff --git a/src/compute_erotate_sphere.cpp b/src/compute_erotate_sphere.cpp index b020fc4e0e..cb92b73731 100644 --- a/src/compute_erotate_sphere.cpp +++ b/src/compute_erotate_sphere.cpp @@ -20,7 +20,7 @@ using namespace LAMMPS_NS; -#define INERTIA 0.4 // moment of inertia prefactor for sphere +static constexpr double INERTIA = 0.4; // moment of inertia prefactor for sphere /* ---------------------------------------------------------------------- */ @@ -34,7 +34,7 @@ ComputeERotateSphere::ComputeERotateSphere(LAMMPS *lmp, int narg, char **arg) : // error check - if (!atom->sphere_flag) error->all(FLERR, "Compute erotate/sphere requires atom style sphere"); + if (!atom->omega_flag) error->all(FLERR, "Compute erotate/sphere requires atom attribute omega"); } /* ---------------------------------------------------------------------- */ diff --git a/src/compute_erotate_sphere_atom.cpp b/src/compute_erotate_sphere_atom.cpp index 3ec0f402a8..fa1ce8a180 100644 --- a/src/compute_erotate_sphere_atom.cpp +++ b/src/compute_erotate_sphere_atom.cpp @@ -12,36 +12,35 @@ ------------------------------------------------------------------------- */ #include "compute_erotate_sphere_atom.h" -#include + #include "atom.h" -#include "update.h" -#include "modify.h" #include "comm.h" +#include "error.h" #include "force.h" #include "memory.h" -#include "error.h" +#include "modify.h" +#include "update.h" using namespace LAMMPS_NS; -#define INERTIA 0.4 // moment of inertia prefactor for sphere +static constexpr double INERTIA = 0.4; // moment of inertia prefactor for sphere /* ---------------------------------------------------------------------- */ -ComputeErotateSphereAtom:: -ComputeErotateSphereAtom(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg), - erot(nullptr) +ComputeErotateSphereAtom::ComputeErotateSphereAtom(LAMMPS *lmp, int narg, char **arg) : + Compute(lmp, narg, arg), erot(nullptr) { - if (narg != 3) - error->all(FLERR,"Illegal compute erotate/sphere//atom command"); + if (narg != 3) error->all(FLERR, "Illegal compute erotate/sphere//atom command"); peratom_flag = 1; size_peratom_cols = 0; // error check - if (!atom->sphere_flag) - error->all(FLERR,"Compute erotate/sphere/atom requires atom style sphere"); + if (!atom->omega_flag) + error->all(FLERR, "Compute erotate/sphere/atom requires atom attribute omega"); + if (!atom->radius_flag) + error->all(FLERR, "Compute erotate/sphere/atom requires atom attribute radius"); nmax = 0; } @@ -74,7 +73,7 @@ void ComputeErotateSphereAtom::compute_peratom() if (atom->nmax > nmax) { memory->destroy(erot); nmax = atom->nmax; - memory->create(erot,nmax,"erotate/sphere/atom:erot"); + memory->create(erot, nmax, "erotate/sphere/atom:erot"); vector_atom = erot; } @@ -89,10 +88,12 @@ void ComputeErotateSphereAtom::compute_peratom() for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - erot[i] = (omega[i][0]*omega[i][0] + omega[i][1]*omega[i][1] + - omega[i][2]*omega[i][2]) * radius[i]*radius[i]*rmass[i]; + erot[i] = + (omega[i][0] * omega[i][0] + omega[i][1] * omega[i][1] + omega[i][2] * omega[i][2]) * + radius[i] * radius[i] * rmass[i]; erot[i] *= pfactor; - } else erot[i] = 0.0; + } else + erot[i] = 0.0; } } @@ -102,6 +103,6 @@ void ComputeErotateSphereAtom::compute_peratom() double ComputeErotateSphereAtom::memory_usage() { - double bytes = (double)nmax * sizeof(double); + double bytes = (double) nmax * sizeof(double); return bytes; } diff --git a/src/compute_group_group.cpp b/src/compute_group_group.cpp index 31bbc81597..afc825ac3c 100644 --- a/src/compute_group_group.cpp +++ b/src/compute_group_group.cpp @@ -37,7 +37,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.00001 +static constexpr double SMALL = 0.00001; enum { OFF, INTER, INTRA }; diff --git a/src/compute_heat_flux.cpp b/src/compute_heat_flux.cpp index 55fa27cafe..64cc8e69f3 100644 --- a/src/compute_heat_flux.cpp +++ b/src/compute_heat_flux.cpp @@ -19,21 +19,20 @@ #include "compute_heat_flux.h" -#include #include "atom.h" -#include "update.h" -#include "modify.h" -#include "force.h" #include "error.h" +#include "force.h" +#include "modify.h" +#include "update.h" using namespace LAMMPS_NS; - /* ---------------------------------------------------------------------- */ ComputeHeatFlux::ComputeHeatFlux(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg), - id_ke(nullptr), id_pe(nullptr), id_stress(nullptr) + id_ke(nullptr), id_pe(nullptr), id_stress(nullptr), + c_ke(nullptr), c_pe(nullptr), c_stress(nullptr) { if (narg != 6) error->all(FLERR,"Illegal compute heat/flux command"); @@ -45,22 +44,24 @@ ComputeHeatFlux::ComputeHeatFlux(LAMMPS *lmp, int narg, char **arg) : // ensure they are valid for these computations id_ke = utils::strdup(arg[3]); - id_pe = utils::strdup(arg[4]); - id_stress = utils::strdup(arg[5]); + auto ike = modify->get_compute_by_id(id_ke); + if (!ike) error->all(FLERR,"Could not find compute heat/flux compute ID {}", id_ke); + if (!utils::strmatch(ike->style,"^ke/atom")) + error->all(FLERR,"Compute heat/flux compute ID {} does not compute ke/atom", id_ke); - int ike = modify->find_compute(id_ke); - int ipe = modify->find_compute(id_pe); - int istress = modify->find_compute(id_stress); - if (ike < 0 || ipe < 0 || istress < 0) - error->all(FLERR,"Could not find compute heat/flux compute ID"); - if (strcmp(modify->compute[ike]->style,"ke/atom") != 0) - error->all(FLERR,"Compute heat/flux compute ID does not compute ke/atom"); - if (modify->compute[ipe]->peatomflag == 0) - error->all(FLERR,"Compute heat/flux compute ID does not compute pe/atom"); - if (modify->compute[istress]->pressatomflag != 1 - && modify->compute[istress]->pressatomflag != 2) + id_pe = utils::strdup(arg[4]); + auto ipe = modify->get_compute_by_id(id_pe); + if (!ipe) error->all(FLERR,"Could not find compute heat/flux compute ID {}", id_pe); + if (ipe->peatomflag == 0) + error->all(FLERR,"Compute heat/flux compute ID {} does not compute pe/atom", id_pe); + + id_stress = utils::strdup(arg[5]); + auto istress = modify->get_compute_by_id(id_stress); + if (!istress) error->all(FLERR,"Could not find compute heat/flux compute ID {}", id_stress); + if ((istress->pressatomflag != 1) && (istress->pressatomflag != 2)) error->all(FLERR, - "Compute heat/flux compute ID does not compute stress/atom or centroid/stress/atom"); + "Compute heat/flux compute ID {} does not compute stress/atom or " + "centroid/stress/atom", id_stress); vector = new double[size_vector]; } @@ -69,10 +70,10 @@ ComputeHeatFlux::ComputeHeatFlux(LAMMPS *lmp, int narg, char **arg) : ComputeHeatFlux::~ComputeHeatFlux() { - delete [] id_ke; - delete [] id_pe; - delete [] id_stress; - delete [] vector; + delete[] id_ke; + delete[] id_pe; + delete[] id_stress; + delete[] vector; } /* ---------------------------------------------------------------------- */ @@ -81,15 +82,12 @@ void ComputeHeatFlux::init() { // error checks - int ike = modify->find_compute(id_ke); - int ipe = modify->find_compute(id_pe); - int istress = modify->find_compute(id_stress); - if (ike < 0 || ipe < 0 || istress < 0) - error->all(FLERR,"Could not find compute heat/flux compute ID"); - - c_ke = modify->compute[ike]; - c_pe = modify->compute[ipe]; - c_stress = modify->compute[istress]; + c_ke = modify->get_compute_by_id(id_ke); + if (!c_ke) error->all(FLERR,"Could not find compute heat/flux compute ID {}", id_ke); + c_pe = modify->get_compute_by_id(id_pe); + if (!c_pe) error->all(FLERR,"Could not find compute heat/flux compute ID {}", id_pe); + c_stress = modify->get_compute_by_id(id_stress); + if (!c_stress) error->all(FLERR,"Could not find compute heat/flux compute ID {}", id_stress); } /* ---------------------------------------------------------------------- */ diff --git a/src/compute_improper_local.cpp b/src/compute_improper_local.cpp index 48070a4f7c..a58f4f4d0d 100644 --- a/src/compute_improper_local.cpp +++ b/src/compute_improper_local.cpp @@ -28,9 +28,9 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define DELTA 10000 +static constexpr int DELTA = 10000; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/compute_ke_atom.cpp b/src/compute_ke_atom.cpp index 9a329232b3..e8ab1b8b25 100644 --- a/src/compute_ke_atom.cpp +++ b/src/compute_ke_atom.cpp @@ -12,6 +12,7 @@ ------------------------------------------------------------------------- */ #include "compute_ke_atom.h" + #include "atom.h" #include "comm.h" #include "error.h" @@ -19,7 +20,6 @@ #include "memory.h" #include "modify.h" #include "update.h" -#include using namespace LAMMPS_NS; diff --git a/src/compute_omega_chunk.cpp b/src/compute_omega_chunk.cpp index 3c345ab7a4..1a8852b144 100644 --- a/src/compute_omega_chunk.cpp +++ b/src/compute_omega_chunk.cpp @@ -23,7 +23,7 @@ using namespace LAMMPS_NS; -#define EPSILON 1.0e-6 +static constexpr double EPSILON = 1.0e-6; /* ---------------------------------------------------------------------- */ diff --git a/src/compute_pair_local.cpp b/src/compute_pair_local.cpp index 5dad405bc3..88991f7481 100644 --- a/src/compute_pair_local.cpp +++ b/src/compute_pair_local.cpp @@ -28,7 +28,7 @@ using namespace LAMMPS_NS; -#define DELTA 10000 +static constexpr int DELTA = 10000; enum { DIST, ENG, FORCE, FX, FY, FZ, PN, DX, DY, DZ }; enum { TYPE, RADIUS }; diff --git a/src/compute_property_atom.cpp b/src/compute_property_atom.cpp index c3c101b995..b95b7267dc 100644 --- a/src/compute_property_atom.cpp +++ b/src/compute_property_atom.cpp @@ -205,6 +205,14 @@ ComputePropertyAtom::ComputePropertyAtom(LAMMPS *lmp, int narg, char **arg) : if (!atom->omega_flag) error->all(FLERR,"Compute property/atom {} is not available", arg[iarg]); pack_choice[i] = &ComputePropertyAtom::pack_omegaz; + } else if (strcmp(arg[iarg],"temperature") == 0) { + if (!atom->temperature_flag) + error->all(FLERR,"Compute property/atom {} is not available", arg[iarg]); + pack_choice[i] = &ComputePropertyAtom::pack_temperature; + } else if (strcmp(arg[iarg],"heatflow") == 0) { + if (!atom->heatflow_flag) + error->all(FLERR,"Compute property/atom {} is not available", arg[iarg]); + pack_choice[i] = &ComputePropertyAtom::pack_heatflow; } else if (strcmp(arg[iarg],"angmomx") == 0) { if (!atom->angmom_flag) error->all(FLERR,"Compute property/atom {} is not available", arg[iarg]); @@ -1213,6 +1221,36 @@ void ComputePropertyAtom::pack_omegaz(int n) /* ---------------------------------------------------------------------- */ +void ComputePropertyAtom::pack_temperature(int n) +{ + double *temperature = atom->temperature; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = temperature[i]; + else buf[n] = 0.0; + n += nvalues; + } +} + +/* ---------------------------------------------------------------------- */ + +void ComputePropertyAtom::pack_heatflow(int n) +{ + double *heatflow = atom->heatflow; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) buf[n] = heatflow[i]; + else buf[n] = 0.0; + n += nvalues; + } +} + +/* ---------------------------------------------------------------------- */ + void ComputePropertyAtom::pack_angmomx(int n) { double **angmom = atom->angmom; diff --git a/src/compute_property_atom.h b/src/compute_property_atom.h index 034b2901c2..d4f4db564f 100644 --- a/src/compute_property_atom.h +++ b/src/compute_property_atom.h @@ -95,6 +95,8 @@ class ComputePropertyAtom : public Compute { void pack_omegax(int); void pack_omegay(int); void pack_omegaz(int); + void pack_temperature(int); + void pack_heatflow(int); void pack_angmomx(int); void pack_angmomy(int); void pack_angmomz(int); diff --git a/src/compute_property_grid.cpp b/src/compute_property_grid.cpp index 17f9689bf6..7624a3b4a9 100644 --- a/src/compute_property_grid.cpp +++ b/src/compute_property_grid.cpp @@ -28,8 +28,6 @@ using namespace LAMMPS_NS; enum { LOW, CTR }; enum { UNSCALED, SCALED }; -#define DELTA 10000 - /* ---------------------------------------------------------------------- */ ComputePropertyGrid::ComputePropertyGrid(LAMMPS *lmp, int narg, char **arg) : diff --git a/src/compute_property_local.cpp b/src/compute_property_local.cpp index 87517a3e05..64f3859117 100644 --- a/src/compute_property_local.cpp +++ b/src/compute_property_local.cpp @@ -31,7 +31,7 @@ using namespace LAMMPS_NS; enum { NONE, NEIGH, PAIR, BOND, ANGLE, DIHEDRAL, IMPROPER }; enum { TYPE, RADIUS }; -#define DELTA 10000 +static constexpr int DELTA = 10000; /* ---------------------------------------------------------------------- */ diff --git a/src/compute_rdf.cpp b/src/compute_rdf.cpp index 17fe450fe5..89f3c91017 100644 --- a/src/compute_rdf.cpp +++ b/src/compute_rdf.cpp @@ -46,7 +46,7 @@ ComputeRDF::ComputeRDF(LAMMPS *lmp, int narg, char **arg) : hist(nullptr), histall(nullptr), typecount(nullptr), icount(nullptr), jcount(nullptr), duplicates(nullptr) { - if (narg < 4) error->all(FLERR,"Illegal compute rdf command"); + if (narg < 4) utils::missing_cmd_args(FLERR,"compute rdf", error); array_flag = 1; extarray = 0; @@ -67,12 +67,14 @@ ComputeRDF::ComputeRDF(LAMMPS *lmp, int narg, char **arg) : while (iarg < narg) { if (strcmp(arg[iarg],"cutoff") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal compute rdf command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR,"compute rdf cutoff", error); + if ((neighbor->style == Neighbor::MULTI) || (neighbor->style == Neighbor::MULTI_OLD)) + error->all(FLERR, "Compute rdf with custom cutoff requires neighbor style 'bin' or 'nsq'"); cutoff_user = utils::numeric(FLERR,arg[iarg+1],false,lmp); if (cutoff_user <= 0.0) cutflag = 0; else cutflag = 1; iarg += 2; - } else error->all(FLERR,"Illegal compute rdf command"); + } else error->all(FLERR,"Unknown compute rdf keyword {}", arg[iarg]); } // pairwise args @@ -94,7 +96,7 @@ ComputeRDF::ComputeRDF(LAMMPS *lmp, int narg, char **arg) : jlo = new int[npairs]; jhi = new int[npairs]; - if (nargpair == 0) { + if (!nargpair) { ilo[0] = 1; ihi[0] = ntypes; jlo[0] = 1; jhi[0] = ntypes; } else { @@ -139,17 +141,17 @@ ComputeRDF::~ComputeRDF() { memory->destroy(rdfpair); memory->destroy(nrdfpair); - delete [] ilo; - delete [] ihi; - delete [] jlo; - delete [] jhi; + delete[] ilo; + delete[] ihi; + delete[] jlo; + delete[] jhi; memory->destroy(hist); memory->destroy(histall); memory->destroy(array); - delete [] typecount; - delete [] icount; - delete [] jcount; - delete [] duplicates; + delete[] typecount; + delete[] icount; + delete[] jcount; + delete[] duplicates; } /* ---------------------------------------------------------------------- */ @@ -158,8 +160,7 @@ void ComputeRDF::init() { if (!force->pair && !cutflag) - error->all(FLERR,"Compute rdf requires a pair style be defined " - "or cutoff specified"); + error->all(FLERR,"Compute rdf requires a pair style or an explicit cutoff"); if (cutflag) { double skin = neighbor->skin; @@ -205,7 +206,11 @@ void ComputeRDF::init() // than cutoff_user apart, just like a normal neighbor list does auto req = neighbor->add_request(this, NeighConst::REQ_OCCASIONAL); - if (cutflag) req->set_cutoff(mycutneigh); + if (cutflag) { + if ((neighbor->style == Neighbor::MULTI) || (neighbor->style == Neighbor::MULTI_OLD)) + error->all(FLERR, "Compute rdf with custom cutoff requires neighbor style 'bin' or 'nsq'"); + req->set_cutoff(mycutneigh); + } } /* ---------------------------------------------------------------------- */ @@ -254,7 +259,7 @@ void ComputeRDF::init_norm() for (i = 0; i < npairs; i++) jcount[i] = scratch[i]; MPI_Allreduce(duplicates,scratch,npairs,MPI_INT,MPI_SUM,world); for (i = 0; i < npairs; i++) duplicates[i] = scratch[i]; - delete [] scratch; + delete[] scratch; } /* ---------------------------------------------------------------------- */ diff --git a/src/compute_reduce.cpp b/src/compute_reduce.cpp index b296804248..ee94c2d9a7 100644 --- a/src/compute_reduce.cpp +++ b/src/compute_reduce.cpp @@ -31,7 +31,7 @@ using namespace LAMMPS_NS; -#define BIG 1.0e20 +static constexpr double BIG = 1.0e20; //---------------------------------------------------------------- diff --git a/src/compute_reduce_chunk.cpp b/src/compute_reduce_chunk.cpp index 51781eac7b..9ba0e30a8d 100644 --- a/src/compute_reduce_chunk.cpp +++ b/src/compute_reduce_chunk.cpp @@ -31,7 +31,7 @@ using namespace LAMMPS_NS; enum { SUM, MINN, MAXX }; -#define BIG 1.0e20 +static constexpr double BIG = 1.0e20; /* ---------------------------------------------------------------------- */ diff --git a/src/compute_stress_atom.cpp b/src/compute_stress_atom.cpp index 55824b1ce5..3560570163 100644 --- a/src/compute_stress_atom.cpp +++ b/src/compute_stress_atom.cpp @@ -54,11 +54,11 @@ ComputeStressAtom::ComputeStressAtom(LAMMPS *lmp, int narg, char **arg) : id_temp = nullptr; else { id_temp = utils::strdup(arg[3]); - - int icompute = modify->find_compute(id_temp); - if (icompute < 0) error->all(FLERR, "Could not find compute stress/atom temperature ID"); - if (modify->compute[icompute]->tempflag == 0) - error->all(FLERR, "Compute stress/atom temperature ID does not compute temperature"); + auto icompute = modify->get_compute_by_id(id_temp); + if (!icompute) + error->all(FLERR, "Could not find compute stress/atom temperature compute {}", id_temp); + if (icompute->tempflag == 0) + error->all(FLERR, "Compute stress/atom compute {} does not compute temperature", id_temp); } // process optional args @@ -122,9 +122,9 @@ void ComputeStressAtom::init() // fixes could have changed or compute_modify could have changed it if (id_temp) { - int icompute = modify->find_compute(id_temp); - if (icompute < 0) error->all(FLERR, "Could not find compute stress/atom temperature ID"); - temperature = modify->compute[icompute]; + temperature = modify->get_compute_by_id(id_temp); + if (!temperature) + error->all(FLERR, "Could not find compute stress/atom temperature compute {}", id_temp); if (temperature->tempbias) biasflag = BIAS; else @@ -216,8 +216,8 @@ void ComputeStressAtom::compute_peratom() // add in per-atom contributions from relevant fixes // skip if vatom = nullptr // possible during setup phase if fix has not initialized its vatom yet - // e.g. fix ave/spatial defined before fix shake, - // and fix ave/spatial uses a per-atom stress from this compute as input + // e.g. fix ave/chunk defined before fix shake, + // and fix ave/chunk uses a per-atom stress from this compute as input if (fixflag) { for (auto &ifix : modify->get_fix_list()) diff --git a/src/compute_temp_sphere.cpp b/src/compute_temp_sphere.cpp index 0cfc9a93ba..2294177e6f 100644 --- a/src/compute_temp_sphere.cpp +++ b/src/compute_temp_sphere.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -14,28 +13,28 @@ #include "compute_temp_sphere.h" -#include #include "atom.h" -#include "update.h" -#include "force.h" #include "domain.h" -#include "modify.h" -#include "group.h" #include "error.h" +#include "force.h" +#include "group.h" +#include "modify.h" +#include "update.h" + +#include using namespace LAMMPS_NS; -enum{ROTATE,ALL}; +enum { ROTATE, ALL }; -#define INERTIA 0.4 // moment of inertia prefactor for sphere +static constexpr double INERTIA = 0.4; // moment of inertia prefactor for sphere /* ---------------------------------------------------------------------- */ ComputeTempSphere::ComputeTempSphere(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg), - id_bias(nullptr) + Compute(lmp, narg, arg), id_bias(nullptr) { - if (narg < 3) error->all(FLERR,"Illegal compute temp/sphere command"); + if (narg < 3) utils::missing_cmd_args(FLERR, "compute temp/sphere", error); scalar_flag = vector_flag = 1; size_vector = 6; @@ -48,20 +47,22 @@ ComputeTempSphere::ComputeTempSphere(LAMMPS *lmp, int narg, char **arg) : int iarg = 3; while (iarg < narg) { - if (strcmp(arg[iarg],"bias") == 0) { - if (iarg+2 > narg) - error->all(FLERR,"Illegal compute temp/sphere command"); + if (strcmp(arg[iarg], "bias") == 0) { + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "compute temp/sphere bias", error); tempbias = 1; - id_bias = utils::strdup(arg[iarg+1]); + id_bias = utils::strdup(arg[iarg + 1]); iarg += 2; - } else if (strcmp(arg[iarg],"dof") == 0) { - if (iarg+2 > narg) - error->all(FLERR,"Illegal compute temp/sphere command"); - if (strcmp(arg[iarg+1],"rotate") == 0) mode = ROTATE; - else if (strcmp(arg[iarg+1],"all") == 0) mode = ALL; - else error->all(FLERR,"Illegal compute temp/sphere command"); + } else if (strcmp(arg[iarg], "dof") == 0) { + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "compute temp/sphere dof", error); + if (strcmp(arg[iarg + 1], "rotate") == 0) + mode = ROTATE; + else if (strcmp(arg[iarg + 1], "all") == 0) + mode = ALL; + else + error->all(FLERR, "Unknown compute temp/sphere dof keyword {}", arg[iarg + 1]); iarg += 2; - } else error->all(FLERR,"Illegal compute temp/sphere command"); + } else + error->all(FLERR, "Unknown compute temp/sphere keyword {}", arg[iarg]); } // when computing only the rotational temperature, @@ -73,16 +74,18 @@ ComputeTempSphere::ComputeTempSphere(LAMMPS *lmp, int narg, char **arg) : // error checks - if (!atom->sphere_flag) - error->all(FLERR,"Compute temp/sphere requires atom style sphere"); + if (!atom->omega_flag) + error->all(FLERR,"Compute temp/sphere requires atom attribute omega"); + if (!atom->radius_flag) + error->all(FLERR,"Compute temp/sphere requires atom attribute radius"); } /* ---------------------------------------------------------------------- */ ComputeTempSphere::~ComputeTempSphere() { - delete [] id_bias; - delete [] vector; + delete[] id_bias; + delete[] vector; } /* ---------------------------------------------------------------------- */ @@ -90,18 +93,16 @@ ComputeTempSphere::~ComputeTempSphere() void ComputeTempSphere::init() { if (tempbias) { - int i = modify->find_compute(id_bias); - if (i < 0) - error->all(FLERR,"Could not find compute ID for temperature bias"); - tbias = modify->compute[i]; - if (tbias->tempflag == 0) - error->all(FLERR,"Bias compute does not calculate temperature"); - if (tbias->tempbias == 0) - error->all(FLERR,"Bias compute does not calculate a velocity bias"); + tbias = modify->get_compute_by_id(id_bias); + if (!tbias) error->all(FLERR, "Could not find compute {} for temperature bias", id_bias); + if (tbias->tempflag == 0) error->all(FLERR, "Bias compute does not calculate temperature"); + if (tbias->tempbias == 0) error->all(FLERR, "Bias compute does not calculate a velocity bias"); if (tbias->igroup != igroup) - error->all(FLERR,"Bias compute group does not match compute group"); - if (strcmp(tbias->style,"temp/region") == 0) tempbias = 2; - else tempbias = 1; + error->all(FLERR, "Bias compute group does not match compute group"); + if (strcmp(tbias->style, "temp/region") == 0) + tempbias = 2; + else + tempbias = 1; // init and setup bias compute because // this compute's setup()->dof_compute() may be called first @@ -124,7 +125,7 @@ void ComputeTempSphere::setup() void ComputeTempSphere::dof_compute() { - int count,count_all; + int count, count_all; adjust_dof_fix(); natoms_temp = group->count(igroup); @@ -146,8 +147,10 @@ void ComputeTempSphere::dof_compute() if (radius[i] == 0.0) { if (mode == ALL) count += 3; } else { - if (mode == ALL) count += 6; - else count += 3; + if (mode == ALL) + count += 6; + else + count += 3; } } } else { @@ -156,13 +159,15 @@ void ComputeTempSphere::dof_compute() if (radius[i] == 0.0) { if (mode == ALL) count += 2; } else { - if (mode == ALL) count += 3; - else count += 1; + if (mode == ALL) + count += 3; + else + count += 1; } } } - MPI_Allreduce(&count,&count_all,1,MPI_INT,MPI_SUM,world); + MPI_Allreduce(&count, &count_all, 1, MPI_INT, MPI_SUM, world); dof = count_all; // additional adjustments to dof @@ -181,8 +186,10 @@ void ComputeTempSphere::dof_compute() if (radius[i] == 0.0) { if (mode == ALL) count += 3; } else { - if (mode == ALL) count += 6; - else count += 3; + if (mode == ALL) + count += 6; + else + count += 3; } } } @@ -193,20 +200,24 @@ void ComputeTempSphere::dof_compute() if (radius[i] == 0.0) { if (mode == ALL) count += 2; } else { - if (mode == ALL) count += 3; - else count += 1; + if (mode == ALL) + count += 3; + else + count += 1; } } } } - MPI_Allreduce(&count,&count_all,1,MPI_INT,MPI_SUM,world); + MPI_Allreduce(&count, &count_all, 1, MPI_INT, MPI_SUM, world); dof -= count_all; } dof -= extra_dof + fix_dof; - if (dof > 0) tfactor = force->mvv2e / (dof * force->boltz); - else tfactor = 0.0; + if (dof > 0) + tfactor = force->mvv2e / (dof * force->boltz); + else + tfactor = 0.0; } /* ---------------------------------------------------------------------- */ @@ -231,6 +242,8 @@ double ComputeTempSphere::compute_scalar() double t = 0.0; + // clang-format off + if (mode == ALL) { for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { @@ -244,13 +257,14 @@ double ComputeTempSphere::compute_scalar() t += (omega[i][0]*omega[i][0] + omega[i][1]*omega[i][1] + omega[i][2]*omega[i][2]) * INERTIA*rmass[i]*radius[i]*radius[i]; } + // clang-format on if (tempbias) tbias->restore_bias_all(); - MPI_Allreduce(&t,&scalar,1,MPI_DOUBLE,MPI_SUM,world); + MPI_Allreduce(&t, &scalar, 1, MPI_DOUBLE, MPI_SUM, world); if (dynamic || tempbias == 2) dof_compute(); if (dof < 0.0 && natoms_temp > 0.0) - error->all(FLERR,"Temperature compute degrees of freedom < 0"); + error->all(FLERR, "Temperature compute degrees of freedom < 0"); scalar *= tfactor; return scalar; } @@ -275,44 +289,44 @@ void ComputeTempSphere::compute_vector() // point particles will not contribute rotation due to radius = 0 - double massone,inertiaone,t[6]; + double massone, inertiaone, t[6]; for (auto &ti : t) ti = 0.0; if (mode == ALL) { for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { massone = rmass[i]; - t[0] += massone * v[i][0]*v[i][0]; - t[1] += massone * v[i][1]*v[i][1]; - t[2] += massone * v[i][2]*v[i][2]; - t[3] += massone * v[i][0]*v[i][1]; - t[4] += massone * v[i][0]*v[i][2]; - t[5] += massone * v[i][1]*v[i][2]; + t[0] += massone * v[i][0] * v[i][0]; + t[1] += massone * v[i][1] * v[i][1]; + t[2] += massone * v[i][2] * v[i][2]; + t[3] += massone * v[i][0] * v[i][1]; + t[4] += massone * v[i][0] * v[i][2]; + t[5] += massone * v[i][1] * v[i][2]; - inertiaone = INERTIA*rmass[i]*radius[i]*radius[i]; - t[0] += inertiaone * omega[i][0]*omega[i][0]; - t[1] += inertiaone * omega[i][1]*omega[i][1]; - t[2] += inertiaone * omega[i][2]*omega[i][2]; - t[3] += inertiaone * omega[i][0]*omega[i][1]; - t[4] += inertiaone * omega[i][0]*omega[i][2]; - t[5] += inertiaone * omega[i][1]*omega[i][2]; + inertiaone = INERTIA * rmass[i] * radius[i] * radius[i]; + t[0] += inertiaone * omega[i][0] * omega[i][0]; + t[1] += inertiaone * omega[i][1] * omega[i][1]; + t[2] += inertiaone * omega[i][2] * omega[i][2]; + t[3] += inertiaone * omega[i][0] * omega[i][1]; + t[4] += inertiaone * omega[i][0] * omega[i][2]; + t[5] += inertiaone * omega[i][1] * omega[i][2]; } } else { for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { - inertiaone = INERTIA*rmass[i]*radius[i]*radius[i]; - t[0] += inertiaone * omega[i][0]*omega[i][0]; - t[1] += inertiaone * omega[i][1]*omega[i][1]; - t[2] += inertiaone * omega[i][2]*omega[i][2]; - t[3] += inertiaone * omega[i][0]*omega[i][1]; - t[4] += inertiaone * omega[i][0]*omega[i][2]; - t[5] += inertiaone * omega[i][1]*omega[i][2]; + inertiaone = INERTIA * rmass[i] * radius[i] * radius[i]; + t[0] += inertiaone * omega[i][0] * omega[i][0]; + t[1] += inertiaone * omega[i][1] * omega[i][1]; + t[2] += inertiaone * omega[i][2] * omega[i][2]; + t[3] += inertiaone * omega[i][0] * omega[i][1]; + t[4] += inertiaone * omega[i][0] * omega[i][2]; + t[5] += inertiaone * omega[i][1] * omega[i][2]; } } if (tempbias) tbias->restore_bias_all(); - MPI_Allreduce(t,vector,6,MPI_DOUBLE,MPI_SUM,world); + MPI_Allreduce(t, vector, 6, MPI_DOUBLE, MPI_SUM, world); for (int i = 0; i < 6; i++) vector[i] *= force->mvv2e; } @@ -322,7 +336,7 @@ void ComputeTempSphere::compute_vector() void ComputeTempSphere::remove_bias(int i, double *v) { - tbias->remove_bias(i,v); + tbias->remove_bias(i, v); } /* ---------------------------------------------------------------------- @@ -331,7 +345,7 @@ void ComputeTempSphere::remove_bias(int i, double *v) void ComputeTempSphere::remove_bias_thr(int i, double *v, double *b) { - tbias->remove_bias_thr(i,v,b); + tbias->remove_bias_thr(i, v, b); } /* ---------------------------------------------------------------------- @@ -341,7 +355,7 @@ void ComputeTempSphere::remove_bias_thr(int i, double *v, double *b) void ComputeTempSphere::restore_bias(int i, double *v) { - tbias->restore_bias(i,v); + tbias->restore_bias(i, v); } /* ---------------------------------------------------------------------- @@ -351,5 +365,5 @@ void ComputeTempSphere::restore_bias(int i, double *v) void ComputeTempSphere::restore_bias_thr(int i, double *v, double *b) { - tbias->restore_bias_thr(i,v,b); + tbias->restore_bias_thr(i, v, b); } diff --git a/src/create_atoms.cpp b/src/create_atoms.cpp index 75c30bd0b8..578ce999f5 100644 --- a/src/create_atoms.cpp +++ b/src/create_atoms.cpp @@ -179,7 +179,8 @@ void CreateAtoms::command(int narg, char **arg) if (imol == -1) error->all(FLERR, "Molecule template ID {} for create_atoms does not exist", arg[iarg + 1]); if ((atom->molecules[imol]->nset > 1) && (comm->me == 0)) - error->warning(FLERR, "Molecule template for create_atoms has multiple molecules"); + error->warning(FLERR, "Molecule template for create_atoms has multiple molecule sets. " + "Only the first set will be used."); mode = MOLECULE; onemol = atom->molecules[imol]; molseed = utils::inumeric(FLERR, arg[iarg + 2], false, lmp); @@ -300,6 +301,8 @@ void CreateAtoms::command(int narg, char **arg) error->all(FLERR, "Invalid atom type in create_atoms mol command"); if (onemol->tag_require && !atom->tag_enable) error->all(FLERR, "Create_atoms molecule has atom IDs, but system does not"); + if (atom->molecular == Atom::TEMPLATE && onemol != atom->avec->onemols[0]) + error->all(FLERR, "Create_atoms molecule template ID must be same as atom style template ID"); onemol->check_attributes(); @@ -504,7 +507,7 @@ void CreateAtoms::command(int narg, char **arg) // molcreate = # of molecules I created - tagint molcreate = (atom->nlocal - nlocal_previous) / onemol->natoms; + tagint molcreate = (atom->nlocal - nlocal_previous) / onemol->natoms * onemol->nmolecules; // increment total bonds,angles,etc diff --git a/src/dihedral_hybrid.cpp b/src/dihedral_hybrid.cpp index d38ccf5d52..9da4df1f68 100644 --- a/src/dihedral_hybrid.cpp +++ b/src/dihedral_hybrid.cpp @@ -24,7 +24,7 @@ using namespace LAMMPS_NS; -#define EXTRA 1000 +static constexpr int EXTRA = 1000; /* ---------------------------------------------------------------------- */ diff --git a/src/dihedral_write.cpp b/src/dihedral_write.cpp index 3d87591bcc..dd1ca1de6a 100644 --- a/src/dihedral_write.cpp +++ b/src/dihedral_write.cpp @@ -25,7 +25,6 @@ #include "error.h" #include "force.h" #include "input.h" -#include "lammps.h" #include "math_const.h" #include "update.h" @@ -35,7 +34,7 @@ using MathConst::DEG2RAD; using MathConst::RAD2DEG; static constexpr double epsilon = 6.5e-6; -#define MAXLINE 1024 +static constexpr int MAXLINE = 1024; /* ---------------------------------------------------------------------- */ void DihedralWrite::command(int narg, char **arg) @@ -148,7 +147,7 @@ void DihedralWrite::command(int narg, char **arg) writer->input->one("mass * 1.0"); writer->input->one(fmt::format("dihedral_style {}", force->dihedral_style)); FILE *coeffs; - char line[MAXLINE]; + char line[MAXLINE] = {'\0'}; coeffs = fopen(coeffs_file.c_str(), "r"); for (int i = 0; i < atom->ndihedraltypes; ++i) { fgets(line, MAXLINE, coeffs); diff --git a/src/domain.cpp b/src/domain.cpp index 3627af26cf..7513d384e2 100644 --- a/src/domain.cpp +++ b/src/domain.cpp @@ -42,10 +42,9 @@ using namespace LAMMPS_NS; -#define BIG 1.0e20 -#define SMALL 1.0e-4 -#define DELTAREGION 4 -#define BONDSTRETCH 1.1 +static constexpr double BIG = 1.0e20; +static constexpr double SMALL = 1.0e-4; +static constexpr double BONDSTRETCH = 1.1; /* ---------------------------------------------------------------------- one instance per region style in style_region.h diff --git a/src/dump.cpp b/src/dump.cpp index a231b367d5..c735a4a60d 100644 --- a/src/dump.cpp +++ b/src/dump.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -38,16 +37,16 @@ using namespace LAMMPS_NS; Dump *Dump::dumpptr; #endif -#define BIG 1.0e20 -#define EPSILON 1.0e-6 +static constexpr double BIG = 1.0e20; +static constexpr double EPSILON = 1.0e-6; enum { ASCEND, DESCEND }; /* ---------------------------------------------------------------------- */ Dump::Dump(LAMMPS *lmp, int /*narg*/, char **arg) : - Pointers(lmp), multiname(nullptr), refresh(nullptr), skipvar(nullptr), format(nullptr), - format_default(nullptr), format_line_user(nullptr), format_float_user(nullptr), + Pointers(lmp), multiname(nullptr), idrefresh(nullptr), irefresh(nullptr), skipvar(nullptr), + format(nullptr), format_default(nullptr), format_line_user(nullptr), format_float_user(nullptr), format_int_user(nullptr), format_bigint_user(nullptr), format_column_user(nullptr), fp(nullptr), nameslist(nullptr), buf(nullptr), sbuf(nullptr), ids(nullptr), bufsort(nullptr), idsort(nullptr), index(nullptr), proclist(nullptr), xpbc(nullptr), vpbc(nullptr), @@ -119,21 +118,21 @@ Dump::Dump(LAMMPS *lmp, int /*narg*/, char **arg) : fileproc = 0; char *ptr; - if ((ptr = strchr(filename,'%'))) { + if ((ptr = strchr(filename, '%'))) { multiproc = 1; nclusterprocs = 1; filewriter = 1; fileproc = me; - MPI_Comm_split(world,me,0,&clustercomm); + MPI_Comm_split(world, me, 0, &clustercomm); *ptr = '\0'; - multiname = utils::strdup(fmt::format("{}{}{}", filename, me, ptr+1)); + multiname = utils::strdup(fmt::format("{}{}{}", filename, me, ptr + 1)); *ptr = '%'; } - if (strchr(filename,'*')) multifile = 1; + if (strchr(filename, '*')) multifile = 1; - if (utils::strmatch(filename, "\\.bin$") - || utils::strmatch(filename, "\\.lammpsbin$")) binary = 1; + if (utils::strmatch(filename, "\\.bin$") || utils::strmatch(filename, "\\.lammpsbin$")) + binary = 1; if (platform::has_compress_extension(filename)) compressed = 1; } @@ -153,7 +152,7 @@ Dump::~Dump() delete[] format_int_user; delete[] format_bigint_user; - delete[] refresh; + delete[] idrefresh; delete[] skipvar; // format_column_user is deallocated by child classes that use it @@ -179,8 +178,7 @@ Dump::~Dump() // delete storage for caching file names if (maxfiles > 0) { - for (int idx=0; idx < numfiles; ++idx) - delete[] nameslist[idx]; + for (int idx = 0; idx < numfiles; ++idx) delete[] nameslist[idx]; delete[] nameslist; } @@ -196,6 +194,8 @@ Dump::~Dump() } } +// clang-format off + /* ---------------------------------------------------------------------- */ void Dump::init() @@ -216,21 +216,21 @@ void Dump::init() index = proclist = nullptr; irregular = nullptr; if ((has_id == 0) && (me == 0)) - error->warning(FLERR,"Dump {} includes no atom IDs and is not sorted by ID. This may complicate " - "post-processing tasks or visualization", id); + error->warning(FLERR,"Dump {} includes no atom IDs and is not sorted by ID. " + "This may complicate post-processing tasks or visualization", id); } if (sort_flag) { if (multiproc > 1) error->all(FLERR, - "Cannot sort dump when 'nfile' or 'fileper' keywords are set to non-default values"); + "Cannot sort dump when 'nfile' or 'fileper' keywords have non-default values"); if (sortcol == 0 && atom->tag_enable == 0) error->all(FLERR,"Cannot sort dump on atom IDs with no atom IDs defined"); if (sortcol && sortcol > size_one) - error->all(FLERR,"Dump sort column is invalid"); + error->all(FLERR,"Dump sort column index {} is invalid", sortcol); if ((sortcol != 0) && (has_id == 0) && (me == 0)) - error->warning(FLERR,"Dump {} includes no atom IDs and is not sorted by ID. This may complicate " - "post-processing tasks or visualization", id); + error->warning(FLERR,"Dump {} includes no atom IDs and is not sorted by ID. " + "This may complicate post-processing tasks or visualization", id); if (nprocs > 1 && irregular == nullptr) irregular = new Irregular(lmp); @@ -288,11 +288,8 @@ void Dump::init() // search for refresh compute specified by dump_modify refresh if (refreshflag) { - int icompute; - for (icompute = 0; icompute < modify->ncompute; icompute++) - if (strcmp(refresh,modify->compute[icompute]->id) == 0) break; - if (icompute < modify->ncompute) irefresh = icompute; - else error->all(FLERR,"Dump could not find refresh compute ID"); + irefresh = modify->get_compute_by_id(idrefresh); + if (!irefresh) error->all(FLERR,"Dump could not find refresh compute ID {}", idrefresh); } // if skipflag, check skip variable @@ -531,7 +528,7 @@ void Dump::write() // trigger post-dump refresh by specified compute // currently used for incremental dump files - if (refreshflag) modify->compute[irefresh]->refresh(); + if (refreshflag) irefresh->refresh(); if (filewriter && fp != nullptr) write_footer(); diff --git a/src/dump.h b/src/dump.h index bae7dbd8c8..43baf96ccf 100644 --- a/src/dump.h +++ b/src/dump.h @@ -19,6 +19,7 @@ #include namespace LAMMPS_NS { +class Compute; class Dump : protected Pointers { friend class Output; @@ -45,15 +46,9 @@ class Dump : protected Pointers { void init(); virtual void write(); - virtual int pack_forward_comm(int, int *, double *, int, int *) - { - return 0; - } + virtual int pack_forward_comm(int, int *, double *, int, int *) { return 0; } virtual void unpack_forward_comm(int, int, double *) {} - virtual int pack_reverse_comm(int, int, double *) - { - return 0; - } + virtual int pack_reverse_comm(int, int, double *) { return 0; } virtual void unpack_reverse_comm(int, int *, double *) {} void modify_params(int, char **); @@ -94,9 +89,9 @@ class Dump : protected Pointers { bigint delaystep; - int refreshflag; // 1 if dump_modify refresh specified - char *refresh; // compute ID to invoke refresh() on - int irefresh; // index of compute + int refreshflag; // 1 if dump_modify refresh specified + char *idrefresh; // compute ID to invoke refresh() on + Compute *irefresh; // index of compute int skipflag; // 1 if skip condition defined char *skipvar; // name of variable to check for skip condition @@ -158,17 +153,11 @@ class Dump : protected Pointers { virtual void init_style() = 0; virtual void openfile(); - virtual int modify_param(int, char **) - { - return 0; - } + virtual int modify_param(int, char **) { return 0; } virtual void write_header(bigint) = 0; virtual int count(); virtual void pack(tagint *) = 0; - virtual int convert_string(int, double *) - { - return 0; - } + virtual int convert_string(int, double *) { return 0; } virtual void write_data(int, double *) = 0; virtual void write_footer() {} diff --git a/src/dump_atom.cpp b/src/dump_atom.cpp index 2d047dc0a0..fb3f58042c 100644 --- a/src/dump_atom.cpp +++ b/src/dump_atom.cpp @@ -24,8 +24,8 @@ using namespace LAMMPS_NS; -#define ONELINE 256 -#define DELTA 1048576 +static constexpr int ONELINE = 256; +static constexpr int DELTA = 1048576; /* ---------------------------------------------------------------------- */ diff --git a/src/dump_cfg.cpp b/src/dump_cfg.cpp index a64507dc16..e5af83a3c6 100644 --- a/src/dump_cfg.cpp +++ b/src/dump_cfg.cpp @@ -29,9 +29,9 @@ using namespace LAMMPS_NS; -#define UNWRAPEXPAND 10.0 -#define ONEFIELD 32 -#define DELTA 1048576 +static constexpr double UNWRAPEXPAND = 10.0; +static constexpr int ONEFIELD = 32; +static constexpr int DELTA = 1048576; /* ---------------------------------------------------------------------- */ diff --git a/src/dump_custom.cpp b/src/dump_custom.cpp index 1e60295bbe..e9935b774f 100644 --- a/src/dump_custom.cpp +++ b/src/dump_custom.cpp @@ -41,14 +41,14 @@ enum{ID,MOL,PROC,PROCP1,TYPE,ELEMENT,MASS, XSU,YSU,ZSU,XSUTRI,YSUTRI,ZSUTRI, IX,IY,IZ, VX,VY,VZ,FX,FY,FZ, - Q,MUX,MUY,MUZ,MU,RADIUS,DIAMETER,HEATFLOW,TEMPERATURE, + Q,MUX,MUY,MUZ,MU,RADIUS,DIAMETER, OMEGAX,OMEGAY,OMEGAZ,ANGMOMX,ANGMOMY,ANGMOMZ, TQX,TQY,TQZ, COMPUTE,FIX,VARIABLE,IVEC,DVEC,IARRAY,DARRAY}; enum{LT,LE,GT,GE,EQ,NEQ,XOR}; -#define ONEFIELD 32 -#define DELTA 1048576 +static constexpr int ONEFIELD = 32; +static constexpr int DELTA = 1048576; /* ---------------------------------------------------------------------- */ @@ -929,18 +929,6 @@ int DumpCustom::count() for (i = 0; i < nlocal; i++) dchoose[i] = 2.0*radius[i]; ptr = dchoose; nstride = 1; - } else if (thresh_array[ithresh] == HEATFLOW) { - if (!atom->heatflow_flag) - error->all(FLERR, - "Threshold for an atom property that isn't allocated"); - ptr = atom->heatflow; - nstride = 1; - } else if (thresh_array[ithresh] == TEMPERATURE) { - if (!atom->temperature_flag) - error->all(FLERR, - "Threshold for an atom property that isn't allocated"); - ptr = atom->temperature; - nstride = 1; } else if (thresh_array[ithresh] == OMEGAX) { if (!atom->omega_flag) error->all(FLERR, @@ -1395,16 +1383,6 @@ int DumpCustom::parse_fields(int narg, char **arg) error->all(FLERR,"Dumping an atom property that isn't allocated"); pack_choice[iarg] = &DumpCustom::pack_diameter; vtype[iarg] = Dump::DOUBLE; - } else if (strcmp(arg[iarg],"heatflow") == 0) { - if (!atom->heatflow_flag) - error->all(FLERR,"Dumping an atom property that isn't allocated"); - pack_choice[iarg] = &DumpCustom::pack_heatflow; - vtype[iarg] = Dump::DOUBLE; - } else if (strcmp(arg[iarg],"temperature") == 0) { - if (!atom->temperature_flag) - error->all(FLERR,"Dumping an atom property that isn't allocated"); - pack_choice[iarg] = &DumpCustom::pack_temperature; - vtype[iarg] = Dump::DOUBLE; } else if (strcmp(arg[iarg],"omegax") == 0) { if (!atom->omega_flag) error->all(FLERR,"Dumping an atom property that isn't allocated"); @@ -1768,7 +1746,7 @@ int DumpCustom::modify_param(int narg, char **arg) if (refreshflag) error->all(FLERR,"Dump_modify can only have one refresh"); refreshflag = 1; - refresh = argi.copy_name(); + idrefresh = argi.copy_name(); return 2; } @@ -1875,8 +1853,6 @@ int DumpCustom::modify_param(int narg, char **arg) else if (strcmp(arg[1],"radius") == 0) thresh_array[nthresh] = RADIUS; else if (strcmp(arg[1],"diameter") == 0) thresh_array[nthresh] = DIAMETER; - else if (strcmp(arg[1],"heatflow") == 0) thresh_array[nthresh] = HEATFLOW; - else if (strcmp(arg[1],"temperature") == 0) thresh_array[nthresh] = TEMPERATURE; else if (strcmp(arg[1],"omegax") == 0) thresh_array[nthresh] = OMEGAX; else if (strcmp(arg[1],"omegay") == 0) thresh_array[nthresh] = OMEGAY; else if (strcmp(arg[1],"omegaz") == 0) thresh_array[nthresh] = OMEGAZ; @@ -2791,30 +2767,6 @@ void DumpCustom::pack_diameter(int n) /* ---------------------------------------------------------------------- */ -void DumpCustom::pack_heatflow(int n) -{ - double *heatflow = atom->heatflow; - - for (int i = 0; i < nchoose; i++) { - buf[n] = heatflow[clist[i]]; - n += size_one; - } -} - -/* ---------------------------------------------------------------------- */ - -void DumpCustom::pack_temperature(int n) -{ - double *temperature = atom->temperature; - - for (int i = 0; i < nchoose; i++) { - buf[n] = temperature[clist[i]]; - n += size_one; - } -} - -/* ---------------------------------------------------------------------- */ - void DumpCustom::pack_omegax(int n) { double **omega = atom->omega; diff --git a/src/dump_custom.h b/src/dump_custom.h index 2b04944ec3..b600bd60b8 100644 --- a/src/dump_custom.h +++ b/src/dump_custom.h @@ -188,8 +188,6 @@ class DumpCustom : public Dump { void pack_mu(int); void pack_radius(int); void pack_diameter(int); - void pack_heatflow(int); - void pack_temperature(int); void pack_omegax(int); void pack_omegay(int); diff --git a/src/dump_grid.cpp b/src/dump_grid.cpp index 8e3a2977cf..ac42a85b01 100644 --- a/src/dump_grid.cpp +++ b/src/dump_grid.cpp @@ -23,7 +23,6 @@ #include "grid3d.h" #include "memory.h" #include "modify.h" -#include "region.h" #include "update.h" #include @@ -35,8 +34,8 @@ using namespace LAMMPS_NS; enum {COMPUTE,FIX}; -#define ONEFIELD 32 -#define DELTA 1048576 +static constexpr int ONEFIELD = 32; +static constexpr int DELTA = 1048576; /* ---------------------------------------------------------------------- */ diff --git a/src/dump_image.cpp b/src/dump_image.cpp index ba7e36eb0b..ed4fc8dff4 100644 --- a/src/dump_image.cpp +++ b/src/dump_image.cpp @@ -49,7 +49,7 @@ using namespace LAMMPS_NS; using MathConst::DEG2RAD; -#define BIG 1.0e20 +static constexpr double BIG = 1.0e20; enum{NUMERIC,ATOM,TYPE,ELEMENT,ATTRIBUTE}; enum{SPHERE,LINE,TRI}; // also in some Body and Fix child classes diff --git a/src/dump_local.cpp b/src/dump_local.cpp index 9695e152b2..8d546634b6 100644 --- a/src/dump_local.cpp +++ b/src/dump_local.cpp @@ -27,8 +27,8 @@ using namespace LAMMPS_NS; -#define ONEFIELD 32 -#define DELTA 1048576 +static constexpr int ONEFIELD = 32; +static constexpr int DELTA = 1048576; /* ---------------------------------------------------------------------- */ diff --git a/src/dump_xyz.cpp b/src/dump_xyz.cpp index 241ec1c059..f7ab77b2bf 100644 --- a/src/dump_xyz.cpp +++ b/src/dump_xyz.cpp @@ -23,8 +23,8 @@ using namespace LAMMPS_NS; -#define ONELINE 128 -#define DELTA 1048576 +static constexpr int ONELINE = 128; +static constexpr int DELTA = 1048576; /* ---------------------------------------------------------------------- */ diff --git a/src/KSPACE/ewald_const.h b/src/ewald_const.h similarity index 100% rename from src/KSPACE/ewald_const.h rename to src/ewald_const.h diff --git a/src/fix_adapt.cpp b/src/fix_adapt.cpp index 996597ab8b..2a10b9d603 100644 --- a/src/fix_adapt.cpp +++ b/src/fix_adapt.cpp @@ -270,7 +270,7 @@ void FixAdapt::post_constructor() if (diam_flag && atom->radius_flag) { id_fix_diam = utils::strdup(id + std::string("_FIX_STORE_DIAM")); fix_diam = dynamic_cast( - modify->add_fix(fmt::format("{} {} STORE/ATOM 1 0 0 1", id_fix_diam,group->names[igroup]))); + modify->add_fix(fmt::format("{} {} STORE/ATOM 1 0 0 1", id_fix_diam, group->names[igroup]))); if (fix_diam->restart_reset) fix_diam->restart_reset = 0; else { double *vec = fix_diam->vstore; @@ -288,7 +288,7 @@ void FixAdapt::post_constructor() if (chgflag && atom->q_flag) { id_fix_chg = utils::strdup(id + std::string("_FIX_STORE_CHG")); fix_chg = dynamic_cast( - modify->add_fix(fmt::format("{} {} STORE/ATOM 1 0 0 1",id_fix_chg,group->names[igroup]))); + modify->add_fix(fmt::format("{} {} STORE/ATOM 1 0 0 1", id_fix_chg, group->names[igroup]))); if (fix_chg->restart_reset) fix_chg->restart_reset = 0; else { double *vec = fix_chg->vstore; diff --git a/src/fix_ave_chunk.cpp b/src/fix_ave_chunk.cpp index 7c37bbaaff..a0d25cf2c7 100644 --- a/src/fix_ave_chunk.cpp +++ b/src/fix_ave_chunk.cpp @@ -301,8 +301,7 @@ FixAveChunk::FixAveChunk(LAMMPS *lmp, int narg, char **arg) : if (fp && comm->me == 0) { clearerr(fp); if (title1) fprintf(fp,"%s\n",title1); - else fprintf(fp,"# Chunk-averaged data for fix %s and group %s\n", - id, group); + else fprintf(fp,"# Chunk-averaged data for fix %s and group %s\n", id, group); if (title2) fprintf(fp,"%s\n",title2); else fprintf(fp,"# Timestep Number-of-chunks Total-count\n"); if (title3) fprintf(fp,"%s\n",title3); @@ -485,7 +484,7 @@ void FixAveChunk::init() /* ---------------------------------------------------------------------- only does averaging if nvalid = current timestep - do not call setup_chunks(), even though fix ave/spatial called setup_bins() + do not call setup_chunks(), even though fix ave/chunk called setup_bins() b/c could cause nchunk to change if Nfreq epoch crosses 2 runs does mean that if change_box is used between runs to change box size, that nchunk may not track it diff --git a/src/fix_ave_grid.cpp b/src/fix_ave_grid.cpp index 8b391a08b5..a1e545a3cf 100644 --- a/src/fix_ave_grid.cpp +++ b/src/fix_ave_grid.cpp @@ -280,33 +280,32 @@ FixAveGrid::FixAveGrid(LAMMPS *lmp, int narg, char **arg) : if (modeatom) { for (int i = 0; i < nvalues; i++) { if (which[i] == ArgInfo::COMPUTE) { - int icompute = modify->find_compute(ids[i]); - if (icompute < 0) - error->all(FLERR,"Compute ID for fix ave/grid does not exist"); - if (modify->compute[icompute]->peratom_flag == 0) - error->all(FLERR, "Fix ave/atom compute does not calculate per-atom values"); - if (argindex[i] == 0 && - modify->compute[icompute]->size_peratom_cols != 0) - error->all(FLERR,"Fix ave/atom compute does not calculate a per-atom vector"); - if (argindex[i] && modify->compute[icompute]->size_peratom_cols == 0) - error->all(FLERR,"Fix ave/atom compute does not calculate a per-atom array"); - if (argindex[i] && argindex[i] > modify->compute[icompute]->size_peratom_cols) - error->all(FLERR,"Fix ave/atom compute array is accessed out-of-range"); + auto icompute = modify->get_compute_by_id(ids[i]); + if (!icompute) + error->all(FLERR,"Compute {} for fix ave/grid does not exist", ids[i]); + if (icompute->peratom_flag == 0) + error->all(FLERR, "Fix ave/atom compute {} does not calculate per-atom values", ids[i]); + if ((argindex[i] == 0) && (icompute->size_peratom_cols != 0)) + error->all(FLERR,"Fix ave/atom compute {} does not calculate a per-atom vector", ids[i]); + if (argindex[i] && (icompute->size_peratom_cols == 0)) + error->all(FLERR,"Fix ave/atom compute {} does not calculate a per-atom array", ids[i]); + if (argindex[i] && (argindex[i] > icompute->size_peratom_cols)) + error->all(FLERR,"Fix ave/atom compute {} array is accessed out-of-range", ids[i]); } else if (which[i] == ArgInfo::FIX) { - int ifix = modify->find_fix(ids[i]); - if (ifix < 0) - error->all(FLERR,"Fix ID for fix ave/atom does not exist"); - if (modify->fix[ifix]->peratom_flag == 0) - error->all(FLERR,"Fix ave/atom fix does not calculate per-atom values"); - if (argindex[i] == 0 && modify->fix[ifix]->size_peratom_cols != 0) - error->all(FLERR, "Fix ave/atom fix does not calculate a per-atom vector"); - if (argindex[i] && modify->fix[ifix]->size_peratom_cols == 0) - error->all(FLERR, "Fix ave/atom fix does not calculate a per-atom array"); - if (argindex[i] && argindex[i] > modify->fix[ifix]->size_peratom_cols) - error->all(FLERR,"Fix ave/atom fix array is accessed out-of-range"); - if (nevery % modify->fix[ifix]->peratom_freq) - error->all(FLERR, "Fix for fix ave/atom not computed at compatible time"); + auto ifix = modify->get_fix_by_id(ids[i]); + if (!ifix) + error->all(FLERR,"Fix {} for fix ave/atom does not exist", ids[i]); + if (ifix->peratom_flag == 0) + error->all(FLERR,"Fix ave/atom fix {} does not calculate per-atom values", ids[i]); + if ((argindex[i] == 0) && (ifix->size_peratom_cols != 0)) + error->all(FLERR, "Fix ave/atom fix {} does not calculate a per-atom vector", ids[i]); + if (argindex[i] && (ifix->size_peratom_cols == 0)) + error->all(FLERR, "Fix ave/atom fix {} does not calculate a per-atom array", ids[i]); + if (argindex[i] && (argindex[i] > ifix->size_peratom_cols)) + error->all(FLERR,"Fix ave/atom fix {} array is accessed out-of-range", ids[i]); + if (nevery % ifix->peratom_freq) + error->all(FLERR, "Fix {} for fix ave/atom not computed at compatible time", ids[i]); } else if (which[i] == ArgInfo::VARIABLE) { int ivariable = input->variable->find(ids[i]); @@ -431,13 +430,13 @@ void FixAveGrid::init() if (which[m] == ArgInfo::COMPUTE) { int icompute = modify->find_compute(ids[m]); if (icompute < 0) - error->all(FLERR,"Compute ID for fix ave/grid does not exist"); + error->all(FLERR,"Compute {} for fix ave/grid does not exist", ids[m]); value2index[m] = icompute; } else if (which[m] == ArgInfo::FIX) { int ifix = modify->find_fix(ids[m]); if (ifix < 0) - error->all(FLERR,"Fix ID for fix ave/grid does not exist"); + error->all(FLERR,"Fix {} for fix ave/grid does not exist", ids[m]); value2index[m] = ifix; } else if (which[m] == ArgInfo::VARIABLE) { @@ -462,10 +461,10 @@ void FixAveGrid::init() for (int m = 0; m < nvalues; m++) { if (dimension == 2) { if (which[m] == ArgInfo::COMPUTE) { - compute = modify->compute[value2index[m]]; + compute = modify->get_compute_by_index(value2index[m]); grid2d = (Grid2d *) compute->get_grid_by_index(value2grid[m]); } else { - fix = modify->fix[value2index[m]]; + fix = modify->get_fix_by_index(value2index[m]); grid2d = (Grid2d *) fix->get_grid_by_index(value2grid[m]); } grid2d->get_size(nxtmp,nytmp); @@ -474,10 +473,10 @@ void FixAveGrid::init() } else { if (which[m] == ArgInfo::COMPUTE) { - compute = modify->compute[value2index[m]]; + compute = modify->get_compute_by_index(value2index[m]); grid3d = (Grid3d *) compute->get_grid_by_index(value2grid[m]); } else { - fix = modify->fix[value2index[m]]; + fix = modify->get_fix_by_index(value2index[m]); grid3d = (Grid3d *) fix->get_grid_by_index(value2grid[m]); } grid3d->get_size(nxtmp,nytmp,nztmp); @@ -966,7 +965,7 @@ void FixAveGrid::atom2grid() double *ovector,**oarray; if (which[m] == ArgInfo::COMPUTE) { - Compute *compute = modify->compute[n]; + Compute *compute = modify->get_compute_by_index(n); if (!(compute->invoked_flag & Compute::INVOKED_PERATOM)) { compute->compute_peratom(); compute->invoked_flag |= Compute::INVOKED_PERATOM; @@ -975,7 +974,7 @@ void FixAveGrid::atom2grid() else oarray = compute->array_atom; } else if (which[m] == ArgInfo::FIX) { - Fix *fix = modify->fix[n]; + Fix *fix = modify->get_fix_by_index(n); if (j == 0) ovector = fix->vector_atom; else oarray = fix->array_atom; } else if (which[m] == ArgInfo::VARIABLE) { @@ -1075,12 +1074,12 @@ void FixAveGrid::grid2grid() Fix *fix; if (which[m] == ArgInfo::COMPUTE) { - compute = modify->compute[n]; + compute = modify->get_compute_by_index(n); if (!(compute->invoked_flag & Compute::INVOKED_PERGRID)) { compute->compute_pergrid(); compute->invoked_flag |= Compute::INVOKED_PERGRID; } - } else if (which[m] == ArgInfo::FIX) fix = modify->fix[n]; + } else if (which[m] == ArgInfo::FIX) fix = modify->get_fix_by_index(n); if (dimension == 2) { double **ovec2d,***oarray2d; diff --git a/src/fix_ave_histo.cpp b/src/fix_ave_histo.cpp index 4503ad56f4..a92efcdacd 100644 --- a/src/fix_ave_histo.cpp +++ b/src/fix_ave_histo.cpp @@ -35,7 +35,7 @@ enum { SCALAR, VECTOR, WINDOW }; enum { DEFAULT, GLOBAL, PERATOM, LOCAL }; enum { IGNORE, END, EXTRA }; -#define BIG 1.0e20 +static constexpr double BIG = 1.0e20; /* ---------------------------------------------------------------------- */ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) : diff --git a/src/fix_ave_histo_weight.cpp b/src/fix_ave_histo_weight.cpp index 181aa2a79d..7a5458bd3d 100644 --- a/src/fix_ave_histo_weight.cpp +++ b/src/fix_ave_histo_weight.cpp @@ -38,7 +38,7 @@ enum { DEFAULT, GLOBAL, PERATOM, LOCAL }; enum { IGNORE, END, EXTRA }; enum { SINGLE, VALUE }; -#define BIG 1.0e20 +static constexpr double BIG = 1.0e20; /* ---------------------------------------------------------------------- */ diff --git a/src/fix_ave_time.cpp b/src/fix_ave_time.cpp index 833d5f4207..f6ba0ad0e6 100644 --- a/src/fix_ave_time.cpp +++ b/src/fix_ave_time.cpp @@ -1081,17 +1081,17 @@ void FixAveTime::options(int iarg, int narg, char **arg) format = format_user; iarg += 2; } else if (strcmp(arg[iarg],"title1") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/spatial command"); + if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/time command"); delete[] title1; title1 = utils::strdup(arg[iarg+1]); iarg += 2; } else if (strcmp(arg[iarg],"title2") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/spatial command"); + if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/time command"); delete[] title2; title2 = utils::strdup(arg[iarg+1]); iarg += 2; } else if (strcmp(arg[iarg],"title3") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/spatial command"); + if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/time command"); delete[] title3; title3 = utils::strdup(arg[iarg+1]); iarg += 2; diff --git a/src/fix_balance.cpp b/src/fix_balance.cpp index 23a56c0a9d..2a32e96106 100644 --- a/src/fix_balance.cpp +++ b/src/fix_balance.cpp @@ -61,20 +61,36 @@ FixBalance::FixBalance(LAMMPS *lmp, int narg, char **arg) : if (nevery < 0) error->all(FLERR,"Illegal fix balance command"); thresh = utils::numeric(FLERR,arg[4],false,lmp); - if (strcmp(arg[5],"shift") == 0) lbstyle = SHIFT; - else if (strcmp(arg[5],"rcb") == 0) lbstyle = BISECTION; - else error->all(FLERR,"Illegal fix balance command"); + reportonly = 0; + if (strcmp(arg[5],"shift") == 0) { + lbstyle = SHIFT; + } else if (strcmp(arg[5],"rcb") == 0) { + lbstyle = BISECTION; + } else if (strcmp(arg[5],"report") == 0) { + lbstyle = SHIFT; + reportonly = 1; + } else error->all(FLERR,"Unknown fix balance style {}", arg[5]); int iarg = 5; if (lbstyle == SHIFT) { - if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "fix balance shift", error); - bstr = arg[iarg+1]; - if (bstr.size() > Balance::BSTR_SIZE) error->all(FLERR,"Illegal fix balance shift command"); - nitermax = utils::inumeric(FLERR,arg[iarg+2],false,lmp); - if (nitermax <= 0) error->all(FLERR,"Illegal fix balance command"); - stopthresh = utils::numeric(FLERR,arg[iarg+3],false,lmp); - if (stopthresh < 1.0) error->all(FLERR,"Illegal fix balance command"); - iarg += 4; + if (reportonly) { + if (dimension == 2) + bstr = "xy"; + else + bstr = "xyz"; + nitermax = 5; + stopthresh = 1.1; + iarg++; + } else { + if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "fix balance shift", error); + bstr = arg[iarg+1]; + if (bstr.size() > Balance::BSTR_SIZE) error->all(FLERR,"Illegal fix balance shift command"); + nitermax = utils::inumeric(FLERR,arg[iarg+2],false,lmp); + if (nitermax <= 0) error->all(FLERR,"Illegal fix balance command"); + stopthresh = utils::numeric(FLERR,arg[iarg+3],false,lmp); + if (stopthresh < 1.0) error->all(FLERR,"Illegal fix balance command"); + iarg += 4; + } } else if (lbstyle == BISECTION) { iarg++; @@ -175,7 +191,7 @@ void FixBalance::setup(int /*vflag*/) void FixBalance::setup_pre_exchange() { // do not allow rebalancing twice on same timestep - // even if wanted to, can mess up elapsed time in ImbalanceTime + // even if you wanted to, it can mess up elapsed time in ImbalanceTime if (update->ntimestep == lastbalance) return; lastbalance = update->ntimestep; @@ -195,6 +211,7 @@ void FixBalance::setup_pre_exchange() balance->set_weights(); imbnow = balance->imbalance_factor(maxloadperproc); + if (imbnow > thresh) rebalance(); // next timestep to rebalance @@ -263,6 +280,13 @@ void FixBalance::pre_neighbor() void FixBalance::rebalance() { + // return immediately if only reporting of the imbalance is requested + + if (reportonly) { + imbprev = imbfinal = imbnow; + return; + } + imbprev = imbnow; // invoke balancer and reset comm->uniform flag diff --git a/src/fix_balance.h b/src/fix_balance.h index 964357a634..a319710ac6 100644 --- a/src/fix_balance.h +++ b/src/fix_balance.h @@ -45,6 +45,7 @@ class FixBalance : public Fix { std::string bstr; int wtflag; // 1 for weighted balancing int sortflag; // 1 for sorting comm messages + int reportonly; // 1 if skipping rebalancing and only computing imbalance double imbnow; // current imbalance factor double imbprev; // imbalance factor before last rebalancing diff --git a/src/fix_bond_history.cpp b/src/fix_bond_history.cpp index cae9dc744d..2d344e24fc 100644 --- a/src/fix_bond_history.cpp +++ b/src/fix_bond_history.cpp @@ -27,8 +27,8 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define LB_FACTOR 1.5 -#define DELTA 8192 +static constexpr double LB_FACTOR = 1.5; +static constexpr int DELTA = 8192; /* ---------------------------------------------------------------------- */ diff --git a/src/fix_box_relax.cpp b/src/fix_box_relax.cpp index 1f715a1dd4..cf8df7cd02 100644 --- a/src/fix_box_relax.cpp +++ b/src/fix_box_relax.cpp @@ -35,10 +35,8 @@ using namespace LAMMPS_NS; using namespace FixConst; -enum{NONE,XYZ,XY,YZ,XZ}; -enum{ISO,ANISO,TRICLINIC}; - -#define MAX_LIFO_DEPTH 2 // 3 box0 arrays in *.h dimensioned to this +enum { NONE, XYZ, XY, YZ, XZ }; +enum { ISO, ANISO, TRICLINIC }; /* ---------------------------------------------------------------------- */ diff --git a/src/fix_box_relax.h b/src/fix_box_relax.h index 0870ed522d..bf9379ceac 100644 --- a/src/fix_box_relax.h +++ b/src/fix_box_relax.h @@ -52,11 +52,12 @@ class FixBoxRelax : public Fix { double vmax, pv2e, pflagsum; int kspace_flag; - int current_lifo; // LIFO stack pointer - double boxlo0[2][3]; // box bounds at start of line search - double boxhi0[2][3]; - double boxtilt0[2][3]; // xy,xz,yz tilts at start of line search - double ds[6]; // increment in scale matrix + static constexpr int MAX_LIFO_DEPTH = 2; + int current_lifo; // LIFO stack pointer + double boxlo0[MAX_LIFO_DEPTH][3]; // low box bounds at start of line search + double boxhi0[MAX_LIFO_DEPTH][3]; // high box bounds at start of line search + double boxtilt0[MAX_LIFO_DEPTH][3]; // xy,xz,yz tilts at start of line search + double ds[6]; // increment in scale matrix int scaleyz; // 1 if yz scaled with lz int scalexz; // 1 if xz scaled with lz diff --git a/src/fix_deform.cpp b/src/fix_deform.cpp index 02aaae5940..bb27faeaa8 100644 --- a/src/fix_deform.cpp +++ b/src/fix_deform.cpp @@ -34,171 +34,204 @@ #include #include +#include +#include using namespace LAMMPS_NS; using namespace FixConst; using namespace MathConst; -enum{NONE=0,FINAL,DELTA,SCALE,VEL,ERATE,TRATE,VOLUME,WIGGLE,VARIABLE}; -enum{ONE_FROM_ONE,ONE_FROM_TWO,TWO_FROM_ONE}; - /* ---------------------------------------------------------------------- */ FixDeform::FixDeform(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), irregular(nullptr), set(nullptr) { - if (narg < 4) error->all(FLERR,"Illegal fix deform command"); + const std::string thiscmd = fmt::format("fix {}", style); + if (narg < 4) utils::missing_cmd_args(FLERR, thiscmd, error); no_change_box = 1; restart_global = 1; pre_exchange_migrate = 1; - nevery = utils::inumeric(FLERR,arg[3],false,lmp); - if (nevery <= 0) error->all(FLERR,"Illegal fix deform command"); + nevery = utils::inumeric(FLERR, arg[3], false, lmp); + if (nevery <= 0) error->all(FLERR, "Fix {} Nevery must be > 0", style); + + // arguments for child classes + + std::unordered_set child_parameters; + std::unordered_map child_styles; + int nskip; + if (utils::strmatch(style, "^deform/pressure")) { + child_parameters.insert("box"); + child_styles.insert({{"pressure", 4}, {"pressure/mean", 4}, {"volume", 2}}); + } // set defaults set = new Set[6]; - memset(set,0,6*sizeof(Set)); + memset(set, 0, 6 * sizeof(Set)); - // parse arguments + // parse all parameter/style arguments for this parent and also child classes + // for child classes, simply store them in leftover_iarg and skip over them triclinic = domain->triclinic; int index; int iarg = 4; + while (iarg < narg) { - if (strcmp(arg[iarg],"x") == 0 || - strcmp(arg[iarg],"y") == 0 || - strcmp(arg[iarg],"z") == 0) { + if ((strcmp(arg[iarg], "x") == 0) + || (strcmp(arg[iarg], "y") == 0) + || (strcmp(arg[iarg], "z") == 0)) { - if (strcmp(arg[iarg],"x") == 0) index = 0; - else if (strcmp(arg[iarg],"y") == 0) index = 1; - else if (strcmp(arg[iarg],"z") == 0) index = 2; + if (strcmp(arg[iarg], "x") == 0) index = 0; + else if (strcmp(arg[iarg], "y") == 0) index = 1; + else if (strcmp(arg[iarg], "z") == 0) index = 2; - if (iarg+2 > narg) error->all(FLERR,"Illegal fix deform command"); - if (strcmp(arg[iarg+1],"final") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal fix deform command"); + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, thiscmd, error); + if (strcmp(arg[iarg + 1], "final") == 0) { + if (iarg + 4 > narg) utils::missing_cmd_args(FLERR, thiscmd + " final", error); set[index].style = FINAL; - set[index].flo = utils::numeric(FLERR,arg[iarg+2],false,lmp); - set[index].fhi = utils::numeric(FLERR,arg[iarg+3],false,lmp); + set[index].flo = utils::numeric(FLERR, arg[iarg + 2], false, lmp); + set[index].fhi = utils::numeric(FLERR, arg[iarg + 3], false, lmp); iarg += 4; - } else if (strcmp(arg[iarg+1],"delta") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal fix deform command"); + } else if (strcmp(arg[iarg + 1], "delta") == 0) { + if (iarg + 4 > narg) utils::missing_cmd_args(FLERR, thiscmd + " delta", error); set[index].style = DELTA; - set[index].dlo = utils::numeric(FLERR,arg[iarg+2],false,lmp); - set[index].dhi = utils::numeric(FLERR,arg[iarg+3],false,lmp); + set[index].dlo = utils::numeric(FLERR, arg[iarg + 2], false, lmp); + set[index].dhi = utils::numeric(FLERR, arg[iarg + 3], false, lmp); iarg += 4; - } else if (strcmp(arg[iarg+1],"scale") == 0) { - if (iarg+3 > narg) error->all(FLERR,"Illegal fix deform command"); + } else if (strcmp(arg[iarg + 1], "scale") == 0) { + if (iarg + 3 > narg) utils::missing_cmd_args(FLERR, thiscmd + " scale", error); set[index].style = SCALE; - set[index].scale = utils::numeric(FLERR,arg[iarg+2],false,lmp); + set[index].scale = utils::numeric(FLERR, arg[iarg + 2], false, lmp); iarg += 3; - } else if (strcmp(arg[iarg+1],"vel") == 0) { - if (iarg+3 > narg) error->all(FLERR,"Illegal fix deform command"); + } else if (strcmp(arg[iarg + 1], "vel") == 0) { + if (iarg + 3 > narg) utils::missing_cmd_args(FLERR, thiscmd + " vel", error); set[index].style = VEL; - set[index].vel = utils::numeric(FLERR,arg[iarg+2],false,lmp); + set[index].vel = utils::numeric(FLERR, arg[iarg + 2], false, lmp); iarg += 3; - } else if (strcmp(arg[iarg+1],"erate") == 0) { - if (iarg+3 > narg) error->all(FLERR,"Illegal fix deform command"); + } else if (strcmp(arg[iarg + 1], "erate") == 0) { + if (iarg + 3 > narg) utils::missing_cmd_args(FLERR, thiscmd + " erate", error); set[index].style = ERATE; - set[index].rate = utils::numeric(FLERR,arg[iarg+2],false,lmp); + set[index].rate = utils::numeric(FLERR, arg[iarg + 2], false, lmp); iarg += 3; - } else if (strcmp(arg[iarg+1],"trate") == 0) { - if (iarg+3 > narg) error->all(FLERR,"Illegal fix deform command"); + } else if (strcmp(arg[iarg + 1], "trate") == 0) { + if (iarg + 3 > narg) utils::missing_cmd_args(FLERR, thiscmd + " trate", error); set[index].style = TRATE; - set[index].rate = utils::numeric(FLERR,arg[iarg+2],false,lmp); + set[index].rate = utils::numeric(FLERR, arg[iarg + 2], false, lmp); iarg += 3; - } else if (strcmp(arg[iarg+1],"volume") == 0) { + } else if (strcmp(arg[iarg + 1], "volume") == 0) { set[index].style = VOLUME; iarg += 2; - } else if (strcmp(arg[iarg+1],"wiggle") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal fix deform command"); + } else if (strcmp(arg[iarg + 1], "wiggle") == 0) { + if (iarg + 4 > narg) utils::missing_cmd_args(FLERR, thiscmd + " wiggle", error); set[index].style = WIGGLE; - set[index].amplitude = utils::numeric(FLERR,arg[iarg+2],false,lmp); - set[index].tperiod = utils::numeric(FLERR,arg[iarg+3],false,lmp); + set[index].amplitude = utils::numeric(FLERR, arg[iarg + 2], false, lmp); + set[index].tperiod = utils::numeric(FLERR, arg[iarg + 3], false, lmp); if (set[index].tperiod <= 0.0) - error->all(FLERR,"Illegal fix deform command"); + error->all(FLERR, "Illegal fix {} wiggle period, must be positive", style); iarg += 4; - } else if (strcmp(arg[iarg+1],"variable") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal fix deform command"); + } else if (strcmp(arg[iarg + 1], "variable") == 0) { + if (iarg + 4 > narg) utils::missing_cmd_args(FLERR, thiscmd + " variable", error); set[index].style = VARIABLE; - if (strstr(arg[iarg+2],"v_") != arg[iarg+2]) - error->all(FLERR,"Illegal fix deform command"); - if (strstr(arg[iarg+3],"v_") != arg[iarg+3]) - error->all(FLERR,"Illegal fix deform command"); + if (strstr(arg[iarg + 2], "v_") != arg[iarg + 2]) + error->all(FLERR, "Illegal fix {} variable name {}", style, arg[iarg + 2]); + if (strstr(arg[iarg + 3], "v_") != arg[iarg + 3]) + error->all(FLERR, "Illegal fix {} variable name {}", style, arg[iarg + 3]); delete[] set[index].hstr; delete[] set[index].hratestr; - set[index].hstr = utils::strdup(&arg[iarg+2][2]); - set[index].hratestr = utils::strdup(&arg[iarg+3][2]); + set[index].hstr = utils::strdup(&arg[iarg + 2][2]); + set[index].hratestr = utils::strdup(&arg[iarg + 3][2]); iarg += 4; - } else error->all(FLERR,"Illegal fix deform command"); + } else if (child_styles.find(arg[iarg + 1]) != child_styles.end()) { + nskip = child_styles[arg[iarg + 1]]; + if (iarg + nskip > narg) + utils::missing_cmd_args(FLERR, fmt::format("fix {} {}", style, arg[iarg + 1]), error); + for (int i = 0; i < nskip; i++) leftover_iarg.push_back(iarg + i); + iarg += nskip; + } else error->all(FLERR, "Illegal fix {} command argument: {}", style, arg[iarg + 1]); - } else if (strcmp(arg[iarg],"xy") == 0 || - strcmp(arg[iarg],"xz") == 0 || - strcmp(arg[iarg],"yz") == 0) { + } else if ((strcmp(arg[iarg], "xy") == 0) + || (strcmp(arg[iarg], "xz") == 0) + || (strcmp(arg[iarg], "yz") == 0)) { - if (triclinic == 0) - error->all(FLERR,"Fix deform tilt factors require triclinic box"); - if (strcmp(arg[iarg],"xy") == 0) index = 5; - else if (strcmp(arg[iarg],"xz") == 0) index = 4; - else if (strcmp(arg[iarg],"yz") == 0) index = 3; + if (triclinic == 0) error->all(FLERR,"Fix {} tilt factors require triclinic box", style); + if (strcmp(arg[iarg], "xy") == 0) index = 5; + else if (strcmp(arg[iarg], "xz") == 0) index = 4; + else if (strcmp(arg[iarg], "yz") == 0) index = 3; - if (iarg+2 > narg) error->all(FLERR,"Illegal fix deform command"); - if (strcmp(arg[iarg+1],"final") == 0) { - if (iarg+3 > narg) error->all(FLERR,"Illegal fix deform command"); + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, thiscmd, error); + if (strcmp(arg[iarg + 1], "final") == 0) { + if (iarg + 3 > narg) utils::missing_cmd_args(FLERR, thiscmd + " final", error); set[index].style = FINAL; - set[index].ftilt = utils::numeric(FLERR,arg[iarg+2],false,lmp); + set[index].ftilt = utils::numeric(FLERR, arg[iarg + 2], false, lmp); iarg += 3; - } else if (strcmp(arg[iarg+1],"delta") == 0) { - if (iarg+3 > narg) error->all(FLERR,"Illegal fix deform command"); + } else if (strcmp(arg[iarg + 1], "delta") == 0) { + if (iarg + 3 > narg) utils::missing_cmd_args(FLERR, thiscmd + " delta", error); set[index].style = DELTA; - set[index].dtilt = utils::numeric(FLERR,arg[iarg+2],false,lmp); + set[index].dtilt = utils::numeric(FLERR, arg[iarg + 2], false, lmp); iarg += 3; - } else if (strcmp(arg[iarg+1],"vel") == 0) { - if (iarg+3 > narg) error->all(FLERR,"Illegal fix deform command"); + } else if (strcmp(arg[iarg + 1], "vel") == 0) { + if (iarg + 3 > narg) utils::missing_cmd_args(FLERR, thiscmd + " vel", error); set[index].style = VEL; - set[index].vel = utils::numeric(FLERR,arg[iarg+2],false,lmp); + set[index].vel = utils::numeric(FLERR, arg[iarg + 2], false, lmp); iarg += 3; - } else if (strcmp(arg[iarg+1],"erate") == 0) { - if (iarg+3 > narg) error->all(FLERR,"Illegal fix deform command"); + } else if (strcmp(arg[iarg + 1], "erate") == 0) { + if (iarg + 3 > narg) utils::missing_cmd_args(FLERR, thiscmd + " erate", error); set[index].style = ERATE; - set[index].rate = utils::numeric(FLERR,arg[iarg+2],false,lmp); + set[index].rate = utils::numeric(FLERR, arg[iarg + 2], false, lmp); iarg += 3; - } else if (strcmp(arg[iarg+1],"trate") == 0) { - if (iarg+3 > narg) error->all(FLERR,"Illegal fix deform command"); + } else if (strcmp(arg[iarg + 1], "trate") == 0) { + if (iarg + 3 > narg) utils::missing_cmd_args(FLERR, thiscmd + " trate", error); set[index].style = TRATE; - set[index].rate = utils::numeric(FLERR,arg[iarg+2],false,lmp); + set[index].rate = utils::numeric(FLERR, arg[iarg + 2], false, lmp); iarg += 3; - } else if (strcmp(arg[iarg+1],"wiggle") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal fix deform command"); + } else if (strcmp(arg[iarg + 1], "wiggle") == 0) { + if (iarg + 4 > narg) utils::missing_cmd_args(FLERR, thiscmd + " wiggle", error); set[index].style = WIGGLE; - set[index].amplitude = utils::numeric(FLERR,arg[iarg+2],false,lmp); - set[index].tperiod = utils::numeric(FLERR,arg[iarg+3],false,lmp); + set[index].amplitude = utils::numeric(FLERR, arg[iarg + 2], false, lmp); + set[index].tperiod = utils::numeric(FLERR, arg[iarg + 3], false, lmp); if (set[index].tperiod <= 0.0) - error->all(FLERR,"Illegal fix deform command"); + error->all(FLERR, "Illegal fix {} wiggle period, must be positive", style); iarg += 4; - } else if (strcmp(arg[iarg+1],"variable") == 0) { - if (iarg+4 > narg) error->all(FLERR,"Illegal fix deform command"); + } else if (strcmp(arg[iarg + 1], "variable") == 0) { + if (iarg + 4 > narg) utils::missing_cmd_args(FLERR, thiscmd + " variable", error); set[index].style = VARIABLE; - if (strstr(arg[iarg+2],"v_") != arg[iarg+2]) - error->all(FLERR,"Illegal fix deform command"); - if (strstr(arg[iarg+3],"v_") != arg[iarg+3]) - error->all(FLERR,"Illegal fix deform command"); + if (strstr(arg[iarg + 2], "v_") != arg[iarg + 2]) + error->all(FLERR, "Illegal fix {} variable name {}", style, arg[iarg + 2]); + if (strstr(arg[iarg + 3], "v_") != arg[iarg + 3]) + error->all(FLERR, "Illegal fix {} variable name {}", style, arg[iarg + 3]); delete[] set[index].hstr; delete[] set[index].hratestr; - set[index].hstr = utils::strdup(&arg[iarg+2][2]); - set[index].hratestr = utils::strdup(&arg[iarg+3][2]); + set[index].hstr = utils::strdup(&arg[iarg + 2][2]); + set[index].hratestr = utils::strdup(&arg[iarg + 3][2]); iarg += 4; - } else error->all(FLERR,"Illegal fix deform command"); - + } else if (child_styles.find(arg[iarg + 1]) != child_styles.end()) { + nskip = child_styles[arg[iarg + 1]]; + if (iarg + nskip > narg) + utils::missing_cmd_args(FLERR, fmt::format("fix {} {}", style, arg[iarg + 1]), error); + for (int i = 0; i < nskip; i++) leftover_iarg.push_back(iarg + i); + iarg += nskip; + } else error->all(FLERR, "Illegal fix {} command argument: {}", style, arg[iarg + 1]); + } else if (child_parameters.find(arg[iarg]) != child_parameters.end()) { + if (child_styles.find(arg[iarg + 1]) != child_styles.end()) { + nskip = child_styles[arg[iarg + 1]]; + if (iarg + nskip > narg) + utils::missing_cmd_args(FLERR, fmt::format("fix {} {}", style, arg[iarg + 1]), error); + for (int i = 0; i < nskip; i++) leftover_iarg.push_back(iarg + i); + iarg += nskip; + } else error->all(FLERR, "Illegal fix {} command argument: {}", style, arg[iarg + 1]); } else break; } // read options from end of input line + + iarg_options_start = iarg; + options(narg - iarg, &arg[iarg]); + // no x remap effectively moves atoms within box, so set restart_pbc - options(narg-iarg,&arg[iarg]); if (remapflag != Domain::X_REMAP) restart_pbc = 1; // setup dimflags used by other classes to check for volume-change conflicts @@ -217,28 +250,19 @@ irregular(nullptr), set(nullptr) // no tensile deformation on shrink-wrapped dims // b/c shrink wrap will change box-length - if (set[0].style && - (domain->boundary[0][0] >= 2 || domain->boundary[0][1] >= 2)) - error->all(FLERR,"Cannot use fix deform on a shrink-wrapped boundary"); - if (set[1].style && - (domain->boundary[1][0] >= 2 || domain->boundary[1][1] >= 2)) - error->all(FLERR,"Cannot use fix deform on a shrink-wrapped boundary"); - if (set[2].style && - (domain->boundary[2][0] >= 2 || domain->boundary[2][1] >= 2)) - error->all(FLERR,"Cannot use fix deform on a shrink-wrapped boundary"); + for (int i = 0; i < 3; i++) + if (set[i].style && (domain->boundary[i][0] >= 2 || domain->boundary[i][1] >= 2)) + error->all(FLERR, "Cannot use fix {} on a shrink-wrapped boundary", style); // no tilt deformation on shrink-wrapped 2nd dim // b/c shrink wrap will change tilt factor in domain::reset_box() - if (set[3].style && - (domain->boundary[2][0] >= 2 || domain->boundary[2][1] >= 2)) - error->all(FLERR,"Cannot use fix deform tilt on a shrink-wrapped 2nd dim"); - if (set[4].style && - (domain->boundary[2][0] >= 2 || domain->boundary[2][1] >= 2)) - error->all(FLERR,"Cannot use fix deform tilt on a shrink-wrapped 2nd dim"); - if (set[5].style && - (domain->boundary[1][0] >= 2 || domain->boundary[1][1] >= 2)) - error->all(FLERR,"Cannot use fix deform tilt on a shrink-wrapped 2nd dim"); + if (set[3].style && (domain->boundary[2][0] >= 2 || domain->boundary[2][1] >= 2)) + error->all(FLERR, "Cannot use fix {} tilt on a shrink-wrapped 2nd dim", style); + if (set[4].style && (domain->boundary[2][0] >= 2 || domain->boundary[2][1] >= 2)) + error->all(FLERR, "Cannot use fix {} tilt on a shrink-wrapped 2nd dim", style); + if (set[5].style && (domain->boundary[1][0] >= 2 || domain->boundary[1][1] >= 2)) + error->all(FLERR, "Cannot use fix {} tilt on a shrink-wrapped 2nd dim", style); // apply scaling to FINAL,DELTA,VEL,WIGGLE since they have dist/vel units @@ -247,7 +271,7 @@ irregular(nullptr), set(nullptr) if (set[i].style == FINAL || set[i].style == DELTA || set[i].style == VEL || set[i].style == WIGGLE) flag = 1; - double xscale,yscale,zscale; + double xscale, yscale, zscale; if (flag && scaleflag) { xscale = domain->lattice->xlattice; yscale = domain->lattice->ylattice; @@ -284,40 +308,40 @@ irregular(nullptr), set(nullptr) // for VOLUME, setup links to other dims // fixed, dynamic1, dynamic2 + // only check for parent, otherwise child will check - for (int i = 0; i < 3; i++) { - if (set[i].style != VOLUME) continue; - int other1 = (i+1) % 3; - int other2 = (i+2) % 3; + if (strcmp(style, "deform") == 0) { + for (int i = 0; i < 3; i++) { + if (set[i].style != VOLUME) continue; + int other1 = (i + 1) % 3; + int other2 = (i + 2) % 3; - if (set[other1].style == NONE) { - if (set[other2].style == NONE || set[other2].style == VOLUME) - error->all(FLERR,"Fix deform volume setting is invalid"); - set[i].substyle = ONE_FROM_ONE; - set[i].fixed = other1; - set[i].dynamic1 = other2; - } else if (set[other2].style == NONE) { + // Cannot use VOLUME option without at least one deformed dimension if (set[other1].style == NONE || set[other1].style == VOLUME) - error->all(FLERR,"Fix deform volume setting is invalid"); - set[i].substyle = ONE_FROM_ONE; - set[i].fixed = other2; - set[i].dynamic1 = other1; - } else if (set[other1].style == VOLUME) { - if (set[other2].style == NONE || set[other2].style == VOLUME) - error->all(FLERR,"Fix deform volume setting is invalid"); - set[i].substyle = TWO_FROM_ONE; - set[i].fixed = other1; - set[i].dynamic1 = other2; - } else if (set[other2].style == VOLUME) { - if (set[other1].style == NONE || set[other1].style == VOLUME) - error->all(FLERR,"Fix deform volume setting is invalid"); - set[i].substyle = TWO_FROM_ONE; - set[i].fixed = other2; - set[i].dynamic1 = other1; - } else { - set[i].substyle = ONE_FROM_TWO; - set[i].dynamic1 = other1; - set[i].dynamic2 = other2; + if (set[other2].style == NONE || set[other2].style == VOLUME) + error->all(FLERR, "Fix {} volume setting is invalid", style); + + if (set[other1].style == NONE) { + set[i].substyle = ONE_FROM_ONE; + set[i].fixed = other1; + set[i].dynamic1 = other2; + } else if (set[other2].style == NONE) { + set[i].substyle = ONE_FROM_ONE; + set[i].fixed = other2; + set[i].dynamic1 = other1; + } else if (set[other1].style == VOLUME) { + set[i].substyle = TWO_FROM_ONE; + set[i].fixed = other1; + set[i].dynamic1 = other2; + } else if (set[other2].style == VOLUME) { + set[i].substyle = TWO_FROM_ONE; + set[i].fixed = other2; + set[i].dynamic1 = other1; + } else { + set[i].substyle = ONE_FROM_TWO; + set[i].dynamic1 = other1; + set[i].dynamic2 = other2; + } } } @@ -348,8 +372,6 @@ irregular(nullptr), set(nullptr) if (force_reneighbor) irregular = new Irregular(lmp); else irregular = nullptr; - - TWOPI = 2.0*MY_PI; } /* ---------------------------------------------------------------------- */ @@ -394,7 +416,7 @@ void FixDeform::init() // domain, fix nvt/sllod, compute temp/deform only work on single h_rate if (modify->get_fix_by_style("deform").size() > 1) - error->all(FLERR,"More than one fix deform"); + error->all(FLERR, "More than one fix deform"); // Kspace setting @@ -411,14 +433,14 @@ void FixDeform::init() if (set[i].style != VARIABLE) continue; set[i].hvar = input->variable->find(set[i].hstr); if (set[i].hvar < 0) - error->all(FLERR,"Variable name for fix deform does not exist"); + error->all(FLERR, "Variable name {} for fix {} does not exist", set[i].hstr, style); if (!input->variable->equalstyle(set[i].hvar)) - error->all(FLERR,"Variable for fix deform is invalid style"); + error->all(FLERR, "Variable {} for fix {} is invalid style", set[i].hstr, style); set[i].hratevar = input->variable->find(set[i].hratestr); if (set[i].hratevar < 0) - error->all(FLERR,"Variable name for fix deform does not exist"); + error->all(FLERR, "Variable name {} for fix {} does not exist", set[i].hratestr, style); if (!input->variable->equalstyle(set[i].hratevar)) - error->all(FLERR,"Variable for fix deform is invalid style"); + error->all(FLERR, "Variable {} for fix {} is invalid style", set[i].hratestr, style); } // set start/stop values for box size and shape @@ -445,30 +467,26 @@ void FixDeform::init() set[i].lo_stop = set[i].lo_start + set[i].dlo; set[i].hi_stop = set[i].hi_start + set[i].dhi; } else if (set[i].style == SCALE) { - set[i].lo_stop = 0.5*(set[i].lo_start+set[i].hi_start) - - 0.5*set[i].scale*(set[i].hi_start-set[i].lo_start); - set[i].hi_stop = 0.5*(set[i].lo_start+set[i].hi_start) + - 0.5*set[i].scale*(set[i].hi_start-set[i].lo_start); + double shift = 0.5 * set[i].scale * (set[i].hi_start - set[i].lo_start); + set[i].lo_stop = 0.5 * (set[i].lo_start + set[i].hi_start) - shift; + set[i].hi_stop = 0.5 * (set[i].lo_start + set[i].hi_start) + shift; } else if (set[i].style == VEL) { - set[i].lo_stop = set[i].lo_start - 0.5*delt*set[i].vel; - set[i].hi_stop = set[i].hi_start + 0.5*delt*set[i].vel; + set[i].lo_stop = set[i].lo_start - 0.5 * delt * set[i].vel; + set[i].hi_stop = set[i].hi_start + 0.5 * delt * set[i].vel; } else if (set[i].style == ERATE) { - set[i].lo_stop = set[i].lo_start - - 0.5*delt*set[i].rate * (set[i].hi_start-set[i].lo_start); - set[i].hi_stop = set[i].hi_start + - 0.5*delt*set[i].rate * (set[i].hi_start-set[i].lo_start); + double shift = 0.5 * delt * set[i].rate * (set[i].hi_start - set[i].lo_start); + set[i].lo_stop = set[i].lo_start - shift; + set[i].hi_stop = set[i].hi_start + shift; if (set[i].hi_stop <= set[i].lo_stop) - error->all(FLERR,"Final box dimension due to fix deform is < 0.0"); + error->all(FLERR, "Final box dimension due to fix {} is < 0.0", style); } else if (set[i].style == TRATE) { - set[i].lo_stop = 0.5*(set[i].lo_start+set[i].hi_start) - - 0.5*((set[i].hi_start-set[i].lo_start) * exp(set[i].rate*delt)); - set[i].hi_stop = 0.5*(set[i].lo_start+set[i].hi_start) + - 0.5*((set[i].hi_start-set[i].lo_start) * exp(set[i].rate*delt)); + double shift = 0.5 * ((set[i].hi_start - set[i].lo_start) * exp(set[i].rate * delt)); + set[i].lo_stop = 0.5 * (set[i].lo_start + set[i].hi_start) - shift; + set[i].hi_stop = 0.5 * (set[i].lo_start + set[i].hi_start) + shift; } else if (set[i].style == WIGGLE) { - set[i].lo_stop = set[i].lo_start - - 0.5*set[i].amplitude * sin(TWOPI*delt/set[i].tperiod); - set[i].hi_stop = set[i].hi_start + - 0.5*set[i].amplitude * sin(TWOPI*delt/set[i].tperiod); + double shift = 0.5 * set[i].amplitude * sin(MY_2PI * delt / set[i].tperiod); + set[i].lo_stop = set[i].lo_start - shift; + set[i].hi_stop = set[i].hi_start + shift; } } @@ -484,50 +502,46 @@ void FixDeform::init() } else if (set[i].style == DELTA) { set[i].tilt_stop = set[i].tilt_start + set[i].dtilt; } else if (set[i].style == VEL) { - set[i].tilt_stop = set[i].tilt_start + delt*set[i].vel; + set[i].tilt_stop = set[i].tilt_start + delt * set[i].vel; } else if (set[i].style == ERATE) { if (i == 3) set[i].tilt_stop = set[i].tilt_start + - delt*set[i].rate * (set[2].hi_start-set[2].lo_start); + delt * set[i].rate * (set[2].hi_start - set[2].lo_start); if (i == 4) set[i].tilt_stop = set[i].tilt_start + - delt*set[i].rate * (set[2].hi_start-set[2].lo_start); + delt * set[i].rate * (set[2].hi_start - set[2].lo_start); if (i == 5) set[i].tilt_stop = set[i].tilt_start + - delt*set[i].rate * (set[1].hi_start-set[1].lo_start); + delt * set[i].rate * (set[1].hi_start - set[1].lo_start); } else if (set[i].style == TRATE) { - set[i].tilt_stop = set[i].tilt_start * exp(set[i].rate*delt); + set[i].tilt_stop = set[i].tilt_start * exp(set[i].rate * delt); } else if (set[i].style == WIGGLE) { - set[i].tilt_stop = set[i].tilt_start + - set[i].amplitude * sin(TWOPI*delt/set[i].tperiod); + double shift = set[i].amplitude * sin(MY_2PI * delt / set[i].tperiod); + set[i].tilt_stop = set[i].tilt_start + shift; // compute min/max for WIGGLE = extrema tilt factor will ever reach if (set[i].amplitude >= 0.0) { - if (delt < 0.25*set[i].tperiod) { + if (delt < 0.25 * set[i].tperiod) { set[i].tilt_min = set[i].tilt_start; - set[i].tilt_max = set[i].tilt_start + - set[i].amplitude*sin(TWOPI*delt/set[i].tperiod); - } else if (delt < 0.5*set[i].tperiod) { + set[i].tilt_max = set[i].tilt_start + shift; + } else if (delt < 0.5 * set[i].tperiod) { set[i].tilt_min = set[i].tilt_start; set[i].tilt_max = set[i].tilt_start + set[i].amplitude; - } else if (delt < 0.75*set[i].tperiod) { - set[i].tilt_min = set[i].tilt_start - - set[i].amplitude*sin(TWOPI*delt/set[i].tperiod); + } else if (delt < 0.75 * set[i].tperiod) { + set[i].tilt_min = set[i].tilt_start - shift; set[i].tilt_max = set[i].tilt_start + set[i].amplitude; } else { set[i].tilt_min = set[i].tilt_start - set[i].amplitude; set[i].tilt_max = set[i].tilt_start + set[i].amplitude; } } else { - if (delt < 0.25*set[i].tperiod) { - set[i].tilt_min = set[i].tilt_start - - set[i].amplitude*sin(TWOPI*delt/set[i].tperiod); + if (delt < 0.25 * set[i].tperiod) { + set[i].tilt_min = set[i].tilt_start - shift; set[i].tilt_max = set[i].tilt_start; - } else if (delt < 0.5*set[i].tperiod) { + } else if (delt < 0.5 * set[i].tperiod) { set[i].tilt_min = set[i].tilt_start - set[i].amplitude; set[i].tilt_max = set[i].tilt_start; - } else if (delt < 0.75*set[i].tperiod) { + } else if (delt < 0.75 * set[i].tperiod) { set[i].tilt_min = set[i].tilt_start - set[i].amplitude; - set[i].tilt_max = set[i].tilt_start + - set[i].amplitude*sin(TWOPI*delt/set[i].tperiod); + set[i].tilt_max = set[i].tilt_start + shift; } else { set[i].tilt_min = set[i].tilt_start - set[i].amplitude; set[i].tilt_max = set[i].tilt_start + set[i].amplitude; @@ -540,7 +554,7 @@ void FixDeform::init() for (int i = 3; i < 6; i++) if (set[i].style == TRATE && set[i].tilt_start == 0.0) - error->all(FLERR,"Cannot use fix deform trate on a box with zero tilt"); + error->all(FLERR, "Cannot use fix {} trate on a box with zero tilt", style); // if yz changes and will cause box flip, then xy cannot be changing // yz = [3], xy = [5] @@ -555,20 +569,20 @@ void FixDeform::init() int flag = 0; double lo,hi; if (flipflag && set[3].style == VARIABLE) - error->all(FLERR,"Fix deform cannot use yz variable with xy"); + error->all(FLERR, "Fix {} cannot use yz variable with xy", style); if (set[3].style == WIGGLE) { lo = set[3].tilt_min; hi = set[3].tilt_max; } else lo = hi = set[3].tilt_stop; if (flipflag) { - if (lo/(set[1].hi_start-set[1].lo_start) < -0.5 || - hi/(set[1].hi_start-set[1].lo_start) > 0.5) flag = 1; + if (lo / (set[1].hi_start - set[1].lo_start) < -0.5 || + hi / (set[1].hi_start - set[1].lo_start) > 0.5) flag = 1; if (set[1].style) { - if (lo/(set[1].hi_stop-set[1].lo_stop) < -0.5 || - hi/(set[1].hi_stop-set[1].lo_stop) > 0.5) flag = 1; + if (lo / (set[1].hi_stop - set[1].lo_stop) < -0.5 || + hi / (set[1].hi_stop - set[1].lo_stop) > 0.5) flag = 1; } if (flag) - error->all(FLERR,"Fix deform is changing yz too much with xy"); + error->all(FLERR, "Fix {} is changing yz too much with xy", style); } } @@ -584,7 +598,7 @@ void FixDeform::init() if (set[i].style == FINAL || set[i].style == DELTA || set[i].style == SCALE || set[i].style == VEL || set[i].style == ERATE) { - double dlo_dt,dhi_dt; + double dlo_dt, dhi_dt; if (delt != 0.0) { dlo_dt = (set[i].lo_stop - set[i].lo_start) / delt; dhi_dt = (set[i].hi_stop - set[i].hi_start) / delt; @@ -633,7 +647,7 @@ void FixDeform::pre_exchange() domain->set_global_box(); domain->set_local_box(); - domain->image_flip(flipxy,flipxz,flipyz); + domain->image_flip(flipxy, flipxz, flipyz); double **x = atom->x; imageint *image = atom->image; @@ -651,104 +665,72 @@ void FixDeform::pre_exchange() void FixDeform::end_of_step() { - int i; - - double delta = update->ntimestep - update->beginstep; - if (delta != 0.0) delta /= update->endstep - update->beginstep; - // wrap variable evaluations with clear/add if (varflag) modify->clearstep_compute(); - // set new box size + // set new box size for strain-based dims + + apply_strain(); + + // set new box size for VOLUME dims that are linked to other dims + // NOTE: still need to set h_rate for these dims + + apply_volume(); + + if (varflag) modify->addstep_compute(update->ntimestep + nevery); + + update_domain(); + + // redo KSpace coeffs since box has changed + + if (kspace_flag) force->kspace->setup(); +} + +/* ---------------------------------------------------------------------- + apply strain controls +------------------------------------------------------------------------- */ + +void FixDeform::apply_strain() +{ // for NONE, target is current box size // for TRATE, set target directly based on current time, also set h_rate // for WIGGLE, set target directly based on current time, also set h_rate // for VARIABLE, set target directly via variable eval, also set h_rate // for others except VOLUME, target is linear value between start and stop - for (i = 0; i < 3; i++) { + double delta = update->ntimestep - update->beginstep; + if (delta != 0.0) delta /= update->endstep - update->beginstep; + + for (int i = 0; i < 3; i++) { if (set[i].style == NONE) { set[i].lo_target = domain->boxlo[i]; set[i].hi_target = domain->boxhi[i]; } else if (set[i].style == TRATE) { double delt = (update->ntimestep - update->beginstep) * update->dt; - set[i].lo_target = 0.5*(set[i].lo_start+set[i].hi_start) - - 0.5*((set[i].hi_start-set[i].lo_start) * exp(set[i].rate*delt)); - set[i].hi_target = 0.5*(set[i].lo_start+set[i].hi_start) + - 0.5*((set[i].hi_start-set[i].lo_start) * exp(set[i].rate*delt)); + double shift = 0.5 * ((set[i].hi_start - set[i].lo_start) * exp(set[i].rate * delt)); + set[i].lo_target = 0.5 * (set[i].lo_start + set[i].hi_start) - shift; + set[i].hi_target = 0.5 * (set[i].lo_start + set[i].hi_start) + shift; h_rate[i] = set[i].rate * domain->h[i]; - h_ratelo[i] = -0.5*h_rate[i]; + h_ratelo[i] = -0.5 * h_rate[i]; } else if (set[i].style == WIGGLE) { double delt = (update->ntimestep - update->beginstep) * update->dt; - set[i].lo_target = set[i].lo_start - - 0.5*set[i].amplitude * sin(TWOPI*delt/set[i].tperiod); - set[i].hi_target = set[i].hi_start + - 0.5*set[i].amplitude * sin(TWOPI*delt/set[i].tperiod); - h_rate[i] = TWOPI/set[i].tperiod * set[i].amplitude * - cos(TWOPI*delt/set[i].tperiod); - h_ratelo[i] = -0.5*h_rate[i]; + double shift = 0.5 * set[i].amplitude * sin(MY_2PI * delt / set[i].tperiod); + set[i].lo_target = set[i].lo_start - shift; + set[i].hi_target = set[i].hi_start + shift; + h_rate[i] = MY_2PI / set[i].tperiod * set[i].amplitude * + cos(MY_2PI * delt / set[i].tperiod); + h_ratelo[i] = -0.5 * h_rate[i]; } else if (set[i].style == VARIABLE) { double del = input->variable->compute_equal(set[i].hvar); - set[i].lo_target = set[i].lo_start - 0.5*del; - set[i].hi_target = set[i].hi_start + 0.5*del; + set[i].lo_target = set[i].lo_start - 0.5 * del; + set[i].hi_target = set[i].hi_start + 0.5 * del; h_rate[i] = input->variable->compute_equal(set[i].hratevar); - h_ratelo[i] = -0.5*h_rate[i]; - } else if (set[i].style != VOLUME) { - set[i].lo_target = set[i].lo_start + - delta*(set[i].lo_stop - set[i].lo_start); - set[i].hi_target = set[i].hi_start + - delta*(set[i].hi_stop - set[i].hi_start); - } - } - - // set new box size for VOLUME dims that are linked to other dims - // NOTE: still need to set h_rate for these dims - - for (i = 0; i < 3; i++) { - if (set[i].style != VOLUME) continue; - - if (set[i].substyle == ONE_FROM_ONE) { - set[i].lo_target = 0.5*(set[i].lo_start+set[i].hi_start) - - 0.5*(set[i].vol_start / - (set[set[i].dynamic1].hi_target - - set[set[i].dynamic1].lo_target) / - (set[set[i].fixed].hi_start-set[set[i].fixed].lo_start)); - set[i].hi_target = 0.5*(set[i].lo_start+set[i].hi_start) + - 0.5*(set[i].vol_start / - (set[set[i].dynamic1].hi_target - - set[set[i].dynamic1].lo_target) / - (set[set[i].fixed].hi_start-set[set[i].fixed].lo_start)); - - } else if (set[i].substyle == ONE_FROM_TWO) { - set[i].lo_target = 0.5*(set[i].lo_start+set[i].hi_start) - - 0.5*(set[i].vol_start / - (set[set[i].dynamic1].hi_target - - set[set[i].dynamic1].lo_target) / - (set[set[i].dynamic2].hi_target - - set[set[i].dynamic2].lo_target)); - set[i].hi_target = 0.5*(set[i].lo_start+set[i].hi_start) + - 0.5*(set[i].vol_start / - (set[set[i].dynamic1].hi_target - - set[set[i].dynamic1].lo_target) / - (set[set[i].dynamic2].hi_target - - set[set[i].dynamic2].lo_target)); - - } else if (set[i].substyle == TWO_FROM_ONE) { - set[i].lo_target = 0.5*(set[i].lo_start+set[i].hi_start) - - 0.5*sqrt(set[i].vol_start / - (set[set[i].dynamic1].hi_target - - set[set[i].dynamic1].lo_target) / - (set[set[i].fixed].hi_start - - set[set[i].fixed].lo_start) * - (set[i].hi_start - set[i].lo_start)); - set[i].hi_target = 0.5*(set[i].lo_start+set[i].hi_start) + - 0.5*sqrt(set[i].vol_start / - (set[set[i].dynamic1].hi_target - - set[set[i].dynamic1].lo_target) / - (set[set[i].fixed].hi_start - - set[set[i].fixed].lo_start) * - (set[i].hi_start - set[i].lo_start)); + h_ratelo[i] = -0.5 * h_rate[i]; + } else if (set[i].style == FINAL || set[i].style == DELTA || set[i].style == SCALE || + set[i].style == VEL || set[i].style == ERATE) { + set[i].lo_target = set[i].lo_start + delta * (set[i].lo_stop - set[i].lo_start); + set[i].hi_target = set[i].hi_start + delta * (set[i].hi_stop - set[i].hi_start); } } @@ -760,55 +742,97 @@ void FixDeform::end_of_step() // for other styles, target is linear value between start and stop values if (triclinic) { - double *h = domain->h; - - for (i = 3; i < 6; i++) { + for (int i = 3; i < 6; i++) { if (set[i].style == NONE) { if (i == 5) set[i].tilt_target = domain->xy; else if (i == 4) set[i].tilt_target = domain->xz; else if (i == 3) set[i].tilt_target = domain->yz; } else if (set[i].style == TRATE) { double delt = (update->ntimestep - update->beginstep) * update->dt; - set[i].tilt_target = set[i].tilt_start * exp(set[i].rate*delt); + set[i].tilt_target = set[i].tilt_start * exp(set[i].rate * delt); h_rate[i] = set[i].rate * domain->h[i]; } else if (set[i].style == WIGGLE) { double delt = (update->ntimestep - update->beginstep) * update->dt; set[i].tilt_target = set[i].tilt_start + - set[i].amplitude * sin(TWOPI*delt/set[i].tperiod); - h_rate[i] = TWOPI/set[i].tperiod * set[i].amplitude * - cos(TWOPI*delt/set[i].tperiod); + set[i].amplitude * sin(MY_2PI * delt / set[i].tperiod); + h_rate[i] = MY_2PI / set[i].tperiod * set[i].amplitude * + cos(MY_2PI * delt / set[i].tperiod); } else if (set[i].style == VARIABLE) { double delta_tilt = input->variable->compute_equal(set[i].hvar); set[i].tilt_target = set[i].tilt_start + delta_tilt; h_rate[i] = input->variable->compute_equal(set[i].hratevar); } else { - set[i].tilt_target = set[i].tilt_start + - delta*(set[i].tilt_stop - set[i].tilt_start); + set[i].tilt_target = set[i].tilt_start + delta * (set[i].tilt_stop - set[i].tilt_start); } + } + } +} - // tilt_target can be large positive or large negative value - // add/subtract box lengths until tilt_target is closest to current value +/* ---------------------------------------------------------------------- + apply volume controls +------------------------------------------------------------------------- */ +void FixDeform::apply_volume() +{ + for (int i = 0; i < 3; i++) { + if (set[i].style != VOLUME) continue; + + int dynamic1 = set[i].dynamic1; + int dynamic2 = set[i].dynamic2; + int fixed = set[i].fixed; + double v0 = set[i].vol_start; + double shift = 0.0; + + if (set[i].substyle == ONE_FROM_ONE) { + shift = 0.5 * (v0 / (set[dynamic1].hi_target - set[dynamic1].lo_target) / + (set[fixed].hi_start - set[fixed].lo_start)); + } else if (set[i].substyle == ONE_FROM_TWO) { + shift = 0.5 * (v0 / (set[dynamic1].hi_target - set[dynamic1].lo_target) / + (set[dynamic2].hi_target - set[dynamic2].lo_target)); + } else if (set[i].substyle == TWO_FROM_ONE) { + shift = 0.5 * sqrt(v0 * (set[i].hi_start - set[i].lo_start) / + (set[dynamic1].hi_target - set[dynamic1].lo_target) / + (set[fixed].hi_start - set[fixed].lo_start)); + } + + h_rate[i] = (2.0 * shift / (domain->boxhi[i] - domain->boxlo[i]) - 1.0) / update->dt; + h_ratelo[i] = -0.5 * h_rate[i]; + + set[i].lo_target = 0.5 * (set[i].lo_start + set[i].hi_start) - shift; + set[i].hi_target = 0.5 * (set[i].lo_start + set[i].hi_start) + shift; + } +} + +/* ---------------------------------------------------------------------- + Update box domain +------------------------------------------------------------------------- */ + +void FixDeform::update_domain() +{ + // tilt_target can be large positive or large negative value + // add/subtract box lengths until tilt_target is closest to current value + + if (triclinic) { + double *h = domain->h; + for (int i = 3; i < 6; i++) { int idenom = 0; if (i == 5) idenom = 0; else if (i == 4) idenom = 0; else if (i == 3) idenom = 1; double denom = set[idenom].hi_target - set[idenom].lo_target; - double current = h[i]/h[idenom]; + double current = h[i] / h[idenom]; - while (set[i].tilt_target/denom - current > 0.0) + while (set[i].tilt_target / denom - current > 0.0) set[i].tilt_target -= denom; - while (set[i].tilt_target/denom - current < 0.0) + while (set[i].tilt_target / denom - current < 0.0) set[i].tilt_target += denom; - if (fabs(set[i].tilt_target/denom - 1.0 - current) < - fabs(set[i].tilt_target/denom - current)) + if (fabs(set[i].tilt_target / denom - 1.0 - current) < + fabs(set[i].tilt_target / denom - current)) set[i].tilt_target -= denom; } } - if (varflag) modify->addstep_compute(update->ntimestep + nevery); - // if any tilt ratios exceed 0.5, set flip = 1 and compute new tilt values // do not flip in x or y if non-periodic (can tilt but not flip) // this is b/c the box length would be changed (dramatically) by flip @@ -823,12 +847,12 @@ void FixDeform::end_of_step() double yprd = set[1].hi_target - set[1].lo_target; double xprdinv = 1.0 / xprd; double yprdinv = 1.0 / yprd; - if (set[3].tilt_target*yprdinv < -0.5 || - set[3].tilt_target*yprdinv > 0.5 || - set[4].tilt_target*xprdinv < -0.5 || - set[4].tilt_target*xprdinv > 0.5 || - set[5].tilt_target*xprdinv < -0.5 || - set[5].tilt_target*xprdinv > 0.5) { + if (set[3].tilt_target * yprdinv < -0.5 || + set[3].tilt_target * yprdinv > 0.5 || + set[4].tilt_target * xprdinv < -0.5 || + set[4].tilt_target * xprdinv > 0.5 || + set[5].tilt_target * xprdinv < -0.5 || + set[5].tilt_target * xprdinv > 0.5) { set[3].tilt_flip = set[3].tilt_target; set[4].tilt_flip = set[4].tilt_target; set[5].tilt_flip = set[5].tilt_target; @@ -836,30 +860,30 @@ void FixDeform::end_of_step() flipxy = flipxz = flipyz = 0; if (domain->yperiodic) { - if (set[3].tilt_flip*yprdinv < -0.5) { + if (set[3].tilt_flip * yprdinv < -0.5) { set[3].tilt_flip += yprd; set[4].tilt_flip += set[5].tilt_flip; flipyz = 1; - } else if (set[3].tilt_flip*yprdinv > 0.5) { + } else if (set[3].tilt_flip * yprdinv > 0.5) { set[3].tilt_flip -= yprd; set[4].tilt_flip -= set[5].tilt_flip; flipyz = -1; } } if (domain->xperiodic) { - if (set[4].tilt_flip*xprdinv < -0.5) { + if (set[4].tilt_flip * xprdinv < -0.5) { set[4].tilt_flip += xprd; flipxz = 1; } - if (set[4].tilt_flip*xprdinv > 0.5) { + if (set[4].tilt_flip * xprdinv > 0.5) { set[4].tilt_flip -= xprd; flipxz = -1; } - if (set[5].tilt_flip*xprdinv < -0.5) { + if (set[5].tilt_flip * xprdinv < -0.5) { set[5].tilt_flip += xprd; flipxy = 1; } - if (set[5].tilt_flip*xprdinv > 0.5) { + if (set[5].tilt_flip * xprdinv > 0.5) { set[5].tilt_flip -= xprd; flipxy = -1; } @@ -878,9 +902,9 @@ void FixDeform::end_of_step() int *mask = atom->mask; int nlocal = atom->nlocal; - for (i = 0; i < nlocal; i++) + for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) - domain->x2lamda(x[i],x[i]); + domain->x2lamda(x[i], x[i]); for (auto &ifix : rfix) ifix->deform(0); @@ -889,22 +913,22 @@ void FixDeform::end_of_step() // reset global and local box to new size/shape // only if deform fix is controlling the dimension - if (set[0].style) { + if (dimflag[0]) { domain->boxlo[0] = set[0].lo_target; domain->boxhi[0] = set[0].hi_target; } - if (set[1].style) { + if (dimflag[1]) { domain->boxlo[1] = set[1].lo_target; domain->boxhi[1] = set[1].hi_target; } - if (set[2].style) { + if (dimflag[2]) { domain->boxlo[2] = set[2].lo_target; domain->boxhi[2] = set[2].hi_target; } if (triclinic) { - if (set[3].style) domain->yz = set[3].tilt_target; - if (set[4].style) domain->xz = set[4].tilt_target; - if (set[5].style) domain->xy = set[5].tilt_target; + if (dimflag[3]) domain->yz = set[3].tilt_target; + if (dimflag[4]) domain->xz = set[4].tilt_target; + if (dimflag[5]) domain->xy = set[5].tilt_target; } domain->set_global_box(); @@ -917,17 +941,13 @@ void FixDeform::end_of_step() int *mask = atom->mask; int nlocal = atom->nlocal; - for (i = 0; i < nlocal; i++) + for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) - domain->lamda2x(x[i],x[i]); + domain->lamda2x(x[i], x[i]); for (auto &ifix : rfix) ifix->deform(1); } - - // redo KSpace coeffs since box has changed - - if (kspace_flag) force->kspace->setup(); } /* ---------------------------------------------------------------------- @@ -937,9 +957,9 @@ void FixDeform::end_of_step() void FixDeform::write_restart(FILE *fp) { if (comm->me == 0) { - int size = 6*sizeof(Set); - fwrite(&size,sizeof(int),1,fp); - fwrite(set,sizeof(Set),6,fp); + int size = 6 * sizeof(Set); + fwrite(&size, sizeof(int), 1, fp); + fwrite(set, sizeof(Set), 6, fp); } } @@ -951,7 +971,7 @@ void FixDeform::restart(char *buf) { int samestyle = 1; Set *set_restart = (Set *) buf; - for (int i=0; i<6; ++i) { + for (int i = 0; i < 6; ++i) { // restore data from initial state set[i].lo_initial = set_restart[i].lo_initial; set[i].hi_initial = set_restart[i].hi_initial; @@ -964,39 +984,57 @@ void FixDeform::restart(char *buf) samestyle = 0; } if (!samestyle) - error->all(FLERR,"Fix deform settings not consistent with restart"); + error->all(FLERR, "Fix {} settings not consistent with restart", style); } /* ---------------------------------------------------------------------- */ void FixDeform::options(int narg, char **arg) { - if (narg < 0) error->all(FLERR,"Illegal fix deform command"); + const std::string thiscmd = fmt::format("fix {}", style); + if (narg < 0) utils::missing_cmd_args(FLERR, thiscmd, error); remapflag = Domain::X_REMAP; scaleflag = 1; flipflag = 1; + // arguments for child classes + + std::unordered_map child_options; + if (utils::strmatch(style, "^deform/pressure")) { + child_options.insert({{"couple", 2}, {"max/rate", 2}, {"normalize/pressure", 2}, + {"vol/balance/p", 2}}); + } + + // parse all optional arguments for this parent and also child classes + // for child classes, simply store them in leftover_iarg and skip over them + int iarg = 0; while (iarg < narg) { - if (strcmp(arg[iarg],"remap") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix deform command"); - if (strcmp(arg[iarg+1],"x") == 0) remapflag = Domain::X_REMAP; - else if (strcmp(arg[iarg+1],"v") == 0) remapflag = Domain::V_REMAP; - else if (strcmp(arg[iarg+1],"none") == 0) remapflag = Domain::NO_REMAP; - else error->all(FLERR,"Illegal fix deform command"); + if (strcmp(arg[iarg], "remap") == 0) { + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, thiscmd + " remap", error); + if (strcmp(arg[iarg + 1], "x") == 0) remapflag = Domain::X_REMAP; + else if (strcmp(arg[iarg + 1], "v") == 0) remapflag = Domain::V_REMAP; + else if (strcmp(arg[iarg + 1], "none") == 0) remapflag = Domain::NO_REMAP; + else error->all(FLERR, "Illegal fix {} remap command: {}", style, arg[iarg + 1]); iarg += 2; - } else if (strcmp(arg[iarg],"units") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix deform command"); - if (strcmp(arg[iarg+1],"box") == 0) scaleflag = 0; - else if (strcmp(arg[iarg+1],"lattice") == 0) scaleflag = 1; - else error->all(FLERR,"Illegal fix deform command"); + } else if (strcmp(arg[iarg], "units") == 0) { + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, thiscmd + " units", error); + if (strcmp(arg[iarg + 1], "box") == 0) scaleflag = 0; + else if (strcmp(arg[iarg + 1], "lattice") == 0) scaleflag = 1; + else error->all(FLERR, "Illegal fix {} units command: {}", style, arg[iarg + 1]); iarg += 2; - } else if (strcmp(arg[iarg],"flip") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix deform command"); - flipflag = utils::logical(FLERR,arg[iarg+1],false,lmp); + } else if (strcmp(arg[iarg], "flip") == 0) { + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, thiscmd + " flip", error); + flipflag = utils::logical(FLERR, arg[iarg + 1], false, lmp); iarg += 2; - } else error->all(FLERR,"Illegal fix deform command"); + } else if (child_options.find(arg[iarg]) != child_options.end()) { + auto nskip = child_options[arg[iarg]]; + if (iarg + nskip > narg) + utils::missing_cmd_args(FLERR, fmt::format("fix {} {}", style, arg[iarg]), error); + for (int i = 0; i < nskip; i++) leftover_iarg.push_back(iarg + i); + iarg += nskip; + } else error->all(FLERR, "Unknown fix {} keyword: {}", style, arg[iarg]); } } diff --git a/src/fix_deform.h b/src/fix_deform.h index 20f6ac5901..b133729444 100644 --- a/src/fix_deform.h +++ b/src/fix_deform.h @@ -29,14 +29,17 @@ class FixDeform : public Fix { int remapflag; // whether x,v are remapped across PBC int dimflag[6]; // which dims are deformed + enum { NONE, FINAL, DELTA, SCALE, VEL, ERATE, TRATE, VOLUME, WIGGLE, VARIABLE, PRESSURE, PMEAN }; + enum { ONE_FROM_ONE, ONE_FROM_TWO, TWO_FROM_ONE }; + FixDeform(class LAMMPS *, int, char **); ~FixDeform() override; int setmask() override; void init() override; void pre_exchange() override; void end_of_step() override; - void write_restart(FILE *) override; - void restart(char *buf) override; + void virtual write_restart(FILE *) override; + void virtual restart(char *buf) override; double memory_usage() override; protected: @@ -48,8 +51,6 @@ class FixDeform : public Fix { std::vector rfix; // pointers to rigid fixes class Irregular *irregular; // for migrating atoms after box flips - double TWOPI; - struct Set { int style, substyle; double flo, fhi, ftilt; @@ -67,7 +68,13 @@ class FixDeform : public Fix { }; Set *set; + std::vector leftover_iarg; + int iarg_options_start; + void options(int, char **); + void virtual apply_volume(); + void apply_strain(); + void update_domain(); }; } // namespace LAMMPS_NS diff --git a/src/fix_deposit.cpp b/src/fix_deposit.cpp index 4a9c5aa9da..d8ea665149 100644 --- a/src/fix_deposit.cpp +++ b/src/fix_deposit.cpp @@ -42,7 +42,7 @@ using namespace MathConst; enum{ATOM,MOLECULE}; enum{DIST_UNIFORM,DIST_GAUSSIAN}; -#define EPSILON 1.0e6 +static constexpr double EPSILON = 1.0e6; /* ---------------------------------------------------------------------- */ diff --git a/src/fix_dt_reset.cpp b/src/fix_dt_reset.cpp index ba69d17718..ea364657c6 100644 --- a/src/fix_dt_reset.cpp +++ b/src/fix_dt_reset.cpp @@ -31,7 +31,7 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define BIG 1.0e20 +static constexpr double BIG = 1.0e20; /* ---------------------------------------------------------------------- */ diff --git a/src/fix_enforce2d.cpp b/src/fix_enforce2d.cpp index c13e2147a3..048f8de543 100644 --- a/src/fix_enforce2d.cpp +++ b/src/fix_enforce2d.cpp @@ -17,7 +17,6 @@ #include "atom.h" #include "domain.h" #include "error.h" -#include "modify.h" #include "respa.h" #include "update.h" diff --git a/src/fix_indent.cpp b/src/fix_indent.cpp index 9adb337dd6..87ed5091bd 100644 --- a/src/fix_indent.cpp +++ b/src/fix_indent.cpp @@ -23,6 +23,7 @@ #include "error.h" #include "input.h" #include "lattice.h" +#include "math_extra.h" #include "modify.h" #include "respa.h" #include "update.h" @@ -34,14 +35,15 @@ using namespace LAMMPS_NS; using namespace FixConst; -enum{NONE,SPHERE,CYLINDER,PLANE}; -enum{INSIDE,OUTSIDE}; +enum{NONE, SPHERE, CYLINDER, PLANE, CONE}; +enum{INSIDE, OUTSIDE}; /* ---------------------------------------------------------------------- */ FixIndent::FixIndent(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), - xstr(nullptr), ystr(nullptr), zstr(nullptr), rstr(nullptr), pstr(nullptr) + xstr(nullptr), ystr(nullptr), zstr(nullptr), rstr(nullptr), pstr(nullptr), + rlostr(nullptr), rhistr(nullptr), lostr(nullptr), histr(nullptr) { if (narg < 4) utils::missing_cmd_args(FLERR, "fix indent", error); @@ -56,21 +58,19 @@ FixIndent::FixIndent(LAMMPS *lmp, int narg, char **arg) : ilevel_respa = 0; k = utils::numeric(FLERR,arg[3],false,lmp); + if (k < 0.0) error->all(FLERR, "Illegal fix indent force constant: {}", k); k3 = k/3.0; - // read options from end of input line + // read geometry of indenter and optional args - options(narg-4,&arg[4]); + int iarg = geometry(narg-4,&arg[4]) + 4; + options(narg-iarg,&arg[iarg]); // setup scaling - double xscale,yscale,zscale; - if (scaleflag) { - xscale = domain->lattice->xlattice; - yscale = domain->lattice->ylattice; - zscale = domain->lattice->zlattice; - } - else xscale = yscale = zscale = 1.0; + const double xscale { scaleflag ? domain->lattice->xlattice : 1.0}; + const double yscale { scaleflag ? domain->lattice->ylattice : 1.0}; + const double zscale { scaleflag ? domain->lattice->zlattice : 1.0}; // apply scaling factors to geometry @@ -79,14 +79,39 @@ FixIndent::FixIndent(LAMMPS *lmp, int narg, char **arg) : if (!ystr) yvalue *= yscale; if (!zstr) zvalue *= zscale; if (!rstr) rvalue *= xscale; + + } else if (istyle == CONE) { + if (!xstr) xvalue *= xscale; + if (!ystr) yvalue *= yscale; + if (!zstr) zvalue *= zscale; + + double scaling_factor = 1.0; + switch (cdim) { + case 0: + scaling_factor = xscale; + break; + case 1: + scaling_factor = yscale; + break; + case 2: + scaling_factor = zscale; + break; + } + + if (!rlostr) rlovalue *= scaling_factor; + if (!rhistr) rhivalue *= scaling_factor; + if (!lostr) lovalue *= scaling_factor; + if (!histr) hivalue *= scaling_factor; + } else if (istyle == PLANE) { if (cdim == 0 && !pstr) pvalue *= xscale; else if (cdim == 1 && !pstr) pvalue *= yscale; else if (cdim == 2 && !pstr) pvalue *= zscale; + } else error->all(FLERR,"Unknown fix indent keyword: {}", istyle); varflag = 0; - if (xstr || ystr || zstr || rstr || pstr) varflag = 1; + if (xstr || ystr || zstr || rstr || pstr || rlostr || rhistr || lostr || histr) varflag = 1; indenter_flag = 0; indenter[0] = indenter[1] = indenter[2] = indenter[3] = 0.0; @@ -101,6 +126,10 @@ FixIndent::~FixIndent() delete [] zstr; delete [] rstr; delete [] pstr; + delete [] rlostr; + delete [] rhistr; + delete [] lostr; + delete [] histr; } /* ---------------------------------------------------------------------- */ @@ -153,6 +182,34 @@ void FixIndent::init() if (!input->variable->equalstyle(pvar)) error->all(FLERR,"Variable {} for fix indent is invalid style", pstr); } + if (rlostr) { + rlovar = input->variable->find(rlostr); + if (rlovar < 0) + error->all(FLERR,"Variable {} for fix indent does not exist", rlostr); + if (!input->variable->equalstyle(rlovar)) + error->all(FLERR,"Variable {} for fix indent is invalid style", rlostr); + } + if (rhistr) { + rhivar = input->variable->find(rhistr); + if (rhivar < 0) + error->all(FLERR,"Variable {} for fix indent does not exist", rhistr); + if (!input->variable->equalstyle(rhivar)) + error->all(FLERR,"Variable {} for fix indent is invalid style", rhistr); + } + if (lostr) { + lovar = input->variable->find(lostr); + if (lovar < 0) + error->all(FLERR,"Variable {} for fix indent does not exist", lostr); + if (!input->variable->equalstyle(lovar)) + error->all(FLERR,"Variable {} for fix indent is invalid style", lostr); + } + if (histr) { + hivar = input->variable->find(histr); + if (hivar < 0) + error->all(FLERR,"Variable {} for fix indent does not exist", histr); + if (!input->variable->equalstyle(hivar)) + error->all(FLERR,"Variable {} for fix indent is invalid style", histr); + } if (utils::strmatch(update->integrate_style,"^respa")) { ilevel_respa = (dynamic_cast(update->integrate))->nlevels-1; @@ -192,32 +249,30 @@ void FixIndent::post_force(int /*vflag*/) indenter_flag = 0; indenter[0] = indenter[1] = indenter[2] = indenter[3] = 0.0; + // ctr = current indenter centerz + + double ctr[3] {xvalue, yvalue, zvalue}; + if (xstr) ctr[0] = input->variable->compute_equal(xvar); + if (ystr) ctr[1] = input->variable->compute_equal(yvar); + if (zstr) ctr[2] = input->variable->compute_equal(zvar); + + double **x = atom->x; + double **f = atom->f; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + double delx, dely, delz, r, dr, fmag, fx, fy, fz; + // spherical indenter if (istyle == SPHERE) { - // ctr = current indenter center - // remap into periodic box + // remap indenter center into periodic box - double ctr[3]; - if (xstr) ctr[0] = input->variable->compute_equal(xvar); - else ctr[0] = xvalue; - if (ystr) ctr[1] = input->variable->compute_equal(yvar); - else ctr[1] = yvalue; - if (zstr) ctr[2] = input->variable->compute_equal(zvar); - else ctr[2] = zvalue; domain->remap(ctr); - double radius; - if (rstr) radius = input->variable->compute_equal(rvar); - else radius = rvalue; - - double **x = atom->x; - double **f = atom->f; - int *mask = atom->mask; - int nlocal = atom->nlocal; - - double delx,dely,delz,r,dr,fmag,fx,fy,fz; + double radius { rstr ? input->variable->compute_equal(rvar) : rvalue}; + if (radius < 0.0) error->all(FLERR, "Illegal fix indent sphere radius: {}", radius); for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { @@ -254,56 +309,18 @@ void FixIndent::post_force(int /*vflag*/) // remap into periodic box // 3rd coord is just near box for remap(), since isn't used - double ctr[3]; - if (cdim == 0) { - ctr[0] = domain->boxlo[0]; - if (ystr) ctr[1] = input->variable->compute_equal(yvar); - else ctr[1] = yvalue; - if (zstr) ctr[2] = input->variable->compute_equal(zvar); - else ctr[2] = zvalue; - } else if (cdim == 1) { - if (xstr) ctr[0] = input->variable->compute_equal(xvar); - else ctr[0] = xvalue; - ctr[1] = domain->boxlo[1]; - if (zstr) ctr[2] = input->variable->compute_equal(zvar); - else ctr[2] = zvalue; - } else { - if (xstr) ctr[0] = input->variable->compute_equal(xvar); - else ctr[0] = xvalue; - if (ystr) ctr[1] = input->variable->compute_equal(yvar); - else ctr[1] = yvalue; - ctr[2] = domain->boxlo[2]; - } + ctr[cdim] = domain->boxlo[cdim]; domain->remap(ctr); - double radius; - if (rstr) radius = input->variable->compute_equal(rvar); - else radius = rvalue; - - double **x = atom->x; - double **f = atom->f; - int *mask = atom->mask; - int nlocal = atom->nlocal; - - double delx,dely,delz,r,dr,fmag,fx,fy,fz; + double radius { rstr ? input->variable->compute_equal(rvar) : rvalue}; + if (radius < 0.0) error->all(FLERR, "Illegal fix indent cylinder radius: {}", radius); for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { - if (cdim == 0) { - delx = 0; - dely = x[i][1] - ctr[1]; - delz = x[i][2] - ctr[2]; - } else if (cdim == 1) { - delx = x[i][0] - ctr[0]; - dely = 0; - delz = x[i][2] - ctr[2]; - } else { - delx = x[i][0] - ctr[0]; - dely = x[i][1] - ctr[1]; - delz = 0; - } - domain->minimum_image(delx,dely,delz); - r = sqrt(delx*delx + dely*dely + delz*delz); + double del[3] {x[i][0] - ctr[0], x[i][1] - ctr[1], x[i][2] - ctr[2]}; + del[cdim] = 0; + domain->minimum_image(del[0], del[1], del[2]); + r = sqrt(del[0]*del[0] + del[1]*del[1] + del[2]*del[2]); if (side == OUTSIDE) { dr = r - radius; fmag = k*dr*dr; @@ -312,9 +329,9 @@ void FixIndent::post_force(int /*vflag*/) fmag = -k*dr*dr; } if (dr >= 0.0) continue; - fx = delx*fmag/r; - fy = dely*fmag/r; - fz = delz*fmag/r; + fx = del[0]*fmag/r; + fy = del[1]*fmag/r; + fz = del[2]*fmag/r; f[i][0] += fx; f[i][1] += fy; f[i][2] += fz; @@ -324,31 +341,88 @@ void FixIndent::post_force(int /*vflag*/) indenter[3] -= fz; } + // conical indenter + + } else if (istyle == CONE) { + + double radiuslo { rlostr ? input->variable->compute_equal(rlovar) : rlovalue }; + if (radiuslo < 0.0) error->all(FLERR, "Illegal fix indent cone lower radius: {}", radiuslo); + double radiushi { rhistr ? input->variable->compute_equal(rhivar) : rhivalue }; + if (radiushi < 0.0) error->all(FLERR, "Illegal fix indent cone high radius: {}", radiushi); + + double initial_lo { lostr ? input->variable->compute_equal(lovar) : lovalue }; + double initial_hi { histr ? input->variable->compute_equal(hivar) : hivalue }; + + ctr[cdim] = 0.5 * (initial_hi + initial_lo); + + domain->remap(ctr); + + double hi = ctr[cdim] + 0.5 * (initial_hi - initial_lo); + double lo = ctr[cdim] - 0.5 * (initial_hi - initial_lo); + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + + delx = x[i][0] - ctr[0]; + dely = x[i][1] - ctr[1]; + delz = x[i][2] - ctr[2]; + domain->minimum_image(delx, dely, delz); + + double x0[3] {delx + ctr[0], dely + ctr[1], delz + ctr[2]}; + r = sqrt(delx * delx + dely * dely + delz * delz); + + // check if particle is inside or outside the cone + + bool point_inside_cone = PointInsideCone(cdim, ctr, lo, hi, radiuslo, radiushi, x0); + + if (side == INSIDE && point_inside_cone) continue; + if (side == OUTSIDE && !point_inside_cone) continue; + + // find the distance between the point and the cone + + if (point_inside_cone) { + DistanceInteriorPoint(cdim, ctr, lo, hi, radiuslo, radiushi, x0[0], x0[1], x0[2]); + } else { + DistanceExteriorPoint(cdim, ctr, lo, hi, radiuslo, radiushi, x0[0], x0[1], x0[2]); + } + + // compute the force from the center of the cone + // this is different from how it is done in fix wall/region + + dr = sqrt(x0[0] * x0[0] + x0[1] * x0[1] + x0[2] * x0[2]); + + int force_sign = { point_inside_cone ? 1 : -1 }; + fmag = force_sign * k * dr * dr; + + fx = delx*fmag/r; + fy = dely*fmag/r; + fz = delz*fmag/r; + f[i][0] += fx; + f[i][1] += fy; + f[i][2] += fz; + indenter[0] -= k3 * dr * dr * dr; + indenter[1] -= fx; + indenter[2] -= fy; + indenter[3] -= fz; + } + } + // planar indenter } else { // plane = current plane position - double plane; - if (pstr) plane = input->variable->compute_equal(pvar); - else plane = pvalue; - - double **x = atom->x; - double **f = atom->f; - int *mask = atom->mask; - int nlocal = atom->nlocal; - - double dr,fatom; + double plane { pstr ? input->variable->compute_equal(pvar) : pvalue}; for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { dr = planeside * (plane - x[i][cdim]); if (dr >= 0.0) continue; - fatom = -planeside * k*dr*dr; - f[i][cdim] += fatom; - indenter[0] -= k3 * dr*dr*dr; - indenter[cdim+1] -= fatom; + fmag = -planeside * k * dr * dr; + f[i][cdim] += fmag; + indenter[0] -= k3 * dr * dr * dr; + indenter[cdim+1] -= fmag; } } @@ -400,94 +474,173 @@ double FixIndent::compute_vector(int n) } /* ---------------------------------------------------------------------- - parse optional parameters at end of input line + parse input args for geometry of indenter ------------------------------------------------------------------------- */ -void FixIndent::options(int narg, char **arg) +int FixIndent::geometry(int narg, char **arg) { if (narg < 0) utils::missing_cmd_args(FLERR, "fix indent", error); istyle = NONE; xstr = ystr = zstr = rstr = pstr = nullptr; xvalue = yvalue = zvalue = rvalue = pvalue = 0.0; + + // sphere + + if (strcmp(arg[0],"sphere") == 0) { + if (istyle != NONE) error->all(FLERR, "Fix indent requires a single geometry keyword"); + if (5 > narg) utils::missing_cmd_args(FLERR, "fix indent sphere", error); + + if (utils::strmatch(arg[1],"^v_")) { + xstr = utils::strdup(arg[1]+2); + } else xvalue = utils::numeric(FLERR,arg[1],false,lmp); + if (utils::strmatch(arg[2],"^v_")) { + ystr = utils::strdup(arg[2]+2); + } else yvalue = utils::numeric(FLERR,arg[2],false,lmp); + if (utils::strmatch(arg[3],"^v_")) { + zstr = utils::strdup(arg[3]+2); + } else zvalue = utils::numeric(FLERR,arg[3],false,lmp); + if (utils::strmatch(arg[4],"^v_")) { + rstr = utils::strdup(arg[4]+2); + } else rvalue = utils::numeric(FLERR,arg[4],false,lmp); + + istyle = SPHERE; + return 5; + } + + // cylinder + + if (strcmp(arg[0],"cylinder") == 0) { + if (istyle != NONE) error->all(FLERR, "Fix indent requires a single geometry keyword"); + if (5 > narg) utils::missing_cmd_args(FLERR, "fix indent cylinder", error); + + if (strcmp(arg[1],"x") == 0) { + cdim = 0; + if (utils::strmatch(arg[2],"^v_")) { + ystr = utils::strdup(arg[2]+2); + } else yvalue = utils::numeric(FLERR,arg[2],false,lmp); + if (utils::strmatch(arg[3],"^v_")) { + zstr = utils::strdup(arg[3]+2); + } else zvalue = utils::numeric(FLERR,arg[3],false,lmp); + } else if (strcmp(arg[1],"y") == 0) { + cdim = 1; + if (utils::strmatch(arg[2],"^v_")) { + xstr = utils::strdup(arg[2]+2); + } else xvalue = utils::numeric(FLERR,arg[2],false,lmp); + if (utils::strmatch(arg[3],"^v_")) { + zstr = utils::strdup(arg[3]+2); + } else zvalue = utils::numeric(FLERR,arg[3],false,lmp); + } else if (strcmp(arg[1],"z") == 0) { + cdim = 2; + if (utils::strmatch(arg[2],"^v_")) { + xstr = utils::strdup(arg[2]+2); + } else xvalue = utils::numeric(FLERR,arg[2],false,lmp); + if (utils::strmatch(arg[3],"^v_")) { + ystr = utils::strdup(arg[3]+2); + } else yvalue = utils::numeric(FLERR,arg[3],false,lmp); + } else error->all(FLERR,"Unknown fix indent cylinder argument: {}", arg[1]); + + if (utils::strmatch(arg[4],"^v_")) { + rstr = utils::strdup(arg[4]+2); + } else rvalue = utils::numeric(FLERR,arg[4],false,lmp); + + istyle = CYLINDER; + return 5; + } + + // cone + + if (strcmp(arg[0],"cone") == 0) { + if (istyle != NONE) error->all(FLERR, "Fix indent requires a single geometry keyword"); + if (8 > narg) utils::missing_cmd_args(FLERR, "fix indent cone", error); + + if (strcmp(arg[1],"x") == 0) { + cdim = 0; + if (utils::strmatch(arg[2],"^v_")) { + ystr = utils::strdup(arg[2]+2); + } else yvalue = utils::numeric(FLERR,arg[2],false,lmp); + if (utils::strmatch(arg[3],"^v_")) { + zstr = utils::strdup(arg[3]+2); + } else zvalue = utils::numeric(FLERR,arg[3],false,lmp); + + } else if (strcmp(arg[1],"y") == 0) { + cdim = 1; + if (utils::strmatch(arg[2],"^v_")) { + xstr = utils::strdup(arg[2]+2); + } else xvalue = utils::numeric(FLERR,arg[2],false,lmp); + if (utils::strmatch(arg[3],"^v_")) { + zstr = utils::strdup(arg[3]+2); + } else zvalue = utils::numeric(FLERR,arg[3],false,lmp); + + } else if (strcmp(arg[1],"z") == 0) { + cdim = 2; + if (utils::strmatch(arg[2],"^v_")) { + xstr = utils::strdup(arg[2]+2); + } else xvalue = utils::numeric(FLERR,arg[2],false,lmp); + if (utils::strmatch(arg[3],"^v_")) { + ystr = utils::strdup(arg[3]+2); + } else yvalue = utils::numeric(FLERR,arg[3],false,lmp); + + } else error->all(FLERR,"Unknown fix indent cone argument: {}", arg[1]); + + if (utils::strmatch(arg[4],"^v_")) { + rlostr = utils::strdup(arg[4]+2); + } else rlovalue = utils::numeric(FLERR,arg[4],false,lmp); + if (utils::strmatch(arg[5],"^v_")) { + rhistr = utils::strdup(arg[5]+2); + } else rhivalue = utils::numeric(FLERR,arg[5],false,lmp); + if (utils::strmatch(arg[6],"^v_")) { + lostr = utils::strdup(arg[6]+2); + } else lovalue = utils::numeric(FLERR,arg[6],false,lmp); + if (utils::strmatch(arg[7],"^v_")) { + histr = utils::strdup(arg[7]+2); + } else hivalue = utils::numeric(FLERR,arg[7],false,lmp); + + istyle = CONE; + return 8; + } + + // plane + + if (strcmp(arg[0],"plane") == 0) { + if (istyle != NONE) error->all(FLERR, "Fix indent requires a single geometry keyword"); + if (4 > narg) utils::missing_cmd_args(FLERR, "fix indent plane", error); + if (strcmp(arg[1],"x") == 0) cdim = 0; + else if (strcmp(arg[1],"y") == 0) cdim = 1; + else if (strcmp(arg[1],"z") == 0) cdim = 2; + else error->all(FLERR,"Unknown fix indent plane argument: {}", arg[1]); + + if (utils::strmatch(arg[2],"^v_")) { + pstr = utils::strdup(arg[2]+2); + } else pvalue = utils::numeric(FLERR,arg[2],false,lmp); + + if (strcmp(arg[3],"lo") == 0) planeside = -1; + else if (strcmp(arg[3],"hi") == 0) planeside = 1; + else error->all(FLERR,"Unknown fix indent plane argument: {}", arg[3]); + istyle = PLANE; + return 4; + } + + // invalid istyle arg + + error->all(FLERR,"Unknown fix indent argument: {}", arg[0]); + + return 0; +} + +/* ---------------------------------------------------------------------- + parse optional input args +------------------------------------------------------------------------- */ + +void FixIndent::options(int narg, char **arg) +{ scaleflag = 1; side = OUTSIDE; int iarg = 0; + while (iarg < narg) { - if (strcmp(arg[iarg],"sphere") == 0) { - if (iarg+5 > narg) utils::missing_cmd_args(FLERR, "fix indent sphere", error); - - if (utils::strmatch(arg[iarg+1],"^v_")) { - xstr = utils::strdup(arg[iarg+1]+2); - } else xvalue = utils::numeric(FLERR,arg[iarg+1],false,lmp); - if (utils::strmatch(arg[iarg+2],"^v_")) { - ystr = utils::strdup(arg[iarg+2]+2); - } else yvalue = utils::numeric(FLERR,arg[iarg+2],false,lmp); - if (utils::strmatch(arg[iarg+3],"^v_")) { - zstr = utils::strdup(arg[iarg+3]+2); - } else zvalue = utils::numeric(FLERR,arg[iarg+3],false,lmp); - if (utils::strmatch(arg[iarg+4],"^v_")) { - rstr = utils::strdup(arg[iarg+4]+2); - } else rvalue = utils::numeric(FLERR,arg[iarg+4],false,lmp); - - istyle = SPHERE; - iarg += 5; - - } else if (strcmp(arg[iarg],"cylinder") == 0) { - if (iarg+5 > narg) utils::missing_cmd_args(FLERR, "fix indent cylinder", error); - - if (strcmp(arg[iarg+1],"x") == 0) { - cdim = 0; - if (utils::strmatch(arg[iarg+2],"^v_")) { - ystr = utils::strdup(arg[iarg+2]+2); - } else yvalue = utils::numeric(FLERR,arg[iarg+2],false,lmp); - if (utils::strmatch(arg[iarg+3],"^v_")) { - zstr = utils::strdup(arg[iarg+3]+2); - } else zvalue = utils::numeric(FLERR,arg[iarg+3],false,lmp); - } else if (strcmp(arg[iarg+1],"y") == 0) { - cdim = 1; - if (utils::strmatch(arg[iarg+2],"^v_")) { - xstr = utils::strdup(arg[iarg+2]+2); - } else xvalue = utils::numeric(FLERR,arg[iarg+2],false,lmp); - if (utils::strmatch(arg[iarg+3],"^v_")) { - zstr = utils::strdup(arg[iarg+3]+2); - } else zvalue = utils::numeric(FLERR,arg[iarg+3],false,lmp); - } else if (strcmp(arg[iarg+1],"z") == 0) { - cdim = 2; - if (utils::strmatch(arg[iarg+2],"^v_")) { - xstr = utils::strdup(arg[iarg+2]+2); - } else xvalue = utils::numeric(FLERR,arg[iarg+2],false,lmp); - if (utils::strmatch(arg[iarg+3],"^v_")) { - ystr = utils::strdup(arg[iarg+3]+2); - } else yvalue = utils::numeric(FLERR,arg[iarg+3],false,lmp); - } else error->all(FLERR,"Unknown fix indent cylinder argument: {}", arg[iarg+1]); - - if (utils::strmatch(arg[iarg+4],"^v_")) { - rstr = utils::strdup(arg[iarg+4]+2); - } else rvalue = utils::numeric(FLERR,arg[iarg+4],false,lmp); - - istyle = CYLINDER; - iarg += 5; - - } else if (strcmp(arg[iarg],"plane") == 0) { - if (iarg+4 > narg) utils::missing_cmd_args(FLERR, "fix indent plane", error); - if (strcmp(arg[iarg+1],"x") == 0) cdim = 0; - else if (strcmp(arg[iarg+1],"y") == 0) cdim = 1; - else if (strcmp(arg[iarg+1],"z") == 0) cdim = 2; - else error->all(FLERR,"Unknown fix indent plane argument: {}", arg[iarg+1]); - - if (utils::strmatch(arg[iarg+2],"^v_")) { - pstr = utils::strdup(arg[iarg+2]+2); - } else pvalue = utils::numeric(FLERR,arg[iarg+2],false,lmp); - - if (strcmp(arg[iarg+3],"lo") == 0) planeside = -1; - else if (strcmp(arg[iarg+3],"hi") == 0) planeside = 1; - else error->all(FLERR,"Unknown fix indent plane argument: {}", arg[iarg+3]); - istyle = PLANE; - iarg += 4; - - } else if (strcmp(arg[iarg],"units") == 0) { + if (strcmp(arg[iarg],"units") == 0) { if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix indent units", error); if (strcmp(arg[iarg+1],"box") == 0) scaleflag = 0; else if (strcmp(arg[iarg+1],"lattice") == 0) scaleflag = 1; @@ -500,6 +653,186 @@ void FixIndent::options(int narg, char **arg) else if (strcmp(arg[iarg+1],"out") == 0) side = OUTSIDE; else error->all(FLERR,"Unknown fix indent side argument: {}", arg[iarg+1]); iarg += 2; + } else error->all(FLERR,"Unknown fix indent argument: {}", arg[iarg]); } } + +/* ---------------------------------------------------------------------- + determines if a point is inside (true) or outside (false) of a cone +------------------------------------------------------------------------- */ + +bool FixIndent::PointInsideCone(int dir, double *center, double lo, + double hi, double rlo, double rhi, double *x) +{ + if ((x[dir] > hi) || (x[dir] < lo)) return false; + + double del[3] {x[0] - center[0], x[1] - center[1], x[2] - center[2]}; + del[dir] = 0.0; + + double dist = sqrt(del[0] * del[0] + del[1] * del[1] + del[2] * del[2]); + double currentradius = rlo + (x[dir] - lo) * (rhi - rlo) / (hi - lo); + + if (dist > currentradius) return false; + + return true; +} + +/* ---------------------------------------------------------------------- + distance between an exterior point and a cone +------------------------------------------------------------------------- */ + +void FixIndent::DistanceExteriorPoint(int dir, double *center, double lo, double hi, + double rlo, double rhi, + double &x, double &y, double &z) +{ + double xp[3], nearest[3], corner1[3], corner2[3]; + + double point[3] {x, y, z}; + + double del[3] {x - center[0], y - center[1], z - center[2]}; + del[dir] = 0.0; + + double r = sqrt(del[0] * del[0] + del[1] * del[1] + del[2] * del[2]); + + corner1[0] = center[0] + del[0] * rlo / r; + corner1[1] = center[1] + del[1] * rlo / r; + corner1[2] = center[2] + del[2] * rlo / r; + corner1[dir] = lo; + + corner2[0] = center[0] + del[0] * rhi / r; + corner2[1] = center[1] + del[1] * rhi / r; + corner2[2] = center[2] + del[2] * rhi / r; + corner2[dir] = hi; + + double corner3[3] {center[0], center[1], center[2]}; + corner3[dir] = lo; + + double corner4[3] {center[0], center[1], center[2]}; + corner4[dir] = hi; + + // initialize distance to a big number + + double distsq = 1.0e20; + + // check the first triangle + + point_on_line_segment(corner1, corner2, point, xp); + distsq = closest(point, xp, nearest, distsq); + + // check the second triangle + + point_on_line_segment(corner1, corner3, point, xp); + distsq = closest(point, xp, nearest, distsq); + + // check the third triangle + + point_on_line_segment(corner2, corner4, point, xp); + distsq = closest(point, xp, nearest, distsq); + + x -= nearest[0]; + y -= nearest[1]; + z -= nearest[2]; + + return; +} + +/* ---------------------------------------------------------------------- + distance between an interior point and a cone +------------------------------------------------------------------------- */ + +void FixIndent::DistanceInteriorPoint(int dir, double *center, + double lo, double hi, double rlo, double rhi, double &x, + double &y, double &z) +{ + double r, dist_disk, dist_surf; + double surflo[3], surfhi[3], xs[3]; + double initial_point[3] {x, y, z}; + double point[3] {0.0, 0.0, 0.0}; + + // initial check with the two disks + + if ( (initial_point[dir] - lo) < (hi - initial_point[dir]) ) { + dist_disk = (initial_point[dir] - lo) * (initial_point[dir] - lo); + point[dir] = initial_point[dir] - lo; + } else { + dist_disk = (hi - initial_point[dir]) * (hi - initial_point[dir]); + point[dir] = initial_point[dir] - hi; + } + + // check with the points in the conical surface + + double del[3] {x - center[0], y - center[1], z - center[2]}; + del[dir] = 0.0; + r = sqrt(del[0] * del[0] + del[1] * del[1] + del[2] * del[2]); + + surflo[0] = center[0] + del[0] * rlo / r; + surflo[1] = center[1] + del[1] * rlo / r; + surflo[2] = center[2] + del[2] * rlo / r; + surflo[dir] = lo; + + surfhi[0] = center[0] + del[0] * rhi / r; + surfhi[1] = center[1] + del[1] * rhi / r; + surfhi[2] = center[2] + del[2] * rhi / r; + surfhi[dir] = hi; + + point_on_line_segment(surflo, surfhi, initial_point, xs); + + double dx[3] {initial_point[0] - xs[0], initial_point[1] - xs[1], initial_point[2] - xs[2]}; + dist_surf = dx[0] * dx[0] + dx[1] * dx[1] + dx[2] * dx[2]; + if (dist_surf < dist_disk) { + x = dx[0]; + y = dx[1]; + z = dx[2]; + } else { + x = point[0]; + y = point[1]; + z = point[2]; + } + + return; +} + +/* ---------------------------------------------------------------------- + helper function extracted from region.cpp +------------------------------------------------------------------------- */ + +void FixIndent::point_on_line_segment(double *a, double *b, double *c, double *d) +{ + double ba[3], ca[3]; + + MathExtra::sub3(b, a, ba); + MathExtra::sub3(c, a, ca); + double t = MathExtra::dot3(ca, ba) / MathExtra::dot3(ba, ba); + if (t <= 0.0) { + d[0] = a[0]; + d[1] = a[1]; + d[2] = a[2]; + } else if (t >= 1.0) { + d[0] = b[0]; + d[1] = b[1]; + d[2] = b[2]; + } else { + d[0] = a[0] + t * ba[0]; + d[1] = a[1] + t * ba[1]; + d[2] = a[2] + t * ba[2]; + } +} + +/* ---------------------------------------------------------------------- + helper function extracted from region_cone.cpp +------------------------------------------------------------------------- */ + +double FixIndent::closest(double *x, double *near, double *nearest, double dsq) +{ + double dx = x[0] - near[0]; + double dy = x[1] - near[1]; + double dz = x[2] - near[2]; + double rsq = dx * dx + dy * dy + dz * dz; + if (rsq >= dsq) return dsq; + + nearest[0] = near[0]; + nearest[1] = near[1]; + nearest[2] = near[2]; + return rsq; +} diff --git a/src/fix_indent.h b/src/fix_indent.h index 527e9ec277..37e1623df9 100644 --- a/src/fix_indent.h +++ b/src/fix_indent.h @@ -49,7 +49,24 @@ class FixIndent : public Fix { int cdim, varflag; int ilevel_respa; + char *rlostr, *rhistr, *lostr, *histr; + int rlovar, rhivar, lovar, hivar; + double rlovalue, rhivalue, lovalue, hivalue; + + // methods for argument parsing + + int geometry(int, char **); void options(int, char **); + + // methods for conical indenter + + bool PointInsideCone(int, double *, double, double, double, double, double *); + void DistanceExteriorPoint(int, double *, double, double, double, double, + double &, double &, double &); + void DistanceInteriorPoint(int, double *, double, double, double, double, + double &, double &, double &); + void point_on_line_segment(double *, double *, double *, double *); + double closest(double *, double *, double *, double); }; } // namespace LAMMPS_NS diff --git a/src/fix_langevin.cpp b/src/fix_langevin.cpp index 35bffb24fa..7339ddada1 100644 --- a/src/fix_langevin.cpp +++ b/src/fix_langevin.cpp @@ -46,8 +46,8 @@ using namespace FixConst; enum { NOBIAS, BIAS }; enum { CONSTANT, EQUAL, ATOM }; -#define SINERTIA 0.4 // moment of inertia prefactor for sphere -#define EINERTIA 0.2 // moment of inertia prefactor for ellipsoid +static constexpr double SINERTIA = 0.4; // moment of inertia prefactor for sphere +static constexpr double EINERTIA = 0.2; // moment of inertia prefactor for ellipsoid /* ---------------------------------------------------------------------- */ @@ -230,18 +230,19 @@ void FixLangevin::init() // warn if any integrate fix comes after this one int before = 1; int flag = 0; - for (int i = 0; i < modify->nfix; i++) { - auto ifix = modify->get_fix_by_index(i); + for (auto ifix : modify->get_fix_list()) { if (strcmp(id, ifix->id) == 0) before = 0; - else if ((modify->fmask[i] && utils::strmatch(ifix->style, "^nve")) && before) + else if ((modify->get_fix_mask(ifix) && utils::strmatch(ifix->style, "^nve")) && before) flag = 1; } if (flag) error->all(FLERR, "Fix langevin gjf should come before fix nve"); } - if (oflag && !atom->sphere_flag) - error->all(FLERR, "Fix langevin omega requires atom style sphere"); + if (oflag && !atom->omega_flag) + error->all(FLERR, "Fix langevin omega requires atom attribute omega"); + if (oflag && !atom->radius_flag) + error->all(FLERR, "Fix langevin omega requires atom attribute radius"); if (ascale && !atom->ellipsoid_flag) error->all(FLERR, "Fix langevin angmom requires atom style ellipsoid"); @@ -789,7 +790,7 @@ void FixLangevin::compute_target() if (tstyle == EQUAL) { t_target = input->variable->compute_equal(tvar); if (t_target < 0.0) - error->one(FLERR,"Fix langevin variable returned negative temperature"); + error->one(FLERR, "Fix langevin variable returned negative temperature"); tsqrt = sqrt(t_target); } else { if (atom->nmax > maxatom2) { @@ -801,8 +802,7 @@ void FixLangevin::compute_target() for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) if (tforce[i] < 0.0) - error->one(FLERR, - "Fix langevin variable returned negative temperature"); + error->one(FLERR, "Fix langevin variable returned negative temperature"); } modify->addstep_compute(update->ntimestep + 1); } diff --git a/src/fix_move.cpp b/src/fix_move.cpp index 53009495b1..80e10c4d3d 100644 --- a/src/fix_move.cpp +++ b/src/fix_move.cpp @@ -42,7 +42,7 @@ using namespace MathConst; enum { LINEAR, WIGGLE, ROTATE, VARIABLE, TRANSROT }; enum { EQUAL, ATOM }; -#define INERTIA 0.2 // moment of inertia prefactor for ellipsoid +static constexpr double INERTIA = 0.2; // moment of inertia prefactor for ellipsoid /* ---------------------------------------------------------------------- */ diff --git a/src/fix_nh.cpp b/src/fix_nh.cpp index 562ca51c29..a7536800cb 100644 --- a/src/fix_nh.cpp +++ b/src/fix_nh.cpp @@ -40,9 +40,9 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define DELTAFLIP 0.1 -#define TILTMAX 1.5 -#define EPSILON 1.0e-6 +static constexpr double DELTAFLIP = 0.1; +static constexpr double TILTMAX = 1.5; +static constexpr double EPSILON = 1.0e-6; enum{NOBIAS,BIAS}; enum{NONE,XYZ,XY,YZ,XZ}; @@ -442,10 +442,16 @@ FixNH::FixNH(LAMMPS *lmp, int narg, char **arg) : error->all(FLERR,"Invalid fix {} pressure settings", style); if (dipole_flag) { - if (!atom->sphere_flag) - error->all(FLERR,"Using update dipole flag requires atom style sphere"); - if (!atom->mu_flag) - error->all(FLERR,"Using update dipole flag requires atom attribute mu"); + if (strstr(style, "/sphere")) { + if (!atom->omega_flag) + error->all(FLERR,"Using update dipole flag requires atom attribute omega"); + if (!atom->radius_flag) + error->all(FLERR,"Using update dipole flag requires atom attribute radius"); + if (!atom->mu_flag) + error->all(FLERR,"Using update dipole flag requires atom attribute mu"); + } else { + error->all(FLERR, "Must use a '/sphere' Nose-Hoover fix style for updating dipoles"); + } } if ((tstat_flag && t_period <= 0.0) || diff --git a/src/fix_nh_sphere.cpp b/src/fix_nh_sphere.cpp index f39de6c656..1835181606 100644 --- a/src/fix_nh_sphere.cpp +++ b/src/fix_nh_sphere.cpp @@ -36,8 +36,10 @@ using namespace MathExtra; FixNHSphere::FixNHSphere(LAMMPS *lmp, int narg, char **arg) : FixNH(lmp, narg, arg) { - if (!atom->sphere_flag) - error->all(FLERR,"Fix nvt/nph/npt sphere requires atom style sphere"); + if (!atom->omega_flag) + error->all(FLERR,"Fix {} requires atom attribute omega", style); + if (!atom->radius_flag) + error->all(FLERR,"Fix {} requires atom attribute radius", style); // inertia = moment of inertia prefactor for sphere or disc @@ -48,8 +50,7 @@ FixNHSphere::FixNHSphere(LAMMPS *lmp, int narg, char **arg) : if (strcmp(arg[iarg],"disc") == 0) { inertia = 0.5; if (domain->dimension != 2) - error->all(FLERR, - "Fix nvt/nph/npt sphere disc option requires 2d simulation"); + error->all(FLERR, "Fix {} disc option requires 2d simulation", style); } iarg++; } diff --git a/src/fix_nve_sphere.cpp b/src/fix_nve_sphere.cpp index ea57028af4..21520d7a69 100644 --- a/src/fix_nve_sphere.cpp +++ b/src/fix_nve_sphere.cpp @@ -68,8 +68,8 @@ FixNVESphere::FixNVESphere(LAMMPS *lmp, int narg, char **arg) : // error checks - if (!atom->sphere_flag) - error->all(FLERR,"Fix nve/sphere requires atom style sphere"); + if (!atom->omega_flag) + error->all(FLERR,"Fix nve/sphere requires atom attribute omega"); if (extra == DIPOLE && !atom->mu_flag) error->all(FLERR,"Fix nve/sphere update dipole requires atom attribute mu"); } diff --git a/src/fix_pair.cpp b/src/fix_pair.cpp index 66212684a8..da56b01f9e 100644 --- a/src/fix_pair.cpp +++ b/src/fix_pair.cpp @@ -21,7 +21,8 @@ #include "memory.h" #include "pair.h" #include "update.h" -#include "fmt/format.h" + +#include using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/fix_press_langevin.cpp b/src/fix_press_langevin.cpp index 752f826dfe..8116d66c0a 100644 --- a/src/fix_press_langevin.cpp +++ b/src/fix_press_langevin.cpp @@ -24,7 +24,6 @@ #include "error.h" #include "fix_deform.h" #include "force.h" -#include "group.h" #include "irregular.h" #include "kspace.h" #include "modify.h" @@ -37,8 +36,8 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define DELTAFLIP 0.1 -#define TILTMAX 1.5 +static constexpr double DELTAFLIP = 0.1; +static constexpr double TILTMAX = 1.5; enum { NONE, XYZ, XY, YZ, XZ }; enum { ISO, ANISO, TRICLINIC }; diff --git a/src/fix_property_atom.cpp b/src/fix_property_atom.cpp index 9613523059..de96b5c39d 100644 --- a/src/fix_property_atom.cpp +++ b/src/fix_property_atom.cpp @@ -51,6 +51,19 @@ FixPropertyAtom::FixPropertyAtom(LAMMPS *lmp, int narg, char **arg) : nvalue = 0; values_peratom = 0; + // check for ghost keyword to use as add_custom() arg + + border = 0; + while (iarg < narg) { + if (strcmp(arg[iarg], "ghost") == 0) { + if (iarg + 2 > narg) error->all(FLERR, "Illegal fix property/atom command"); + border = utils::logical(FLERR, arg[iarg + 1], false, lmp); + iarg += 2; + } else iarg++; + } + + iarg = 3; + while (iarg < narg) { if (strcmp(arg[iarg], "mol") == 0) { if (atom->molecule_flag) @@ -112,7 +125,7 @@ FixPropertyAtom::FixPropertyAtom(LAMMPS *lmp, int narg, char **arg) : if (index[nvalue] >= 0) error->all(FLERR, "Fix property/atom vector name already exists"); if (ReadData::is_data_section(id)) error->all(FLERR, "Fix property/atom fix ID must not be a data file section name"); - index[nvalue] = atom->add_custom(&arg[iarg][2], 0, 0); + index[nvalue] = atom->add_custom(&arg[iarg][2], 0, 0, border); cols[nvalue] = 0; values_peratom++; nvalue++; @@ -125,7 +138,7 @@ FixPropertyAtom::FixPropertyAtom(LAMMPS *lmp, int narg, char **arg) : if (index[nvalue] >= 0) error->all(FLERR, "Fix property/atom vector name already exists"); if (ReadData::is_data_section(id)) error->all(FLERR, "Fix property/atom fix ID must not be a data file section name"); - index[nvalue] = atom->add_custom(&arg[iarg][2], 1, 0); + index[nvalue] = atom->add_custom(&arg[iarg][2], 1, 0, border); cols[nvalue] = 0; values_peratom++; nvalue++; @@ -154,7 +167,7 @@ FixPropertyAtom::FixPropertyAtom(LAMMPS *lmp, int narg, char **arg) : which = 1; styles[nvalue] = DARRAY; } - index[nvalue] = atom->add_custom(&arg[iarg][3], which, ncols); + index[nvalue] = atom->add_custom(&arg[iarg][3], which, ncols, border); cols[nvalue] = ncols; values_peratom += ncols; nvalue++; @@ -168,11 +181,8 @@ FixPropertyAtom::FixPropertyAtom(LAMMPS *lmp, int narg, char **arg) : // optional args - border = 0; while (iarg < narg) { - if (strcmp(arg[iarg], "ghost") == 0) { - if (iarg + 2 > narg) error->all(FLERR, "Illegal fix property/atom command"); - border = utils::logical(FLERR, arg[iarg + 1], false, lmp); + if (strcmp(arg[iarg], "ghost") == 0) { // skip here, since handled earlier iarg += 2; } else if (strcmp(arg[iarg], "writedata") == 0) { if (iarg + 2 > narg) error->all(FLERR, "Illegal fix property/atom command"); diff --git a/src/fix_recenter.cpp b/src/fix_recenter.cpp index bee7f55823..4da8c4787b 100644 --- a/src/fix_recenter.cpp +++ b/src/fix_recenter.cpp @@ -125,13 +125,12 @@ void FixRecenter::init() int after = 0; int flag = 0; - for (int i = 0; i < modify->nfix; i++) { - if (strcmp(id,modify->fix[i]->id) == 0) after = 1; - else if ((modify->fmask[i] & INITIAL_INTEGRATE) && after) flag = 1; + for (const auto &ifix : modify->get_fix_list()) { + if (strcmp(id, ifix->id) == 0) after = 1; + else if ((modify->get_fix_mask(ifix) & INITIAL_INTEGRATE) && after) flag = 1; } if (flag && comm->me == 0) - error->warning(FLERR,"Fix recenter should come after all other " - "integration fixes"); + error->warning(FLERR,"Fix recenter should come after all other integration fixes"); masstotal = group->mass(igroup); diff --git a/src/fix_restrain.cpp b/src/fix_restrain.cpp index f252134aa9..cc95fc93f3 100644 --- a/src/fix_restrain.cpp +++ b/src/fix_restrain.cpp @@ -38,9 +38,9 @@ using MathConst::DEG2RAD; enum{BOND,LBOUND,ANGLE,DIHEDRAL}; -#define TOLERANCE 0.05 -#define SMALL 0.001 -#define DELTA 1 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; +static constexpr int DELTA = 1; /* ---------------------------------------------------------------------- */ diff --git a/src/fix_spring.cpp b/src/fix_spring.cpp index 3a14ec8de1..93c1f7867d 100644 --- a/src/fix_spring.cpp +++ b/src/fix_spring.cpp @@ -30,7 +30,7 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define SMALL 1.0e-10 +static constexpr double SMALL = 1.0e-10; enum{TETHER,COUPLE}; diff --git a/src/fix_spring_chunk.cpp b/src/fix_spring_chunk.cpp index 3deedcffac..f42572b190 100644 --- a/src/fix_spring_chunk.cpp +++ b/src/fix_spring_chunk.cpp @@ -30,7 +30,7 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define SMALL 1.0e-10 +static constexpr double SMALL = 1.0e-10; /* ---------------------------------------------------------------------- */ diff --git a/src/fix_store_local.cpp b/src/fix_store_local.cpp index d32f0e8178..8deac03d79 100644 --- a/src/fix_store_local.cpp +++ b/src/fix_store_local.cpp @@ -21,7 +21,7 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define DELTA 1024 +static constexpr int DELTA = 1024; /* ---------------------------------------------------------------------- */ diff --git a/src/fix_thermal_conductivity.cpp b/src/fix_thermal_conductivity.cpp index 5fcb59d276..dd674a0506 100644 --- a/src/fix_thermal_conductivity.cpp +++ b/src/fix_thermal_conductivity.cpp @@ -29,7 +29,7 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define BIG 1.0e10 +static constexpr double BIG = 1.0e10; /* ---------------------------------------------------------------------- */ @@ -108,15 +108,14 @@ int FixThermalConductivity::setmask() void FixThermalConductivity::init() { - // warn if any fix ave/spatial comes after this fix + // warn if any fix ave/chunk comes after this fix // can cause glitch in averaging since ave will happen after swap int foundme = 0; - for (int i = 0; i < modify->nfix; i++) { - if (modify->fix[i] == this) foundme = 1; - if (foundme && strcmp(modify->fix[i]->style,"ave/spatial") == 0 && me == 0) - error->warning(FLERR, - "Fix thermal/conductivity comes before fix ave/spatial"); + for (const auto &ifix : modify->get_fix_list()) { + if (ifix == this) foundme = 1; + if (foundme && utils::strmatch(ifix->style,"^ave/chunk") && (me == 0)) + error->warning(FLERR, "Fix thermal/conductivity comes before fix ave/chunk"); } // set bounds of 2 slabs in edim diff --git a/src/fix_vector.cpp b/src/fix_vector.cpp index e18b53f615..7c75f93a3a 100644 --- a/src/fix_vector.cpp +++ b/src/fix_vector.cpp @@ -22,6 +22,8 @@ #include "update.h" #include "variable.h" +#include + using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/fix_wall.cpp b/src/fix_wall.cpp index c4f3219622..50289d0f69 100644 --- a/src/fix_wall.cpp +++ b/src/fix_wall.cpp @@ -28,7 +28,6 @@ using namespace LAMMPS_NS; using namespace FixConst; enum { XLO = 0, XHI = 1, YLO = 2, YHI = 3, ZLO = 4, ZHI = 5 }; -enum { NONE = 0, EDGE, CONSTANT, VARIABLE }; static const char *wallpos[] = {"xlo", "xhi", "ylo", "yhi", "zlo", "zhi"}; diff --git a/src/fix_wall.h b/src/fix_wall.h index 12ceb17b49..81abfab8ea 100644 --- a/src/fix_wall.h +++ b/src/fix_wall.h @@ -27,6 +27,7 @@ class FixWall : public Fix { int xstyle[6]; int xindex[6]; char *xstr[6]; + enum { NONE = 0, EDGE, CONSTANT, VARIABLE }; FixWall(class LAMMPS *, int, char **); ~FixWall() override; diff --git a/src/fix_wall_lj126.cpp b/src/fix_wall_lj126.cpp index f0f7750edb..d526390153 100644 --- a/src/fix_wall_lj126.cpp +++ b/src/fix_wall_lj126.cpp @@ -17,8 +17,6 @@ #include "error.h" #include "math_special.h" -#include - using namespace LAMMPS_NS; using MathSpecial::powint; diff --git a/src/fix_wall_lj93.cpp b/src/fix_wall_lj93.cpp index c0c5e86ce3..dda0298be1 100644 --- a/src/fix_wall_lj93.cpp +++ b/src/fix_wall_lj93.cpp @@ -17,8 +17,6 @@ #include "error.h" #include "math_special.h" -#include - using namespace LAMMPS_NS; using MathSpecial::powint; diff --git a/src/fix_wall_reflect.cpp b/src/fix_wall_reflect.cpp index 00ef968828..0169644e4a 100644 --- a/src/fix_wall_reflect.cpp +++ b/src/fix_wall_reflect.cpp @@ -32,8 +32,7 @@ using namespace FixConst; /* ---------------------------------------------------------------------- */ FixWallReflect::FixWallReflect(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg), - nwall(0) + Fix(lmp, narg, arg), nwall(0), varflag(0) { if (narg < 4) utils::missing_cmd_args(FLERR, "fix wall/reflect", error); diff --git a/src/fix_wall_region.cpp b/src/fix_wall_region.cpp index da9ee757d9..d6fc63f55c 100644 --- a/src/fix_wall_region.cpp +++ b/src/fix_wall_region.cpp @@ -38,7 +38,7 @@ enum { LJ93, LJ126, LJ1043, COLLOID, HARMONIC, MORSE }; FixWallRegion::FixWallRegion(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), idregion(nullptr), region(nullptr) { - if (narg < 8) error->all(FLERR, "Illegal fix wall/region command"); + if (narg < 8) utils::missing_cmd_args(FLERR, "fix wall/region", error); scalar_flag = 1; vector_flag = 1; @@ -70,12 +70,12 @@ FixWallRegion::FixWallRegion(LAMMPS *lmp, int narg, char **arg) : else if (strcmp(arg[4], "morse") == 0) style = MORSE; else - error->all(FLERR, "Illegal fix wall/region command"); + error->all(FLERR, "Unknown fix wall/region style {}", arg[4]); if (style != COLLOID) dynamic_group_allow = 1; if (style == MORSE) { - if (narg != 9) error->all(FLERR, "Illegal fix wall/region command"); + if (narg != 9) error->all(FLERR, "Illegal fix wall/region morse command"); epsilon = utils::numeric(FLERR, arg[5], false, lmp); alpha = utils::numeric(FLERR, arg[6], false, lmp); @@ -127,7 +127,7 @@ void FixWallRegion::init() // ensure all particles in group are extended particles if (style == COLLOID) { - if (!atom->sphere_flag) error->all(FLERR, "Fix wall/region colloid requires atom style sphere"); + if (!atom->radius_flag) error->all(FLERR, "Fix wall/region colloid requires atom attribute radius"); double *radius = atom->radius; int *mask = atom->mask; @@ -140,7 +140,7 @@ void FixWallRegion::init() int flagall; MPI_Allreduce(&flag, &flagall, 1, MPI_INT, MPI_SUM, world); - if (flagall) error->all(FLERR, "Fix wall/region colloid requires extended particles"); + if (flagall) error->all(FLERR, "Fix wall/region colloid requires only extended particles"); } // setup coefficients for each style diff --git a/src/fmt/args.h b/src/fmt/args.h index 2d684e7cc1..b77a2d0661 100644 --- a/src/fmt/args.h +++ b/src/fmt/args.h @@ -12,7 +12,7 @@ #include // std::unique_ptr #include -#include "core.h" +#include "format.h" // std_string_view FMT_BEGIN_NAMESPACE @@ -22,8 +22,9 @@ template struct is_reference_wrapper : std::false_type {}; template struct is_reference_wrapper> : std::true_type {}; -template const T& unwrap(const T& v) { return v; } -template const T& unwrap(const std::reference_wrapper& v) { +template auto unwrap(const T& v) -> const T& { return v; } +template +auto unwrap(const std::reference_wrapper& v) -> const T& { return static_cast(v); } @@ -50,7 +51,7 @@ class dynamic_arg_list { std::unique_ptr> head_; public: - template const T& push(const Arg& arg) { + template auto push(const Arg& arg) -> const T& { auto new_node = std::unique_ptr>(new typed_node(arg)); auto& value = new_node->value; new_node->next = std::move(head_); @@ -110,14 +111,14 @@ class dynamic_format_arg_store friend class basic_format_args; - unsigned long long get_types() const { + auto get_types() const -> unsigned long long { return detail::is_unpacked_bit | data_.size() | (named_info_.empty() ? 0ULL : static_cast(detail::has_named_args_bit)); } - const basic_format_arg* data() const { + auto data() const -> const basic_format_arg* { return named_info_.empty() ? data_.data() : data_.data() + 1; } diff --git a/src/fmt/chrono.h b/src/fmt/chrono.h index ff3e1445b9..9d54574e16 100644 --- a/src/fmt/chrono.h +++ b/src/fmt/chrono.h @@ -18,7 +18,7 @@ #include #include -#include "format.h" +#include "ostream.h" // formatbuf FMT_BEGIN_NAMESPACE @@ -72,7 +72,8 @@ template ::value && std::numeric_limits::is_signed == std::numeric_limits::is_signed)> -FMT_CONSTEXPR To lossless_integral_conversion(const From from, int& ec) { +FMT_CONSTEXPR auto lossless_integral_conversion(const From from, int& ec) + -> To { ec = 0; using F = std::numeric_limits; using T = std::numeric_limits; @@ -101,7 +102,8 @@ template ::value && std::numeric_limits::is_signed != std::numeric_limits::is_signed)> -FMT_CONSTEXPR To lossless_integral_conversion(const From from, int& ec) { +FMT_CONSTEXPR auto lossless_integral_conversion(const From from, int& ec) + -> To { ec = 0; using F = std::numeric_limits; using T = std::numeric_limits; @@ -133,7 +135,8 @@ FMT_CONSTEXPR To lossless_integral_conversion(const From from, int& ec) { template ::value)> -FMT_CONSTEXPR To lossless_integral_conversion(const From from, int& ec) { +FMT_CONSTEXPR auto lossless_integral_conversion(const From from, int& ec) + -> To { ec = 0; return from; } // function @@ -154,7 +157,7 @@ FMT_CONSTEXPR To lossless_integral_conversion(const From from, int& ec) { // clang-format on template ::value)> -FMT_CONSTEXPR To safe_float_conversion(const From from, int& ec) { +FMT_CONSTEXPR auto safe_float_conversion(const From from, int& ec) -> To { ec = 0; using T = std::numeric_limits; static_assert(std::is_floating_point::value, "From must be floating"); @@ -176,7 +179,7 @@ FMT_CONSTEXPR To safe_float_conversion(const From from, int& ec) { template ::value)> -FMT_CONSTEXPR To safe_float_conversion(const From from, int& ec) { +FMT_CONSTEXPR auto safe_float_conversion(const From from, int& ec) -> To { ec = 0; static_assert(std::is_floating_point::value, "From must be floating"); return from; @@ -188,8 +191,8 @@ FMT_CONSTEXPR To safe_float_conversion(const From from, int& ec) { template ::value), FMT_ENABLE_IF(std::is_integral::value)> -To safe_duration_cast(std::chrono::duration from, - int& ec) { +auto safe_duration_cast(std::chrono::duration from, + int& ec) -> To { using From = std::chrono::duration; ec = 0; // the basic idea is that we need to convert from count() in the from type @@ -240,8 +243,8 @@ To safe_duration_cast(std::chrono::duration from, template ::value), FMT_ENABLE_IF(std::is_floating_point::value)> -To safe_duration_cast(std::chrono::duration from, - int& ec) { +auto safe_duration_cast(std::chrono::duration from, + int& ec) -> To { using From = std::chrono::duration; ec = 0; if (std::isnan(from.count())) { @@ -321,12 +324,12 @@ To safe_duration_cast(std::chrono::duration from, namespace detail { template struct null {}; -inline null<> localtime_r FMT_NOMACRO(...) { return null<>(); } -inline null<> localtime_s(...) { return null<>(); } -inline null<> gmtime_r(...) { return null<>(); } -inline null<> gmtime_s(...) { return null<>(); } +inline auto localtime_r FMT_NOMACRO(...) -> null<> { return null<>(); } +inline auto localtime_s(...) -> null<> { return null<>(); } +inline auto gmtime_r(...) -> null<> { return null<>(); } +inline auto gmtime_s(...) -> null<> { return null<>(); } -inline const std::locale& get_classic_locale() { +inline auto get_classic_locale() -> const std::locale& { static const auto& locale = std::locale::classic(); return locale; } @@ -336,8 +339,6 @@ template struct codecvt_result { CodeUnit buf[max_size]; CodeUnit* end; }; -template -constexpr const size_t codecvt_result::max_size; template void write_codecvt(codecvt_result& out, string_view in_buf, @@ -408,8 +409,7 @@ inline void do_write(buffer& buf, const std::tm& time, auto&& format_buf = formatbuf>(buf); auto&& os = std::basic_ostream(&format_buf); os.imbue(loc); - using iterator = std::ostreambuf_iterator; - const auto& facet = std::use_facet>(loc); + const auto& facet = std::use_facet>(loc); auto end = facet.put(os, os, Char(' '), &time, format, modifier); if (end.failed()) FMT_THROW(format_error("failed to format time")); } @@ -432,6 +432,51 @@ auto write(OutputIt out, const std::tm& time, const std::locale& loc, return write_encoded_tm_str(out, string_view(buf.data(), buf.size()), loc); } +template +struct is_same_arithmetic_type + : public std::integral_constant::value && + std::is_integral::value) || + (std::is_floating_point::value && + std::is_floating_point::value)> { +}; + +template < + typename To, typename FromRep, typename FromPeriod, + FMT_ENABLE_IF(is_same_arithmetic_type::value)> +auto fmt_duration_cast(std::chrono::duration from) -> To { +#if FMT_SAFE_DURATION_CAST + // Throwing version of safe_duration_cast is only available for + // integer to integer or float to float casts. + int ec; + To to = safe_duration_cast::safe_duration_cast(from, ec); + if (ec) FMT_THROW(format_error("cannot format duration")); + return to; +#else + // Standard duration cast, may overflow. + return std::chrono::duration_cast(from); +#endif +} + +template < + typename To, typename FromRep, typename FromPeriod, + FMT_ENABLE_IF(!is_same_arithmetic_type::value)> +auto fmt_duration_cast(std::chrono::duration from) -> To { + // Mixed integer <-> float cast is not supported by safe_duration_cast. + return std::chrono::duration_cast(from); +} + +template +auto to_time_t( + std::chrono::time_point time_point) + -> std::time_t { + // Cannot use std::chrono::system_clock::to_time_t since this would first + // require a cast to std::chrono::system_clock::time_point, which could + // overflow. + return fmt_duration_cast>( + time_point.time_since_epoch()) + .count(); +} } // namespace detail FMT_BEGIN_EXPORT @@ -441,29 +486,29 @@ FMT_BEGIN_EXPORT expressed in local time. Unlike ``std::localtime``, this function is thread-safe on most platforms. */ -inline std::tm localtime(std::time_t time) { +inline auto localtime(std::time_t time) -> std::tm { struct dispatcher { std::time_t time_; std::tm tm_; dispatcher(std::time_t t) : time_(t) {} - bool run() { + auto run() -> bool { using namespace fmt::detail; return handle(localtime_r(&time_, &tm_)); } - bool handle(std::tm* tm) { return tm != nullptr; } + auto handle(std::tm* tm) -> bool { return tm != nullptr; } - bool handle(detail::null<>) { + auto handle(detail::null<>) -> bool { using namespace fmt::detail; return fallback(localtime_s(&tm_, &time_)); } - bool fallback(int res) { return res == 0; } + auto fallback(int res) -> bool { return res == 0; } #if !FMT_MSC_VERSION - bool fallback(detail::null<>) { + auto fallback(detail::null<>) -> bool { using namespace fmt::detail; std::tm* tm = std::localtime(&time_); if (tm) tm_ = *tm; @@ -480,8 +525,8 @@ inline std::tm localtime(std::time_t time) { #if FMT_USE_LOCAL_TIME template inline auto localtime(std::chrono::local_time time) -> std::tm { - return localtime(std::chrono::system_clock::to_time_t( - std::chrono::current_zone()->to_sys(time))); + return localtime( + detail::to_time_t(std::chrono::current_zone()->to_sys(time))); } #endif @@ -490,29 +535,29 @@ inline auto localtime(std::chrono::local_time time) -> std::tm { expressed in Coordinated Universal Time (UTC). Unlike ``std::gmtime``, this function is thread-safe on most platforms. */ -inline std::tm gmtime(std::time_t time) { +inline auto gmtime(std::time_t time) -> std::tm { struct dispatcher { std::time_t time_; std::tm tm_; dispatcher(std::time_t t) : time_(t) {} - bool run() { + auto run() -> bool { using namespace fmt::detail; return handle(gmtime_r(&time_, &tm_)); } - bool handle(std::tm* tm) { return tm != nullptr; } + auto handle(std::tm* tm) -> bool { return tm != nullptr; } - bool handle(detail::null<>) { + auto handle(detail::null<>) -> bool { using namespace fmt::detail; return fallback(gmtime_s(&tm_, &time_)); } - bool fallback(int res) { return res == 0; } + auto fallback(int res) -> bool { return res == 0; } #if !FMT_MSC_VERSION - bool fallback(detail::null<>) { + auto fallback(detail::null<>) -> bool { std::tm* tm = std::gmtime(&time_); if (tm) tm_ = *tm; return tm != nullptr; @@ -525,9 +570,11 @@ inline std::tm gmtime(std::time_t time) { return gt.tm_; } -inline std::tm gmtime( - std::chrono::time_point time_point) { - return gmtime(std::chrono::system_clock::to_time_t(time_point)); +template +inline auto gmtime( + std::chrono::time_point time_point) + -> std::tm { + return gmtime(detail::to_time_t(time_point)); } namespace detail { @@ -566,7 +613,8 @@ inline void write_digit2_separated(char* buf, unsigned a, unsigned b, } } -template FMT_CONSTEXPR inline const char* get_units() { +template +FMT_CONSTEXPR inline auto get_units() -> const char* { if (std::is_same::value) return "as"; if (std::is_same::value) return "fs"; if (std::is_same::value) return "ps"; @@ -584,8 +632,9 @@ template FMT_CONSTEXPR inline const char* get_units() { if (std::is_same::value) return "Ts"; if (std::is_same::value) return "Ps"; if (std::is_same::value) return "Es"; - if (std::is_same>::value) return "m"; + if (std::is_same>::value) return "min"; if (std::is_same>::value) return "h"; + if (std::is_same>::value) return "d"; return nullptr; } @@ -621,9 +670,8 @@ auto write_padding(OutputIt out, pad_type pad) -> OutputIt { // Parses a put_time-like format string and invokes handler actions. template -FMT_CONSTEXPR const Char* parse_chrono_format(const Char* begin, - const Char* end, - Handler&& handler) { +FMT_CONSTEXPR auto parse_chrono_format(const Char* begin, const Char* end, + Handler&& handler) -> const Char* { if (begin == end || *begin == '}') return begin; if (*begin != '%') FMT_THROW(format_error("invalid format")); auto ptr = begin; @@ -954,25 +1002,25 @@ struct tm_format_checker : null_chrono_spec_handler { FMT_CONSTEXPR void on_tz_name() {} }; -inline const char* tm_wday_full_name(int wday) { +inline auto tm_wday_full_name(int wday) -> const char* { static constexpr const char* full_name_list[] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; return wday >= 0 && wday <= 6 ? full_name_list[wday] : "?"; } -inline const char* tm_wday_short_name(int wday) { +inline auto tm_wday_short_name(int wday) -> const char* { static constexpr const char* short_name_list[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; return wday >= 0 && wday <= 6 ? short_name_list[wday] : "???"; } -inline const char* tm_mon_full_name(int mon) { +inline auto tm_mon_full_name(int mon) -> const char* { static constexpr const char* full_name_list[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; return mon >= 0 && mon <= 11 ? full_name_list[mon] : "?"; } -inline const char* tm_mon_short_name(int mon) { +inline auto tm_mon_short_name(int mon) -> const char* { static constexpr const char* short_name_list[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", @@ -1004,21 +1052,21 @@ inline void tzset_once() { // Converts value to Int and checks that it's in the range [0, upper). template ::value)> -inline Int to_nonnegative_int(T value, Int upper) { - FMT_ASSERT(std::is_unsigned::value || - (value >= 0 && to_unsigned(value) <= to_unsigned(upper)), - "invalid value"); - (void)upper; +inline auto to_nonnegative_int(T value, Int upper) -> Int { + if (!std::is_unsigned::value && + (value < 0 || to_unsigned(value) > to_unsigned(upper))) { + FMT_THROW(fmt::format_error("chrono value is out of range")); + } return static_cast(value); } template ::value)> -inline Int to_nonnegative_int(T value, Int upper) { +inline auto to_nonnegative_int(T value, Int upper) -> Int { if (value < 0 || value > static_cast(upper)) FMT_THROW(format_error("invalid value")); return static_cast(value); } -constexpr long long pow10(std::uint32_t n) { +constexpr auto pow10(std::uint32_t n) -> long long { return n == 0 ? 1 : 10 * pow10(n - 1); } @@ -1052,13 +1100,12 @@ void write_fractional_seconds(OutputIt& out, Duration d, int precision = -1) { std::chrono::seconds::rep>::type, std::ratio<1, detail::pow10(num_fractional_digits)>>; - const auto fractional = - d - std::chrono::duration_cast(d); + const auto fractional = d - fmt_duration_cast(d); const auto subseconds = std::chrono::treat_as_floating_point< typename subsecond_precision::rep>::value ? fractional.count() - : std::chrono::duration_cast(fractional).count(); + : fmt_duration_cast(fractional).count(); auto n = static_cast>(subseconds); const int num_digits = detail::count_digits(n); @@ -1109,11 +1156,11 @@ void write_floating_seconds(memory_buffer& buf, Duration duration, num_fractional_digits = 6; } - format_to(std::back_inserter(buf), FMT_STRING("{:.{}f}"), - std::fmod(val * static_cast(Duration::period::num) / - static_cast(Duration::period::den), - static_cast(60)), - num_fractional_digits); + fmt::format_to(std::back_inserter(buf), FMT_STRING("{:.{}f}"), + std::fmod(val * static_cast(Duration::period::num) / + static_cast(Duration::period::den), + static_cast(60)), + num_fractional_digits); } template (l); } - // Algorithm: - // https://en.wikipedia.org/wiki/ISO_week_date#Calculating_the_week_number_from_a_month_and_day_of_the_month_or_ordinal_date + // Algorithm: https://en.wikipedia.org/wiki/ISO_week_date. auto iso_year_weeks(long long curr_year) const noexcept -> int { const auto prev_year = curr_year - 1; const auto curr_p = @@ -1315,7 +1361,7 @@ class tm_writer { subsecs_(subsecs), tm_(tm) {} - OutputIt out() const { return out_; } + auto out() const -> OutputIt { return out_; } FMT_CONSTEXPR void on_text(const Char* begin, const Char* end) { out_ = copy_str(begin, end, out_); @@ -1579,6 +1625,7 @@ struct chrono_format_checker : null_chrono_spec_handler { template FMT_CONSTEXPR void on_text(const Char*, const Char*) {} + FMT_CONSTEXPR void on_day_of_year() {} FMT_CONSTEXPR void on_24_hour(numeric_system, pad_type) {} FMT_CONSTEXPR void on_12_hour(numeric_system, pad_type) {} FMT_CONSTEXPR void on_minute(numeric_system, pad_type) {} @@ -1597,16 +1644,16 @@ struct chrono_format_checker : null_chrono_spec_handler { template ::value&& has_isfinite::value)> -inline bool isfinite(T) { +inline auto isfinite(T) -> bool { return true; } template ::value)> -inline T mod(T x, int y) { +inline auto mod(T x, int y) -> T { return x % static_cast(y); } template ::value)> -inline T mod(T x, int y) { +inline auto mod(T x, int y) -> T { return std::fmod(x, static_cast(y)); } @@ -1621,49 +1668,38 @@ template struct make_unsigned_or_unchanged { using type = typename std::make_unsigned::type; }; -#if FMT_SAFE_DURATION_CAST -// throwing version of safe_duration_cast -template -To fmt_safe_duration_cast(std::chrono::duration from) { - int ec; - To to = safe_duration_cast::safe_duration_cast(from, ec); - if (ec) FMT_THROW(format_error("cannot format duration")); - return to; -} -#endif - template ::value)> -inline std::chrono::duration get_milliseconds( - std::chrono::duration d) { +inline auto get_milliseconds(std::chrono::duration d) + -> std::chrono::duration { // this may overflow and/or the result may not fit in the // target type. #if FMT_SAFE_DURATION_CAST using CommonSecondsType = typename std::common_type::type; - const auto d_as_common = fmt_safe_duration_cast(d); + const auto d_as_common = fmt_duration_cast(d); const auto d_as_whole_seconds = - fmt_safe_duration_cast(d_as_common); + fmt_duration_cast(d_as_common); // this conversion should be nonproblematic const auto diff = d_as_common - d_as_whole_seconds; const auto ms = - fmt_safe_duration_cast>(diff); + fmt_duration_cast>(diff); return ms; #else - auto s = std::chrono::duration_cast(d); - return std::chrono::duration_cast(d - s); + auto s = fmt_duration_cast(d); + return fmt_duration_cast(d - s); #endif } template ::value)> -OutputIt format_duration_value(OutputIt out, Rep val, int) { +auto format_duration_value(OutputIt out, Rep val, int) -> OutputIt { return write(out, val); } template ::value)> -OutputIt format_duration_value(OutputIt out, Rep val, int precision) { +auto format_duration_value(OutputIt out, Rep val, int precision) -> OutputIt { auto specs = format_specs(); specs.precision = precision; specs.type = precision >= 0 ? presentation_type::fixed_lower @@ -1672,12 +1708,12 @@ OutputIt format_duration_value(OutputIt out, Rep val, int precision) { } template -OutputIt copy_unit(string_view unit, OutputIt out, Char) { +auto copy_unit(string_view unit, OutputIt out, Char) -> OutputIt { return std::copy(unit.begin(), unit.end(), out); } template -OutputIt copy_unit(string_view unit, OutputIt out, wchar_t) { +auto copy_unit(string_view unit, OutputIt out, wchar_t) -> OutputIt { // This works when wchar_t is UTF-32 because units only contain characters // that have the same representation in UTF-16 and UTF-32. utf8_to_utf16 u(unit); @@ -1685,7 +1721,7 @@ OutputIt copy_unit(string_view unit, OutputIt out, wchar_t) { } template -OutputIt format_duration_unit(OutputIt out) { +auto format_duration_unit(OutputIt out) -> OutputIt { if (const char* unit = get_units()) return copy_unit(string_view(unit), out, Char()); *out++ = '['; @@ -1752,18 +1788,12 @@ struct chrono_formatter { // this may overflow and/or the result may not fit in the // target type. -#if FMT_SAFE_DURATION_CAST // might need checked conversion (rep!=Rep) - auto tmpval = std::chrono::duration(val); - s = fmt_safe_duration_cast(tmpval); -#else - s = std::chrono::duration_cast( - std::chrono::duration(val)); -#endif + s = fmt_duration_cast(std::chrono::duration(val)); } // returns true if nan or inf, writes to out. - bool handle_nan_inf() { + auto handle_nan_inf() -> bool { if (isfinite(val)) { return false; } @@ -1780,17 +1810,22 @@ struct chrono_formatter { return true; } - Rep hour() const { return static_cast(mod((s.count() / 3600), 24)); } + auto days() const -> Rep { return static_cast(s.count() / 86400); } + auto hour() const -> Rep { + return static_cast(mod((s.count() / 3600), 24)); + } - Rep hour12() const { + auto hour12() const -> Rep { Rep hour = static_cast(mod((s.count() / 3600), 12)); return hour <= 0 ? 12 : hour; } - Rep minute() const { return static_cast(mod((s.count() / 60), 60)); } - Rep second() const { return static_cast(mod(s.count(), 60)); } + auto minute() const -> Rep { + return static_cast(mod((s.count() / 60), 60)); + } + auto second() const -> Rep { return static_cast(mod(s.count(), 60)); } - std::tm time() const { + auto time() const -> std::tm { auto time = std::tm(); time.tm_hour = to_nonnegative_int(hour(), 24); time.tm_min = to_nonnegative_int(minute(), 60); @@ -1858,10 +1893,14 @@ struct chrono_formatter { void on_dec0_week_of_year(numeric_system) {} void on_dec1_week_of_year(numeric_system) {} void on_iso_week_of_year(numeric_system) {} - void on_day_of_year() {} void on_day_of_month(numeric_system) {} void on_day_of_month_space(numeric_system) {} + void on_day_of_year() { + if (handle_nan_inf()) return; + write(days(), 0); + } + void on_24_hour(numeric_system ns, pad_type pad) { if (handle_nan_inf()) return; @@ -1968,7 +2007,7 @@ class weekday { weekday() = default; explicit constexpr weekday(unsigned wd) noexcept : value(static_cast(wd != 7 ? wd : 0)) {} - constexpr unsigned c_encoding() const noexcept { return value; } + constexpr auto c_encoding() const noexcept -> unsigned { return value; } }; class year_month_day {}; @@ -2083,25 +2122,22 @@ struct formatter, period::num != 1 || period::den != 1 || std::is_floating_point::value)) { const auto epoch = val.time_since_epoch(); - auto subsecs = std::chrono::duration_cast( - epoch - std::chrono::duration_cast(epoch)); + auto subsecs = detail::fmt_duration_cast( + epoch - detail::fmt_duration_cast(epoch)); if (subsecs.count() < 0) { auto second = - std::chrono::duration_cast(std::chrono::seconds(1)); + detail::fmt_duration_cast(std::chrono::seconds(1)); if (epoch.count() < ((Duration::min)() + second).count()) FMT_THROW(format_error("duration is too small")); subsecs += second; val -= second; } - return formatter::do_format( - gmtime(std::chrono::time_point_cast(val)), ctx, - &subsecs); + return formatter::do_format(gmtime(val), ctx, &subsecs); } - return formatter::format( - gmtime(std::chrono::time_point_cast(val)), ctx); + return formatter::format(gmtime(val), ctx); } }; @@ -2120,17 +2156,13 @@ struct formatter, Char> if (period::num != 1 || period::den != 1 || std::is_floating_point::value) { const auto epoch = val.time_since_epoch(); - const auto subsecs = std::chrono::duration_cast( - epoch - std::chrono::duration_cast(epoch)); + const auto subsecs = detail::fmt_duration_cast( + epoch - detail::fmt_duration_cast(epoch)); - return formatter::do_format( - localtime(std::chrono::time_point_cast(val)), - ctx, &subsecs); + return formatter::do_format(localtime(val), ctx, &subsecs); } - return formatter::format( - localtime(std::chrono::time_point_cast(val)), - ctx); + return formatter::format(localtime(val), ctx); } }; #endif diff --git a/src/fmt/color.h b/src/fmt/color.h index 8697e1ca0b..464519e582 100644 --- a/src/fmt/color.h +++ b/src/fmt/color.h @@ -233,7 +233,7 @@ class text_style { FMT_CONSTEXPR text_style(emphasis em = emphasis()) noexcept : set_foreground_color(), set_background_color(), ems(em) {} - FMT_CONSTEXPR text_style& operator|=(const text_style& rhs) { + FMT_CONSTEXPR auto operator|=(const text_style& rhs) -> text_style& { if (!set_foreground_color) { set_foreground_color = rhs.set_foreground_color; foreground_color = rhs.foreground_color; @@ -257,29 +257,29 @@ class text_style { return *this; } - friend FMT_CONSTEXPR text_style operator|(text_style lhs, - const text_style& rhs) { + friend FMT_CONSTEXPR auto operator|(text_style lhs, const text_style& rhs) + -> text_style { return lhs |= rhs; } - FMT_CONSTEXPR bool has_foreground() const noexcept { + FMT_CONSTEXPR auto has_foreground() const noexcept -> bool { return set_foreground_color; } - FMT_CONSTEXPR bool has_background() const noexcept { + FMT_CONSTEXPR auto has_background() const noexcept -> bool { return set_background_color; } - FMT_CONSTEXPR bool has_emphasis() const noexcept { + FMT_CONSTEXPR auto has_emphasis() const noexcept -> bool { return static_cast(ems) != 0; } - FMT_CONSTEXPR detail::color_type get_foreground() const noexcept { + FMT_CONSTEXPR auto get_foreground() const noexcept -> detail::color_type { FMT_ASSERT(has_foreground(), "no foreground specified for this style"); return foreground_color; } - FMT_CONSTEXPR detail::color_type get_background() const noexcept { + FMT_CONSTEXPR auto get_background() const noexcept -> detail::color_type { FMT_ASSERT(has_background(), "no background specified for this style"); return background_color; } - FMT_CONSTEXPR emphasis get_emphasis() const noexcept { + FMT_CONSTEXPR auto get_emphasis() const noexcept -> emphasis { FMT_ASSERT(has_emphasis(), "no emphasis specified for this style"); return ems; } @@ -297,9 +297,11 @@ class text_style { } } - friend FMT_CONSTEXPR text_style fg(detail::color_type foreground) noexcept; + friend FMT_CONSTEXPR auto fg(detail::color_type foreground) noexcept + -> text_style; - friend FMT_CONSTEXPR text_style bg(detail::color_type background) noexcept; + friend FMT_CONSTEXPR auto bg(detail::color_type background) noexcept + -> text_style; detail::color_type foreground_color; detail::color_type background_color; @@ -309,16 +311,19 @@ class text_style { }; /** Creates a text style from the foreground (text) color. */ -FMT_CONSTEXPR inline text_style fg(detail::color_type foreground) noexcept { +FMT_CONSTEXPR inline auto fg(detail::color_type foreground) noexcept + -> text_style { return text_style(true, foreground); } /** Creates a text style from the background color. */ -FMT_CONSTEXPR inline text_style bg(detail::color_type background) noexcept { +FMT_CONSTEXPR inline auto bg(detail::color_type background) noexcept + -> text_style { return text_style(false, background); } -FMT_CONSTEXPR inline text_style operator|(emphasis lhs, emphasis rhs) noexcept { +FMT_CONSTEXPR inline auto operator|(emphasis lhs, emphasis rhs) noexcept + -> text_style { return text_style(lhs) | rhs; } @@ -384,8 +389,8 @@ template struct ansi_color_escape { } FMT_CONSTEXPR operator const Char*() const noexcept { return buffer; } - FMT_CONSTEXPR const Char* begin() const noexcept { return buffer; } - FMT_CONSTEXPR_CHAR_TRAITS const Char* end() const noexcept { + FMT_CONSTEXPR auto begin() const noexcept -> const Char* { return buffer; } + FMT_CONSTEXPR20 auto end() const noexcept -> const Char* { return buffer + std::char_traits::length(buffer); } @@ -400,25 +405,27 @@ template struct ansi_color_escape { out[2] = static_cast('0' + c % 10); out[3] = static_cast(delimiter); } - static FMT_CONSTEXPR bool has_emphasis(emphasis em, emphasis mask) noexcept { + static FMT_CONSTEXPR auto has_emphasis(emphasis em, emphasis mask) noexcept + -> bool { return static_cast(em) & static_cast(mask); } }; template -FMT_CONSTEXPR ansi_color_escape make_foreground_color( - detail::color_type foreground) noexcept { +FMT_CONSTEXPR auto make_foreground_color(detail::color_type foreground) noexcept + -> ansi_color_escape { return ansi_color_escape(foreground, "\x1b[38;2;"); } template -FMT_CONSTEXPR ansi_color_escape make_background_color( - detail::color_type background) noexcept { +FMT_CONSTEXPR auto make_background_color(detail::color_type background) noexcept + -> ansi_color_escape { return ansi_color_escape(background, "\x1b[48;2;"); } template -FMT_CONSTEXPR ansi_color_escape make_emphasis(emphasis em) noexcept { +FMT_CONSTEXPR auto make_emphasis(emphasis em) noexcept + -> ansi_color_escape { return ansi_color_escape(em); } @@ -427,9 +434,10 @@ template inline void reset_color(buffer& buffer) { buffer.append(reset_color.begin(), reset_color.end()); } -template struct styled_arg { +template struct styled_arg : detail::view { const T& value; text_style style; + styled_arg(const T& v, text_style s) : value(v), style(s) {} }; template @@ -510,9 +518,10 @@ void print(const text_style& ts, const S& format_str, const Args&... args) { } template > -inline std::basic_string vformat( +inline auto vformat( const text_style& ts, const S& format_str, - basic_format_args>> args) { + basic_format_args>> args) + -> std::basic_string { basic_memory_buffer buf; detail::vformat_to(buf, ts, detail::to_string_view(format_str), args); return fmt::to_string(buf); @@ -531,8 +540,8 @@ inline std::basic_string vformat( \endrst */ template > -inline std::basic_string format(const text_style& ts, const S& format_str, - const Args&... args) { +inline auto format(const text_style& ts, const S& format_str, + const Args&... args) -> std::basic_string { return fmt::vformat(ts, detail::to_string_view(format_str), fmt::make_format_args>(args...)); } @@ -542,9 +551,10 @@ inline std::basic_string format(const text_style& ts, const S& format_str, */ template ::value)> -OutputIt vformat_to( - OutputIt out, const text_style& ts, basic_string_view format_str, - basic_format_args>> args) { +auto vformat_to(OutputIt out, const text_style& ts, + basic_string_view format_str, + basic_format_args>> args) + -> OutputIt { auto&& buf = detail::get_buffer(out); detail::vformat_to(buf, ts, format_str, args); return detail::get_iterator(buf, out); @@ -562,9 +572,10 @@ OutputIt vformat_to( fmt::emphasis::bold | fg(fmt::color::red), "{}", 42); \endrst */ -template >::value&& - detail::is_string::value> +template < + typename OutputIt, typename S, typename... Args, + bool enable = detail::is_output_iterator>::value && + detail::is_string::value> inline auto format_to(OutputIt out, const text_style& ts, const S& format_str, Args&&... args) -> typename std::enable_if::type { diff --git a/src/fmt/compile.h b/src/fmt/compile.h index af76507f07..71fa69c67e 100644 --- a/src/fmt/compile.h +++ b/src/fmt/compile.h @@ -14,8 +14,8 @@ FMT_BEGIN_NAMESPACE namespace detail { template -FMT_CONSTEXPR inline counting_iterator copy_str(InputIt begin, InputIt end, - counting_iterator it) { +FMT_CONSTEXPR inline auto copy_str(InputIt begin, InputIt end, + counting_iterator it) -> counting_iterator { return it + (end - begin); } @@ -57,7 +57,7 @@ struct udl_compiled_string : compiled_string { #endif template -const T& first(const T& value, const Tail&...) { +auto first(const T& value, const Tail&...) -> const T& { return value; } @@ -489,18 +489,19 @@ FMT_CONSTEXPR OutputIt format_to(OutputIt out, const S&, Args&&... args) { template ::value)> -format_to_n_result format_to_n(OutputIt out, size_t n, - const S& format_str, Args&&... args) { +auto format_to_n(OutputIt out, size_t n, const S& format_str, Args&&... args) + -> format_to_n_result { using traits = detail::fixed_buffer_traits; auto buf = detail::iterator_buffer(out, n); - format_to(std::back_inserter(buf), format_str, std::forward(args)...); + fmt::format_to(std::back_inserter(buf), format_str, + std::forward(args)...); return {buf.out(), buf.count()}; } template ::value)> -FMT_CONSTEXPR20 size_t formatted_size(const S& format_str, - const Args&... args) { +FMT_CONSTEXPR20 auto formatted_size(const S& format_str, const Args&... args) + -> size_t { return fmt::format_to(detail::counting_iterator(), format_str, args...) .count(); } diff --git a/src/fmt/core.h b/src/fmt/core.h index 9f7de781bb..6a53b8c52c 100644 --- a/src/fmt/core.h +++ b/src/fmt/core.h @@ -8,17 +8,15 @@ #ifndef FMT_CORE_H_ #define FMT_CORE_H_ -#include // std::byte -#include // std::FILE -#include // std::strlen -#include -#include -#include // std::addressof -#include -#include +#include // std::byte +#include // std::FILE +#include // std::strlen +#include // CHAR_BIT +#include // std::string +#include // std::enable_if // The fmt library version in the form major * 10000 + minor * 100 + patch. -#define FMT_VERSION 100100 +#define FMT_VERSION 100200 #if defined(__clang__) && !defined(__ibmxl__) # define FMT_CLANG_VERSION (__clang_major__ * 100 + __clang_minor__) @@ -58,6 +56,12 @@ # define FMT_MSC_WARNING(...) #endif +#ifdef _GLIBCXX_RELEASE +# define FMT_GLIBCXX_RELEASE _GLIBCXX_RELEASE +#else +# define FMT_GLIBCXX_RELEASE 0 +#endif + #ifdef _MSVC_LANG # define FMT_CPLUSPLUS _MSVC_LANG #else @@ -88,6 +92,20 @@ #define FMT_HAS_CPP17_ATTRIBUTE(attribute) \ (FMT_CPLUSPLUS >= 201703L && FMT_HAS_CPP_ATTRIBUTE(attribute)) +#ifndef FMT_DEPRECATED +# if FMT_HAS_CPP14_ATTRIBUTE(deprecated) || FMT_MSC_VERSION >= 1900 +# define FMT_DEPRECATED [[deprecated]] +# else +# if (defined(__GNUC__) && !defined(__LCC__)) || defined(__clang__) +# define FMT_DEPRECATED __attribute__((deprecated)) +# elif FMT_MSC_VERSION +# define FMT_DEPRECATED __declspec(deprecated) +# else +# define FMT_DEPRECATED /* deprecated */ +# endif +# endif +#endif + // Check if relaxed C++14 constexpr is supported. // GCC doesn't allow throw in constexpr until version 6 (bug 67371). #ifndef FMT_USE_CONSTEXPR @@ -105,30 +123,17 @@ # define FMT_CONSTEXPR #endif -#if ((FMT_CPLUSPLUS >= 202002L) && \ - (!defined(_GLIBCXX_RELEASE) || _GLIBCXX_RELEASE > 9)) || \ - (FMT_CPLUSPLUS >= 201709L && FMT_GCC_VERSION >= 1002) +#if (FMT_CPLUSPLUS >= 202002L || \ + (FMT_CPLUSPLUS >= 201709L && FMT_GCC_VERSION >= 1002)) && \ + ((!FMT_GLIBCXX_RELEASE || FMT_GLIBCXX_RELEASE >= 10) && \ + (!defined(_LIBCPP_VERSION) || _LIBCPP_VERSION >= 10000) && \ + (!FMT_MSC_VERSION || FMT_MSC_VERSION >= 1928)) && \ + defined(__cpp_lib_is_constant_evaluated) # define FMT_CONSTEXPR20 constexpr #else # define FMT_CONSTEXPR20 #endif -// Check if constexpr std::char_traits<>::{compare,length} are supported. -#if defined(__GLIBCXX__) -# if FMT_CPLUSPLUS >= 201703L && defined(_GLIBCXX_RELEASE) && \ - _GLIBCXX_RELEASE >= 7 // GCC 7+ libstdc++ has _GLIBCXX_RELEASE. -# define FMT_CONSTEXPR_CHAR_TRAITS constexpr -# endif -#elif defined(_LIBCPP_VERSION) && FMT_CPLUSPLUS >= 201703L && \ - _LIBCPP_VERSION >= 4000 -# define FMT_CONSTEXPR_CHAR_TRAITS constexpr -#elif FMT_MSC_VERSION >= 1914 && FMT_CPLUSPLUS >= 201703L -# define FMT_CONSTEXPR_CHAR_TRAITS constexpr -#endif -#ifndef FMT_CONSTEXPR_CHAR_TRAITS -# define FMT_CONSTEXPR_CHAR_TRAITS -#endif - // Check if exceptions are disabled. #ifndef FMT_EXCEPTIONS # if (defined(__GNUC__) && !defined(__EXCEPTIONS)) || \ @@ -191,33 +196,25 @@ # define FMT_END_EXPORT #endif +#if FMT_GCC_VERSION || FMT_CLANG_VERSION +# define FMT_VISIBILITY(value) __attribute__((visibility(value))) +#else +# define FMT_VISIBILITY(value) +#endif + #if !defined(FMT_HEADER_ONLY) && defined(_WIN32) -# ifdef FMT_LIB_EXPORT +# if defined(FMT_LIB_EXPORT) # define FMT_API __declspec(dllexport) # elif defined(FMT_SHARED) # define FMT_API __declspec(dllimport) # endif -#else -# if defined(FMT_LIB_EXPORT) || defined(FMT_SHARED) -# if defined(__GNUC__) || defined(__clang__) -# define FMT_API __attribute__((visibility("default"))) -# endif -# endif +#elif defined(FMT_LIB_EXPORT) || defined(FMT_SHARED) +# define FMT_API FMT_VISIBILITY("default") #endif #ifndef FMT_API # define FMT_API #endif -// libc++ supports string_view in pre-c++17. -#if FMT_HAS_INCLUDE() && \ - (FMT_CPLUSPLUS >= 201703L || defined(_LIBCPP_VERSION)) -# include -# define FMT_USE_STRING_VIEW -#elif FMT_HAS_INCLUDE("experimental/string_view") && FMT_CPLUSPLUS >= 201402L -# include -# define FMT_USE_EXPERIMENTAL_STRING_VIEW -#endif - #ifndef FMT_UNICODE # define FMT_UNICODE !FMT_MSC_VERSION #endif @@ -228,8 +225,9 @@ __apple_build_version__ >= 14000029L) && \ FMT_CPLUSPLUS >= 202002L) || \ (defined(__cpp_consteval) && \ - (!FMT_MSC_VERSION || _MSC_FULL_VER >= 193030704)) -// consteval is broken in MSVC before VS2022 and Apple clang before 14. + (!FMT_MSC_VERSION || FMT_MSC_VERSION >= 1929)) +// consteval is broken in MSVC before VS2019 version 16.10 and Apple clang +// before 14. # define FMT_CONSTEVAL consteval # define FMT_HAS_CONSTEVAL # else @@ -248,6 +246,15 @@ # endif #endif +// GCC < 5 requires this-> in decltype. +#ifndef FMT_DECLTYPE_THIS +# if FMT_GCC_VERSION && FMT_GCC_VERSION < 500 +# define FMT_DECLTYPE_THIS this-> +# else +# define FMT_DECLTYPE_THIS +# endif +#endif + // Enable minimal optimizations for more compact code in debug mode. FMT_GCC_PRAGMA("GCC push_options") #if !defined(__OPTIMIZE__) && !defined(__NVCOMPILER) && !defined(__LCC__) && \ @@ -269,20 +276,57 @@ template using remove_const_t = typename std::remove_const::type; template using remove_cvref_t = typename std::remove_cv>::type; -template struct type_identity { using type = T; }; +template struct type_identity { + using type = T; +}; template using type_identity_t = typename type_identity::type; template using underlying_t = typename std::underlying_type::type; -// Checks whether T is a container with contiguous storage. -template struct is_contiguous : std::false_type {}; -template -struct is_contiguous> : std::true_type {}; +#if FMT_GCC_VERSION && FMT_GCC_VERSION < 500 +// A workaround for gcc 4.8 to make void_t work in a SFINAE context. +template struct void_t_impl { + using type = void; +}; +template using void_t = typename void_t_impl::type; +#else +template using void_t = void; +#endif struct monostate { constexpr monostate() {} }; +// An implementation of back_insert_iterator to avoid dependency on . +template class back_insert_iterator { + private: + Container* container_; + + friend auto get_container(back_insert_iterator it) -> Container& { + return *it.container_; + } + + public: + using difference_type = ptrdiff_t; + FMT_UNCHECKED_ITERATOR(back_insert_iterator); + + explicit back_insert_iterator(Container& c) : container_(&c) {} + + auto operator=(const typename Container::value_type& value) + -> back_insert_iterator& { + container_->push_back(value); + return *this; + } + auto operator*() -> back_insert_iterator& { return *this; } + auto operator++() -> back_insert_iterator& { return *this; } + auto operator++(int) -> back_insert_iterator { return *this; } +}; + +template +auto back_inserter(Container& c) -> back_insert_iterator { + return {c}; +} + // An enable_if helper to be used in template parameters which results in much // shorter symbols: https://godbolt.org/z/sWw4vP. Extra parentheses are needed // to workaround a bug in MSVC 2019 (see #1140 and #1186). @@ -310,10 +354,9 @@ template FMT_CONSTEXPR void ignore_unused(const T&...) {} constexpr FMT_INLINE auto is_constant_evaluated( bool default_value = false) noexcept -> bool { // Workaround for incompatibility between libstdc++ consteval-based -// std::is_constant_evaluated() implementation and clang-14. -// https://github.com/fmtlib/fmt/issues/3247 -#if FMT_CPLUSPLUS >= 202002L && defined(_GLIBCXX_RELEASE) && \ - _GLIBCXX_RELEASE >= 12 && \ +// std::is_constant_evaluated() implementation and clang-14: +// https://github.com/fmtlib/fmt/issues/3247. +#if FMT_CPLUSPLUS >= 202002L && FMT_GLIBCXX_RELEASE >= 12 && \ (FMT_CLANG_VERSION >= 1400 && FMT_CLANG_VERSION < 1500) ignore_unused(default_value); return __builtin_is_constant_evaluated(); @@ -346,15 +389,6 @@ FMT_NORETURN FMT_API void assert_fail(const char* file, int line, # endif #endif -#if defined(FMT_USE_STRING_VIEW) -template using std_string_view = std::basic_string_view; -#elif defined(FMT_USE_EXPERIMENTAL_STRING_VIEW) -template -using std_string_view = std::experimental::basic_string_view; -#else -template struct std_string_view {}; -#endif - #ifdef FMT_USE_INT128 // Do nothing. #elif defined(__SIZEOF_INT128__) && !defined(__NVCC__) && \ @@ -386,6 +420,15 @@ FMT_CONSTEXPR auto to_unsigned(Int value) -> return static_cast::type>(value); } +template +struct is_string_like : std::false_type {}; + +// A heuristic to detect std::string and std::string_view. +template +struct is_string_like().find_first_of( + typename T::value_type(), 0))>> : std::true_type { +}; + FMT_CONSTEXPR inline auto is_utf8() -> bool { FMT_MSC_WARNING(suppress : 4566) constexpr unsigned char section[] = "\u00A7"; @@ -394,8 +437,33 @@ FMT_CONSTEXPR inline auto is_utf8() -> bool { return FMT_UNICODE || (sizeof(section) == 3 && uchar(section[0]) == 0xC2 && uchar(section[1]) == 0xA7); } + +template FMT_CONSTEXPR auto length(const Char* s) -> size_t { + size_t len = 0; + while (*s++) ++len; + return len; +} + +template +FMT_CONSTEXPR auto compare(const Char* s1, const Char* s2, std::size_t n) + -> int { + for (; n != 0; ++s1, ++s2, --n) { + if (*s1 < *s2) return -1; + if (*s1 > *s2) return 1; + } + return 0; +} } // namespace detail +template +using basic_string = + std::basic_string, std::allocator>; + +// Checks whether T is a container with contiguous storage. +template struct is_contiguous : std::false_type {}; +template +struct is_contiguous> : std::true_type {}; + /** An implementation of ``std::basic_string_view`` for pre-C++17. It provides a subset of the API. ``fmt::basic_string_view`` is used for format strings even @@ -420,29 +488,25 @@ template class basic_string_view { : data_(s), size_(count) {} /** - \rst - Constructs a string reference object from a C string computing - the size with ``std::char_traits::length``. - \endrst + Constructs a string reference object from a C string. */ - FMT_CONSTEXPR_CHAR_TRAITS + FMT_CONSTEXPR20 FMT_INLINE basic_string_view(const Char* s) : data_(s), size_(detail::const_check(std::is_same::value && - !detail::is_constant_evaluated(true)) + !detail::is_constant_evaluated(false)) ? std::strlen(reinterpret_cast(s)) - : std::char_traits::length(s)) {} + : detail::length(s)) {} - /** Constructs a string reference from a ``std::basic_string`` object. */ - template - FMT_CONSTEXPR basic_string_view( - const std::basic_string& s) noexcept - : data_(s.data()), size_(s.size()) {} - - template >::value)> - FMT_CONSTEXPR basic_string_view(S s) noexcept + /** + Constructs a string reference from a ``std::basic_string`` or a + ``std::basic_string_view`` object. + */ + template ::value&& std::is_same< + typename S::value_type, Char>::value)> + FMT_CONSTEXPR basic_string_view(const S& s) noexcept : data_(s.data()), size_(s.size()) {} /** Returns a pointer to the string data. */ @@ -463,30 +527,28 @@ template class basic_string_view { size_ -= n; } - FMT_CONSTEXPR_CHAR_TRAITS bool starts_with( - basic_string_view sv) const noexcept { - return size_ >= sv.size_ && - std::char_traits::compare(data_, sv.data_, sv.size_) == 0; + FMT_CONSTEXPR auto starts_with(basic_string_view sv) const noexcept + -> bool { + return size_ >= sv.size_ && detail::compare(data_, sv.data_, sv.size_) == 0; } - FMT_CONSTEXPR_CHAR_TRAITS bool starts_with(Char c) const noexcept { - return size_ >= 1 && std::char_traits::eq(*data_, c); + FMT_CONSTEXPR auto starts_with(Char c) const noexcept -> bool { + return size_ >= 1 && *data_ == c; } - FMT_CONSTEXPR_CHAR_TRAITS bool starts_with(const Char* s) const { + FMT_CONSTEXPR auto starts_with(const Char* s) const -> bool { return starts_with(basic_string_view(s)); } // Lexicographically compare this string reference to other. - FMT_CONSTEXPR_CHAR_TRAITS auto compare(basic_string_view other) const -> int { + FMT_CONSTEXPR auto compare(basic_string_view other) const -> int { size_t str_size = size_ < other.size_ ? size_ : other.size_; - int result = std::char_traits::compare(data_, other.data_, str_size); + int result = detail::compare(data_, other.data_, str_size); if (result == 0) result = size_ == other.size_ ? 0 : (size_ < other.size_ ? -1 : 1); return result; } - FMT_CONSTEXPR_CHAR_TRAITS friend auto operator==(basic_string_view lhs, - basic_string_view rhs) - -> bool { + FMT_CONSTEXPR friend auto operator==(basic_string_view lhs, + basic_string_view rhs) -> bool { return lhs.compare(rhs) == 0; } friend auto operator!=(basic_string_view lhs, basic_string_view rhs) -> bool { @@ -526,21 +588,16 @@ template ::value)> FMT_INLINE auto to_string_view(const Char* s) -> basic_string_view { return s; } -template -inline auto to_string_view(const std::basic_string& s) - -> basic_string_view { - return s; +template ::value)> +inline auto to_string_view(const S& s) + -> basic_string_view { + return s; // std::basic_string[_view] } template constexpr auto to_string_view(basic_string_view s) -> basic_string_view { return s; } -template >::value)> -inline auto to_string_view(std_string_view s) -> basic_string_view { - return s; -} template ::value)> constexpr auto to_string_view(const S& s) -> basic_string_view { @@ -609,10 +666,10 @@ FMT_TYPE_CONSTANT(const Char*, cstring_type); FMT_TYPE_CONSTANT(basic_string_view, string_type); FMT_TYPE_CONSTANT(const void*, pointer_type); -constexpr bool is_integral_type(type t) { +constexpr auto is_integral_type(type t) -> bool { return t > type::none_type && t <= type::last_integer_type; } -constexpr bool is_arithmetic_type(type t) { +constexpr auto is_arithmetic_type(type t) -> bool { return t > type::none_type && t <= type::last_numeric_type; } @@ -635,21 +692,10 @@ enum { cstring_set = set(type::cstring_type), pointer_set = set(type::pointer_type) }; - -FMT_NORETURN FMT_API void throw_format_error(const char* message); - -struct error_handler { - constexpr error_handler() = default; - - // This function is intentionally not constexpr to give a compile-time error. - FMT_NORETURN void on_error(const char* message) { - throw_format_error(message); - } -}; } // namespace detail /** Throws ``format_error`` with a given message. */ -using detail::throw_format_error; +FMT_NORETURN FMT_API void throw_format_error(const char* message); /** String's character type. */ template using char_t = typename detail::char_t_impl::type; @@ -701,7 +747,7 @@ template class basic_format_parse_context { */ FMT_CONSTEXPR auto next_arg_id() -> int { if (next_arg_id_ < 0) { - detail::throw_format_error( + throw_format_error( "cannot switch from manual to automatic argument indexing"); return 0; } @@ -716,7 +762,7 @@ template class basic_format_parse_context { */ FMT_CONSTEXPR void check_arg_id(int id) { if (next_arg_id_ > 0) { - detail::throw_format_error( + throw_format_error( "cannot switch from automatic to manual argument indexing"); return; } @@ -769,35 +815,6 @@ class compile_parse_context : public basic_format_parse_context { } }; -// Extracts a reference to the container from back_insert_iterator. -template -inline auto get_container(std::back_insert_iterator it) - -> Container& { - using base = std::back_insert_iterator; - struct accessor : base { - accessor(base b) : base(b) {} - using base::container; - }; - return *accessor(it).container; -} - -template -FMT_CONSTEXPR auto copy_str(InputIt begin, InputIt end, OutputIt out) - -> OutputIt { - while (begin != end) *out++ = static_cast(*begin++); - return out; -} - -template , U>::value&& is_char::value)> -FMT_CONSTEXPR auto copy_str(T* begin, T* end, U* out) -> U* { - if (is_constant_evaluated()) return copy_str(begin, end, out); - auto size = to_unsigned(end - begin); - if (size > 0) memcpy(out, begin, size * sizeof(U)); - return out + size; -} - /** \rst A contiguous memory buffer with an optional growing ability. It is an internal @@ -810,13 +827,18 @@ template class buffer { size_t size_; size_t capacity_; + using grow_fun = void (*)(buffer& buf, size_t capacity); + grow_fun grow_; + protected: // Don't initialize ptr_ since it is not accessed to save a few cycles. FMT_MSC_WARNING(suppress : 26495) - buffer(size_t sz) noexcept : size_(sz), capacity_(sz) {} + FMT_CONSTEXPR buffer(grow_fun grow, size_t sz) noexcept + : size_(sz), capacity_(sz), grow_(grow) {} - FMT_CONSTEXPR20 buffer(T* p = nullptr, size_t sz = 0, size_t cap = 0) noexcept - : ptr_(p), size_(sz), capacity_(cap) {} + FMT_CONSTEXPR20 buffer(grow_fun grow, T* p = nullptr, size_t sz = 0, + size_t cap = 0) noexcept + : ptr_(p), size_(sz), capacity_(cap), grow_(grow) {} FMT_CONSTEXPR20 ~buffer() = default; buffer(buffer&&) = default; @@ -827,9 +849,6 @@ template class buffer { capacity_ = buf_capacity; } - /** Increases the buffer capacity to hold at least *capacity* elements. */ - virtual FMT_CONSTEXPR20 void grow(size_t capacity) = 0; - public: using value_type = T; using const_reference = const T&; @@ -868,7 +887,7 @@ template class buffer { // for at least one additional element either by increasing the capacity or by // flushing the buffer if it is full. FMT_CONSTEXPR20 void try_reserve(size_t new_capacity) { - if (new_capacity > capacity_) grow(new_capacity); + if (new_capacity > capacity_) grow_(*this, new_capacity); } FMT_CONSTEXPR20 void push_back(const T& value) { @@ -917,22 +936,25 @@ class iterator_buffer final : public Traits, public buffer { enum { buffer_size = 256 }; T data_[buffer_size]; - protected: - FMT_CONSTEXPR20 void grow(size_t) override { - if (this->size() == buffer_size) flush(); + static FMT_CONSTEXPR20 void grow(buffer& buf, size_t) { + if (buf.size() == buffer_size) static_cast(buf).flush(); } void flush() { auto size = this->size(); this->clear(); - out_ = copy_str(data_, data_ + this->limit(size), out_); + const T* begin = data_; + const T* end = begin + this->limit(size); + while (begin != end) *out_++ = *begin++; } public: explicit iterator_buffer(OutputIt out, size_t n = buffer_size) - : Traits(n), buffer(data_, 0, buffer_size), out_(out) {} + : Traits(n), buffer(grow, data_, 0, buffer_size), out_(out) {} iterator_buffer(iterator_buffer&& other) - : Traits(other), buffer(data_, 0, buffer_size), out_(other.out_) {} + : Traits(other), + buffer(grow, data_, 0, buffer_size), + out_(other.out_) {} ~iterator_buffer() { flush(); } auto out() -> OutputIt { @@ -951,9 +973,9 @@ class iterator_buffer final enum { buffer_size = 256 }; T data_[buffer_size]; - protected: - FMT_CONSTEXPR20 void grow(size_t) override { - if (this->size() == this->capacity()) flush(); + static FMT_CONSTEXPR20 void grow(buffer& buf, size_t) { + if (buf.size() == buf.capacity()) + static_cast(buf).flush(); } void flush() { @@ -967,10 +989,10 @@ class iterator_buffer final public: explicit iterator_buffer(T* out, size_t n = buffer_size) - : fixed_buffer_traits(n), buffer(out, 0, n), out_(out) {} + : fixed_buffer_traits(n), buffer(grow, out, 0, n), out_(out) {} iterator_buffer(iterator_buffer&& other) : fixed_buffer_traits(other), - buffer(std::move(other)), + buffer(static_cast(other)), out_(other.out_) { if (this->data() != out_) { this->set(data_, buffer_size); @@ -989,38 +1011,37 @@ class iterator_buffer final }; template class iterator_buffer final : public buffer { - protected: - FMT_CONSTEXPR20 void grow(size_t) override {} - public: - explicit iterator_buffer(T* out, size_t = 0) : buffer(out, 0, ~size_t()) {} + explicit iterator_buffer(T* out, size_t = 0) + : buffer([](buffer&, size_t) {}, out, 0, ~size_t()) {} auto out() -> T* { return &*this->end(); } }; // A buffer that writes to a container with the contiguous storage. template -class iterator_buffer, +class iterator_buffer, enable_if_t::value, typename Container::value_type>> final : public buffer { private: + using value_type = typename Container::value_type; Container& container_; - protected: - FMT_CONSTEXPR20 void grow(size_t capacity) override { - container_.resize(capacity); - this->set(&container_[0], capacity); + static FMT_CONSTEXPR20 void grow(buffer& buf, size_t capacity) { + auto& self = static_cast(buf); + self.container_.resize(capacity); + self.set(&self.container_[0], capacity); } public: explicit iterator_buffer(Container& c) - : buffer(c.size()), container_(c) {} - explicit iterator_buffer(std::back_insert_iterator out, size_t = 0) + : buffer(grow, c.size()), container_(c) {} + explicit iterator_buffer(back_insert_iterator out, size_t = 0) : iterator_buffer(get_container(out)) {} - auto out() -> std::back_insert_iterator { - return std::back_inserter(container_); + auto out() -> back_insert_iterator { + return fmt::back_inserter(container_); } }; @@ -1031,15 +1052,14 @@ template class counting_buffer final : public buffer { T data_[buffer_size]; size_t count_ = 0; - protected: - FMT_CONSTEXPR20 void grow(size_t) override { - if (this->size() != buffer_size) return; - count_ += this->size(); - this->clear(); + static FMT_CONSTEXPR20 void grow(buffer& buf, size_t) { + if (buf.size() != buffer_size) return; + static_cast(buf).count_ += buf.size(); + buf.clear(); } public: - counting_buffer() : buffer(data_, 0, buffer_size) {} + counting_buffer() : buffer(grow, data_, 0, buffer_size) {} auto count() -> size_t { return count_ + this->size(); } }; @@ -1053,7 +1073,7 @@ FMT_CONSTEXPR void basic_format_parse_context::do_check_arg_id(int id) { (!FMT_GCC_VERSION || FMT_GCC_VERSION >= 1200)) { using context = detail::compile_parse_context; if (id >= static_cast(this)->num_args()) - detail::throw_format_error("argument not found"); + throw_format_error("argument not found"); } } @@ -1085,18 +1105,29 @@ template using has_formatter = std::is_constructible>; -// An output iterator that appends to a buffer. -// It is used to reduce symbol sizes for the common case. -class appender : public std::back_insert_iterator> { - using base = std::back_insert_iterator>; +// An output iterator that appends to a buffer. It is used instead of +// back_insert_iterator to reduce symbol sizes for the common case. +class appender { + private: + detail::buffer* buffer_; + + friend auto get_container(appender app) -> detail::buffer& { + return *app.buffer_; + } public: - using std::back_insert_iterator>::back_insert_iterator; - appender(base it) noexcept : base(it) {} + using difference_type = ptrdiff_t; FMT_UNCHECKED_ITERATOR(appender); - auto operator++() noexcept -> appender& { return *this; } - auto operator++(int) noexcept -> appender { return *this; } + appender(detail::buffer& buf) : buffer_(&buf) {} + + auto operator=(char c) -> appender& { + buffer_->push_back(c); + return *this; + } + auto operator*() -> appender& { return *this; } + auto operator++() -> appender& { return *this; } + auto operator++(int) -> appender { return *this; } }; namespace detail { @@ -1119,7 +1150,7 @@ constexpr auto has_const_formatter() -> bool { template using buffer_appender = conditional_t::value, appender, - std::back_insert_iterator>>; + back_insert_iterator>>; // Maps an output iterator to a buffer. template @@ -1128,7 +1159,7 @@ auto get_buffer(OutputIt out) -> iterator_buffer { } template , Buf>::value)> -auto get_buffer(std::back_insert_iterator out) -> buffer& { +auto get_buffer(back_insert_iterator out) -> buffer& { return get_container(out); } @@ -1293,7 +1324,13 @@ template class value { template FMT_CONSTEXPR20 FMT_INLINE value(T& val) { using value_type = remove_const_t; - custom.value = const_cast(std::addressof(val)); + // T may overload operator& e.g. std::vector::reference in libc++. +#ifdef __cpp_if_constexpr + if constexpr (std::is_same::value) + custom.value = const_cast(&val); +#endif + if (!is_constant_evaluated()) + custom.value = const_cast(&reinterpret_cast(val)); // Get the formatter type through the context to allow different contexts // have different extension points, e.g. `formatter` for `format` and // `printf_formatter` for `printf`. @@ -1314,6 +1351,7 @@ template class value { parse_ctx.advance_to(f.parse(parse_ctx)); using qualified_type = conditional_t(), const T, T>; + // Calling format through a mutable reference is deprecated. ctx.advance_to(f.format(*static_cast(arg), ctx)); } }; @@ -1327,7 +1365,7 @@ using ulong_type = conditional_t; template struct format_as_result { template ::value || std::is_class::value)> - static auto map(U*) -> decltype(format_as(std::declval())); + static auto map(U*) -> remove_cvref_t()))>; static auto map(...) -> void; using type = decltype(map(static_cast(nullptr))); @@ -1444,7 +1482,8 @@ template struct arg_mapper { // Only map owning types because mapping views can be unsafe. template , FMT_ENABLE_IF(std::is_arithmetic::value)> - FMT_CONSTEXPR FMT_INLINE auto map(const T& val) -> decltype(this->map(U())) { + FMT_CONSTEXPR FMT_INLINE auto map(const T& val) + -> decltype(FMT_DECLTYPE_THIS map(U())) { return map(format_as(val)); } @@ -1468,13 +1507,14 @@ template struct arg_mapper { !is_string::value && !is_char::value && !is_named_arg::value && !std::is_arithmetic>::value)> - FMT_CONSTEXPR FMT_INLINE auto map(T& val) -> decltype(this->do_map(val)) { + FMT_CONSTEXPR FMT_INLINE auto map(T& val) + -> decltype(FMT_DECLTYPE_THIS do_map(val)) { return do_map(val); } template ::value)> FMT_CONSTEXPR FMT_INLINE auto map(const T& named_arg) - -> decltype(this->map(named_arg.value)) { + -> decltype(FMT_DECLTYPE_THIS map(named_arg.value)) { return map(named_arg.value); } @@ -1493,45 +1533,19 @@ enum { max_packed_args = 62 / packed_arg_bits }; enum : unsigned long long { is_unpacked_bit = 1ULL << 63 }; enum : unsigned long long { has_named_args_bit = 1ULL << 62 }; -template -auto copy_str(InputIt begin, InputIt end, appender out) -> appender { - get_container(out).append(begin, end); - return out; -} -template -auto copy_str(InputIt begin, InputIt end, - std::back_insert_iterator out) - -> std::back_insert_iterator { - get_container(out).append(begin, end); - return out; -} - -template -FMT_CONSTEXPR auto copy_str(R&& rng, OutputIt out) -> OutputIt { - return detail::copy_str(rng.begin(), rng.end(), out); -} - -#if FMT_GCC_VERSION && FMT_GCC_VERSION < 500 -// A workaround for gcc 4.8 to make void_t work in a SFINAE context. -template struct void_t_impl { using type = void; }; -template using void_t = typename void_t_impl::type; -#else -template using void_t = void; -#endif - template struct is_output_iterator : std::false_type {}; +template <> struct is_output_iterator : std::true_type {}; + template struct is_output_iterator< - It, T, - void_t::iterator_category, - decltype(*std::declval() = std::declval())>> + It, T, void_t()++ = std::declval())>> : std::true_type {}; template struct is_back_insert_iterator : std::false_type {}; template -struct is_back_insert_iterator> +struct is_back_insert_iterator> : std::true_type {}; // A type-erased reference to an std::locale to avoid a heavy include. @@ -1607,8 +1621,8 @@ FMT_CONSTEXPR inline auto make_arg(T& val) -> basic_format_arg { } // namespace detail FMT_BEGIN_EXPORT -// A formatting argument. It is a trivially copyable/constructible type to -// allow storage in basic_memory_buffer. +// A formatting argument. Context is a template parameter for the compiled API +// where output can be unbuffered. template class basic_format_arg { private: detail::value value_; @@ -1618,11 +1632,6 @@ template class basic_format_arg { friend FMT_CONSTEXPR auto detail::make_arg(T& value) -> basic_format_arg; - template - friend FMT_CONSTEXPR auto visit_format_arg(Visitor&& vis, - const basic_format_arg& arg) - -> decltype(vis(0)); - friend class basic_format_args; friend class dynamic_format_arg_store; @@ -1660,55 +1669,68 @@ template class basic_format_arg { auto is_arithmetic() const -> bool { return detail::is_arithmetic_type(type_); } + + /** + \rst + Visits an argument dispatching to the appropriate visit method based on + the argument type. For example, if the argument type is ``double`` then + ``vis(value)`` will be called with the value of type ``double``. + \endrst + */ + template + FMT_CONSTEXPR auto visit(Visitor&& vis) -> decltype(vis(0)) { + switch (type_) { + case detail::type::none_type: + break; + case detail::type::int_type: + return vis(value_.int_value); + case detail::type::uint_type: + return vis(value_.uint_value); + case detail::type::long_long_type: + return vis(value_.long_long_value); + case detail::type::ulong_long_type: + return vis(value_.ulong_long_value); + case detail::type::int128_type: + return vis(detail::convert_for_visit(value_.int128_value)); + case detail::type::uint128_type: + return vis(detail::convert_for_visit(value_.uint128_value)); + case detail::type::bool_type: + return vis(value_.bool_value); + case detail::type::char_type: + return vis(value_.char_value); + case detail::type::float_type: + return vis(value_.float_value); + case detail::type::double_type: + return vis(value_.double_value); + case detail::type::long_double_type: + return vis(value_.long_double_value); + case detail::type::cstring_type: + return vis(value_.string.data); + case detail::type::string_type: + using sv = basic_string_view; + return vis(sv(value_.string.data, value_.string.size)); + case detail::type::pointer_type: + return vis(value_.pointer); + case detail::type::custom_type: + return vis(typename basic_format_arg::handle(value_.custom)); + } + return vis(monostate()); + } + + FMT_INLINE auto format_custom(const char_type* parse_begin, + typename Context::parse_context_type& parse_ctx, + Context& ctx) -> bool { + if (type_ != detail::type::custom_type) return false; + parse_ctx.advance_to(parse_begin); + value_.custom.format(value_.custom.value, parse_ctx, ctx); + return true; + } }; -/** - \rst - Visits an argument dispatching to the appropriate visit method based on - the argument type. For example, if the argument type is ``double`` then - ``vis(value)`` will be called with the value of type ``double``. - \endrst - */ -// DEPRECATED! template -FMT_CONSTEXPR FMT_INLINE auto visit_format_arg( +FMT_DEPRECATED FMT_CONSTEXPR FMT_INLINE auto visit_format_arg( Visitor&& vis, const basic_format_arg& arg) -> decltype(vis(0)) { - switch (arg.type_) { - case detail::type::none_type: - break; - case detail::type::int_type: - return vis(arg.value_.int_value); - case detail::type::uint_type: - return vis(arg.value_.uint_value); - case detail::type::long_long_type: - return vis(arg.value_.long_long_value); - case detail::type::ulong_long_type: - return vis(arg.value_.ulong_long_value); - case detail::type::int128_type: - return vis(detail::convert_for_visit(arg.value_.int128_value)); - case detail::type::uint128_type: - return vis(detail::convert_for_visit(arg.value_.uint128_value)); - case detail::type::bool_type: - return vis(arg.value_.bool_value); - case detail::type::char_type: - return vis(arg.value_.char_value); - case detail::type::float_type: - return vis(arg.value_.float_value); - case detail::type::double_type: - return vis(arg.value_.double_value); - case detail::type::long_double_type: - return vis(arg.value_.long_double_value); - case detail::type::cstring_type: - return vis(arg.value_.string.data); - case detail::type::string_type: - using sv = basic_string_view; - return vis(sv(arg.value_.string.data, arg.value_.string.size)); - case detail::type::pointer_type: - return vis(arg.value_.pointer); - case detail::type::custom_type: - return vis(typename basic_format_arg::handle(arg.value_.custom)); - } - return vis(monostate()); + return arg.visit(std::forward(vis)); } // Formatting context. @@ -1748,8 +1770,8 @@ template class basic_format_context { } auto args() const -> const format_args& { return args_; } - FMT_CONSTEXPR auto error_handler() -> detail::error_handler { return {}; } - void on_error(const char* message) { error_handler().on_error(message); } + // This function is intentionally not constexpr to give a compile-time error. + void on_error(const char* message) { throw_format_error(message); } // Returns an iterator to the beginning of the output range. FMT_CONSTEXPR auto out() -> iterator { return out_; } @@ -1831,7 +1853,7 @@ class format_arg_store // Arguments are taken by lvalue references to avoid some lifetime issues. template constexpr auto make_format_args(T&... args) - -> format_arg_store...> { + -> format_arg_store...> { return {args...}; } @@ -2107,11 +2129,8 @@ struct dynamic_format_specs : format_specs { }; // Converts a character to ASCII. Returns '\0' on conversion failure. -template ::value)> -constexpr auto to_ascii(Char c) -> char { - return c <= 0xff ? static_cast(c) : '\0'; -} -template ::value)> +template ::value || + std::is_enum::value)> constexpr auto to_ascii(Char c) -> char { return c <= 0xff ? static_cast(c) : '\0'; } @@ -2156,11 +2175,11 @@ FMT_CONSTEXPR auto parse_nonnegative_int(const Char*& begin, const Char* end, } while (p != end && '0' <= *p && *p <= '9'); auto num_digits = p - begin; begin = p; - if (num_digits <= std::numeric_limits::digits10) - return static_cast(value); + int digits10 = static_cast(sizeof(int) * CHAR_BIT * 3 / 10); + if (num_digits <= digits10) return static_cast(value); // Check for overflow. - const unsigned max = to_unsigned((std::numeric_limits::max)()); - return num_digits == std::numeric_limits::digits10 + 1 && + unsigned max = INT_MAX; + return num_digits == digits10 + 1 && prev * 10ull + unsigned(p[-1] - '0') <= max ? static_cast(value) : error_value; @@ -2188,9 +2207,8 @@ FMT_CONSTEXPR auto do_parse_arg_id(const Char* begin, const Char* end, Char c = *begin; if (c >= '0' && c <= '9') { int index = 0; - constexpr int max = (std::numeric_limits::max)(); if (c != '0') - index = parse_nonnegative_int(begin, end, max); + index = parse_nonnegative_int(begin, end, INT_MAX); else ++begin; if (begin == end || (*begin != '}' && *begin != ':')) @@ -2309,9 +2327,12 @@ FMT_CONSTEXPR FMT_INLINE auto parse_format_specs( dynamic_format_specs& specs; type arg_type; - FMT_CONSTEXPR auto operator()(pres type, int set) -> const Char* { - if (!in(arg_type, set)) throw_format_error("invalid format specifier"); - specs.type = type; + FMT_CONSTEXPR auto operator()(pres pres_type, int set) -> const Char* { + if (!in(arg_type, set)) { + if (arg_type == type::none_type) return begin; + throw_format_error("invalid format specifier"); + } + specs.type = pres_type; return begin + 1; } } parse_presentation_type{begin, specs, arg_type}; @@ -2328,6 +2349,7 @@ FMT_CONSTEXPR FMT_INLINE auto parse_format_specs( case '+': case '-': case ' ': + if (arg_type == type::none_type) return begin; enter_state(state::sign, in(arg_type, sint_set | float_set)); switch (c) { case '+': @@ -2343,14 +2365,17 @@ FMT_CONSTEXPR FMT_INLINE auto parse_format_specs( ++begin; break; case '#': + if (arg_type == type::none_type) return begin; enter_state(state::hash, is_arithmetic_type(arg_type)); specs.alt = true; ++begin; break; case '0': enter_state(state::zero); - if (!is_arithmetic_type(arg_type)) + if (!is_arithmetic_type(arg_type)) { + if (arg_type == type::none_type) return begin; throw_format_error("format specifier requires numeric argument"); + } if (specs.align == align::none) { // Ignore 0 if align is specified for compatibility with std::format. specs.align = align::numeric; @@ -2372,12 +2397,14 @@ FMT_CONSTEXPR FMT_INLINE auto parse_format_specs( begin = parse_dynamic_spec(begin, end, specs.width, specs.width_ref, ctx); break; case '.': + if (arg_type == type::none_type) return begin; enter_state(state::precision, in(arg_type, float_set | string_set | cstring_set)); begin = parse_precision(begin, end, specs.precision, specs.precision_ref, ctx); break; case 'L': + if (arg_type == type::none_type) return begin; enter_state(state::locale, is_arithmetic_type(arg_type)); specs.localized = true; ++begin; @@ -2411,6 +2438,8 @@ FMT_CONSTEXPR FMT_INLINE auto parse_format_specs( case 'G': return parse_presentation_type(pres::general_upper, float_set); case 'c': + if (arg_type == type::bool_type) + throw_format_error("invalid format specifier"); return parse_presentation_type(pres::chr, integral_set); case 's': return parse_presentation_type(pres::string, @@ -2550,9 +2579,9 @@ FMT_CONSTEXPR auto parse_format_specs(ParseContext& ctx) decltype(arg_mapper().map(std::declval())), typename strip_named_arg::type>; // LAMMPS customization. Fails to compile with (some) Intel compilers -#if defined(__cpp_if_constexpr) && 0 - if constexpr (std::is_default_constructible_v< - formatter>) { +#if defined(__cpp_if_constexpr) && 1 + if constexpr (std::is_default_constructible< + formatter>::value) { return formatter().parse(ctx); } else { type_is_unformattable_for _; @@ -2675,9 +2704,11 @@ void check_format_string(S format_str) { template struct vformat_args { using type = basic_format_args< - basic_format_context>, Char>>; + basic_format_context>, Char>>; +}; +template <> struct vformat_args { + using type = format_args; }; -template <> struct vformat_args { using type = format_args; }; // Use vformat_args and avoid type_identity to keep symbols short. template @@ -2779,7 +2810,7 @@ using format_string = basic_format_string...>; inline auto runtime(string_view s) -> runtime_format_string<> { return {{s}}; } #endif -FMT_API auto vformat(string_view fmt, format_args args) -> std::string; +FMT_API auto vformat(string_view fmt, format_args args) -> basic_string; /** \rst @@ -2794,7 +2825,7 @@ FMT_API auto vformat(string_view fmt, format_args args) -> std::string; */ template FMT_NODISCARD FMT_INLINE auto format(format_string fmt, T&&... args) - -> std::string { + -> basic_string { return vformat(fmt, fmt::make_format_args(args...)); } @@ -2816,7 +2847,7 @@ auto vformat_to(OutputIt out, string_view fmt, format_args args) -> OutputIt { **Example**:: auto out = std::vector(); - fmt::format_to(std::back_inserter(out), "{}", 42); + fmt::format_to(fmt::back_inserter(out), "{}", 42); \endrst */ template #endif -#ifdef _WIN32 +#if defined(_WIN32) && !defined(FMT_WINDOWS_NO_WCHAR) # include // _isatty #endif @@ -36,10 +36,6 @@ FMT_FUNC void assert_fail(const char* file, int line, const char* message) { std::terminate(); } -FMT_FUNC void throw_format_error(const char* message) { - FMT_THROW(format_error(message)); -} - FMT_FUNC void format_error_code(detail::buffer& out, int error_code, string_view message) noexcept { // Report error code making sure that the output fits into @@ -58,8 +54,8 @@ FMT_FUNC void format_error_code(detail::buffer& out, int error_code, error_code_size += detail::to_unsigned(detail::count_digits(abs_value)); auto it = buffer_appender(out); if (message.size() <= inline_buffer_size - error_code_size) - format_to(it, FMT_STRING("{}{}"), message, SEP); - format_to(it, FMT_STRING("{}{}"), ERROR_STR, error_code); + fmt::format_to(it, FMT_STRING("{}{}"), message, SEP); + fmt::format_to(it, FMT_STRING("{}{}"), ERROR_STR, error_code); FMT_ASSERT(out.size() <= inline_buffer_size, ""); } @@ -73,9 +69,8 @@ FMT_FUNC void report_error(format_func func, int error_code, } // A wrapper around fwrite that throws on error. -inline void fwrite_fully(const void* ptr, size_t size, size_t count, - FILE* stream) { - size_t written = std::fwrite(ptr, size, count, stream); +inline void fwrite_fully(const void* ptr, size_t count, FILE* stream) { + size_t written = std::fwrite(ptr, 1, count, stream); if (written < count) FMT_THROW(system_error(errno, FMT_STRING("cannot write to file"))); } @@ -86,7 +81,7 @@ locale_ref::locale_ref(const Locale& loc) : locale_(&loc) { static_assert(std::is_same::value, ""); } -template Locale locale_ref::get() const { +template auto locale_ref::get() const -> Locale { static_assert(std::is_same::value, ""); return locale_ ? *static_cast(locale_) : std::locale(); } @@ -98,7 +93,8 @@ FMT_FUNC auto thousands_sep_impl(locale_ref loc) -> thousands_sep_result { auto thousands_sep = grouping.empty() ? Char() : facet.thousands_sep(); return {std::move(grouping), thousands_sep}; } -template FMT_FUNC Char decimal_point_impl(locale_ref loc) { +template +FMT_FUNC auto decimal_point_impl(locale_ref loc) -> Char { return std::use_facet>(loc.get()) .decimal_point(); } @@ -127,6 +123,10 @@ FMT_FUNC auto write_loc(appender out, loc_value value, } } // namespace detail +FMT_FUNC void throw_format_error(const char* message) { + FMT_THROW(format_error(message)); +} + template typename Locale::id format_facet::id; #ifndef FMT_STATIC_THOUSANDS_SEPARATOR @@ -144,24 +144,25 @@ FMT_API FMT_FUNC auto format_facet::do_put( } #endif -FMT_FUNC std::system_error vsystem_error(int error_code, string_view fmt, - format_args args) { +FMT_FUNC auto vsystem_error(int error_code, string_view fmt, format_args args) + -> std::system_error { auto ec = std::error_code(error_code, std::generic_category()); return std::system_error(ec, vformat(fmt, args)); } namespace detail { -template inline bool operator==(basic_fp x, basic_fp y) { +template +inline auto operator==(basic_fp x, basic_fp y) -> bool { return x.f == y.f && x.e == y.e; } // Compilers should be able to optimize this into the ror instruction. -FMT_CONSTEXPR inline uint32_t rotr(uint32_t n, uint32_t r) noexcept { +FMT_CONSTEXPR inline auto rotr(uint32_t n, uint32_t r) noexcept -> uint32_t { r &= 31; return (n >> r) | (n << (32 - r)); } -FMT_CONSTEXPR inline uint64_t rotr(uint64_t n, uint32_t r) noexcept { +FMT_CONSTEXPR inline auto rotr(uint64_t n, uint32_t r) noexcept -> uint64_t { r &= 63; return (n >> r) | (n << (64 - r)); } @@ -170,14 +171,14 @@ FMT_CONSTEXPR inline uint64_t rotr(uint64_t n, uint32_t r) noexcept { namespace dragonbox { // Computes upper 64 bits of multiplication of a 32-bit unsigned integer and a // 64-bit unsigned integer. -inline uint64_t umul96_upper64(uint32_t x, uint64_t y) noexcept { +inline auto umul96_upper64(uint32_t x, uint64_t y) noexcept -> uint64_t { return umul128_upper64(static_cast(x) << 32, y); } // Computes lower 128 bits of multiplication of a 64-bit unsigned integer and a // 128-bit unsigned integer. -inline uint128_fallback umul192_lower128(uint64_t x, - uint128_fallback y) noexcept { +inline auto umul192_lower128(uint64_t x, uint128_fallback y) noexcept + -> uint128_fallback { uint64_t high = x * y.high(); uint128_fallback high_low = umul128(x, y.low()); return {high + high_low.high(), high_low.low()}; @@ -185,12 +186,12 @@ inline uint128_fallback umul192_lower128(uint64_t x, // Computes lower 64 bits of multiplication of a 32-bit unsigned integer and a // 64-bit unsigned integer. -inline uint64_t umul96_lower64(uint32_t x, uint64_t y) noexcept { +inline auto umul96_lower64(uint32_t x, uint64_t y) noexcept -> uint64_t { return x * y; } // Various fast log computations. -inline int floor_log10_pow2_minus_log10_4_over_3(int e) noexcept { +inline auto floor_log10_pow2_minus_log10_4_over_3(int e) noexcept -> int { FMT_ASSERT(e <= 2936 && e >= -2985, "too large exponent"); return (e * 631305 - 261663) >> 21; } @@ -204,7 +205,7 @@ FMT_INLINE_VARIABLE constexpr struct { // divisible by pow(10, N). // Precondition: n <= pow(10, N + 1). template -bool check_divisibility_and_divide_by_pow10(uint32_t& n) noexcept { +auto check_divisibility_and_divide_by_pow10(uint32_t& n) noexcept -> bool { // The numbers below are chosen such that: // 1. floor(n/d) = floor(nm / 2^k) where d=10 or d=100, // 2. nm mod 2^k < m if and only if n is divisible by d, @@ -229,7 +230,7 @@ bool check_divisibility_and_divide_by_pow10(uint32_t& n) noexcept { // Computes floor(n / pow(10, N)) for small n and N. // Precondition: n <= pow(10, N + 1). -template uint32_t small_division_by_pow10(uint32_t n) noexcept { +template auto small_division_by_pow10(uint32_t n) noexcept -> uint32_t { constexpr auto info = div_small_pow10_infos[N - 1]; FMT_ASSERT(n <= info.divisor * 10, "n is too large"); constexpr uint32_t magic_number = @@ -238,12 +239,12 @@ template uint32_t small_division_by_pow10(uint32_t n) noexcept { } // Computes floor(n / 10^(kappa + 1)) (float) -inline uint32_t divide_by_10_to_kappa_plus_1(uint32_t n) noexcept { +inline auto divide_by_10_to_kappa_plus_1(uint32_t n) noexcept -> uint32_t { // 1374389535 = ceil(2^37/100) return static_cast((static_cast(n) * 1374389535) >> 37); } // Computes floor(n / 10^(kappa + 1)) (double) -inline uint64_t divide_by_10_to_kappa_plus_1(uint64_t n) noexcept { +inline auto divide_by_10_to_kappa_plus_1(uint64_t n) noexcept -> uint64_t { // 2361183241434822607 = ceil(2^(64+7)/1000) return umul128_upper64(n, 2361183241434822607ull) >> 7; } @@ -255,7 +256,7 @@ template <> struct cache_accessor { using carrier_uint = float_info::carrier_uint; using cache_entry_type = uint64_t; - static uint64_t get_cached_power(int k) noexcept { + static auto get_cached_power(int k) noexcept -> uint64_t { FMT_ASSERT(k >= float_info::min_k && k <= float_info::max_k, "k is out of range"); static constexpr const uint64_t pow10_significands[] = { @@ -297,20 +298,23 @@ template <> struct cache_accessor { bool is_integer; }; - static compute_mul_result compute_mul( - carrier_uint u, const cache_entry_type& cache) noexcept { + static auto compute_mul(carrier_uint u, + const cache_entry_type& cache) noexcept + -> compute_mul_result { auto r = umul96_upper64(u, cache); return {static_cast(r >> 32), static_cast(r) == 0}; } - static uint32_t compute_delta(const cache_entry_type& cache, - int beta) noexcept { + static auto compute_delta(const cache_entry_type& cache, int beta) noexcept + -> uint32_t { return static_cast(cache >> (64 - 1 - beta)); } - static compute_mul_parity_result compute_mul_parity( - carrier_uint two_f, const cache_entry_type& cache, int beta) noexcept { + static auto compute_mul_parity(carrier_uint two_f, + const cache_entry_type& cache, + int beta) noexcept + -> compute_mul_parity_result { FMT_ASSERT(beta >= 1, ""); FMT_ASSERT(beta < 64, ""); @@ -319,22 +323,22 @@ template <> struct cache_accessor { static_cast(r >> (32 - beta)) == 0}; } - static carrier_uint compute_left_endpoint_for_shorter_interval_case( - const cache_entry_type& cache, int beta) noexcept { + static auto compute_left_endpoint_for_shorter_interval_case( + const cache_entry_type& cache, int beta) noexcept -> carrier_uint { return static_cast( (cache - (cache >> (num_significand_bits() + 2))) >> (64 - num_significand_bits() - 1 - beta)); } - static carrier_uint compute_right_endpoint_for_shorter_interval_case( - const cache_entry_type& cache, int beta) noexcept { + static auto compute_right_endpoint_for_shorter_interval_case( + const cache_entry_type& cache, int beta) noexcept -> carrier_uint { return static_cast( (cache + (cache >> (num_significand_bits() + 1))) >> (64 - num_significand_bits() - 1 - beta)); } - static carrier_uint compute_round_up_for_shorter_interval_case( - const cache_entry_type& cache, int beta) noexcept { + static auto compute_round_up_for_shorter_interval_case( + const cache_entry_type& cache, int beta) noexcept -> carrier_uint { return (static_cast( cache >> (64 - num_significand_bits() - 2 - beta)) + 1) / @@ -346,7 +350,7 @@ template <> struct cache_accessor { using carrier_uint = float_info::carrier_uint; using cache_entry_type = uint128_fallback; - static uint128_fallback get_cached_power(int k) noexcept { + static auto get_cached_power(int k) noexcept -> uint128_fallback { FMT_ASSERT(k >= float_info::min_k && k <= float_info::max_k, "k is out of range"); @@ -985,8 +989,7 @@ template <> struct cache_accessor { {0xe0accfa875af45a7, 0x93eb1b80a33b8606}, {0x8c6c01c9498d8b88, 0xbc72f130660533c4}, {0xaf87023b9bf0ee6a, 0xeb8fad7c7f8680b5}, - { 0xdb68c2ca82ed2a05, - 0xa67398db9f6820e2 } + {0xdb68c2ca82ed2a05, 0xa67398db9f6820e2}, #else {0xff77b1fcbebcdc4f, 0x25e8e89c13bb0f7b}, {0xce5d73ff402d98e3, 0xfb0a3d212dc81290}, @@ -1071,19 +1074,22 @@ template <> struct cache_accessor { bool is_integer; }; - static compute_mul_result compute_mul( - carrier_uint u, const cache_entry_type& cache) noexcept { + static auto compute_mul(carrier_uint u, + const cache_entry_type& cache) noexcept + -> compute_mul_result { auto r = umul192_upper128(u, cache); return {r.high(), r.low() == 0}; } - static uint32_t compute_delta(cache_entry_type const& cache, - int beta) noexcept { + static auto compute_delta(cache_entry_type const& cache, int beta) noexcept + -> uint32_t { return static_cast(cache.high() >> (64 - 1 - beta)); } - static compute_mul_parity_result compute_mul_parity( - carrier_uint two_f, const cache_entry_type& cache, int beta) noexcept { + static auto compute_mul_parity(carrier_uint two_f, + const cache_entry_type& cache, + int beta) noexcept + -> compute_mul_parity_result { FMT_ASSERT(beta >= 1, ""); FMT_ASSERT(beta < 64, ""); @@ -1092,35 +1098,35 @@ template <> struct cache_accessor { ((r.high() << beta) | (r.low() >> (64 - beta))) == 0}; } - static carrier_uint compute_left_endpoint_for_shorter_interval_case( - const cache_entry_type& cache, int beta) noexcept { + static auto compute_left_endpoint_for_shorter_interval_case( + const cache_entry_type& cache, int beta) noexcept -> carrier_uint { return (cache.high() - (cache.high() >> (num_significand_bits() + 2))) >> (64 - num_significand_bits() - 1 - beta); } - static carrier_uint compute_right_endpoint_for_shorter_interval_case( - const cache_entry_type& cache, int beta) noexcept { + static auto compute_right_endpoint_for_shorter_interval_case( + const cache_entry_type& cache, int beta) noexcept -> carrier_uint { return (cache.high() + (cache.high() >> (num_significand_bits() + 1))) >> (64 - num_significand_bits() - 1 - beta); } - static carrier_uint compute_round_up_for_shorter_interval_case( - const cache_entry_type& cache, int beta) noexcept { + static auto compute_round_up_for_shorter_interval_case( + const cache_entry_type& cache, int beta) noexcept -> carrier_uint { return ((cache.high() >> (64 - num_significand_bits() - 2 - beta)) + 1) / 2; } }; -FMT_FUNC uint128_fallback get_cached_power(int k) noexcept { +FMT_FUNC auto get_cached_power(int k) noexcept -> uint128_fallback { return cache_accessor::get_cached_power(k); } // Various integer checks template -bool is_left_endpoint_integer_shorter_interval(int exponent) noexcept { +auto is_left_endpoint_integer_shorter_interval(int exponent) noexcept -> bool { const int case_shorter_interval_left_endpoint_lower_threshold = 2; const int case_shorter_interval_left_endpoint_upper_threshold = 3; return exponent >= case_shorter_interval_left_endpoint_lower_threshold && @@ -1132,7 +1138,7 @@ FMT_INLINE int remove_trailing_zeros(uint32_t& n, int s = 0) noexcept { FMT_ASSERT(n != 0, ""); // Modular inverse of 5 (mod 2^32): (mod_inv_5 * 5) mod 2^32 = 1. constexpr uint32_t mod_inv_5 = 0xcccccccd; - constexpr uint32_t mod_inv_25 = 0xc28f5c29; // = mod_inv_5 * mod_inv_5 + constexpr uint32_t mod_inv_25 = 0xc28f5c29; // = mod_inv_5 * mod_inv_5 while (true) { auto q = rotr(n * mod_inv_25, 2); @@ -1168,7 +1174,7 @@ FMT_INLINE int remove_trailing_zeros(uint64_t& n) noexcept { // If n is not divisible by 10^8, work with n itself. constexpr uint64_t mod_inv_5 = 0xcccccccccccccccd; - constexpr uint64_t mod_inv_25 = 0x8f5c28f5c28f5c29; // = mod_inv_5 * mod_inv_5 + constexpr uint64_t mod_inv_25 = 0x8f5c28f5c28f5c29; // mod_inv_5 * mod_inv_5 int s = 0; while (true) { @@ -1234,7 +1240,7 @@ FMT_INLINE decimal_fp shorter_interval_case(int exponent) noexcept { return ret_value; } -template decimal_fp to_decimal(T x) noexcept { +template auto to_decimal(T x) noexcept -> decimal_fp { // Step 1: integer promotion & Schubfach multiplier calculation. using carrier_uint = typename float_info::carrier_uint; @@ -1373,15 +1379,15 @@ template <> struct formatter { for (auto i = n.bigits_.size(); i > 0; --i) { auto value = n.bigits_[i - 1u]; if (first) { - out = format_to(out, FMT_STRING("{:x}"), value); + out = fmt::format_to(out, FMT_STRING("{:x}"), value); first = false; continue; } - out = format_to(out, FMT_STRING("{:08x}"), value); + out = fmt::format_to(out, FMT_STRING("{:08x}"), value); } if (n.exp_ > 0) - out = format_to(out, FMT_STRING("p{}"), - n.exp_ * detail::bigint::bigit_bits); + out = fmt::format_to(out, FMT_STRING("p{}"), + n.exp_ * detail::bigint::bigit_bits); return out; } }; @@ -1417,7 +1423,7 @@ FMT_FUNC void report_system_error(int error_code, report_error(format_system_error, error_code, message); } -FMT_FUNC std::string vformat(string_view fmt, format_args args) { +FMT_FUNC auto vformat(string_view fmt, format_args args) -> std::string { // Don't optimize the "{}" case to keep the binary size small and because it // can be better optimized in fmt::format anyway. auto buffer = memory_buffer(); @@ -1426,33 +1432,38 @@ FMT_FUNC std::string vformat(string_view fmt, format_args args) { } namespace detail { -#ifndef _WIN32 -FMT_FUNC bool write_console(std::FILE*, string_view) { return false; } +#if !defined(_WIN32) || defined(FMT_WINDOWS_NO_WCHAR) +FMT_FUNC auto write_console(int, string_view) -> bool { return false; } #else using dword = conditional_t; extern "C" __declspec(dllimport) int __stdcall WriteConsoleW( // void*, const void*, dword, dword*, void*); -FMT_FUNC bool write_console(std::FILE* f, string_view text) { - auto fd = _fileno(f); - if (!_isatty(fd)) return false; +FMT_FUNC bool write_console(int fd, string_view text) { auto u16 = utf8_to_utf16(text); - auto written = dword(); return WriteConsoleW(reinterpret_cast(_get_osfhandle(fd)), u16.c_str(), - static_cast(u16.size()), &written, nullptr) != 0; + static_cast(u16.size()), nullptr, nullptr) != 0; } +#endif +#ifdef _WIN32 // Print assuming legacy (non-Unicode) encoding. FMT_FUNC void vprint_mojibake(std::FILE* f, string_view fmt, format_args args) { auto buffer = memory_buffer(); - detail::vformat_to(buffer, fmt, - basic_format_args>(args)); - fwrite_fully(buffer.data(), 1, buffer.size(), f); + detail::vformat_to(buffer, fmt, args); + fwrite_fully(buffer.data(), buffer.size(), f); } #endif FMT_FUNC void print(std::FILE* f, string_view text) { - if (!write_console(f, text)) fwrite_fully(text.data(), 1, text.size(), f); +#ifdef _WIN32 + int fd = _fileno(f); + if (_isatty(fd)) { + std::fflush(f); + if (write_console(fd, text)) return; + } +#endif + fwrite_fully(text.data(), text.size(), f); } } // namespace detail diff --git a/src/fmt/format.h b/src/fmt/format.h index 87a34b972c..8cdf95b7bd 100644 --- a/src/fmt/format.h +++ b/src/fmt/format.h @@ -37,17 +37,28 @@ #include // uint32_t #include // std::memcpy #include // std::initializer_list -#include // std::numeric_limits -#include // std::uninitialized_copy -#include // std::runtime_error -#include // std::system_error +#include +#include // std::numeric_limits +#include // std::uninitialized_copy +#include // std::runtime_error +#include // std::system_error #ifdef __cpp_lib_bit_cast -# include // std::bitcast +# include // std::bit_cast #endif #include "core.h" +// libc++ supports string_view in pre-c++17. +#if FMT_HAS_INCLUDE() && \ + (FMT_CPLUSPLUS >= 201703L || defined(_LIBCPP_VERSION)) +# include +# define FMT_USE_STRING_VIEW +#elif FMT_HAS_INCLUDE("experimental/string_view") && FMT_CPLUSPLUS >= 201402L +# include +# define FMT_USE_EXPERIMENTAL_STRING_VIEW +#endif + #if defined __cpp_inline_variables && __cpp_inline_variables >= 201606L # define FMT_INLINE_VARIABLE inline #else @@ -65,25 +76,11 @@ # define FMT_FALLTHROUGH #endif -#ifndef FMT_DEPRECATED -# if FMT_HAS_CPP14_ATTRIBUTE(deprecated) || FMT_MSC_VERSION >= 1900 -# define FMT_DEPRECATED [[deprecated]] -# else -# if (defined(__GNUC__) && !defined(__LCC__)) || defined(__clang__) -# define FMT_DEPRECATED __attribute__((deprecated)) -# elif FMT_MSC_VERSION -# define FMT_DEPRECATED __declspec(deprecated) -# else -# define FMT_DEPRECATED /* deprecated */ -# endif -# endif -#endif - #ifndef FMT_NO_UNIQUE_ADDRESS # if FMT_CPLUSPLUS >= 202002L # if FMT_HAS_CPP_ATTRIBUTE(no_unique_address) # define FMT_NO_UNIQUE_ADDRESS [[no_unique_address]] -// VS2019 v16.10 and later except clang-cl (https://reviews.llvm.org/D110485) +// VS2019 v16.10 and later except clang-cl (https://reviews.llvm.org/D110485). # elif (FMT_MSC_VERSION >= 1929) && !FMT_CLANG_VERSION # define FMT_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]] # endif @@ -93,10 +90,11 @@ # define FMT_NO_UNIQUE_ADDRESS #endif -#if FMT_GCC_VERSION || defined(__clang__) -# define FMT_VISIBILITY(value) __attribute__((visibility(value))) +// Visibility when compiled as a shared library/object. +#if defined(FMT_LIB_EXPORT) || defined(FMT_SHARED) +# define FMT_SO_VISIBILITY(value) FMT_VISIBILITY(value) #else -# define FMT_VISIBILITY(value) +# define FMT_SO_VISIBILITY(value) #endif #ifdef __has_builtin @@ -152,7 +150,10 @@ FMT_END_NAMESPACE #ifndef FMT_USE_USER_DEFINED_LITERALS // EDG based compilers (Intel, NVIDIA, Elbrus, etc), GCC and MSVC support UDLs. -# if (FMT_HAS_FEATURE(cxx_user_literals) || FMT_GCC_VERSION >= 407 || \ +// +// GCC before 4.9 requires a space in `operator"" _a` which is invalid in later +// compiler versions. +# if (FMT_HAS_FEATURE(cxx_user_literals) || FMT_GCC_VERSION >= 409 || \ FMT_MSC_VERSION >= 1900) && \ (!defined(__EDG_VERSION__) || __EDG_VERSION__ >= /* UDL feature */ 480) # define FMT_USE_USER_DEFINED_LITERALS 1 @@ -272,20 +273,19 @@ inline auto ctzll(uint64_t x) -> int { FMT_END_NAMESPACE #endif +namespace std { +template <> struct iterator_traits { + using value_type = void; + using iterator_category = std::output_iterator_tag; +}; +template +struct iterator_traits> { + using value_type = void; + using iterator_category = std::output_iterator_tag; +}; +} // namespace std + FMT_BEGIN_NAMESPACE - -template struct disjunction : std::false_type {}; -template struct disjunction

: P {}; -template -struct disjunction - : conditional_t> {}; - -template struct conjunction : std::true_type {}; -template struct conjunction

: P {}; -template -struct conjunction - : conditional_t, P1> {}; - namespace detail { FMT_CONSTEXPR inline void abort_fuzzing_if(bool condition) { @@ -295,6 +295,15 @@ FMT_CONSTEXPR inline void abort_fuzzing_if(bool condition) { #endif } +#if defined(FMT_USE_STRING_VIEW) +template using std_string_view = std::basic_string_view; +#elif defined(FMT_USE_EXPERIMENTAL_STRING_VIEW) +template +using std_string_view = std::experimental::basic_string_view; +#else +template struct std_string_view {}; +#endif + template struct string_literal { static constexpr CharT value[sizeof...(C)] = {C...}; constexpr operator basic_string_view() const { @@ -307,37 +316,6 @@ template constexpr CharT string_literal::value[sizeof...(C)]; #endif -template class formatbuf : public Streambuf { - private: - using char_type = typename Streambuf::char_type; - using streamsize = decltype(std::declval().sputn(nullptr, 0)); - using int_type = typename Streambuf::int_type; - using traits_type = typename Streambuf::traits_type; - - buffer& buffer_; - - public: - explicit formatbuf(buffer& buf) : buffer_(buf) {} - - protected: - // The put area is always empty. This makes the implementation simpler and has - // the advantage that the streambuf and the buffer are always in sync and - // sputc never writes into uninitialized memory. A disadvantage is that each - // call to sputc always results in a (virtual) call to overflow. There is no - // disadvantage here for sputn since this always results in a call to xsputn. - - auto overflow(int_type ch) -> int_type override { - if (!traits_type::eq_int_type(ch, traits_type::eof())) - buffer_.push_back(static_cast(ch)); - return ch; - } - - auto xsputn(const char_type* s, streamsize count) -> streamsize override { - buffer_.append(s, s + count); - return count; - } -}; - // Implementation of std::bit_cast for pre-C++20. template FMT_CONSTEXPR20 auto bit_cast(const From& from) -> To { @@ -373,8 +351,8 @@ class uint128_fallback { constexpr uint128_fallback(uint64_t hi, uint64_t lo) : lo_(lo), hi_(hi) {} constexpr uint128_fallback(uint64_t value = 0) : lo_(value), hi_(0) {} - constexpr uint64_t high() const noexcept { return hi_; } - constexpr uint64_t low() const noexcept { return lo_; } + constexpr auto high() const noexcept -> uint64_t { return hi_; } + constexpr auto low() const noexcept -> uint64_t { return lo_; } template ::value)> constexpr explicit operator T() const { @@ -450,7 +428,7 @@ class uint128_fallback { hi_ &= n.hi_; } - FMT_CONSTEXPR20 uint128_fallback& operator+=(uint64_t n) noexcept { + FMT_CONSTEXPR20 auto operator+=(uint64_t n) noexcept -> uint128_fallback& { if (is_constant_evaluated()) { lo_ += n; hi_ += (lo_ < n ? 1 : 0); @@ -546,6 +524,52 @@ FMT_INLINE void assume(bool condition) { #endif } +// Extracts a reference to the container from back_insert_iterator. +template +inline auto get_container(std::back_insert_iterator it) + -> Container& { + using base = std::back_insert_iterator; + struct accessor : base { + accessor(base b) : base(b) {} + using base::container; + }; + return *accessor(it).container; +} + +template +FMT_CONSTEXPR auto copy_str(InputIt begin, InputIt end, OutputIt out) + -> OutputIt { + while (begin != end) *out++ = static_cast(*begin++); + return out; +} + +template , U>::value&& is_char::value)> +FMT_CONSTEXPR auto copy_str(T* begin, T* end, U* out) -> U* { + if (is_constant_evaluated()) return copy_str(begin, end, out); + auto size = to_unsigned(end - begin); + if (size > 0) memcpy(out, begin, size * sizeof(U)); + return out + size; +} + +template +auto copy_str(InputIt begin, InputIt end, appender out) -> appender { + get_container(out).append(begin, end); + return out; +} +template +auto copy_str(InputIt begin, InputIt end, back_insert_iterator out) + -> back_insert_iterator { + get_container(out).append(begin, end); + return out; +} + +template +FMT_CONSTEXPR auto copy_str(R&& rng, OutputIt out) -> OutputIt { + return detail::copy_str(rng.begin(), rng.end(), out); +} + // An approximation of iterator_t for pre-C++20 systems. template using iterator_t = decltype(std::begin(std::declval())); @@ -740,7 +764,7 @@ inline auto compute_width(basic_string_view s) -> size_t { } // Computes approximate display width of a UTF-8 string. -FMT_CONSTEXPR inline size_t compute_width(string_view s) { +FMT_CONSTEXPR inline auto compute_width(string_view s) -> size_t { size_t num_code_points = 0; // It is not a lambda for compatibility with C++14. struct count_code_points { @@ -787,12 +811,17 @@ inline auto code_point_index(basic_string_view s, size_t n) -> size_t { // Calculates the index of the nth code point in a UTF-8 string. inline auto code_point_index(string_view s, size_t n) -> size_t { - const char* data = s.data(); - size_t num_code_points = 0; - for (size_t i = 0, size = s.size(); i != size; ++i) { - if ((data[i] & 0xc0) != 0x80 && ++num_code_points > n) return i; - } - return s.size(); + size_t result = s.size(); + const char* begin = s.begin(); + for_each_codepoint(s, [begin, &n, &result](uint32_t, string_view sv) { + if (n != 0) { + --n; + return true; + } + result = to_unsigned(sv.begin() - begin); + return false; + }); + return result; } inline auto code_point_index(basic_string_view s, size_t n) @@ -902,7 +931,7 @@ enum { inline_buffer_size = 500 }; **Example**:: auto out = fmt::memory_buffer(); - format_to(std::back_inserter(out), "The answer is {}.", 42); + fmt::format_to(std::back_inserter(out), "The answer is {}.", 42); This will append the following output to the ``out`` object: @@ -929,27 +958,29 @@ class basic_memory_buffer final : public detail::buffer { } protected: - FMT_CONSTEXPR20 void grow(size_t size) override { + static FMT_CONSTEXPR20 void grow(detail::buffer& buf, size_t size) { detail::abort_fuzzing_if(size > 5000); - const size_t max_size = std::allocator_traits::max_size(alloc_); - size_t old_capacity = this->capacity(); + auto& self = static_cast(buf); + const size_t max_size = + std::allocator_traits::max_size(self.alloc_); + size_t old_capacity = buf.capacity(); size_t new_capacity = old_capacity + old_capacity / 2; if (size > new_capacity) new_capacity = size; else if (new_capacity > max_size) new_capacity = size > max_size ? size : max_size; - T* old_data = this->data(); + T* old_data = buf.data(); T* new_data = - std::allocator_traits::allocate(alloc_, new_capacity); + std::allocator_traits::allocate(self.alloc_, new_capacity); // Suppress a bogus -Wstringop-overflow in gcc 13.1 (#3481). - detail::assume(this->size() <= new_capacity); + detail::assume(buf.size() <= new_capacity); // The following code doesn't throw, so the raw pointer above doesn't leak. - std::uninitialized_copy_n(old_data, this->size(), new_data); - this->set(new_data, new_capacity); + std::uninitialized_copy_n(old_data, buf.size(), new_data); + self.set(new_data, new_capacity); // deallocate must not throw according to the standard, but even if it does, // the buffer already uses the new storage and will deallocate it in // destructor. - if (old_data != store_) alloc_.deallocate(old_data, old_capacity); + if (old_data != self.store_) self.alloc_.deallocate(old_data, old_capacity); } public: @@ -958,7 +989,7 @@ class basic_memory_buffer final : public detail::buffer { FMT_CONSTEXPR20 explicit basic_memory_buffer( const Allocator& alloc = Allocator()) - : alloc_(alloc) { + : detail::buffer(grow), alloc_(alloc) { this->set(store_, SIZE); if (detail::is_constant_evaluated()) detail::fill_n(store_, SIZE, T()); } @@ -990,7 +1021,8 @@ class basic_memory_buffer final : public detail::buffer { of the other object to it. \endrst */ - FMT_CONSTEXPR20 basic_memory_buffer(basic_memory_buffer&& other) noexcept { + FMT_CONSTEXPR20 basic_memory_buffer(basic_memory_buffer&& other) noexcept + : detail::buffer(grow) { move(other); } @@ -1018,7 +1050,6 @@ class basic_memory_buffer final : public detail::buffer { /** Increases the buffer capacity to *new_capacity*. */ void reserve(size_t new_capacity) { this->try_reserve(new_capacity); } - // Directly append data into the buffer using detail::buffer::append; template void append(const ContiguousRange& range) { @@ -1034,7 +1065,7 @@ struct is_contiguous> : std::true_type { FMT_END_EXPORT namespace detail { -FMT_API bool write_console(std::FILE* f, string_view text); +FMT_API auto write_console(int fd, string_view text) -> bool; FMT_API void print(std::FILE*, string_view); } // namespace detail @@ -1046,7 +1077,7 @@ FMT_BEGIN_EXPORT #endif /** An error reported from a formatting function. */ -class FMT_VISIBILITY("default") format_error : public std::runtime_error { +class FMT_SO_VISIBILITY("default") format_error : public std::runtime_error { public: using std::runtime_error::runtime_error; }; @@ -1089,7 +1120,7 @@ class loc_value { loc_value(T) {} template auto visit(Visitor&& vis) -> decltype(vis(0)) { - return visit_format_arg(vis, value_); + return value_.visit(vis); } }; @@ -1153,13 +1184,13 @@ using uint32_or_64_or_128_t = template using uint64_or_128_t = conditional_t() <= 64, uint64_t, uint128_t>; -#define FMT_POWERS_OF_10(factor) \ - factor * 10, (factor)*100, (factor)*1000, (factor)*10000, (factor)*100000, \ - (factor)*1000000, (factor)*10000000, (factor)*100000000, \ - (factor)*1000000000 +#define FMT_POWERS_OF_10(factor) \ + factor * 10, (factor) * 100, (factor) * 1000, (factor) * 10000, \ + (factor) * 100000, (factor) * 1000000, (factor) * 10000000, \ + (factor) * 100000000, (factor) * 1000000000 // Converts value in the range [0, 100) to a string. -constexpr const char* digits2(size_t value) { +constexpr auto digits2(size_t value) -> const char* { // GCC generates slightly better code when value is pointer-size. return &"0001020304050607080910111213141516171819" "2021222324252627282930313233343536373839" @@ -1169,7 +1200,7 @@ constexpr const char* digits2(size_t value) { } // Sign is a template parameter to workaround a bug in gcc 4.8. -template constexpr Char sign(Sign s) { +template constexpr auto sign(Sign s) -> Char { #if !FMT_GCC_VERSION || FMT_GCC_VERSION >= 604 static_assert(std::is_same::value, ""); #endif @@ -1394,7 +1425,7 @@ FMT_CONSTEXPR inline auto format_uint(It out, UInt value, int num_digits, return out; } // Buffer should be large enough to hold all digits (digits / BASE_BITS + 1). - char buffer[num_bits() / BASE_BITS + 1]; + char buffer[num_bits() / BASE_BITS + 1] = {}; format_uint(buffer, value, num_digits, upper); return detail::copy_str_noinline(buffer, buffer + num_digits, out); } @@ -1430,22 +1461,23 @@ template class to_utf8 { : "invalid utf32")); } operator string_view() const { return string_view(&buffer_[0], size()); } - size_t size() const { return buffer_.size() - 1; } - const char* c_str() const { return &buffer_[0]; } - std::string str() const { return std::string(&buffer_[0], size()); } + auto size() const -> size_t { return buffer_.size() - 1; } + auto c_str() const -> const char* { return &buffer_[0]; } + auto str() const -> std::string { return std::string(&buffer_[0], size()); } // Performs conversion returning a bool instead of throwing exception on // conversion error. This method may still throw in case of memory allocation // error. - bool convert(basic_string_view s, - to_utf8_error_policy policy = to_utf8_error_policy::abort) { + auto convert(basic_string_view s, + to_utf8_error_policy policy = to_utf8_error_policy::abort) + -> bool { if (!convert(buffer_, s, policy)) return false; buffer_.push_back(0); return true; } - static bool convert( - Buffer& buf, basic_string_view s, - to_utf8_error_policy policy = to_utf8_error_policy::abort) { + static auto convert(Buffer& buf, basic_string_view s, + to_utf8_error_policy policy = to_utf8_error_policy::abort) + -> bool { for (auto p = s.begin(); p != s.end(); ++p) { uint32_t c = static_cast(*p); if (sizeof(WChar) == 2 && c >= 0xd800 && c <= 0xdfff) { @@ -1481,7 +1513,7 @@ template class to_utf8 { }; // Computes 128-bit result of multiplication of two 64-bit unsigned integers. -inline uint128_fallback umul128(uint64_t x, uint64_t y) noexcept { +inline auto umul128(uint64_t x, uint64_t y) noexcept -> uint128_fallback { #if FMT_USE_INT128 auto p = static_cast(x) * static_cast(y); return {static_cast(p >> 64), static_cast(p)}; @@ -1512,19 +1544,19 @@ inline uint128_fallback umul128(uint64_t x, uint64_t y) noexcept { namespace dragonbox { // Computes floor(log10(pow(2, e))) for e in [-2620, 2620] using the method from // https://fmt.dev/papers/Dragonbox.pdf#page=28, section 6.1. -inline int floor_log10_pow2(int e) noexcept { +inline auto floor_log10_pow2(int e) noexcept -> int { FMT_ASSERT(e <= 2620 && e >= -2620, "too large exponent"); static_assert((-1 >> 1) == -1, "right shift is not arithmetic"); return (e * 315653) >> 20; } -inline int floor_log2_pow10(int e) noexcept { +inline auto floor_log2_pow10(int e) noexcept -> int { FMT_ASSERT(e <= 1233 && e >= -1233, "too large exponent"); return (e * 1741647) >> 19; } // Computes upper 64 bits of multiplication of two 64-bit unsigned integers. -inline uint64_t umul128_upper64(uint64_t x, uint64_t y) noexcept { +inline auto umul128_upper64(uint64_t x, uint64_t y) noexcept -> uint64_t { #if FMT_USE_INT128 auto p = static_cast(x) * static_cast(y); return static_cast(p >> 64); @@ -1537,14 +1569,14 @@ inline uint64_t umul128_upper64(uint64_t x, uint64_t y) noexcept { // Computes upper 128 bits of multiplication of a 64-bit unsigned integer and a // 128-bit unsigned integer. -inline uint128_fallback umul192_upper128(uint64_t x, - uint128_fallback y) noexcept { +inline auto umul192_upper128(uint64_t x, uint128_fallback y) noexcept + -> uint128_fallback { uint128_fallback r = umul128(x, y.high()); r += umul128_upper64(x, y.low()); return r; } -FMT_API uint128_fallback get_cached_power(int k) noexcept; +FMT_API auto get_cached_power(int k) noexcept -> uint128_fallback; // Type-specific information that Dragonbox uses. template struct float_info; @@ -1598,14 +1630,14 @@ template FMT_API auto to_decimal(T x) noexcept -> decimal_fp; } // namespace dragonbox // Returns true iff Float has the implicit bit which is not stored. -template constexpr bool has_implicit_bit() { +template constexpr auto has_implicit_bit() -> bool { // An 80-bit FP number has a 64-bit significand an no implicit bit. return std::numeric_limits::digits != 64; } // Returns the number of significand bits stored in Float. The implicit bit is // not counted since it is not stored. -template constexpr int num_significand_bits() { +template constexpr auto num_significand_bits() -> int { // std::numeric_limits may not support __float128. return is_float128() ? 112 : (std::numeric_limits::digits - @@ -1698,7 +1730,7 @@ using fp = basic_fp; // Normalizes the value converted from double and multiplied by (1 << SHIFT). template -FMT_CONSTEXPR basic_fp normalize(basic_fp value) { +FMT_CONSTEXPR auto normalize(basic_fp value) -> basic_fp { // Handle subnormals. const auto implicit_bit = F(1) << num_significand_bits(); const auto shifted_implicit_bit = implicit_bit << SHIFT; @@ -1715,7 +1747,7 @@ FMT_CONSTEXPR basic_fp normalize(basic_fp value) { } // Computes lhs * rhs / pow(2, 64) rounded to nearest with half-up tie breaking. -FMT_CONSTEXPR inline uint64_t multiply(uint64_t lhs, uint64_t rhs) { +FMT_CONSTEXPR inline auto multiply(uint64_t lhs, uint64_t rhs) -> uint64_t { #if FMT_USE_INT128 auto product = static_cast<__uint128_t>(lhs) * rhs; auto f = static_cast(product >> 64); @@ -1732,33 +1764,10 @@ FMT_CONSTEXPR inline uint64_t multiply(uint64_t lhs, uint64_t rhs) { #endif } -FMT_CONSTEXPR inline fp operator*(fp x, fp y) { +FMT_CONSTEXPR inline auto operator*(fp x, fp y) -> fp { return {multiply(x.f, y.f), x.e + y.e + 64}; } -template struct basic_data { - // For checking rounding thresholds. - // The kth entry is chosen to be the smallest integer such that the - // upper 32-bits of 10^(k+1) times it is strictly bigger than 5 * 10^k. - static constexpr uint32_t fractional_part_rounding_thresholds[8] = { - 2576980378U, // ceil(2^31 + 2^32/10^1) - 2190433321U, // ceil(2^31 + 2^32/10^2) - 2151778616U, // ceil(2^31 + 2^32/10^3) - 2147913145U, // ceil(2^31 + 2^32/10^4) - 2147526598U, // ceil(2^31 + 2^32/10^5) - 2147487943U, // ceil(2^31 + 2^32/10^6) - 2147484078U, // ceil(2^31 + 2^32/10^7) - 2147483691U // ceil(2^31 + 2^32/10^8) - }; -}; -// This is a struct rather than an alias to avoid shadowing warnings in gcc. -struct data : basic_data<> {}; - -#if FMT_CPLUSPLUS < 201703L -template -constexpr uint32_t basic_data::fractional_part_rounding_thresholds[]; -#endif - template () == num_bits()> using convert_float_result = conditional_t::value || doublish, double, T>; @@ -1939,15 +1948,11 @@ auto write_escaped_cp(OutputIt out, const find_escape_result& escape) *out++ = static_cast('\\'); break; default: - if (escape.cp < 0x100) { - return write_codepoint<2, Char>(out, 'x', escape.cp); - } - if (escape.cp < 0x10000) { + if (escape.cp < 0x100) return write_codepoint<2, Char>(out, 'x', escape.cp); + if (escape.cp < 0x10000) return write_codepoint<4, Char>(out, 'u', escape.cp); - } - if (escape.cp < 0x110000) { + if (escape.cp < 0x110000) return write_codepoint<8, Char>(out, 'U', escape.cp); - } for (Char escape_char : basic_string_view( escape.begin, to_unsigned(escape.end - escape.begin))) { out = write_codepoint<2, Char>(out, 'x', @@ -1977,11 +1982,13 @@ auto write_escaped_string(OutputIt out, basic_string_view str) template auto write_escaped_char(OutputIt out, Char v) -> OutputIt { + Char v_array[1] = {v}; *out++ = static_cast('\''); if ((needs_escape(static_cast(v)) && v != static_cast('"')) || v == static_cast('\'')) { - out = write_escaped_cp( - out, find_escape_result{&v, &v + 1, static_cast(v)}); + out = write_escaped_cp(out, + find_escape_result{v_array, v_array + 1, + static_cast(v)}); } else { *out++ = v; } @@ -2070,10 +2077,10 @@ template class digit_grouping { std::string::const_iterator group; int pos; }; - next_state initial_state() const { return {grouping_.begin(), 0}; } + auto initial_state() const -> next_state { return {grouping_.begin(), 0}; } // Returns the next digit group separator position. - int next(next_state& state) const { + auto next(next_state& state) const -> int { if (thousands_sep_.empty()) return max_value(); if (state.group == grouping_.end()) return state.pos += grouping_.back(); if (*state.group <= 0 || *state.group == max_value()) @@ -2092,9 +2099,9 @@ template class digit_grouping { digit_grouping(std::string grouping, std::basic_string sep) : grouping_(std::move(grouping)), thousands_sep_(std::move(sep)) {} - bool has_separator() const { return !thousands_sep_.empty(); } + auto has_separator() const -> bool { return !thousands_sep_.empty(); } - int count_separators(int num_digits) const { + auto count_separators(int num_digits) const -> int { int count = 0; auto state = initial_state(); while (num_digits > next(state)) ++count; @@ -2103,7 +2110,7 @@ template class digit_grouping { // Applies grouping to digits and write the output to out. template - Out apply(Out out, basic_string_view digits) const { + auto apply(Out out, basic_string_view digits) const -> Out { auto num_digits = static_cast(digits.size()); auto separators = basic_memory_buffer(); separators.push_back(0); @@ -2126,24 +2133,66 @@ template class digit_grouping { } }; +FMT_CONSTEXPR inline void prefix_append(unsigned& prefix, unsigned value) { + prefix |= prefix != 0 ? value << 8 : value; + prefix += (1u + (value > 0xff ? 1 : 0)) << 24; +} + // Writes a decimal integer with digit grouping. template auto write_int(OutputIt out, UInt value, unsigned prefix, const format_specs& specs, const digit_grouping& grouping) -> OutputIt { static_assert(std::is_same, UInt>::value, ""); - int num_digits = count_digits(value); - char digits[40]; - format_decimal(digits, value, num_digits); - unsigned size = to_unsigned((prefix != 0 ? 1 : 0) + num_digits + - grouping.count_separators(num_digits)); + int num_digits = 0; + auto buffer = memory_buffer(); + switch (specs.type) { + case presentation_type::none: + case presentation_type::dec: { + num_digits = count_digits(value); + format_decimal(appender(buffer), value, num_digits); + break; + } + case presentation_type::hex_lower: + case presentation_type::hex_upper: { + bool upper = specs.type == presentation_type::hex_upper; + if (specs.alt) + prefix_append(prefix, unsigned(upper ? 'X' : 'x') << 8 | '0'); + num_digits = count_digits<4>(value); + format_uint<4, char>(appender(buffer), value, num_digits, upper); + break; + } + case presentation_type::bin_lower: + case presentation_type::bin_upper: { + bool upper = specs.type == presentation_type::bin_upper; + if (specs.alt) + prefix_append(prefix, unsigned(upper ? 'B' : 'b') << 8 | '0'); + num_digits = count_digits<1>(value); + format_uint<1, char>(appender(buffer), value, num_digits); + break; + } + case presentation_type::oct: { + num_digits = count_digits<3>(value); + // Octal prefix '0' is counted as a digit, so only add it if precision + // is not greater than the number of digits. + if (specs.alt && specs.precision <= num_digits && value != 0) + prefix_append(prefix, '0'); + format_uint<3, char>(appender(buffer), value, num_digits); + break; + } + case presentation_type::chr: + return write_char(out, static_cast(value), specs); + default: + throw_format_error("invalid format specifier"); + } + + unsigned size = (prefix != 0 ? prefix >> 24 : 0) + to_unsigned(num_digits) + + to_unsigned(grouping.count_separators(num_digits)); return write_padded( out, specs, size, size, [&](reserve_iterator it) { - if (prefix != 0) { - char sign = static_cast(prefix); - *it++ = static_cast(sign); - } - return grouping.apply(it, string_view(digits, to_unsigned(num_digits))); + for (unsigned p = prefix & 0xffffff; p != 0; p >>= 8) + *it++ = static_cast(p & 0xff); + return grouping.apply(it, string_view(buffer.data(), buffer.size())); }); } @@ -2156,11 +2205,6 @@ inline auto write_loc(OutputIt, loc_value, const format_specs&, return false; } -FMT_CONSTEXPR inline void prefix_append(unsigned& prefix, unsigned value) { - prefix |= prefix != 0 ? value << 8 : value; - prefix += (1u + (value > 0xff ? 1 : 0)) << 24; -} - template struct write_int_arg { UInt abs_value; unsigned prefix; @@ -2307,25 +2351,25 @@ class counting_iterator { FMT_CONSTEXPR counting_iterator() : count_(0) {} - FMT_CONSTEXPR size_t count() const { return count_; } + FMT_CONSTEXPR auto count() const -> size_t { return count_; } - FMT_CONSTEXPR counting_iterator& operator++() { + FMT_CONSTEXPR auto operator++() -> counting_iterator& { ++count_; return *this; } - FMT_CONSTEXPR counting_iterator operator++(int) { + FMT_CONSTEXPR auto operator++(int) -> counting_iterator { auto it = *this; ++*this; return it; } - FMT_CONSTEXPR friend counting_iterator operator+(counting_iterator it, - difference_type n) { + FMT_CONSTEXPR friend auto operator+(counting_iterator it, difference_type n) + -> counting_iterator { it.count_ += static_cast(n); return it; } - FMT_CONSTEXPR value_type operator*() const { return {}; } + FMT_CONSTEXPR auto operator*() const -> value_type { return {}; } }; template @@ -2360,9 +2404,10 @@ template FMT_CONSTEXPR auto write(OutputIt out, const Char* s, const format_specs& specs, locale_ref) -> OutputIt { - return specs.type != presentation_type::pointer - ? write(out, basic_string_view(s), specs, {}) - : write_ptr(out, bit_cast(s), &specs); + if (specs.type == presentation_type::pointer) + return write_ptr(out, bit_cast(s), &specs); + if (!s) throw_format_error("string pointer is null"); + return write(out, basic_string_view(s), specs, {}); } template -FMT_CONSTEXPR auto parse_float_type_spec(const format_specs& specs, - ErrorHandler&& eh = {}) +template +FMT_CONSTEXPR auto parse_float_type_spec(const format_specs& specs) -> float_specs { auto result = float_specs(); result.showpoint = specs.alt; @@ -2486,7 +2530,7 @@ FMT_CONSTEXPR auto parse_float_type_spec(const format_specs& specs, result.format = float_format::hex; break; default: - eh.on_error("invalid format specifier"); + throw_format_error("invalid format specifier"); break; } return result; @@ -2725,12 +2769,12 @@ template class fallback_digit_grouping { public: constexpr fallback_digit_grouping(locale_ref, bool) {} - constexpr bool has_separator() const { return false; } + constexpr auto has_separator() const -> bool { return false; } - constexpr int count_separators(int) const { return 0; } + constexpr auto count_separators(int) const -> int { return 0; } template - constexpr Out apply(Out out, basic_string_view) const { + constexpr auto apply(Out out, basic_string_view) const -> Out { return out; } }; @@ -2749,7 +2793,7 @@ FMT_CONSTEXPR20 auto write_float(OutputIt out, const DecimalFP& f, } } -template constexpr bool isnan(T value) { +template constexpr auto isnan(T value) -> bool { return !(value >= value); // std::isnan doesn't support __float128. } @@ -2762,14 +2806,14 @@ struct has_isfinite> template ::value&& has_isfinite::value)> -FMT_CONSTEXPR20 bool isfinite(T value) { +FMT_CONSTEXPR20 auto isfinite(T value) -> bool { constexpr T inf = T(std::numeric_limits::infinity()); if (is_constant_evaluated()) return !detail::isnan(value) && value < inf && value > -inf; return std::isfinite(value); } template ::value)> -FMT_CONSTEXPR bool isfinite(T value) { +FMT_CONSTEXPR auto isfinite(T value) -> bool { T inf = T(std::numeric_limits::infinity()); // std::isfinite doesn't support __float128. return !detail::isnan(value) && value < inf && value > -inf; @@ -2806,10 +2850,10 @@ class bigint { basic_memory_buffer bigits_; int exp_; - FMT_CONSTEXPR20 bigit operator[](int index) const { + FMT_CONSTEXPR20 auto operator[](int index) const -> bigit { return bigits_[to_unsigned(index)]; } - FMT_CONSTEXPR20 bigit& operator[](int index) { + FMT_CONSTEXPR20 auto operator[](int index) -> bigit& { return bigits_[to_unsigned(index)]; } @@ -2905,11 +2949,11 @@ class bigint { assign(uint64_or_128_t(n)); } - FMT_CONSTEXPR20 int num_bigits() const { + FMT_CONSTEXPR20 auto num_bigits() const -> int { return static_cast(bigits_.size()) + exp_; } - FMT_NOINLINE FMT_CONSTEXPR20 bigint& operator<<=(int shift) { + FMT_NOINLINE FMT_CONSTEXPR20 auto operator<<=(int shift) -> bigint& { FMT_ASSERT(shift >= 0, ""); exp_ += shift / bigit_bits; shift %= bigit_bits; @@ -2924,13 +2968,15 @@ class bigint { return *this; } - template FMT_CONSTEXPR20 bigint& operator*=(Int value) { + template + FMT_CONSTEXPR20 auto operator*=(Int value) -> bigint& { FMT_ASSERT(value > 0, ""); multiply(uint32_or_64_or_128_t(value)); return *this; } - friend FMT_CONSTEXPR20 int compare(const bigint& lhs, const bigint& rhs) { + friend FMT_CONSTEXPR20 auto compare(const bigint& lhs, const bigint& rhs) + -> int { int num_lhs_bigits = lhs.num_bigits(), num_rhs_bigits = rhs.num_bigits(); if (num_lhs_bigits != num_rhs_bigits) return num_lhs_bigits > num_rhs_bigits ? 1 : -1; @@ -2947,8 +2993,9 @@ class bigint { } // Returns compare(lhs1 + lhs2, rhs). - friend FMT_CONSTEXPR20 int add_compare(const bigint& lhs1, const bigint& lhs2, - const bigint& rhs) { + friend FMT_CONSTEXPR20 auto add_compare(const bigint& lhs1, + const bigint& lhs2, const bigint& rhs) + -> int { auto minimum = [](int a, int b) { return a < b ? a : b; }; auto maximum = [](int a, int b) { return a > b ? a : b; }; int max_lhs_bigits = maximum(lhs1.num_bigits(), lhs2.num_bigits()); @@ -3029,13 +3076,13 @@ class bigint { bigits_.resize(to_unsigned(num_bigits + exp_difference)); for (int i = num_bigits - 1, j = i + exp_difference; i >= 0; --i, --j) bigits_[j] = bigits_[i]; - std::uninitialized_fill_n(bigits_.data(), exp_difference, 0); + std::uninitialized_fill_n(bigits_.data(), exp_difference, 0u); exp_ -= exp_difference; } // Divides this bignum by divisor, assigning the remainder to this and // returning the quotient. - FMT_CONSTEXPR20 int divmod_assign(const bigint& divisor) { + FMT_CONSTEXPR20 auto divmod_assign(const bigint& divisor) -> int { FMT_ASSERT(this != &divisor, ""); if (compare(*this, divisor) < 0) return 0; FMT_ASSERT(divisor.bigits_[divisor.bigits_.size() - 1u] != 0, ""); @@ -3178,8 +3225,10 @@ FMT_CONSTEXPR20 inline void format_dragon(basic_fp value, } if (buf[0] == overflow) { buf[0] = '1'; - if ((flags & dragon::fixed) != 0) buf.push_back('0'); - else ++exp10; + if ((flags & dragon::fixed) != 0) + buf.push_back('0'); + else + ++exp10; } return; } @@ -3276,6 +3325,17 @@ FMT_CONSTEXPR20 void format_hexfloat(Float value, int precision, format_hexfloat(static_cast(value), precision, specs, buf); } +constexpr auto fractional_part_rounding_thresholds(int index) -> uint32_t { + // For checking rounding thresholds. + // The kth entry is chosen to be the smallest integer such that the + // upper 32-bits of 10^(k+1) times it is strictly bigger than 5 * 10^k. + // It is equal to ceil(2^31 + 2^32/10^(k + 1)). + // These are stored in a string literal because we cannot have static arrays + // in constexpr functions and non-static ones are poorly optimized. + return U"\x9999999a\x828f5c29\x80418938\x80068db9\x8000a7c6\x800010c7" + U"\x800001ae\x8000002b"[index]; +} + template FMT_CONSTEXPR20 auto format_float(Float value, int precision, float_specs specs, buffer& buf) -> int { @@ -3480,12 +3540,12 @@ FMT_CONSTEXPR20 auto format_float(Float value, int precision, float_specs specs, // fractional part is strictly larger than 1/2. if (precision < 9) { uint32_t fractional_part = static_cast(prod); - should_round_up = fractional_part >= - data::fractional_part_rounding_thresholds - [8 - number_of_digits_to_print] || - ((fractional_part >> 31) & - ((digits & 1) | (second_third_subsegments != 0) | - has_more_segments)) != 0; + should_round_up = + fractional_part >= fractional_part_rounding_thresholds( + 8 - number_of_digits_to_print) || + ((fractional_part >> 31) & + ((digits & 1) | (second_third_subsegments != 0) | + has_more_segments)) != 0; } // Rounding at the subsegment boundary. // In this case, the fractional part is at least 1/2 if and only if @@ -3520,12 +3580,12 @@ FMT_CONSTEXPR20 auto format_float(Float value, int precision, float_specs specs, // of 19 digits, so in this case the third segment should be // consisting of a genuine digit from the input. uint32_t fractional_part = static_cast(prod); - should_round_up = fractional_part >= - data::fractional_part_rounding_thresholds - [8 - number_of_digits_to_print] || - ((fractional_part >> 31) & - ((digits & 1) | (third_subsegment != 0) | - has_more_segments)) != 0; + should_round_up = + fractional_part >= fractional_part_rounding_thresholds( + 8 - number_of_digits_to_print) || + ((fractional_part >> 31) & + ((digits & 1) | (third_subsegment != 0) | + has_more_segments)) != 0; } // Rounding at the subsegment boundary. else { @@ -3726,8 +3786,7 @@ FMT_CONSTEXPR auto write(OutputIt out, Char value) -> OutputIt { } template -FMT_CONSTEXPR_CHAR_TRAITS auto write(OutputIt out, const Char* value) - -> OutputIt { +FMT_CONSTEXPR20 auto write(OutputIt out, const Char* value) -> OutputIt { if (value) return write(out, basic_string_view(value)); throw_format_error("string pointer is null"); return out; @@ -3757,8 +3816,11 @@ template enable_if_t::value == type::custom_type, OutputIt> { + auto formatter = typename Context::template formatter_type(); + auto parse_ctx = typename Context::parse_context_type({}); + formatter.parse(parse_ctx); auto ctx = Context(out, {}, {}); - return typename Context::template formatter_type().format(value, ctx); + return formatter.format(value, ctx); } // An argument visitor that formats the argument and writes it via the output @@ -3801,62 +3863,39 @@ template struct arg_formatter { } }; -template struct custom_formatter { - basic_format_parse_context& parse_ctx; - buffer_context& ctx; - - void operator()( - typename basic_format_arg>::handle h) const { - h.format(parse_ctx, ctx); - } - template void operator()(T) const {} -}; - -template class width_checker { - public: - explicit FMT_CONSTEXPR width_checker(ErrorHandler& eh) : handler_(eh) {} - +struct width_checker { template ::value)> FMT_CONSTEXPR auto operator()(T value) -> unsigned long long { - if (is_negative(value)) handler_.on_error("negative width"); + if (is_negative(value)) throw_format_error("negative width"); return static_cast(value); } template ::value)> FMT_CONSTEXPR auto operator()(T) -> unsigned long long { - handler_.on_error("width is not integer"); + throw_format_error("width is not integer"); return 0; } - - private: - ErrorHandler& handler_; }; -template class precision_checker { - public: - explicit FMT_CONSTEXPR precision_checker(ErrorHandler& eh) : handler_(eh) {} - +struct precision_checker { template ::value)> FMT_CONSTEXPR auto operator()(T value) -> unsigned long long { - if (is_negative(value)) handler_.on_error("negative precision"); + if (is_negative(value)) throw_format_error("negative precision"); return static_cast(value); } template ::value)> FMT_CONSTEXPR auto operator()(T) -> unsigned long long { - handler_.on_error("precision is not integer"); + throw_format_error("precision is not integer"); return 0; } - - private: - ErrorHandler& handler_; }; -template